@@ -574,20 +574,20 @@ def make_constrained_surface_from_edges(edges): #, w
574574 '''
575575 DOESNT RESPECT BOUNDARIES
576576 '''
577- from Plate import GeomPlate_MakeApprox , GeomPlate_BuildPlateSurface
577+ from OCC . Core . GeomPlate import GeomPlate_MakeApprox , GeomPlate_BuildPlateSurface
578578 from OCC .Core .BRepFill import BRepFill_CurveConstraint
579579 bpSrf = GeomPlate_BuildPlateSurface (3 , 15 , 2 )
580580 for edg in edges :
581581 c = BRepAdaptor_HCurve ()
582582 c .ChangeCurve ().Initialize (edg )
583583 constraint = BRepFill_CurveConstraint (c .GetHandle (), 0 )
584- bpSrf .Add (constraint . GetHandle () )
584+ bpSrf .Add (constraint )
585585 bpSrf .Perform ()
586586 maxSeg , maxDeg , critOrder = 9 , 8 , 0
587587 tol = 1e-4
588588 srf = bpSrf .Surface ()
589589 plate = GeomPlate_MakeApprox (srf , tol , maxSeg , maxDeg , tol , critOrder )
590- uMin , uMax , vMin , vMax = srf .GetObject ().Bounds ()
590+ uMin , uMax , vMin , vMax = srf .Bounds () #srf. GetObject().Bounds()
591591 face = make_face (plate .Surface (), uMin , uMax , vMin , vMax )
592592 #face = make_face(srf, w, False) #plate.Surface(), uMin, uMax, vMin, vMax)
593593 return face
@@ -610,7 +610,7 @@ def add_wire_to_face(face, wire, reverse=False):
610610 return result
611611
612612
613- def sew_shapes (shapes , tolerance = 0.001 ):
613+ def sew_shapes (shapes , tolerance = 0.001 , verbose = True ):
614614 sew = BRepBuilderAPI_Sewing (tolerance )
615615 for shp in shapes :
616616 if isinstance (shp , list ):
@@ -619,10 +619,11 @@ def sew_shapes(shapes, tolerance=0.001):
619619 else :
620620 sew .Add (shp )
621621 sew .Perform ()
622- print ("n degenerated shapes" , sew .NbDegeneratedShapes ())
623- print ("n deleted faces:" , sew .NbDeletedFaces ())
624- print ("n free edges" , sew .NbFreeEdges ())
625- print ("n multiple edges:" , sew .NbMultipleEdges ())
622+ if verbose :
623+ print ("n degenerated shapes" , sew .NbDegeneratedShapes ())
624+ print ("n deleted faces:" , sew .NbDeletedFaces ())
625+ print ("n free edges" , sew .NbFreeEdges ())
626+ print ("n multiple edges:" , sew .NbMultipleEdges ())
626627 result = ShapeToTopology ()(sew .SewedShape ())
627628 return result , sew
628629
@@ -675,7 +676,7 @@ def trim_wire(wire, shapeLimit1, shapeLimit2, periodic=False):
675676 adap = to_adaptor_3d (wire )
676677 bspl = adap .BSpline ()
677678 if periodic :
678- spl = bspl .GetObject ()
679+ spl = bspl # .GetObject()
679680 if spl .IsClosed ():
680681 spl .SetPeriodic ()
681682 else :
@@ -695,7 +696,7 @@ def fix_shape(shp, tolerance=1e-3):
695696 from OCC .ShapeFix import ShapeFix_Shape
696697 fix = ShapeFix_Shape (shp )
697698 fix .SetFixFreeShellMode (True )
698- sf = fix .FixShellTool ().GetObject ()
699+ sf = fix .FixShellTool () # .GetObject()
699700 sf .SetFixOrientationMode (True )
700701 fix .LimitTolerance (tolerance )
701702 fix .Perform ()
@@ -709,6 +710,24 @@ def fix_face(shp, tolerance=1e-3):
709710 fix .Perform ()
710711 return fix .Face ()
711712
713+ def fix_small_faces (shp , prec , tolerance = 1e-3 ):
714+ from OCC .ShapeFix import ShapeFix_FixSmallFace
715+ fix = ShapeFix_FixSmallFace ()
716+ fix .Init (shp )
717+ fix .SetPrecision (prec )
718+ fix .SetMaxTolerance (tolerance )
719+ fix .Perform ()
720+ return fix .FixShape ()
721+
722+ def fix_solid (shp , tolerance = 1e-3 ):
723+ from OCC .ShapeFix import ShapeFix_Solid
724+ fix = ShapeFix_Solid (shp )
725+ fix .SetCreateOpenSolidMode (True )
726+ fix .SetMaxTolerance (tolerance )
727+ fix .Perform ()
728+ print (dir (fix ))
729+ return fix .Solid ()
730+
712731#===========================================================================
713732# --- TRANSFORM ---
714733#===========================================================================
@@ -813,7 +832,7 @@ def find_plane_from_shape(shape, tolerance=-1):
813832 try :
814833 fpl = BRepBuilderAPI_FindPlane (shape , tolerance )
815834 if fpl .Found ():
816- return fpl .Plane ().GetObject ()
835+ return fpl .Plane () # .GetObject()
817836 else :
818837 return None
819838 except :
@@ -835,7 +854,7 @@ def fit_plane_through_face_vertices(_face):
835854 [NORMALS .Append (i ) for i in normals ]
836855 POINTS = to_tcol_ (points , TColgp_HArray1OfPnt )
837856
838- pl = GeomPlate_BuildAveragePlane (NORMALS , POINTS ).Plane ().GetObject ()
857+ pl = GeomPlate_BuildAveragePlane (NORMALS , POINTS ).Plane () # .GetObject()
839858 vec = gp_Vec (pl .Location (), _face .GlobalProperties .centre ())
840859 pt = (pl .Location ().as_vec () + vec ).as_pnt ()
841860 pl .SetLocation (pt )
0 commit comments