22746: [EDF] Improvement of Glue Faces and Glue Edges operations

This commit is contained in:
eap 2014-10-14 20:45:17 +04:00
parent 79f33ff735
commit 9a5dbc5a8d
33 changed files with 682 additions and 482 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View File

@ -7,7 +7,7 @@
\n This operation glues edges that are coincident with respect to the \n This operation glues edges that are coincident with respect to the
given tolerance value. given tolerance value.
\n <b>Arguments:</b> Name + Compound of shapes + Tolerance value. \n <b>Arguments:</b> Name + Shapes + Tolerance value.
\n <b>Advanced option:</b> \n <b>Advanced option:</b>
\ref restore_presentation_parameters_page "Set presentation parameters and sub-shapes from arguments". \ref restore_presentation_parameters_page "Set presentation parameters and sub-shapes from arguments".
\n The \b Result will be a \b GEOM_Object. \n The \b Result will be a \b GEOM_Object.
@ -16,10 +16,10 @@ given tolerance value.
\image html glue4.png \image html glue4.png
\n <b>TUI Command:</b> \n <b>TUI Command:</b>
\n <em>geompy.MakeGlueEdges(theShape,theTolerance)</em>, <p><em>geompy.MakeGlueEdges( theShapes, theTolerance )</em>,
\n where \em theShape is a compound of shapes to be glued, and \em \n where \em theShapes is either a list or compound of shapes to be
theTolerance is a maximum distance between two faces/edges, which can glued, and \em theTolerance is a maximum distance between two
be considered as coincident. edges, which can be considered as coincident.
\n It is also possible to manually select the edges that will be \n It is also possible to manually select the edges that will be
glued - select the shape, specify the tolerance and press \b Detect button. glued - select the shape, specify the tolerance and press \b Detect button.
@ -36,23 +36,24 @@ possible to select the edges for gluing in the 3D viewer.
The selected edges will be marked in white. The selected edges will be marked in white.
\n <b>TUI Command:</b> \n <b>TUI Command:</b>
\n <em>geompy.GetGlueEdges(theShape,theTolerance)</em>, <p><em>geompy.GetGlueEdges( theShapes, theTolerance )</em>,
\n where \em theShape is a compound of shapes to be glued, \em \n where \em theShape is either a list or compound of shapes to be glued, \em
theTolerance is a maximum distance between two edges, which can theTolerance is a maximum distance between two edges, which can
be considered as coincident. The \b Result will be a list of \b be considered as coincident. The \b Result will be a list of \b
GEOM_Objects, containing one sub-shape per each detected set of GEOM_Objects (edges), containing one sub-shape per each detected set of
coincident sub-shapes. coincident sub-shapes. For example if there are two coincident edges
in selected shapes, the result list contains one of the two coincident edges.
\n <em>geompy.MakeGlueEdgesByList(theShape,theTolerance,theEdges)</em>, <em>geompy.MakeGlueEdgesByList( theShapes, theTolerance, theEdges )</em>,
\n where \em theShape is a compound of shapes to be glued, \em \n where \em theShape is either a list or compound of shapes to be glued, \em
theTolerance is a maximum distance between two edges, which can theTolerance is a maximum distance between two edges, which can
be considered as coincident, \em theEdges is a list of be considered as coincident, \em theEdges is a list of
sub-shapes to be glued. edges to be glued.
\n <b>Example:</b> \n <b>Example:</b>
\image html glue8.png \image html glue8.png
<center><em>Box with an edge that can be glued</em></center> <center><em>Two boxes with an edge that can be glued</em></center>
Our <b>TUI Scripts</b> provide you with useful examples of the use of Our <b>TUI Scripts</b> provide you with useful examples of the use of
<b>Repairing Operations</b> \ref tui_glue_edges "Glue Edges". <b>Repairing Operations</b> \ref tui_glue_edges "Glue Edges".

View File

@ -8,7 +8,7 @@
\n This operation glues faces that are coincident with respect to the \n This operation glues faces that are coincident with respect to the
given tolerance value. given tolerance value.
\n <b>Arguments:</b> Name + Compound of shapes + Tolerance value. \n <b>Arguments:</b> Name + Shapes + Tolerance value.
\n <b>Advanced option:</b> \n <b>Advanced option:</b>
\ref restore_presentation_parameters_page "Set presentation parameters and sub-shapes from arguments". \ref restore_presentation_parameters_page "Set presentation parameters and sub-shapes from arguments".
\n The \b Result will be a \b GEOM_Object. \n The \b Result will be a \b GEOM_Object.
@ -17,8 +17,9 @@ given tolerance value.
\n <b>TUI Commands:</b> \n <b>TUI Commands:</b>
\n <em>geompy.MakeGlueFaces(theShape,theTolerance,doKeepNonSolids)</em>,
\n where \em theShape is a compound of shapes to be glued, \em <em>geompy.MakeGlueFaces( theShapes, theTolerance, doKeepNonSolids )</em>,
\n where \em theShapes is either a list or compound of shapes to be glued, \em
theTolerance is a maximum distance between two faces, which can theTolerance is a maximum distance between two faces, which can
be considered as coincident. The \em doKeepNonSolids flag allows to be considered as coincident. The \em doKeepNonSolids flag allows to
throw away non-solids from the result, if false. The \b Result will throw away non-solids from the result, if false. The \b Result will
@ -38,20 +39,23 @@ performed and displays a notification.
possible to select the faces for gluing in the 3D viewer. possible to select the faces for gluing in the 3D viewer.
The selected faces will be marked in white. The selected faces will be marked in white.
\n When the faces are glued their edges are glued as well. By default, other When the faces are glued their edges are glued as well. By default, other
edges are not glued. To force gluing of all edges, check <b>Glue all coincident edges</b> edges are not glued. To force gluing of all edges, check <b>Glue all coincident edges</b>
checkbox. checkbox.
\n <b>TUI Commands:</b> \n <b>TUI Commands:</b>
\n <em>geompy.GetGlueFaces(theShape,theTolerance)</em>,
\n where \em theShape is a compound of shapes to be glued, \em <em>geompy.GetGlueFaces( theShapes, theTolerance )</em>,
\n where \em theShapes is either a list or compound of shapes to be glued, \em
theTolerance is a maximum distance between two faces, which can theTolerance is a maximum distance between two faces, which can
be considered as coincident. The \b Result will be a list of \b be considered as coincident. The \b Result will be a list of \b
GEOM_Objects, containing one sub-shape per each detected set of GEOM_Objects (faces), containing one sub-shape per each detected set of
coincident sub-shapes. coincident sub-shapes. For example if there are two coincident faces
in selected shapes, the result list contains one of the two coincident faces.
\n <em>geompy.MakeGlueFacesByList(theShape,theTolerance,theFaces,doKeepNonSolids,doGlueAllEdges)</em>, <em>geompy.MakeGlueFacesByList( theShapes, theTolerance, theFaces,
\n where \em theShape is a compound of shapes to be glued, \em doKeepNonSolids, doGlueAllEdges )</em>,
\n where \em theShapes is either a list or compound of shapes to be glued, \em
theTolerance is a maximum distance between two faces, which can theTolerance is a maximum distance between two faces, which can
be considered as coincident, \em theFaces is a list of be considered as coincident, \em theFaces is a list of
sub-shapes to be glued. The \em doKeepNonSolids flag allows to throw sub-shapes to be glued. The \em doKeepNonSolids flag allows to throw

View File

@ -5,7 +5,7 @@
\n To <b>Remove internal faces</b> in the <b>Main Menu</b> select \n To <b>Remove internal faces</b> in the <b>Main Menu</b> select
<b>Repair - > Remove internal faces</b>. <b>Repair - > Remove internal faces</b>.
\n This operation removes all shared faces from a compound to obtain This operation removes all shared faces from a compound to obtain
one or more bigger solids from a set of smaller solids. one or more bigger solids from a set of smaller solids.
\image html remove_webs.png \image html remove_webs.png
@ -15,10 +15,11 @@ one or more bigger solids from a set of smaller solids.
\ref restore_presentation_parameters_page "Set presentation parameters and sub-shapes from arguments". \ref restore_presentation_parameters_page "Set presentation parameters and sub-shapes from arguments".
\note Only shared faces will be removed. Coincident but not shared \note Only shared faces will be removed. Coincident but not shared
faces will stay as is, use Glue Faces or Partition before faces will stay as is, use \ref glue_faces_operation_page or \ref partition_page before
Remove Internal Faces if you need to remove them. <b>Remove Internal Faces</b> if you need to remove them.
\n <b>TUI Command:</b> <em>geompy.RemoveInternalFaces(theCompound)</em>, \n <b>TUI Command:</b> <br>
<em>geompy.RemoveInternalFaces( theCompound )</em>,<br>
where <em>theCompound</em> is a compound of solids. where <em>theCompound</em> is a compound of solids.
\n Our <b>TUI Scripts</b> provide you with useful examples of the \n Our <b>TUI Scripts</b> provide you with useful examples of the

View File

@ -16,9 +16,9 @@ open contour asnd miodifies the underlying face.</li>
holes with free boundaries on a selected face.</li> holes with free boundaries on a selected face.</li>
<li>\subpage sewing_operation_page "Sewing" - sews faces or shells.</li> <li>\subpage sewing_operation_page "Sewing" - sews faces or shells.</li>
<li>\subpage glue_faces_operation_page "Glue faces" - unites <li>\subpage glue_faces_operation_page "Glue faces" - unites
coincident faces within the given tolerance.</li> faces coincident within the given tolerance.</li>
<li>\subpage glue_edges_operation_page "Glue edges" - unites <li>\subpage glue_edges_operation_page "Glue edges" - unites
coincident edges within the given tolerance.</li> edges coincident within the given tolerance.</li>
<li>\subpage limit_tolerance_operation_page "Limit Tolerance" - tries <li>\subpage limit_tolerance_operation_page "Limit Tolerance" - tries
to set new tolerance value for the given shape.</li> to set new tolerance value for the given shape.</li>
<li>\subpage add_point_on_edge_operation_page "Add point on edge" - <li>\subpage add_point_on_edge_operation_page "Add point on edge" -

View File

@ -1939,63 +1939,63 @@ module GEOM
GEOM_Object MakeCompound (in ListOfGO theShapes); GEOM_Object MakeCompound (in ListOfGO theShapes);
/*! /*!
* \brief Replace coincident faces in theShape by one face. * \brief Replace coincident faces in \a theShapes by one face.
* \param theShape Initial shape. * \param theShapes Initial shapes.
* \param theTolerance Maximum distance between faces, which can be considered as coincident. * \param theTolerance Maximum distance between faces, which can be considered as coincident.
* \param doKeepNonSolids If FALSE, only solids will present in the result, otherwise all initial shapes. * \param doKeepNonSolids If FALSE, only solids will present in the result, otherwise all initial shapes.
* \return New GEOM_Object, containing a copy of theShape without coincident faces. * \return New GEOM_Object containing copies of theShapes without coincident faces.
*/ */
GEOM_Object MakeGlueFaces (in GEOM_Object theShape, in double theTolerance, in boolean doKeepNonSolids); GEOM_Object MakeGlueFaces (in ListOfGO theShapes, in double theTolerance, in boolean doKeepNonSolids);
/*! /*!
* Find coincident faces in theShape for possible gluing. * Find coincident faces in theShapes for possible gluing.
* \param theShape Initial shape. * \param theShapes Initial shapes.
* \param theTolerance Maximum distance between faces, which can be considered as coincident. * \param theTolerance Maximum distance between faces, which can be considered as coincident.
* \return ListOfGO * \return ListOfGO
*/ */
ListOfGO GetGlueFaces (in GEOM_Object theShape, in double theTolerance); ListOfGO GetGlueFaces (in ListOfGO theShapes, in double theTolerance);
/*! /*!
* \brief Replace coincident faces in theShape by one face * \brief Replace coincident faces in \a theShapes by one face
* in compliance with given list of faces * in compliance with given list of faces
* \param theShape Initial shape. * \param theShapes Initial shapes.
* \param theTolerance Maximum distance between faces, which can be considered as coincident. * \param theTolerance Maximum distance between faces, which can be considered as coincident.
* \param theFaces List of faces for gluing. * \param theFaces List of faces for gluing.
* \param doKeepNonSolids If FALSE, only solids will present in the result, otherwise all initial shapes. * \param doKeepNonSolids If FALSE, only solids will present in the result, otherwise all initial shapes.
* \param doGlueAllEdges If TRUE, all coincident edges of <VAR>theShape</VAR> * \param doGlueAllEdges If TRUE, all coincident edges of <VAR>theShape</VAR>
* will be glued, otherwise only the edges, * will be glued, otherwise only the edges,
* belonging to <VAR>theFaces</VAR>. * belonging to <VAR>theFaces</VAR>.
* \return New GEOM_Object, containing a copy of theShape without some faces. * \return New GEOM_Object containing copies of theShapes without coincident faces.
*/ */
GEOM_Object MakeGlueFacesByList (in GEOM_Object theShape, in double theTolerance, GEOM_Object MakeGlueFacesByList (in ListOfGO theShapes, in double theTolerance,
in ListOfGO theFaces, in boolean doKeepNonSolids, in ListOfGO theFaces, in boolean doKeepNonSolids,
in boolean doGlueAllEdges); in boolean doGlueAllEdges);
/*! /*!
* \brief Replace coincident edges in theShape by one edge. * \brief Replace coincident edges in \a theShapes by one edge.
* \param theShape Initial shape. * \param theShapes Initial shapes.
* \param theTolerance Maximum distance between edges, which can be considered as coincident. * \param theTolerance Maximum distance between edges, which can be considered as coincident.
* \return New GEOM_Object, containing a copy of theShape without coincident edges. * \return New GEOM_Object containing copies of theShapes without coincident edges.
*/ */
GEOM_Object MakeGlueEdges (in GEOM_Object theShape, in double theTolerance); GEOM_Object MakeGlueEdges (in ListOfGO theShapes, in double theTolerance);
/*! /*!
* Find coincident edges in theShape for possible gluing. * Find coincident edges in \a theShapes for possible gluing.
* \param theShape Initial shape. * \param theShapes Initial shapes.
* \param theTolerance Maximum distance between edges, which can be considered as coincident. * \param theTolerance Maximum distance between edges, which can be considered as coincident.
* \return ListOfGO * \return ListOfGO
*/ */
ListOfGO GetGlueEdges (in GEOM_Object theShape, in double theTolerance); ListOfGO GetGlueEdges (in ListOfGO theShapes, in double theTolerance);
/*! /*!
* \brief Replace coincident edges in theShape by one edge * \brief Replace coincident edges in \a theShapes by one edge
* in compliance with given list of edges * in compliance with given list of edges
* \param theShape Initial shape. * \param theShapes Initial shapes.
* \param theTolerance Maximum distance between edges, which can be considered as coincident. * \param theTolerance Maximum distance between edges, which can be considered as coincident.
* \param theEdges List of edges for gluing. * \param theEdges List of edges for gluing.
* \return New GEOM_Object, containing a copy of theShape without some edges. * \return New GEOM_Object containing copies of theShapes without some edges.
*/ */
GEOM_Object MakeGlueEdgesByList (in GEOM_Object theShape, GEOM_Object MakeGlueEdgesByList (in ListOfGO theShape,
in double theTolerance, in double theTolerance,
in ListOfGO theEdges); in ListOfGO theEdges);

View File

@ -1669,7 +1669,8 @@ bool AdvancedEngine_IOperations::MakePipeTShapeMirrorAndGlue(Handle(GEOM_Object)
TColStd_IndexedDataMapOfTransientTransient aMapTShapes; TColStd_IndexedDataMapOfTransientTransient aMapTShapes;
TNaming_CopyShape::CopyTool(Te7->GetValue(), aMapTShapes, aShapeCopy); TNaming_CopyShape::CopyTool(Te7->GetValue(), aMapTShapes, aShapeCopy);
Handle(GEOM_Object) Te8 = myShapesOperations->MakeGlueFaces(Te7, 1e-7, true); std::list<Handle(GEOM_Object)> Te7list( 1, Te7 );
Handle(GEOM_Object) Te8 = myShapesOperations->MakeGlueFaces(Te7list, 1e-7, true);
if (Te8.IsNull()) { if (Te8.IsNull()) {
SetErrorCode("Impossible to glue faces of TShape"); SetErrorCode("Impossible to glue faces of TShape");
return false; return false;
@ -1694,7 +1695,7 @@ bool AdvancedEngine_IOperations::MakePipeTShapeMirrorAndGlue(Handle(GEOM_Object)
// Perform gluing // Perform gluing
Te7->GetLastFunction()->SetValue(aShapeCopy); Te7->GetLastFunction()->SetValue(aShapeCopy);
Te8 = myShapesOperations->MakeGlueFaces(Te7, aTolMax, true); Te8 = myShapesOperations->MakeGlueFaces(Te7list, aTolMax, true);
if (Te8.IsNull()) { if (Te8.IsNull()) {
SetErrorCode("Impossible to glue faces of TShape"); SetErrorCode("Impossible to glue faces of TShape");

View File

@ -46,7 +46,7 @@
*/ */
//============================================================================= //=============================================================================
Handle(GEOM_Object) GEOM_Object::GetObject(TDF_Label& theLabel) Handle(GEOM_Object) GEOM_Object::GetObject(const TDF_Label& theLabel)
{ {
Handle(GEOM_BaseObject) base = GEOM_BaseObject::GetObject(theLabel); Handle(GEOM_BaseObject) base = GEOM_BaseObject::GetObject(theLabel);
return Handle(GEOM_Object)::DownCast( base ); return Handle(GEOM_Object)::DownCast( base );
@ -58,7 +58,7 @@ Handle(GEOM_Object) GEOM_Object::GetObject(TDF_Label& theLabel)
*/ */
//============================================================================= //=============================================================================
Handle(GEOM_Object) GEOM_Object::GetReferencedObject(TDF_Label& theLabel) Handle(GEOM_Object) GEOM_Object::GetReferencedObject(const TDF_Label& theLabel)
{ {
Handle(GEOM_BaseObject) base = GEOM_BaseObject::GetReferencedObject(theLabel); Handle(GEOM_BaseObject) base = GEOM_BaseObject::GetReferencedObject(theLabel);
return Handle(GEOM_Object)::DownCast( base ); return Handle(GEOM_Object)::DownCast( base );
@ -275,5 +275,27 @@ bool GEOM_Object::IsMainShape()
return false; return false;
} }
//================================================================================
/*!
* \brief Returns GetLastFunction() of given objects
*/
//================================================================================
Handle(TColStd_HSequenceOfTransient)
GEOM_Object::GetLastFunctions( const std::list< Handle(GEOM_Object) >& theObjects )
{
Handle(TColStd_HSequenceOfTransient) funs = new TColStd_HSequenceOfTransient;
std::list<Handle(GEOM_Object)>::const_iterator it = theObjects.begin();
for (; it != theObjects.end(); it++)
{
Handle(GEOM_Function) fun = (*it)->GetLastFunction();
if ( fun.IsNull())
return Handle(TColStd_HSequenceOfTransient)();
funs->Append( fun );
}
return funs;
}
IMPLEMENT_STANDARD_HANDLE (GEOM_Object, GEOM_BaseObject ); IMPLEMENT_STANDARD_HANDLE (GEOM_Object, GEOM_BaseObject );
IMPLEMENT_STANDARD_RTTIEXT(GEOM_Object, GEOM_BaseObject ); IMPLEMENT_STANDARD_RTTIEXT(GEOM_Object, GEOM_BaseObject );

View File

@ -27,9 +27,12 @@
#include <Aspect_TypeOfMarker.hxx> #include <Aspect_TypeOfMarker.hxx>
#include <Standard_GUID.hxx> #include <Standard_GUID.hxx>
#include <TColStd_HSequenceOfTransient.hxx>
#include <TDF_Label.hxx> #include <TDF_Label.hxx>
#include <TopoDS_Shape.hxx> #include <TopoDS_Shape.hxx>
#include <list>
class GEOM_Object; class GEOM_Object;
class Handle(TFunction_Driver); class Handle(TFunction_Driver);
class GEOM_Engine; class GEOM_Engine;
@ -58,10 +61,10 @@ class GEOM_Object : public GEOM_BaseObject
Standard_EXPORT ~GEOM_Object(); Standard_EXPORT ~GEOM_Object();
//Finds a GEOM_Object on the label theLabel //Finds a GEOM_Object on the label theLabel
Standard_EXPORT static Handle(GEOM_Object) GetObject(TDF_Label& theLabel); Standard_EXPORT static Handle(GEOM_Object) GetObject(const TDF_Label& theLabel);
//Finds a GEOM_Object by a reference, stored on the label theLabel //Finds a GEOM_Object by a reference, stored on the label theLabel
Standard_EXPORT static Handle(GEOM_Object) GetReferencedObject(TDF_Label& theLabel); Standard_EXPORT static Handle(GEOM_Object) GetReferencedObject(const TDF_Label& theLabel);
//########################################################### //###########################################################
//Access to properties //Access to properties
@ -107,6 +110,10 @@ class GEOM_Object : public GEOM_BaseObject
//Returns false if the object is a sub-shape of another object //Returns false if the object is a sub-shape of another object
Standard_EXPORT bool IsMainShape(); Standard_EXPORT bool IsMainShape();
//Comfort method
Standard_EXPORT static Handle(TColStd_HSequenceOfTransient)
GetLastFunctions( const std::list< Handle(GEOM_Object) >& theObjects );
public: public:
DEFINE_STANDARD_RTTI( GEOM_Object ); DEFINE_STANDARD_RTTI( GEOM_Object );
}; };

View File

@ -201,6 +201,11 @@ namespace GEOM
for (i = 1; i <= aLen; i++) { for (i = 1; i <= aLen; i++) {
anObject = Handle(GEOM_Object)::DownCast(theObjects->Value(i)); anObject = Handle(GEOM_Object)::DownCast(theObjects->Value(i));
if ( anObject.IsNull() ) {
Handle(GEOM_Function) fun = Handle(GEOM_Function)::DownCast(theObjects->Value(i));
if ( !fun.IsNull() )
anObject = GEOM_Object::GetObject( fun->GetOwnerEntry() );
}
aLatest = GetCreatedLast(aLatest, anObject); aLatest = GetCreatedLast(aLatest, anObject);
} }
return aLatest; return aLatest;

View File

@ -872,6 +872,14 @@ Please, select face, shell or solid and try again</translation>
<source>GEOM_GLUE_EDGES_TITLE</source> <source>GEOM_GLUE_EDGES_TITLE</source>
<translation>Glue edges</translation> <translation>Glue edges</translation>
</message> </message>
<message>
<source>GEOM_GLUE_EDGES_DETECT_TITLE</source>
<translation>Coincident edges detection</translation>
</message>
<message>
<source>GEOM_GLUE_FACES_DETECT_TITLE</source>
<translation>Coincident faces detection</translation>
</message>
<message> <message>
<source>GLUE_ERROR_STICKED_SHAPES</source> <source>GLUE_ERROR_STICKED_SHAPES</source>
<translation>The tolerance value is too big. Sticked shapes are detected.</translation> <translation>The tolerance value is too big. Sticked shapes are detected.</translation>
@ -1668,6 +1676,10 @@ Please, select face, shell or solid and try again</translation>
<source>GEOM_SELECTED_SHAPE</source> <source>GEOM_SELECTED_SHAPE</source>
<translation>Selected shape</translation> <translation>Selected shape</translation>
</message> </message>
<message>
<source>GEOM_SELECTED_SHAPES</source>
<translation>Selected shapes</translation>
</message>
<message> <message>
<source>GEOM_SELECTION</source> <source>GEOM_SELECTION</source>
<translation>Selection</translation> <translation>Selection</translation>

View File

@ -38,16 +38,15 @@
#include "utilities.h" #include "utilities.h"
#include <BRep_Builder.hxx>
#include <ShapeFix_Shape.hxx>
#include <TDataStd_IntegerArray.hxx> #include <TDataStd_IntegerArray.hxx>
#include <TopExp.hxx> #include <TopExp.hxx>
#include <TopoDS_Shape.hxx>
#include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx> #include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
#include <TopTools_IndexedMapOfShape.hxx> #include <TopTools_IndexedMapOfShape.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx> #include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_ListOfShape.hxx>
#include <ShapeFix_Shape.hxx> #include <TopoDS_Shape.hxx>
#include <Standard_NullObject.hxx> #include <Standard_NullObject.hxx>
#include <Standard_Failure.hxx> #include <Standard_Failure.hxx>
@ -729,8 +728,36 @@ Standard_Integer GEOMImpl_GlueDriver::Execute(TFunction_Logbook& log) const
TopoDS_Shape aShape; TopoDS_Shape aShape;
TCollection_AsciiString aWrn; TCollection_AsciiString aWrn;
Handle(GEOM_Function) aRefBase = aCI.GetBase(); TopoDS_Shape aShapeBase;
TopoDS_Shape aShapeBase = aRefBase->GetValue(); Handle(TColStd_HSequenceOfTransient) aRefBases = aCI.GetBase();
if ( aRefBases && !aRefBases->IsEmpty() )
{
if ( aRefBases->Length() == 1 )
{
Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aRefBases->Value(1));
if ( !aRefShape.IsNull() )
aShapeBase = aRefShape->GetValue();
}
else
{
TopoDS_Compound compound;
BRep_Builder builder;
builder.MakeCompound( compound );
int ind = 1;
for ( ; ind <= aRefBases->Length(); ind++)
{
Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aRefBases->Value(ind));
if ( aRefShape.IsNull() ) break;
TopoDS_Shape aShape = aRefShape->GetValue();
if (aShape.IsNull()) break;
builder.Add( compound, aShape );
}
if ( ind > aRefBases->Length() )
aShapeBase = compound;
else
aShapeBase.Nullify();
}
}
if (aShapeBase.IsNull()) { if (aShapeBase.IsNull()) {
Standard_NullObject::Raise("Shape for gluing is null"); Standard_NullObject::Raise("Shape for gluing is null");
} }
@ -803,18 +830,18 @@ GetCreationInformation(std::string& theOperationName,
switch ( aType ) { switch ( aType ) {
case GLUE_FACES: case GLUE_FACES:
theOperationName = "GLUE_FACES"; theOperationName = "GLUE_FACES";
AddParam( theParams, "Selected shape", aCI.GetBase() ); AddParam( theParams, "Selected shapes", aCI.GetBase() );
AddParam( theParams, "Tolerance", aCI.GetTolerance() ); AddParam( theParams, "Tolerance", aCI.GetTolerance() );
AddParam( theParams, "To keep non solids", aCI.GetKeepNonSolids() ); AddParam( theParams, "To keep non solids", aCI.GetKeepNonSolids() );
break; break;
case GLUE_EDGES: case GLUE_EDGES:
theOperationName = "GLUE_EDGES"; theOperationName = "GLUE_EDGES";
AddParam( theParams, "Selected shape", aCI.GetBase() ); AddParam( theParams, "Selected shapes", aCI.GetBase() );
AddParam( theParams, "Tolerance", aCI.GetTolerance() ); AddParam( theParams, "Tolerance", aCI.GetTolerance() );
break; break;
case GLUE_FACES_BY_LIST: case GLUE_FACES_BY_LIST:
theOperationName = "GLUE_FACES"; theOperationName = "GLUE_FACES";
AddParam( theParams, "Selected shape", aCI.GetBase() ); AddParam( theParams, "Selected shapes", aCI.GetBase() );
AddParam( theParams, "Tolerance", aCI.GetTolerance() ); AddParam( theParams, "Tolerance", aCI.GetTolerance() );
AddParam( theParams, "Faces", aCI.GetFaces() ); AddParam( theParams, "Faces", aCI.GetFaces() );
AddParam( theParams, "To keep non solids", aCI.GetKeepNonSolids() ); AddParam( theParams, "To keep non solids", aCI.GetKeepNonSolids() );
@ -822,7 +849,7 @@ GetCreationInformation(std::string& theOperationName,
break; break;
case GLUE_EDGES_BY_LIST: case GLUE_EDGES_BY_LIST:
theOperationName = "GLUE_EDGES"; theOperationName = "GLUE_EDGES";
AddParam( theParams, "Selected shape", aCI.GetBase() ); AddParam( theParams, "Selected shapes", aCI.GetBase() );
AddParam( theParams, "Tolerance", aCI.GetTolerance() ); AddParam( theParams, "Tolerance", aCI.GetTolerance() );
AddParam( theParams, "Edges", aCI.GetFaces() ); AddParam( theParams, "Edges", aCI.GetFaces() );
break; break;

View File

@ -38,10 +38,11 @@ class GEOMImpl_IGlue
GEOMImpl_IGlue(Handle(GEOM_Function) theFunction): _func(theFunction) {} GEOMImpl_IGlue(Handle(GEOM_Function) theFunction): _func(theFunction) {}
void SetBase(Handle(GEOM_Function) theRefBase) void SetBase(const Handle(TColStd_HSequenceOfTransient)& theShapes)
{ _func->SetReference(GLUE_ARG_BASE, theRefBase); } { _func->SetReferenceList(GLUE_ARG_BASE, theShapes); }
Handle(GEOM_Function) GetBase() { return _func->GetReference(GLUE_ARG_BASE); } Handle(TColStd_HSequenceOfTransient) GetBase()
{ return _func->GetReferenceList(GLUE_ARG_BASE); }
void SetTolerance(const Standard_Real theTolerance) void SetTolerance(const Standard_Real theTolerance)
{ _func->SetReal(GLUE_ARG_TOLER, theTolerance); } { _func->SetReal(GLUE_ARG_TOLER, theTolerance); }

View File

@ -592,17 +592,12 @@ GEOMImpl_IHealingOperations::Sew (std::list<Handle(GEOM_Object)>& theObjects,
if (theObjects.empty()) if (theObjects.empty())
return NULL; return NULL;
Handle(TColStd_HSequenceOfTransient) objects = new TColStd_HSequenceOfTransient; Handle(TColStd_HSequenceOfTransient) objects =
std::list<Handle(GEOM_Object)>::iterator it = theObjects.begin(); GEOM_Object::GetLastFunctions( theObjects );
for (; it != theObjects.end(); it++) if ( objects.IsNull() || objects->IsEmpty() ) {
{
Handle(GEOM_Function) aRefSh = (*it)->GetLastFunction();
if (aRefSh.IsNull()) {
SetErrorCode("NULL argument shape"); SetErrorCode("NULL argument shape");
return NULL; return NULL;
} }
objects->Append(aRefSh);
}
// Add a new object // Add a new object
Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY ); Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
@ -643,7 +638,7 @@ GEOMImpl_IHealingOperations::Sew (std::list<Handle(GEOM_Object)>& theObjects,
pd << aNewObject << " = geompy.Sew(" << theObjects << ", " << theTolerance; pd << aNewObject << " = geompy.Sew(" << theObjects << ", " << theTolerance;
if (isAllowNonManifold) { if (isAllowNonManifold) {
pd << ", true"; pd << ", True";
} }
pd << ")"; pd << ")";

View File

@ -67,60 +67,61 @@
#include <OpUtil.hxx> #include <OpUtil.hxx>
#include <Utils_ExceptHandlers.hxx> #include <Utils_ExceptHandlers.hxx>
#include <TFunction_DriverTable.hxx>
#include <TFunction_Driver.hxx>
#include <TFunction_Logbook.hxx>
#include <TDataStd_Integer.hxx>
#include <TDataStd_IntegerArray.hxx>
#include <TDataStd_ListIteratorOfListOfExtendedString.hxx>
#include <TDF_Tool.hxx>
#include <BRepExtrema_ExtCF.hxx>
#include <BRepExtrema_DistShapeShape.hxx>
#include <BRep_Tool.hxx>
#include <BRep_Builder.hxx>
#include <BRepTools.hxx>
#include <BRepGProp.hxx>
#include <BRepAdaptor_Curve.hxx> #include <BRepAdaptor_Curve.hxx>
#include <BRepAdaptor_Surface.hxx> #include <BRepAdaptor_Surface.hxx>
#include <BRepBndLib.hxx> #include <BRepBndLib.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>
#include <BRepClass3d_SolidClassifier.hxx>
#include <BRepClass_FaceClassifier.hxx>
#include <BRepExtrema_DistShapeShape.hxx>
#include <BRepExtrema_ExtCF.hxx>
#include <BRepGProp.hxx>
#include <BRepMesh_IncrementalMesh.hxx> #include <BRepMesh_IncrementalMesh.hxx>
#include <BRepTools.hxx>
#include <TopAbs.hxx> #include <BRep_Builder.hxx>
#include <TopExp.hxx> #include <BRep_Tool.hxx>
#include <TopExp_Explorer.hxx> #include <Bnd_Box.hxx>
#include <TopLoc_Location.hxx> #include <GEOMImpl_IMeasure.hxx>
#include <TopoDS.hxx> #include <GEOMImpl_MeasureDriver.hxx>
#include <TopoDS_Shape.hxx> #include <GProp_GProps.hxx>
#include <TopoDS_Solid.hxx> #include <Geom2d_Curve.hxx>
#include <TopoDS_Face.hxx> #include <GeomAdaptor_Surface.hxx>
#include <TopoDS_Edge.hxx> #include <GeomLib_Tool.hxx>
#include <TopoDS_Vertex.hxx> #include <Geom_CylindricalSurface.hxx>
#include <TopoDS_Compound.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopTools_Array1OfShape.hxx>
#include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_MapOfShape.hxx>
#include <TopTools_MapOfOrientedShape.hxx>
#include <Geom_Surface.hxx>
#include <Geom_Plane.hxx> #include <Geom_Plane.hxx>
#include <Geom_SphericalSurface.hxx> #include <Geom_SphericalSurface.hxx>
#include <Geom_CylindricalSurface.hxx> #include <Geom_Surface.hxx>
#include <GeomAdaptor_Surface.hxx> #include <Precision.hxx>
#include <GeomLib_Tool.hxx>
#include <Geom2d_Curve.hxx>
#include <Bnd_Box.hxx>
#include <GProp_GProps.hxx>
#include <TColStd_Array1OfReal.hxx> #include <TColStd_Array1OfReal.hxx>
#include <TColStd_HArray1OfInteger.hxx> #include <TColStd_HArray1OfInteger.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx> #include <TColStd_ListIteratorOfListOfInteger.hxx>
#include <TColStd_ListOfInteger.hxx> #include <TColStd_ListOfInteger.hxx>
#include <TDF_Tool.hxx>
#include <TDataStd_Integer.hxx>
#include <TDataStd_IntegerArray.hxx>
#include <TDataStd_ListIteratorOfListOfExtendedString.hxx>
#include <TFunction_Driver.hxx>
#include <TFunction_DriverTable.hxx>
#include <TFunction_Logbook.hxx>
#include <TopAbs.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopLoc_Location.hxx>
#include <TopTools_Array1OfShape.hxx>
#include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_MapOfOrientedShape.hxx>
#include <TopTools_MapOfShape.hxx>
#include <TopTools_SequenceOfShape.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Compound.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Solid.hxx>
#include <TopoDS_Vertex.hxx>
#include <gp_Cylinder.hxx> #include <gp_Cylinder.hxx>
#include <gp_Lin.hxx> #include <gp_Lin.hxx>
#include <gp_Pnt.hxx> #include <gp_Pnt.hxx>
@ -133,15 +134,6 @@
#include <Standard_Failure.hxx> #include <Standard_Failure.hxx>
#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
// Includes added for GetInPlace algorithm improvement
#include <GEOMImpl_MeasureDriver.hxx>
#include <GEOMImpl_IMeasure.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>
#include <BRepClass_FaceClassifier.hxx>
#include <BRepClass3d_SolidClassifier.hxx>
#include <Precision.hxx>
//============================================================================= //=============================================================================
/*! /*!
@ -666,14 +658,18 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeShape
* MakeGlueFaces * MakeGlueFaces
*/ */
//============================================================================= //=============================================================================
Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeGlueFaces Handle(GEOM_Object)
(Handle(GEOM_Object) theShape, GEOMImpl_IShapesOperations::MakeGlueFaces (std::list< Handle(GEOM_Object) >& theShapes,
const Standard_Real theTolerance, const Standard_Real theTolerance,
const Standard_Boolean doKeepNonSolids) const Standard_Boolean doKeepNonSolids)
{ {
SetErrorCode(KO); SetErrorCode(KO);
if (theShape.IsNull()) return NULL; Handle(TColStd_HSequenceOfTransient) objects = GEOM_Object::GetLastFunctions( theShapes );
if ( objects.IsNull() || objects->IsEmpty() ) {
SetErrorCode("NULL argument shape");
return NULL;
}
//Add a new Glued object //Add a new Glued object
Handle(GEOM_Object) aGlued = GetEngine()->AddObject(GetDocID(), GEOM_GLUED); Handle(GEOM_Object) aGlued = GetEngine()->AddObject(GetDocID(), GEOM_GLUED);
@ -688,10 +684,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeGlueFaces
GEOMImpl_IGlue aCI (aFunction); GEOMImpl_IGlue aCI (aFunction);
Handle(GEOM_Function) aRefShape = theShape->GetLastFunction(); aCI.SetBase( objects );
if (aRefShape.IsNull()) return NULL;
aCI.SetBase(aRefShape);
aCI.SetTolerance(theTolerance); aCI.SetTolerance(theTolerance);
aCI.SetKeepNonSolids(doKeepNonSolids); aCI.SetKeepNonSolids(doKeepNonSolids);
@ -717,7 +710,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeGlueFaces
//Make a Python command //Make a Python command
GEOM::TPythonDump(aFunction) << aGlued << " = geompy.MakeGlueFaces(" GEOM::TPythonDump(aFunction) << aGlued << " = geompy.MakeGlueFaces("
<< theShape << ", " << theTolerance << ")"; << theShapes << ", " << theTolerance << ")";
// to provide warning // to provide warning
if (!isWarning) SetErrorCode(OK); if (!isWarning) SetErrorCode(OK);
@ -806,16 +799,25 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetGlueFaces
* MakeGlueFacesByList * MakeGlueFacesByList
*/ */
//============================================================================= //=============================================================================
Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeGlueFacesByList Handle(GEOM_Object)
(Handle(GEOM_Object) theShape, GEOMImpl_IShapesOperations::MakeGlueFacesByList(std::list< Handle(GEOM_Object) >& theShapes,
const Standard_Real theTolerance, const Standard_Real theTolerance,
std::list<Handle(GEOM_Object)> theFaces, std::list<Handle(GEOM_Object)> & theFaces,
const Standard_Boolean doKeepNonSolids, const Standard_Boolean doKeepNonSolids,
const Standard_Boolean doGlueAllEdges) const Standard_Boolean doGlueAllEdges)
{ {
SetErrorCode(KO); SetErrorCode(KO);
if (theShape.IsNull()) return NULL; Handle(TColStd_HSequenceOfTransient) objects = GEOM_Object::GetLastFunctions( theShapes );
if ( objects.IsNull() || objects->IsEmpty() ) {
SetErrorCode("NULL argument shape");
return NULL;
}
Handle(TColStd_HSequenceOfTransient) aFaces = GEOM_Object::GetLastFunctions( theFaces );
if ( aFaces.IsNull() ) {
SetErrorCode("NULL argument shape for the shape construction");
return NULL;
}
//Add a new Glued object //Add a new Glued object
Handle(GEOM_Object) aGlued = GetEngine()->AddObject(GetDocID(), GEOM_GLUED); Handle(GEOM_Object) aGlued = GetEngine()->AddObject(GetDocID(), GEOM_GLUED);
@ -830,24 +832,10 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeGlueFacesByList
GEOMImpl_IGlue aCI (aFunction); GEOMImpl_IGlue aCI (aFunction);
Handle(GEOM_Function) aRefShape = theShape->GetLastFunction(); aCI.SetBase( objects );
if (aRefShape.IsNull()) return NULL;
aCI.SetBase(aRefShape);
aCI.SetTolerance(theTolerance); aCI.SetTolerance(theTolerance);
aCI.SetKeepNonSolids(doKeepNonSolids); aCI.SetKeepNonSolids(doKeepNonSolids);
aCI.SetGlueAllEdges(doGlueAllEdges); aCI.SetGlueAllEdges(doGlueAllEdges);
Handle(TColStd_HSequenceOfTransient) aFaces = new TColStd_HSequenceOfTransient;
std::list<Handle(GEOM_Object)>::iterator it = theFaces.begin();
for (; it != theFaces.end(); it++) {
Handle(GEOM_Function) aRefSh = (*it)->GetLastFunction();
if (aRefSh.IsNull()) {
SetErrorCode("NULL argument shape for the shape construction");
return NULL;
}
aFaces->Append(aRefSh);
}
aCI.SetFaces(aFaces); aCI.SetFaces(aFaces);
//Compute the sub-shape value //Compute the sub-shape value
@ -874,16 +862,8 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeGlueFacesByList
GEOM::TPythonDump pd(aFunction); GEOM::TPythonDump pd(aFunction);
pd << aGlued << " = geompy.MakeGlueFacesByList(" pd << aGlued << " = geompy.MakeGlueFacesByList("
<< theShape << ", " << theTolerance << ", ["; << theShapes << ", " << theTolerance << ", " << theFaces << ", "
// Faces << (bool)doKeepNonSolids << ", " << (bool)doGlueAllEdges << ")";
it = theFaces.begin();
if (it != theFaces.end()) {
pd << (*it++);
while (it != theFaces.end()) {
pd << ", " << (*it++);
}
}
pd << "], " << (bool)doKeepNonSolids << ", " << (bool)doGlueAllEdges << ")";
// to provide warning // to provide warning
if (!isWarning) SetErrorCode(OK); if (!isWarning) SetErrorCode(OK);
@ -895,13 +875,17 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeGlueFacesByList
* MakeGlueEdges * MakeGlueEdges
*/ */
//============================================================================= //=============================================================================
Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeGlueEdges Handle(GEOM_Object)
(Handle(GEOM_Object) theShape, GEOMImpl_IShapesOperations::MakeGlueEdges (std::list< Handle(GEOM_Object) >& theShapes,
const Standard_Real theTolerance) const Standard_Real theTolerance)
{ {
SetErrorCode(KO); SetErrorCode(KO);
if (theShape.IsNull()) return NULL; Handle(TColStd_HSequenceOfTransient) objects = GEOM_Object::GetLastFunctions( theShapes );
if ( objects.IsNull() || objects->IsEmpty() ) {
SetErrorCode("NULL argument shape");
return NULL;
}
//Add a new Glued object //Add a new Glued object
Handle(GEOM_Object) aGlued = GetEngine()->AddObject(GetDocID(), GEOM_GLUED); Handle(GEOM_Object) aGlued = GetEngine()->AddObject(GetDocID(), GEOM_GLUED);
@ -916,10 +900,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeGlueEdges
GEOMImpl_IGlue aCI (aFunction); GEOMImpl_IGlue aCI (aFunction);
Handle(GEOM_Function) aRefShape = theShape->GetLastFunction(); aCI.SetBase( objects );
if (aRefShape.IsNull()) return NULL;
aCI.SetBase(aRefShape);
aCI.SetTolerance(theTolerance); aCI.SetTolerance(theTolerance);
aCI.SetKeepNonSolids(true); aCI.SetKeepNonSolids(true);
@ -945,7 +926,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeGlueEdges
//Make a Python command //Make a Python command
GEOM::TPythonDump(aFunction) << aGlued << " = geompy.MakeGlueEdges(" GEOM::TPythonDump(aFunction) << aGlued << " = geompy.MakeGlueEdges("
<< theShape << ", " << theTolerance << ")"; << theShapes << ", " << theTolerance << ")";
// to provide warning // to provide warning
if (!isWarning) SetErrorCode(OK); if (!isWarning) SetErrorCode(OK);
@ -957,16 +938,36 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeGlueEdges
* GetGlueShapes * GetGlueShapes
*/ */
//============================================================================= //=============================================================================
Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetGlueShapes Handle(TColStd_HSequenceOfTransient)
(Handle(GEOM_Object) theShape, GEOMImpl_IShapesOperations::GetGlueShapes (std::list< Handle(GEOM_Object) >& theShapes,
const Standard_Real theTolerance, const Standard_Real theTolerance,
const TopAbs_ShapeEnum theType) const TopAbs_ShapeEnum theType)
{ {
SetErrorCode(KO); SetErrorCode(KO);
if (theShape.IsNull()) return NULL; TopoDS_Shape aShape;
TopoDS_Shape aShape = theShape->GetValue(); TopTools_SequenceOfShape shapes;
std::list< Handle(GEOM_Object) >::iterator s = theShapes.begin();
Handle(GEOM_Object) lastCreatedGO;
for ( ; s != theShapes.end(); ++s )
{
Handle(GEOM_Object) go = *s;
if ( go.IsNull() ) return NULL;
aShape = go->GetValue();
if ( aShape.IsNull() ) return NULL; if ( aShape.IsNull() ) return NULL;
shapes.Append( aShape );
lastCreatedGO = GEOM::GetCreatedLast( lastCreatedGO, go );
}
if ( shapes.Length() > 1 )
{
TopoDS_Compound compound;
BRep_Builder builder;
builder.MakeCompound( compound );
for ( int i = 1; i <= shapes.Length(); ++i )
builder.Add( compound, shapes( i ) );
aShape = compound;
}
Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
@ -977,9 +978,7 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetGlueShapes
Standard_Integer iErr = aGluer.ErrorStatus(); Standard_Integer iErr = aGluer.ErrorStatus();
if (iErr) return NULL; if (iErr) return NULL;
TCollection_AsciiString anAsciiList, anEntry; std::vector< TopTools_IndexedMapOfShape* > anIndices( shapes.Length(), NULL );
TopTools_IndexedMapOfShape anIndices;
TopExp::MapShapes(aShape, anIndices);
Handle(TColStd_HArray1OfInteger) anArray; Handle(TColStd_HArray1OfInteger) anArray;
Handle(GEOM_Object) anObj; Handle(GEOM_Object) anObj;
@ -1006,31 +1005,40 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetGlueShapes
GEOMUtils::SortShapes(listOnePerSet, Standard_False); GEOMUtils::SortShapes(listOnePerSet, Standard_False);
TopTools_ListIteratorOfListOfShape aListIt (listOnePerSet); TopTools_ListIteratorOfListOfShape aListIt (listOnePerSet);
for (; aListIt.More(); aListIt.Next()) { for (; aListIt.More(); aListIt.Next())
{
TopoDS_Shape aValue = aListIt.Value(); TopoDS_Shape aValue = aListIt.Value();
// find a shape to add aValue as a sub-shape
anObj.Nullify();
s = theShapes.begin();
for ( int i = 0; i < shapes.Length(); ++i, ++s )
{
Handle(GEOM_Object) object = *s;
if ( !anIndices[i] ) {
anIndices[i] = new TopTools_IndexedMapOfShape;
TopExp::MapShapes( object->GetValue(), *anIndices[i]);
}
if (int index = anIndices[i]->FindIndex( aValue )) {
anArray = new TColStd_HArray1OfInteger(1,1); anArray = new TColStd_HArray1OfInteger(1,1);
anArray->SetValue(1, anIndices.FindIndex(aValue)); anArray->SetValue(1, index);
anObj = GetEngine()->AddSubShape(theShape, anArray); anObj = GetEngine()->AddSubShape( object, anArray);
if (!anObj.IsNull()) { break;
}
}
if (!anObj.IsNull())
aSeq->Append(anObj); aSeq->Append(anObj);
// for python command
TDF_Tool::Entry(anObj->GetEntry(), anEntry);
anAsciiList += anEntry;
anAsciiList += ",";
}
} }
for ( size_t i = 0 ; i < anIndices.size(); ++i )
delete anIndices[i];
// Make a Python command // Make a Python command
if (anAsciiList.Length() > 0) { if ( aSeq->Length() > 0)
anAsciiList.Trunc(anAsciiList.Length() - 1); {
Handle(GEOM_Function) aFunction = theShape->GetLastFunction(); Handle(GEOM_Function) aFunction = lastCreatedGO->GetLastFunction();
GEOM::TPythonDump pd (aFunction, /*append=*/true); GEOM::TPythonDump pd (aFunction, /*append=*/true);
pd << "[" << anAsciiList.ToCString(); pd << aSeq
if (theType == TopAbs_FACE) << " = geompy." << (theType == TopAbs_FACE ? "GetGlueFaces" : "GetGlueEdges" )
pd << "] = geompy.GetGlueFaces(" << theShape << ", " << theTolerance << ")"; << "( " << theShapes << ", " << theTolerance << ")";
else if (theType == TopAbs_EDGE)
pd << "] = geompy.GetGlueEdges(" << theShape << ", " << theTolerance << ")";
} }
SetErrorCode(OK); SetErrorCode(OK);
@ -1043,15 +1051,23 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetGlueShapes
* MakeGlueEdgesByList * MakeGlueEdgesByList
*/ */
//============================================================================= //=============================================================================
Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeGlueEdgesByList Handle(GEOM_Object)
(Handle(GEOM_Object) theShape, GEOMImpl_IShapesOperations::MakeGlueEdgesByList (std::list< Handle(GEOM_Object) >& theShapes,
const Standard_Real theTolerance, const Standard_Real theTolerance,
std::list<Handle(GEOM_Object)> theEdges) std::list<Handle(GEOM_Object)>& theEdges)
{ {
SetErrorCode(KO); SetErrorCode(KO);
if (theShape.IsNull()) return NULL; Handle(TColStd_HSequenceOfTransient) objects = GEOM_Object::GetLastFunctions( theShapes );
if ( objects.IsNull() || objects->IsEmpty() ) {
SetErrorCode("NULL argument shape");
return NULL;
}
Handle(TColStd_HSequenceOfTransient) anEdges = GEOM_Object::GetLastFunctions( theEdges );
if ( anEdges.IsNull() ) {
SetErrorCode("NULL argument shape for the shape construction");
return NULL;
}
//Add a new Glued object //Add a new Glued object
Handle(GEOM_Object) aGlued = GetEngine()->AddObject(GetDocID(), GEOM_GLUED); Handle(GEOM_Object) aGlued = GetEngine()->AddObject(GetDocID(), GEOM_GLUED);
@ -1065,23 +1081,9 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeGlueEdgesByList
GEOMImpl_IGlue aCI (aFunction); GEOMImpl_IGlue aCI (aFunction);
Handle(GEOM_Function) aRefShape = theShape->GetLastFunction(); aCI.SetBase( objects );
if (aRefShape.IsNull()) return NULL;
aCI.SetBase(aRefShape);
aCI.SetTolerance(theTolerance); aCI.SetTolerance(theTolerance);
aCI.SetKeepNonSolids(true); aCI.SetKeepNonSolids(true);
Handle(TColStd_HSequenceOfTransient) anEdges = new TColStd_HSequenceOfTransient;
std::list<Handle(GEOM_Object)>::iterator it = theEdges.begin();
for (; it != theEdges.end(); it++) {
Handle(GEOM_Function) aRefSh = (*it)->GetLastFunction();
if (aRefSh.IsNull()) {
SetErrorCode("NULL argument shape for the shape construction");
return NULL;
}
anEdges->Append(aRefSh);
}
aCI.SetFaces(anEdges); aCI.SetFaces(anEdges);
//Compute the sub-shape value //Compute the sub-shape value
@ -1108,16 +1110,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeGlueEdgesByList
GEOM::TPythonDump pd (aFunction); GEOM::TPythonDump pd (aFunction);
pd << aGlued << " = geompy.MakeGlueEdgesByList(" pd << aGlued << " = geompy.MakeGlueEdgesByList("
<< theShape << ", " << theTolerance << ", ["; << theShapes << ", " << theTolerance << ", " << theEdges << " )";
// Edges
it = theEdges.begin();
if (it != theEdges.end()) {
pd << (*it++);
while (it != theEdges.end()) {
pd << ", " << (*it++);
}
}
pd << "])";
// to provide warning // to provide warning
if (!isWarning) SetErrorCode(OK); if (!isWarning) SetErrorCode(OK);

View File

@ -91,29 +91,26 @@ class GEOMImpl_IShapesOperations : public GEOM_IOperations
Standard_EXPORT Handle(GEOM_Object) MakeCompound (std::list<Handle(GEOM_Object)> theShapes); Standard_EXPORT Handle(GEOM_Object) MakeCompound (std::list<Handle(GEOM_Object)> theShapes);
Standard_EXPORT Handle(GEOM_Object) MakeGlueFaces (Handle(GEOM_Object) theShape, Standard_EXPORT Handle(GEOM_Object) MakeGlueFaces (std::list< Handle(GEOM_Object) >& theShapes,
const Standard_Real theTolerance, const Standard_Real theTolerance,
const Standard_Boolean doKeepNonSolids); const Standard_Boolean doKeepNonSolids);
//Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetGlueFaces (Handle(GEOM_Object) theShape, Standard_EXPORT Handle(GEOM_Object) MakeGlueFacesByList (std::list< Handle(GEOM_Object) >& theShapes,
// const Standard_Real theTolerance);
Standard_EXPORT Handle(GEOM_Object) MakeGlueFacesByList (Handle(GEOM_Object) theShape,
const Standard_Real theTolerance, const Standard_Real theTolerance,
std::list<Handle(GEOM_Object)> theFaces, std::list<Handle(GEOM_Object)>& theFaces,
const Standard_Boolean doKeepNonSolids, const Standard_Boolean doKeepNonSolids,
const Standard_Boolean doGlueAllEdges); const Standard_Boolean doGlueAllEdges);
Standard_EXPORT Handle(GEOM_Object) MakeGlueEdges (Handle(GEOM_Object) theShape, Standard_EXPORT Handle(GEOM_Object) MakeGlueEdges (std::list< Handle(GEOM_Object) >& theShapes,
const Standard_Real theTolerance); const Standard_Real theTolerance);
Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetGlueShapes (Handle(GEOM_Object) theShape, Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetGlueShapes (std::list< Handle(GEOM_Object) >& theShapes,
const Standard_Real theTolerance, const Standard_Real theTolerance,
const TopAbs_ShapeEnum theType); const TopAbs_ShapeEnum theType);
Standard_EXPORT Handle(GEOM_Object) MakeGlueEdgesByList (Handle(GEOM_Object) theShape, Standard_EXPORT Handle(GEOM_Object) MakeGlueEdgesByList (std::list< Handle(GEOM_Object) >& theShapes,
const Standard_Real theTolerance, const Standard_Real theTolerance,
std::list<Handle(GEOM_Object)> theEdges); std::list<Handle(GEOM_Object)> & theEdges);
Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetExistingSubObjects(Handle(GEOM_Object) theShape, Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetExistingSubObjects(Handle(GEOM_Object) theShape,
const Standard_Boolean theGroupsOnly); const Standard_Boolean theGroupsOnly);

View File

@ -347,17 +347,12 @@ GEOM::GEOM_Object_ptr GEOM_IHealingOperations_i::Sew (const GEOM::ListOfGO& theO
return aGEOMObject._retn(); return aGEOMObject._retn();
//Get the shapes //Get the shapes
std::list<Handle(GEOM_Object)> objects; std::list< Handle(GEOM_Object) > aShapes;
const int aLen = theObjects.length(); if (! GetListOfObjectsImpl( theObjects, aShapes ))
for ( int ind = 0; ind < aLen; ind++) return aGEOMObject._retn();
{
Handle(GEOM_Object) aSh = GetObjectImpl(theObjects[ind]);
if (aSh.IsNull()) return aGEOMObject._retn();
objects.push_back(aSh);
}
// Perform // Perform
Handle(GEOM_Object) aNewObject = GetOperations()->Sew( objects, theTolerance, false ); Handle(GEOM_Object) aNewObject = GetOperations()->Sew( aShapes, theTolerance, false );
if (!GetOperations()->IsDone() || aNewObject.IsNull()) if (!GetOperations()->IsDone() || aNewObject.IsNull())
return aGEOMObject._retn(); return aGEOMObject._retn();
@ -383,17 +378,12 @@ GEOM_IHealingOperations_i::SewAllowNonManifold (const GEOM::ListOfGO& theObjects
return aGEOMObject._retn(); return aGEOMObject._retn();
//Get the shapes //Get the shapes
std::list<Handle(GEOM_Object)> objects; std::list< Handle(GEOM_Object) > aShapes;
const int aLen = theObjects.length(); if (! GetListOfObjectsImpl( theObjects, aShapes ))
for ( int ind = 0; ind < aLen; ind++) return aGEOMObject._retn();
{
Handle(GEOM_Object) aSh = GetObjectImpl(theObjects[ind]);
if (aSh.IsNull()) return aGEOMObject._retn();
objects.push_back(aSh);
}
// Perform // Perform
Handle(GEOM_Object) aNewObject = GetOperations()->Sew( objects, theTolerance, true ); Handle(GEOM_Object) aNewObject = GetOperations()->Sew( aShapes, theTolerance, true );
if (!GetOperations()->IsDone() || aNewObject.IsNull()) if (!GetOperations()->IsDone() || aNewObject.IsNull())
return aGEOMObject._retn(); return aGEOMObject._retn();

View File

@ -209,6 +209,29 @@ Handle(TColStd_HSequenceOfTransient) GEOM_IOperations_i::GetListOfObjectsImpl
return aResult; return aResult;
} }
//=======================================================================
//function : GetListOfObjectsImpl
//purpose :
//=======================================================================
bool GEOM_IOperations_i::GetListOfObjectsImpl(const GEOM::ListOfGO& theObjects,
std::list< Handle(GEOM_Object) >& theList)
{
int i;
int aNbObj = theObjects.length();
for (i = 0; i < aNbObj; i++) {
Handle(GEOM_Object) anObj = GetObjectImpl(theObjects[i]);
if (anObj.IsNull())
return false;
theList.push_back(anObj);
}
return true;
}
//============================================================================= //=============================================================================
/*! /*!
* UpdateGUIForObject * UpdateGUIForObject

View File

@ -54,6 +54,8 @@ class GEOM_I_EXPORT GEOM_IOperations_i : public virtual POA_GEOM::GEOM_IOperatio
virtual Handle(TColStd_HSequenceOfTransient) virtual Handle(TColStd_HSequenceOfTransient)
GetListOfObjectsImpl(const GEOM::ListOfGO& theObjects); GetListOfObjectsImpl(const GEOM::ListOfGO& theObjects);
bool GetListOfObjectsImpl(const GEOM::ListOfGO& theObjects,
std::list< Handle(GEOM_Object) >& theList);
virtual void StartOperation(); virtual void StartOperation();

View File

@ -345,8 +345,8 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSolidShells
* MakeCompound * MakeCompound
*/ */
//============================================================================= //=============================================================================
GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeCompound GEOM::GEOM_Object_ptr
(const GEOM::ListOfGO& theShapes) GEOM_IShapesOperations_i::MakeCompound (const GEOM::ListOfGO& theShapes)
{ {
GEOM::GEOM_Object_var aGEOMObject; GEOM::GEOM_Object_var aGEOMObject;
@ -378,8 +378,8 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeCompound
* MakeGlueFaces * MakeGlueFaces
*/ */
//============================================================================= //=============================================================================
GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueFaces GEOM::GEOM_Object_ptr
(GEOM::GEOM_Object_ptr theShape, GEOM_IShapesOperations_i::MakeGlueFaces (const GEOM::ListOfGO& theShapes,
CORBA::Double theTolerance, CORBA::Double theTolerance,
CORBA::Boolean doKeepNonSolids) CORBA::Boolean doKeepNonSolids)
{ {
@ -389,12 +389,13 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueFaces
GetOperations()->SetNotDone(); GetOperations()->SetNotDone();
//Get the reference objects //Get the reference objects
Handle(GEOM_Object) aShape = GetObjectImpl(theShape); std::list< Handle(GEOM_Object) > aShapes;
if (aShape.IsNull()) return aGEOMObject._retn(); if (! GetListOfObjectsImpl( theShapes, aShapes ))
return aGEOMObject._retn();
//Perform the gluing //Perform the gluing
Handle(GEOM_Object) anObject = Handle(GEOM_Object) anObject =
GetOperations()->MakeGlueFaces(aShape, theTolerance, doKeepNonSolids); GetOperations()->MakeGlueFaces(aShapes, theTolerance, doKeepNonSolids);
//if (!GetOperations()->IsDone() || anObject.IsNull()) //if (!GetOperations()->IsDone() || anObject.IsNull())
// to allow warning // to allow warning
if (anObject.IsNull()) if (anObject.IsNull())
@ -408,8 +409,8 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueFaces
* GetGlueFaces * GetGlueFaces
*/ */
//============================================================================= //=============================================================================
GEOM::ListOfGO* GEOM_IShapesOperations_i::GetGlueFaces GEOM::ListOfGO*
(GEOM::GEOM_Object_ptr theShape, GEOM_IShapesOperations_i::GetGlueFaces (const GEOM::ListOfGO& theShapes,
const CORBA::Double theTolerance) const CORBA::Double theTolerance)
{ {
GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
@ -418,12 +419,12 @@ GEOM::ListOfGO* GEOM_IShapesOperations_i::GetGlueFaces
GetOperations()->SetNotDone(); GetOperations()->SetNotDone();
//Get the reference objects //Get the reference objects
Handle(GEOM_Object) aShape = GetObjectImpl(theShape); std::list< Handle(GEOM_Object) > aShapes;
if (aShape.IsNull()) return aSeq._retn(); if (! GetListOfObjectsImpl( theShapes, aShapes ))
return aSeq._retn();
Handle(TColStd_HSequenceOfTransient) aHSeq = Handle(TColStd_HSequenceOfTransient) aHSeq =
//GetOperations()->GetGlueFaces(aShape, theTolerance); GetOperations()->GetGlueShapes(aShapes, theTolerance, TopAbs_FACE);
GetOperations()->GetGlueShapes(aShape, theTolerance, TopAbs_FACE);
//if (!GetOperations()->IsDone() || aHSeq.IsNull()) //if (!GetOperations()->IsDone() || aHSeq.IsNull())
// to allow warning // to allow warning
@ -443,8 +444,8 @@ GEOM::ListOfGO* GEOM_IShapesOperations_i::GetGlueFaces
* MakeGlueFacesByList * MakeGlueFacesByList
*/ */
//============================================================================= //=============================================================================
GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueFacesByList GEOM::GEOM_Object_ptr
(GEOM::GEOM_Object_ptr theShape, GEOM_IShapesOperations_i::MakeGlueFacesByList (const GEOM::ListOfGO& theShapes,
CORBA::Double theTolerance, CORBA::Double theTolerance,
const GEOM::ListOfGO& theFaces, const GEOM::ListOfGO& theFaces,
CORBA::Boolean doKeepNonSolids, CORBA::Boolean doKeepNonSolids,
@ -456,22 +457,19 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueFacesByList
GetOperations()->SetNotDone(); GetOperations()->SetNotDone();
//Get the reference objects //Get the reference objects
Handle(GEOM_Object) aShape = GetObjectImpl(theShape); std::list< Handle(GEOM_Object) > aShapes;
if (aShape.IsNull()) return aGEOMObject._retn(); if (! GetListOfObjectsImpl( theShapes, aShapes ))
return aGEOMObject._retn();
int ind, aLen;
std::list<Handle(GEOM_Object)> aFaces;
//Get the shapes //Get the shapes
aLen = theFaces.length(); std::list<Handle(GEOM_Object)> aFaces;
for (ind = 0; ind < aLen; ind++) { if (! GetListOfObjectsImpl( theFaces, aFaces ))
Handle(GEOM_Object) aSh = GetObjectImpl(theFaces[ind]); return aGEOMObject._retn();
if (aSh.IsNull()) return aGEOMObject._retn();
aFaces.push_back(aSh);
}
//Perform the gluing //Perform the gluing
Handle(GEOM_Object) anObject = Handle(GEOM_Object) anObject =
GetOperations()->MakeGlueFacesByList(aShape, theTolerance, aFaces, doKeepNonSolids, doGlueAllEdges); GetOperations()->MakeGlueFacesByList(aShapes, theTolerance, aFaces,
doKeepNonSolids, doGlueAllEdges);
//if (!GetOperations()->IsDone() || anObject.IsNull()) //if (!GetOperations()->IsDone() || anObject.IsNull())
// to allow warning // to allow warning
if (anObject.IsNull()) if (anObject.IsNull())
@ -485,8 +483,8 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueFacesByList
* MakeGlueEdges * MakeGlueEdges
*/ */
//============================================================================= //=============================================================================
GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueEdges GEOM::GEOM_Object_ptr
(GEOM::GEOM_Object_ptr theShape, GEOM_IShapesOperations_i::MakeGlueEdges (const GEOM::ListOfGO& theShapes,
CORBA::Double theTolerance) CORBA::Double theTolerance)
{ {
GEOM::GEOM_Object_var aGEOMObject; GEOM::GEOM_Object_var aGEOMObject;
@ -495,12 +493,13 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueEdges
GetOperations()->SetNotDone(); GetOperations()->SetNotDone();
//Get the reference objects //Get the reference objects
Handle(GEOM_Object) aShape = GetObjectImpl(theShape); std::list< Handle(GEOM_Object) > aShapes;
if (aShape.IsNull()) return aGEOMObject._retn(); if (! GetListOfObjectsImpl( theShapes, aShapes ))
return aGEOMObject._retn();
//Perform the gluing //Perform the gluing
Handle(GEOM_Object) anObject = Handle(GEOM_Object) anObject =
GetOperations()->MakeGlueEdges(aShape, theTolerance); GetOperations()->MakeGlueEdges(aShapes, theTolerance);
//if (!GetOperations()->IsDone() || anObject.IsNull()) //if (!GetOperations()->IsDone() || anObject.IsNull())
// to allow warning // to allow warning
if (anObject.IsNull()) if (anObject.IsNull())
@ -514,8 +513,8 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueEdges
* GetGlueEdges * GetGlueEdges
*/ */
//============================================================================= //=============================================================================
GEOM::ListOfGO* GEOM_IShapesOperations_i::GetGlueEdges GEOM::ListOfGO*
(GEOM::GEOM_Object_ptr theShape, GEOM_IShapesOperations_i::GetGlueEdges (const GEOM::ListOfGO& theShapes,
const CORBA::Double theTolerance) const CORBA::Double theTolerance)
{ {
GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
@ -524,11 +523,12 @@ GEOM::ListOfGO* GEOM_IShapesOperations_i::GetGlueEdges
GetOperations()->SetNotDone(); GetOperations()->SetNotDone();
//Get the reference objects //Get the reference objects
Handle(GEOM_Object) aShape = GetObjectImpl(theShape); std::list< Handle(GEOM_Object) > aShapes;
if (aShape.IsNull()) return aSeq._retn(); if (! GetListOfObjectsImpl( theShapes, aShapes ))
return aSeq._retn();
Handle(TColStd_HSequenceOfTransient) aHSeq = Handle(TColStd_HSequenceOfTransient) aHSeq =
GetOperations()->GetGlueShapes(aShape, theTolerance, TopAbs_EDGE); GetOperations()->GetGlueShapes(aShapes, theTolerance, TopAbs_EDGE);
//if (!GetOperations()->IsDone() || aHSeq.IsNull()) //if (!GetOperations()->IsDone() || aHSeq.IsNull())
// to allow warning // to allow warning
@ -548,8 +548,8 @@ GEOM::ListOfGO* GEOM_IShapesOperations_i::GetGlueEdges
* MakeGlueEdgesByList * MakeGlueEdgesByList
*/ */
//============================================================================= //=============================================================================
GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueEdgesByList GEOM::GEOM_Object_ptr
(GEOM::GEOM_Object_ptr theShape, GEOM_IShapesOperations_i::MakeGlueEdgesByList (const GEOM::ListOfGO& theShapes,
CORBA::Double theTolerance, CORBA::Double theTolerance,
const GEOM::ListOfGO& theEdges) const GEOM::ListOfGO& theEdges)
{ {
@ -559,22 +559,18 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueEdgesByList
GetOperations()->SetNotDone(); GetOperations()->SetNotDone();
//Get the reference objects //Get the reference objects
Handle(GEOM_Object) aShape = GetObjectImpl(theShape); std::list< Handle(GEOM_Object) > aShapes;
if (aShape.IsNull()) return aGEOMObject._retn(); if (! GetListOfObjectsImpl( theShapes, aShapes ))
return aGEOMObject._retn();
int ind, aLen;
std::list<Handle(GEOM_Object)> anEdges;
//Get the shapes //Get the shapes
aLen = theEdges.length(); std::list<Handle(GEOM_Object)> anEdges;
for (ind = 0; ind < aLen; ind++) { if (! GetListOfObjectsImpl( theEdges, anEdges ))
Handle(GEOM_Object) aSh = GetObjectImpl(theEdges[ind]); return aGEOMObject._retn();
if (aSh.IsNull()) return aGEOMObject._retn();
anEdges.push_back(aSh);
}
//Perform the gluing //Perform the gluing
Handle(GEOM_Object) anObject = Handle(GEOM_Object) anObject =
GetOperations()->MakeGlueEdgesByList(aShape, theTolerance, anEdges); GetOperations()->MakeGlueEdgesByList(aShapes, theTolerance, anEdges);
//if (!GetOperations()->IsDone() || anObject.IsNull()) //if (!GetOperations()->IsDone() || anObject.IsNull())
// to allow warning // to allow warning
if (anObject.IsNull()) if (anObject.IsNull())
@ -588,7 +584,8 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueEdgesByList
* GetExistingSubObjects * GetExistingSubObjects
*/ */
//============================================================================= //=============================================================================
GEOM::ListOfGO* GEOM_IShapesOperations_i::GetExistingSubObjects (GEOM::GEOM_Object_ptr theShape, GEOM::ListOfGO*
GEOM_IShapesOperations_i::GetExistingSubObjects (GEOM::GEOM_Object_ptr theShape,
CORBA::Boolean theGroupsOnly) CORBA::Boolean theGroupsOnly)
{ {
GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;

View File

@ -72,26 +72,26 @@ class GEOM_I_EXPORT GEOM_IShapesOperations_i :
GEOM::GEOM_Object_ptr MakeCompound (const GEOM::ListOfGO& theShapes); GEOM::GEOM_Object_ptr MakeCompound (const GEOM::ListOfGO& theShapes);
GEOM::GEOM_Object_ptr MakeGlueFaces (GEOM::GEOM_Object_ptr theShape, GEOM::GEOM_Object_ptr MakeGlueFaces (const GEOM::ListOfGO& theShape,
CORBA::Double theTolerance, CORBA::Double theTolerance,
CORBA::Boolean doKeepNonSolids); CORBA::Boolean doKeepNonSolids);
GEOM::ListOfGO* GetGlueFaces (GEOM::GEOM_Object_ptr theShape, GEOM::ListOfGO* GetGlueFaces (const GEOM::ListOfGO& theShape,
CORBA::Double theTolerance); CORBA::Double theTolerance);
GEOM::GEOM_Object_ptr MakeGlueFacesByList (GEOM::GEOM_Object_ptr theShape, GEOM::GEOM_Object_ptr MakeGlueFacesByList (const GEOM::ListOfGO& theShape,
CORBA::Double theTolerance, CORBA::Double theTolerance,
const GEOM::ListOfGO& theFaces, const GEOM::ListOfGO& theFaces,
CORBA::Boolean doKeepNonSolids, CORBA::Boolean doKeepNonSolids,
CORBA::Boolean doGlueAllEdges); CORBA::Boolean doGlueAllEdges);
GEOM::GEOM_Object_ptr MakeGlueEdges (GEOM::GEOM_Object_ptr theShape, GEOM::GEOM_Object_ptr MakeGlueEdges (const GEOM::ListOfGO& theShape,
CORBA::Double theTolerance); CORBA::Double theTolerance);
GEOM::ListOfGO* GetGlueEdges (GEOM::GEOM_Object_ptr theShape, GEOM::ListOfGO* GetGlueEdges (const GEOM::ListOfGO& theShape,
CORBA::Double theTolerance); CORBA::Double theTolerance);
GEOM::GEOM_Object_ptr MakeGlueEdgesByList (GEOM::GEOM_Object_ptr theShape, GEOM::GEOM_Object_ptr MakeGlueEdgesByList (const GEOM::ListOfGO& theShape,
CORBA::Double theTolerance, CORBA::Double theTolerance,
const GEOM::ListOfGO& theEdges); const GEOM::ListOfGO& theEdges);

View File

@ -387,8 +387,125 @@ def TestRemoveWebs (geompy):
Joined_1 = geompy.RemoveInternalFaces(Partition_1) Joined_1 = geompy.RemoveInternalFaces(Partition_1)
geompy.addToStudy(Joined_1, 'Joined_1') geompy.addToStudy(Joined_1, 'Joined_1')
def TestSewGluing(geompy):
import GEOM
box1 = geompy.MakeBox(0,0,0, 1,1,1)
box2 = geompy.MakeBox(1,0,0, 2,1,1)
comp = geompy.MakeCompound( [box1, box2] )
# no sewing with AllowNonManifold=False
sew1 = geompy.MakeSewing( [box1,box2], 1e-5, AllowNonManifold=False)
assert not sew1
sew2 = geompy.MakeSewing( comp, 1e-5, AllowNonManifold=False)
assert not sew2
sew3 = geompy.MakeSewing( [comp], 1e-5, AllowNonManifold=False)
assert not sew3
sew1 = geompy.Sew( [box1,box2], 1e-5, AllowNonManifold=False)
assert not sew1
sew2 = geompy.Sew( comp, 1e-5, AllowNonManifold=False)
assert not sew2
sew3 = geompy.Sew( [comp], 1e-5, AllowNonManifold=False)
assert not sew3
# check MakeSewing()
sew1 = geompy.MakeSewing( [box1,box2], 1e-5, AllowNonManifold=True)
assert sew1.GetShapeType() == GEOM.SHELL
assert geompy.NumberOfFaces( sew1 ) == geompy.NumberOfFaces( comp )
assert geompy.NumberOfEdges( sew1 ) == geompy.NumberOfEdges( comp ) - 4
sew2 = geompy.MakeSewing( comp, 1e-5, AllowNonManifold=True)
assert sew2.GetShapeType() == GEOM.SHELL
assert geompy.NumberOfFaces( sew2 ) == geompy.NumberOfFaces( comp )
assert geompy.NumberOfEdges( sew2 ) == geompy.NumberOfEdges( comp ) - 4
sew3 = geompy.MakeSewing( [comp], 1e-5, AllowNonManifold=True)
assert sew3.GetShapeType() == GEOM.SHELL
assert geompy.NumberOfFaces( sew3 ) == geompy.NumberOfFaces( comp )
assert geompy.NumberOfEdges( sew3 ) == geompy.NumberOfEdges( comp ) - 4
# check Sew()
sew1 = geompy.Sew( [box1,box2], 1e-5, AllowNonManifold=True)
assert sew1.GetShapeType() == GEOM.SHELL
assert geompy.NumberOfFaces( sew1 ) == geompy.NumberOfFaces( comp )
assert geompy.NumberOfEdges( sew1 ) == geompy.NumberOfEdges( comp ) - 4
sew2 = geompy.Sew( comp, 1e-5, AllowNonManifold=True)
assert sew2.GetShapeType() == GEOM.SHELL
assert geompy.NumberOfFaces( sew2 ) == geompy.NumberOfFaces( comp )
assert geompy.NumberOfEdges( sew2 ) == geompy.NumberOfEdges( comp ) - 4
sew3 = geompy.Sew( [comp], 1e-5, AllowNonManifold=True)
assert sew3.GetShapeType() == GEOM.SHELL
assert geompy.NumberOfFaces( sew3 ) == geompy.NumberOfFaces( comp )
assert geompy.NumberOfEdges( sew3 ) == geompy.NumberOfEdges( comp ) - 4
# check MakeGlueFaces()
glueF1 = geompy.MakeGlueFaces( [box1,box2], 1e-5)
assert glueF1.GetShapeType() == GEOM.COMPOUND
assert geompy.NumberOfFaces( glueF1 ) == geompy.NumberOfFaces( comp ) - 1
assert geompy.NumberOfEdges( glueF1 ) == geompy.NumberOfEdges( comp ) - 4
glueF2 = geompy.MakeGlueFaces( [comp], 1e-5)
assert glueF2.GetShapeType() == GEOM.COMPOUND
assert geompy.NumberOfFaces( glueF2 ) == geompy.NumberOfFaces( comp ) - 1
assert geompy.NumberOfEdges( glueF2 ) == geompy.NumberOfEdges( comp ) - 4
glueF3 = geompy.MakeGlueFaces( comp, 1e-5)
assert glueF3.GetShapeType() == GEOM.COMPOUND
assert geompy.NumberOfFaces( glueF3 ) == geompy.NumberOfFaces( comp ) - 1
assert geompy.NumberOfEdges( glueF3 ) == geompy.NumberOfEdges( comp ) - 4
# check GetGlueFaces()
glueFF1 = geompy.GetGlueFaces( [box1,box2], 1e-5)
assert len( glueFF1 ) == 1 and glueFF1[0].GetShapeType() == GEOM.FACE
glueFF2 = geompy.GetGlueFaces( [comp], 1e-5)
assert len( glueFF2 ) == 1 and glueFF2[0].GetShapeType() == GEOM.FACE
glueFF3 = geompy.GetGlueFaces( comp, 1e-5)
assert len( glueFF3 ) == 1 and glueFF3[0].GetShapeType() == GEOM.FACE
#check MakeGlueFacesByList()
glueF1 = geompy.MakeGlueFacesByList( [box1,box2], 1e-5, glueFF1)
assert glueF1.GetShapeType() == GEOM.COMPOUND
assert geompy.NumberOfFaces( glueF1 ) == geompy.NumberOfFaces( comp ) - 1
assert geompy.NumberOfEdges( glueF1 ) == geompy.NumberOfEdges( comp ) - 4
glueF2 = geompy.MakeGlueFacesByList( [comp], 1e-5, glueFF2)
assert glueF2.GetShapeType() == GEOM.COMPOUND
assert geompy.NumberOfFaces( glueF2 ) == geompy.NumberOfFaces( comp ) - 1
assert geompy.NumberOfEdges( glueF2 ) == geompy.NumberOfEdges( comp ) - 4
glueF3 = geompy.MakeGlueFacesByList( comp, 1e-5, glueFF3 )
assert glueF3.GetShapeType() == GEOM.COMPOUND
assert geompy.NumberOfFaces( glueF3 ) == geompy.NumberOfFaces( comp ) - 1
assert geompy.NumberOfEdges( glueF3 ) == geompy.NumberOfEdges( comp ) - 4
# check MakeGlueEdges()
glueE1 = geompy.MakeGlueEdges( [box1,box2], 1e-5)
assert glueE1.GetShapeType() == GEOM.COMPOUND
assert geompy.NumberOfEdges( glueE1 ) == geompy.NumberOfEdges( comp ) - 4
glueE2 = geompy.MakeGlueEdges( [comp], 1e-5)
assert glueE2.GetShapeType() == GEOM.COMPOUND
assert geompy.NumberOfEdges( glueE2 ) == geompy.NumberOfEdges( comp ) - 4
glueE3 = geompy.MakeGlueEdges( comp, 1e-5)
assert glueE3.GetShapeType() == GEOM.COMPOUND
assert geompy.NumberOfEdges( glueE3 ) == geompy.NumberOfEdges( comp ) - 4
# check GetGlueEdges()
glueEE1 = geompy.GetGlueEdges( [box1,box2], 1e-5)
assert len( glueEE1 ) == 4 and glueEE1[0].GetShapeType() == GEOM.EDGE
glueEE2 = geompy.GetGlueEdges( [comp], 1e-5)
assert len( glueEE2 ) == 4 and glueEE2[0].GetShapeType() == GEOM.EDGE
glueEE3 = geompy.GetGlueEdges( comp, 1e-5)
assert len( glueEE3 ) == 4 and glueEE3[0].GetShapeType() == GEOM.EDGE
#check MakeGlueEdgesByList()
glueEL1 = geompy.MakeGlueEdgesByList( [box1,box2], 1e-5, glueEE1)
assert glueEL1.GetShapeType() == GEOM.COMPOUND
assert geompy.NumberOfEdges( glueEL1 ) == geompy.NumberOfEdges( comp ) - 4
glueEL2 = geompy.MakeGlueEdgesByList( [comp], 1e-5, glueEE2)
assert glueEL2.GetShapeType() == GEOM.COMPOUND
assert geompy.NumberOfEdges( glueEL2 ) == geompy.NumberOfEdges( comp ) - 4
glueEL3 = geompy.MakeGlueEdgesByList( comp, 1e-5, glueEE3 )
assert glueEL3.GetShapeType() == GEOM.COMPOUND
assert geompy.NumberOfEdges( glueEL3 ) == geompy.NumberOfEdges( comp ) - 4
return
def TestHealingOperations (geompy, math): def TestHealingOperations (geompy, math):
TestSewGluing(geompy)
TestMakeSewing(geompy, math) TestMakeSewing(geompy, math)
TestDivideEdge(geompy) TestDivideEdge(geompy)
TestSuppressHoles(geompy) TestSuppressHoles(geompy)

View File

@ -6702,8 +6702,8 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
self._autoPublish(anObj[2], theName, "openWire") self._autoPublish(anObj[2], theName, "openWire")
return anObj return anObj
## Replace coincident faces in theShape by one face. ## Replace coincident faces in \a theShapes by one face.
# @param theShape Initial shape. # @param theShapes Initial shapes, either a list or compound of shapes.
# @param theTolerance Maximum distance between faces, which can be considered as coincident. # @param theTolerance Maximum distance between faces, which can be considered as coincident.
# @param doKeepNonSolids If FALSE, only solids will present in the result, # @param doKeepNonSolids If FALSE, only solids will present in the result,
# otherwise all initial shapes. # otherwise all initial shapes.
@ -6711,16 +6711,16 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
# for result publication in the study. Otherwise, if automatic # for result publication in the study. Otherwise, if automatic
# publication is switched on, default value is used for result name. # publication is switched on, default value is used for result name.
# #
# @return New GEOM.GEOM_Object, containing a copy of theShape without coincident faces. # @return New GEOM.GEOM_Object, containing copies of theShapes without coincident faces.
# #
# @ref tui_glue_faces "Example" # @ref tui_glue_faces "Example"
@ManageTransactions("ShapesOp") @ManageTransactions("ShapesOp")
def MakeGlueFaces(self, theShape, theTolerance, doKeepNonSolids=True, theName=None): def MakeGlueFaces(self, theShapes, theTolerance, doKeepNonSolids=True, theName=None):
""" """
Replace coincident faces in theShape by one face. Replace coincident faces in theShapes by one face.
Parameters: Parameters:
theShape Initial shape. theShapes Initial shapes, either a list or compound of shapes.
theTolerance Maximum distance between faces, which can be considered as coincident. theTolerance Maximum distance between faces, which can be considered as coincident.
doKeepNonSolids If FALSE, only solids will present in the result, doKeepNonSolids If FALSE, only solids will present in the result,
otherwise all initial shapes. otherwise all initial shapes.
@ -6729,19 +6729,19 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
publication is switched on, default value is used for result name. publication is switched on, default value is used for result name.
Returns: Returns:
New GEOM.GEOM_Object, containing a copy of theShape without coincident faces. New GEOM.GEOM_Object, containing copies of theShapes without coincident faces.
""" """
# Example: see GEOM_Spanner.py # Example: see GEOM_Spanner.py
theTolerance,Parameters = ParseParameters(theTolerance) theTolerance,Parameters = ParseParameters(theTolerance)
anObj = self.ShapesOp.MakeGlueFaces(theShape, theTolerance, doKeepNonSolids) anObj = self.ShapesOp.MakeGlueFaces(ToList(theShapes), theTolerance, doKeepNonSolids)
if anObj is None: if anObj is None:
raise RuntimeError, "MakeGlueFaces : " + self.ShapesOp.GetErrorCode() raise RuntimeError, "MakeGlueFaces : " + self.ShapesOp.GetErrorCode()
anObj.SetParameters(Parameters) anObj.SetParameters(Parameters)
self._autoPublish(anObj, theName, "glueFaces") self._autoPublish(anObj, theName, "glueFaces")
return anObj return anObj
## Find coincident faces in theShape for possible gluing. ## Find coincident faces in \a theShapes for possible gluing.
# @param theShape Initial shape. # @param theShapes Initial shapes, either a list or compound of shapes.
# @param theTolerance Maximum distance between faces, # @param theTolerance Maximum distance between faces,
# which can be considered as coincident. # which can be considered as coincident.
# @param theName Object name; when specified, this parameter is used # @param theName Object name; when specified, this parameter is used
@ -6752,12 +6752,12 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
# #
# @ref tui_glue_faces "Example" # @ref tui_glue_faces "Example"
@ManageTransactions("ShapesOp") @ManageTransactions("ShapesOp")
def GetGlueFaces(self, theShape, theTolerance, theName=None): def GetGlueFaces(self, theShapes, theTolerance, theName=None):
""" """
Find coincident faces in theShape for possible gluing. Find coincident faces in theShapes for possible gluing.
Parameters: Parameters:
theShape Initial shape. theShapes Initial shapes, either a list or compound of shapes.
theTolerance Maximum distance between faces, theTolerance Maximum distance between faces,
which can be considered as coincident. which can be considered as coincident.
theName Object name; when specified, this parameter is used theName Object name; when specified, this parameter is used
@ -6767,14 +6767,14 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
Returns: Returns:
GEOM.ListOfGO GEOM.ListOfGO
""" """
anObj = self.ShapesOp.GetGlueFaces(theShape, theTolerance) anObj = self.ShapesOp.GetGlueFaces(ToList(theShapes), theTolerance)
RaiseIfFailed("GetGlueFaces", self.ShapesOp) RaiseIfFailed("GetGlueFaces", self.ShapesOp)
self._autoPublish(anObj, theName, "facesToGlue") self._autoPublish(anObj, theName, "facesToGlue")
return anObj return anObj
## Replace coincident faces in theShape by one face ## Replace coincident faces in \a theShapes by one face
# in compliance with given list of faces # in compliance with given list of faces
# @param theShape Initial shape. # @param theShapes Initial shapes, either a list or compound of shapes.
# @param theTolerance Maximum distance between faces, # @param theTolerance Maximum distance between faces,
# which can be considered as coincident. # which can be considered as coincident.
# @param theFaces List of faces for gluing. # @param theFaces List of faces for gluing.
@ -6787,19 +6787,18 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
# for result publication in the study. Otherwise, if automatic # for result publication in the study. Otherwise, if automatic
# publication is switched on, default value is used for result name. # publication is switched on, default value is used for result name.
# #
# @return New GEOM.GEOM_Object, containing a copy of theShape # @return New GEOM.GEOM_Object, containing copies of theShapes without coincident faces.
# without some faces.
# #
# @ref tui_glue_faces "Example" # @ref tui_glue_faces "Example"
@ManageTransactions("ShapesOp") @ManageTransactions("ShapesOp")
def MakeGlueFacesByList(self, theShape, theTolerance, theFaces, def MakeGlueFacesByList(self, theShapes, theTolerance, theFaces,
doKeepNonSolids=True, doGlueAllEdges=True, theName=None): doKeepNonSolids=True, doGlueAllEdges=True, theName=None):
""" """
Replace coincident faces in theShape by one face Replace coincident faces in theShapes by one face
in compliance with given list of faces in compliance with given list of faces
Parameters: Parameters:
theShape Initial shape. theShapes theShapes Initial shapes, either a list or compound of shapes.
theTolerance Maximum distance between faces, theTolerance Maximum distance between faces,
which can be considered as coincident. which can be considered as coincident.
theFaces List of faces for gluing. theFaces List of faces for gluing.
@ -6813,51 +6812,50 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
publication is switched on, default value is used for result name. publication is switched on, default value is used for result name.
Returns: Returns:
New GEOM.GEOM_Object, containing a copy of theShape New GEOM.GEOM_Object, containing copies of theShapes without coincident faces.
without some faces.
""" """
anObj = self.ShapesOp.MakeGlueFacesByList(theShape, theTolerance, theFaces, anObj = self.ShapesOp.MakeGlueFacesByList(ToList(theShapes), theTolerance, theFaces,
doKeepNonSolids, doGlueAllEdges) doKeepNonSolids, doGlueAllEdges)
if anObj is None: if anObj is None:
raise RuntimeError, "MakeGlueFacesByList : " + self.ShapesOp.GetErrorCode() raise RuntimeError, "MakeGlueFacesByList : " + self.ShapesOp.GetErrorCode()
self._autoPublish(anObj, theName, "glueFaces") self._autoPublish(anObj, theName, "glueFaces")
return anObj return anObj
## Replace coincident edges in theShape by one edge. ## Replace coincident edges in \a theShapes by one edge.
# @param theShape Initial shape. # @param theShapes Initial shapes, either a list or compound of shapes.
# @param theTolerance Maximum distance between edges, which can be considered as coincident. # @param theTolerance Maximum distance between edges, which can be considered as coincident.
# @param theName Object name; when specified, this parameter is used # @param theName Object name; when specified, this parameter is used
# for result publication in the study. Otherwise, if automatic # for result publication in the study. Otherwise, if automatic
# publication is switched on, default value is used for result name. # publication is switched on, default value is used for result name.
# #
# @return New GEOM.GEOM_Object, containing a copy of theShape without coincident edges. # @return New GEOM.GEOM_Object, containing copies of theShapes without coincident edges.
# #
# @ref tui_glue_edges "Example" # @ref tui_glue_edges "Example"
@ManageTransactions("ShapesOp") @ManageTransactions("ShapesOp")
def MakeGlueEdges(self, theShape, theTolerance, theName=None): def MakeGlueEdges(self, theShapes, theTolerance, theName=None):
""" """
Replace coincident edges in theShape by one edge. Replace coincident edges in theShapes by one edge.
Parameters: Parameters:
theShape Initial shape. theShapes Initial shapes, either a list or compound of shapes.
theTolerance Maximum distance between edges, which can be considered as coincident. theTolerance Maximum distance between edges, which can be considered as coincident.
theName Object name; when specified, this parameter is used theName Object name; when specified, this parameter is used
for result publication in the study. Otherwise, if automatic for result publication in the study. Otherwise, if automatic
publication is switched on, default value is used for result name. publication is switched on, default value is used for result name.
Returns: Returns:
New GEOM.GEOM_Object, containing a copy of theShape without coincident edges. New GEOM.GEOM_Object, containing copies of theShapes without coincident edges.
""" """
theTolerance,Parameters = ParseParameters(theTolerance) theTolerance,Parameters = ParseParameters(theTolerance)
anObj = self.ShapesOp.MakeGlueEdges(theShape, theTolerance) anObj = self.ShapesOp.MakeGlueEdges(ToList(theShapes), theTolerance)
if anObj is None: if anObj is None:
raise RuntimeError, "MakeGlueEdges : " + self.ShapesOp.GetErrorCode() raise RuntimeError, "MakeGlueEdges : " + self.ShapesOp.GetErrorCode()
anObj.SetParameters(Parameters) anObj.SetParameters(Parameters)
self._autoPublish(anObj, theName, "glueEdges") self._autoPublish(anObj, theName, "glueEdges")
return anObj return anObj
## Find coincident edges in theShape for possible gluing. ## Find coincident edges in \a theShapes for possible gluing.
# @param theShape Initial shape. # @param theShapes Initial shapes, either a list or compound of shapes.
# @param theTolerance Maximum distance between edges, # @param theTolerance Maximum distance between edges,
# which can be considered as coincident. # which can be considered as coincident.
# @param theName Object name; when specified, this parameter is used # @param theName Object name; when specified, this parameter is used
@ -6868,12 +6866,12 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
# #
# @ref tui_glue_edges "Example" # @ref tui_glue_edges "Example"
@ManageTransactions("ShapesOp") @ManageTransactions("ShapesOp")
def GetGlueEdges(self, theShape, theTolerance, theName=None): def GetGlueEdges(self, theShapes, theTolerance, theName=None):
""" """
Find coincident edges in theShape for possible gluing. Find coincident edges in theShapes for possible gluing.
Parameters: Parameters:
theShape Initial shape. theShapes Initial shapes, either a list or compound of shapes.
theTolerance Maximum distance between edges, theTolerance Maximum distance between edges,
which can be considered as coincident. which can be considered as coincident.
theName Object name; when specified, this parameter is used theName Object name; when specified, this parameter is used
@ -6883,14 +6881,14 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
Returns: Returns:
GEOM.ListOfGO GEOM.ListOfGO
""" """
anObj = self.ShapesOp.GetGlueEdges(theShape, theTolerance) anObj = self.ShapesOp.GetGlueEdges(ToList(theShapes), theTolerance)
RaiseIfFailed("GetGlueEdges", self.ShapesOp) RaiseIfFailed("GetGlueEdges", self.ShapesOp)
self._autoPublish(anObj, theName, "edgesToGlue") self._autoPublish(anObj, theName, "edgesToGlue")
return anObj return anObj
## Replace coincident edges in theShape by one edge ## Replace coincident edges in theShapes by one edge
# in compliance with given list of edges. # in compliance with given list of edges.
# @param theShape Initial shape. # @param theShapes Initial shapes, either a list or compound of shapes.
# @param theTolerance Maximum distance between edges, # @param theTolerance Maximum distance between edges,
# which can be considered as coincident. # which can be considered as coincident.
# @param theEdges List of edges for gluing. # @param theEdges List of edges for gluing.
@ -6898,18 +6896,17 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
# for result publication in the study. Otherwise, if automatic # for result publication in the study. Otherwise, if automatic
# publication is switched on, default value is used for result name. # publication is switched on, default value is used for result name.
# #
# @return New GEOM.GEOM_Object, containing a copy of theShape # @return New GEOM.GEOM_Object, containing copies of theShapes without coincident edges.
# without some edges.
# #
# @ref tui_glue_edges "Example" # @ref tui_glue_edges "Example"
@ManageTransactions("ShapesOp") @ManageTransactions("ShapesOp")
def MakeGlueEdgesByList(self, theShape, theTolerance, theEdges, theName=None): def MakeGlueEdgesByList(self, theShapes, theTolerance, theEdges, theName=None):
""" """
Replace coincident edges in theShape by one edge Replace coincident edges in theShapes by one edge
in compliance with given list of edges. in compliance with given list of edges.
Parameters: Parameters:
theShape Initial shape. theShapes Initial shapes, either a list or compound of shapes.
theTolerance Maximum distance between edges, theTolerance Maximum distance between edges,
which can be considered as coincident. which can be considered as coincident.
theEdges List of edges for gluing. theEdges List of edges for gluing.
@ -6918,10 +6915,9 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
publication is switched on, default value is used for result name. publication is switched on, default value is used for result name.
Returns: Returns:
New GEOM.GEOM_Object, containing a copy of theShape New GEOM.GEOM_Object, containing copies of theShapes without coincident edges.
without some edges.
""" """
anObj = self.ShapesOp.MakeGlueEdgesByList(theShape, theTolerance, theEdges) anObj = self.ShapesOp.MakeGlueEdgesByList(ToList(theShapes), theTolerance, theEdges)
if anObj is None: if anObj is None:
raise RuntimeError, "MakeGlueEdgesByList : " + self.ShapesOp.GetErrorCode() raise RuntimeError, "MakeGlueEdgesByList : " + self.ShapesOp.GetErrorCode()
self._autoPublish(anObj, theName, "glueEdges") self._autoPublish(anObj, theName, "glueEdges")

View File

@ -91,7 +91,7 @@ RepairGUI_GlueDlg::RepairGUI_GlueDlg(GeometryGUI* theGeometryGUI, QWidget* paren
GroupPoints = new DlgRef_1SelExt(centralWidget()); GroupPoints = new DlgRef_1SelExt(centralWidget());
GroupPoints->GroupBox1->setTitle(tr("GEOM_GLUE")); GroupPoints->GroupBox1->setTitle(tr("GEOM_GLUE"));
GroupPoints->TextLabel1->setText(tr("GEOM_SELECTED_SHAPE")); GroupPoints->TextLabel1->setText(tr("GEOM_SELECTED_SHAPES"));
GroupPoints->PushButton1->setIcon(image0); GroupPoints->PushButton1->setIcon(image0);
GroupPoints->LineEdit1->setReadOnly(true); GroupPoints->LineEdit1->setReadOnly(true);
@ -108,7 +108,7 @@ RepairGUI_GlueDlg::RepairGUI_GlueDlg(GeometryGUI* theGeometryGUI, QWidget* paren
GroupPoints2 = new DlgRef_1SelExt(centralWidget()); GroupPoints2 = new DlgRef_1SelExt(centralWidget());
GroupPoints2->GroupBox1->setTitle(tr("GEOM_GLUE")); GroupPoints2->GroupBox1->setTitle(tr("GEOM_GLUE"));
GroupPoints2->TextLabel1->setText(tr("GEOM_SELECTED_SHAPE")); GroupPoints2->TextLabel1->setText(tr("GEOM_SELECTED_SHAPES"));
GroupPoints2->PushButton1->setIcon(image0); GroupPoints2->PushButton1->setIcon(image0);
GroupPoints2->LineEdit1->setReadOnly(true); GroupPoints2->LineEdit1->setReadOnly(true);
@ -191,7 +191,7 @@ void RepairGUI_GlueDlg::Init()
/* init variables */ /* init variables */
myEditCurrentArgument = GroupPoints->LineEdit1; myEditCurrentArgument = GroupPoints->LineEdit1;
myObject = GEOM::GEOM_Object::_nil(); myObjects.clear();
//myGeomGUI->SetState(0); //myGeomGUI->SetState(0);
//globalSelection(GEOM_COMPOUND); //globalSelection(GEOM_COMPOUND);
@ -330,17 +330,13 @@ void RepairGUI_GlueDlg::SelectionIntoArgument()
erasePreview(); erasePreview();
myEditCurrentArgument->setText(""); myEditCurrentArgument->setText("");
myObject = GEOM::GEOM_Object::_nil(); myObjects.clear();
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); myObjects = getSelected( TopAbs_SHAPE, -1 );
SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList);
if (aSelList.Extent() == 1) { if ( !myObjects.isEmpty() ) {
Handle(SALOME_InteractiveObject) anIO = aSelList.First(); QString aName = myObjects.count() > 1 ? QString( "%1_objects").arg( myObjects.count() ) : GEOMBase::GetName( myObjects[0].get() );
myObject = GEOMBase::ConvertIOinGEOMObject(anIO); myEditCurrentArgument->setText( aName );
if (!CORBA::is_nil(myObject))
myEditCurrentArgument->setText(GEOMBase::GetName(myObject));
} }
updateButtonState(); updateButtonState();
} }
@ -432,7 +428,7 @@ bool RepairGUI_GlueDlg::isValid(QString& msg)
ok = myTolEdt2->isValid(msg, !IsPreview()); ok = myTolEdt2->isValid(msg, !IsPreview());
break; break;
} }
return !myObject->_is_nil() && (IsPreview() || v > 0.) && ok; return !myObjects.isEmpty() && (IsPreview() || v > 0.) && ok;
} }
//================================================================================= //=================================================================================
@ -444,15 +440,20 @@ bool RepairGUI_GlueDlg::execute(ObjectList& objects)
bool aResult = false; bool aResult = false;
objects.clear(); objects.clear();
GEOM::ListOfGO_var objList = new GEOM::ListOfGO;
objList->length( myObjects.count() );
for ( int i = 0; i < myObjects.count(); ++i )
objList[i] = myObjects[i].copy();
GEOM::GEOM_IShapesOperations_var anOper = GEOM::GEOM_IShapesOperations::_narrow(getOperation()); GEOM::GEOM_IShapesOperations_var anOper = GEOM::GEOM_IShapesOperations::_narrow(getOperation());
switch (getConstructorId()) { switch (getConstructorId()) {
case 0: case 0:
{ {
GEOM::GEOM_Object_var anObj; GEOM::GEOM_Object_var anObj;
if (myGlueMode == TopAbs_FACE) if (myGlueMode == TopAbs_FACE)
anObj = anOper->MakeGlueFaces(myObject, myTolEdt->value(), true); anObj = anOper->MakeGlueFaces( objList, myTolEdt->value(), true);
else if (myGlueMode == TopAbs_EDGE) else if (myGlueMode == TopAbs_EDGE)
anObj = anOper->MakeGlueEdges(myObject, myTolEdt->value()); anObj = anOper->MakeGlueEdges( objList, myTolEdt->value());
aResult = !anObj->_is_nil(); aResult = !anObj->_is_nil();
if (aResult && !IsPreview()) if (aResult && !IsPreview())
@ -506,11 +507,11 @@ bool RepairGUI_GlueDlg::execute(ObjectList& objects)
GEOM::GEOM_Object_var anObj; GEOM::GEOM_Object_var anObj;
if (myGlueMode == TopAbs_FACE) { if (myGlueMode == TopAbs_FACE) {
bool doGlueAllEdges = myGlueAllEdgesChk->isChecked(); bool doGlueAllEdges = myGlueAllEdgesChk->isChecked();
anObj = anOper->MakeGlueFacesByList(myObject, myTolEdt2->value(), aListForGlue.in(), anObj = anOper->MakeGlueFacesByList( objList, myTolEdt2->value(), aListForGlue.in(),
true, doGlueAllEdges); true, doGlueAllEdges);
} }
else if (myGlueMode == TopAbs_EDGE) else if (myGlueMode == TopAbs_EDGE)
anObj = anOper->MakeGlueEdgesByList(myObject, myTolEdt2->value(), aListForGlue.in()); anObj = anOper->MakeGlueEdgesByList( objList, myTolEdt2->value(), aListForGlue.in());
aResult = !anObj->_is_nil(); aResult = !anObj->_is_nil();
@ -693,12 +694,17 @@ void RepairGUI_GlueDlg::onDetect()
buttonApply()->setEnabled(false); buttonApply()->setEnabled(false);
globalSelection(GEOM_ALLSHAPES); globalSelection(GEOM_ALLSHAPES);
GEOM::ListOfGO_var objList = new GEOM::ListOfGO;
objList->length( myObjects.count() );
for ( int i = 0; i < myObjects.count(); ++i )
objList[i] = myObjects[i].copy();
GEOM::GEOM_IShapesOperations_var anOper = GEOM::GEOM_IShapesOperations::_narrow(getOperation()); GEOM::GEOM_IShapesOperations_var anOper = GEOM::GEOM_IShapesOperations::_narrow(getOperation());
GEOM::ListOfGO_var aList; GEOM::ListOfGO_var aList;
if (myGlueMode == TopAbs_FACE) if (myGlueMode == TopAbs_FACE)
aList = anOper->GetGlueFaces(myObject.in(), myTolEdt2->value()); aList = anOper->GetGlueFaces( objList, myTolEdt2->value());
else if (myGlueMode == TopAbs_EDGE) else if (myGlueMode == TopAbs_EDGE)
aList = anOper->GetGlueEdges(myObject.in(), myTolEdt2->value()); aList = anOper->GetGlueEdges( objList, myTolEdt2->value());
for (int i = 0, n = aList->length(); i < n; i++) for (int i = 0, n = aList->length(); i < n; i++)
myTmpObjs << GEOM::GeomObjPtr(aList[i].in()); myTmpObjs << GEOM::GeomObjPtr(aList[i].in());
@ -719,7 +725,10 @@ void RepairGUI_GlueDlg::onDetect()
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument())) ; this, SLOT(SelectionIntoArgument())) ;
SUIT_MessageBox::information(this, tr("GEOM_FREE_BOUNDS_TLT"), msg, tr("Close")); if ( myGlueMode == TopAbs_FACE )
SUIT_MessageBox::information(this, tr("GEOM_GLUE_FACES_DETECT_TITLE"), msg, tr("Close"));
else
SUIT_MessageBox::information(this, tr("GEOM_GLUE_EDGES_DETECT_TITLE"), msg, tr("Close"));
updateButtonState(); updateButtonState();
activateSelection(); activateSelection();
} }
@ -739,7 +748,7 @@ void RepairGUI_GlueDlg::activateSelection()
this, SLOT(SelectionIntoArgument())); this, SLOT(SelectionIntoArgument()));
globalSelection(GEOM_ALLSHAPES); globalSelection(GEOM_ALLSHAPES);
if (myObject->_is_nil()) if ( myObjects.isEmpty() )
SelectionIntoArgument(); SelectionIntoArgument();
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
@ -768,7 +777,7 @@ void RepairGUI_GlueDlg::activateSelection()
void RepairGUI_GlueDlg::updateButtonState() void RepairGUI_GlueDlg::updateButtonState()
{ {
int anId = getConstructorId(); int anId = getConstructorId();
bool hasMainObj = !myObject->_is_nil(); bool hasMainObj = !myObjects.isEmpty();
if (anId == 0) { if (anId == 0) {
buttonOk()->setEnabled(hasMainObj); buttonOk()->setEnabled(hasMainObj);
buttonApply()->setEnabled(hasMainObj); buttonApply()->setEnabled(hasMainObj);

View File

@ -73,7 +73,7 @@ private:
void selectTmpInViewer(); void selectTmpInViewer();
private: private:
GEOM::GEOM_Object_var myObject; QList<GEOM::GeomObjPtr> myObjects;
QList<GEOM::GeomObjPtr> myTmpObjs; QList<GEOM::GeomObjPtr> myTmpObjs;
DlgRef_1SelExt* GroupPoints; DlgRef_1SelExt* GroupPoints;

View File

@ -70,7 +70,7 @@ RepairGUI_SewingDlg::RepairGUI_SewingDlg( GeometryGUI* theGeometryGUI, QWidget*
GroupPoints = new DlgRef_1SelExt( centralWidget() ); GroupPoints = new DlgRef_1SelExt( centralWidget() );
GroupPoints->GroupBox1->setTitle( tr( "GEOM_SEWING" ) ); GroupPoints->GroupBox1->setTitle( tr( "GEOM_SEWING" ) );
GroupPoints->TextLabel1->setText( tr( "GEOM_SELECTED_SHAPE" ) ); GroupPoints->TextLabel1->setText( tr( "GEOM_SELECTED_SHAPES" ) );
GroupPoints->PushButton1->setIcon( image1 ); GroupPoints->PushButton1->setIcon( image1 );
GroupPoints->LineEdit1->setReadOnly( true ); GroupPoints->LineEdit1->setReadOnly( true );