
Thu, 04/27/2023 - 13:17
Guys, i produce BRepPrimAPI_MakeRevol of simple rect profile and after i can't find any normal wires/edges data inside shape entity, why? In case of BRepPrimAPI_MakePrism -> all ok, but BRepPrimAPI_MakeRevol doesn't work properly for wires/edges...
I do:
BRepPrimAPI_MakeRevol -> shape
...
uint32_t c1 = 0;
for (TopExp_Explorer ex0(shape, TopAbs_WIRE); ex0.More(); ex0.Next())
{
TopoDS_Wire wire = TopoDS::Wire(ex0.Current());
std::cout << "=========WIRE: " << c1++ << std::endl;
int c2 = 0;
for (TopExp_Explorer ex1(wire, TopAbs_EDGE); ex1.More(); ex1.Next())
{
std::cout << "+++++++EDGE: " << c2++ << std::endl;
TopoDS_Edge edge = TopoDS::Edge(ex1.Current());
for (TopExp_Explorer ex2(edge, TopAbs_VERTEX); ex2.More(); ex2.Next())
{
TopoDS_Vertex vertex = TopoDS::Vertex(ex2.Current());
gp_Pnt p = BRep_Tool::Pnt(vertex);
std::cout << "\t" << p.X() << " " << p.Y() << " " << p.Z() << std::endl;
}
}
}
and result looks like crap... No desired circular edges... Hmm, any ideas?
=========WIRE: 0
+++++++EDGE: 0
-100 0 200
-100 0 200
+++++++EDGE: 1
100 0 200
100 0 200
+++++++EDGE: 2
-100 0 200
100 0 200
+++++++EDGE: 3
-100 0 200
100 0 200
=========WIRE: 1
+++++++EDGE: 0
-100 0 100
-100 0 100
=========WIRE: 2
+++++++EDGE: 0
-100 0 200
-100 0 200
=========WIRE: 3
+++++++EDGE: 0
100 0 100
100 0 100
+++++++EDGE: 1
-100 0 100
-100 0 100
+++++++EDGE: 2
100 0 100
-100 0 100
+++++++EDGE: 3
100 0 100
-100 0 100
=========WIRE: 4
+++++++EDGE: 0
100 0 200
100 0 200
=========WIRE: 5
+++++++EDGE: 0
100 0 100
100 0 100
Thu, 04/27/2023 - 14:27
Hello, unfortunately, I'm not very familiar with the BRepPrimAPI_MakeRevol function. However, I think your result is valid.
As far as I can see, you have received a surface of revolution. The faces built using this type of surface have natural boundaries and do not require any additional boundaries such as wires.
Best regards, Dmitrii
Thu, 04/27/2023 - 14:53
Well, i guess i have to additionally rotate my vertices of sketch profile by BRepPrimAPI_MakeRevol to get edges. I'll try it now and let you know what happens.
Thu, 04/27/2023 - 15:38
It looks like a bug, nothing works. Vertices also don't rotate around axis to form edges... I do this:
int ccc = 0;
std::unordered_map<glm::dvec3, TopoDS_Vertex> ds;
for (TopExp_Explorer ex0(face, TopAbs_VERTEX); ex0.More(); ex0.Next())
{
TopoDS_Vertex vertex = TopoDS::Vertex(ex0.Current());
gp_Pnt p = BRep_Tool::Pnt(vertex);
ccc++;
glm::dvec3 dp(p.X(), p.Y(), p.Z());
ds.insert({ dp, vertex });
}
int vc = 0;
for (auto& it : ds)
{
BRepPrimAPI_MakeRevol revolve(it.second, revAxis, Standard_True);
if (!revolve.IsDone())
return false;
TopoDS_Shape revEdge = revolve.Shape();
TopAbs_ShapeEnum revEdgeType = revEdge.ShapeType();
int ec = 0;
//std::vector<glm::dvec3> edgeVertices;
for (TopExp_Explorer ex0(revEdge, TopAbs_VERTEX); ex0.More(); ex0.Next())
{
TopoDS_Vertex vertex = TopoDS::Vertex(ex0.Current());
gp_Pnt p = BRep_Tool::Pnt(vertex);
glm::dvec3 dp(p.X(), p.Y(), p.Z());
//edgeVertices.emplace_back(dp);
std::cout << "ROTATED VERTEX#" << vc << " DOT#" << ec << "\t:" << dp.x << " " << dp.y << " " << dp.z << std::endl;
ec++;
}
vc++;
}
and taking:
ROTATED VERTEX#0 DOT#0 :100 0 100
ROTATED VERTEX#0 DOT#1 :100 0 100
ROTATED VERTEX#1 DOT#0 :-100 0 200
ROTATED VERTEX#1 DOT#1 :-100 0 200
ROTATED VERTEX#2 DOT#0 :-100 0 100
ROTATED VERTEX#2 DOT#1 :-100 0 100
ROTATED VERTEX#3 DOT#0 :100 0 200
ROTATED VERTEX#3 DOT#1 :100 0 200
Look at attached image
Thu, 04/27/2023 - 15:54
Im very interested on type if Edge curve, that generated.
Can you share result brep file after generation? You can just Write TopoDS_Shape into file using follow code:
Im interested in full result and rotating of vertexes. Can you share types of generated edges? It looks like a circle. If it is a circle, you be able to recieve a point on curve by getting value from pereodic (for example aCircle->Value(Pi))
Best regards, Dmitrii.
Thu, 04/27/2023 - 16:15
ok, look at my revovle-dump files, i don't understand them :)
Thu, 04/27/2023 - 16:29
I was right. It is a circle. Now you be able to recieve a "gp_Pnt aPont = aCurve->Value(M_PI)"; or any other pereodic values.
Circle shareds one vertex for start and end with different orientation. So, as a result you recieve a start and end point in the same place.
Best regards, Dmitrii.
Thu, 04/27/2023 - 16:42
"Circle shareds one vertex for start and end with different orientation. So, as a result you recieve a start and end point in the same place."
Aha!! Now I begin to understand :) Thank's man, but how to convert WIRE to CURVE?
Here is "shape" -> full revolve result, now i scan it for a wires...
for (TopExp_Explorer ex0(shape, TopAbs_WIRE); ex0.More(); ex0.Next())
{
TopoDS_Wire wire = TopoDS::Wire(ex0.Current());
//1) how to get aCurve from wire?
//2) and how to check "is wire a circle-curve or simple segment"?
gp_Pnt aPont = aCurve->Value(M_PI);
}
Thu, 04/27/2023 - 16:45
To get a Handle(Geom_Curve) from a TopoDS_Edge that is contained in a TopoDS_Wire, you need to first extract the TopoDS_Edge from the TopoDS_Wire and then get the Handle(Geom_Curve) from the TopoDS_Edge.
Here is an example code to get a Handle(Geom_Curve) from a TopoDS_Edge that is contained in a TopoDS_Wire:
Best regards, Dmitrii.
Thu, 04/27/2023 - 16:55
"Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdge);"
Wow, cool, so easy, but how to determinate is aCurve a circle or simple segment or spline or something else?
I mean, if aCurve is just a segment, i don't need to interpolate it by aCurve->Value(M_PI)...
Thu, 04/27/2023 - 17:00
Thu, 04/27/2023 - 17:06
Ohh man, thank you very much! Your OCCT level - THE GOD! :-)
Last question:
In OCCT paradigm, Handle(Geom_Curve) -> self destroying smart pointer, which will deleted out of scope, right?
Thu, 04/27/2023 - 17:21
Yes, but it has a little different from std::shared_pointer or other std smart pointeres. It it the same with boost::intrusive_ptr
In any case, as you said, the Handle object will be destroyed as soon as it's no longer needed.
Regarding Geom_Curve, it can be a simple curve, as described earlier, but in some cases it can also be a Handle(Geom_TrimmedCurve), which has additional UV limitations and a basic simple curve that you might need.
Best regards, Dmitrii.
Thu, 04/27/2023 - 17:51
I made it! But how to exclude base profile from existing wires in revolve resulting shape?
Thu, 04/27/2023 - 18:44
It is possible only in visualization part to disable render edge.
Unfortunatelly, I don't know the Vis API.
Best regards, Dmitrii.
Thu, 04/27/2023 - 19:00
I don't use built-in OCCT visualizer, I write my own render on Vulkan API.
Thanks again for help, I will find solution myself, most likely i just need to compare wires with the base profile and if it matches completely, exclude it.
Thu, 04/27/2023 - 17:26
Thank you more buddy!