pythonCascade Sample Problems
Geometry: 3D
curves from points

P1 =
gp_Pnt(0,0,1)
P2 =
gp_Pnt(1,2,2)
P3 =
gp_Pnt(2,3,3)
P4 =
gp_Pnt(4,3,4)
P5 =
gp_Pnt(5,5,5)
array = []
array.append(P1)
array.append(P2)
array.append(P3)
array.append(P4)
array.append(P5)
harray = []
harray.append(P1.Translated(gp_Vec(4,0,0)))
harray.append(P2.Translated(gp_Vec(4,0,0)))
harray.append(P3.Translated(gp_Vec(4,0,0)))
harray.append(P4.Translated(gp_Vec(4,0,0)))
harray.append(P5.Translated(gp_Vec(4,0,0)))
SPL1 =
GeomAPI_PointsToBSpline(array).Curve()
anInterpolation =
GeomAPI_Interpolate(harray,0,Precision.Approximation())
anInterpolation.Perform();
if
anInterpolation.IsDone():
SPL2 =
anInterpolation.Curve()
else:
print
"The Interpolation is Not done"
for i in
range(0,len(array)):
P =
array[i]
pstring =
"P"+`i+1`
if i ==
0:
pstring = pstring + " (array)
"
self.DisplayPoint(P,pstring,0,0,0,0,0.1)
for i in
range(0,len(harray)):
P =
harray[i]
pstring =
"P"+`i+1`
if i ==
0:
pstring = pstring + " (harray)
"
self.DisplayPoint(P,pstring,0,0,0,0,0.1)
aCurve =
ISession_Curve(SPL1)
self.interactive_context.SetDisplayMode(aCurve,1,1)
self.interactive_context.Display(aCurve,1)
if
anInterpolation.IsDone():
SPL2 =
anInterpolation.Curve()
aCurve2 =
ISession_Curve(SPL2)
self.interactive_context.SetDisplayMode(aCurve2,1,1)
self.interactive_context.Display(aCurve2,1)