For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

BRepAlgoAPI_Section help

Chris Murray's picture
Forums: 

I am ultimately trying to trim one surface with another. The way I was intending to do this is to generate the intersection shape between the two surfaces then use BRepFeat_SplitShape(). However I can't get good intersections. Here is an example where I have caught some of the undesirable results. It appears the intersection is not generated when it is between surfaces that both have two curvature directions. The intersection between surfaces1 and 2 is complete, however the intersection between surface 2 and 3 is incomplete.

--------------

from OCC.gp import gp_Pnt, gp_Dir, gp_Ax2, gp_Circ, gp_Vec, gp_Ax1
from OCC.BRepAlgoAPI import BRepAlgoAPI_Section
from OCC.BRepBuilderAPI import BRepBuilderAPI_MakeEdge, BRepBuilderAPI_MakeWire
from OCC.BRepPrimAPI import BRepPrimAPI_MakeRevol, BRepPrimAPI_MakePrism

#surface1
profileBuilder = BRepBuilderAPI_MakeWire()
circle = gp_Circ(gp_Ax2(gp_Pnt(-150,20,-50),gp_Dir(1,0,0)),10)
profileBuilder.Add(BRepBuilderAPI_MakeEdge(circle, gp_Pnt(-150,30,-50), gp_Pnt(-150,20,-40)).Edge())

profileBuilder.Add(BRepBuilderAPI_MakeEdge(gp_Pnt(-150,20,-40), gp_Pnt(-150,10,-40)).Edge())

circle = gp_Circ(gp_Ax2(gp_Pnt(-150,10,-50),gp_Dir(1,0,0)),10)
profileBuilder.Add(BRepBuilderAPI_MakeEdge(circle, gp_Pnt(-150,10,-40), gp_Pnt(-150,0,-50)).Edge())

surfaceShape1 = BRepPrimAPI_MakePrism(profileBuilder.Wire(),gp_Vec(200,0,0)).Shape()

#surface2
profileBuilder = BRepBuilderAPI_MakeWire()
circle = gp_Circ(gp_Ax2(gp_Pnt(0,20,0),gp_Dir(0,0,-1)),10)
profileBuilder.Add(BRepBuilderAPI_MakeEdge(circle, gp_Pnt(0,30,0), gp_Pnt(10,20,0)).Edge())

profileBuilder.Add(BRepBuilderAPI_MakeEdge(gp_Pnt(10,20,0), gp_Pnt(10,10,0)).Edge())

circle = gp_Circ(gp_Ax2(gp_Pnt(0,10,0),gp_Dir(0,0,-1)),10)
profileBuilder.Add(BRepBuilderAPI_MakeEdge(circle, gp_Pnt(10,10,0), gp_Pnt(0,0,0)).Edge())

revolAxis = gp_Ax1(gp_Pnt(200,0,0),gp_Dir(0,-1,0))
surfaceShape2 = BRepPrimAPI_MakeRevol(profileBuilder.Wire(),revolAxis,pi/2).Shape()

#surface3
profileBuilder = BRepBuilderAPI_MakeWire()
circle = gp_Circ(gp_Ax2(gp_Pnt(150,20,-150),gp_Dir(0,0,-1)),10)
profileBuilder.Add(BRepBuilderAPI_MakeEdge(circle, gp_Pnt(150,30,-150), gp_Pnt(160,20,-150)).Edge())

profileBuilder.Add(BRepBuilderAPI_MakeEdge(gp_Pnt(160,20,-150), gp_Pnt(160,10,-150)).Edge())

circle = gp_Circ(gp_Ax2(gp_Pnt(150,10,-150),gp_Dir(0,0,-1)),10)
profileBuilder.Add(BRepBuilderAPI_MakeEdge(circle, gp_Pnt(160,10,-150), gp_Pnt(150,0,-150)).Edge())

revolAxis = gp_Ax1(gp_Pnt(350,0,-150),gp_Dir(0,-1,0))
surfaceShape3 = BRepPrimAPI_MakeRevol(profileBuilder.Wire(),revolAxis,pi/2).Shape()

intersectCurve1 = BRepAlgoAPI_Section(surfaceShape1,surfaceShape2,True).Shape()
intersectCurve2 = BRepAlgoAPI_Section(surfaceShape2,surfaceShape3,True).Shape()

scene.DisplayColoredShape(surfaceShape1, color='RED')
scene.DisplayColoredShape(surfaceShape2, color='YELLOW')
scene.DisplayColoredShape(surfaceShape3, color='GREEN')
scene.DisplayColoredShape(intersectCurve1, color='BLACK')
scene.DisplayColoredShape(intersectCurve2, color='BLACK')

------------------------

I'm using the wxDisplay with python 2.7 and pythonOCC 0.6-rc1.

Thanks in advance for any help that can be given.

-Chris