Hi,

     I started using pythonocc 0.5 a couple weeks ago, and I like it.  I ran
across an issue this morning with boolean operations.  Basically, cutting a
diamond shape from a cylinder creates a messed up solid in pythonocc (some of
the cylinder border is missing and some of the diamond has been bordered over)
but it's okay in DRAWEXE.  Therefore, it seems to be a pythonocc problem, not an
OCC problem.  Am I doing something wrong, or is this a bug?  The code examples
follow.

Thanks,
Charles Sharman

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

from OCC.gp import *
from OCC.BRepPrimAPI import *
import OCC.Display.SimpleGui as gui
import OCC.Utils.Construct as construct

def bug():
    length = 10.0
    rad = 4.0
    wm = 5.0
    hm = 3.0

    # Body
    b1 = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(0.0, -length/2, 0.0),
gp_Dir(0.0, 1.0, 0.0)), rad, length).Shape()

    # Voids
    edgem = construct.make_polygon([
            gp_Pnt(wm/2, 0.0, 0.0),
            gp_Pnt(0.0, hm/2, 0.0),
            gp_Pnt(-wm/2, 0.0, 0.0),
            gp_Pnt(0.0, -hm/2, 0.0),
            gp_Pnt(wm/2, 0.0, 0.0)])
    vm = construct.make_prism(construct.make_face(edgem), gp_Vec(0.0, 0.0, 
2*rad))
    vm = construct.translate_topods_from_vector(vm, gp_Vec(0.0, -length/2+hm/2,
0.0))
    vn = construct.translate_topods_from_vector(vm, gp_Vec(0.0, 1.5*hm, 0.0), 
True)
    vs = construct.boolean_fuse(vm, vn)

    vb = BRepPrimAPI_MakeBox(gp_Pnt(-2*rad, -length/2-hm, -2*rad), gp_Pnt(2*rad,
-length/2+hm/2, 2*rad)).Shape()
    vs = construct.boolean_cut(vs, vb)

    # Subtracts the voids from the body
    return construct.boolean_cut(b1, vs)

if __name__ == '__main__':
    d, start_display, add_menu, add_function_to_menu = gui.init_display()
    d.DisplayShape(bug())
    gui.start_display()

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

pload ALL

set length 10.0
set rad 4.0
set wm 5.0
set hm 3.0

plane py 0 0 0 0 1 0 1 0 0
pcylinder b1 py $rad $length
ttranslate b1 0 -$length/2 0

polyline edgem $wm/2 0 0 0 $hm/2 0 -$wm/2 0 0 0 -$hm/2 0 $wm/2 0 0
mkplane f edgem
prism vm f 0 0 2*$rad
ttranslate vm 0 -$length/2+$hm/2 0

tcopy vm vn
ttranslate vn 0 1.5*$hm 0
bop vm vn
bopfuse vs

box vb -2*$rad -$length/2-$hm -2*$rad 4*$rad 1.5*$hm 4*$rad
bop vs vb
bopcut vc

bop b1 vc
bopcut retval

vinit
vdisplay retval



_______________________________________________
Pythonocc-users mailing list
Pythonocc-users@gna.org
https://mail.gna.org/listinfo/pythonocc-users

Reply via email to