-
-
Notifications
You must be signed in to change notification settings - Fork 405
Description
Hello,
I'm just working with BSplineSurfaces, solids and boolean operations.
In the following example the BRepAlgoAPI_Cut and BRepAlgoAPI_Common functions don't work.
The BRepAlgoAPI_Fuse function is working.
from OCC.gp import *
from OCC.TColgp import *
from OCC.TColStd import *
from OCC.Geom import *
from OCC.GeomFill import *
from OCC.BRepBuilderAPI import *
from OCC.BRepFill import *
from OCC.GC import *
from OCC.TopoDS import *
from OCC.BRep import *
from OCC.BRepPrimAPI import *
from OCC.BRepAlgoAPI import *
from OCC.Display.SimpleGui import init_display
display, start_display, add_menu, add_function_to_menu = init_display()
display.DisableAntiAliasing()
def bsplineSurface(zVal,xFak_Val,yFak_Val):
nCP_U = 4
nCP_V = 4
degree_U = 3
degree_V = 3
#k_U = degree_U +1
#k_V = degree_V +1
z = zVal
xFak = xFak_Val
yFak = yFak_Val
array_Pol = TColgp_Array2OfPnt(1, nCP_U,1,nCP_V)
array_Pol.SetValue(1,1, gp_Pnt(0_xFak, 0_yFak, 0))
array_Pol.SetValue(1,2, gp_Pnt(0_xFak, 1_yFak, 0))
array_Pol.SetValue(1,3, gp_Pnt(0_xFak, 2_yFak, 0))
array_Pol.SetValue(1,4, gp_Pnt(0_xFak, 3_yFak, 0))
array_Pol.SetValue(2,1, gp_Pnt(1_xFak, 0_yFak, 0))
array_Pol.SetValue(2,2, gp_Pnt(1_xFak, 1_yFak, z))
array_Pol.SetValue(2,3, gp_Pnt(1_xFak, 2_yFak, z))
array_Pol.SetValue(2,4, gp_Pnt(1_xFak, 3_yFak, 0))
array_Pol.SetValue(3,1, gp_Pnt(2_xFak, 0_yFak, 0))
array_Pol.SetValue(3,2, gp_Pnt(2_xFak, 1_yFak, z))
array_Pol.SetValue(3,3, gp_Pnt(2_xFak, 2_yFak, z))
array_Pol.SetValue(3,4, gp_Pnt(2_xFak, 3_yFak, 0))
array_Pol.SetValue(4,1, gp_Pnt(3_xFak, 0_yFak, 0))
array_Pol.SetValue(4,2, gp_Pnt(3_xFak, 1_yFak, 0))
array_Pol.SetValue(4,3, gp_Pnt(3_xFak, 2_yFak, 0))
array_Pol.SetValue(4,4, gp_Pnt(3_xFak, 3_yFak, 0))
array_Knots_U = TColStd_Array1OfReal(1, 2)
array_Knots_U.SetValue(1, 0.0)
array_Knots_U.SetValue(2, 0.1)
array_Multi_U = TColStd_Array1OfInteger(1,2)
array_Multi_U.SetValue(1,4)
array_Multi_U.SetValue(2,4)
array_Knots_V = TColStd_Array1OfReal(1,2)
array_Knots_V.SetValue(1, 0.0)
array_Knots_V.SetValue(2, 0.1)
array_Multi_V = TColStd_Array1OfInteger(1,2)
array_Multi_V.SetValue(1,4)
array_Multi_V.SetValue(2,4)
return Geom_BSplineSurface(array_Pol,array_Knots_U,array_Knots_V,array_Multi_U,array_Multi_V,degree_U,degree_V,False,False)
if name == 'main':
aTol = 1e-06
aSurface =bsplineSurface(2,1,1)
aFace = BRepBuilderAPI_MakeFace(aSurface.GetHandle(),aTol)
aSurface1 = bsplineSurface(-4,1,1)
aFace1 = BRepBuilderAPI_MakeFace(aSurface1.GetHandle(),aTol)
aBuilder = BRep_Builder()
aShell = TopoDS_Shell()
aBuilder.MakeShell(aShell)
aBuilder.Add(aShell,aFace.Shape())
aBuilder.Add(aShell,aFace1.Shape())
aSolid = BRepBuilderAPI_MakeSolid(aShell)
anOrigin = gp_Pnt(1.5,1.5,-5)
aDir = gp_Dir(gp_XYZ(0,0,1))
anAxis = gp_Ax2(anOrigin,aDir)
aRadius = 0.5
aHeight = 10
aCylinder = BRepPrimAPI_MakeCylinder(anAxis,aRadius,aHeight)
aCut = BRepAlgoAPI_Cut(aSolid.Shape(),aCylinder.Shape())
aCommon = BRepAlgoAPI_Common(aSolid.Shape(),aCylinder.Shape())
aFuse = BRepAlgoAPI_Fuse(aSolid.Shape(),aCylinder.Shape())
display.DisplayShape(aCut.Shape())
#display.DisplayShape(aCommon.Shape())
#display.DisplayShape(aFuse.Shape())
display.FitAll()
start_display()
Some ideas?
Best Regards
Achim