From: eap Date: Thu, 9 Oct 2014 14:34:57 +0000 (+0400) Subject: 0022745: [EDF] Improvement of Sewing operation X-Git-Tag: V7_6_0a1~60^2~40 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=db4ad95d8e04bf23ba8f65833ae13e7f7d10b675;p=modules%2Fgeom.git 0022745: [EDF] Improvement of Sewing operation --- diff --git a/doc/salome/examples/repairing_operations_ex06.py b/doc/salome/examples/repairing_operations_ex06.py index 8935962bf..5f6014e74 100644 --- a/doc/salome/examples/repairing_operations_ex06.py +++ b/doc/salome/examples/repairing_operations_ex06.py @@ -1,27 +1,26 @@ # Sewing -import salome +import salome, math salome.salome_init() -import GEOM from salome.geom import geomBuilder + geompy = geomBuilder.New(salome.myStudy) -import math -gg = salome.ImportComponentGUI("GEOM") +gg = salome.ImportComponentGUI("GEOM") # create base points px = geompy.MakeVertex(100., 0., 0.) py = geompy.MakeVertex(0., 100., 0.) pz = geompy.MakeVertex(0., 0., 100.) -# create base geometry 2D & 3D +# create base geometry 2D vector = geompy.MakeVector(px, py) -arc = geompy.MakeArc(py, pz, px) +arc = geompy.MakeArc(py, pz, px) # create base objects angle = 45. * math.pi / 180 -WantPlanarFace = 1 #True -wire = geompy.MakeWire([vector, arc]) -face = geompy.MakeFace(wire, WantPlanarFace) +WantPlanarFace = True +wire = geompy.MakeWire([vector, arc]) +face = geompy.MakeFace(wire, WantPlanarFace) face_rot = geompy.MakeRotation(face, vector, angle) # make sewing @@ -29,9 +28,9 @@ precision = 0.00001 sewing = geompy.MakeSewing([face, face_rot], precision) # add objects in the study -id_face = geompy.addToStudy(face, "Face") +id_face = geompy.addToStudy(face, "Face") id_face_rot = geompy.addToStudy(face_rot, "Face rotation") -id_sewing = geompy.addToStudy(sewing, "Sewing") +id_sewing = geompy.addToStudy(sewing, "Sewing") # display the results gg.createAndDisplayGO(id_face) @@ -40,3 +39,12 @@ gg.createAndDisplayGO(id_face_rot) gg.setDisplayMode(id_face_rot,1) gg.createAndDisplayGO(id_sewing) gg.setDisplayMode(id_sewing,1) + + +# Example 2: make a shell of a multiply translated face +quad = geompy.MakeFaceHW( 10, 20, 1 ) +quadCompound = geompy.MakeMultiTranslation1D( quad, geompy.MakeVectorDXDYDZ(1,0,0), 10, 3) +shell = geompy.Sew( quadCompound, 1e-6 ) + +id_shell = geompy.addToStudy( shell, "3 quads shell") +gg.createAndDisplayGO(id_shell) diff --git a/doc/salome/gui/GEOM/images/neo-detect2.png b/doc/salome/gui/GEOM/images/neo-detect2.png old mode 100755 new mode 100644 index 273d000f2..20608c452 Binary files a/doc/salome/gui/GEOM/images/neo-detect2.png and b/doc/salome/gui/GEOM/images/neo-detect2.png differ diff --git a/doc/salome/gui/GEOM/images/repair6.png b/doc/salome/gui/GEOM/images/repair6.png old mode 100755 new mode 100644 index 1816e30ec..666ea8708 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/creating_3dsketcher.doc b/doc/salome/gui/GEOM/input/creating_3dsketcher.doc index 030912ad6..b04c8aa65 100755 --- a/doc/salome/gui/GEOM/input/creating_3dsketcher.doc +++ b/doc/salome/gui/GEOM/input/creating_3dsketcher.doc @@ -25,7 +25,7 @@ By Cartesian coordinates , which can be either: - \b Relative coordinates \b DX, \b DY and \b DZ with respect to the previous applied point, By Angular coordinates, which include: -- the \b Length of the segment and an \b Angle in the chosen plane (OXY for example) in \b Relative mode. The angle is then relative to a local coordinate system with the last point of the sketch as origin. +- the \b Length of the segment and an \b Angle in the chosen plane (OXY for example) in \b Relative mode. The angle is then relative to a local coordinate system with the last point of the sketch as origin. \image html 3dsketch_angle_rel.png diff --git a/doc/salome/gui/GEOM/input/dependency_tree.doc b/doc/salome/gui/GEOM/input/dependency_tree.doc index e44dba400..15a3a7639 100644 --- a/doc/salome/gui/GEOM/input/dependency_tree.doc +++ b/doc/salome/gui/GEOM/input/dependency_tree.doc @@ -103,7 +103,7 @@ Buttons marked with small downward triangles have extended functionality which can be accessed by locking on them with left mouse button. -\image tree_tool_bar +\image html tree_tool_bar.png Dump View - exports an object from the viewer in bmp, png or jpeg image format. diff --git a/doc/salome/gui/GEOM/input/import_export.doc b/doc/salome/gui/GEOM/input/import_export.doc index 93ddcc384..890ce97e6 100644 --- a/doc/salome/gui/GEOM/input/import_export.doc +++ b/doc/salome/gui/GEOM/input/import_export.doc @@ -25,8 +25,8 @@ Our TUI Scripts provide you with useful examples of the use of To import geometrical objects from a BREP, IGES, STEP or STL file: \par -From the \b File menu choose Import/, where is a name -of desirable format. In the Import dialog box select the file to import +From the \b File menu choose Import/\, where \ is a name +of desirable format. In the Import \ dialog box select the file to import and press \b Open. The file will be imported in the module and its contents (geometrical object) will be displayed in the Object Browser. @@ -63,8 +63,8 @@ file: \par Select the object you wish to export, then from the \b File menu choose -Export/, where is a name of desirable format. -In the Export dialog box define the name and the location +Export/\, where \ is a name of desirable format. +In the Export \ dialog box define the name and the location of the file to export and press \b Save. The dialog box to export the file can provide additional advanced parameters. diff --git a/doc/salome/gui/GEOM/input/managing_dimensions.doc b/doc/salome/gui/GEOM/input/managing_dimensions.doc index 13187978b..8b49f3ad1 100644 --- a/doc/salome/gui/GEOM/input/managing_dimensions.doc +++ b/doc/salome/gui/GEOM/input/managing_dimensions.doc @@ -18,7 +18,7 @@ It is possible to show/hide a dimension in the view by checking on/off the box t The buttons to the right of the list provide the following operations: diff --git a/doc/salome/gui/GEOM/input/sewing_operation.doc b/doc/salome/gui/GEOM/input/sewing_operation.doc index 18d95e881..0008dc80a 100644 --- a/doc/salome/gui/GEOM/input/sewing_operation.doc +++ b/doc/salome/gui/GEOM/input/sewing_operation.doc @@ -2,9 +2,24 @@ \page sewing_operation_page Sewing +\b Sewing operation allows uniting several faces (possibly contained +in a shell, solid or compound) into one shell while geometrically +coincident (within a specified tolerance) edges (or parts of edges) of +different faces are replaced by one edge thus producing a shell of +faces with shared boundaries.

+This operation is similar to New Entity - > Build - > Shell +operation, the difference is that with \b Sewing you can specify the +tolerance and can get a non-manifold result.

+Possibility to create a non-manifold shell can be used e.g. to create a +shell forming several closed domains and then to create several solids +with shared boundaries from this shell. + +\note Geometrically coincident faces (or part of faces) won't be +replaced by one face during \b Sewing. + To produce a \b Sewing operation in the Main Menu select Repair - > Sewing. -The \b Result will be a \b GEOM_Object. +The \b Result will be a \b GEOM_Object (shell). \image html repair6.png diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index 8863bae26..0f168018a 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -3680,7 +3680,7 @@ module GEOM * \param theTolerance Required tolerance value. * \return New GEOM_Object, containing processed shape. */ - GEOM_Object Sew (in GEOM_Object theObject, in double theTolerance); + GEOM_Object Sew (in ListOfGO theObjects, in double theTolerance); /*! * Sewing of the given object. Allows non-manifold sewing. @@ -3688,7 +3688,7 @@ module GEOM * \param theTolerance Required tolerance value. * \return New GEOM_Object, containing processed shape. */ - GEOM_Object SewAllowNonManifold(in GEOM_Object theObject, in double theTolerance); + GEOM_Object SewAllowNonManifold(in ListOfGO theObjects, in double theTolerance); /*! * Rebuild the topology of theCompound of solids by removing @@ -3725,12 +3725,12 @@ module GEOM /*! * \brief Get a list of wires (wrapped in GEOM_Object-s), * that constitute a free boundary of the given shape. - * \param theObject Shape to get free boundary of. + * \param theObject Shapes to get free boundary of. * \param theClosedWires Output. Closed wires on the free boundary of the given shape. * \param theOpenWires Output. Open wires on the free boundary of the given shape. * \return FALSE, if an error(s) occured during the method execution. */ - boolean GetFreeBoundary (in GEOM_Object theObject, + boolean GetFreeBoundary (in ListOfGO theObjects, out ListOfGO theClosedWires, out ListOfGO theOpenWires); diff --git a/src/GEOM/GEOM_PythonDump.cxx b/src/GEOM/GEOM_PythonDump.cxx index 395a3ab72..2a2e498d8 100644 --- a/src/GEOM/GEOM_PythonDump.cxx +++ b/src/GEOM/GEOM_PythonDump.cxx @@ -140,6 +140,23 @@ namespace GEOM } return *this; } + Standard_EXPORT TPythonDump& + TPythonDump::operator<< (const std::list& theObjects) + { + Standard_Integer aLength = theObjects.size(); + if ( aLength > 1 ) { + myStream << "["; + } + std::list::const_iterator obj = theObjects.begin(); + for ( Standard_Integer i = 1; i <= aLength; i++, ++obj ) { + *this << *obj; + if ( i < aLength ) myStream << ", "; + } + if ( aLength > 1 ) { + myStream << "]"; + } + return *this; + } TPythonDump& TPythonDump::operator<< (const GEOM_BaseObject* theObject) { diff --git a/src/GEOM/GEOM_PythonDump.hxx b/src/GEOM/GEOM_PythonDump.hxx index 66b87506e..a9f20190d 100644 --- a/src/GEOM/GEOM_PythonDump.hxx +++ b/src/GEOM/GEOM_PythonDump.hxx @@ -30,6 +30,8 @@ #include +#include + namespace GEOM { class TPythonDump @@ -56,7 +58,8 @@ namespace GEOM Standard_EXPORT TPythonDump& operator<< (const TCollection_AsciiString theArg); Standard_EXPORT TPythonDump& operator<< (const TopAbs_ShapeEnum theArg); Standard_EXPORT TPythonDump& operator<< (const Handle(GEOM_BaseObject)& theObject); - Standard_EXPORT TPythonDump& operator<< (const Handle(TColStd_HSequenceOfTransient)& theObjects); + Standard_EXPORT TPythonDump& operator<< (const Handle(TColStd_HSequenceOfTransient)& objects); + Standard_EXPORT TPythonDump& operator<< (const std::list& theObjects); Standard_EXPORT TPythonDump& operator<< (const GEOM_BaseObject* theObject); }; diff --git a/src/GEOMImpl/GEOMImpl_HealingDriver.cxx b/src/GEOMImpl/GEOMImpl_HealingDriver.cxx index 09441ab23..0678df2c7 100644 --- a/src/GEOMImpl/GEOMImpl_HealingDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_HealingDriver.cxx @@ -425,14 +425,33 @@ Standard_Boolean GEOMImpl_HealingDriver::RemoveHoles (GEOMImpl_IHealing* theHI, //function : Sew //purpose : //======================================================================= -Standard_Boolean GEOMImpl_HealingDriver::Sew (GEOMImpl_IHealing* theHI, +Standard_Boolean GEOMImpl_HealingDriver::Sew (GEOMImpl_IHealing* theHI, const TopoDS_Shape& theOriginalShape, - TopoDS_Shape& theOutShape, - Standard_Boolean isAllowNonManifold) const + TopoDS_Shape& theOutShape, + Standard_Boolean isAllowNonManifold) const { Standard_Real aTol = theHI->GetTolerance(); - ShHealOper_Sewing aHealer (theOriginalShape, aTol); + TopoDS_Compound faceCompound; + BRep_Builder builder; + builder.MakeCompound( faceCompound ); + + TopExp_Explorer faceExp( theOriginalShape, TopAbs_FACE ); + for ( ; faceExp.More(); faceExp.Next() ) + builder.Add( faceCompound, faceExp.Current() ); + + Handle(TColStd_HSequenceOfTransient) otherObjs = theHI->GetShapes(); + for ( int ind = 1; ind <= otherObjs->Length(); ind++) + { + Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(otherObjs->Value(ind)); + TopoDS_Shape aShape = aRefShape->GetValue(); + if (aShape.IsNull()) + Standard_NullObject::Raise("Null object given"); + for ( faceExp.Init( aShape, TopAbs_FACE ); faceExp.More(); faceExp.Next() ) + builder.Add( faceCompound, faceExp.Current() ); + } + + ShHealOper_Sewing aHealer (faceCompound, aTol); // Set non-manifold mode. aHealer.SetNonManifoldMode(isAllowNonManifold); @@ -606,7 +625,7 @@ void GEOMImpl_HealingDriver::FuseCollinearEdges (const TopoDS_Shape& theOriginal removeAll = true; if (!removeAll) { - for (unsigned int ind = 1; ind <= aVerts->Length(); ind++) { + for ( int ind = 1; ind <= aVerts->Length(); ind++) { Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aVerts->Value(ind)); TopoDS_Shape aShape_i = aRefShape->GetValue(); if (aShape_i.IsNull()) @@ -881,7 +900,7 @@ GetCreationInformation(std::string& theOperationName, case SEWING: case SEWING_NON_MANIFOLD: theOperationName = "SEWING"; - AddParam( theParams, "Selected shape", aCI.GetOriginal() ); + AddParam( theParams, "Selected shapes", aCI.GetOriginalAndShapes() ); AddParam( theParams, "Allow Non Manifold", ( aType == SEWING_NON_MANIFOLD )); AddParam( theParams, "Tolerance", aCI.GetTolerance() ); break; diff --git a/src/GEOMImpl/GEOMImpl_IHealing.hxx b/src/GEOMImpl/GEOMImpl_IHealing.hxx index 8fcbf3110..d21962155 100755 --- a/src/GEOMImpl/GEOMImpl_IHealing.hxx +++ b/src/GEOMImpl/GEOMImpl_IHealing.hxx @@ -55,7 +55,7 @@ public: void SetValues( const Handle(TColStd_HArray1OfExtendedString)& arr ) { if ( !arr.IsNull() ) _func->SetStringArray(ARG_SHAPE_PROCESS_VALUES, arr); } Handle(TColStd_HArray1OfExtendedString) GetValues() { return _func->GetStringArray(ARG_SHAPE_PROCESS_VALUES); } - void SetOriginal( Handle(GEOM_Function)& f ) { _func->SetReference(ARG_ORIGINAL, f); } + void SetOriginal( Handle(GEOM_Function) f ) { _func->SetReference(ARG_ORIGINAL, f); } Handle(GEOM_Function) GetOriginal() { return _func->GetReference(ARG_ORIGINAL); } void SetFaces( const Handle(TColStd_HArray1OfInteger)& arr ) { if ( !arr.IsNull() ) _func->SetIntegerArray(ARG_LIST_ARGUMENTS, arr); } @@ -84,6 +84,13 @@ public: Handle(TColStd_HSequenceOfTransient) GetShapes() { return _func->GetReferenceList(ARG_LIST_SHAPES); } + Handle(TColStd_HSequenceOfTransient) GetOriginalAndShapes() + { + Handle(TColStd_HSequenceOfTransient) funs = GetShapes(); + if ( funs.IsNull() ) funs = new TColStd_HSequenceOfTransient; + funs->Prepend( GetOriginal() ); + return funs; + } private: Handle(GEOM_Function) _func; }; diff --git a/src/GEOMImpl/GEOMImpl_IHealingOperations.cxx b/src/GEOMImpl/GEOMImpl_IHealingOperations.cxx index b45374c45..fb04fd1cb 100644 --- a/src/GEOMImpl/GEOMImpl_IHealingOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IHealingOperations.cxx @@ -28,9 +28,7 @@ #include #include - #include - #include #include #include @@ -40,22 +38,20 @@ #include -#include "utilities.h" +#include #include #include +#include #include - #include - -#include -#include - #include #include #include - #include +#include +#include +#include #include #include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC @@ -585,27 +581,36 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::FillHoles (Handle(GEOM_Object) * Sew */ //============================================================================= -Handle(GEOM_Object) GEOMImpl_IHealingOperations::Sew (Handle(GEOM_Object) theObject, - double theTolerance, - bool isAllowNonManifold) +Handle(GEOM_Object) +GEOMImpl_IHealingOperations::Sew (std::list& theObjects, + double theTolerance, + bool isAllowNonManifold) { // set error code, check parameters SetErrorCode(KO); - if (theObject.IsNull()) + if (theObjects.empty()) return NULL; - Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction(); - if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed + 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); + } // Add a new object Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY ); //Add the function int aFunctionType = (isAllowNonManifold ? SEWING_NON_MANIFOLD : SEWING); - - aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), aFunctionType); - + Handle(GEOM_Function) aFunction = + aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), aFunctionType); if (aFunction.IsNull()) return NULL; //Check if the function is set correctly @@ -614,7 +619,8 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::Sew (Handle(GEOM_Object) theObj // prepare "data container" class IHealing GEOMImpl_IHealing HI(aFunction); HI.SetTolerance( theTolerance ); - HI.SetOriginal( aLastFunction ); + HI.SetOriginal( theObjects.front()->GetLastFunction() ); objects->Remove(1); + HI.SetShapes( objects ); //Compute the result try { @@ -634,7 +640,7 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::Sew (Handle(GEOM_Object) theObj //Make a Python command GEOM::TPythonDump pd(aFunction); - pd << aNewObject << " = geompy.Sew(" << theObject << ", " << theTolerance; + pd << aNewObject << " = geompy.Sew(" << theObjects << ", " << theTolerance; if (isAllowNonManifold) { pd << ", true"; @@ -835,19 +841,40 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::FuseCollinearEdgesWithinWire * GetFreeBoundary */ //============================================================================= -bool GEOMImpl_IHealingOperations::GetFreeBoundary (Handle(GEOM_Object) theObject, +bool GEOMImpl_IHealingOperations::GetFreeBoundary (Handle(TColStd_HSequenceOfTransient)& theObjects, Handle(TColStd_HSequenceOfTransient)& theClosed, Handle(TColStd_HSequenceOfTransient)& theOpen ) { // set error code, check parameters SetErrorCode(KO); - if ( theObject.IsNull() || theClosed.IsNull() || theOpen.IsNull() ) + if ( theObjects.IsNull() || theObjects->Length() == 0 || + theClosed.IsNull() || theOpen.IsNull() ) return false; - TopoDS_Shape aShape = theObject->GetValue(); - if ( aShape.IsNull() ) - return false; + TopoDS_Shape aShape; + TopTools_SequenceOfShape shapes; + for ( int ind = 1; ind <= theObjects->Length(); ind++) + { + Handle(GEOM_Object) aRefShape = Handle(GEOM_Object)::DownCast( theObjects->Value(ind)); + if ( aRefShape.IsNull() ) + return false; + aShape = aRefShape->GetValue(); + if ( aShape.IsNull() ) + return false; + shapes.Append( aShape ); + } + + 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; + } // get free boundary shapes @@ -906,7 +933,7 @@ bool GEOMImpl_IHealingOperations::GetFreeBoundary (Handle(GEOM_Object) theObject pd << "empty_list"; } - pd << ") = geompy.GetFreeBoundary(" << theObject << ")"; + pd << ") = geompy.GetFreeBoundary(" << theObjects << ")"; } SetErrorCode(OK); diff --git a/src/GEOMImpl/GEOMImpl_IHealingOperations.hxx b/src/GEOMImpl/GEOMImpl_IHealingOperations.hxx index 607ecc4b4..7dd25d87f 100644 --- a/src/GEOMImpl/GEOMImpl_IHealingOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_IHealingOperations.hxx @@ -70,9 +70,9 @@ class GEOMImpl_IHealingOperations : public GEOM_IOperations { Standard_EXPORT Handle(GEOM_Object) FillHoles( Handle(GEOM_Object) theObject, const Handle(TColStd_HArray1OfInteger)& theWires); - Standard_EXPORT Handle(GEOM_Object) Sew( Handle(GEOM_Object) theObject, - double theTolerance, - bool isAllowNonManifold); + Standard_EXPORT Handle(GEOM_Object) Sew( std::list & theObject, + double theTolerance, + bool isAllowNonManifold); Standard_EXPORT Handle(GEOM_Object) RemoveInternalFaces (Handle(GEOM_Object) theObject); @@ -88,9 +88,9 @@ class GEOMImpl_IHealingOperations : public GEOM_IOperations { // this function does not use Function-Driver mechanism, it just computes the free // boundary edges and returns them in the sequence. It is called just for information reasons // and it's not intended for history/undo/redo/etc.. - Standard_EXPORT bool GetFreeBoundary ( Handle(GEOM_Object) theObject, - Handle(TColStd_HSequenceOfTransient)& theOutClosedWires, - Handle(TColStd_HSequenceOfTransient)& theOutOpenWires ); + Standard_EXPORT bool GetFreeBoundary ( Handle(TColStd_HSequenceOfTransient)& theObjects, + Handle(TColStd_HSequenceOfTransient)& theOutClosedWires, + Handle(TColStd_HSequenceOfTransient)& theOutOpenWires ); Standard_EXPORT Handle(GEOM_Object) ChangeOrientation( Handle(GEOM_Object) theObject); Standard_EXPORT Handle(GEOM_Object) ChangeOrientationCopy( Handle(GEOM_Object) theObject); diff --git a/src/GEOM_I/GEOM_IHealingOperations_i.cc b/src/GEOM_I/GEOM_IHealingOperations_i.cc index 51fe6c46e..ffcb214ef 100644 --- a/src/GEOM_I/GEOM_IHealingOperations_i.cc +++ b/src/GEOM_I/GEOM_IHealingOperations_i.cc @@ -316,8 +316,8 @@ GEOM::GEOM_Object_ptr GEOM_IHealingOperations_i::FillHoles (GEOM::GEOM_Object_pt * Sew */ //============================================================================= -GEOM::GEOM_Object_ptr GEOM_IHealingOperations_i::Sew (GEOM::GEOM_Object_ptr theObject, - CORBA::Double theTolerance) +GEOM::GEOM_Object_ptr GEOM_IHealingOperations_i::Sew (const GEOM::ListOfGO& theObjects, + CORBA::Double theTolerance) { GEOM::GEOM_Object_var aGEOMObject; @@ -328,14 +328,18 @@ GEOM::GEOM_Object_ptr GEOM_IHealingOperations_i::Sew (GEOM::GEOM_Object_ptr theO if (theTolerance < 0) return aGEOMObject._retn(); - // Get the object itself - Handle(GEOM_Object) anObject = GetObjectImpl(theObject); - if (anObject.IsNull()) - 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); + } // Perform - Handle(GEOM_Object) aNewObject = - GetOperations()->Sew( anObject, theTolerance, false ); + Handle(GEOM_Object) aNewObject = GetOperations()->Sew( objects, theTolerance, false ); if (!GetOperations()->IsDone() || aNewObject.IsNull()) return aGEOMObject._retn(); @@ -347,8 +351,9 @@ GEOM::GEOM_Object_ptr GEOM_IHealingOperations_i::Sew (GEOM::GEOM_Object_ptr theO * SewAllowNonManifold */ //============================================================================= -GEOM::GEOM_Object_ptr GEOM_IHealingOperations_i::SewAllowNonManifold (GEOM::GEOM_Object_ptr theObject, - CORBA::Double theTolerance) +GEOM::GEOM_Object_ptr +GEOM_IHealingOperations_i::SewAllowNonManifold (const GEOM::ListOfGO& theObjects, + CORBA::Double theTolerance) { GEOM::GEOM_Object_var aGEOMObject; @@ -359,14 +364,18 @@ GEOM::GEOM_Object_ptr GEOM_IHealingOperations_i::SewAllowNonManifold (GEOM::GEOM if (theTolerance < 0) return aGEOMObject._retn(); - // Get the object itself - Handle(GEOM_Object) anObject = GetObjectImpl(theObject); - if (anObject.IsNull()) - 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); + } // Perform - Handle(GEOM_Object) aNewObject = - GetOperations()->Sew( anObject, theTolerance, true ); + Handle(GEOM_Object) aNewObject = GetOperations()->Sew( objects, theTolerance, true ); if (!GetOperations()->IsDone() || aNewObject.IsNull()) return aGEOMObject._retn(); @@ -473,9 +482,10 @@ GEOM::GEOM_Object_ptr GEOM_IHealingOperations_i::FuseCollinearEdgesWithinWire * GetFreeBoundary */ //============================================================================= -CORBA::Boolean GEOM_IHealingOperations_i::GetFreeBoundary ( GEOM::GEOM_Object_ptr theObject, - GEOM::ListOfGO_out theClosedWires, - GEOM::ListOfGO_out theOpenWires ) +CORBA::Boolean +GEOM_IHealingOperations_i::GetFreeBoundary ( const GEOM::ListOfGO & theObjects, + GEOM::ListOfGO_out theClosedWires, + GEOM::ListOfGO_out theOpenWires ) { theClosedWires = new GEOM::ListOfGO; theOpenWires = new GEOM::ListOfGO; @@ -483,14 +493,19 @@ CORBA::Boolean GEOM_IHealingOperations_i::GetFreeBoundary ( GEOM::GEOM_Object_pt // Set a not done flag GetOperations()->SetNotDone(); - // Get the object itself - Handle(GEOM_Object) anObject = GetObjectImpl(theObject); - if (anObject.IsNull()) - return false; + // Get the objects + Handle(TColStd_HSequenceOfTransient) anObjects = new TColStd_HSequenceOfTransient(); + for ( size_t i = 0; i < theObjects.length(); ++i ) + { + Handle(GEOM_Object) anObject = GetObjectImpl(theObjects[i]); + if (anObject.IsNull()) + return false; + anObjects->Append( anObject ); + } Handle(TColStd_HSequenceOfTransient) aClosed = new TColStd_HSequenceOfTransient(); Handle(TColStd_HSequenceOfTransient) anOpen = new TColStd_HSequenceOfTransient(); - bool res = GetOperations()->GetFreeBoundary( anObject, aClosed, anOpen ); + bool res = GetOperations()->GetFreeBoundary( anObjects, aClosed, anOpen ); if ( !GetOperations()->IsDone() || !res ) return false; diff --git a/src/GEOM_I/GEOM_IHealingOperations_i.hh b/src/GEOM_I/GEOM_IHealingOperations_i.hh index 091358771..7cbc08d78 100644 --- a/src/GEOM_I/GEOM_IHealingOperations_i.hh +++ b/src/GEOM_I/GEOM_IHealingOperations_i.hh @@ -69,10 +69,10 @@ class GEOM_I_EXPORT GEOM_IHealingOperations_i : GEOM::GEOM_Object_ptr FillHoles (GEOM::GEOM_Object_ptr theObject, const GEOM::short_array& theWires); - GEOM::GEOM_Object_ptr Sew (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr Sew (const GEOM::ListOfGO & theObject, CORBA::Double theTolerance); - GEOM::GEOM_Object_ptr SewAllowNonManifold (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr SewAllowNonManifold (const GEOM::ListOfGO & theObject, CORBA::Double theTolerance); GEOM::GEOM_Object_ptr RemoveInternalFaces (GEOM::GEOM_Object_ptr theCompound); @@ -85,9 +85,9 @@ class GEOM_I_EXPORT GEOM_IHealingOperations_i : GEOM::GEOM_Object_ptr FuseCollinearEdgesWithinWire (GEOM::GEOM_Object_ptr theWire, const GEOM::ListOfGO& theVertices); - CORBA::Boolean GetFreeBoundary(GEOM::GEOM_Object_ptr theObject, - GEOM::ListOfGO_out theClosedWires, - GEOM::ListOfGO_out theOpenWires ); + CORBA::Boolean GetFreeBoundary(const GEOM::ListOfGO& theObjects, + GEOM::ListOfGO_out theClosedWires, + GEOM::ListOfGO_out theOpenWires ); GEOM::GEOM_Object_ptr ChangeOrientation (GEOM::GEOM_Object_ptr theObject); GEOM::GEOM_Object_ptr ChangeOrientationCopy (GEOM::GEOM_Object_ptr theObject); diff --git a/src/GEOM_SWIG/geomBuilder.py b/src/GEOM_SWIG/geomBuilder.py index 93e6da907..0e5975d11 100644 --- a/src/GEOM_SWIG/geomBuilder.py +++ b/src/GEOM_SWIG/geomBuilder.py @@ -517,6 +517,14 @@ def EnumToLong(theItem): if hasattr(theItem, "_v"): ret = theItem._v return ret +## Pack an argument into a list +def ToList( arg ): + if isinstance( arg, list ): + return arg + if hasattr( arg, "__getitem__" ): + return list( arg ) + return [ arg ] + ## Information about closed/unclosed state of shell or wire # @ingroup l1_geomBuilder_auxiliary class info: @@ -4537,7 +4545,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): New GEOM.GEOM_Object, containing the created shell. """ # Example: see GEOM_TestAll.py - anObj = self.ShapesOp.MakeShell(theFacesAndShells) + anObj = self.ShapesOp.MakeShell( ToList( theFacesAndShells )) RaiseIfFailed("MakeShell", self.ShapesOp) self._autoPublish(anObj, theName, "shell") return anObj @@ -6317,7 +6325,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): self._autoPublish(anObj, theName, "suppressFaces") return anObj - ## Sewing of some shapes into single shape. + ## Sewing of faces into a single shell. # @param ListShape Shapes to be processed. # @param theTolerance Required tolerance value. # @param AllowNonManifold Flag that allows non-manifold sewing. @@ -6325,12 +6333,12 @@ 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 processed shape. + # @return New GEOM.GEOM_Object, containing a result shell. # # @ref tui_sewing "Example" def MakeSewing(self, ListShape, theTolerance, AllowNonManifold=False, theName=None): """ - Sewing of some shapes into single shape. + Sewing of faces into a single shell. Parameters: ListShape Shapes to be processed. @@ -6341,30 +6349,29 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): publication is switched on, default value is used for result name. Returns: - New GEOM.GEOM_Object, containing processed shape. + New GEOM.GEOM_Object, containing containing a result shell. """ # Example: see GEOM_TestHealing.py - comp = self.MakeCompound(ListShape) # note: auto-publishing is done in self.Sew() - anObj = self.Sew(comp, theTolerance, AllowNonManifold, theName) + anObj = self.Sew(ListShape, theTolerance, AllowNonManifold, theName) return anObj - ## Sewing of the given object. - # @param theObject Shape to be processed. + ## Sewing of faces into a single shell. + # @param ListShape Shapes to be processed. # @param theTolerance Required tolerance value. # @param AllowNonManifold Flag that allows non-manifold sewing. # @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 processed shape. + # @return New GEOM.GEOM_Object, containing a result shell. @ManageTransactions("HealOp") - def Sew(self, theObject, theTolerance, AllowNonManifold=False, theName=None): + def Sew(self, ListShape, theTolerance, AllowNonManifold=False, theName=None): """ - Sewing of the given object. + Sewing of faces into a single shell. Parameters: - theObject Shape to be processed. + ListShape Shapes to be processed. theTolerance Required tolerance value. AllowNonManifold Flag that allows non-manifold sewing. theName Object name; when specified, this parameter is used @@ -6372,17 +6379,18 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): publication is switched on, default value is used for result name. Returns: - New GEOM.GEOM_Object, containing processed shape. + New GEOM.GEOM_Object, containing a result shell. """ # Example: see MakeSewing() above theTolerance,Parameters = ParseParameters(theTolerance) if AllowNonManifold: - anObj = self.HealOp.SewAllowNonManifold(theObject, theTolerance) + anObj = self.HealOp.SewAllowNonManifold( ToList( ListShape ), theTolerance) else: - anObj = self.HealOp.Sew(theObject, theTolerance) + anObj = self.HealOp.Sew( ToList( ListShape ), theTolerance) # To avoid script failure in case of good argument shape + # (Fix of test cases geom/bugs11/L7,L8) if self.HealOp.GetErrorCode() == "ShHealOper_NotError_msg": - return theObject + return anObj RaiseIfFailed("Sew", self.HealOp) anObj.SetParameters(Parameters) self._autoPublish(anObj, theName, "sewed") @@ -6707,7 +6715,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): theOpenWires: Open wires on the free boundary of the given shape. """ # Example: see GEOM_TestHealing.py - anObj = self.HealOp.GetFreeBoundary(theObject) + anObj = self.HealOp.GetFreeBoundary( ToList( theObject )) RaiseIfFailed("GetFreeBoundary", self.HealOp) self._autoPublish(anObj[1], theName, "closedWire") self._autoPublish(anObj[2], theName, "openWire") diff --git a/src/RepairGUI/RepairGUI_FreeBoundDlg.cxx b/src/RepairGUI/RepairGUI_FreeBoundDlg.cxx index 4bb57553f..08ff45edf 100644 --- a/src/RepairGUI/RepairGUI_FreeBoundDlg.cxx +++ b/src/RepairGUI/RepairGUI_FreeBoundDlg.cxx @@ -261,8 +261,11 @@ bool RepairGUI_FreeBoundDlg::execute (ObjectList& objects) { GEOM::ListOfGO_var aClosed, anOpen; + GEOM::ListOfGO_var objList = new GEOM::ListOfGO; + objList->length(1); + objList[0] = myObj; GEOM::GEOM_IHealingOperations_var anOper = GEOM::GEOM_IHealingOperations::_narrow(getOperation()); - bool result = anOper->GetFreeBoundary(myObj, aClosed, anOpen); + bool result = anOper->GetFreeBoundary(objList, aClosed, anOpen); if (result) { myNbClosed = aClosed->length(); diff --git a/src/RepairGUI/RepairGUI_RemoveHolesDlg.cxx b/src/RepairGUI/RepairGUI_RemoveHolesDlg.cxx index 6206da990..56b5aa004 100644 --- a/src/RepairGUI/RepairGUI_RemoveHolesDlg.cxx +++ b/src/RepairGUI/RepairGUI_RemoveHolesDlg.cxx @@ -330,8 +330,11 @@ bool RepairGUI_RemoveHolesDlg::execute (ObjectList& objects) // highlight them (add to objects), display message dialog GEOM::ListOfGO_var aClosed, anOpen; + GEOM::ListOfGO_var objList = new GEOM::ListOfGO; + objList->length(1); + objList[0] = myObject; GEOM::GEOM_IHealingOperations_var anOper = GEOM::GEOM_IHealingOperations::_narrow(getOperation()); - aResult = anOper->GetFreeBoundary(myObject, aClosed, anOpen); + aResult = anOper->GetFreeBoundary(objList, aClosed, anOpen); if (aResult) { myClosed = aClosed->length(); diff --git a/src/RepairGUI/RepairGUI_SewingDlg.cxx b/src/RepairGUI/RepairGUI_SewingDlg.cxx index 34cc7ddb6..e26f26157 100644 --- a/src/RepairGUI/RepairGUI_SewingDlg.cxx +++ b/src/RepairGUI/RepairGUI_SewingDlg.cxx @@ -117,7 +117,7 @@ void RepairGUI_SewingDlg::Init() /* init variables */ myEditCurrentArgument = GroupPoints->LineEdit1; - myObject = GEOM::GEOM_Object::_nil(); + myObjects.clear(); //myGeomGUI->SetState( 0 ); initSelection(); @@ -166,7 +166,7 @@ bool RepairGUI_SewingDlg::ClickOnApply() initName(); GroupPoints->LineEdit1->setText( "" ); - myObject = GEOM::GEOM_Object::_nil(); + myObjects.clear(); initSelection(); @@ -182,17 +182,13 @@ void RepairGUI_SewingDlg::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 ); } } @@ -235,7 +231,7 @@ void RepairGUI_SewingDlg::ActivateThisDialog() SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); GroupPoints->LineEdit1->setText( "" ); - myObject = GEOM::GEOM_Object::_nil(); + myObjects.clear(); myClosed = -1; myOpen = -1; @@ -273,7 +269,7 @@ bool RepairGUI_SewingDlg::isValid( QString& msg ) { myClosed = -1; bool ok = myTolEdt->isValid( msg, !IsPreview() ); - return !myObject->_is_nil() && ( IsPreview() || myTolEdt->value() > 0. ) && ok; + return !myObjects.isEmpty() && ( IsPreview() || myTolEdt->value() > 0. ) && ok; } //================================================================================= @@ -285,10 +281,15 @@ bool RepairGUI_SewingDlg::execute( ObjectList& objects ) bool aResult = false; GEOM::GEOM_IHealingOperations_var anOper = GEOM::GEOM_IHealingOperations::_narrow( getOperation() ); + GEOM::ListOfGO_var objList = new GEOM::ListOfGO; + objList->length( myObjects.count() ); + for ( int i = 0; i < myObjects.count(); ++i ) + objList[i] = myObjects[i].copy(); + if ( IsPreview() ) { // called from onDetect(): detect free boundary edges, highlight them (add to objects), display message dialog GEOM::ListOfGO_var aClosed, anOpen; - aResult = anOper->GetFreeBoundary( myObject, aClosed, anOpen ); + aResult = anOper->GetFreeBoundary( objList, aClosed, anOpen ); if ( aResult ) { myClosed = aClosed->length(); @@ -306,9 +307,9 @@ bool RepairGUI_SewingDlg::execute( ObjectList& objects ) GEOM::GEOM_Object_var anObj; if (myAllowNonManifoldChk->isChecked()) { - anObj = anOper->SewAllowNonManifold( myObject, myTolEdt->value() ); + anObj = anOper->SewAllowNonManifold( objList, myTolEdt->value() ); } else { - anObj = anOper->Sew( myObject, myTolEdt->value() ); + anObj = anOper->Sew( objList, myTolEdt->value() ); } aResult = !anObj->_is_nil(); @@ -334,6 +335,7 @@ bool RepairGUI_SewingDlg::execute( ObjectList& objects ) void RepairGUI_SewingDlg::initSelection() { TColStd_MapOfInteger aTypes; + aTypes.Add( GEOM_FACE ); aTypes.Add( GEOM_SHELL ); aTypes.Add( GEOM_SOLID ); aTypes.Add( GEOM_COMPOUND ); diff --git a/src/RepairGUI/RepairGUI_SewingDlg.h b/src/RepairGUI/RepairGUI_SewingDlg.h index 264a9b6e7..f1945009c 100644 --- a/src/RepairGUI/RepairGUI_SewingDlg.h +++ b/src/RepairGUI/RepairGUI_SewingDlg.h @@ -42,7 +42,7 @@ class RepairGUI_SewingDlg : public GEOMBase_Skeleton { Q_OBJECT -public: + public: RepairGUI_SewingDlg( GeometryGUI*, QWidget* = 0, bool = false ); ~RepairGUI_SewingDlg(); @@ -51,33 +51,33 @@ protected: virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid( QString& ); virtual bool execute( ObjectList& ); - + private: void Init(); void enterEvent( QEvent* ); void initSelection(); private: - GEOM::GEOM_Object_var myObject; + QList myObjects; DlgRef_1SelExt* GroupPoints; QCheckBox* myAllowNonManifoldChk; SalomeApp_DoubleSpinBox* myTolEdt; QPushButton* myFreeBoundBtn; - + int myClosed; // Number of free closed boundaries detected. Calculated in execute(), used in onDetect(). int myOpen; // Number of free open boundaries detected. Calculated in execute(), used in onDetect(). - + private slots: void ClickOnOk(); bool ClickOnApply(); - + void ActivateThisDialog(); - + void LineEditReturnPressed(); void SelectionIntoArgument(); void SetEditCurrentArgument(); - + void onDetect(); }; diff --git a/src/ShHealOper/ShHealOper_Sewing.cxx b/src/ShHealOper/ShHealOper_Sewing.cxx index 183b17a46..156808c15 100644 --- a/src/ShHealOper/ShHealOper_Sewing.cxx +++ b/src/ShHealOper/ShHealOper_Sewing.cxx @@ -248,15 +248,31 @@ Standard_Boolean ShHealOper_Sewing::getModifications(const TopoDS_Shape& theShap Standard_Boolean ShHealOper_Sewing::isSewed(const TopoDS_Shape& theShape) const { - Standard_Integer nbNewShells =0; - Standard_Integer nbOldShells =0; - TopExp_Explorer aExpShells(theShape,TopAbs_SHELL); - for( ; aExpShells.More(); aExpShells.Next()) - nbNewShells++; - for( aExpShells.Init(myInitShape,TopAbs_SHELL); aExpShells.More(); aExpShells.Next()) - nbOldShells++; - return (nbNewShells != nbOldShells); + // Standard_Integer nbNewShells =0; + // Standard_Integer nbOldShells =0; + // TopExp_Explorer aExpShells(theShape,TopAbs_SHELL); + // for( ; aExpShells.More(); aExpShells.Next()) + // nbNewShells++; + // for( aExpShells.Init(myInitShape,TopAbs_SHELL); aExpShells.More(); aExpShells.Next()) + // nbOldShells++; + // return (nbNewShells != nbOldShells); + + // EAP, 22745: [EDF] Improvement of Sewing operation + // now myInitShape is ALWAYS a compound of faces -> no shells + int nbNew = 0, nbOld = 0; + TopExp_Explorer exp; + for ( exp.Init( theShape, TopAbs_VERTEX ); exp.More(); exp.Next() ) ++nbNew; + for ( exp.Init( myInitShape, TopAbs_VERTEX ); exp.More(); exp.Next() ) ++nbOld; + if ( nbNew != nbOld ) + return true; + for ( exp.Init( theShape, TopAbs_EDGE ); exp.More(); exp.Next() ) ++nbNew; + for ( exp.Init( myInitShape, TopAbs_EDGE ); exp.More(); exp.Next() ) ++nbOld; + if ( nbNew != nbOld ) + return true; + + return false; } + //======================================================================= //function : deleteFreeEdges //purpose :