Add new idl function GEOM_IBooleanOperations::MakePartitionNonSelfIntersectedShape to provide correct publishing in study of a partition arguments and also to provide homogeneous behaviour of Partition in GUI and in python scripts.

This commit is contained in:
jfa 2006-12-13 09:40:11 +00:00
parent 1c87498d87
commit da257d8d06
9 changed files with 479 additions and 162 deletions

@ -219,9 +219,18 @@
<tr><td class="memItemLeft" nowrap align="right" valign="top">def&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespacegeompy.html#db16045827aa23070ef98eca038ecd2c">GetShapesOnQuadrangleIDs</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Works like the above method, but returns list of sub-shapes indices. <a href="#db16045827aa23070ef98eca038ecd2c"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">def&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespacegeompy.html#94c97c957d04ebd433cb5b3d94e8c8ac">GetShapesOnBox</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Find in <em>theShape</em> all sub-shapes of type <em>theShapeType</em>, situated relatively the specified <em>theBox</em> by the certain way, defined through <em>theState</em> parameter. <a href="#94c97c957d04ebd433cb5b3d94e8c8ac"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">def&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespacegeompy.html#c7b1da4e965bf551fc87b72ebd6afde7">GetShapesOnBoxIDs</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Works like the above method, but returns list of sub-shapes indices. <a href="#c7b1da4e965bf551fc87b72ebd6afde7"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">def&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespacegeompy.html#2695635fc745e6aa6cda4545e2133c41">GetInPlace</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Get sub-shape(s) of theShapeWhere, which are coincident with <em>theShapeWhat</em> or could be a part of it. <a href="#2695635fc745e6aa6cda4545e2133c41"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">def&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespacegeompy.html#808c0723c1cc2c641a02aeaa0d0b45c6">GetSame</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Get sub-shape of theShapeWhere, which is equal to <em>theShapeWhat</em>. <a href="#808c0723c1cc2c641a02aeaa0d0b45c6"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">def&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespacegeompy.html#67706610dda0d5005ee1cdfe2e8362a2">GetSubShape</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Obtain a composite sub-shape of &lt;aShape&gt;, composed from sub-shapes of &lt;aShape&gt;, selected by their unique IDs inside &lt;aShape&gt;. <a href="#67706610dda0d5005ee1cdfe2e8362a2"></a><br></td></tr>
@ -306,9 +315,9 @@
<tr><td class="memItemLeft" nowrap align="right" valign="top">def&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespacegeompy.html#56f48212a436f46c02722f627d27e7f2">MakePartition</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Perform partition operation. <a href="#56f48212a436f46c02722f627d27e7f2"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">def&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespacegeompy.html#dcdde81ee91dd4fffbd61f027fce692b">MakePartitionNonSelfIntersectedShape</a></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">def&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespacegeompy.html#85a4e715d0d0e4c8c9960372bfeb5327">MakePartitionNonSelfIntersectedShape</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Perform partition operation. <a href="#dcdde81ee91dd4fffbd61f027fce692b"></a><br></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Perform partition operation. <a href="#85a4e715d0d0e4c8c9960372bfeb5327"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">def&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespacegeompy.html#f1fc43bc5612514bcc2f6d772c3d38db">Partition</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Shortcut to <a class="el" href="namespacegeompy.html#56f48212a436f46c02722f627d27e7f2">MakePartition()</a>. <a href="#f1fc43bc5612514bcc2f6d772c3d38db"></a><br></td></tr>
@ -3934,6 +3943,113 @@ Example: see GEOM_TestOthers.py </td>
Example: see GEOM_TestOthers.py </td>
</tr>
</table>
<a class="anchor" name="94c97c957d04ebd433cb5b3d94e8c8ac"></a><!-- doxytag: member="geompy::GetShapesOnBox" ref="94c97c957d04ebd433cb5b3d94e8c8ac" args="" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top">def geompy::GetShapesOnBox </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">&nbsp;</td>
<td class="mdname" nowrap> <em>theBox</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>&nbsp;</td>
<td class="mdname" nowrap> <em>theShape</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>&nbsp;</td>
<td class="mdname" nowrap> <em>theShapeType</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>&nbsp;</td>
<td class="mdname" nowrap> <em>theState</em></td>
</tr>
<tr>
<td class="md"></td>
<td class="md">)&nbsp;</td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
&nbsp;
</td>
<td>
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>theBox</em>&nbsp;</td><td>Shape for relative comparing. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>theShape</em>&nbsp;</td><td>Shape to find sub-shapes of. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>theShapeType</em>&nbsp;</td><td>Type of sub-shapes to be retrieved. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>theState</em>&nbsp;</td><td>The state of the subshapes to find. It can be one of ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN. </td></tr>
</table>
</dl>
<dl compact><dt><b>Returns:</b></dt><dd>List of all found sub-shapes. </dd></dl>
</td>
</tr>
</table>
<a class="anchor" name="c7b1da4e965bf551fc87b72ebd6afde7"></a><!-- doxytag: member="geompy::GetShapesOnBoxIDs" ref="c7b1da4e965bf551fc87b72ebd6afde7" args="" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top">def geompy::GetShapesOnBoxIDs </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">&nbsp;</td>
<td class="mdname" nowrap> <em>theBox</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>&nbsp;</td>
<td class="mdname" nowrap> <em>theShape</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>&nbsp;</td>
<td class="mdname" nowrap> <em>theShapeType</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>&nbsp;</td>
<td class="mdname" nowrap> <em>theState</em></td>
</tr>
<tr>
<td class="md"></td>
<td class="md">)&nbsp;</td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
&nbsp;
</td>
<td>
<p>
</td>
</tr>
</table>
<a class="anchor" name="2695635fc745e6aa6cda4545e2133c41"></a><!-- doxytag: member="geompy::GetInPlace" ref="2695635fc745e6aa6cda4545e2133c41" args="" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
<tr>
@ -3978,6 +4094,50 @@ Example: see GEOM_TestOthers.py </td>
Example: see GEOM_TestOthers.py </td>
</tr>
</table>
<a class="anchor" name="808c0723c1cc2c641a02aeaa0d0b45c6"></a><!-- doxytag: member="geompy::GetSame" ref="808c0723c1cc2c641a02aeaa0d0b45c6" args="" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top">def geompy::GetSame </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">&nbsp;</td>
<td class="mdname" nowrap> <em>theShapeWhere</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>&nbsp;</td>
<td class="mdname" nowrap> <em>theShapeWhat</em></td>
</tr>
<tr>
<td class="md"></td>
<td class="md">)&nbsp;</td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
&nbsp;
</td>
<td>
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>theShapeWhere</em>&nbsp;</td><td>Shape to find sub-shape of. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>theShapeWhat</em>&nbsp;</td><td>Shape, specifying what to find. </td></tr>
</table>
</dl>
<dl compact><dt><b>Returns:</b></dt><dd>New <a class="el" href="classGEOM__Object.html">GEOM_Object</a> for found sub-shape. </dd></dl>
</td>
</tr>
</table>
<a class="anchor" name="67706610dda0d5005ee1cdfe2e8362a2"></a><!-- doxytag: member="geompy::GetSubShape" ref="67706610dda0d5005ee1cdfe2e8362a2" args="" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
<tr>
@ -5208,13 +5368,13 @@ Example: see GEOM_TestOthers.py </td>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>ListShapes</em>&nbsp;</td><td>Shapes to be intersected. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>ListTools</em>&nbsp;</td><td>Shapes to intersect theShapes. !!!NOTE: Each compound from ListShapes and ListTools will be exploded in order to avoid possible intersection between shapes from this compound.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>Limit</em>&nbsp;</td><td>Type of resulting shapes (corresponding to TopAbs_ShapeEnum). </td></tr>
</table>
</dl>
After implementation new version of PartitionAlgo (October 2006) other parameters are ignored by current functionality. They are kept in this function only for support old versions. Ignored parameters: <dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>ListKeepInside</em>&nbsp;</td><td>Shapes, outside which the results will be deleted. Each shape from theKeepInside must belong to theShapes also. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>ListRemoveInside</em>&nbsp;</td><td>Shapes, inside which the results will be deleted. Each shape from theRemoveInside must belong to theShapes also. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>Limit</em>&nbsp;</td><td>Type of resulting shapes (corresponding to TopAbs_ShapeEnum). </td></tr>
<tr><td valign="top"></td><td valign="top"><em>RemoveWebs</em>&nbsp;</td><td>If TRUE, perform Glue 3D algorithm. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>ListMaterials</em>&nbsp;</td><td>Material indices for each shape. Make sence, only if theRemoveWebs is TRUE.</td></tr>
</table>
@ -5223,7 +5383,7 @@ After implementation new version of PartitionAlgo (October 2006) other parameter
Example: see GEOM_TestAll.py </td>
</tr>
</table>
<a class="anchor" name="dcdde81ee91dd4fffbd61f027fce692b"></a><!-- doxytag: member="geompy::MakePartitionNonSelfIntersectedShape" ref="dcdde81ee91dd4fffbd61f027fce692b" args="" --><p>
<a class="anchor" name="85a4e715d0d0e4c8c9960372bfeb5327"></a><!-- doxytag: member="geompy::MakePartitionNonSelfIntersectedShape" ref="85a4e715d0d0e4c8c9960372bfeb5327" args="" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
@ -5289,7 +5449,7 @@ Example: see GEOM_TestAll.py </td>
<p>
This method may be useful if it is needed to make a partition for compound contains nonintersected shapes. Performance will be better since intersection between shapes from compound is not performed.<p>
Description of all parameters as in previous method <a class="el" href="namespacegeompy.html#56f48212a436f46c02722f627d27e7f2">MakePartition()</a><p>
!!!NOTE: Compounds from ListShapes can not have intersections with each other and compounds from ListTools can not have intersections with each other.<p>
!!!NOTE: Passed compounds (via ListShapes or via ListTools) have to consist of nonintersecting shapes.<p>
<dl compact><dt><b>Returns:</b></dt><dd>New <a class="el" href="classGEOM__Object.html">GEOM_Object</a>, containing the result shapes. </dd></dl>
</td>
</tr>

@ -1645,13 +1645,21 @@ module GEOM
* Perform partition operation.
* \param theShapes Shapes to be intersected.
* \param theTools Shapes to intersect theShapes.
* \note Each compound from ListShapes and ListTools will be exploded in order
* to avoid possible intersection between shapes from this compound.
* \param theLimit Type of resulting shapes (corresponding to TopAbs_ShapeEnum).
*
* After implementation new version of PartitionAlgo (October 2006)
* other parameters are ignored by current functionality. They are kept
* in this function only for supporting old versions.
* Ignored parameters:
* \param theKeepInside Shapes, outside which the results will be deleted.
* Each shape from theKeepInside must belong to theShapes also.
* \param theRemoveInside Shapes, inside which the results will be deleted.
* Each shape from theRemoveInside must belong to theShapes also.
* \param theLimit Type of resulting shapes (corresponding to TopAbs_ShapeEnum).
* \param theRemoveWebs If TRUE, perform Glue 3D algorithm.
* \param theMaterials Material indices for each shape. Make sence, only if theRemoveWebs is TRUE.
*
* \return New GEOM_Object, containing the result shapes.
*/
GEOM_Object MakePartition (in ListOfGO theShapes,
@ -1662,6 +1670,27 @@ module GEOM
in boolean theRemoveWebs,
in ListOfLong theMaterials);
/*!
* Perform partition operation.
* This method may be usefull if it is needed to make a partition for
* a compound containing nonintersected shapes. Performance will be better
* since intersection between shapes from compound is not performed.
*
* Description of all parameters as in previous method MakePartition()
*
* \note Passed compounds (via ListShapes or via ListTools)
* have to consist of nonintersecting shapes.
*
* \return New GEOM_Object, containing the result shapes.
*/
GEOM_Object MakePartitionNonSelfIntersectedShape (in ListOfGO theShapes,
in ListOfGO theTools,
in ListOfGO theKeepInside,
in ListOfGO theRemoveInside,
in short theLimit,
in boolean theRemoveWebs,
in ListOfLong theMaterials);
/*!
* Perform partition of the Shape with the Plane
* \param theShape Shape to be intersected.

@ -1,22 +1,23 @@
// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
//
// This library is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include <Standard_Stream.hxx>
#include <GEOMImpl_IBooleanOperations.hxx>
@ -44,7 +45,7 @@
* constructor:
*/
//=============================================================================
GEOMImpl_IBooleanOperations::GEOMImpl_IBooleanOperations (GEOM_Engine* theEngine, int theDocID)
GEOMImpl_IBooleanOperations::GEOMImpl_IBooleanOperations (GEOM_Engine* theEngine, int theDocID)
: GEOM_IOperations(theEngine, theDocID)
{
MESSAGE("GEOMImpl_IBooleanOperations::GEOMImpl_IBooleanOperations");
@ -73,10 +74,10 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeBoolean (Handle(GEOM_Object
SetErrorCode(KO);
if (theShape1.IsNull() || theShape2.IsNull()) return NULL;
//Add a new Boolean object
//Add a new Boolean object
Handle(GEOM_Object) aBool = GetEngine()->AddObject(GetDocID(), GEOM_BOOLEAN);
//Add a new Boolean function
Handle(GEOM_Function) aFunction;
if (theOp == 1) {
@ -92,10 +93,10 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeBoolean (Handle(GEOM_Object
if (aFunction.IsNull()) return NULL;
//Check if the function is set correctly
if (aFunction->GetDriverGUID() != GEOMImpl_BooleanDriver::GetID()) return NULL;
if (aFunction->GetDriverGUID() != GEOMImpl_BooleanDriver::GetID()) return NULL;
GEOMImpl_IBoolean aCI (aFunction);
Handle(GEOM_Function) aRef1 = theShape1->GetLastFunction();
Handle(GEOM_Function) aRef2 = theShape2->GetLastFunction();
@ -131,7 +132,7 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeBoolean (Handle(GEOM_Object
pd << theShape1 << ", " << theShape2 << ")";
SetErrorCode(OK);
return aBool;
return aBool;
}
//=============================================================================
@ -140,31 +141,32 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeBoolean (Handle(GEOM_Object
*/
//=============================================================================
Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakePartition
(const Handle(TColStd_HSequenceOfTransient)& theShapes,
(const Handle(TColStd_HSequenceOfTransient)& theShapes,
const Handle(TColStd_HSequenceOfTransient)& theTools,
const Handle(TColStd_HSequenceOfTransient)& theKeepIns,
const Handle(TColStd_HSequenceOfTransient)& theRemoveIns,
const Standard_Integer theLimit,
const Standard_Boolean theRemoveWebs,
const Handle(TColStd_HArray1OfInteger)& theMaterials)
const Standard_Integer theLimit,
const Standard_Boolean theRemoveWebs,
const Handle(TColStd_HArray1OfInteger)& theMaterials,
const Standard_Boolean thePerformSelfIntersections)
{
SetErrorCode(KO);
//Add a new Partition object
//Add a new Partition object
Handle(GEOM_Object) aPartition = GetEngine()->AddObject(GetDocID(), GEOM_PARTITION);
//Add a new Partition function
Handle(GEOM_Function) aFunction =
aPartition->AddFunction(GEOMImpl_PartitionDriver::GetID(), PARTITION_PARTITION);
Handle(GEOM_Function) aFunction;
if (thePerformSelfIntersections)
aFunction = aPartition->AddFunction(GEOMImpl_PartitionDriver::GetID(), PARTITION_PARTITION);
else
aFunction = aPartition->AddFunction(GEOMImpl_PartitionDriver::GetID(), PARTITION_NO_SELF_INTERSECTIONS);
if (aFunction.IsNull()) return NULL;
//Check if the function is set correctly
if (aFunction->GetDriverGUID() != GEOMImpl_PartitionDriver::GetID()) return NULL;
if (aFunction->GetDriverGUID() != GEOMImpl_PartitionDriver::GetID()) return NULL;
GEOMImpl_IPartition aCI (aFunction);
// int aLen = theShapes.size();
// aCI.SetLength(aLen);
Handle(TColStd_HSequenceOfTransient) aShapesSeq = new TColStd_HSequenceOfTransient;
Handle(TColStd_HSequenceOfTransient) aToolsSeq = new TColStd_HSequenceOfTransient;
@ -278,15 +280,19 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakePartition
return NULL;
}
//Make a Python command
//Make a Python command
GEOM::TPythonDump pd (aFunction);
pd << aPartition << " = geompy.MakePartition([";
if (thePerformSelfIntersections)
pd << aPartition << " = geompy.MakePartition([";
else
pd << aPartition << " = geompy.MakePartitionNonSelfIntersectedShape([";
// Shapes, Tools
pd << aShapesDescr.ToCString() << "], [" << aToolsDescr.ToCString() << "], [";
// Keep Ins, Remove Ins
pd << aKeepInsDescr.ToCString() << "], [" << aRemoveInsDescr.ToCString() << "], ";
// Limit, Remove Webs
pd << theLimit << ", " << (int)theRemoveWebs << ", [";
pd << TopAbs_ShapeEnum(theLimit) << ", " << (int)theRemoveWebs << ", [";
// Materials
if (!theMaterials.IsNull() && theMaterials->Length() > 0) {
int i = theMaterials->Lower();
@ -299,7 +305,7 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakePartition
pd << "])";
SetErrorCode(OK);
return aPartition;
return aPartition;
}
//=============================================================================
@ -313,20 +319,20 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeHalfPartition
SetErrorCode(KO);
if (theShape.IsNull() || thePlane.IsNull()) return NULL;
//Add a new Boolean object
Handle(GEOM_Object) aPart = GetEngine()->AddObject(GetDocID(), GEOM_BOOLEAN);
//Add a new Boolean object
Handle(GEOM_Object) aPart = GetEngine()->AddObject(GetDocID(), GEOM_PARTITION);
//Add a new Partition function
Handle(GEOM_Function) aFunction =
aPart->AddFunction(GEOMImpl_PartitionDriver::GetID(), PARTITION_HALF);
if (aFunction.IsNull()) return NULL;
//Check if the function is set correctly
if (aFunction->GetDriverGUID() != GEOMImpl_PartitionDriver::GetID()) return NULL;
if (aFunction->GetDriverGUID() != GEOMImpl_PartitionDriver::GetID()) return NULL;
GEOMImpl_IPartition aCI (aFunction);
Handle(GEOM_Function) aRef1 = theShape->GetLastFunction();
Handle(GEOM_Function) aRef2 = thePlane->GetLastFunction();
@ -351,10 +357,10 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeHalfPartition
return NULL;
}
//Make a Python command
//Make a Python command
GEOM::TPythonDump(aFunction) << aPart << " = geompy.MakeHalfPartition("
<< theShape << ", " << thePlane << ")";
SetErrorCode(OK);
return aPart;
return aPart;
}

@ -23,8 +23,6 @@
#include "GEOM_IOperations.hxx"
//#include "TColStd_HSequenceOfTransient.hxx"
#include "list"
class GEOM_Engine;
@ -37,19 +35,21 @@ class GEOMImpl_IBooleanOperations : public GEOM_IOperations {
Standard_EXPORT ~GEOMImpl_IBooleanOperations();
Standard_EXPORT Handle(GEOM_Object) MakeBoolean (Handle(GEOM_Object) theShape1,
Handle(GEOM_Object) theShape2,
Standard_Integer theOp);
Handle(GEOM_Object) theShape2,
Standard_Integer theOp);
Standard_EXPORT Handle(GEOM_Object) MakePartition (const Handle(TColStd_HSequenceOfTransient)& theShapes,
const Handle(TColStd_HSequenceOfTransient)& theTools,
const Handle(TColStd_HSequenceOfTransient)& theKeepInside,
const Handle(TColStd_HSequenceOfTransient)& theRemoveInside,
const Standard_Integer theLimit,
const Standard_Boolean theRemoveWebs,
const Handle(TColStd_HArray1OfInteger)& theMaterials);
Standard_EXPORT Handle(GEOM_Object) MakePartition
(const Handle(TColStd_HSequenceOfTransient)& theShapes,
const Handle(TColStd_HSequenceOfTransient)& theTools,
const Handle(TColStd_HSequenceOfTransient)& theKeepInside,
const Handle(TColStd_HSequenceOfTransient)& theRemoveInside,
const Standard_Integer theLimit,
const Standard_Boolean theRemoveWebs,
const Handle(TColStd_HArray1OfInteger)& theMaterials,
const Standard_Boolean thePerformSelfIntersections);
Standard_EXPORT Handle(GEOM_Object) MakeHalfPartition (Handle(GEOM_Object) theShape,
Handle(GEOM_Object) thePlane);
Handle(GEOM_Object) thePlane);
};
#endif

@ -1,18 +1,18 @@
// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
//
// This library is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
@ -36,12 +36,13 @@
#include <BRep_Tool.hxx>
#include <BRepAlgo.hxx>
#include <TopAbs.hxx>
#include <TopExp.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Wire.hxx>
#include <TopAbs.hxx>
#include <TopExp.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopTools_MapOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
@ -54,29 +55,54 @@
//=======================================================================
//function : GetID
//purpose :
//=======================================================================
//=======================================================================
const Standard_GUID& GEOMImpl_PartitionDriver::GetID()
{
static Standard_GUID aPartitionDriver("FF1BBB22-5D14-4df2-980B-3A668264EA16");
return aPartitionDriver;
return aPartitionDriver;
}
//=======================================================================
//function : GEOMImpl_PartitionDriver
//purpose :
//purpose :
//=======================================================================
GEOMImpl_PartitionDriver::GEOMImpl_PartitionDriver()
GEOMImpl_PartitionDriver::GEOMImpl_PartitionDriver()
{
}
//=======================================================================
//function : SimplifyCompound
//purpose :
//=======================================================================
static void PrepareShapes (const TopoDS_Shape& theShape,
Standard_Integer theType,
TopTools_ListOfShape& theSimpleList)
{
if (theType == PARTITION_NO_SELF_INTERSECTIONS ||
theShape.ShapeType() != TopAbs_COMPOUND) {
theSimpleList.Append(theShape);
return;
}
// explode compound on simple shapes to allow their intersections
TopoDS_Iterator It (theShape, Standard_True, Standard_True);
TopTools_MapOfShape mapShape;
for (; It.More(); It.Next()) {
if (mapShape.Add(It.Value())) {
TopoDS_Shape curSh = It.Value();
PrepareShapes(curSh, theType, theSimpleList);
}
}
}
//=======================================================================
//function : Execute
//purpose :
//=======================================================================
//=======================================================================
Standard_Integer GEOMImpl_PartitionDriver::Execute(TFunction_Logbook& log) const
{
if (Label().IsNull()) return 0;
if (Label().IsNull()) return 0;
Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
GEOMImpl_IPartition aCI (aFunction);
@ -86,19 +112,21 @@ Standard_Integer GEOMImpl_PartitionDriver::Execute(TFunction_Logbook& log) const
//sklNMTAlgo_Splitter1 PS;
GEOMAlgo_Splitter PS;
if (aType == PARTITION_PARTITION) {
if (aType == PARTITION_PARTITION || aType == PARTITION_NO_SELF_INTERSECTIONS)
{
Handle(TColStd_HSequenceOfTransient) aShapes = aCI.GetShapes();
Handle(TColStd_HSequenceOfTransient) aTools = aCI.GetTools();
Handle(TColStd_HSequenceOfTransient) aKeepIns = aCI.GetKeepIns();
Handle(TColStd_HSequenceOfTransient) aRemIns = aCI.GetRemoveIns();
Handle(TColStd_HArray1OfInteger) aMaterials = aCI.GetMaterials();
//sklStandard_Boolean DoRemoveWebs = !aMaterials.IsNull();
//skl Standard_Boolean DoRemoveWebs = !aMaterials.IsNull();
unsigned int ind, nbshapes = 0;
nbshapes += aShapes->Length() + aTools->Length();
nbshapes += aKeepIns->Length() + aRemIns->Length();
TopTools_MapOfShape ShapesMap(nbshapes), ToolsMap(nbshapes);
unsigned int ind;
//unsigned int ind, nbshapes = 0;
//nbshapes += aShapes->Length() + aTools->Length();
//nbshapes += aKeepIns->Length() + aRemIns->Length();
//TopTools_MapOfShape ShapesMap(nbshapes), ToolsMap(nbshapes);
TopTools_MapOfShape ShapesMap, ToolsMap;
// add object shapes that are in ListShapes;
for (ind = 1; ind <= aShapes->Length(); ind++) {
@ -107,12 +135,19 @@ Standard_Integer GEOMImpl_PartitionDriver::Execute(TFunction_Logbook& log) const
if (aShape_i.IsNull()) {
Standard_NullObject::Raise("In Partition a shape is null");
}
if (ShapesMap.Add(aShape_i)) {
PS.AddShape(aShape_i);
//skl if (DoRemoveWebs) {
//skl if (aMaterials->Length() >= ind)
//skl PS.SetMaterial(aShape_i, aMaterials->Value(ind));
//skl }
//
TopTools_ListOfShape aSimpleShapes;
PrepareShapes(aShape_i, aType, aSimpleShapes);
TopTools_ListIteratorOfListOfShape aSimpleIter (aSimpleShapes);
for (; aSimpleIter.More(); aSimpleIter.Next()) {
const TopoDS_Shape& aSimpleSh = aSimpleIter.Value();
if (ShapesMap.Add(aSimpleSh)) {
PS.AddShape(aSimpleSh);
//skl if (DoRemoveWebs) {
//skl if (aMaterials->Length() >= ind)
//skl PS.SetMaterial(aSimpleSh, aMaterials->Value(ind));
//skl }
}
}
}
@ -123,8 +158,15 @@ Standard_Integer GEOMImpl_PartitionDriver::Execute(TFunction_Logbook& log) const
if (aShape_i.IsNull()) {
Standard_NullObject::Raise("In Partition a tool shape is null");
}
if (!ShapesMap.Contains(aShape_i) && ToolsMap.Add(aShape_i)) {
PS.AddTool(aShape_i);
//
TopTools_ListOfShape aSimpleShapes;
PrepareShapes(aShape_i, aType, aSimpleShapes);
TopTools_ListIteratorOfListOfShape aSimpleIter (aSimpleShapes);
for (; aSimpleIter.More(); aSimpleIter.Next()) {
const TopoDS_Shape& aSimpleSh = aSimpleIter.Value();
if (!ShapesMap.Contains(aSimpleSh) && ToolsMap.Add(aSimpleSh)) {
PS.AddTool(aSimpleSh);
}
}
}
@ -135,8 +177,15 @@ Standard_Integer GEOMImpl_PartitionDriver::Execute(TFunction_Logbook& log) const
if (aShape_i.IsNull()) {
Standard_NullObject::Raise("In Partition a Keep Inside shape is null");
}
if (!ToolsMap.Contains(aShape_i) && ShapesMap.Add(aShape_i))
PS.AddShape(aShape_i);
//
TopTools_ListOfShape aSimpleShapes;
PrepareShapes(aShape_i, aType, aSimpleShapes);
TopTools_ListIteratorOfListOfShape aSimpleIter (aSimpleShapes);
for (; aSimpleIter.More(); aSimpleIter.Next()) {
const TopoDS_Shape& aSimpleSh = aSimpleIter.Value();
if (!ToolsMap.Contains(aSimpleSh) && ShapesMap.Add(aSimpleSh))
PS.AddShape(aSimpleSh);
}
}
// add shapes that are in ListRemoveInside, as object shapes;
@ -146,16 +195,23 @@ Standard_Integer GEOMImpl_PartitionDriver::Execute(TFunction_Logbook& log) const
if (aShape_i.IsNull()) {
Standard_NullObject::Raise("In Partition a Remove Inside shape is null");
}
if (!ToolsMap.Contains(aShape_i) && ShapesMap.Add(aShape_i))
PS.AddShape(aShape_i);
//
TopTools_ListOfShape aSimpleShapes;
PrepareShapes(aShape_i, aType, aSimpleShapes);
TopTools_ListIteratorOfListOfShape aSimpleIter (aSimpleShapes);
for (; aSimpleIter.More(); aSimpleIter.Next()) {
const TopoDS_Shape& aSimpleSh = aSimpleIter.Value();
if (!ToolsMap.Contains(aSimpleSh) && ShapesMap.Add(aSimpleSh))
PS.AddShape(aSimpleSh);
}
}
PS.SetLimit( (TopAbs_ShapeEnum)aCI.GetLimit() );
PS.Perform();
//sklPS.Compute();
//sklPS.SetRemoveWebs(!DoRemoveWebs);
//sklPS.Build((TopAbs_ShapeEnum) aCI.GetLimit());
//skl PS.Compute();
//skl PS.SetRemoveWebs(!DoRemoveWebs);
//skl PS.Build((TopAbs_ShapeEnum) aCI.GetLimit());
/*skl
// suppress result outside of shapes in KInsideMap
for (ind = 1; ind <= aKeepIns->Length(); ind++) {
@ -172,7 +228,8 @@ Standard_Integer GEOMImpl_PartitionDriver::Execute(TFunction_Logbook& log) const
}
*/
}
else if (aType == PARTITION_HALF) {
else if (aType == PARTITION_HALF)
{
Handle(GEOM_Function) aRefShape = aCI.GetShape();
Handle(GEOM_Function) aRefPlane = aCI.GetPlane();
TopoDS_Shape aShapeArg = aRefShape->GetValue();
@ -188,7 +245,7 @@ Standard_Integer GEOMImpl_PartitionDriver::Execute(TFunction_Logbook& log) const
// add tool shapes that are in ListTools and not in ListShapes;
PS.AddTool(aPlaneArg);
//sklPS.Compute();
//skl PS.Compute();
PS.Perform();
//PS.SetRemoveWebs(Standard_False);
//PS.Build(aShapeArg.ShapeType());
@ -263,17 +320,17 @@ Standard_Integer GEOMImpl_PartitionDriver::Execute(TFunction_Logbook& log) const
//=======================================================================
//function : GEOMImpl_PartitionDriver_Type_
//purpose :
//=======================================================================
//=======================================================================
Standard_EXPORT Handle_Standard_Type& GEOMImpl_PartitionDriver_Type_()
{
static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver);
if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver);
static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared);
if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared);
if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared);
static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient);
if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient);
static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL};
static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_PartitionDriver",
@ -288,7 +345,7 @@ Standard_EXPORT Handle_Standard_Type& GEOMImpl_PartitionDriver_Type_()
//=======================================================================
//function : DownCast
//purpose :
//=======================================================================
//=======================================================================
const Handle(GEOMImpl_PartitionDriver) Handle(GEOMImpl_PartitionDriver)::DownCast(const Handle(Standard_Transient)& AnObject)
{
Handle(GEOMImpl_PartitionDriver) _anOtherObject;

@ -173,6 +173,7 @@
#define PARTITION_PARTITION 1
#define PARTITION_HALF 2
#define PARTITION_NO_SELF_INTERSECTIONS 3
#define POLYLINE_POINTS 1

@ -1,22 +1,23 @@
// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
//
// This library is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include <Standard_Stream.hxx>
#include "GEOM_IBooleanOperations_i.hh"
@ -57,7 +58,7 @@ GEOM_IBooleanOperations_i::~GEOM_IBooleanOperations_i()
/*!
* MakeBoolean
*/
//=============================================================================
//=============================================================================
GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeBoolean
(GEOM::GEOM_Object_ptr theShape1,
GEOM::GEOM_Object_ptr theShape2,
@ -90,14 +91,14 @@ GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeBoolean
/*!
* MakePartition
*/
//=============================================================================
//=============================================================================
GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakePartition
(const GEOM::ListOfGO& theShapes,
const GEOM::ListOfGO& theTools,
const GEOM::ListOfGO& theKeepIns,
const GEOM::ListOfGO& theRemoveIns,
const CORBA::Short theLimit,
const CORBA::Boolean theRemoveWebs,
CORBA::Short theLimit,
CORBA::Boolean theRemoveWebs,
const GEOM::ListOfLong& theMaterials)
{
GEOM::GEOM_Object_var aGEOMObject;
@ -164,7 +165,94 @@ GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakePartition
// Make Partition
Handle(GEOM_Object) anObject =
GetOperations()->MakePartition(aShapes, aTools, aKeepIns, aRemIns,
theLimit, theRemoveWebs, aMaterials);
theLimit, theRemoveWebs, aMaterials,
/*PerformSelfIntersections*/Standard_True);
if (!GetOperations()->IsDone() || anObject.IsNull())
return aGEOMObject._retn();
return GetObject(anObject);
}
//=============================================================================
/*!
* MakePartitionNonSelfIntersectedShape
*/
//=============================================================================
GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakePartitionNonSelfIntersectedShape
(const GEOM::ListOfGO& theShapes,
const GEOM::ListOfGO& theTools,
const GEOM::ListOfGO& theKeepIns,
const GEOM::ListOfGO& theRemoveIns,
CORBA::Short theLimit,
CORBA::Boolean theRemoveWebs,
const GEOM::ListOfLong& theMaterials)
{
GEOM::GEOM_Object_var aGEOMObject;
//Set a not done flag
GetOperations()->SetNotDone();
int ind, aLen;
Handle(TColStd_HSequenceOfTransient) aShapes = new TColStd_HSequenceOfTransient;
Handle(TColStd_HSequenceOfTransient) aTools = new TColStd_HSequenceOfTransient;
Handle(TColStd_HSequenceOfTransient) aKeepIns = new TColStd_HSequenceOfTransient;
Handle(TColStd_HSequenceOfTransient) aRemIns = new TColStd_HSequenceOfTransient;
Handle(TColStd_HArray1OfInteger) aMaterials;
//Get the shapes
aLen = theShapes.length();
for (ind = 0; ind < aLen; ind++) {
if (theShapes[ind] == NULL) return aGEOMObject._retn();
Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject
(theShapes[ind]->GetStudyID(), theShapes[ind]->GetEntry());
if (aSh.IsNull()) return aGEOMObject._retn();
aShapes->Append(aSh);
}
//Get the tools
aLen = theTools.length();
for (ind = 0; ind < aLen; ind++) {
if (theTools[ind] == NULL) return aGEOMObject._retn();
Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject
(theTools[ind]->GetStudyID(), theTools[ind]->GetEntry());
if (aSh.IsNull()) return aGEOMObject._retn();
aTools->Append(aSh);
}
//Get the keep inside shapes
aLen = theKeepIns.length();
for (ind = 0; ind < aLen; ind++) {
if (theKeepIns[ind] == NULL) return aGEOMObject._retn();
Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject
(theKeepIns[ind]->GetStudyID(), theKeepIns[ind]->GetEntry());
if (aSh.IsNull()) return aGEOMObject._retn();
aKeepIns->Append(aSh);
}
//Get the remove inside shapes
aLen = theRemoveIns.length();
for (ind = 0; ind < aLen; ind++) {
if (theRemoveIns[ind] == NULL) return aGEOMObject._retn();
Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject
(theRemoveIns[ind]->GetStudyID(), theRemoveIns[ind]->GetEntry());
if (aSh.IsNull()) return aGEOMObject._retn();
aRemIns->Append(aSh);
}
//Get the materials
aLen = theMaterials.length();
if ( aLen ) {
aMaterials = new TColStd_HArray1OfInteger (1, aLen);
for (ind = 0; ind < aLen; ind++) {
aMaterials->SetValue(ind+1, theMaterials[ind]);
}
}
// Make Partition
Handle(GEOM_Object) anObject =
GetOperations()->MakePartition(aShapes, aTools, aKeepIns, aRemIns,
theLimit, theRemoveWebs, aMaterials,
/*PerformSelfIntersections*/Standard_False);
if (!GetOperations()->IsDone() || anObject.IsNull())
return aGEOMObject._retn();
@ -175,7 +263,7 @@ GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakePartition
/*!
* MakeHalfPartition
*/
//=============================================================================
//=============================================================================
GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeHalfPartition
(GEOM::GEOM_Object_ptr theShape,
GEOM::GEOM_Object_ptr thePlane)

@ -47,10 +47,18 @@ class GEOM_IBooleanOperations_i :
const GEOM::ListOfGO& theTools,
const GEOM::ListOfGO& theKeepInside,
const GEOM::ListOfGO& theRemoveInside,
CORBA::Short theLimit,
CORBA::Boolean theRemoveWebs,
CORBA::Short theLimit,
CORBA::Boolean theRemoveWebs,
const GEOM::ListOfLong& theMaterials);
GEOM::GEOM_Object_ptr MakePartitionNonSelfIntersectedShape (const GEOM::ListOfGO& theShapes,
const GEOM::ListOfGO& theTools,
const GEOM::ListOfGO& theKeepInside,
const GEOM::ListOfGO& theRemoveInside,
CORBA::Short theLimit,
CORBA::Boolean theRemoveWebs,
const GEOM::ListOfLong& theMaterials);
GEOM::GEOM_Object_ptr MakeHalfPartition (GEOM::GEOM_Object_ptr theShape,
GEOM::GEOM_Object_ptr thePlane);

@ -1379,27 +1379,13 @@ def MakeFuse(s1, s2):
def MakeSection(s1, s2):
return MakeBoolean(s1, s2, 4)
## Perform explode of compound
# Auxilary method for MakePartition
def ExplodeCompound(aComp):
ResListShapes = []
shapes = SubShapeAll(aComp,ShapeType["SHAPE"])
nbss = len(shapes)
for i in range(0,nbss):
if shapes[i].GetShapeType()==GEOM.COMPOUND:
ResListShapes.extend(ExplodeCompound(shapes[i]))
else:
ResListShapes.append(shapes[i])
pass
pass
return ResListShapes
## Perform partition operation.
# @param ListShapes Shapes to be intersected.
# @param ListTools Shapes to intersect theShapes.
# !!!NOTE: Each compound from ListShapes and ListTools will be exploded
# in order to avoid possible intersection between shapes from
# this compound.
# @param Limit Type of resulting shapes (corresponding to TopAbs_ShapeEnum).
#
# After implementation new version of PartitionAlgo (October 2006)
# other parameters are ignored by current functionality. They are kept
@ -1409,7 +1395,6 @@ def ExplodeCompound(aComp):
# Each shape from theKeepInside must belong to theShapes also.
# @param ListRemoveInside Shapes, inside which the results will be deleted.
# Each shape from theRemoveInside must belong to theShapes also.
# @param Limit Type of resulting shapes (corresponding to TopAbs_ShapeEnum).
# @param RemoveWebs If TRUE, perform Glue 3D algorithm.
# @param ListMaterials Material indices for each shape. Make sence,
# only if theRemoveWebs is TRUE.
@ -1419,28 +1404,12 @@ def ExplodeCompound(aComp):
# Example: see GEOM_TestAll.py
def MakePartition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[]):
NewListShapes = []
nbs = len(ListShapes)
for i in range(0,nbs):
if ListShapes[i].GetShapeType()==GEOM.COMPOUND:
# need to explode
NewListShapes.extend(ExplodeCompound(ListShapes[i]))
else: NewListShapes.append(ListShapes[i])
pass
NewListTools = []
nbs = len(ListTools)
for i in range(0,nbs):
if ListTools[i].GetShapeType()==GEOM.COMPOUND:
# need to explode
NewListTools.extend(ExplodeCompound(ListTools[i]))
else: NewListTools.append(ListTools[i])
pass
return MakePartitionNonSelfIntersectedShape(NewListShapes, NewListTools,
ListKeepInside, ListRemoveInside,
Limit, RemoveWebs, ListMaterials)
anObj = BoolOp.MakePartition(ListShapes, ListTools,
ListKeepInside, ListRemoveInside,
Limit, RemoveWebs, ListMaterials);
if BoolOp.IsDone() == 0:
print "MakePartition : ", BoolOp.GetErrorCode()
return anObj
## Perform partition operation.
# This method may be useful if it is needed to make a partition for
@ -1449,19 +1418,18 @@ def MakePartition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=
#
# Description of all parameters as in previous method MakePartition()
#
# !!!NOTE: Compounds from ListShapes can not have intersections with each
# other and compounds from ListTools can not have intersections
# with each other.
# !!!NOTE: Passed compounds (via ListShapes or via ListTools)
# have to consist of nonintersecting shapes.
#
# @return New GEOM_Object, containing the result shapes.
#
def MakePartitionNonSelfIntersectedShape(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[]):
anObj = BoolOp.MakePartition(ListShapes, ListTools,
ListKeepInside, ListRemoveInside,
Limit, RemoveWebs, ListMaterials);
anObj = BoolOp.MakePartitionNonSelfIntersectedShape(ListShapes, ListTools,
ListKeepInside, ListRemoveInside,
Limit, RemoveWebs, ListMaterials);
if BoolOp.IsDone() == 0:
print "MakePartition : ", BoolOp.GetErrorCode()
print "MakePartitionNonSelfIntersectedShape : ", BoolOp.GetErrorCode()
return anObj
## Shortcut to MakePartition()