Tue, 06/25/2019 - 18:06
Forums:
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
Wed, 06/26/2019 - 14:18
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 ?
Wed, 06/26/2019 - 15:38
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
Wed, 06/26/2019 - 15:45
Can you dump the shapes before the operation or at least provide the values of myRadius, myHeight, myThickness variables?
Wed, 06/26/2019 - 17:56
this calls the previous code with
myRadius= 0.5
myHeight=1
myThickness=0.1
Thu, 06/27/2019 - 09:19
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.
Thu, 06/27/2019 - 11:23
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 :)