Thu, 08/16/2012 - 19:06
Dear developers,
I am experimenting Opencascade booleans, whith a simple example i can call "the swiss cheese": take a box and perform a series of holes ;)
her eis the full code in c++
...startcode
const bool mydebug = false;
BRepPrimAPI_MakeBox B( 10,10.,10.);
const Standard_Real spacing =3.5f;
const Standard_Real m_radius =1.0f;
TopoDS_Shape finalshape = B.Shape();
int k =0;
// remmed because 2 cycles is sufficent to create the bug
//for(float k=0;k
//{
for(float j=0;j
{
for(float i=0;i
{
TopoDS_Shape tempSphere = BRepPrimAPI_MakeSphere(gp_Pnt(i*spacing,j*spacing,k*spacing), m_radius);
if (!mydebug)
{
try
{
BRepAlgo_Cut S1(finalshape,tempSphere);
if (S1.IsDone() && !S1.Shape().IsNull()) finalshape = S1.Shape();
}
catch(...)
{
//Handle(Standard_Failure) error = Failure::Caught();
cerr
}
} else // Show the spheres only - not necessary code
{
Handle(AIS_Shape) AIStempsphere=new AIS_Shape(tempSphere);
theContext->Display(AIStempsphere, Standard_False);
theContext->SetMaterial(AIStempsphere,Graphic3d_NOM_NEON_PHC);
//theContext->SetTransparency(AIStempsphere,0.9);
theContext->Display(AIStempsphere, Standard_False);
theContext->SetDisplayMode(AIStempsphere,1,true);
}
}
}
//}
Handle(AIS_Shape) AISBottle=new AIS_Shape(finalshape);
theContext->SetMaterial(AISBottle,Graphic3d_NOM_GOLD);
theContext->SetColor(AISBottle, Quantity_NOC_RED);
if (mydebug) theContext->SetDisplayMode(AISBottle,AIS_WireFrame,true);
else theContext->SetDisplayMode(AISBottle,AIS_Shaded,true);
theContext->Display(AISBottle, Standard_False);
...endcode
I added the flag debug to see how are spatially located the spheres.
The code works for 1 row but give me a fault when I add a row (as in the example above)
Feel free to play with it..;)
So my question:
1) is the code right?(i.e. some faults because the resulting shape is temp?)
2) The geometry i want to build is tecnically feseabel in Opencascade? (the cheese?)
3) this 3D is very similar to this
http://www.opencascade.org/org/forum/thread_9201/?forum=3
and another one where it was suggested to create a compound of objects and teh perform the boolean operation one time. This is the way I'll test..
4) if it's a bug i already sent a mail to the bugmaster but in my account i cannot open new issues.
thanks
Thu, 08/16/2012 - 19:12
Autoanswer: I did a quick test and using BRepAlgoAPI_Cut works for this example. It's pretty confusing having two functions doing the same thing!
Thu, 08/16/2012 - 19:40
Dear Michele,
BRepAlgoAPI contains a new version of Boolean operations algorithm.
BRepAlgo package contains old algorithm of Boolean operations. It is kept for compatibility and not maintained more.
Regards