\n This operation glues edges that are coincident with respect to the
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>
\ref restore_presentation_parameters_page "Set presentation parameters and sub-shapes from arguments".
\n The \b Result will be a \b GEOM_Object.
\image html glue4.png
\n <b>TUI Command:</b>
-\n <em>geompy.MakeGlueEdges(theShape,theTolerance)</em>,
-\n where \em theShape is a compound of shapes to be glued, and \em
- theTolerance is a maximum distance between two faces/edges, which can
- be considered as coincident.
+<p><em>geompy.MakeGlueEdges( theShapes, theTolerance )</em>,
+\n where \em theShapes is either a list or compound of shapes to be
+glued, and \em theTolerance is a maximum distance between two
+edges, which can be considered as coincident.
\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.
The selected edges will be marked in white.
\n <b>TUI Command:</b>
-\n <em>geompy.GetGlueEdges(theShape,theTolerance)</em>,
-\n where \em theShape is a compound of shapes to be glued, \em
+<p><em>geompy.GetGlueEdges( theShapes, theTolerance )</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
be considered as coincident. The \b Result will be a list of \b
- GEOM_Objects, containing one sub-shape per each detected set of
- coincident sub-shapes.
+ GEOM_Objects (edges), containing one sub-shape per each detected set of
+ 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>,
-\n where \em theShape is a compound of shapes to be glued, \em
+<em>geompy.MakeGlueEdgesByList( theShapes, theTolerance, theEdges )</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
be considered as coincident, \em theEdges is a list of
- sub-shapes to be glued.
+ edges to be glued.
\n <b>Example:</b>
\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
<b>Repairing Operations</b> \ref tui_glue_edges "Glue Edges".
\n This operation glues faces that are coincident with respect to the
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>
\ref restore_presentation_parameters_page "Set presentation parameters and sub-shapes from arguments".
\n The \b Result will be a \b GEOM_Object.
\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
be considered as coincident. The \em doKeepNonSolids flag allows to
throw away non-solids from the result, if false. The \b Result will
possible to select the faces for gluing in the 3D viewer.
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>
checkbox.
\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
- theTolerance is a maximum distance between two faces, which can
- be considered as coincident. The \b Result will be a list of \b
- GEOM_Objects, containing one sub-shape per each detected set of
- coincident sub-shapes.
-\n <em>geompy.MakeGlueFacesByList(theShape,theTolerance,theFaces,doKeepNonSolids,doGlueAllEdges)</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
+be considered as coincident. The \b Result will be a list of \b
+GEOM_Objects (faces), containing one sub-shape per each detected set of
+coincident sub-shapes. For example if there are two coincident faces
+in selected shapes, the result list contains one of the two coincident faces.
+
+<em>geompy.MakeGlueFacesByList( theShapes, theTolerance, theFaces,
+ 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
be considered as coincident, \em theFaces is a list of
sub-shapes to be glued. The \em doKeepNonSolids flag allows to throw
\n To <b>Remove internal faces</b> in the <b>Main Menu</b> select
<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.
\image html remove_webs.png
\ref restore_presentation_parameters_page "Set presentation parameters and sub-shapes from arguments".
\note Only shared faces will be removed. Coincident but not shared
-faces will stay as is, use Glue Faces or Partition before
-Remove Internal Faces if you need to remove them.
+faces will stay as is, use \ref glue_faces_operation_page or \ref partition_page before
+<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.
\n Our <b>TUI Scripts</b> provide you with useful examples of the
holes with free boundaries on a selected face.</li>
<li>\subpage sewing_operation_page "Sewing" - sews faces or shells.</li>
<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
-coincident edges within the given tolerance.</li>
+edges coincident within the given tolerance.</li>
<li>\subpage limit_tolerance_operation_page "Limit Tolerance" - tries
to set new tolerance value for the given shape.</li>
<li>\subpage add_point_on_edge_operation_page "Add point on edge" -
GEOM_Object MakeCompound (in ListOfGO theShapes);
/*!
- * \brief Replace coincident faces in theShape by one face.
- * \param theShape Initial shape.
+ * \brief Replace coincident faces in \a theShapes by one face.
+ * \param theShapes Initial shapes.
* \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.
- * \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.
- * \param theShape Initial shape.
+ * Find coincident faces in theShapes for possible gluing.
+ * \param theShapes Initial shapes.
* \param theTolerance Maximum distance between faces, which can be considered as coincident.
* \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
- * in compliance with given list of faces
- * \param theShape Initial shape.
+ * \brief Replace coincident faces in \a theShapes by one face
+ * in compliance with given list of faces
+ * \param theShapes Initial shapes.
* \param theTolerance Maximum distance between faces, which can be considered as coincident.
* \param theFaces List of faces for gluing.
* \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>
* will be glued, otherwise only the edges,
* 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,
- in ListOfGO theFaces, in boolean doKeepNonSolids,
+ GEOM_Object MakeGlueFacesByList (in ListOfGO theShapes, in double theTolerance,
+ in ListOfGO theFaces, in boolean doKeepNonSolids,
in boolean doGlueAllEdges);
/*!
- * \brief Replace coincident edges in theShape by one edge.
- * \param theShape Initial shape.
+ * \brief Replace coincident edges in \a theShapes by one edge.
+ * \param theShapes Initial shapes.
* \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.
- * \param theShape Initial shape.
+ * Find coincident edges in \a theShapes for possible gluing.
+ * \param theShapes Initial shapes.
* \param theTolerance Maximum distance between edges, which can be considered as coincident.
* \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
- * in compliance with given list of edges
- * \param theShape Initial shape.
+ * \brief Replace coincident edges in \a theShapes by one edge
+ * in compliance with given list of edges
+ * \param theShapes Initial shapes.
* \param theTolerance Maximum distance between edges, which can be considered as coincident.
* \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,
- in double theTolerance,
+ GEOM_Object MakeGlueEdgesByList (in ListOfGO theShape,
+ in double theTolerance,
in ListOfGO theEdges);
/*!
*/
//=============================================================================
gp_Trsf AdvancedEngine_IOperations::GetPositionTrsf(double theL1, double theL2,
- Handle(GEOM_Object) theP1,
- Handle(GEOM_Object) theP2,
- Handle(GEOM_Object) theP3)
+ Handle(GEOM_Object) theP1,
+ Handle(GEOM_Object) theP2,
+ Handle(GEOM_Object) theP3)
{
// Old Local Coordinates System oldLCS
gp_Pnt P0(0, 0, 0);
*/
//=============================================================================
bool AdvancedEngine_IOperations::CheckCompatiblePosition(double& theL1, double& theL2,
- Handle(GEOM_Object) theP1,
- Handle(GEOM_Object) theP2,
- Handle(GEOM_Object) theP3,
- double theTolerance)
+ Handle(GEOM_Object) theP1,
+ Handle(GEOM_Object) theP2,
+ Handle(GEOM_Object) theP3,
+ double theTolerance)
{
SetErrorCode(KO);
gp_Pnt P1 = BRep_Tool::Pnt(TopoDS::Vertex(theP1->GetValue()));
*/
//=============================================================================
bool AdvancedEngine_IOperations::MakeGroups(Handle(GEOM_Object) theShape, int shapeType,
- double theR1, double theW1, double theL1,
- double theR2, double theW2, double theL2,
- double theH, double theW, double theRF,
- Handle(TColStd_HSequenceOfTransient) theSeq,
- gp_Trsf aTrsf)
+ double theR1, double theW1, double theL1,
+ double theR2, double theW2, double theL2,
+ double theH, double theW, double theRF,
+ Handle(TColStd_HSequenceOfTransient) theSeq,
+ gp_Trsf aTrsf)
{
SetErrorCode(KO);
}
bool AdvancedEngine_IOperations::MakePipeTShapePartition(Handle(GEOM_Object) theShape,
- double theR1, double theW1, double theL1,
- double theR2, double theW2, double theL2,
- double theH, double theW,
- double theRF, bool isNormal)
+ double theR1, double theW1, double theL1,
+ double theR2, double theW2, double theL2,
+ double theH, double theW,
+ double theRF, bool isNormal)
{
SetErrorCode(KO);
if (Abs(aP.X()) <= Precision::Confusion()) {
if (Abs(aP.Y()) < d1min) {
vi1 = v;
- d1min = Abs(aP.Y());
- }
+ d1min = Abs(aP.Y());
+ }
} else if (Abs(aP.Y()) <= Precision::Confusion()) {
- if (Abs(aP.X()) < d2min) {
- vi2 = v;
- d2min = Abs(aP.X());
+ if (Abs(aP.X()) < d2min) {
+ vi2 = v;
+ d2min = Abs(aP.X());
}
}
}
if (Abs(aP.X()) <= Precision::Confusion()) {
if (Abs(aP.Y()) > d1max) {
ve1 = v;
- vertex1 = aVertex;
- d1max = Abs(aP.Y());
+ vertex1 = aVertex;
+ d1max = Abs(aP.Y());
}
} else if (Abs(aP.Y()) <= Precision::Confusion()) {
if (Abs(aP.X()) > d2max) {
ve2 = v;
- vertex2 = aVertex;
- d2max = Abs(aP.X());
+ vertex2 = aVertex;
+ d2max = Abs(aP.X());
}
}
}
for (int i=1; i<=edges_e->Length();i++) {
Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(edges_e->Value(i));
anObj->GetLastFunction()->SetDescription("");
- TopoDS_Edge anEdge = TopoDS::Edge(anObj->GetValue());
- if ( !anEdge.IsNull() &&
- (sae.FirstVertex(anEdge).IsSame(vertex1) || sae.LastVertex(anEdge).IsSame(vertex1)) &&
- (sae.FirstVertex(anEdge).IsSame(vertex2) || sae.LastVertex(anEdge).IsSame(vertex2))) {
- arete_intersect_ext = anObj;
- }
+ TopoDS_Edge anEdge = TopoDS::Edge(anObj->GetValue());
+ if ( !anEdge.IsNull() &&
+ (sae.FirstVertex(anEdge).IsSame(vertex1) || sae.LastVertex(anEdge).IsSame(vertex1)) &&
+ (sae.FirstVertex(anEdge).IsSame(vertex2) || sae.LastVertex(anEdge).IsSame(vertex2))) {
+ arete_intersect_ext = anObj;
+ }
}
edge_e1 = myBasicOperations->MakeLineTwoPnt(ve1, vi1);
// Mirror and glue faces
bool AdvancedEngine_IOperations::MakePipeTShapeMirrorAndGlue(Handle(GEOM_Object) theShape,
- double theR1, double theW1, double theL1,
- double theR2, double theW2, double theL2)
+ double theR1, double theW1, double theL1,
+ double theR2, double theW2, double theL2)
{
SetErrorCode(KO);
TColStd_IndexedDataMapOfTransientTransient aMapTShapes;
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()) {
SetErrorCode("Impossible to glue faces of TShape");
return false;
// Perform gluing
Te7->GetLastFunction()->SetValue(aShapeCopy);
- Te8 = myShapesOperations->MakeGlueFaces(Te7, aTolMax, true);
+ Te8 = myShapesOperations->MakeGlueFaces(Te7list, aTolMax, true);
if (Te8.IsNull()) {
SetErrorCode("Impossible to glue faces of TShape");
//purpose : Static method. Create one thickness reduction element.
//=======================================================================
TopoDS_Shape AdvancedEngine_IOperations::MakeThicknessReduction (gp_Ax2 theAxes,
- const double R, const double W,
- const double Rthin, const double Wthin,
- const double Ltrans, const double Lthin,
- bool fuse)
+ const double R, const double W,
+ const double Rthin, const double Wthin,
+ const double Ltrans, const double Lthin,
+ bool fuse)
{
double aTol = Precision::Confusion();
if (Rthin < aTol || Wthin < aTol || Ltrans < aTol) {
//=============================================================================
Handle(TColStd_HSequenceOfTransient)
AdvancedEngine_IOperations::MakePipeTShape(double theR1, double theW1, double theL1,
- double theR2, double theW2, double theL2,
- double theRL, double theWL, double theLtransL, double theLthinL,
- double theRR, double theWR, double theLtransR, double theLthinR,
- double theRI, double theWI, double theLtransI, double theLthinI,
- bool theHexMesh)
+ double theR2, double theW2, double theL2,
+ double theRL, double theWL, double theLtransL, double theLthinL,
+ double theRR, double theWR, double theLtransR, double theLthinR,
+ double theRI, double theWI, double theLtransI, double theLthinI,
+ bool theHexMesh)
{
MESSAGE("AdvancedEngine_IOperations::MakePipeTShape");
SetErrorCode(KO);
*/
//=============================================================================
Handle(GEOM_Object) AdvancedEngine_IOperations::MakeDividedDisk (double theR, double theRatio,
- int theOrientation, int thePattern)
+ int theOrientation, int thePattern)
{
SetErrorCode(KO);
*/
//=============================================================================
Handle(GEOM_Object) AdvancedEngine_IOperations::MakeDividedDiskPntVecR (Handle(GEOM_Object) thePnt,
- Handle(GEOM_Object) theVec,
- double theR,
- double theRatio,
- int thePattern)
+ Handle(GEOM_Object) theVec,
+ double theR,
+ double theRatio,
+ int thePattern)
{
SetErrorCode(KO);
*/
//=============================================================================
Handle(GEOM_Object) AdvancedEngine_IOperations::MakeDividedCylinder (double theR,
- double theH,
- int thePattern)
+ double theH,
+ int thePattern)
{
SetErrorCode(KO);
*/
//=============================================================================
Handle(GEOM_Object) AdvancedEngine_IOperations::MakeSmoothingSurface (std::list<Handle(GEOM_Object)> thelPoints,
- int theNbMax,
- int theDegMax,
- double theDMax)
+ int theNbMax,
+ int theDegMax,
+ double theDMax)
{
SetErrorCode(KO);
*/
//=============================================================================
-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);
return Handle(GEOM_Object)::DownCast( base );
*/
//=============================================================================
-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);
return Handle(GEOM_Object)::DownCast( base );
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_RTTIEXT(GEOM_Object, GEOM_BaseObject );
+
#include <Aspect_TypeOfMarker.hxx>
#include <Standard_GUID.hxx>
+#include <TColStd_HSequenceOfTransient.hxx>
#include <TDF_Label.hxx>
#include <TopoDS_Shape.hxx>
+#include <list>
+
class GEOM_Object;
class Handle(TFunction_Driver);
class GEOM_Engine;
Standard_EXPORT ~GEOM_Object();
//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
- Standard_EXPORT static Handle(GEOM_Object) GetReferencedObject(TDF_Label& theLabel);
+ Standard_EXPORT static Handle(GEOM_Object) GetReferencedObject(const TDF_Label& theLabel);
//###########################################################
//Access to properties
//Returns false if the object is a sub-shape of another object
Standard_EXPORT bool IsMainShape();
+ //Comfort method
+ Standard_EXPORT static Handle(TColStd_HSequenceOfTransient)
+ GetLastFunctions( const std::list< Handle(GEOM_Object) >& theObjects );
+
public:
DEFINE_STANDARD_RTTI( GEOM_Object );
};
for (i = 1; i <= aLen; 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);
}
return aLatest;
<source>GEOM_GLUE_EDGES_TITLE</source>
<translation>Glue edges</translation>
</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>
<source>GLUE_ERROR_STICKED_SHAPES</source>
<translation>The tolerance value is too big. Sticked shapes are detected.</translation>
<source>GEOM_SELECTED_SHAPE</source>
<translation>Selected shape</translation>
</message>
+ <message>
+ <source>GEOM_SELECTED_SHAPES</source>
+ <translation>Selected shapes</translation>
+ </message>
<message>
<source>GEOM_SELECTION</source>
<translation>Selection</translation>
#include "utilities.h"
+#include <BRep_Builder.hxx>
+#include <ShapeFix_Shape.hxx>
#include <TDataStd_IntegerArray.hxx>
-
#include <TopExp.hxx>
-#include <TopoDS_Shape.hxx>
#include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
-#include <TopTools_ListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
-
-#include <ShapeFix_Shape.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopoDS_Shape.hxx>
#include <Standard_NullObject.hxx>
#include <Standard_Failure.hxx>
TopoDS_Shape aShape;
TCollection_AsciiString aWrn;
- Handle(GEOM_Function) aRefBase = aCI.GetBase();
- TopoDS_Shape aShapeBase = aRefBase->GetValue();
+ TopoDS_Shape aShapeBase;
+ 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()) {
Standard_NullObject::Raise("Shape for gluing is null");
}
switch ( aType ) {
case GLUE_FACES:
theOperationName = "GLUE_FACES";
- AddParam( theParams, "Selected shape", aCI.GetBase() );
+ AddParam( theParams, "Selected shapes", aCI.GetBase() );
AddParam( theParams, "Tolerance", aCI.GetTolerance() );
AddParam( theParams, "To keep non solids", aCI.GetKeepNonSolids() );
break;
case GLUE_EDGES:
theOperationName = "GLUE_EDGES";
- AddParam( theParams, "Selected shape", aCI.GetBase() );
+ AddParam( theParams, "Selected shapes", aCI.GetBase() );
AddParam( theParams, "Tolerance", aCI.GetTolerance() );
break;
case GLUE_FACES_BY_LIST:
theOperationName = "GLUE_FACES";
- AddParam( theParams, "Selected shape", aCI.GetBase() );
+ AddParam( theParams, "Selected shapes", aCI.GetBase() );
AddParam( theParams, "Tolerance", aCI.GetTolerance() );
AddParam( theParams, "Faces", aCI.GetFaces() );
AddParam( theParams, "To keep non solids", aCI.GetKeepNonSolids() );
break;
case GLUE_EDGES_BY_LIST:
theOperationName = "GLUE_EDGES";
- AddParam( theParams, "Selected shape", aCI.GetBase() );
+ AddParam( theParams, "Selected shapes", aCI.GetBase() );
AddParam( theParams, "Tolerance", aCI.GetTolerance() );
AddParam( theParams, "Edges", aCI.GetFaces() );
break;
#include <TColStd_HSequenceOfTransient.hxx>
-#define GLUE_ARG_BASE 1
-#define GLUE_ARG_TOLER 2
-#define GLUE_ARG_FACES 3
+#define GLUE_ARG_BASE 1
+#define GLUE_ARG_TOLER 2
+#define GLUE_ARG_FACES 3
#define GLUE_ARG_KEEPALL 4
#define GLUE_ARG_GLUEEDG 5
GEOMImpl_IGlue(Handle(GEOM_Function) theFunction): _func(theFunction) {}
- void SetBase(Handle(GEOM_Function) theRefBase)
- { _func->SetReference(GLUE_ARG_BASE, theRefBase); }
+ void SetBase(const Handle(TColStd_HSequenceOfTransient)& theShapes)
+ { _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)
{ _func->SetReal(GLUE_ARG_TOLER, theTolerance); }
if (theObjects.empty())
return NULL;
- Handle(TColStd_HSequenceOfTransient) objects = new TColStd_HSequenceOfTransient;
- std::list<Handle(GEOM_Object)>::iterator it = theObjects.begin();
- for (; it != theObjects.end(); it++)
- {
- Handle(GEOM_Function) aRefSh = (*it)->GetLastFunction();
- if (aRefSh.IsNull()) {
- SetErrorCode("NULL argument shape");
- return NULL;
- }
- objects->Append(aRefSh);
+ Handle(TColStd_HSequenceOfTransient) objects =
+ GEOM_Object::GetLastFunctions( theObjects );
+ if ( objects.IsNull() || objects->IsEmpty() ) {
+ SetErrorCode("NULL argument shape");
+ return NULL;
}
// Add a new object
pd << aNewObject << " = geompy.Sew(" << theObjects << ", " << theTolerance;
if (isAllowNonManifold) {
- pd << ", true";
+ pd << ", True";
}
pd << ")";
#include <OpUtil.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_Surface.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 <BRepTools.hxx>
+#include <BRep_Builder.hxx>
+#include <BRep_Tool.hxx>
+#include <Bnd_Box.hxx>
+#include <GEOMImpl_IMeasure.hxx>
+#include <GEOMImpl_MeasureDriver.hxx>
+#include <GProp_GProps.hxx>
+#include <Geom2d_Curve.hxx>
+#include <GeomAdaptor_Surface.hxx>
+#include <GeomLib_Tool.hxx>
+#include <Geom_CylindricalSurface.hxx>
+#include <Geom_Plane.hxx>
+#include <Geom_SphericalSurface.hxx>
+#include <Geom_Surface.hxx>
+#include <Precision.hxx>
+#include <TColStd_Array1OfReal.hxx>
+#include <TColStd_HArray1OfInteger.hxx>
+#include <TColStd_ListIteratorOfListOfInteger.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 <TopoDS.hxx>
-#include <TopoDS_Shape.hxx>
-#include <TopoDS_Solid.hxx>
-#include <TopoDS_Face.hxx>
-#include <TopoDS_Edge.hxx>
-#include <TopoDS_Vertex.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_SphericalSurface.hxx>
-#include <Geom_CylindricalSurface.hxx>
-#include <GeomAdaptor_Surface.hxx>
-
-#include <GeomLib_Tool.hxx>
-#include <Geom2d_Curve.hxx>
-
-#include <Bnd_Box.hxx>
-#include <GProp_GProps.hxx>
-#include <TColStd_Array1OfReal.hxx>
-#include <TColStd_HArray1OfInteger.hxx>
-#include <TColStd_ListIteratorOfListOfInteger.hxx>
-#include <TColStd_ListOfInteger.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_Lin.hxx>
#include <gp_Pnt.hxx>
#include <Standard_Failure.hxx>
#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>
//=============================================================================
/*!
* MakeGlueFaces
*/
//=============================================================================
-Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeGlueFaces
- (Handle(GEOM_Object) theShape,
- const Standard_Real theTolerance,
- const Standard_Boolean doKeepNonSolids)
+Handle(GEOM_Object)
+GEOMImpl_IShapesOperations::MakeGlueFaces (std::list< Handle(GEOM_Object) >& theShapes,
+ const Standard_Real theTolerance,
+ const Standard_Boolean doKeepNonSolids)
{
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
Handle(GEOM_Object) aGlued = GetEngine()->AddObject(GetDocID(), GEOM_GLUED);
GEOMImpl_IGlue aCI (aFunction);
- Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
- if (aRefShape.IsNull()) return NULL;
-
- aCI.SetBase(aRefShape);
+ aCI.SetBase( objects );
aCI.SetTolerance(theTolerance);
aCI.SetKeepNonSolids(doKeepNonSolids);
//Make a Python command
GEOM::TPythonDump(aFunction) << aGlued << " = geompy.MakeGlueFaces("
- << theShape << ", " << theTolerance << ")";
+ << theShapes << ", " << theTolerance << ")";
// to provide warning
if (!isWarning) SetErrorCode(OK);
* MakeGlueFacesByList
*/
//=============================================================================
-Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeGlueFacesByList
- (Handle(GEOM_Object) theShape,
- const Standard_Real theTolerance,
- std::list<Handle(GEOM_Object)> theFaces,
- const Standard_Boolean doKeepNonSolids,
- const Standard_Boolean doGlueAllEdges)
+Handle(GEOM_Object)
+GEOMImpl_IShapesOperations::MakeGlueFacesByList(std::list< Handle(GEOM_Object) >& theShapes,
+ const Standard_Real theTolerance,
+ std::list<Handle(GEOM_Object)> & theFaces,
+ const Standard_Boolean doKeepNonSolids,
+ const Standard_Boolean doGlueAllEdges)
{
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
Handle(GEOM_Object) aGlued = GetEngine()->AddObject(GetDocID(), GEOM_GLUED);
GEOMImpl_IGlue aCI (aFunction);
- Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
- if (aRefShape.IsNull()) return NULL;
-
- aCI.SetBase(aRefShape);
+ aCI.SetBase( objects );
aCI.SetTolerance(theTolerance);
aCI.SetKeepNonSolids(doKeepNonSolids);
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);
//Compute the sub-shape value
GEOM::TPythonDump pd(aFunction);
pd << aGlued << " = geompy.MakeGlueFacesByList("
- << theShape << ", " << theTolerance << ", [";
- // Faces
- it = theFaces.begin();
- if (it != theFaces.end()) {
- pd << (*it++);
- while (it != theFaces.end()) {
- pd << ", " << (*it++);
- }
- }
- pd << "], " << (bool)doKeepNonSolids << ", " << (bool)doGlueAllEdges << ")";
+ << theShapes << ", " << theTolerance << ", " << theFaces << ", "
+ << (bool)doKeepNonSolids << ", " << (bool)doGlueAllEdges << ")";
// to provide warning
if (!isWarning) SetErrorCode(OK);
* MakeGlueEdges
*/
//=============================================================================
-Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeGlueEdges
- (Handle(GEOM_Object) theShape,
- const Standard_Real theTolerance)
+Handle(GEOM_Object)
+GEOMImpl_IShapesOperations::MakeGlueEdges (std::list< Handle(GEOM_Object) >& theShapes,
+ const Standard_Real theTolerance)
{
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
Handle(GEOM_Object) aGlued = GetEngine()->AddObject(GetDocID(), GEOM_GLUED);
GEOMImpl_IGlue aCI (aFunction);
- Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
- if (aRefShape.IsNull()) return NULL;
-
- aCI.SetBase(aRefShape);
+ aCI.SetBase( objects );
aCI.SetTolerance(theTolerance);
aCI.SetKeepNonSolids(true);
//Make a Python command
GEOM::TPythonDump(aFunction) << aGlued << " = geompy.MakeGlueEdges("
- << theShape << ", " << theTolerance << ")";
+ << theShapes << ", " << theTolerance << ")";
// to provide warning
if (!isWarning) SetErrorCode(OK);
* GetGlueShapes
*/
//=============================================================================
-Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetGlueShapes
- (Handle(GEOM_Object) theShape,
- const Standard_Real theTolerance,
- const TopAbs_ShapeEnum theType)
+Handle(TColStd_HSequenceOfTransient)
+GEOMImpl_IShapesOperations::GetGlueShapes (std::list< Handle(GEOM_Object) >& theShapes,
+ const Standard_Real theTolerance,
+ const TopAbs_ShapeEnum theType)
{
SetErrorCode(KO);
- if (theShape.IsNull()) return NULL;
- TopoDS_Shape aShape = theShape->GetValue();
- if (aShape.IsNull()) return NULL;
+ TopoDS_Shape aShape;
+ 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;
+ 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;
Standard_Integer iErr = aGluer.ErrorStatus();
if (iErr) return NULL;
- TCollection_AsciiString anAsciiList, anEntry;
- TopTools_IndexedMapOfShape anIndices;
- TopExp::MapShapes(aShape, anIndices);
+ std::vector< TopTools_IndexedMapOfShape* > anIndices( shapes.Length(), NULL );
Handle(TColStd_HArray1OfInteger) anArray;
Handle(GEOM_Object) anObj;
GEOMUtils::SortShapes(listOnePerSet, Standard_False);
TopTools_ListIteratorOfListOfShape aListIt (listOnePerSet);
- for (; aListIt.More(); aListIt.Next()) {
+ for (; aListIt.More(); aListIt.Next())
+ {
TopoDS_Shape aValue = aListIt.Value();
- anArray = new TColStd_HArray1OfInteger(1,1);
- anArray->SetValue(1, anIndices.FindIndex(aValue));
- anObj = GetEngine()->AddSubShape(theShape, anArray);
- if (!anObj.IsNull()) {
- aSeq->Append(anObj);
-
- // for python command
- TDF_Tool::Entry(anObj->GetEntry(), anEntry);
- anAsciiList += anEntry;
- anAsciiList += ",";
+ // 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->SetValue(1, index);
+ anObj = GetEngine()->AddSubShape( object, anArray);
+ break;
+ }
}
+ if (!anObj.IsNull())
+ aSeq->Append(anObj);
}
+ for ( size_t i = 0 ; i < anIndices.size(); ++i )
+ delete anIndices[i];
// Make a Python command
- if (anAsciiList.Length() > 0) {
- anAsciiList.Trunc(anAsciiList.Length() - 1);
- Handle(GEOM_Function) aFunction = theShape->GetLastFunction();
+ if ( aSeq->Length() > 0)
+ {
+ Handle(GEOM_Function) aFunction = lastCreatedGO->GetLastFunction();
GEOM::TPythonDump pd (aFunction, /*append=*/true);
- pd << "[" << anAsciiList.ToCString();
- if (theType == TopAbs_FACE)
- pd << "] = geompy.GetGlueFaces(" << theShape << ", " << theTolerance << ")";
- else if (theType == TopAbs_EDGE)
- pd << "] = geompy.GetGlueEdges(" << theShape << ", " << theTolerance << ")";
+ pd << aSeq
+ << " = geompy." << (theType == TopAbs_FACE ? "GetGlueFaces" : "GetGlueEdges" )
+ << "( " << theShapes << ", " << theTolerance << ")";
}
SetErrorCode(OK);
* MakeGlueEdgesByList
*/
//=============================================================================
-Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeGlueEdgesByList
- (Handle(GEOM_Object) theShape,
- const Standard_Real theTolerance,
- std::list<Handle(GEOM_Object)> theEdges)
+Handle(GEOM_Object)
+GEOMImpl_IShapesOperations::MakeGlueEdgesByList (std::list< Handle(GEOM_Object) >& theShapes,
+ const Standard_Real theTolerance,
+ std::list<Handle(GEOM_Object)>& theEdges)
{
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
Handle(GEOM_Object) aGlued = GetEngine()->AddObject(GetDocID(), GEOM_GLUED);
GEOMImpl_IGlue aCI (aFunction);
- Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
- if (aRefShape.IsNull()) return NULL;
-
- aCI.SetBase(aRefShape);
+ aCI.SetBase( objects );
aCI.SetTolerance(theTolerance);
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);
//Compute the sub-shape value
GEOM::TPythonDump pd (aFunction);
pd << aGlued << " = geompy.MakeGlueEdgesByList("
- << theShape << ", " << theTolerance << ", [";
- // Edges
- it = theEdges.begin();
- if (it != theEdges.end()) {
- pd << (*it++);
- while (it != theEdges.end()) {
- pd << ", " << (*it++);
- }
- }
- pd << "])";
+ << theShapes << ", " << theTolerance << ", " << theEdges << " )";
// to provide warning
if (!isWarning) SetErrorCode(OK);
//=============================================================================
Handle(TColStd_HSequenceOfTransient)
GEOMImpl_IShapesOperations::GetExistingSubObjects(Handle(GEOM_Object) theShape,
- const Standard_Boolean theGroupsOnly)
+ const Standard_Boolean theGroupsOnly)
{
// note: this method does not return fields
Handle(GEOM_BaseObject) obj = Handle(GEOM_BaseObject)::DownCast( results->Value(i));
obj->GetEntryString();
if ( i < results->Length() )
- anAsciiList += ",";
+ anAsciiList += ",";
}
GEOM::TPythonDump pd (theShape->GetLastFunction(), /*append=*/true);
Handle(TColStd_HSequenceOfTransient)
GEOMImpl_IShapesOperations::GetExistingSubObjects(Handle(GEOM_Object) theShape,
- const Standard_Integer theTypes)
+ const Standard_Integer theTypes)
{
SetErrorCode(KO);
bool isSubShape = anObj->IsKind(STANDARD_TYPE(GEOM_Object)) && anObj->GetType() != GEOM_GROUP;
bool isField = anObj->IsKind(STANDARD_TYPE(GEOM_Field));
if (theTypes & Groups && isGroup ||
- theTypes & SubShapes && isSubShape ||
- theTypes & Fields && isField) {
+ theTypes & SubShapes && isSubShape ||
+ theTypes & Fields && isField) {
aSeq->Append(anObj);
}
}
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_Boolean doKeepNonSolids);
- //Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetGlueFaces (Handle(GEOM_Object) theShape,
- // const Standard_Real theTolerance);
-
- Standard_EXPORT Handle(GEOM_Object) MakeGlueFacesByList (Handle(GEOM_Object) theShape,
+ Standard_EXPORT Handle(GEOM_Object) MakeGlueFacesByList (std::list< Handle(GEOM_Object) >& theShapes,
const Standard_Real theTolerance,
- std::list<Handle(GEOM_Object)> theFaces,
+ std::list<Handle(GEOM_Object)>& theFaces,
const Standard_Boolean doKeepNonSolids,
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);
- 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 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,
- std::list<Handle(GEOM_Object)> theEdges);
+ std::list<Handle(GEOM_Object)> & theEdges);
Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetExistingSubObjects(Handle(GEOM_Object) theShape,
- const Standard_Boolean theGroupsOnly);
+ const Standard_Boolean theGroupsOnly);
Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetExistingSubObjects(Handle(GEOM_Object) theShape,
- const Standard_Integer theTypes = All);
+ const Standard_Integer theTypes = All);
enum ExplodeType {
EXPLODE_OLD_INCLUDE_MAIN,
return aGEOMObject._retn();
//Get the shapes
- std::list<Handle(GEOM_Object)> objects;
- const int aLen = theObjects.length();
- for ( int ind = 0; ind < aLen; ind++)
- {
- Handle(GEOM_Object) aSh = GetObjectImpl(theObjects[ind]);
- if (aSh.IsNull()) return aGEOMObject._retn();
- objects.push_back(aSh);
- }
+ std::list< Handle(GEOM_Object) > aShapes;
+ if (! GetListOfObjectsImpl( theObjects, aShapes ))
+ return aGEOMObject._retn();
// Perform
- Handle(GEOM_Object) aNewObject = GetOperations()->Sew( objects, theTolerance, false );
+ Handle(GEOM_Object) aNewObject = GetOperations()->Sew( aShapes, theTolerance, false );
if (!GetOperations()->IsDone() || aNewObject.IsNull())
return aGEOMObject._retn();
return aGEOMObject._retn();
//Get the shapes
- std::list<Handle(GEOM_Object)> objects;
- const int aLen = theObjects.length();
- for ( int ind = 0; ind < aLen; ind++)
- {
- Handle(GEOM_Object) aSh = GetObjectImpl(theObjects[ind]);
- if (aSh.IsNull()) return aGEOMObject._retn();
- objects.push_back(aSh);
- }
+ std::list< Handle(GEOM_Object) > aShapes;
+ if (! GetListOfObjectsImpl( theObjects, aShapes ))
+ return aGEOMObject._retn();
// Perform
- Handle(GEOM_Object) aNewObject = GetOperations()->Sew( objects, theTolerance, true );
+ Handle(GEOM_Object) aNewObject = GetOperations()->Sew( aShapes, theTolerance, true );
if (!GetOperations()->IsDone() || aNewObject.IsNull())
return aGEOMObject._retn();
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
Handle(TColStd_HSequenceOfTransient)
GetListOfObjectsImpl(const GEOM::ListOfGO& theObjects);
+ bool GetListOfObjectsImpl(const GEOM::ListOfGO& theObjects,
+ std::list< Handle(GEOM_Object) >& theList);
Handle(TColStd_HArray1OfExtendedString)
ConvertStringArray(const GEOM::string_array &theInArray);
* MakeCompound
*/
//=============================================================================
-GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeCompound
- (const GEOM::ListOfGO& theShapes)
+GEOM::GEOM_Object_ptr
+GEOM_IShapesOperations_i::MakeCompound (const GEOM::ListOfGO& theShapes)
{
GEOM::GEOM_Object_var aGEOMObject;
* MakeGlueFaces
*/
//=============================================================================
-GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueFaces
- (GEOM::GEOM_Object_ptr theShape,
- CORBA::Double theTolerance,
- CORBA::Boolean doKeepNonSolids)
+GEOM::GEOM_Object_ptr
+GEOM_IShapesOperations_i::MakeGlueFaces (const GEOM::ListOfGO& theShapes,
+ CORBA::Double theTolerance,
+ CORBA::Boolean doKeepNonSolids)
{
GEOM::GEOM_Object_var aGEOMObject;
GetOperations()->SetNotDone();
//Get the reference objects
- Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
- if (aShape.IsNull()) return aGEOMObject._retn();
+ std::list< Handle(GEOM_Object) > aShapes;
+ if (! GetListOfObjectsImpl( theShapes, aShapes ))
+ return aGEOMObject._retn();
//Perform the gluing
Handle(GEOM_Object) anObject =
- GetOperations()->MakeGlueFaces(aShape, theTolerance, doKeepNonSolids);
+ GetOperations()->MakeGlueFaces(aShapes, theTolerance, doKeepNonSolids);
//if (!GetOperations()->IsDone() || anObject.IsNull())
// to allow warning
if (anObject.IsNull())
* GetGlueFaces
*/
//=============================================================================
-GEOM::ListOfGO* GEOM_IShapesOperations_i::GetGlueFaces
- (GEOM::GEOM_Object_ptr theShape,
- const CORBA::Double theTolerance)
+GEOM::ListOfGO*
+GEOM_IShapesOperations_i::GetGlueFaces (const GEOM::ListOfGO& theShapes,
+ const CORBA::Double theTolerance)
{
GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
GetOperations()->SetNotDone();
//Get the reference objects
- Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
- if (aShape.IsNull()) return aSeq._retn();
+ std::list< Handle(GEOM_Object) > aShapes;
+ if (! GetListOfObjectsImpl( theShapes, aShapes ))
+ return aSeq._retn();
Handle(TColStd_HSequenceOfTransient) aHSeq =
- //GetOperations()->GetGlueFaces(aShape, theTolerance);
- GetOperations()->GetGlueShapes(aShape, theTolerance, TopAbs_FACE);
+ GetOperations()->GetGlueShapes(aShapes, theTolerance, TopAbs_FACE);
//if (!GetOperations()->IsDone() || aHSeq.IsNull())
// to allow warning
* MakeGlueFacesByList
*/
//=============================================================================
-GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueFacesByList
- (GEOM::GEOM_Object_ptr theShape,
- CORBA::Double theTolerance,
- const GEOM::ListOfGO& theFaces,
- CORBA::Boolean doKeepNonSolids,
- CORBA::Boolean doGlueAllEdges)
+GEOM::GEOM_Object_ptr
+GEOM_IShapesOperations_i::MakeGlueFacesByList (const GEOM::ListOfGO& theShapes,
+ CORBA::Double theTolerance,
+ const GEOM::ListOfGO& theFaces,
+ CORBA::Boolean doKeepNonSolids,
+ CORBA::Boolean doGlueAllEdges)
{
GEOM::GEOM_Object_var aGEOMObject;
GetOperations()->SetNotDone();
//Get the reference objects
- Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
- if (aShape.IsNull()) return aGEOMObject._retn();
+ std::list< Handle(GEOM_Object) > aShapes;
+ if (! GetListOfObjectsImpl( theShapes, aShapes ))
+ return aGEOMObject._retn();
- int ind, aLen;
- std::list<Handle(GEOM_Object)> aFaces;
//Get the shapes
- aLen = theFaces.length();
- for (ind = 0; ind < aLen; ind++) {
- Handle(GEOM_Object) aSh = GetObjectImpl(theFaces[ind]);
- if (aSh.IsNull()) return aGEOMObject._retn();
- aFaces.push_back(aSh);
- }
+ std::list<Handle(GEOM_Object)> aFaces;
+ if (! GetListOfObjectsImpl( theFaces, aFaces ))
+ return aGEOMObject._retn();
//Perform the gluing
Handle(GEOM_Object) anObject =
- GetOperations()->MakeGlueFacesByList(aShape, theTolerance, aFaces, doKeepNonSolids, doGlueAllEdges);
+ GetOperations()->MakeGlueFacesByList(aShapes, theTolerance, aFaces,
+ doKeepNonSolids, doGlueAllEdges);
//if (!GetOperations()->IsDone() || anObject.IsNull())
// to allow warning
if (anObject.IsNull())
* MakeGlueEdges
*/
//=============================================================================
-GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueEdges
- (GEOM::GEOM_Object_ptr theShape,
- CORBA::Double theTolerance)
+GEOM::GEOM_Object_ptr
+GEOM_IShapesOperations_i::MakeGlueEdges (const GEOM::ListOfGO& theShapes,
+ CORBA::Double theTolerance)
{
GEOM::GEOM_Object_var aGEOMObject;
GetOperations()->SetNotDone();
//Get the reference objects
- Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
- if (aShape.IsNull()) return aGEOMObject._retn();
+ std::list< Handle(GEOM_Object) > aShapes;
+ if (! GetListOfObjectsImpl( theShapes, aShapes ))
+ return aGEOMObject._retn();
//Perform the gluing
Handle(GEOM_Object) anObject =
- GetOperations()->MakeGlueEdges(aShape, theTolerance);
+ GetOperations()->MakeGlueEdges(aShapes, theTolerance);
//if (!GetOperations()->IsDone() || anObject.IsNull())
// to allow warning
if (anObject.IsNull())
* GetGlueEdges
*/
//=============================================================================
-GEOM::ListOfGO* GEOM_IShapesOperations_i::GetGlueEdges
- (GEOM::GEOM_Object_ptr theShape,
- const CORBA::Double theTolerance)
+GEOM::ListOfGO*
+GEOM_IShapesOperations_i::GetGlueEdges (const GEOM::ListOfGO& theShapes,
+ const CORBA::Double theTolerance)
{
GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
GetOperations()->SetNotDone();
//Get the reference objects
- Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
- if (aShape.IsNull()) return aSeq._retn();
+ std::list< Handle(GEOM_Object) > aShapes;
+ if (! GetListOfObjectsImpl( theShapes, aShapes ))
+ return aSeq._retn();
Handle(TColStd_HSequenceOfTransient) aHSeq =
- GetOperations()->GetGlueShapes(aShape, theTolerance, TopAbs_EDGE);
+ GetOperations()->GetGlueShapes(aShapes, theTolerance, TopAbs_EDGE);
//if (!GetOperations()->IsDone() || aHSeq.IsNull())
// to allow warning
* MakeGlueEdgesByList
*/
//=============================================================================
-GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueEdgesByList
- (GEOM::GEOM_Object_ptr theShape,
- CORBA::Double theTolerance,
- const GEOM::ListOfGO& theEdges)
+GEOM::GEOM_Object_ptr
+GEOM_IShapesOperations_i::MakeGlueEdgesByList (const GEOM::ListOfGO& theShapes,
+ CORBA::Double theTolerance,
+ const GEOM::ListOfGO& theEdges)
{
GEOM::GEOM_Object_var aGEOMObject;
GetOperations()->SetNotDone();
//Get the reference objects
- Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
- if (aShape.IsNull()) return aGEOMObject._retn();
+ std::list< Handle(GEOM_Object) > aShapes;
+ if (! GetListOfObjectsImpl( theShapes, aShapes ))
+ return aGEOMObject._retn();
- int ind, aLen;
- std::list<Handle(GEOM_Object)> anEdges;
//Get the shapes
- aLen = theEdges.length();
- for (ind = 0; ind < aLen; ind++) {
- Handle(GEOM_Object) aSh = GetObjectImpl(theEdges[ind]);
- if (aSh.IsNull()) return aGEOMObject._retn();
- anEdges.push_back(aSh);
- }
+ std::list<Handle(GEOM_Object)> anEdges;
+ if (! GetListOfObjectsImpl( theEdges, anEdges ))
+ return aGEOMObject._retn();
//Perform the gluing
Handle(GEOM_Object) anObject =
- GetOperations()->MakeGlueEdgesByList(aShape, theTolerance, anEdges);
+ GetOperations()->MakeGlueEdgesByList(aShapes, theTolerance, anEdges);
//if (!GetOperations()->IsDone() || anObject.IsNull())
// to allow warning
if (anObject.IsNull())
* GetExistingSubObjects
*/
//=============================================================================
-GEOM::ListOfGO* GEOM_IShapesOperations_i::GetExistingSubObjects (GEOM::GEOM_Object_ptr theShape,
- CORBA::Boolean theGroupsOnly)
+GEOM::ListOfGO*
+GEOM_IShapesOperations_i::GetExistingSubObjects (GEOM::GEOM_Object_ptr theShape,
+ CORBA::Boolean theGroupsOnly)
{
GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
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::Boolean doKeepNonSolids);
- GEOM::ListOfGO* GetGlueFaces (GEOM::GEOM_Object_ptr theShape,
+ GEOM::ListOfGO* GetGlueFaces (const GEOM::ListOfGO& theShape,
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,
const GEOM::ListOfGO& theFaces,
CORBA::Boolean doKeepNonSolids,
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);
- GEOM::ListOfGO* GetGlueEdges (GEOM::GEOM_Object_ptr theShape,
+ GEOM::ListOfGO* GetGlueEdges (const GEOM::ListOfGO& theShape,
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,
const GEOM::ListOfGO& theEdges);
Joined_1 = geompy.RemoveInternalFaces(Partition_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):
+ TestSewGluing(geompy)
TestMakeSewing(geompy, math)
TestDivideEdge(geompy)
TestSuppressHoles(geompy)
self._autoPublish(anObj[2], theName, "openWire")
return anObj
- ## Replace coincident faces in theShape by one face.
- # @param theShape Initial shape.
+ ## Replace coincident faces in \a theShapes by one face.
+ # @param theShapes Initial shapes, either a list or compound of shapes.
# @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.
# for result publication in the study. Otherwise, if automatic
# 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"
@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:
- theShape Initial shape.
+ theShapes Initial shapes, either a list or compound of shapes.
theTolerance Maximum distance between faces, which can be considered as coincident.
doKeepNonSolids If FALSE, only solids will present in the result,
otherwise all initial shapes.
publication is switched on, default value is used for result name.
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
theTolerance,Parameters = ParseParameters(theTolerance)
- anObj = self.ShapesOp.MakeGlueFaces(theShape, theTolerance, doKeepNonSolids)
+ anObj = self.ShapesOp.MakeGlueFaces(ToList(theShapes), theTolerance, doKeepNonSolids)
if anObj is None:
raise RuntimeError, "MakeGlueFaces : " + self.ShapesOp.GetErrorCode()
anObj.SetParameters(Parameters)
self._autoPublish(anObj, theName, "glueFaces")
return anObj
- ## Find coincident faces in theShape for possible gluing.
- # @param theShape Initial shape.
+ ## Find coincident faces in \a theShapes for possible gluing.
+ # @param theShapes Initial shapes, either a list or compound of shapes.
# @param theTolerance Maximum distance between faces,
# which can be considered as coincident.
# @param theName Object name; when specified, this parameter is used
#
# @ref tui_glue_faces "Example"
@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:
- theShape Initial shape.
+ theShapes Initial shapes, either a list or compound of shapes.
theTolerance Maximum distance between faces,
which can be considered as coincident.
theName Object name; when specified, this parameter is used
Returns:
GEOM.ListOfGO
"""
- anObj = self.ShapesOp.GetGlueFaces(theShape, theTolerance)
+ anObj = self.ShapesOp.GetGlueFaces(ToList(theShapes), theTolerance)
RaiseIfFailed("GetGlueFaces", self.ShapesOp)
self._autoPublish(anObj, theName, "facesToGlue")
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
- # @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 theFaces List of faces for gluing.
# for result publication in the study. Otherwise, if automatic
# publication is switched on, default value is used for result name.
#
- # @return New GEOM.GEOM_Object, containing a copy of theShape
- # without some faces.
+ # @return New GEOM.GEOM_Object, containing copies of theShapes without coincident faces.
#
# @ref tui_glue_faces "Example"
@ManageTransactions("ShapesOp")
- def MakeGlueFacesByList(self, theShape, theTolerance, theFaces,
+ def MakeGlueFacesByList(self, theShapes, theTolerance, theFaces,
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
Parameters:
- theShape Initial shape.
+ theShapes theShapes Initial shapes, either a list or compound of shapes.
theTolerance Maximum distance between faces,
which can be considered as coincident.
theFaces List of faces for gluing.
publication is switched on, default value is used for result name.
Returns:
- New GEOM.GEOM_Object, containing a copy of theShape
- without some faces.
+ New GEOM.GEOM_Object, containing copies of theShapes without coincident faces.
"""
- anObj = self.ShapesOp.MakeGlueFacesByList(theShape, theTolerance, theFaces,
+ anObj = self.ShapesOp.MakeGlueFacesByList(ToList(theShapes), theTolerance, theFaces,
doKeepNonSolids, doGlueAllEdges)
if anObj is None:
raise RuntimeError, "MakeGlueFacesByList : " + self.ShapesOp.GetErrorCode()
self._autoPublish(anObj, theName, "glueFaces")
return anObj
- ## Replace coincident edges in theShape by one edge.
- # @param theShape Initial shape.
+ ## Replace coincident edges in \a theShapes by one edge.
+ # @param theShapes Initial shapes, either a list or compound of shapes.
# @param theTolerance Maximum distance between edges, which can be considered as coincident.
# @param theName Object name; when specified, this parameter is used
# for result publication in the study. Otherwise, if automatic
# 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"
@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:
- theShape Initial shape.
+ theShapes Initial shapes, either a list or compound of shapes.
theTolerance Maximum distance between edges, which can be considered as coincident.
theName Object name; when specified, this parameter is used
for result publication in the study. Otherwise, if automatic
publication is switched on, default value is used for result name.
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)
- anObj = self.ShapesOp.MakeGlueEdges(theShape, theTolerance)
+ anObj = self.ShapesOp.MakeGlueEdges(ToList(theShapes), theTolerance)
if anObj is None:
raise RuntimeError, "MakeGlueEdges : " + self.ShapesOp.GetErrorCode()
anObj.SetParameters(Parameters)
self._autoPublish(anObj, theName, "glueEdges")
return anObj
- ## Find coincident edges in theShape for possible gluing.
- # @param theShape Initial shape.
+ ## Find coincident edges in \a theShapes for possible gluing.
+ # @param theShapes Initial shapes, either a list or compound of shapes.
# @param theTolerance Maximum distance between edges,
# which can be considered as coincident.
# @param theName Object name; when specified, this parameter is used
#
# @ref tui_glue_edges "Example"
@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:
- theShape Initial shape.
+ theShapes Initial shapes, either a list or compound of shapes.
theTolerance Maximum distance between edges,
which can be considered as coincident.
theName Object name; when specified, this parameter is used
Returns:
GEOM.ListOfGO
"""
- anObj = self.ShapesOp.GetGlueEdges(theShape, theTolerance)
+ anObj = self.ShapesOp.GetGlueEdges(ToList(theShapes), theTolerance)
RaiseIfFailed("GetGlueEdges", self.ShapesOp)
self._autoPublish(anObj, theName, "edgesToGlue")
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.
- # @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 theEdges List of edges for gluing.
# for result publication in the study. Otherwise, if automatic
# publication is switched on, default value is used for result name.
#
- # @return New GEOM.GEOM_Object, containing a copy of theShape
- # without some edges.
+ # @return New GEOM.GEOM_Object, containing copies of theShapes without coincident edges.
#
# @ref tui_glue_edges "Example"
@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.
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.
theEdges List of edges for gluing.
publication is switched on, default value is used for result name.
Returns:
- New GEOM.GEOM_Object, containing a copy of theShape
- without some edges.
+ New GEOM.GEOM_Object, containing copies of theShapes without coincident edges.
"""
- anObj = self.ShapesOp.MakeGlueEdgesByList(theShape, theTolerance, theEdges)
+ anObj = self.ShapesOp.MakeGlueEdgesByList(ToList(theShapes), theTolerance, theEdges)
if anObj is None:
raise RuntimeError, "MakeGlueEdgesByList : " + self.ShapesOp.GetErrorCode()
self._autoPublish(anObj, theName, "glueEdges")
GroupPoints = new DlgRef_1SelExt(centralWidget());
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->LineEdit1->setReadOnly(true);
GroupPoints2 = new DlgRef_1SelExt(centralWidget());
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->LineEdit1->setReadOnly(true);
/* init variables */
myEditCurrentArgument = GroupPoints->LineEdit1;
- myObject = GEOM::GEOM_Object::_nil();
+ myObjects.clear();
//myGeomGUI->SetState(0);
//globalSelection(GEOM_COMPOUND);
erasePreview();
myEditCurrentArgument->setText("");
- myObject = GEOM::GEOM_Object::_nil();
+ myObjects.clear();
- LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
- SALOME_ListIO aSelList;
- aSelMgr->selectedObjects(aSelList);
+ myObjects = getSelected( TopAbs_SHAPE, -1 );
- if (aSelList.Extent() == 1) {
- Handle(SALOME_InteractiveObject) anIO = aSelList.First();
- myObject = GEOMBase::ConvertIOinGEOMObject(anIO);
- if (!CORBA::is_nil(myObject))
- myEditCurrentArgument->setText(GEOMBase::GetName(myObject));
+ if ( !myObjects.isEmpty() ) {
+ QString aName = myObjects.count() > 1 ? QString( "%1_objects").arg( myObjects.count() ) : GEOMBase::GetName( myObjects[0].get() );
+ myEditCurrentArgument->setText( aName );
}
updateButtonState();
}
ok = myTolEdt2->isValid(msg, !IsPreview());
break;
}
- return !myObject->_is_nil() && (IsPreview() || v > 0.) && ok;
+ return !myObjects.isEmpty() && (IsPreview() || v > 0.) && ok;
}
//=================================================================================
bool aResult = false;
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());
switch (getConstructorId()) {
case 0:
{
GEOM::GEOM_Object_var anObj;
if (myGlueMode == TopAbs_FACE)
- anObj = anOper->MakeGlueFaces(myObject, myTolEdt->value(), true);
+ anObj = anOper->MakeGlueFaces( objList, myTolEdt->value(), true);
else if (myGlueMode == TopAbs_EDGE)
- anObj = anOper->MakeGlueEdges(myObject, myTolEdt->value());
+ anObj = anOper->MakeGlueEdges( objList, myTolEdt->value());
aResult = !anObj->_is_nil();
if (aResult && !IsPreview())
GEOM::GEOM_Object_var anObj;
if (myGlueMode == TopAbs_FACE) {
bool doGlueAllEdges = myGlueAllEdgesChk->isChecked();
- anObj = anOper->MakeGlueFacesByList(myObject, myTolEdt2->value(), aListForGlue.in(),
+ anObj = anOper->MakeGlueFacesByList( objList, myTolEdt2->value(), aListForGlue.in(),
true, doGlueAllEdges);
}
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();
buttonApply()->setEnabled(false);
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::ListOfGO_var aList;
if (myGlueMode == TopAbs_FACE)
- aList = anOper->GetGlueFaces(myObject.in(), myTolEdt2->value());
+ aList = anOper->GetGlueFaces( objList, myTolEdt2->value());
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++)
myTmpObjs << GEOM::GeomObjPtr(aList[i].in());
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
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();
activateSelection();
}
this, SLOT(SelectionIntoArgument()));
globalSelection(GEOM_ALLSHAPES);
- if (myObject->_is_nil())
+ if ( myObjects.isEmpty() )
SelectionIntoArgument();
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
void RepairGUI_GlueDlg::updateButtonState()
{
int anId = getConstructorId();
- bool hasMainObj = !myObject->_is_nil();
+ bool hasMainObj = !myObjects.isEmpty();
if (anId == 0) {
buttonOk()->setEnabled(hasMainObj);
buttonApply()->setEnabled(hasMainObj);
void selectTmpInViewer();
private:
- GEOM::GEOM_Object_var myObject;
+ QList<GEOM::GeomObjPtr> myObjects;
QList<GEOM::GeomObjPtr> myTmpObjs;
DlgRef_1SelExt* GroupPoints;
GroupPoints = new DlgRef_1SelExt( centralWidget() );
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->LineEdit1->setReadOnly( true );