Boolean operation "cut" - representation

Posting and OpenCascade Forum:

Our projectteam encountered an unsolvable problem using OpenCascade:

When cutting with a sphere through a box, representation errors occur. The cutting part gets part of the box, the box is open and at some places holes arise. The really intersting thing is that this representation errors do not occur, when we move the sphere more often. (Same amount of boolean operations, but more transformations)

Now we tested the same programs in OC 4.0, which made hardly any difference except of both programs create the same represantation errors.

We´d really appreciate every help!

Please contact megiddus@gmx.at

Source Code:

TopoDS_Shape aTool; TopoDS_Shape aBox; Handle(AIS_Shape) aBoxShape; Handle(AIS_Shape) aToolShape;

TopoDS_Shape createTool(gp_Pnt pos, Standard_Real sr, Standard_Real cr) // creates tool from cylinder and sphere {

TopoDS_Shape wkz;

Standard_Real sRadius = sr;

Standard_Real cRadius = cr;

BRepPrimAPI_MakeCylinder C(sRadius, 100);

BRepPrimAPI_MakeSphere S(pos, cRadius);

wkz = BRepAlgoAPI_Fuse(C, S);

return wkz; }

void CminiDoc::OnBUTTONwz() {

// create tool and box

aTool = createTool(gp_Pnt(0,0,0), 40, 45);

aBox = BRepPrimAPI_MakeBox(gp_Pnt(0,0,0), 200, 200, 200);

// transformation of tool to startpoint 1

gp_Vec vect(-30,100,220);

gp_Trsf theTransformation;

theTransformation.SetTranslation(vect);

BRepBuilderAPI_Transform myBRepTransformation(aTool,theTransformation);

aTool = myBRepTransformation.Shape();

// set color and material of box

aBoxShape = new AIS_Shape(aBox);

myAISContext->SetMaterial(aBoxShape,Graphic3d_NOM_GOLD);

myAISContext->SetDisplayMode(aBoxShape,1);

myAISContext->Display(aBoxShape);

// set color and material of tool

aToolShape = new AIS_Shape(aTool);

myAISContext->SetMaterial(aBoxShape,Graphic3d_NOM_SILVER);

myAISContext->SetDisplayMode(aToolShape,1);

myAISContext->Display(aToolShape);

// transformation for boolean operation

vect.SetX(10); // SetX(1) working version, else SetX(10)

vect.SetY(0);

vect.SetZ(0);

theTransformation.SetTranslation(vect);

BRepBuilderAPI_Transform myMoveTransformation(theTransformation);

// move tool and build difference

for (int j=1; j

myMoveTransformation.Perform(aTool);

aTool = myMoveTransformation.Shape();

//if (j % 10 == 0) // uncomment for working version

aBox = BRepAlgoAPI_Cut(aBox, aTool);

aToolShape->Set(aTool);

aBoxShape->Set(aBox);

myAISContext->Redisplay(aToolShape);

myAISContext->Redisplay(aBoxShape);

myAISContext->UpdateCurrentViewer();

}

myAISContext->UpdateCurrentViewer();

// move tool to 2. startpoint

vect.SetX(-120);

vect.SetY(-120);

vect.SetZ(0);

theTransformation.SetTranslation(vect);

BRepBuilderAPI_Transform myBRepTransformation2(aTool,theTransformation);

aTool = myBRepTransformation2.Shape();

vect.SetX(0);

vect.SetY(10); // SetY(1) working version, else SetY(10)

vect.SetZ(0);

theTransformation.SetTranslation(vect);

BRepBuilderAPI_Transform myMoveTransformation2(theTransformation);

// move tool and build difference

for (int i=1; i

myMoveTransformation2.Perform(aTool);

aTool = myMoveTransformation2.Shape();

//if (i % 10 == 0) // uncomment for working version

aBox = BRepAlgoAPI_Cut(aBox, aTool);

aToolShape->Set(aTool);

aBoxShape->Set(aBox);

myAISContext->Redisplay(aToolShape);

myAISContext->Redisplay(aBoxShape);

myAISContext->UpdateCurrentViewer();

}

myAISContext->UpdateCurrentViewer();

}

Mikael Aronsson's picture

Hi !

This a very old bug in OpenCascade, I had problems with it over a year ago and was told that it was a problem when a degenerate pcurve (the pole of the sphere) intersect the other object (the box) I think, I was told that this would be fixed, but I guess no one has done that....yet......

Mikael