156
156
157
157
from OCP .TopExp import TopExp
158
158
159
- from OCP .ShapeFix import ShapeFix_Shape , ShapeFix_Solid
159
+ from OCP .ShapeFix import ShapeFix_Shape , ShapeFix_Solid , ShapeFix_Face
160
160
161
161
from OCP .STEPControl import STEPControl_Writer , STEPControl_AsIs
162
162
@@ -2100,7 +2100,12 @@ def makeFromWires(
2100
2100
if not BRepLib_FindSurface (ws .wrapped , OnlyPlane = True ).Found ():
2101
2101
raise ValueError ("Cannot build face(s): wires not planar" )
2102
2102
2103
- face_builder = BRepBuilderAPI_MakeFace (outerWire .wrapped , True )
2103
+ # fix outer wire
2104
+ sf_s = ShapeFix_Shape (outerWire .wrapped )
2105
+ sf_s .Perform ()
2106
+ wo = TopoDS .Wire_s (sf_s .Shape ())
2107
+
2108
+ face_builder = BRepBuilderAPI_MakeFace (wo , True )
2104
2109
2105
2110
for w in innerWires :
2106
2111
face_builder .Add (w .wrapped )
@@ -2110,9 +2115,13 @@ def makeFromWires(
2110
2115
if not face_builder .IsDone ():
2111
2116
raise ValueError (f"Cannot build face(s): { face_builder .Error ()} " )
2112
2117
2113
- face = face_builder .Shape ()
2118
+ face = face_builder .Face ()
2119
+
2120
+ sf_f = ShapeFix_Face (face )
2121
+ sf_f .FixOrientation ()
2122
+ sf_f .Perform ()
2114
2123
2115
- return cls (face ). fix ( )
2124
+ return cls (sf_f . Result () )
2116
2125
2117
2126
@classmethod
2118
2127
def makeSplineApprox (
@@ -2127,7 +2136,7 @@ def makeSplineApprox(
2127
2136
Approximate a spline surface through the provided points.
2128
2137
2129
2138
:param points: a 2D list of Vectors that represent the points
2130
- :param tol: tolerance of the algorithm (consult OCC documentation).
2139
+ :param tol: tolerance of the algorithm (consult OCC documentation).
2131
2140
:param smoothing: optional tuple of 3 weights use for variational smoothing (default: None)
2132
2141
:param minDeg: minimum spline degree. Enforced only when smothing is None (default: 1)
2133
2142
:param maxDeg: maximum spline degree (default: 6)
0 commit comments