Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetShellPoints of a component #478

Open
SunilApte opened this issue May 24, 2024 · 1 comment
Open

GetShellPoints of a component #478

SunilApte opened this issue May 24, 2024 · 1 comment

Comments

@SunilApte
Copy link

SunilApte commented May 24, 2024

We are replacing HOOPS code by using Xbim.
We are able to replace the model loading and showing on desktop application.

We need to get shell points of any component. Specifically IfcGeographicElement.
Function using HOOPS is as follows:

public void GetShellPointsOfComponent(HPS.Component component, out List<HPS.Point> shellPoint, out List<int> faces, out List<int[]> FacesSet,
            List<Mathematical_Utility.Point> mathPoints=null)
        {
            FacesSet = new List<int[]>();

            shellPoint = new List<HPS.Point>(); 
            faces = new List<int>();
            HPS.Component[] children = component.GetSubcomponents();
            if (children.Length > 0)
            {
                //HPS.Component[] SubComponents = children[0].GetSubcomponents();
                foreach (HPS.Component comp1 in children)
                {
                    foreach (HPS.Component comp in comp1.GetSubcomponents())
                    {
                        HPS.Component.ComponentType compType = comp.GetComponentType();

                        if (compType == HPS.Component.ComponentType.ExchangeRIPolyBRepModel)
                        {
                            Exchange.Component exchComponent = new Exchange.Component(comp);
                            HPS.Key[] keys = exchComponent.GetKeys();
                            Stack<HPS.Component> componentStack2 = new Stack<HPS.Component>();
                            componentStack2.Push(comp);
                            HPS.ComponentPath ComponentPath2 = new ComponentPath(componentStack2.ToArray());
                            KeyPath[] paths = ComponentPath2.GetKeyPaths();
                            paths[0].ShowNetModellingMatrix(out MatrixKit mKit);

                            foreach (HPS.Key key in keys)
                            {

                                if (key.Type() == HPS.Type.SegmentKey)
                                {
                                    HPS.SegmentKey segKey = new HPS.SegmentKey(key);
                                    _ = segKey.Find(Search.Type.Geometry,       // searching for geometry
                                                                        Search.Space.SegmentOnly,  // within all this segment
                                                                         out SearchResults searchResults);
                                    HPS.SearchResultsIterator it = searchResults.GetIterator();

                                    while (it.IsValid())
                                    {
                                        HPS.Key geomKey = it.GetItem();
                                        HPS.Type geomKeyType = geomKey.Type();
                                        if (geomKeyType == HPS.Type.ShellKey)
                                        {
                                            HPS.ShellKey shellKey = new ShellKey(geomKey);
                                            HPS.Point[] shellPoints;
                                            shellKey.ShowPoints(out shellPoints);
                                            int k = 0;
                                            foreach (HPS.Point point in shellPoints)
                                            {
                                                HPS.Point temp = mKit.Transform(point);
                                                shellPoints[k] = temp;
                                                if (mathPoints != null)
                                                    mathPoints.Add(new Mathematical_Utility.Point(temp.x, temp.y, temp.z));
                                                k++;
                                            }
                                            shellPoint.AddRange(shellPoints.ToList());
                                            
                                        }
                                        it.Next();
                                    }

                                }
                            }
                        }
                    }
                }
            }
        }

How can we write similar function in xbim?

@andyward andyward transferred this issue from xBimTeam/XbimWindowsUI May 24, 2024
@andyward
Copy link
Member

I'm assuming what you want to do is output a mesh for each component?

Probably worth a look at https://github.com/xBimTeam/XbimEssentials/blob/master/Xbim.Tessellator/XbimTessellator.cs

You could also look at how the GlTF exporter works: https://github.com/xBimTeam/XbimGltf/blob/develop/Xbim.GLTF.IO/XbimMesher.cs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants