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)
def build_geom_plate(edges): bpSrf = GeomPlate_BuildPlateSurface(3, 9, 12) # add curve constraints for edg in edges: c = BRepAdaptor_HCurve() print 'edge:', edg c.ChangeCurve().Initialize(edg) constraint = BRepFill_CurveConstraint(c.GetHandle(), 0) bpSrf.Add(constraint.GetHandle()) # add point constraint try: bpSrf.Perform() except RuntimeError: print 'failed to build the geom plate surface ' maxSeg, maxDeg, critOrder = 9, 8, 0 tol = 1e-4 dmax = max([tol, 10*bpSrf.G0Error()]) srf = bpSrf.Surface() plate = GeomPlate_MakeApprox(srf, 1e-04, 100, 9, 1e-03, 0) uMin, uMax, vMin, vMax = srf.GetObject().Bounds() face = make_face(plate.Surface(), uMin, uMax, vMin, vMax, 1e-6) return face
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)
def build_geom_plate(edges): bpSrf = GeomPlate_BuildPlateSurface(3, 9, 12) # add curve constraints for edg in edges: c = BRepAdaptor_HCurve() print 'edge:', edg c.ChangeCurve().Initialize(edg) constraint = BRepFill_CurveConstraint(c.GetHandle(), 0) bpSrf.Add(constraint.GetHandle()) # add point constraint try: bpSrf.Perform() except RuntimeError: print 'failed to build the geom plate surface ' 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) plate = GeomPlate_MakeApprox(srf, 1e-04, 100, 9, 1e-03, 0) uMin, uMax, vMin, vMax = srf.GetObject().Bounds() face = make_face(plate.Surface(), uMin, uMax, vMin, vMax, 1e-6) return face
def floor(): P1 = gp_Pnt(0,0,-100) V1 = gp_Vec(0,0,1) PL = gp_Pln(P1,gp_Dir(V1)) aPlane = GC_MakePlane(PL).Value() aSurface = Geom_RectangularTrimmedSurface( aPlane, -100., 100., -60., 60., 1, 1 ) face = make_face(aSurface.GetHandle(), 1e-6) floor = ode.GeomPlane(dyn_context._space, (0,0,1), -100) references.append(floor) display.DisplayColoredShape(face,'RED') display.FitAll()
def floor(): P1 = gp_Pnt(0, 0, -100) V1 = gp_Vec(0, 0, 1) PL = gp_Pln(P1, gp_Dir(V1)) aPlane = GC_MakePlane(PL).Value() aSurface = Geom_RectangularTrimmedSurface(aPlane, -100., 100., -60., 60., 1, 1) face = make_face(aSurface.GetHandle(), 1e-6) floor = ode.GeomPlane(dyn_context._space, (0, 0, 1), -100) references.append(floor) display.DisplayColoredShape(face, 'RED') display.FitAll()