Cutting a Custom TopoDS_Shape with another one (Imported from STEP file)

In my current project I have two files (STEP files for now) and I import them. They seem to working fine while visualizing I only switched one of them to the wireframe mode so that you can see. When I use BRepAlgoAPI_Cut, it only makes a "crack" on the surface where there should be a "hole". Do you have any suggestions?

Attachments: 
Ali Can KESKİN's picture

Nobody ?

Mikhail Sazonov's picture

Hi,

Your models seem to contain facets. Do they contain surfaces? Boolean operations work only with shapes built on geometric surfaces. It would be useful if you attached the original files.

Mikhail

Ali Can KESKİN's picture

Hi,

Thanks for your reply. I am a newbie to OpenCascade. I am importing/exporting my objects from Unity Engine via CADExchanger (needed in a project). These shapes are Unity's primitive Cube and Cylinder (also attached them). Also I am not quite sure about my import method, so I am adding that below. Any help would be much appreciated.


TopoDS_Shape ReadStep(Standard_CString fName)
{
	STEPControl_Reader reader;

	IFSelect_ReturnStatus stat = reader.ReadFile(fName);

	IFSelect_PrintCount mode = IFSelect_ListByItem;

	reader.PrintCheckLoad(false, mode);


	Interface_Static::SetIVal("read.precision.mode", 0);

	Interface_Static::SetIVal("read.stdsameparameter.mode", 1);

	Interface_Static::SetRVal("read.encoderegularity.angle", 0.001);

	Interface_Static::SetIVal("read.step.shape.repr", 1);

	Interface_Static::SetIVal("read.step.shape.relationship", 1);

	Standard_Integer NbRoots = reader.NbRootsForTransfer();                      //Transfer whole file

	Standard_Integer NbTrans = reader.TransferRoots();

	Standard_Integer num = reader.NbShapes();

	TopoDS_Shape shape = reader.Shape();

	TopoDS_Shape result = reader.OneShape();

	return result;
}
Attachments: 
Mikhail Sazonov's picture

Your shapes are not valid for performing modeling algorithms on them. Each shape is just a set of not connected with each other faces. But for boolean CUT operation shapes (at least the tool) are expected to be solids.

You may use the algorithms BRepBuilderAPI_Sewing and BOPAlgo_MakerVolume to obtain a solid.

Ali Can KESKİN's picture

Thank you, I will search and try to use those algorithms and try again.

Ali Can KESKİN's picture

Thanks, using BRepBuilderAPI_Sewing and BOPAlgo_MakerVolume solved the problem

Kirill Gavrilov's picture

I don't know how Unity defines primitives like Cylinder and if it is possible or not exporting them correctly via plugin, but generated STEP file doesn't preserve it's primitive nature - the geometry is a plain list of triangles. Normally, cylinder should be defined by Cylinder or B-Spline surface types (see screenshot below). Of course, a general-purpose geometry, I guess, Unity may define only as a triangulation, but primitives like spheres, cylinders and boxes might be defined in a special way (at least for handling in physics).

Ali Can KESKİN's picture

As far as I know Unity is representing all of the shapes with triangles . I am using CADExchanger for exporting but I guess, it does not -and probably cannot since Unity does not support it- convert it properly. Do you know any way to handle this within Open Cascade ?

Mikhail Sazonov's picture

All that OCCT can do with such models is to treat them as is, i.e. facetted. I attached the result of cutting the cube by the cylinder.

Attachments: