From bf04ae3297dba17b1a5a806b0a8a5f4a73b3e6b0 Mon Sep 17 00:00:00 2001 From: jfa Date: Wed, 27 Apr 2011 13:18:06 +0000 Subject: [PATCH] IMPs 19998 and 21191: new gluing by PKV. Documentation updated. --- .../gui/GEOM/input/glue_faces_operation.doc | 64 ++++++++++++++----- .../GEOM/input/tui_repairing_operations.doc | 34 ++++++++++ src/GEOMImpl/GEOMImpl_IShapesOperations.cxx | 31 ++++++--- src/GEOM_SWIG/geompyDC.py | 15 ++--- 4 files changed, 107 insertions(+), 37 deletions(-) diff --git a/doc/salome/gui/GEOM/input/glue_faces_operation.doc b/doc/salome/gui/GEOM/input/glue_faces_operation.doc index ebdbe9c34..435a303fa 100644 --- a/doc/salome/gui/GEOM/input/glue_faces_operation.doc +++ b/doc/salome/gui/GEOM/input/glue_faces_operation.doc @@ -5,35 +5,64 @@ \n To Glue Faces in the Main Menu select Repair - > Glue Faces. \n To Glue Edges in the Main Menu select Repair - > Glue Edges. -\n This operation glues faces that are coincident with respect to the +\n This operation glues faces/edges that are coincident with respect to the given tolerance value. -\n The \b Result will be a \b GEOM_Object. - -\n TUI Command: - geompy.MakeGlueFaces(theShape,theTolerance), - where \em theShape is a compound of solids to be glued, \em - theTolerance is a maximum distance between two faces, which can be - considered as coincident. -\n Arguments: Name + Compound of solids + Tolerance value. +\n Arguments: Name + Compound of shapes + Tolerance value. \n Advanced option: \ref restore_presentation_parameters_page "Set presentation parameters and subshapes from arguments". +\n The \b Result will be a \b GEOM_Object. \image html glue1.png - -\n It is also possible to manually select the faces that will be +\n \image html glue4.png + +\n TUI Commands: + geompy.MakeGlueFaces(theShape,theTolerance,doKeepNonSolids) and + geompy.MakeGlueEdges(theShape,theTolerance), + where \em theShape is a compound of shapes to be glued, \em + theTolerance is a maximum distance between two faces/edges, 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 + be a new \b GEOM_Object. + +\n It is also possible to manually select the faces/edges that will be glued - select the shape, specify the tolerance and press \b Detect button. \image html glue2.png +\n \image html glue5.png -\n \b Geometry module detects the faces where gluing can be performed and -displays a notification. +\n \b Geometry module detects the faces/edges where gluing can be +performed and displays a notification. \image html glue3.png -\n The faces that can be glued are colored in red. It is possible to -select the faces for gluing in the 3D viewer. The selected faces will -be marked in white. +\n The faces/edges that can be glued are colored in red. It is +possible to select the faces/edges for gluing in the 3D viewer. +The selected faces/edges will be marked in white. + +\n For faces gluing their edges are also glued. By default, other +edges are not glued (this concerns only Glue Faces, of course). +To force all edges gluing, check the "Glue all coincident edges" +checkbox. + +\n TUI Commands: + geompy.GetGlueFaces(theShape,theTolerance) and + geompy.GetGlueEdges(theShape,theTolerance), + where \em theShape is a compound of shapes to be glued, \em + theTolerance is a maximum distance between two faces/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. + +\n geompy.MakeGlueFacesByList(theShape,theTolerance,theFaces,doKeepNonSolids,doGlueAllEdges) + and geompy.MakeGlueEdgesByList(theShape,theTolerance,theEdges), + where \em theShape is a compound of shapes to be glued, \em + theTolerance is a maximum distance between two faces/edges, which can + be considered as coincident, \em theFaces/theEdges is a list of + subshapes to be glued. The \em doKeepNonSolids flag allows to throw + away non-solids from the result, if false. The \em doGlueAllEdges + allows to glue all edges, not only owned by glued faces. The \b + Result will be a new \b GEOM_Object. \n Example: @@ -47,6 +76,7 @@ be marked in white.
Manual selection of faces for gluing
Our TUI Scripts provide you with useful examples of the use of -\ref tui_glue_faces "Repairing Operations". +Repairing Operations \ref tui_glue_faces "Glue Faces" and \ref +tui_glue_edges "Glue Edges". */ diff --git a/doc/salome/gui/GEOM/input/tui_repairing_operations.doc b/doc/salome/gui/GEOM/input/tui_repairing_operations.doc index 237440c2f..4b1f067cc 100644 --- a/doc/salome/gui/GEOM/input/tui_repairing_operations.doc +++ b/doc/salome/gui/GEOM/input/tui_repairing_operations.doc @@ -289,6 +289,40 @@ gg.createAndDisplayGO(id_glue) gg.setDisplayMode(id_glue,1) \endcode +\anchor tui_glue_edges +

Glue Edges

+ +\code +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create boxes +box1 = geompy.MakeBox(0,0,0,100,50,100) +box2 = geompy.MakeBox(100,0,0,250,50,100) + +# make compound +compound = geompy.MakeCompound([box1, box2]) + +# glue all compound's edges +tolerance = 1e-5 +glue1 = geompy.MakeGlueEdges(compound, tolerance) + +# glue some compound's edges +list_edges = geompy.GetGlueEdges(compound, tolerance) +glue2 = geompy.MakeGlueEdgesByList(compound, tolerance, [list_edges[0], list_edges[2]]) + +# add objects in study +geompy.addToStudy(box1, "Box1") +geompy.addToStudy(box2, "Box2") +geompy.addToStudy(compound, "Compound") +geompy.addToStudy(glue1, "Glue all edges") +geompy.addToStudy(glue2, "Glue two edges") + +if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser(1) +\endcode + \anchor tui_limit_tolerance

Limit Tolerance

diff --git a/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx index a9eb02821..11e0ee2fd 100644 --- a/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx @@ -985,6 +985,8 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetGlueShapes Handle(TColStd_HArray1OfInteger) anArray; Handle(GEOM_Object) anObj; + TopTools_ListOfShape listOnePerSet; + const TopTools_DataMapOfShapeListOfShape& aImages = aGluer.Images(); TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItDMSLS (aImages); for (int index = 1; aItDMSLS.More(); aItDMSLS.Next(), ++index) { @@ -998,17 +1000,26 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetGlueShapes TopoDS_Shape aValue = aLSD.First(); if (aValue.ShapeType() == theType) { - anArray = new TColStd_HArray1OfInteger(1,1); - anArray->SetValue(1, anIndices.FindIndex(aValue)); - anObj = GetEngine()->AddSubShape(theShape, anArray); - if (!anObj.IsNull()) { - aSeq->Append(anObj); + listOnePerSet.Append(aValue); + } + } - // for python command - TDF_Tool::Entry(anObj->GetEntry(), anEntry); - anAsciiList += anEntry; - anAsciiList += ","; - } + // for stable order of returned entities + GEOMImpl_IShapesOperations::SortShapes(listOnePerSet, Standard_False); + + TopTools_ListIteratorOfListOfShape aListIt (listOnePerSet); + 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 += ","; } } diff --git a/src/GEOM_SWIG/geompyDC.py b/src/GEOM_SWIG/geompyDC.py index 0b0ce1b36..68543eecc 100644 --- a/src/GEOM_SWIG/geompyDC.py +++ b/src/GEOM_SWIG/geompyDC.py @@ -2556,9 +2556,8 @@ class geompyDC(GEOM._objref_GEOM_Gen): # which can be considered as coincident. # @return ListOfGO. # - # @ref swig_todo "Example" + # @ref tui_glue_faces "Example" def GetGlueFaces(self, theShape, theTolerance): - # Example: see GEOM_Spanner.py anObj = self.ShapesOp.GetGlueFaces(theShape, theTolerance) RaiseIfFailed("GetGlueFaces", self.ShapesOp) return anObj @@ -2577,10 +2576,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @return New GEOM_Object, containing a copy of theShape # without some faces. # - # @ref swig_todo "Example" + # @ref tui_glue_faces "Example" def MakeGlueFacesByList(self, theShape, theTolerance, theFaces, doKeepNonSolids=True, doGlueAllEdges=True): - # Example: see GEOM_Spanner.py anObj = self.ShapesOp.MakeGlueFacesByList(theShape, theTolerance, theFaces, doKeepNonSolids, doGlueAllEdges) if anObj is None: @@ -2592,9 +2590,8 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theTolerance Maximum distance between edges, which can be considered as coincident. # @return New GEOM_Object, containing a copy of theShape without coincident edges. # - # @ref tui_glue_faces "Example" + # @ref tui_glue_edges "Example" def MakeGlueEdges(self, theShape, theTolerance): - # Example: see GEOM_Spanner.py theTolerance,Parameters = ParseParameters(theTolerance) anObj = self.ShapesOp.MakeGlueEdges(theShape, theTolerance) if anObj is None: @@ -2608,9 +2605,8 @@ class geompyDC(GEOM._objref_GEOM_Gen): # which can be considered as coincident. # @return ListOfGO. # - # @ref tui_glue_faces "Example" + # @ref tui_glue_edges "Example" def GetGlueEdges(self, theShape, theTolerance): - # Example: see GEOM_Spanner.py anObj = self.ShapesOp.GetGlueEdges(theShape, theTolerance) RaiseIfFailed("GetGlueEdges", self.ShapesOp) return anObj @@ -2624,9 +2620,8 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @return New GEOM_Object, containing a copy of theShape # without some edges. # - # @ref tui_glue_faces "Example" + # @ref tui_glue_edges "Example" def MakeGlueEdgesByList(self, theShape, theTolerance, theEdges): - # Example: see GEOM_Spanner.py anObj = self.ShapesOp.MakeGlueEdgesByList(theShape, theTolerance, theEdges) if anObj is None: raise RuntimeError, "MakeGlueEdgesByList : " + self.ShapesOp.GetErrorCode() -- 2.39.2