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

Open CASCADEShowroomGet it!Developer CornerSupport and ProductsAbout us
Technical overview
Areas of use
Advantages
FAQ
Screenshots
Shape factory
Shape gallery
Demonstrations
What's new
System requirements
Download Center
Public license
Documentation
Getting started
Forum
Open Source community
Training and e-learning
A la Carte Support
Value-added software
Complementary Components
Customer Corner
Company Profile
Marketing Materials
Contact Us
News
Home / Developer Corner / Forum / How to cut a solid by a face into two sub solids using cut API only once

Forum

How to cut a solid by a face into two sub solids using cut API only once
Cauchy Ding2010/03/10 02:01
Hi All,

Now, to cut a solid by a face into two sub solids, I have to use API BRepAlgoAPI_Cut twice. One uses positive half space , and another uses negative half space. So it's somewhat stupid and low performance. My method is as follows:

bool Trim_FaceCutShell(const TopoDS_Face& trimFaceTool, const TopoDS_Shape& shellSolid, std::vector<TopoDS_Shape>& resultShapes)
{
TopoDS_Solid solidPos, solidNeg;
TopoDS_Shape resultShape;

resultShapes.clear();
if(!Aux_MakeTwoHalfSpaceByFace(trimFaceTool, solidPos, solidNeg))
return false;
try
{
resultShape = BRepAlgoAPI_Cut (shellSolid, solidPos);
if(resultShape.ShapeType()==TopAbs_COMPOUND)
{
for(TopoDS_Iterator iter(resultShape); iter.More(); iter.Next())
resultShapes.push_back(iter.Value());
}
else
resultShapes.push_back(resultShape);
resultShape = BRepAlgoAPI_Cut (shellSolid, solidNeg);
if(resultShape.ShapeType()==TopAbs_COMPOUND)
{
for(TopoDS_Iterator iter(resultShape); iter.More(); iter.Next())
resultShapes.push_back(iter.Value());
}
else
resultShapes.push_back(resultShape);
}
catch (...)
{
resultShapes.clear();
return false;
}

return !resultShapes.empty();
}

I just wonder know how can I get the two sub solids by one time CUT operation. Does any API support it or is there any similar API DirectLeft() or DirectRight() to get any part of the cutting result.
Thanks in advance. Any suggestion is welcome.

-Ding
Lodyzhensky Evgeny Nicolaich2010/03/10 05:37
Dear Cauchy Ding .

1. If you prefer to use standard Boolean Operations you can increase the performance by the following trick.

...
TopoDS_Shape S1, S2, aRCm, aRCt;
BOPTools_DSFiller aDF;
//
S1=shellSolid;
S2=solidPos;
//
aDF.SetShapes (S1, S2);
if (!aDF.IsDone()) {
// ... some error handler     
return;     
}
//
aDF->Perform();
//
BRepAlgoAPI_Common aBCm(S1, S2, aDF);
if (!aBCm.IsDone()) {
aRCm=aBCm.Shape();
resultShapes.push_back(aRCm);
}
else {
// ... some error handler     
return;     
}
//
S2=solidNeg;
BRepAlgoAPI_Cut aBCt(S1, S2, aDF);
if (!aBCt.IsDone()) {
aRCt=aBCt.Shape();
resultShapes.push_back(aRCt);
}
else {
// ... some error handler     
return;     
}
...

Here you use the one (shared) DSFiller for two Boolean operations instead of the two as it was.

But again you have to use the two builders:

BRepAlgoAPI_Common aBCm(S1, S2, aDF);
BRepAlgoAPI_Cut aBCt(S1, S2, aDF);

The builders above are not so time consuming things as the DSFiller, so may be the way will be good for you.

2.If not. You can use the class GEOMAlgo_Splitter from Salome plarform.
The class allows to perform the things you want at once.
Furthermore you can use trimFaceTool directly as the argument of the operation.
Thomas Paviot2010/03/10 14:55
The GEOMAlgo_Splitter class does the job pretty well. It can also be used to split a face from a curve (see http://www.opencascade.org/org/forum/thread_14379/).

Attached a python sample (pythonOCC actually wraps for both OCC and GEOM libraries), as well as 2 screenshots (input/output), that illustrates how to split a box with a plane face.

Regards,

Thomas
You have to be logged in to download the attached file
Thomas Paviot2010/03/10 14:56
The first screenshot (the box and the plane face)
You have to be logged in to download the attached file
Thomas Paviot2010/03/10 14:56
And the second one (resulting shape)
You have to be logged in to download the attached file
Cauchy Ding2010/03/11 07:31
Dear Thomas Paviot,

Thank you very much for your reply. I am sorry that my app can't use Salome platform directly. But still thanks to your detailed explanations.

Thank you.
Regards.

-Ding
Cauchy Ding2010/03/11 07:27
Dear Lodyzhensky Evgeny Nicolaich,

Thank you so much for your detailed explanation. Your method is so nice and works very well now. The new method is about double faster than old method.
I think there is a minor bug in your pseudocode.
S2=solidNeg;
BRepAlgoAPI_Cut aBCt(S1, S2, aDF);
Here S2 should also be the "solidPos" instead of "solidNeg".

Thank you very much.

-Ding
Lodyzhensky Evgeny Nicolaich2010/03/15 05:16
Dear Cauchy Ding.

You are quite right.
...Here S2 should also be the "solidPos" instead of "solidNeg".
It is my misprint.
 
 
Latest news
  • FAQ section updated
  • OPEN CASCADE Uses Intel ® Parallel Studio XE to Introduce Parallelism into SALOME SMESH Module
  • Open CASCADE Technology 6.5.2 is available for download!

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