How to create Face from edges?

Technical discussions
Post Reply
Gin Chun
Posts: 1
Joined: Sun May 03, 2020 4:05 am

How to create Face from edges?

Post by Gin Chun »

A compound that only contain edges from intersection operation which one big box contain small box,
the compound only contains 12 edges, is there anyway to create faces from the compound?
thanks very much

Prashant Kande
Posts: 121
Joined: Mon Apr 04, 2016 4:55 am

Re: How to create Face from edges?

Post by Prashant Kande »

Hi Gin
I assume the edges come from another software? Also, boxes have non-trivial intersection, otherwise no point talking about two boxes. So I guess you are asking how to build a solid out of set of edges, knowing the faces are planar.

First, I suggest extracting list of the edges using
iCompound >(query) IBRepShape_DG > GetSubShapes(ShapeType_DG.eShTypeEdgeDG)

You need to assume the edges do not share vertices. So you would need to code a small method which checks if two edges are connected geometrically up to a tolerance.
IBRepEdge_DG > GetEndVertex() > GetPosition1() > Point_DG > PointDg > Dist()
The last two steps here use the C# client side wrapper. See any C# sample.

For every two connected edges you can get a containing plane:

Code: Select all

IObjectGenerator_DG m_iGener;
IPlane_DG iPlane = m_iGener.Create("Plane_DG") as IPlane_DG;
iPlane.Init(point0, point1, point2);
See also FaceForm.CreatePlane() in Face sample. The points here are ends of the edges.

You can extend the pair by searching for connected edges which lie in the plane. Check an edge belongs to the plane can be done with
IPlane_DG.GetPointLocation() for each edge end.

This way you can build wires for every face. Or rather sequences of geometrically connected edges (loops). The process of extending should stop when a loop becomes closed. Otherwise the input is invalid.

When this is done you can build a solid from scratch using sequences of points from each loop. The edges cannot be reused as they do not share vertices.

Code: Select all

IBRepSolid_DG iSolid = m_iGener.Create("BRepSolid_DG") as IBRepSolid_DG;
Or

Code: Select all

IEntity_DG iEntity = IModel_DG.AddNewBRepSolid();
IBRepGeometry_DG iBRepGeom = iEntity.GetGeometry() as IBRepGeometry_DG;
IBRepSolid_DG iSolid = iBRepGeom.GetShape() as IBRepSolid_DG;

Code: Select all

IBRepShell_DG iShell = iSolid.GetOuterShell(true);		// Create
// For each loop
I2DPointArray_DG uvLoop;
// Add points to the loop
IBRepFace_DG iFace = iShell.AddNewFace();
iFace.AddWire1(I2DPointArray_DG uvLoop)
Good luck

Post Reply