Fri, 03/11/2022 - 18:15
Hi,
I'm trying to make an offset tool in FreeCad sketcher. And for this I'm trying to do :
1) get wires from Part::Geometry (a Freecad sketcher class which can provide a Handle(Geom_Curve) that is turned to TopoDS_Edge with BRepBuilderAPI_MakeEdge)
2) offset wires with BRepOffsetAPI_MakeOffset
3) add the obtained edges to FreeCad sketcher object.
To create the line in FreeCad sketcher I need a const Handle(Geom_Line).
How can I get a Handle(Geom_Line) from a TopoDS_Edge ?
So basically the reverse of BRepBuilderAPI_MakeEdge. It seems trivial but somehow I just can't find the answer.
Note: currently I found this snippet but it's loosing the parameters which print crazy values (in line case but not in circle case!!!).
BRepAdaptor_Curve adapt(my_TopoDS_Edge);
GeomAdaptor_Curve gAdapt = adapt.Curve();
Base::Console().Warning("gadapt2->FirstParameter: %f\n", gAdapt.FirstParameter());
Base::Console().Warning("gadapt2->LastParameter: %f\n", gAdapt.LastParameter());
const Handle(Geom_Curve) c = gAdapt.Curve();
Base::Console().Warning("c->FirstParameter: %f\n", c->FirstParameter());
Base::Console().Warning("c->LastParameter: %f\n", c->LastParameter());
gadapt2->FirstParameter prints correct parameters
c->FirstParameter prints -20000000000000000318057822195198360936721617127890562779562655115495677544340762121626939971713630208.000000
It might be a bug because someone repported such issues : https://github.com/tpaviot/pythonocc-core/issues/1057
Sat, 03/12/2022 - 01:44
Geom_Line has an infinite range since line has no ends (until it is not trimmed via Geom_TrimmedCurve or via topological vertices forming a line segment), why you expect something else?
Sat, 03/12/2022 - 17:32
Thanks for your reply!
Why did I expect something else ? The question is rather how would I know what to expect. Information is rather scarce to be honest. The difference between TopoDS_Edge and Geom_curve may be obvious for experts, but for newcomers it's hard to get a clear understanding of all that.
Anyway the issue is solved after finding some code in freecad doing something similar to what I needed.
Sat, 03/12/2022 - 18:52
The high-level description of B-Rep cannot be easily determined by reading description of C++ classes. For that, Training materials (Geometry) and documentation could be helpful. Otherwise, you may easily end-up asking wrong questions difficult to answer.