Thu, 01/27/2022 - 09:06
I am creating a prism shape using 'BRepPrimAPI_MakePrism' API. For a simple use-case I have created three edges, then a TopoDS_Wire triangle from these edges, then used this wire to create a TopoDS_Face using 'BRepBuilderAPI_MakeFace'.
So far so good, the MakeFace api is able to generate a prism.
I am now trying to get 'Generated' shapes from the edges I created. I am not able to get any generated shapes from one of the edges in the list. How is this possible? Because I have created Face >> Wire from these edges only! I got the same results while using 'BRepTools_History' api.
I am using 7.5.0, I downloaded older releases, like 6.9.0, etc. In the older versions it seems to work.
Please help,
Thanks.
Here is the sample I am trying to work with:
gp_Pnt aPnt1(0., 0, 0);
gp_Pnt aPnt2(100.0, 0.0, 0.0);
gp_Pnt aPnt3(50.0, 100.0, 0.0);
Handle(Geom_TrimmedCurve) aSegment1 = GC_MakeSegment(aPnt1, aPnt2);
Handle(Geom_TrimmedCurve) aSegment2 = GC_MakeSegment(aPnt2, aPnt3);
Handle(Geom_TrimmedCurve) aSegment3 = GC_MakeSegment(aPnt3, aPnt1);
TopoDS_Edge anEdge1 = BRepBuilderAPI_MakeEdge(aSegment1);
TopoDS_Edge anEdge2 = BRepBuilderAPI_MakeEdge(aSegment2);
TopoDS_Edge anEdge3 = BRepBuilderAPI_MakeEdge(aSegment3);
std::vector<TopoDS_Edge> edges;
edges.push_back(anEdge1);edges.push_back(anEdge2); edges.push_back(anEdge3);
TopoDS_Wire aWire = BRepBuilderAPI_MakeWire(anEdge1, anEdge2, anEdge3);
TopoDS_Face face = BRepBuilderAPI_MakeFace(aWire, Standard_True);
gp_Vec vector(0.0 , 0.0, 20.0);
BRepPrimAPI_MakePrism mkPrism(face, vector, Standard_True, Standard_True);
if (!mkPrism.IsDone()) {
std::stringstream s;
s << "Extrude failed." << std::endl;
}
TopoDS_Shape extrudeShape = mkPrism.Shape();
std::vector<TopoDS_Shape> shapes;
for (size_t sz = 0; sz < edges.size(); ++sz)
{
const TopoDS_Shape &F = mkPrism.Generated(edges[sz]).First(); // THIS LINE ALWAYS FAILS FOR "edge2"!
shapes.push_back(F);
}
Fri, 02/04/2022 - 16:08
Any comments/suggestions please? I am blocked here actually. Thank you.
Fri, 02/04/2022 - 20:33
Your use of GC_MakeSegment is a little unorthodox. With that method you are creating 3 edges and 6 vertices and thus the edges are not topologically connected. The edges get stored in the vector in this state. Then when you run the edges through BRepBuilderAPI_MakeWire, it does what is expected and connects the edges by making them share 3 vertices. When that happens, the edges are changed are not the same edges you stored in the vector.
replace this:
gp_Pnt aPnt1(0., 0, 0);
gp_Pnt aPnt2(100.0, 0.0, 0.0);
gp_Pnt aPnt3(50.0, 100.0, 0.0);
Handle(Geom_TrimmedCurve) aSegment1 = GC_MakeSegment(aPnt1, aPnt2);
Handle(Geom_TrimmedCurve) aSegment2 = GC_MakeSegment(aPnt2, aPnt3);
Handle(Geom_TrimmedCurve) aSegment3 = GC_MakeSegment(aPnt3, aPnt1);
TopoDS_Edge anEdge1 = BRepBuilderAPI_MakeEdge(aSegment1);
TopoDS_Edge anEdge2 = BRepBuilderAPI_MakeEdge(aSegment2);
TopoDS_Edge anEdge3 = BRepBuilderAPI_MakeEdge(aSegment3);
with this:
TopoDS_Vertex v0 = BRepBuilderAPI_MakeVertex(gp_Pnt(0.0, 0.0, 0.0));
TopoDS_Vertex v1 = BRepBuilderAPI_MakeVertex(gp_Pnt(100.0, 0.0, 0.0));
TopoDS_Vertex v2 = BRepBuilderAPI_MakeVertex(gp_Pnt(50.0, 100.0, 0.0));
TopoDS_Edge anEdge1 = BRepBuilderAPI_MakeEdge(v0, v1);
TopoDS_Edge anEdge2 = BRepBuilderAPI_MakeEdge(v1, v2);
TopoDS_Edge anEdge3 = BRepBuilderAPI_MakeEdge(v2, v0);
Wed, 03/30/2022 - 12:48
@Thomas Anderson
Yes, that worked!
I took the reference from OCC Tutorial actually and there I saw the use of 'GC_MakeSegment'.
But now as you explained, it is clear to me what 'BRepBuilderAPI_MakeWire' does. As it modifies the edges themselves, Generated() returns an empty list, as there are in fact no generated objects from those edges!
Thank you.