From: eap Date: Tue, 14 Oct 2014 16:45:17 +0000 (+0400) Subject: 0022746: [EDF] Improvement of Glue Faces and Glue Edges operations X-Git-Tag: V7_6_0a1~60^2~38 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2c3b809cb74cbb115d7d399f22e8d07f0d67e85c;p=modules%2Fgeom.git 0022746: [EDF] Improvement of Glue Faces and Glue Edges operations --- diff --git a/doc/salome/gui/GEOM/images/glue1.png b/doc/salome/gui/GEOM/images/glue1.png index 48a40d6e1..33f8fad0e 100644 Binary files a/doc/salome/gui/GEOM/images/glue1.png and b/doc/salome/gui/GEOM/images/glue1.png differ diff --git a/doc/salome/gui/GEOM/images/glue2.png b/doc/salome/gui/GEOM/images/glue2.png index 2df8a68b4..001224ebf 100644 Binary files a/doc/salome/gui/GEOM/images/glue2.png and b/doc/salome/gui/GEOM/images/glue2.png differ diff --git a/doc/salome/gui/GEOM/images/glue3.png b/doc/salome/gui/GEOM/images/glue3.png index de80520b9..598fff5aa 100644 Binary files a/doc/salome/gui/GEOM/images/glue3.png and b/doc/salome/gui/GEOM/images/glue3.png differ diff --git a/doc/salome/gui/GEOM/images/glue4.png b/doc/salome/gui/GEOM/images/glue4.png index 32e07ec22..7fbbb0eb0 100644 Binary files a/doc/salome/gui/GEOM/images/glue4.png and b/doc/salome/gui/GEOM/images/glue4.png differ diff --git a/doc/salome/gui/GEOM/images/glue5.png b/doc/salome/gui/GEOM/images/glue5.png index 3a9a266e2..c24a0f42c 100644 Binary files a/doc/salome/gui/GEOM/images/glue5.png and b/doc/salome/gui/GEOM/images/glue5.png differ diff --git a/doc/salome/gui/GEOM/images/glue7.png b/doc/salome/gui/GEOM/images/glue7.png index a365ca2c4..c3a58eaef 100644 Binary files a/doc/salome/gui/GEOM/images/glue7.png and b/doc/salome/gui/GEOM/images/glue7.png differ diff --git a/doc/salome/gui/GEOM/images/glue8.png b/doc/salome/gui/GEOM/images/glue8.png index 20e3aec7d..e248988c4 100644 Binary files a/doc/salome/gui/GEOM/images/glue8.png and b/doc/salome/gui/GEOM/images/glue8.png differ diff --git a/doc/salome/gui/GEOM/images/repair6.png b/doc/salome/gui/GEOM/images/repair6.png index 666ea8708..a2a0b50c2 100644 Binary files a/doc/salome/gui/GEOM/images/repair6.png and b/doc/salome/gui/GEOM/images/repair6.png differ diff --git a/doc/salome/gui/GEOM/input/glue_edges_operation.doc b/doc/salome/gui/GEOM/input/glue_edges_operation.doc index e7e6a3330..eb7d2377c 100644 --- a/doc/salome/gui/GEOM/input/glue_edges_operation.doc +++ b/doc/salome/gui/GEOM/input/glue_edges_operation.doc @@ -7,7 +7,7 @@ \n This operation glues edges that are coincident with respect to the given tolerance value. -\n Arguments: Name + Compound of shapes + Tolerance value. +\n Arguments: Name + Shapes + Tolerance value. \n Advanced option: \ref restore_presentation_parameters_page "Set presentation parameters and sub-shapes from arguments". \n The \b Result will be a \b GEOM_Object. @@ -16,10 +16,10 @@ given tolerance value. \image html glue4.png \n TUI Command: -\n geompy.MakeGlueEdges(theShape,theTolerance), -\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. +

geompy.MakeGlueEdges( theShapes, theTolerance ), +\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. @@ -36,23 +36,24 @@ possible to select the edges for gluing in the 3D viewer. The selected edges will be marked in white. \n TUI Command: -\n geompy.GetGlueEdges(theShape,theTolerance), -\n where \em theShape is a compound of shapes to be glued, \em +

geompy.GetGlueEdges( theShapes, theTolerance ), +\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 geompy.MakeGlueEdgesByList(theShape,theTolerance,theEdges), -\n where \em theShape is a compound of shapes to be glued, \em +geompy.MakeGlueEdgesByList( theShapes, theTolerance, theEdges ), +\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 Example: \image html glue8.png -

Box with an edge that can be glued
+
Two boxes with an edge that can be glued
Our TUI Scripts provide you with useful examples of the use of Repairing Operations \ref tui_glue_edges "Glue Edges". diff --git a/doc/salome/gui/GEOM/input/glue_faces_operation.doc b/doc/salome/gui/GEOM/input/glue_faces_operation.doc index 3775aa479..8f020115b 100644 --- a/doc/salome/gui/GEOM/input/glue_faces_operation.doc +++ b/doc/salome/gui/GEOM/input/glue_faces_operation.doc @@ -8,7 +8,7 @@ \n This operation glues faces that are coincident with respect to the given tolerance value. -\n Arguments: Name + Compound of shapes + Tolerance value. +\n Arguments: Name + Shapes + Tolerance value. \n Advanced option: \ref restore_presentation_parameters_page "Set presentation parameters and sub-shapes from arguments". \n The \b Result will be a \b GEOM_Object. @@ -17,8 +17,9 @@ given tolerance value. \n TUI Commands: -\n geompy.MakeGlueFaces(theShape,theTolerance,doKeepNonSolids), -\n where \em theShape is a compound of shapes to be glued, \em + +geompy.MakeGlueFaces( theShapes, theTolerance, doKeepNonSolids ), +\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 @@ -38,20 +39,23 @@ performed and displays a notification. 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 Glue all coincident edges checkbox. \n TUI Commands: -\n geompy.GetGlueFaces(theShape,theTolerance), -\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 geompy.MakeGlueFacesByList(theShape,theTolerance,theFaces,doKeepNonSolids,doGlueAllEdges), -\n where \em theShape is a compound of shapes to be glued, \em +geompy.GetGlueFaces( theShapes, theTolerance ), +\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. + +geompy.MakeGlueFacesByList( theShapes, theTolerance, theFaces, + doKeepNonSolids, doGlueAllEdges ), +\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 diff --git a/doc/salome/gui/GEOM/input/remove_webs_operation.doc b/doc/salome/gui/GEOM/input/remove_webs_operation.doc index 26ab2efb1..a2dc78026 100644 --- a/doc/salome/gui/GEOM/input/remove_webs_operation.doc +++ b/doc/salome/gui/GEOM/input/remove_webs_operation.doc @@ -5,7 +5,7 @@ \n To Remove internal faces in the Main Menu select Repair - > Remove internal faces. -\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 @@ -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". \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 +Remove Internal Faces if you need to remove them. -\n TUI Command: geompy.RemoveInternalFaces(theCompound), +\n TUI Command:
+geompy.RemoveInternalFaces( theCompound ),
where theCompound is a compound of solids. \n Our TUI Scripts provide you with useful examples of the diff --git a/doc/salome/gui/GEOM/input/repairing_operations.doc b/doc/salome/gui/GEOM/input/repairing_operations.doc index d0559d764..28bf44819 100644 --- a/doc/salome/gui/GEOM/input/repairing_operations.doc +++ b/doc/salome/gui/GEOM/input/repairing_operations.doc @@ -16,9 +16,9 @@ open contour asnd miodifies the underlying face. holes with free boundaries on a selected face.
  • \subpage sewing_operation_page "Sewing" - sews faces or shells.
  • \subpage glue_faces_operation_page "Glue faces" - unites -coincident faces within the given tolerance.
  • +faces coincident within the given tolerance.
  • \subpage glue_edges_operation_page "Glue edges" - unites -coincident edges within the given tolerance.
  • +edges coincident within the given tolerance.
  • \subpage limit_tolerance_operation_page "Limit Tolerance" - tries to set new tolerance value for the given shape.
  • \subpage add_point_on_edge_operation_page "Add point on edge" - diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index 0f168018a..b9cfadd17 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -1941,64 +1941,64 @@ module GEOM 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 theShape * will be glued, otherwise only the edges, * belonging to theFaces. - * \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); /*! diff --git a/src/AdvancedEngine/AdvancedEngine_IOperations.cxx b/src/AdvancedEngine/AdvancedEngine_IOperations.cxx index e713e003a..234407a9e 100644 --- a/src/AdvancedEngine/AdvancedEngine_IOperations.cxx +++ b/src/AdvancedEngine/AdvancedEngine_IOperations.cxx @@ -154,9 +154,9 @@ AdvancedEngine_IOperations::~AdvancedEngine_IOperations() */ //============================================================================= 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); @@ -195,10 +195,10 @@ gp_Trsf AdvancedEngine_IOperations::GetPositionTrsf(double theL1, double theL2, */ //============================================================================= 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())); @@ -266,11 +266,11 @@ bool AdvancedEngine_IOperations::CheckCompatiblePosition(double& theL1, double& */ //============================================================================= 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); @@ -1132,10 +1132,10 @@ bool AdvancedEngine_IOperations::MakeInternalGroup } 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); @@ -1203,12 +1203,12 @@ bool AdvancedEngine_IOperations::MakePipeTShapePartition(Handle(GEOM_Object) the 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()); } } } @@ -1249,14 +1249,14 @@ bool AdvancedEngine_IOperations::MakePipeTShapePartition(Handle(GEOM_Object) the 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()); } } } @@ -1281,12 +1281,12 @@ bool AdvancedEngine_IOperations::MakePipeTShapePartition(Handle(GEOM_Object) the 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); @@ -1614,8 +1614,8 @@ bool AdvancedEngine_IOperations::MakePipeTShapePartition(Handle(GEOM_Object) the // 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); @@ -1669,7 +1669,8 @@ bool AdvancedEngine_IOperations::MakePipeTShapeMirrorAndGlue(Handle(GEOM_Object) TColStd_IndexedDataMapOfTransientTransient aMapTShapes; TNaming_CopyShape::CopyTool(Te7->GetValue(), aMapTShapes, aShapeCopy); - Handle(GEOM_Object) Te8 = myShapesOperations->MakeGlueFaces(Te7, 1e-7, true); + std::list 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; @@ -1694,7 +1695,7 @@ bool AdvancedEngine_IOperations::MakePipeTShapeMirrorAndGlue(Handle(GEOM_Object) // 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"); @@ -1845,10 +1846,10 @@ TopoDS_Shape AdvancedEngine_IOperations::MakePipeTShapeThicknessReduction //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) { @@ -1953,11 +1954,11 @@ TopoDS_Shape AdvancedEngine_IOperations::MakeThicknessReduction (gp_Ax2 theAxes, //============================================================================= 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); @@ -3215,7 +3216,7 @@ AdvancedEngine_IOperations::MakePipeTShapeFilletWithPosition */ //============================================================================= Handle(GEOM_Object) AdvancedEngine_IOperations::MakeDividedDisk (double theR, double theRatio, - int theOrientation, int thePattern) + int theOrientation, int thePattern) { SetErrorCode(KO); @@ -3287,10 +3288,10 @@ Handle(GEOM_Object) AdvancedEngine_IOperations::MakeDividedDisk (double theR, do */ //============================================================================= 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); @@ -3362,8 +3363,8 @@ Handle(GEOM_Object) AdvancedEngine_IOperations::MakeDividedDiskPntVecR (Handle(G */ //============================================================================= Handle(GEOM_Object) AdvancedEngine_IOperations::MakeDividedCylinder (double theR, - double theH, - int thePattern) + double theH, + int thePattern) { SetErrorCode(KO); @@ -3409,9 +3410,9 @@ Handle(GEOM_Object) AdvancedEngine_IOperations::MakeDividedCylinder (double theR */ //============================================================================= Handle(GEOM_Object) AdvancedEngine_IOperations::MakeSmoothingSurface (std::list thelPoints, - int theNbMax, - int theDegMax, - double theDMax) + int theNbMax, + int theDegMax, + double theDMax) { SetErrorCode(KO); diff --git a/src/GEOM/GEOM_Object.cxx b/src/GEOM/GEOM_Object.cxx index fc8a1f326..289945409 100644 --- a/src/GEOM/GEOM_Object.cxx +++ b/src/GEOM/GEOM_Object.cxx @@ -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); 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); return Handle(GEOM_Object)::DownCast( base ); @@ -275,5 +275,27 @@ bool GEOM_Object::IsMainShape() 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::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 ); + diff --git a/src/GEOM/GEOM_Object.hxx b/src/GEOM/GEOM_Object.hxx index 214ca30b9..9f1c907d3 100644 --- a/src/GEOM/GEOM_Object.hxx +++ b/src/GEOM/GEOM_Object.hxx @@ -27,9 +27,12 @@ #include #include +#include #include #include +#include + class GEOM_Object; class Handle(TFunction_Driver); class GEOM_Engine; @@ -58,10 +61,10 @@ class GEOM_Object : public GEOM_BaseObject 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 @@ -107,6 +110,10 @@ class GEOM_Object : public GEOM_BaseObject //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 ); }; diff --git a/src/GEOM/GEOM_PythonDump.cxx b/src/GEOM/GEOM_PythonDump.cxx index 2a2e498d8..07aaa0e33 100644 --- a/src/GEOM/GEOM_PythonDump.cxx +++ b/src/GEOM/GEOM_PythonDump.cxx @@ -201,6 +201,11 @@ namespace GEOM 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; diff --git a/src/GEOMGUI/GEOM_msg_en.ts b/src/GEOMGUI/GEOM_msg_en.ts index cc359f60e..60757aabf 100644 --- a/src/GEOMGUI/GEOM_msg_en.ts +++ b/src/GEOMGUI/GEOM_msg_en.ts @@ -872,6 +872,14 @@ Please, select face, shell or solid and try again GEOM_GLUE_EDGES_TITLE Glue edges + + GEOM_GLUE_EDGES_DETECT_TITLE + Coincident edges detection + + + GEOM_GLUE_FACES_DETECT_TITLE + Coincident faces detection + GLUE_ERROR_STICKED_SHAPES The tolerance value is too big. Sticked shapes are detected. @@ -1660,6 +1668,10 @@ Please, select face, shell or solid and try again GEOM_SELECTED_SHAPE Selected shape + + GEOM_SELECTED_SHAPES + Selected shapes + GEOM_SELECTION Selection diff --git a/src/GEOMImpl/GEOMImpl_GlueDriver.cxx b/src/GEOMImpl/GEOMImpl_GlueDriver.cxx index 1f03275c5..4b3dfba96 100644 --- a/src/GEOMImpl/GEOMImpl_GlueDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_GlueDriver.cxx @@ -38,16 +38,15 @@ #include "utilities.h" +#include +#include #include - #include -#include #include #include -#include #include - -#include +#include +#include #include #include @@ -729,8 +728,36 @@ Standard_Integer GEOMImpl_GlueDriver::Execute(TFunction_Logbook& log) const 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"); } @@ -803,18 +830,18 @@ GetCreationInformation(std::string& theOperationName, 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() ); @@ -822,7 +849,7 @@ GetCreationInformation(std::string& theOperationName, 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; diff --git a/src/GEOMImpl/GEOMImpl_IGlue.hxx b/src/GEOMImpl/GEOMImpl_IGlue.hxx index b07654541..9e24e0fc1 100644 --- a/src/GEOMImpl/GEOMImpl_IGlue.hxx +++ b/src/GEOMImpl/GEOMImpl_IGlue.hxx @@ -26,9 +26,9 @@ #include -#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 @@ -38,10 +38,11 @@ class GEOMImpl_IGlue 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); } diff --git a/src/GEOMImpl/GEOMImpl_IHealingOperations.cxx b/src/GEOMImpl/GEOMImpl_IHealingOperations.cxx index fb04fd1cb..9c5d71fff 100644 --- a/src/GEOMImpl/GEOMImpl_IHealingOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IHealingOperations.cxx @@ -592,16 +592,11 @@ GEOMImpl_IHealingOperations::Sew (std::list& theObjects, if (theObjects.empty()) return NULL; - Handle(TColStd_HSequenceOfTransient) objects = new TColStd_HSequenceOfTransient; - std::list::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 @@ -643,7 +638,7 @@ GEOMImpl_IHealingOperations::Sew (std::list& theObjects, pd << aNewObject << " = geompy.Sew(" << theObjects << ", " << theTolerance; if (isAllowNonManifold) { - pd << ", true"; + pd << ", True"; } pd << ")"; diff --git a/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx index 75a2b46d4..a2738417f 100644 --- a/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx @@ -67,60 +67,61 @@ #include #include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include #include #include #include +#include +#include +#include +#include +#include +#include #include - +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include #include #include #include #include -#include #include - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -133,15 +134,6 @@ #include #include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC -// Includes added for GetInPlace algorithm improvement - -#include -#include -#include - -#include -#include -#include //============================================================================= /*! @@ -666,14 +658,18 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeShape * 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); @@ -688,10 +684,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeGlueFaces 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); @@ -717,7 +710,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeGlueFaces //Make a Python command GEOM::TPythonDump(aFunction) << aGlued << " = geompy.MakeGlueFaces(" - << theShape << ", " << theTolerance << ")"; + << theShapes << ", " << theTolerance << ")"; // to provide warning if (!isWarning) SetErrorCode(OK); @@ -806,16 +799,25 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetGlueFaces * MakeGlueFacesByList */ //============================================================================= -Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeGlueFacesByList - (Handle(GEOM_Object) theShape, - const Standard_Real theTolerance, - std::list 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 & 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); @@ -830,24 +832,10 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeGlueFacesByList 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::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 @@ -874,16 +862,8 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeGlueFacesByList 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); @@ -895,13 +875,17 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeGlueFacesByList * 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); @@ -916,10 +900,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeGlueEdges 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); @@ -945,7 +926,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeGlueEdges //Make a Python command GEOM::TPythonDump(aFunction) << aGlued << " = geompy.MakeGlueEdges(" - << theShape << ", " << theTolerance << ")"; + << theShapes << ", " << theTolerance << ")"; // to provide warning if (!isWarning) SetErrorCode(OK); @@ -957,16 +938,36 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeGlueEdges * 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; @@ -977,9 +978,7 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetGlueShapes 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; @@ -1006,31 +1005,40 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetGlueShapes 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); @@ -1043,15 +1051,23 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetGlueShapes * MakeGlueEdgesByList */ //============================================================================= -Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeGlueEdgesByList - (Handle(GEOM_Object) theShape, - const Standard_Real theTolerance, - std::list theEdges) +Handle(GEOM_Object) +GEOMImpl_IShapesOperations::MakeGlueEdgesByList (std::list< Handle(GEOM_Object) >& theShapes, + const Standard_Real theTolerance, + std::list& 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); @@ -1065,23 +1081,9 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeGlueEdgesByList 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::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 @@ -1108,16 +1110,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeGlueEdgesByList 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); @@ -1131,7 +1124,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeGlueEdgesByList //============================================================================= 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 @@ -1146,7 +1139,7 @@ GEOMImpl_IShapesOperations::GetExistingSubObjects(Handle(GEOM_Object) theShap 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); @@ -1160,7 +1153,7 @@ GEOMImpl_IShapesOperations::GetExistingSubObjects(Handle(GEOM_Object) theShap Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetExistingSubObjects(Handle(GEOM_Object) theShape, - const Standard_Integer theTypes) + const Standard_Integer theTypes) { SetErrorCode(KO); @@ -1190,8 +1183,8 @@ GEOMImpl_IShapesOperations::GetExistingSubObjects(Handle(GEOM_Object) theShap 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); } } diff --git a/src/GEOMImpl/GEOMImpl_IShapesOperations.hxx b/src/GEOMImpl/GEOMImpl_IShapesOperations.hxx index d12642a36..a5b81b4d3 100644 --- a/src/GEOMImpl/GEOMImpl_IShapesOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_IShapesOperations.hxx @@ -91,34 +91,31 @@ class GEOMImpl_IShapesOperations : public GEOM_IOperations Standard_EXPORT Handle(GEOM_Object) MakeCompound (std::list 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 theFaces, + std::list& 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 theEdges); + std::list & 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, diff --git a/src/GEOM_I/GEOM_IHealingOperations_i.cc b/src/GEOM_I/GEOM_IHealingOperations_i.cc index ffcb214ef..3876b8159 100644 --- a/src/GEOM_I/GEOM_IHealingOperations_i.cc +++ b/src/GEOM_I/GEOM_IHealingOperations_i.cc @@ -329,17 +329,12 @@ GEOM::GEOM_Object_ptr GEOM_IHealingOperations_i::Sew (const GEOM::ListOfGO& theO return aGEOMObject._retn(); //Get the shapes - std::list 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(); @@ -365,17 +360,12 @@ GEOM_IHealingOperations_i::SewAllowNonManifold (const GEOM::ListOfGO& theObjects return aGEOMObject._retn(); //Get the shapes - std::list 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(); diff --git a/src/GEOM_I/GEOM_IOperations_i.cc b/src/GEOM_I/GEOM_IOperations_i.cc index 9cb5b8469..bfc12f04d 100644 --- a/src/GEOM_I/GEOM_IOperations_i.cc +++ b/src/GEOM_I/GEOM_IOperations_i.cc @@ -209,6 +209,29 @@ Handle(TColStd_HSequenceOfTransient) GEOM_IOperations_i::GetListOfObjectsImpl 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 diff --git a/src/GEOM_I/GEOM_IOperations_i.hh b/src/GEOM_I/GEOM_IOperations_i.hh index b82b36c68..c9b88d090 100644 --- a/src/GEOM_I/GEOM_IOperations_i.hh +++ b/src/GEOM_I/GEOM_IOperations_i.hh @@ -67,6 +67,8 @@ protected: 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); diff --git a/src/GEOM_I/GEOM_IShapesOperations_i.cc b/src/GEOM_I/GEOM_IShapesOperations_i.cc index e26497648..e109838e8 100644 --- a/src/GEOM_I/GEOM_IShapesOperations_i.cc +++ b/src/GEOM_I/GEOM_IShapesOperations_i.cc @@ -345,8 +345,8 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSolidShells * 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; @@ -378,10 +378,10 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeCompound * 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; @@ -389,12 +389,13 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueFaces 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()) @@ -408,9 +409,9 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueFaces * 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; @@ -418,12 +419,12 @@ GEOM::ListOfGO* GEOM_IShapesOperations_i::GetGlueFaces 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 @@ -443,12 +444,12 @@ GEOM::ListOfGO* GEOM_IShapesOperations_i::GetGlueFaces * 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; @@ -456,22 +457,19 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueFacesByList 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 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 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()) @@ -485,9 +483,9 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueFacesByList * 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; @@ -495,12 +493,13 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueEdges 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()) @@ -514,9 +513,9 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueEdges * 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; @@ -524,11 +523,12 @@ GEOM::ListOfGO* GEOM_IShapesOperations_i::GetGlueEdges 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 @@ -548,10 +548,10 @@ GEOM::ListOfGO* GEOM_IShapesOperations_i::GetGlueEdges * 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; @@ -559,22 +559,18 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueEdgesByList 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 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 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()) @@ -588,8 +584,9 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueEdgesByList * 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; diff --git a/src/GEOM_I/GEOM_IShapesOperations_i.hh b/src/GEOM_I/GEOM_IShapesOperations_i.hh index 028d927e0..8b18fe9f2 100644 --- a/src/GEOM_I/GEOM_IShapesOperations_i.hh +++ b/src/GEOM_I/GEOM_IShapesOperations_i.hh @@ -72,26 +72,26 @@ class GEOM_I_EXPORT GEOM_IShapesOperations_i : 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); diff --git a/src/GEOM_SWIG/GEOM_TestHealing.py b/src/GEOM_SWIG/GEOM_TestHealing.py index d3d7af966..72ad4927e 100644 --- a/src/GEOM_SWIG/GEOM_TestHealing.py +++ b/src/GEOM_SWIG/GEOM_TestHealing.py @@ -387,8 +387,125 @@ def TestRemoveWebs (geompy): 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) diff --git a/src/GEOM_SWIG/geomBuilder.py b/src/GEOM_SWIG/geomBuilder.py index 0e5975d11..e20f6031e 100644 --- a/src/GEOM_SWIG/geomBuilder.py +++ b/src/GEOM_SWIG/geomBuilder.py @@ -6721,8 +6721,8 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): 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. @@ -6730,16 +6730,16 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # 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. @@ -6748,19 +6748,19 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): 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 @@ -6771,12 +6771,12 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # # @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 @@ -6786,14 +6786,14 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): 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. @@ -6806,19 +6806,18 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # 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. @@ -6832,51 +6831,50 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): 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 @@ -6887,12 +6885,12 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # # @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 @@ -6902,14 +6900,14 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): 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. @@ -6917,18 +6915,17 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # 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. @@ -6937,10 +6934,9 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): 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") diff --git a/src/RepairGUI/RepairGUI_GlueDlg.cxx b/src/RepairGUI/RepairGUI_GlueDlg.cxx index 55a1bb27a..debad4f6a 100644 --- a/src/RepairGUI/RepairGUI_GlueDlg.cxx +++ b/src/RepairGUI/RepairGUI_GlueDlg.cxx @@ -91,7 +91,7 @@ RepairGUI_GlueDlg::RepairGUI_GlueDlg(GeometryGUI* theGeometryGUI, QWidget* paren 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); @@ -108,7 +108,7 @@ RepairGUI_GlueDlg::RepairGUI_GlueDlg(GeometryGUI* theGeometryGUI, QWidget* paren 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); @@ -191,7 +191,7 @@ void RepairGUI_GlueDlg::Init() /* init variables */ myEditCurrentArgument = GroupPoints->LineEdit1; - myObject = GEOM::GEOM_Object::_nil(); + myObjects.clear(); //myGeomGUI->SetState(0); //globalSelection(GEOM_COMPOUND); @@ -330,17 +330,13 @@ void RepairGUI_GlueDlg::SelectionIntoArgument() 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(); } @@ -432,7 +428,7 @@ bool RepairGUI_GlueDlg::isValid(QString& msg) ok = myTolEdt2->isValid(msg, !IsPreview()); 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; 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()) @@ -506,11 +507,11 @@ bool RepairGUI_GlueDlg::execute(ObjectList& objects) 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(); @@ -693,12 +694,17 @@ void RepairGUI_GlueDlg::onDetect() 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()); @@ -719,7 +725,10 @@ void RepairGUI_GlueDlg::onDetect() 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(); } @@ -739,7 +748,7 @@ void RepairGUI_GlueDlg::activateSelection() this, SLOT(SelectionIntoArgument())); globalSelection(GEOM_ALLSHAPES); - if (myObject->_is_nil()) + if ( myObjects.isEmpty() ) SelectionIntoArgument(); connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), @@ -768,7 +777,7 @@ void RepairGUI_GlueDlg::activateSelection() 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); diff --git a/src/RepairGUI/RepairGUI_GlueDlg.h b/src/RepairGUI/RepairGUI_GlueDlg.h index 4b6ccc3af..494c80716 100644 --- a/src/RepairGUI/RepairGUI_GlueDlg.h +++ b/src/RepairGUI/RepairGUI_GlueDlg.h @@ -73,7 +73,7 @@ private: void selectTmpInViewer(); private: - GEOM::GEOM_Object_var myObject; + QList myObjects; QList myTmpObjs; DlgRef_1SelExt* GroupPoints; diff --git a/src/RepairGUI/RepairGUI_SewingDlg.cxx b/src/RepairGUI/RepairGUI_SewingDlg.cxx index e26f26157..3f146c644 100644 --- a/src/RepairGUI/RepairGUI_SewingDlg.cxx +++ b/src/RepairGUI/RepairGUI_SewingDlg.cxx @@ -70,7 +70,7 @@ RepairGUI_SewingDlg::RepairGUI_SewingDlg( GeometryGUI* theGeometryGUI, QWidget* 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 );