For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

OCC 7.2 : BRepAlgoAPI_Cut not giving correct result when first shape is Surface and tool is Solid

Niraj Pansare's picture
Forums: 

Hi,

I am trying to migrate my application from OCC 6.7.1 to OCC7.2 release.But I am facing one critical issue with OCC7.2 regarding boolean cut operation.

When I am trying to use BRepAlgoAPI_Cut API on surface+Solid Cut , it is not giving wrong result and returning original surface body back.

Even I tried to simulate same problem in OCC sample application (Modelling) and able to reproduce the same.

Example : Cut a simple Cylindrical surface with Box.

Note : This was working fine in OCC 6.7.1.

Regards,

Niraj

Andrey BETENEV's picture

Hello Niraj,

Please share your data and describe how to reproduce the problem. The best way to that is to register an issue in OCCT Mantis bug tracker, providing reproducer in the form of a DRAW script.

Andrey

Niraj Pansare's picture

Hello Andrey,

Here is snapshot of code which I added to standard OCC Modeling application.

BRepBuilderAPI_MakePolygon P;
P.Add(gp_Pnt(0.,0.,0.));
P.Add(gp_Pnt(100.,0.,0.));
P.Add(gp_Pnt(100.,100.,0.));
P.Add(gp_Pnt(0.,100.,0.));
P.Add(gp_Pnt(0.,0.,0.));
TopoDS_Wire W = P.Wire();
TopoDS_Wire wprof = BRepBuilderAPI_MakePolygon(gp_Pnt(0.,0.,0.),gp_Pnt(-60.,-60.,-100.));
TopoDS_Shape theSphere = BRepOffsetAPI_MakeEvolved(W,wprof,GeomAbs_Arc,Standard_True,Standard_False,Standard_True,0.0001);
 

Handle (AIS_Shape)    ais2 = new AIS_Shape(theSphere);
myAISContext->SetDisplayMode(ais2,1,Standard_False);
myAISContext->SetColor(ais2,Quantity_NOC_YELLOW,Standard_False);
myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
myAISContext->Display(ais2,Standard_False);
const Handle(AIS_InteractiveObject)& anIO2 = ais2;
myAISContext->SetSelected (anIO2, Standard_False);
Fit();
Sleep(1000);

TopoDS_Shape ShapeCut = BRepAlgoAPI_Cut(theSphere,theBox);

Here I used code snippets from sample application to create Surface and Solid Body.

Regards,

Niraj

Eugeny's picture

Hello Niraj,

Could you please also clarify how the tool shape theBox is created? Or, even better, could you please save the shapes before the Boolean operation? You can use the following code for that:

BinTools::Write(theSphere, "sphere");
BinTools::Write(theBox, "box");

It will be easier to reproduce the problem this way.

Best regards,
Eugeny.

Niraj Pansare's picture

Hi,

I have uploaded sample 2 shapes -

1. Shape to cut (name shape) - it is simple  cylinder

2. Shape used for cutting (name Tool) - it is simple box

Boolean opearation with these two shapes are working fine in version 6.7.1 but failing in 7.1 and 7.2.

Regards,

Niraj Pansare

Attachments: 
Eugeny's picture

Hello Niraj,

Thanks for the shapes.

Draw script to reproduce the problem in OCCT 7.2.0:

binrestore Shape s
binrestore Tool t
bcut r s t

Draw script to reproduce the problem in OCCT 6.7.1 (*.bin files are not supported in OCCT6.7.1, so the *.brep files are attached):

restore Shape.brep s
restore Tool.brep t

bcut r s t

Boolean operation on these shapes fails in both OCCT 6.7.1 and OCCT 7.2.0 versions.

The Tool shape does not seem to be valid - it has really huge tolerance. Try the following in draw:

tolerance t
# Tolerance MAX=3.7503222964417714e+091 AVG=3.1733496354507292e+091 MIN=9.9999999999999995e-008
# FACE    : MAX=3.75032229644177e+091 AVG=1.2501074321472567e+091 MIN=9.9999999999999995e-008
# EDGE    : MAX=3.7503222964417714e+091 AVG=2.5002148642945133e+091 MIN=9.9999999999999995e-008
# VERTEX  : MAX=3.7503222964417714e+091 AVG=3.7503222964417714e+091 MIN=3.7503222964417714e+091

Such tolerance values are not acceptable. Boolean operations algorithm cannot work with the shapes having such tolerance values. I have also tried to perform the Cut operation on these shape in OCCT6.7.1 and it failed. Reducing the tolerance values of the Tool helps to obtain the valid result of Cut operation:

settolerance t 1.e-7
fixshape t t
bcut r s t
checkshape r

To fix the problem you need to find how the Tool shape (box) has been created. Probably there is a problem in some other OCCT algorithm which has been used to create the box and in OCCT 6.7.1 the box was OK.
Could you please provide the code snippet of box creation?

Best regards,
Eugeny.

Attachments: 
Niraj Pansare's picture

Hello Eugeny,

Thank you for the help.

I would like to give some more information related to this.

Currently I am using cascade unit as  "M" (meter) for my application.

The shapes which I attached earlier are from OCC 7.2. But if I create those with 6.7.1 it works fine.

To Create Tool box I am using following steps :

1. Created one planar face and offseted that one (BRepOffsetAPI_MakeOffsetShape)

2. Extruded offseted face using (BRepPrimAPI_MakePrism)

Regards,

Niraj Pansare

Niraj Pansare's picture

Thank you Eugeny.

After Setting up tolerance value Cut API is giving me correct results.

 ShapeFix_ShapeTolerance shapeTolerance = new ShapeFix_ShapeTolerance();
 double tolerance = 1e-6;
 shapeTolerance.SetTolerance(createdShape,tolerance);

Regards,

Niraj Pansare