def getTestFace(): P1 = gp_Pnt(0., 0., 0.) P12 = gp_Pnt(0., 2., 2.) P2 = gp_Pnt(0., 10., 0.) P3 = gp_Pnt(0., 10., 10.) P4 = gp_Pnt(0., 0., 10.) P5 = gp_Pnt(5., 5., 5.) SceneDrawPoint('p1', P1) SceneDrawPoint('p12', P12) SceneDrawPoint('p2', P2) SceneDrawPoint('p3', P3) SceneDrawPoint('p4', P4) SceneDrawPoint('p5', P5) W = BRepBuilderAPI_MakePolygon() W.Add(P1) W.Add(P12) W.Add(P2) W.Add(P3) W.Add(P4) W.Add(P1) SceneDrawShape('w', W.Shape()) # Initialize a BuildPlateSurface BPSurf = GeomPlate_BuildPlateSurface(3, 15, 2) # Create the curve constraints anExp = BRepTools_WireExplorer() anExp.Init(W.Wire()) while anExp.More(): E = anExp.Current() C = BRepAdaptor_HCurve() C.ChangeCurve().Initialize(E) Cont = BRepFill_CurveConstraint(C, 0) BPSurf.Add(Cont) anExp.Next() # Point constraint PCont = GeomPlate_PointConstraint(P5, 0) BPSurf.Add(PCont) # Compute the Plate surface BPSurf.Perform() # Approximation of the Plate surface MaxSeg = 9 MaxDegree = 8 CritOrder = 0 PSurf = BPSurf.Surface() dmax = max(0.0001, 10 * BPSurf.G0Error()) Tol = 0.0001 Mapp = GeomPlate_MakeApprox(PSurf, Tol, MaxSeg, MaxDegree, dmax, CritOrder) Surf = Mapp.Surface() # create a face corresponding to the approximated Plate Surface Umin, Umax, Vmin, Vmax = PSurf.Bounds() #MF = BRepBuilderAPI_MakeFace (Surf, Umin, Umax, Vmin, Vmax, Tol) MF = BRepBuilderAPI_MakeFace(Surf, Tol) return MF
def build_plate(polygon, points): ''' build a surface from a constraining polygon(s) and point(s) @param polygon: list of polygons ( TopoDS_Shape) @param points: list of points ( gp_Pnt ) ''' # plate surface bpSrf = GeomPlate_BuildPlateSurface(3, 15, 2) # add curve constraints for poly in polygon: for edg in WireExplorer(poly).ordered_edges(): c = BRepAdaptor_HCurve() c.ChangeCurve().Initialize(edg) constraint = BRepFill_CurveConstraint(c.GetHandle(), 0) bpSrf.Add(constraint.GetHandle()) # add point constraint for pt in points: bpSrf.Add(GeomPlate_PointConstraint(pt, 0).GetHandle()) bpSrf.Perform() maxSeg, maxDeg, critOrder = 9, 8, 0 tol = 1e-4 dmax = max([tol, 10*bpSrf.G0Error()]) srf = bpSrf.Surface() plate = GeomPlate_MakeApprox(srf, tol, maxSeg, maxDeg, dmax, critOrder) uMin, uMax, vMin, vMax = srf.GetObject().Bounds() return make_face(plate.Surface(), uMin, uMax, vMin, vMax, 1e-4)