GetShellPoints of a component
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?
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
Closing. Please re-open if you need more help