Hello everyone,
I'm new to using PythonOCC and OCE. While the learning curve for the
very large API has been rather steep, I'm steadily learning to produce
the three-dimensional objects I want. Unfortunately, I've encountered a
problem with intersections that I'm unable to figure out.
Since the topic of the intersection of two curves has been discussed
several times before on the OpenCascade forums, without any clear
examples demonstrating a solution, I'm growing suspicious that the
problem might be deeper the usual case of I'm doing it wrong.
Following suggestions I've read elsewhere, I've constructed two gp_Circ
objects, then converted them to Geom_Cricles, before using GeomAPI_To2d
to convert them to two dimensional circles. Then
Geom2dAPI_InterCurveCurve should find the intersection, correct?
Can someone please explain why the attached code fails to find
intersections? This approach has correctly found the intersections of a
couple of other circles, but now I can't seem to get it to work
reliably. I think I might be doing something wrong related to the axes
and the planes.
Thanks in advance to anyone who's able to either fix my problem or
confirm that I'm not losing my mind.
Cory
#!/usr/bin/python
import OCC.gp
import OCC.BRepPrimAPI
import OCC.BRepAlgo
import OCC.GeomAPI
import OCC.Geom2dAPI
import OCC.BRepBuilderAPI
from OCC.Display.SimpleGui import set_backend, init_display
set_backend('qt')
display, start_display, add_menu, add_function_to_menu = init_display()
L = OCC.gp.gp_Pnt(4, 10, 0);
Lsphere = OCC.BRepPrimAPI.BRepPrimAPI_MakeSphere(L, 0.25)
display.DisplayShape(Lsphere.Shape())
M = OCC.gp.gp_Pnt(10, 16, 0);
Msphere = OCC.BRepPrimAPI.BRepPrimAPI_MakeSphere(M, 0.25)
display.DisplayShape(Msphere.Shape())
Oaxis = OCC.gp.gp_Ax2()
Laxis = OCC.gp.gp_Ax2()
Maxis = OCC.gp.gp_Ax2()
Laxis.SetLocation(L)
Maxis.SetLocation(M)
Lplane = OCC.gp.gp_Pln(OCC.gp.gp_Ax3(Laxis))
Mplane = OCC.gp.gp_Pln(OCC.gp.gp_Ax3(Maxis))
Oplane = OCC.gp.gp_Pln(OCC.gp.gp_Ax3(Oaxis))
r1 = 12.0
r2 = 15.0
Ltorus = OCC.BRepPrimAPI.BRepPrimAPI_MakeTorus(Laxis, r1, 0.05)
display.DisplayShape(Ltorus.Shape())
Mtorus = OCC.BRepPrimAPI.BRepPrimAPI_MakeTorus(Maxis, r2, 0.05)
display.DisplayShape(Mtorus.Shape())
Lcircle = OCC.gp.gp_Circ(Laxis, r1)
Mcircle = OCC.gp.gp_Circ(Maxis, r2)
LGcircle = OCC.Geom.Geom_Circle(Lcircle)
MGcircle = OCC.Geom.Geom_Circle(Mcircle)
L2curve = OCC.GeomAPI.GeomAPI_To2d(LGcircle.GetHandle(), Oplane)
M2curve = OCC.GeomAPI.GeomAPI_To2d(MGcircle.GetHandle(), Oplane)
Ledge = OCC.BRepBuilderAPI.BRepBuilderAPI_MakeEdge2d(L2curve)
Ledge.Build()
display.DisplayShape(Ledge.Shape())
Medge = OCC.BRepBuilderAPI.BRepBuilderAPI_MakeEdge2d(M2curve)
Medge.Build()
display.DisplayShape(Medge.Shape())
intersections = OCC.Geom2dAPI.Geom2dAPI_InterCurveCurve(L2curve, M2curve)
if intersections.NbPoints() == 0:
print "No intersections!"
for i in range(1, intersections.NbPoints() + 1):
print "I=", intersections.Point(i)
display.View_Iso()
display.FitAll()
start_display()
_______________________________________________
Pythonocc-users mailing list
Pythonocc-users@gna.org
https://mail.gna.org/listinfo/pythonocc-users