Tessellate edges from a TopoDS_Shape
Submitted by Marco on 14 March, 2021 - 11:36
Forums:
Hi,
I need to get all contours which are within a STEP file and to process them. I need the curves as point list. Therefore, I need to tessellate the edges of my shape.
Atm I read the step file and iterate over the edges. I found some examples how to triangulate a face, but nothing about the edges.
So how can I get a nice tessellation of my edges?
STEPControl_Reader reader;
if (reader.ReadFile("pipe.stp") != IFSelect_RetDone)
return -1;
// Root transfers
reader.TransferRoots();
//
auto nbs = reader.NbShapes();
for (Standard_Integer i = 1; i <= nbs; ++i)
{
auto shape = reader.Shape(i);
TopExp_Explorer ex_ed;
for (ex_ed.Init(aMesh.Shape(), TopAbs_EDGE); ex_ed.More(); ex_ed.Next())
{
BRepAdaptor_Curve adapt_crv = BRepAdaptor_Curve(TopoDS::Edge(ex_ed.Current()));
//how to tesselate my edge/curve into a vector of points
}
}
BRepMesh_IncrementalMesh
BRepMesh_IncrementalMesh creates tessellation for both - Faces and Edges.
The latter hold Poly_Polygon3D (defining polyline) or Poly_PolygonOnTriangulation (defining indexes of Poly_Triangulation nodes on a Face)
and accessible in the same matter as triangulation of Face - using methods BRep_Tool::Polygon3D() and BRep_Tool::PolygonOnTriangulation().
You may also use tools like GCPnts_TangentialDeflection/GCPnts_QuasiUniformDeflection on specific curve if you don't want to use BRepMesh_IncrementalMesh.
Thank you very much for the
Thank you very much for the hint!
Do you have some short example code how to use it proper?
OK, I found a general
OK, I found a general solution with GCPnts_TangentialDeflection (see example code below).
But I have a problem with a pipe. My pipe is defined by end contours (outer and inner on the left and on the right) which are connected. So you got 2 cylindrical surfaces and 2 connecting surfaces (a special case would be a hollow cylinder)
I only want to have the curves which defines the contours. But when iterating over the content of my STEP file with the below code, I also got connection lines between the left and right contours (see attached example image)
Why is OC introducing these curves? How can I prevent this?
Hello Marco,
Hello Marco,
As the forum moved to Development Portal, please post your questions there: https://dev.opencascade.org/forums/usage-issues
Thank you.
Hello OCC,
Hello OCC,
In the new development portal I no longer receive emails from the forum?
These lines are so-named
These lines are so-named 'seam' edges. They are needed to close the cylinder in 2D parametric space. Without them the shape would be considered invalid from point of view of OCCT data model. You can ignore them in your code by querying BRep_Tool::IsClosed (edge, face). For that, you need to explore your shape on faces, then explore each face on edges.
Hi Mikhail Sazonov,
Hi Mikhail Sazonov,
thank you very much. That works!
One further question. Must I take care about getting the same edges multiple times? When iterating over the faces of the shapes, I suppose that I get every edge twice, because the faces share edges. Is this right?
Thank you!
Yes, it's right.
Yes, it's right.
Him,
Hi,
I tried the following to detect the double edges: I push all 'used' edges into a std::vector. And when iterating over the edges of a face, I first check, if the Edge is already in the vector with the help of 'IsEqual'.
But this doesn't work. How can I test if two TopoDS_Edge objects refer to the same edge in the solid?
Use IsSame(). It ignores
Use IsSame(). It ignores orientation.
Thank you very much! That
Thank you very much! That works!