cut opération doesn't work

Hello, 

I can't manage to make the cut operation work. Any idea ? thanks in advance

            // my initial cylinder from which i'll remove another cylinder
            BRepPrimAPI_MakeCylinder aMakeCylinder = new BRepPrimAPI_MakeCylinder(new gp_Ax2(new gp_Pnt(0, 0, 0), new gp_Dir(0, 0, 1)), myRadius, myHeight, 0);
            TopoDS_Shape myBody = aMakeCylinder.Shape();
            TopoDS_Solid mySolid = aMakeCylinder.Solid();

            
            // higher cylinder that i'll remove from the first one
            BRepPrimAPI_MakeCylinder aMakeHollowedPart = new BRepPrimAPI_MakeCylinder(new gp_Ax2(new gp_Pnt(0, 0, 0 - myHeight / 2), new gp_Dir(0, 0, 1)), myRadius - myThickness, myHeight * 2, 0);
            TopoDS_Solid myHollowedSolid = aMakeHollowedPart.Solid();


            // the cut operation between the 2 solids
            BRepAlgoAPI.BRepAlgoAPI_Cut myCut = new BRepAlgoAPI.BRepAlgoAPI_Cut(mySolid, myHollowedSolid);
            myBody = myCut.Shape();

            // shape healing
            ShapeFix_Shape FixShape = new ShapeFix_Shape();
            FixShape.Init(myBody);
            FixShape.Perform();

            // my hollowed cylinder
            myBody = FixShape.Shape();

            // then i'm extracting the vertices but i get only top and bottom faces + some edges
            // note that top and bottom faces are not hollowed but are the same than if it was a cylinder

 

magesecond_148729's picture
            // my solid
            BRepPrimAPI_MakeCylinder aMakeCylinder = new BRepPrimAPI_MakeCylinder(new gp_Ax2(new gp_Pnt(0, 0, 0), new gp_Dir(0, 0, 1)), myRadius, myHeight, 0);
            TopoDS_Solid mySolid = aMakeCylinder.Solid();



            // the solid i want to remove from my solid
            BRepPrimAPI_MakeCylinder aMakeHollowedPart = new BRepPrimAPI_MakeCylinder(new gp_Ax2(new gp_Pnt(0, 0, 0), new gp_Dir(0, 0, 1)), myRadius - myThickness, myHeight , 0);
            TopoDS_Shape hollowedPart = aMakeHollowedPart.Shape();


            // cut operation
            BOPAlgo_BOP test = new BOPAlgo_BOP();
            test.AddArgument(mySolid);
            TopTools_ListOfShape LS = new TopTools_ListOfShape();
            LS.Append(hollowedPart);
            test.SetTools(LS);
            test.SetRunParallel(true);
            test.SetOperation(BOPAlgo_Operation.BOPAlgo_CUT);
            test.Perform();


            // the result
            TopoDS_Shape result= test.Shape();

this kinda works... i get all the vertices... BUT this doesn't give the vertices the way i want them

it retrieves 3 faces, the lateral face and the vertices inside the cylinder for the hollowed part ( top + bottom )

what i was expecting: lateral face exterior, lateral face interior, top face hollowed, bottom face hollowed

because right now it would be ok to compute the triangles and so on to have my mesh but with a more complex mesh, how would i know what is supposed to be the faces to add, and the ones to remove ?

Attachments: 
magesecond_148729's picture

note that it doesn't work when the cylinder that i remove is longer than the first cylinder, which is completely stupid, that should retrieve the same vertices

Eugeny's picture

Can you dump the shapes before the operation or at least provide the values of myRadius, myHeight, myThickness variables?

magesecond_148729's picture
// create a hollowed cylinder with parameters: radius = 0.5, height = 1 and thickness=0.1
HollowedCylinder hollowedCylinder = new OCCTest.HollowedCylinder(0.5, 1, 0.1);

this calls the previous code with

myRadius= 0.5

myHeight=1

myThickness=0.1

Eugeny's picture

I see it now, the last parameter in BRepPrimAPI_MakeCylinder is the angle - portion of the cylinder to be created. You are creating the zero angle cylinder, thus the zero thickness cylinder. I guess you need the whole cylinder to be created, so just remove the last parameter and it will work fine.

magesecond_148729's picture

omg you are totally right >.< sorry for not reading enough carefully my code and thanks for your time!

now i get the 4 faces as expected :)