Example #1
0
 def test_default_constructor_DEFINE_STANDARD_ALLOC(self):
     ''' OCE classes the defines standard alllocator can be instanciated
     if they're not abstract nor define any protected or private
     constructor '''
     BRep_Builder()
     TopoDS_Builder()
     ShapeAnalysis_Curve()
 def test_default_constructor_DEFINE_STANDARD_ALLOC(self) -> None:
     ''' OCE classes the defines standard alllocator can be instantiated
     if they're not abstract nor define any protected or private
     constructor '''
     b = BRep_Builder()
     self.assertIsInstance(b, BRep_Builder)
     t = TopoDS_Builder()
     self.assertIsInstance(t, TopoDS_Builder)
     s = ShapeAnalysis_Curve()
     self.assertIsInstance(s, ShapeAnalysis_Curve)
Example #3
0
wireAdaptor = BRepAdaptor_CompCurve(wire)
curve = BRepAdaptor_HCompCurve(wireAdaptor)
tol = 1e-7
max_segments = 200
max_degrees = 12
approx = Approx_Curve3d(curve, tol, GeomAbs_C2, max_segments, max_degrees)
if (approx.IsDone() and approx.HasResult()):
    an_approximated_curve = approx.Curve()

# there are two ways to project a point on this curve,
# they both give the same restult

# 1st solution: using GeomAPI_ProjectPointOnCurve
point_to_project = gp_Pnt(1., 2., 3.)
projection = GeomAPI_ProjectPointOnCurve(point_to_project,
                                         an_approximated_curve)
# get the results of the projection
projected_point = projection.NearestPoint()
# the number of possible results
nb_results = projection.NbPoints()
print("NbResults : %i" % nb_results)
print("Distance :", projection.LowerDistance())

# 2nd solution : using ShapeAnalysis_Curve().Project
tolerance = 1e-7
proj = gp_Pnt()
distance, parameter = ShapeAnalysis_Curve().Project(an_approximated_curve,
                                                    point_to_project,
                                                    tolerance, proj)
print("Distance :", distance)