Open CASCADE, the 3D modelling kernel
3D modeling & numerical simulation

Search the Forums
See All Topics
 

boolean operations.... BRepAlgo_Cut bug?

boolean operations.... BRepAlgo_Cut bug?
Michele Fiorentino 2012/08/16 17: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<= 2;k++)
     //{
          for(float j=0;j<= 2;j++)
          {
               for(float i=0;i<= 2;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<<"non so"<<endl;
                         }

                    } 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


Michele Fiorentino 2012/08/16 17: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!


Forum supervisor 2012/08/16 17: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
 
 
Latest news
  • Open CASCADE Technology 6.8.0 is available for download!
  • New features to enhance the development process
  • Open CASCADE Technology 6.7.1 is available for download!

  • © OPEN CASCADE 2000 - 2014  |  Search  |  Contacts   |  Site map