OK, I found a trick how to keep the canonical curve. See
git commit 1073d06
The trick is to use BRepAdaptor_Curve and then for each canonical curve recreate the edge the using this curve and the boundaries. This way a 3d curve is created. If the curve type is unknown BRepLib::BuildCurves3d is used to create a B-spline.
Code: Select all
from FreeCAD import Base
import Part
obj = App.ActiveDocument.addObject("Part::Cylinder","Cylinder")
App.ActiveDocument.recompute()
shp = obj.Shape
elt = shp.Face1
# helix
l2d = Part.Geom2d.Line2dSegment(Base.Vector2d(0,0),Base.Vector2d(6.283185307179586,10.0))
edge = l2d.toShape(elt.Surface)
Part.show(edge)
edge.Curve
edge.check()
# line
l2d = Part.Geom2d.Line2dSegment(Base.Vector2d(0,0),Base.Vector2d(6.283185307179586,10.0))
edge = l2d.toShape(Part.Plane())
Part.show(edge)
edge.Curve
edge.check()
# circle
import math
l2d = Part.Geom2d.Line2dSegment(Base.Vector2d(0,0),Base.Vector2d(2*math.pi,0.0))
edge = l2d.toShape(elt.Surface)
Part.show(edge)
edge.Curve
edge.check()
# arc of circle
import math
l2d = Part.Geom2d.Line2dSegment(Base.Vector2d(0,0),Base.Vector2d(math.pi,0.0))
edge = l2d.toShape(elt.Surface)
Part.show(edge)
edge.Curve
edge.check()