--
cadquery home: https://github.com/dcowden/cadquery
post issues at https://github.com/dcowden/cadquery/issues
run it at home at : https://github.com/jmwright/cadquery-freecad-module
see it in action at http://www.parametricparts.com
---
You received this message because you are subscribed to the Google Groups "CadQuery" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cadquery+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cadquery/9bb50069-0729-477a-94c7-03fa860e4d2do%40googlegroups.com.
import cadquery as cq
from OCP.GCPnts import GCPnts_QuasiUniformDeflection
from OCP.ShapeAnalysis import ShapeAnalysis_FreeBounds
from OCP.TopTools import TopTools_HSequenceOfShape
from OCP.BRepBuilderAPI import BRepBuilderAPI_MakeFace
from OCP.BRepOffsetAPI import BRepOffsetAPI_MakeFilling
from OCP.GeomAbs import GeomAbs_C0, GeomAbs_C1
def split_faces(obj):
rv_spline = []
rv_regular = []
for f in obj.Faces():
if any(e.geomType()=='BSPLINE' for e in f.Edges()):
rv_spline.append(f)
else:
rv_regular.append(f)
return rv_spline,rv_regular
def transform_bspline(e,tol=1e-3):
curve = e._geomAdaptor() # adapt the edge into curve
start = curve.FirstParameter()
end = curve.LastParameter()
points = GCPnts_QuasiUniformDeflection(curve, tol, start, end)
return cq.Wire.makePolygon((cq.Vector(points.Value(i + 1)) for i in range(points.NbPoints())))
def makeNSidedSurface(
face,
edges,
continuity=GeomAbs_C0,
degree=2,
nbPtsOnCur=15,
nbIter=2,
anisotropy=False,
tol2d=0.00001,
tol3d=0.0001,
tolAng=0.01,
tolCurv=0.1,
maxDeg=8,
maxSegments=9,
):
n_sided = BRepOffsetAPI_MakeFilling(
degree,
nbPtsOnCur,
nbIter,
anisotropy,
tol2d,
tol3d,
tolAng,
tolCurv,
maxDeg,
maxSegments,
)
for edge in edges:
n_sided.Add(edge.wrapped, continuity)
n_sided.LoadInitSurface(face)
n_sided.Build()
face = n_sided.Shape()
return cq.Shape.cast(face).fix()
def transform_spline_face(f):
edges = []
for e in f.Edges():
if e.geomType() != 'BSPLINE':
edges.append(e)
else:
edges.extend(transform_bspline(e).Edges())
# edges to wires
wires_out = TopTools_HSequenceOfShape()
edges_in = TopTools_HSequenceOfShape()
for el in edges: edges_in.Append(el.wrapped)
ShapeAnalysis_FreeBounds.ConnectEdgesToWires_s(edges_in, 1e-6, False, wires_out)
wires = [cq.Shape.cast(el) for el in wires_out]
bldr = BRepBuilderAPI_MakeFace(wires[0].wrapped,False)
for w in wires[1:]:
bldr.Add(w.wrapped)
bldr.Build()
if bldr.IsDone():
return cq.Shape.cast(bldr.Shape())
else:
return makeNSidedSurface(f.wrapped,wires[0].Edges(),[],degree=2)
solid = (
cq.Workplane('XY')
.polyline([(1,1), (1,2)])
.spline([(1,2),(2,4),(3,2)])
.polyline([(3,2), (3,1)])
.threePointArc((2,0),(1,1))
.close()
.extrude(1)
)
spline_faces,regular_faces = split_faces(solid.val())
transformed_faces = [transform_spline_face(f) for f in spline_faces]
sh = cq.Shell.makeShell(transformed_faces+regular_faces)
s = cq.Solid.makeSolid(sh)
show_object(s)
return makeNSidedSurface(f.wrapped,wires[0].Edges(),degree=2)
--
cadquery home: https://github.com/dcowden/cadquery
post issues at https://github.com/dcowden/cadquery/issues
run it at home at : https://github.com/jmwright/cadquery-freecad-module
see it in action at http://www.parametricparts.com
---
You received this message because you are subscribed to the Google Groups "CadQuery" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cadquery+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cadquery/76e683ee-c15c-48e2-980d-9ef6e9c06a87o%40googlegroups.com.
--
cadquery home: https://github.com/CadQuery/cadquery
post issues at https://github.com/CadQuery/cadquery/issues
run it at home at : https://github.com/CadQuery/CQ-editor
---
You received this message because you are subscribed to the Google Groups "CadQuery" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cadquery+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cadquery/b39ed124-938c-4627-a874-9d3b3aaa667en%40googlegroups.com.
You received this message because you are subscribed to a topic in the Google Groups "CadQuery" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cadquery/Ia84dtcnCo0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cadquery+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cadquery/603e564a-a82a-4660-9240-636158770dabn%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cadquery/CAHh5t2nJbqMo4Nqg0mv3%2BZXSvoH-JieBcewA%2BfMAdPCMP_-6Rg%40mail.gmail.com.