Salome HOME
IMPs 0020745 (GetVertexNearPoint and GetShapesNearPoint) and 0020851 (LimitTolerance).
authorjfa <jfa@opencascade.com>
Wed, 14 Jul 2010 07:16:07 +0000 (07:16 +0000)
committerjfa <jfa@opencascade.com>
Wed, 14 Jul 2010 07:16:07 +0000 (07:16 +0000)
30 files changed:
doc/salome/gui/GEOM/images/limit_tolerance_dlg.png [new file with mode: 0644]
doc/salome/gui/GEOM/input/limit_tolerance_operation.doc [new file with mode: 0644]
doc/salome/gui/GEOM/input/repairing_operations.doc
doc/salome/gui/GEOM/input/tui_repairing_operations.doc
doc/salome/gui/GEOM/input/tui_test_others.doc
idl/GEOM_Gen.idl
resources/Makefile.am
resources/limit_tolerance.png [new file with mode: 0644]
src/GEOMGUI/GEOM_images.ts
src/GEOMGUI/GEOM_msg_en.ts
src/GEOMGUI/GeometryGUI.cxx
src/GEOMGUI/GeometryGUI_Operations.h
src/GEOMImpl/GEOMImpl_HealingDriver.cxx
src/GEOMImpl/GEOMImpl_HealingDriver.hxx
src/GEOMImpl/GEOMImpl_IBlocksOperations.cxx
src/GEOMImpl/GEOMImpl_IBlocksOperations.hxx
src/GEOMImpl/GEOMImpl_IHealing.hxx
src/GEOMImpl/GEOMImpl_IHealingOperations.cxx
src/GEOMImpl/GEOMImpl_IHealingOperations.hxx
src/GEOMImpl/GEOMImpl_Types.hxx
src/GEOM_I/GEOM_IBlocksOperations_i.cc
src/GEOM_I/GEOM_IBlocksOperations_i.hh
src/GEOM_I/GEOM_IHealingOperations_i.cc
src/GEOM_I/GEOM_IHealingOperations_i.hh
src/GEOM_SWIG/GEOM_TestOthers.py
src/GEOM_SWIG/geompyDC.py
src/RepairGUI/Makefile.am
src/RepairGUI/RepairGUI.cxx
src/RepairGUI/RepairGUI_LimitToleranceDlg.cxx [new file with mode: 0644]
src/RepairGUI/RepairGUI_LimitToleranceDlg.h [new file with mode: 0644]

diff --git a/doc/salome/gui/GEOM/images/limit_tolerance_dlg.png b/doc/salome/gui/GEOM/images/limit_tolerance_dlg.png
new file mode 100644 (file)
index 0000000..98adfc4
Binary files /dev/null and b/doc/salome/gui/GEOM/images/limit_tolerance_dlg.png differ
diff --git a/doc/salome/gui/GEOM/input/limit_tolerance_operation.doc b/doc/salome/gui/GEOM/input/limit_tolerance_operation.doc
new file mode 100644 (file)
index 0000000..7f69265
--- /dev/null
@@ -0,0 +1,23 @@
+/*!
+
+\page limit_tolerance_operation_page Limit Tolerance
+
+\n To produce a <b>Limit Tolerance</b> operation in the <b>Main
+   Menu</b> select <b>Repair - > Limit Tolerance</b>.
+
+\n It is possible on all kind of shapes.
+
+\n The \b Result will be a \b GEOM_Object. 
+
+\n <b>TUI Command:</b> <em>geompy.LimitTolerance(Shape, Tolerance),</em>
+ where \em Shape is a shape with presumably incorrect tolerance, \em
+ Tolerance is a desired value of tolerance.
+
+\image html limit_tolerance_dlg.png
+
+\n <b>Arguments:</b> Name + 1 shape + 1 value (new tolerance).
+
+Our <b>TUI Scripts</b> provide you with useful examples of the use of
+\ref tui_limit_tolerance "Repairing Operations".
+
+*/
index 542f5c25e159b14b7005cffd7f2afc09263e2b7a..592c1b65346ae1a7df5fdc20c76b8e19c7ad1cb2 100644 (file)
@@ -17,6 +17,8 @@ holes with free boundaries on a selected face.</li>
 <li>\subpage sewing_operation_page "Sewing" - sews faces or shells.</li>
 <li>\subpage glue_faces_operation_page "Glue faces" - unites
 coincident faces within the given tolerance.</li>
+<li>\subpage limit_tolerance_operation_page "Limit Tolerance" - tries
+to set new tolerance value for the given shape.</li>
 <li>\subpage add_point_on_edge_operation_page "Add point on edge" -
 splits an edge in two.</li>
 <li>\subpage change_orientation_operation_page "Change orientation" -
index 98dccc6f0e461a89ec71474eec60a5a5c5e03240..ff562631f9abc14a80abc5c57b6f79dd98b82e6b 100644 (file)
@@ -289,6 +289,31 @@ gg.createAndDisplayGO(id_glue)
 gg.setDisplayMode(id_glue,1) 
 \endcode
 
+\anchor tui_limit_tolerance
+<br><h2>Limit Tolerance</h2>
+
+\code
+import geompy
+gg = salome.ImportComponentGUI("GEOM")
+
+# import initial topology
+bad_shape = geompy.ImportBREP("my_bad_shape.brep")
+
+# limit tolerance
+tolerance = 1e-07
+good_shape = geompy.LimitTolerance(bad_shape, tolerance)
+
+# add objects in the study
+id_bad_shape  = geompy.addToStudy(bad_shape, "My Bad Shape")
+id_good_shape = geompy.addToStudy(good_shape, "My Good Shape")
+
+# display the results
+gg.createAndDisplayGO(id_bad_shape)
+gg.setDisplayMode(id_bad_shape, 1)
+gg.createAndDisplayGO(id_good_shape)
+gg.setDisplayMode(id_good_shape, 1) 
+\endcode
+
 \anchor tui_add_point_on_edge
 <br><h2>Add Point on Edge</h2>
 
index 443326feaf08f8ec8bacb07295b968903ea4c739..e2c6d43b4f00d17f2242a361eca5c7e8a874fdb4 100644 (file)
 \anchor swig_GetPoint
 \until blocksComp (-50, -50, -50)
 
+\anchor swig_GetVertexNearPoint
+\until near (40,  40,  40)
+
+\anchor swig_GetEdge
+\until by two points
+
 \anchor swig_GetEdgeNearPoint
 \until edge near point
 
 \anchor swig_GetBlockByParts
 \until "b0 image"
 
+\anchor swig_GetShapesNearPoint
+\until "faces near point"
+
 \anchor swig_GetShapesOnPlane
 \until Face on Plane
 
index 164969e51be1c3a7fa9ea0d4a195abf89ac735b9..309d9bbe84621d75bc6d93e174a76b77c82642d2 100644 (file)
@@ -1905,6 +1905,15 @@ module GEOM
                          in double      theZ,
                          in double      theEpsilon);
 
+    /*!
+     *  Find a vertex of the given shape, which has minimal distance to the given point.
+     *  \param theShape Any shape.
+     *  \param thePoint Point, close to the desired vertex.
+     *  \return New GEOM_Object, containing the found vertex.
+     */
+    GEOM_Object GetVertexNearPoint (in GEOM_Object theShape,
+                                    in GEOM_Object thePoint);
+
     /*!
      *  Get an edge, found in the given shape by two given vertices.
      *  \param theShape Block or a compound of blocks.
@@ -1973,6 +1982,22 @@ module GEOM
     GEOM_Object GetFaceByNormale (in GEOM_Object theBlock,
                                  in GEOM_Object theVector);
 
+    /*!
+     *  Find all subshapes of type \a theShapeType of the given shape,
+     *  which have minimal distance to the given point.
+     *  \param theShape Any shape.
+     *  \param thePoint Point, close to the desired shape.
+     *  \param theShapeType Defines what kind of subshapes is searched.
+     *  \param theTolerance The tolerance for distances comparison. All shapes
+     *                      with distances to the given point in interval
+     *                      [minimal_distance, minimal_distance + theTolerance] will be gathered.
+     *  \return New GEOM_Object, containing a group of all found shapes.
+     */
+    GEOM_Object GetShapesNearPoint (in GEOM_Object theShape,
+                                    in GEOM_Object thePoint,
+                                    in long        theShapeType,
+                                    in double      theTolerance);
+
     /*!
      *  Extract blocks from blocks compounds
      */
@@ -2726,6 +2751,14 @@ module GEOM
     GEOM_Object ChangeOrientation (in GEOM_Object theObject);
     GEOM_Object ChangeOrientationCopy (in GEOM_Object theObject);
 
+    /*!
+     *  Try to limit tolerance of the given object by value \a theTolerance.
+     *  \param theObject Shape to be processed.
+     *  \param theTolerance Required tolerance value.
+     *  \return New GEOM_Object, containing processed shape.
+     */
+    GEOM_Object LimitTolerance (in GEOM_Object theObject, in double theTolerance);
+
   };
 
   /*!
index 3ba2946e012b9f214ae732cbf27bfc964a424feb..f8bc0a9dcf168989eea3910632d529f78177ee81 100644 (file)
@@ -93,6 +93,7 @@ filletface.png                        \
 filling.png                    \
 fuse.png                       \
 geometry.png                   \
+limit_tolerance.png            \
 line.png                       \
 line2points.png                        \
 line2faces.png                 \
diff --git a/resources/limit_tolerance.png b/resources/limit_tolerance.png
new file mode 100644 (file)
index 0000000..35f2080
Binary files /dev/null and b/resources/limit_tolerance.png differ
index 3dab5a40488426d1810e1c6b698834d88e541754..e41de1d956ae89e7be97933ecdde9606d0c01ee5 100644 (file)
             <source>ICON_DLG_GLUE_FACES2</source>
             <translation>glue2.png</translation>
         </message>
+        <message>
+            <source>ICON_DLG_LIMIT_TOLERANCE</source>
+            <translation>limit_tolerance.png</translation>
+        </message>
         <message>
             <source>ICON_DLG_INERTIA</source>
             <translation>axisinertia.png</translation>
             <source>ICO_GLUE_FACES</source>
             <translation>glue.png</translation>
         </message>
+        <message>
+            <source>ICO_LIMIT_TOLERANCE</source>
+            <translation>limit_tolerance.png</translation>
+        </message>
         <message>
             <source>ICO_GROUP_CREATE</source>
             <translation>group_new.png</translation>
index aac0da797f0ddb53b165ba2f8e82dd6e491993d8..9a47a49af37c0e1aa3f03f9747efdf1f445f1fd2 100644 (file)
@@ -771,6 +771,10 @@ Please, select face, shell or solid and try again</translation>
             <source>GEOM_GLUE_TITLE</source>
             <translation>Glue faces</translation>
         </message>
+        <message>
+            <source>GEOM_LIMIT_TOLERANCE_TITLE</source>
+            <translation>Limit tolerance</translation>
+        </message>
         <message>
             <source>GEOM_HEIGHT</source>
             <translation>Height :</translation>
@@ -2055,6 +2059,10 @@ Please, select face, shell or solid and try again</translation>
             <source>GLUE_NEW_OBJ_NAME</source>
             <translation>Glue</translation>
         </message>
+        <message>
+            <source>LIMIT_TOLERANCE_NEW_OBJ_NAME</source>
+            <translation>Limit_tolerance</translation>
+        </message>
         <message>
             <source>MEN_ALL_SEL_ONLY</source>
             <translation>Select All</translation>
@@ -2307,6 +2315,10 @@ Please, select face, shell or solid and try again</translation>
             <source>MEN_ISOS</source>
             <translation>Isos</translation>
         </message>
+        <message>
+            <source>MEN_LIMIT_TOLERANCE</source>
+            <translation>Limit tolerance</translation>
+        </message>
         <message>
             <source>MEN_LINE</source>
             <translation>Line</translation>
@@ -2955,6 +2967,10 @@ Please, select face, shell or solid and try again</translation>
             <source>STB_LINE</source>
             <translation>Create a line</translation>
         </message>
+        <message>
+            <source>STB_LIMIT_TOLERANCE</source>
+            <translation>Limit tolerance</translation>
+        </message>
         <message>
             <source>STB_LOCAL_CS</source>
             <translation>Create a local coordinate system</translation>
@@ -3479,6 +3495,10 @@ Please, select face, shell or solid and try again</translation>
             <source>TOP_LINE</source>
             <translation>Create a line</translation>
         </message>
+        <message>
+            <source>TOP_LIMIT_TOLERANCE</source>
+            <translation>Limit tolerance</translation>
+        </message>
         <message>
             <source>TOP_LOCAL_CS</source>
             <translation>Create a local coordinate system</translation>
index 1edeb1adad602384dd82f357b1165382b3dfdb3d..44d9898fd995093d86595c34710ccc0e8efa45e6 100644 (file)
 //
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+//  GEOM GEOMGUI : GUI for Geometry component
+//  File   : GeometryGUI.cxx
+//  Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
 
-// GEOM GEOMGUI : GUI for Geometry component
-// File   : GeometryGUI.cxx
-// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
-//
 #include <Standard_math.hxx>  // E.A. must be included before Python.h to fix compilation on windows
 #include "Python.h"
 #include "GeometryGUI.h"
@@ -476,6 +475,7 @@ void GeometryGUI::OnGUIEvent( int id )
   case GEOMOp::OpFreeFaces:        // MENU MEASURE - FREE FACES
   case GEOMOp::OpOrientation:      // MENU REPAIR - CHANGE ORIENTATION
   case GEOMOp::OpGlueFaces:        // MENU REPAIR - GLUE FACES
+  case GEOMOp::OpLimitTolerance:   // MENU REPAIR - LIMIT TOLERANCE
   case GEOMOp::OpRemoveExtraEdges: // MENU REPAIR - REMOVE EXTRA EDGES
     libName = "RepairGUI";
     break;
@@ -580,7 +580,7 @@ void GeometryGUI::createGeomAction( const int id, const QString& label, const QS
   createAction( id,
                tr( QString( "TOP_%1" ).arg( label ).toLatin1().constData() ),
                icon,
-               tr( QString( "MEN_%1" ).arg( label ).toLatin1().constData() ), 
+               tr( QString( "MEN_%1" ).arg( label ).toLatin1().constData() ),
                tr( QString( "STB_%1" ).arg( label ).toLatin1().constData() ),
                accel,
                application()->desktop(),
@@ -706,6 +706,7 @@ void GeometryGUI::initialize( CAM_Application* app )
 
   createGeomAction( GEOMOp::OpSewing,           "SEWING" );
   createGeomAction( GEOMOp::OpGlueFaces,        "GLUE_FACES" );
+  createGeomAction( GEOMOp::OpLimitTolerance,   "LIMIT_TOLERANCE" );
   createGeomAction( GEOMOp::OpSuppressFaces,    "SUPPRESS_FACES" );
   createGeomAction( GEOMOp::OpSuppressHoles,    "SUPPERSS_HOLES" );
   createGeomAction( GEOMOp::OpShapeProcess,     "SHAPE_PROCESS" );
@@ -765,7 +766,7 @@ void GeometryGUI::initialize( CAM_Application* app )
   createGeomAction( GEOMOp::OpShowChildren,     "POP_SHOW_CHILDREN" );
   createGeomAction( GEOMOp::OpHideChildren,     "POP_HIDE_CHILDREN" );
   createGeomAction( GEOMOp::OpPointMarker,      "POP_POINT_MARKER" );
-  
+
   createGeomAction( GEOMOp::OpPipeTShape, "PIPETSHAPE" );
 //   createGeomAction( GEOMOp::OpPipeTShapeGroups, "PIPETSHAPEGROUPS" );
   //@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@//
@@ -891,6 +892,7 @@ void GeometryGUI::initialize( CAM_Application* app )
   createMenu( GEOMOp::OpSuppressHoles,   repairId, -1 );
   createMenu( GEOMOp::OpSewing,          repairId, -1 );
   createMenu( GEOMOp::OpGlueFaces,       repairId, -1 );
+  createMenu( GEOMOp::OpLimitTolerance,  repairId, -1 );
   createMenu( GEOMOp::OpAddPointOnEdge,  repairId, -1 );
   //createMenu( GEOMOp::OpFreeBoundaries,  repairId, -1 );
   //createMenu( GEOMOp::OpFreeFaces,       repairId, -1 );
@@ -1210,7 +1212,7 @@ bool GeometryGUI::activateModule( SUIT_Study* study )
   SALOME_ListIO selected;
   sm->selectedObjects( selected );
   sm->clearSelected();
-  
+
   // disable OCC selectors
   getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
   QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
@@ -1473,7 +1475,7 @@ void GeometryGUI::createPreferences()
   setPreferenceProperty( genGroup, "columns", 2 );
 
   int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), genGroup,
-                                LightApp_Preferences::Selector, 
+                                LightApp_Preferences::Selector,
                                 "Geometry", "display_mode" );
 
   addPreference( tr( "PREF_SHADING_COLOR" ), genGroup,
@@ -1499,36 +1501,36 @@ void GeometryGUI::createPreferences()
 
   int defl = addPreference( tr( "PREF_DEFLECTION" ), genGroup,
                             LightApp_Preferences::DblSpin, "Geometry", "deflection_coeff" );
-  
+
   // Quantities with individual precision settings
   int precGroup = addPreference( tr( "GEOM_PREF_GROUP_PRECISION" ), tabId );
   setPreferenceProperty( precGroup, "columns", 2 );
-  
+
   const int nbQuantities = 8;
   int prec[nbQuantities], ii = 0;
   prec[ii++] = addPreference( tr( "GEOM_PREF_length_precision" ), precGroup,
-                            LightApp_Preferences::IntSpin, "Geometry", "length_precision" );  
+                              LightApp_Preferences::IntSpin, "Geometry", "length_precision" );
   prec[ii++] = addPreference( tr( "GEOM_PREF_angle_precision" ), precGroup,
-                            LightApp_Preferences::IntSpin, "Geometry", "angle_precision" );
+                              LightApp_Preferences::IntSpin, "Geometry", "angle_precision" );
   prec[ii++] = addPreference( tr( "GEOM_PREF_len_tol_precision" ), precGroup,
-                            LightApp_Preferences::IntSpin, "Geometry", "len_tol_precision" );
+                              LightApp_Preferences::IntSpin, "Geometry", "len_tol_precision" );
   prec[ii++] = addPreference( tr( "GEOM_PREF_ang_tol_precision" ), precGroup,
-                            LightApp_Preferences::IntSpin, "Geometry", "ang_tol_precision" );  
+                              LightApp_Preferences::IntSpin, "Geometry", "ang_tol_precision" );
   prec[ii++] = addPreference( tr( "GEOM_PREF_weight_precision" ), precGroup,
-                            LightApp_Preferences::IntSpin, "Geometry", "weight_precision" ); 
+                              LightApp_Preferences::IntSpin, "Geometry", "weight_precision" );
   prec[ii++] = addPreference( tr( "GEOM_PREF_density_precision" ), precGroup,
-                            LightApp_Preferences::IntSpin, "Geometry", "density_precision" );   
+                              LightApp_Preferences::IntSpin, "Geometry", "density_precision" );
   prec[ii++] = addPreference( tr( "GEOM_PREF_parametric_precision" ), precGroup,
-                            LightApp_Preferences::IntSpin, "Geometry", "parametric_precision" );
+                              LightApp_Preferences::IntSpin, "Geometry", "parametric_precision" );
   prec[ii  ] = addPreference( tr( "GEOM_PREF_param_tol_precision" ), precGroup,
-                            LightApp_Preferences::IntSpin, "Geometry", "param_tol_precision" );  
-  
+                              LightApp_Preferences::IntSpin, "Geometry", "param_tol_precision" );
+
   // Set property for precision value for spinboxes
   for ( ii = 0; ii < nbQuantities; ii++ ){
     setPreferenceProperty( prec[ii], "min", -14 );
     setPreferenceProperty( prec[ii], "max", 14 );
     setPreferenceProperty( prec[ii], "precision", 2 );
-  }  
+  }
 
   int VertexGroup = addPreference( tr( "PREF_GROUP_VERTEX" ), tabId );
   setPreferenceProperty( VertexGroup, "columns", 2 );
index 311dbbe76e4c4a48bd8bf22a75d15573e75523b2..c027220c936dcfec888a1ff08cd25f7322f43266 100644 (file)
 //
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
-
 //  File   : GeometryGUI_Operations.h
 //  Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
-//
+
 #ifndef GEOMETRYGUI_OPERATIONS_H
 #define GEOMETRYGUI_OPERATIONS_H
 
@@ -131,6 +130,7 @@ namespace GEOMOp {
     OpOrientation       = 4009,   // MENU REPAIR - CHANGE ORIENTATION
     OpGlueFaces         = 4010,   // MENU REPAIR - GLUE FACES
     OpRemoveExtraEdges  = 4011,   // MENU REPAIR - REMOVE EXTRA EDGES
+    OpLimitTolerance    = 4012,   // MENU REPAIR - LIMIT TOLERANCE
     // MeasureGUI ----------------//--------------------------------
     OpProperties        = 5000,   // MENU MEASURES - PROPERTIES
     OpCenterMass        = 5001,   // MENU MEASURES - CENTRE OF MASS
@@ -160,6 +160,6 @@ namespace GEOMOp {
 //     OpPipeTShapeGroups  = 10002,  // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE GROUPS
     //@@ insert new functions before this line @@ do not remove this line @@//
   };
-} 
+}
 
 #endif // GEOMETRYGUI_OPERATIONS_H
index 5670d099b6c17b7bcebc21ebf5878a5ad80b1542..d59b07203200ee6c6cfedf9b1e1bc73dafe86378 100644 (file)
@@ -18,7 +18,6 @@
 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
 
 #include <Standard_Stream.hxx>
 
 #include <TopoDS_Iterator.hxx>
 #include <TopTools_IndexedMapOfShape.hxx>
 
+#include <TColStd_IndexedDataMapOfTransientTransient.hxx>
+#include <TNaming_CopyShape.hxx>
+#include <ShapeFix_ShapeTolerance.hxx>
+#include <ShapeFix_Shape.hxx>
+#include <BRepCheck_Analyzer.hxx>
+
 #include <Precision.hxx>
 
 #include <StdFail_NotDone.hxx>
@@ -126,6 +131,9 @@ Standard_Integer GEOMImpl_HealingDriver::Execute(TFunction_Logbook& log) const
   case CHANGE_ORIENTATION:
     ChangeOrientation(&HI, anOriginalShape, aShape);
     break;
+  case LIMIT_TOLERANCE:
+    LimitTolerance(&HI, anOriginalShape, aShape);
+    break;
   default:
     return 0;
   }
@@ -465,6 +473,36 @@ Standard_Boolean GEOMImpl_HealingDriver::ChangeOrientation (GEOMImpl_IHealing* t
   return aResult;
 }
 
+//=======================================================================
+//function : LimitTolerance
+//purpose  :
+//=======================================================================
+void GEOMImpl_HealingDriver::LimitTolerance (GEOMImpl_IHealing* theHI,
+                                             const TopoDS_Shape& theOriginalShape,
+                                             TopoDS_Shape& theOutShape) const
+{
+  Standard_Real aTol = theHI->GetTolerance();
+  if (aTol < Precision::Confusion())
+    aTol = Precision::Confusion();
+
+  // 1. Make a copy to prevent the original shape changes.
+  TopoDS_Shape aShapeCopy;
+  TColStd_IndexedDataMapOfTransientTransient aMapTShapes;
+  TNaming_CopyShape::CopyTool(theOriginalShape, aMapTShapes, aShapeCopy);
+
+  // 2. Limit tolerance.
+  ShapeFix_ShapeTolerance aSFT;
+  aSFT.LimitTolerance(aShapeCopy, aTol, aTol, TopAbs_SHAPE);
+
+  // 3. Fix obtained shape.
+  Handle(ShapeFix_Shape) aSfs = new ShapeFix_Shape (aShapeCopy);
+  aSfs->Perform();
+  theOutShape = aSfs->Shape();
+
+  BRepCheck_Analyzer ana (theOutShape, Standard_True);
+  if (!ana.IsValid())
+    StdFail_NotDone::Raise("Non valid shape result");
+}
 
 //=======================================================================
 //function :  GEOMImpl_HealingDriver_Type_
index 344cf770c6972ede94fed26b50ca3696eb6f3880..4e4b44b4999b0f6d1f8165806439f45f3f3b0d49 100644 (file)
 //
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
-
 //  File   : GEOMImpl_HealingDriver.hxx
 //  Module : GEOMImpl
-//
+
 #ifndef _GEOMImpl_HealingDriver_HeaderFile
 #define _GEOMImpl_HealingDriver_HeaderFile
 
@@ -156,7 +155,7 @@ Standard_EXPORT ~GEOMImpl_HealingDriver() {};
  //
 Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_HealingDriver_Type_();
 Standard_EXPORT const Handle(Standard_Type)& DynamicType() const  { return STANDARD_TYPE(GEOMImpl_HealingDriver) ; }
-Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_HealingDriver) == AType || TFunction_Driver::IsKind(AType)); } 
+Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_HealingDriver) == AType || TFunction_Driver::IsKind(AType)); }
 
 private:
 Standard_Boolean ShapeProcess  ( GEOMImpl_IHealing*, const TopoDS_Shape&, TopoDS_Shape& ) const;
@@ -167,7 +166,7 @@ Standard_Boolean RemoveHoles   ( GEOMImpl_IHealing*, const TopoDS_Shape&, TopoDS
 Standard_Boolean Sew           ( GEOMImpl_IHealing*, const TopoDS_Shape&, TopoDS_Shape& ) const;
 Standard_Boolean AddPointOnEdge( GEOMImpl_IHealing*, const TopoDS_Shape&, TopoDS_Shape& ) const;
 Standard_Boolean ChangeOrientation( GEOMImpl_IHealing*, const TopoDS_Shape&, TopoDS_Shape& ) const;
-
+void             LimitTolerance( GEOMImpl_IHealing*, const TopoDS_Shape&, TopoDS_Shape& ) const;
 
 };
 
index 3aeca30083d730350ee13eda680200259a087b26..b4c4ebd77966e4ed495a393afc717d14135a605a 100644 (file)
@@ -569,6 +569,81 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetPoint
   return aResult;
 }
 
+//=============================================================================
+/*!
+ *  GetVertexNearPoint
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetVertexNearPoint
+                                               (Handle(GEOM_Object) theShape,
+                                                Handle(GEOM_Object) thePoint)
+{
+  SetErrorCode(KO);
+
+  // New Point object
+  Handle(GEOM_Object) aResult;
+
+  // Arguments
+  if (theShape.IsNull() || thePoint.IsNull()) return NULL;
+
+  TopoDS_Shape aBlockOrComp = theShape->GetValue();
+  TopoDS_Shape aPoint       = thePoint->GetValue();
+  if (aBlockOrComp.IsNull() || aPoint.IsNull()) {
+    SetErrorCode("Given shape is null");
+    return NULL;
+  }
+
+  if (aPoint.ShapeType() != TopAbs_VERTEX) {
+    SetErrorCode("Element for vertex identification is not a vertex");
+    return NULL;
+  }
+
+  TopoDS_Vertex aVert = TopoDS::Vertex(aPoint);
+  gp_Pnt aP = BRep_Tool::Pnt(aVert);
+
+  // Compute the Vertex value
+  TopoDS_Shape V;
+  bool isFound = false;
+  Standard_Real aDist = RealLast();
+  TopTools_MapOfShape mapShape;
+
+  TopExp_Explorer exp (aBlockOrComp, TopAbs_VERTEX);
+  for (; exp.More(); exp.Next()) {
+    if (mapShape.Add(exp.Current())) {
+      TopoDS_Vertex aVi = TopoDS::Vertex(exp.Current());
+      gp_Pnt aPi = BRep_Tool::Pnt(aVi);
+      Standard_Real aDisti = aPi.Distance(aP);
+      if (aDisti < aDist) {
+        V = aVi;
+        aDist = aDisti;
+        isFound = true;
+      }
+    }
+  }
+
+  if (!isFound) {
+    SetErrorCode("Vertex has not been found");
+    return NULL;
+  }
+
+  TopTools_IndexedMapOfShape anIndices;
+  TopExp::MapShapes(aBlockOrComp, anIndices);
+  Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger(1,1);
+  anArray->SetValue(1, anIndices.FindIndex(V));
+  aResult = GetEngine()->AddSubShape(theShape, anArray);
+
+  // The GetPoint() doesn't change object so no new function is required.
+  Handle(GEOM_Function) aFunction = theShape->GetLastFunction();
+
+  // Make a Python command
+  GEOM::TPythonDump(aFunction, /*append=*/true)
+    << aResult << " = geompy.GetVertexNearPoint("
+    << theShape << ", " << thePoint << ")";
+
+  SetErrorCode(OK);
+  return aResult;
+}
+
 //=============================================================================
 /*!
  *  GetEdge
@@ -1458,6 +1533,136 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetFaceByNormale
   return aResult;
 }
 
+//=============================================================================
+/*!
+ *  GetShapesNearPoint
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetShapesNearPoint
+                                         (Handle(GEOM_Object)    theShape,
+                                          Handle(GEOM_Object)    thePoint,
+                                          const Standard_Integer theShapeType,
+                                          const Standard_Real    theTolerance)
+{
+  SetErrorCode(KO);
+
+  // New object
+  Handle(GEOM_Object) aResult;
+
+  // Arguments
+  if (theShape.IsNull() || thePoint.IsNull()) return NULL;
+
+  TopoDS_Shape aBlockOrComp = theShape->GetValue();
+  if (aBlockOrComp.IsNull()) {
+    SetErrorCode("Block or compound is null");
+    return NULL;
+  }
+
+  TopoDS_Shape anArg = thePoint->GetValue();
+  if (anArg.IsNull()) {
+    SetErrorCode("Null shape is given as argument");
+    return NULL;
+  }
+  if (anArg.ShapeType() != TopAbs_VERTEX) {
+    SetErrorCode("Element for face identification is not a vertex");
+    return NULL;
+  }
+
+  if (theShapeType < TopAbs_SOLID || TopAbs_VERTEX < theShapeType) {
+    SetErrorCode("Invalid type of result is requested");
+    return NULL;
+  }
+
+  if (theTolerance < Precision::Confusion()) {
+    theTolerance == Precision::Confusion();
+  }
+
+  // Compute the result
+  try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+    OCC_CATCH_SIGNALS;
+#endif
+    TopoDS_Vertex aVert = TopoDS::Vertex(anArg);
+
+    TopTools_MapOfShape mapShape;
+    Standard_Integer nbEdges = 0;
+    TopExp_Explorer exp (aBlockOrComp, TopAbs_ShapeEnum(theShapeType));
+    for (; exp.More(); exp.Next()) {
+      if (mapShape.Add(exp.Current())) {
+        nbEdges++;
+      }
+    }
+
+    if (nbEdges == 0) {
+      SetErrorCode("Given shape contains no subshapes of requested type");
+      return NULL;
+    }
+
+    // Calculate distances and find min
+    mapShape.Clear();
+    Standard_Integer ind = 1;
+    Standard_Real aMinDist = RealLast();
+    TopTools_Array1OfShape anEdges (1, nbEdges);
+    TColStd_Array1OfReal aDistances (1, nbEdges);
+    for (exp.Init(aBlockOrComp, TopAbs_ShapeEnum(theShapeType)); exp.More(); exp.Next()) {
+      if (mapShape.Add(exp.Current())) {
+        TopoDS_Shape anEdge = exp.Current();
+        anEdges(ind) = anEdge;
+
+        BRepExtrema_DistShapeShape aDistTool (aVert, anEdges(ind));
+        if (!aDistTool.IsDone()) {
+          SetErrorCode("Can not find a distance from the given point to one of subshapes");
+          return NULL;
+        }
+        aDistances(ind) = aDistTool.Value();
+        if (aDistances(ind) < aMinDist) {
+          aMinDist = aDistances(ind);
+        }
+        ind++;
+      }
+    }
+
+    if (aMinDist < RealLast()) {
+      // Collect subshapes with distance < (aMinDist + theTolerance)
+      int nbSubShapes = 0;
+      TopTools_Array1OfShape aNearShapes (1, nbEdges);
+      for (ind = 1; ind <= nbEdges; ind++) {
+        if (aDistances(ind) < aMinDist + theTolerance) {
+          nbSubShapes++;
+          aNearShapes(nbSubShapes) = anEdges(ind);
+        }
+      }
+
+      // Add subshape
+      TopTools_IndexedMapOfShape anIndices;
+      TopExp::MapShapes(aBlockOrComp, anIndices);
+      Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger (1, nbSubShapes);
+      for (ind = 1; ind <= nbSubShapes; ind++) {
+        anArray->SetValue(ind, anIndices.FindIndex(aNearShapes(ind)));
+      }
+      aResult = GetEngine()->AddSubShape(theShape, anArray);
+    }
+  }
+  catch (Standard_Failure) {
+    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
+    SetErrorCode(aFail->GetMessageString());
+    return NULL;
+  }
+
+  if (aResult.IsNull())
+    return NULL;
+
+  Handle(GEOM_Function) aFunction = aResult->GetLastFunction();
+
+  //Make a Python command
+  GEOM::TPythonDump(aFunction)
+    << aResult << " = geompy.GetShapesNearPoint(" << theShape << ", " << thePoint
+    << ", " << TopAbs_ShapeEnum(theShapeType) << ", " << theTolerance << ")";
+
+  SetErrorCode(OK);
+  return aResult;
+}
+
 //=============================================================================
 /*!
  *  IsCompoundOfBlocks
index c5ce211517d37a515691e05a1461e5209b0e42f2..43caa588349f8dbe3390b25869fd74fbec5fcd87 100644 (file)
@@ -18,7 +18,6 @@
 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
 
 #ifndef _GEOMImpl_IBlocksOperations_HXX_
 #define _GEOMImpl_IBlocksOperations_HXX_
@@ -41,68 +40,76 @@ class GEOMImpl_IBlocksOperations : public GEOM_IOperations {
 
   // Creation of blocks and block faces
   Standard_EXPORT Handle(GEOM_Object) MakeQuad (Handle(GEOM_Object) theEdge1,
-                                Handle(GEOM_Object) theEdge2,
-                                Handle(GEOM_Object) theEdge3,
-                                Handle(GEOM_Object) theEdge4);
+                                                Handle(GEOM_Object) theEdge2,
+                                                Handle(GEOM_Object) theEdge3,
+                                                Handle(GEOM_Object) theEdge4);
 
   Standard_EXPORT Handle(GEOM_Object) MakeQuad2Edges (Handle(GEOM_Object) theEdge1,
-                                      Handle(GEOM_Object) theEdge2);
+                                                      Handle(GEOM_Object) theEdge2);
 
   Standard_EXPORT Handle(GEOM_Object) MakeQuad4Vertices (Handle(GEOM_Object) thePoint1,
-                                         Handle(GEOM_Object) thePoint2,
-                                         Handle(GEOM_Object) thePoint3,
-                                         Handle(GEOM_Object) thePoint4);
+                                                         Handle(GEOM_Object) thePoint2,
+                                                         Handle(GEOM_Object) thePoint3,
+                                                         Handle(GEOM_Object) thePoint4);
 
   Standard_EXPORT Handle(GEOM_Object) MakeHexa (Handle(GEOM_Object) theFace1,
-                                Handle(GEOM_Object) theFace2,
-                                Handle(GEOM_Object) theFace3,
-                                Handle(GEOM_Object) theFace4,
-                                Handle(GEOM_Object) theFace5,
-                                Handle(GEOM_Object) theFace6);
+                                                Handle(GEOM_Object) theFace2,
+                                                Handle(GEOM_Object) theFace3,
+                                                Handle(GEOM_Object) theFace4,
+                                                Handle(GEOM_Object) theFace5,
+                                                Handle(GEOM_Object) theFace6);
 
   Standard_EXPORT Handle(GEOM_Object) MakeHexa2Faces (Handle(GEOM_Object) theFace1,
-                                      Handle(GEOM_Object) theFace2);
+                                                      Handle(GEOM_Object) theFace2);
 
   Standard_EXPORT Handle(GEOM_Object) MakeBlockCompound (Handle(GEOM_Object) theCompound);
 
   // Extract elements of blocks and blocks compounds
   Standard_EXPORT Handle(GEOM_Object) GetPoint (Handle(GEOM_Object) theShape,
-                                const Standard_Real theX,
-                                const Standard_Real theY,
-                                const Standard_Real theZ,
-                                const Standard_Real theEpsilon);
+                                                const Standard_Real theX,
+                                                const Standard_Real theY,
+                                                const Standard_Real theZ,
+                                                const Standard_Real theEpsilon);
+
+  Standard_EXPORT Handle(GEOM_Object) GetVertexNearPoint (Handle(GEOM_Object) theShape,
+                                                          Handle(GEOM_Object) thePoint);
 
   Standard_EXPORT Handle(GEOM_Object) GetEdge (Handle(GEOM_Object) theShape,
-                               Handle(GEOM_Object) thePoint1,
-                               Handle(GEOM_Object) thePoint2);
+                                               Handle(GEOM_Object) thePoint1,
+                                               Handle(GEOM_Object) thePoint2);
 
   Standard_EXPORT Handle(GEOM_Object) GetEdgeNearPoint (Handle(GEOM_Object) theBlock,
-                                        Handle(GEOM_Object) thePoint);
+                                                        Handle(GEOM_Object) thePoint);
 
   Standard_EXPORT Handle(GEOM_Object) GetFaceByPoints (Handle(GEOM_Object) theShape,
-                                       Handle(GEOM_Object) thePoint1,
-                                       Handle(GEOM_Object) thePoint2,
-                                       Handle(GEOM_Object) thePoint3,
-                                       Handle(GEOM_Object) thePoint4);
+                                                       Handle(GEOM_Object) thePoint1,
+                                                       Handle(GEOM_Object) thePoint2,
+                                                       Handle(GEOM_Object) thePoint3,
+                                                       Handle(GEOM_Object) thePoint4);
 
   Standard_EXPORT Handle(GEOM_Object) GetFaceByEdges (Handle(GEOM_Object) theShape,
-                                      Handle(GEOM_Object) theEdge1,
-                                      Handle(GEOM_Object) theEdge2);
+                                                      Handle(GEOM_Object) theEdge1,
+                                                      Handle(GEOM_Object) theEdge2);
 
   Standard_EXPORT Handle(GEOM_Object) GetOppositeFace (Handle(GEOM_Object) theBlock,
-                                       Handle(GEOM_Object) theFace);
+                                                       Handle(GEOM_Object) theFace);
 
   Standard_EXPORT Handle(GEOM_Object) GetFaceNearPoint (Handle(GEOM_Object) theBlock,
-                                        Handle(GEOM_Object) thePoint);
+                                                        Handle(GEOM_Object) thePoint);
 
   Standard_EXPORT Handle(GEOM_Object) GetFaceByNormale (Handle(GEOM_Object) theBlock,
-                                        Handle(GEOM_Object) theVector);
+                                                        Handle(GEOM_Object) theVector);
+
+  Standard_EXPORT Handle(GEOM_Object) GetShapesNearPoint (Handle(GEOM_Object)    theShape,
+                                                          Handle(GEOM_Object)    thePoint,
+                                                          const Standard_Integer theShapeType,
+                                                          const Standard_Real    theTolerance);
 
   // Check blocks compounds
   Standard_EXPORT Standard_Boolean IsCompoundOfBlocks (Handle(GEOM_Object)    theCompound,
-                                       const Standard_Integer theMinNbFaces,
-                                       const Standard_Integer theMaxNbFaces,
-                                       Standard_Integer&      theNbBlocks);
+                                                       const Standard_Integer theMinNbFaces,
+                                                       const Standard_Integer theMaxNbFaces,
+                                                       Standard_Integer&      theNbBlocks);
 
   enum BCErrorType {
     NOT_BLOCK,
@@ -118,13 +125,13 @@ class GEOMImpl_IBlocksOperations : public GEOM_IOperations {
   };
 
   Standard_EXPORT Standard_Boolean CheckCompoundOfBlocksOld (Handle(GEOM_Object) theCompound,
-                                             std::list<BCError>&      theErrors);
+                                                             std::list<BCError>&      theErrors);
 
   Standard_EXPORT Standard_Boolean CheckCompoundOfBlocks (Handle(GEOM_Object) theCompound,
-                                          std::list<BCError>&      theErrors);
+                                                          std::list<BCError>&      theErrors);
 
   Standard_EXPORT TCollection_AsciiString PrintBCErrors (Handle(GEOM_Object)  theCompound,
-                                         const std::list<BCError>& theErrors);
+                                                         const std::list<BCError>& theErrors);
 
   Standard_EXPORT Handle(GEOM_Object) RemoveExtraEdges (Handle(GEOM_Object) theShape,
                                                         const Standard_Integer theOptimumNbFaces = 6);
@@ -132,9 +139,9 @@ class GEOMImpl_IBlocksOperations : public GEOM_IOperations {
   Standard_EXPORT Handle(GEOM_Object) CheckAndImprove (Handle(GEOM_Object) theCompound);
 
   Standard_EXPORT static void AddBlocksFrom (const TopoDS_Shape&   theShape,
-                             TopTools_ListOfShape& BLO,
-                             TopTools_ListOfShape& NOT,
-                             TopTools_ListOfShape& EXT);
+                                             TopTools_ListOfShape& BLO,
+                                             TopTools_ListOfShape& NOT,
+                                             TopTools_ListOfShape& EXT);
 
   // Extract blocks from blocks compounds
   Standard_EXPORT Handle(TColStd_HSequenceOfTransient) ExplodeCompoundOfBlocks
@@ -143,7 +150,7 @@ class GEOMImpl_IBlocksOperations : public GEOM_IOperations {
                                        const Standard_Integer theMaxNbFaces);
 
   Standard_EXPORT Handle(GEOM_Object) GetBlockNearPoint (Handle(GEOM_Object) theCompound,
-                                         Handle(GEOM_Object) thePoint);
+                                                         Handle(GEOM_Object) thePoint);
 
   Standard_EXPORT Handle(GEOM_Object) GetBlockByParts
                      (Handle(GEOM_Object)                         theCompound,
@@ -155,17 +162,17 @@ class GEOMImpl_IBlocksOperations : public GEOM_IOperations {
 
   // Operations on blocks with gluing of result
   Standard_EXPORT Handle(GEOM_Object) MakeMultiTransformation1D (Handle(GEOM_Object)    theBlock,
-                                                 const Standard_Integer theDirFace1,
-                                                 const Standard_Integer theDirFace2,
-                                                 const Standard_Integer theNbTimes);
+                                                                 const Standard_Integer theDirFace1,
+                                                                 const Standard_Integer theDirFace2,
+                                                                 const Standard_Integer theNbTimes);
 
   Standard_EXPORT Handle(GEOM_Object) MakeMultiTransformation2D (Handle(GEOM_Object)    theBlock,
-                                                 const Standard_Integer theDirFace1U,
-                                                 const Standard_Integer theDirFace2U,
-                                                 const Standard_Integer theNbTimesU,
-                                                 const Standard_Integer theDirFace1V,
-                                                 const Standard_Integer theDirFace2V,
-                                                 const Standard_Integer theNbTimesV);
+                                                                 const Standard_Integer theDirFace1U,
+                                                                 const Standard_Integer theDirFace2U,
+                                                                 const Standard_Integer theNbTimesU,
+                                                                 const Standard_Integer theDirFace1V,
+                                                                 const Standard_Integer theDirFace2V,
+                                                                 const Standard_Integer theNbTimesV);
 
   // Build groups for Propagation of 1D hypotheses
   Standard_EXPORT Handle(TColStd_HSequenceOfTransient) Propagate (Handle(GEOM_Object) theShape);
index 07252ac76e7ccc3166401ee730885e5376f4e18a..5a9d264555a9974bb866633439d50e4f96fbf4c7 100755 (executable)
@@ -19,9 +19,8 @@
 //
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+//  NOTE: This is an intreface to a function for the Healing creation.
 
-//NOTE: This is an intreface to a function for the Healing creation.
-//
 #include "GEOM_Function.hxx"
 
 #include <TColStd_HArray1OfInteger.hxx>
@@ -76,7 +75,7 @@ public:
 
   void SetIndex( Standard_Integer val ) { _func->SetInteger(ARG_SUBSHAPE_INDEX, val); }
   Standard_Integer GetIndex() { return _func->GetInteger(ARG_SUBSHAPE_INDEX); }
-            
+
 private:
-  Handle(GEOM_Function) _func;  
+  Handle(GEOM_Function) _func;
 };
index d78c82d4ee5ccaa0da22bf5068504fd483b1f54e..e19acd19ad31bbda170483c3548876f657cfa6be 100644 (file)
@@ -18,7 +18,6 @@
 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
 
 #ifdef WNT
 #pragma warning( disable:4786 )
@@ -864,7 +863,6 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::ChangeOrientation (Handle(GEOM_
   return theObject;
 }
 
-
 //=============================================================================
 /*!
  *  ChangeOrientationCopy
@@ -921,3 +919,62 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::ChangeOrientationCopy (Handle(G
   SetErrorCode(OK);
   return aNewObject;
 }
+
+//=============================================================================
+/*!
+ *  LimitTolerance
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_IHealingOperations::LimitTolerance (Handle(GEOM_Object) theObject,
+                                                                 double theTolerance)
+{
+  // Set error code, check parameters
+  SetErrorCode(KO);
+
+  if (theObject.IsNull())
+    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
+
+  // Add a new object
+  Handle(GEOM_Object) aNewObject = GetEngine()->AddObject(GetDocID(), theObject->GetType());
+
+  // Add the function
+  aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), LIMIT_TOLERANCE);
+
+  if (aFunction.IsNull())
+    return NULL;
+
+  // Check if the function is set correctly
+  if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
+
+  // Prepare "data container" class IHealing
+  GEOMImpl_IHealing HI (aFunction);
+  HI.SetOriginal(aLastFunction);
+  HI.SetTolerance(theTolerance);
+
+  // Compute
+  try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+    OCC_CATCH_SIGNALS;
+#endif
+    if (!GetSolver()->ComputeFunction(aFunction)) {
+      SetErrorCode("Healing driver failed");
+      return NULL;
+    }
+  }
+  catch (Standard_Failure) {
+    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
+    SetErrorCode(aFail->GetMessageString());
+    return NULL;
+  }
+
+  // Make a Python command
+  GEOM::TPythonDump(aFunction) << aNewObject << " = geompy.LimitTolerance("
+                               << theObject << ", " << theTolerance << ")";
+
+  SetErrorCode(OK);
+  return aNewObject;
+}
index aafa9687dd6641d98df7fdaac1252227e8ca5ad8..064194fdd8c1c5869605ebfc09511b948632f585 100644 (file)
@@ -18,7 +18,6 @@
 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
 
 #ifndef _GEOMImpl_IHealingOperations_HXX_
 #define _GEOMImpl_IHealingOperations_HXX_
@@ -39,9 +38,9 @@ class GEOMImpl_IHealingOperations : public GEOM_IOperations {
 
   // Apply Shape Processing to the selected Object
   Standard_EXPORT Handle(GEOM_Object) ShapeProcess( Handle(GEOM_Object) theObject,
-                                    const Handle(TColStd_HArray1OfExtendedString)& theOperations,
-                                    const Handle(TColStd_HArray1OfExtendedString)& theParams,
-                                    const Handle(TColStd_HArray1OfExtendedString)& theValues );
+                            const Handle(TColStd_HArray1OfExtendedString)& theOperations,
+                            const Handle(TColStd_HArray1OfExtendedString)& theParams,
+                            const Handle(TColStd_HArray1OfExtendedString)& theValues );
 
   // Retrieve default Shape Process parameters (from resource file)
   Standard_EXPORT void GetShapeProcessParameters( std::list<std::string>& theOperations,
@@ -49,12 +48,13 @@ class GEOMImpl_IHealingOperations : public GEOM_IOperations {
                                                   std::list<std::string>& theValues );
 
   // Retrieve default Shape Process parameters for given operator
-  Standard_EXPORT bool GetOperatorParameters( const std::string theOperation, 
+  Standard_EXPORT bool GetOperatorParameters( const std::string theOperation,
                                               std::list<std::string>& theParams,
                                               std::list<std::string>& theValues );
 
   // returns all parameters that are valid for the given operation (Shape Process operator)
-  Standard_EXPORT static bool GetParameters( const std::string theOperation, std::list<std::string>& theParams );
+  Standard_EXPORT static bool GetParameters( const std::string theOperation,
+                                             std::list<std::string>& theParams );
 
   Standard_EXPORT Handle(GEOM_Object) SuppressFaces( Handle(GEOM_Object) theObject,
                                      const Handle(TColStd_HArray1OfInteger)& theFaces);
@@ -68,25 +68,28 @@ 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 );
 
   Standard_EXPORT Handle(GEOM_Object) DivideEdge( Handle(GEOM_Object) theObject,
-                                  int theIndex,  
-                                  double theValue,
-                                  bool isByParameter );
+                                                  int theIndex,
+                                                  double theValue,
+                                                  bool isByParameter );
 
   // 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, 
+  Standard_EXPORT bool GetFreeBoundary ( Handle(GEOM_Object) theObject,
+                         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);
 
+  Standard_EXPORT Handle(GEOM_Object) LimitTolerance( Handle(GEOM_Object) theObject,
+                                                      double theTolerance );
+
 };
 
 #endif
index b1d626427dad148325ce8ddf0f7e36db0bf09e71..d1dcbe27446ebe862becba24edd5a6592a552ced 100755 (executable)
 #define SEWING             6
 #define DIVIDE_EDGE        7
 #define CHANGE_ORIENTATION 8
+#define LIMIT_TOLERANCE    9
 
 #define BASIC_FILLING 1
 
index d5435c5d1bc9e9c33586de649fb59fc7d22e9845..f765856d0950c94be2e4b519909ff49de0064f42 100644 (file)
@@ -269,6 +269,34 @@ GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetPoint (GEOM::GEOM_Object_ptr
   return GetObject(anObject);
 }
 
+//=============================================================================
+/*!
+ *  GetVertexNearPoint
+ */
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetVertexNearPoint
+                                                (GEOM::GEOM_Object_ptr theShape,
+                                                 GEOM::GEOM_Object_ptr thePoint)
+{
+  GEOM::GEOM_Object_var aGEOMObject;
+
+  // Set a not done flag
+  GetOperations()->SetNotDone();
+
+  // Get the reference Objects
+  Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
+  Handle(GEOM_Object) aPoint = GetObjectImpl(thePoint);
+  if (aShape.IsNull() || aPoint.IsNull()) return aGEOMObject._retn();
+
+  // Create the Point
+  Handle(GEOM_Object) anObject =
+    GetOperations()->GetVertexNearPoint(aShape, aPoint);
+  if (!GetOperations()->IsDone() || anObject.IsNull())
+    return aGEOMObject._retn();
+
+  return GetObject(anObject);
+}
+
 //=============================================================================
 /*!
  *  GetEdge
@@ -481,6 +509,37 @@ GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetFaceByNormale (GEOM::GEOM_Obj
   return GetObject(anObject);
 }
 
+//=============================================================================
+/*!
+ *  GetShapesNearPoint
+ */
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetShapesNearPoint
+                      (GEOM::GEOM_Object_ptr theShape,
+                       GEOM::GEOM_Object_ptr thePoint,
+                       CORBA::Long           theShapeType,
+                       CORBA::Double         theTolerance)
+{
+  GEOM::GEOM_Object_var aGEOMObject;
+
+  // Set a not done flag
+  GetOperations()->SetNotDone();
+
+  // Get the reference Objects
+  Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
+  Handle(GEOM_Object) aPoint = GetObjectImpl(thePoint);
+
+  if (aShape.IsNull() || aPoint.IsNull()) return aGEOMObject._retn();
+
+  // Create the Shape
+  Handle(GEOM_Object) anObject =
+    GetOperations()->GetShapesNearPoint(aShape, aPoint, theShapeType, theTolerance);
+  if (!GetOperations()->IsDone() || anObject.IsNull())
+    return aGEOMObject._retn();
+
+  return GetObject(anObject);
+}
+
 //=============================================================================
 /*!
  *  ExplodeCompoundOfBlocks
index 68904892c10ad6ea2fe23899be25507128cd61be..8fa1e1de7766660df12924f4cd5436e2cfb05b47 100644 (file)
@@ -75,6 +75,9 @@ class GEOM_I_EXPORT GEOM_IBlocksOperations_i :
                                  CORBA::Double   theZ,
                                  CORBA::Double   theEpsilon);
 
+  GEOM::GEOM_Object_ptr GetVertexNearPoint (GEOM::GEOM_Object_ptr theShape,
+                                            GEOM::GEOM_Object_ptr thePoint);
+
   GEOM::GEOM_Object_ptr GetEdge (GEOM::GEOM_Object_ptr theShape,
                                 GEOM::GEOM_Object_ptr thePoint1,
                                 GEOM::GEOM_Object_ptr thePoint2);
@@ -101,10 +104,15 @@ class GEOM_I_EXPORT GEOM_IBlocksOperations_i :
   GEOM::GEOM_Object_ptr GetFaceByNormale (GEOM::GEOM_Object_ptr theBlock,
                                          GEOM::GEOM_Object_ptr theVector);
 
+  GEOM::GEOM_Object_ptr GetShapesNearPoint (GEOM::GEOM_Object_ptr theShape,
+                                            GEOM::GEOM_Object_ptr thePoint,
+                                            CORBA::Long           theShapeType,
+                                            CORBA::Double         theTolerance);
+
   // Check blocks compound
   CORBA::Boolean IsCompoundOfBlocks (GEOM::GEOM_Object_ptr theCompound,
-                                    CORBA::Long     theMinNbFaces,
-                                    CORBA::Long     theMaxNbFaces,
+                                    CORBA::Long           theMinNbFaces,
+                                    CORBA::Long           theMaxNbFaces,
                                     CORBA::Long&          theNbBlocks);
 
   CORBA::Boolean CheckCompoundOfBlocks (GEOM::GEOM_Object_ptr theCompound,
index 81dac09c329d9f57972fc3772d1c3546854312d5..39df78fe1cecb656e901a0f8502e3268c059b1ff 100644 (file)
@@ -18,7 +18,6 @@
 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
 
 #include <Standard_Stream.hxx>
 
@@ -493,3 +492,30 @@ GEOM::GEOM_Object_ptr GEOM_IHealingOperations_i::ChangeOrientationCopy (GEOM::GE
 
   return GetObject(aNewObject);
 }
+
+//=============================================================================
+/*!
+ *  LimitTolerance
+ */
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_IHealingOperations_i::LimitTolerance (GEOM::GEOM_Object_ptr theObject,
+                                                                 CORBA::Double theTolerance)
+{
+  GEOM::GEOM_Object_var aGEOMObject;
+
+  // Set a not done flag
+  GetOperations()->SetNotDone();
+
+  // Get the object itself
+  Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
+  if (anObject.IsNull())
+    return aGEOMObject._retn();
+
+  // Perform
+  Handle(GEOM_Object) aNewObject =
+    GetOperations()->LimitTolerance(anObject, theTolerance);
+  if (!GetOperations()->IsDone() || aNewObject.IsNull())
+    return aGEOMObject._retn();
+
+  return GetObject(aNewObject);
+}
index be42fbd55115cc85464394bf1e365ec9f2ac4b6b..01b3f48fc4ba5da4a3c5ae9bb6f0ea191cc7df1c 100644 (file)
@@ -18,7 +18,7 @@
 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
+
 
 #ifndef _GEOM_IHealingOperations_i_HeaderFile
 #define _GEOM_IHealingOperations_i_HeaderFile
 #include <TColStd_HArray1OfExtendedString.hxx>
 #include <TColStd_HArray1OfInteger.hxx>
 
-class GEOM_I_EXPORT GEOM_IHealingOperations_i : 
+class GEOM_I_EXPORT GEOM_IHealingOperations_i :
     public virtual POA_GEOM::GEOM_IHealingOperations,
     public virtual GEOM_IOperations_i
 {
  public:
-   GEOM_IHealingOperations_i(PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, ::GEOMImpl_IHealingOperations* theImpl);
+   GEOM_IHealingOperations_i(PortableServer::POA_ptr thePOA,
+                             GEOM::GEOM_Gen_ptr theEngine,
+                             ::GEOMImpl_IHealingOperations* theImpl);
    ~GEOM_IHealingOperations_i();
-  
-   GEOM::GEOM_Object_ptr ProcessShape(GEOM::GEOM_Object_ptr theObject, const GEOM::string_array& theOperations, const GEOM::string_array& theParams, const GEOM::string_array& theValues);
 
-   void GetShapeProcessParameters(GEOM::string_array_out theOperations, GEOM::string_array_out theParams, GEOM::string_array_out theValues);
+   GEOM::GEOM_Object_ptr ProcessShape(GEOM::GEOM_Object_ptr theObject,
+                                      const GEOM::string_array& theOperations,
+                                      const GEOM::string_array& theParams,
+                                      const GEOM::string_array& theValues);
+
+   void GetShapeProcessParameters(GEOM::string_array_out theOperations,
+                                  GEOM::string_array_out theParams,
+                                  GEOM::string_array_out theValues);
 
-   void GetOperatorParameters (const char* theOperator,  GEOM::string_array_out theParams, GEOM::string_array_out theValues);
+   void GetOperatorParameters (const char* theOperator,
+                               GEOM::string_array_out theParams,
+                               GEOM::string_array_out theValues);
 
-   GEOM::GEOM_Object_ptr SuppressFaces(GEOM::GEOM_Object_ptr theObject, const GEOM::short_array& theFaces);
+   GEOM::GEOM_Object_ptr SuppressFaces(GEOM::GEOM_Object_ptr theObject,
+                                       const GEOM::short_array& theFaces);
 
-   GEOM::GEOM_Object_ptr CloseContour (GEOM::GEOM_Object_ptr theObject, const GEOM::short_array& theWires, CORBA::Boolean isCommonVertex);
+   GEOM::GEOM_Object_ptr CloseContour (GEOM::GEOM_Object_ptr theObject,
+                                       const GEOM::short_array& theWires,
+                                       CORBA::Boolean isCommonVertex);
 
-   GEOM::GEOM_Object_ptr RemoveIntWires (GEOM::GEOM_Object_ptr theObject, const GEOM::short_array& theWires);
-   
-   GEOM::GEOM_Object_ptr FillHoles (GEOM::GEOM_Object_ptr theObject, const GEOM::short_array& theWires);
+   GEOM::GEOM_Object_ptr RemoveIntWires (GEOM::GEOM_Object_ptr theObject,
+                                         const GEOM::short_array& theWires);
 
-   GEOM::GEOM_Object_ptr Sew (GEOM::GEOM_Object_ptr theObject, CORBA::Double theTolerance);
+   GEOM::GEOM_Object_ptr FillHoles (GEOM::GEOM_Object_ptr theObject,
+                                    const GEOM::short_array& theWires);
 
-   GEOM::GEOM_Object_ptr DivideEdge (GEOM::GEOM_Object_ptr theObject, CORBA::Short theIndex, CORBA::Double theValue, CORBA::Boolean isByParameter);        
+   GEOM::GEOM_Object_ptr Sew (GEOM::GEOM_Object_ptr theObject,
+                              CORBA::Double theTolerance);
+
+   GEOM::GEOM_Object_ptr DivideEdge (GEOM::GEOM_Object_ptr theObject,
+                                     CORBA::Short theIndex,
+                                     CORBA::Double theValue,
+                                     CORBA::Boolean isByParameter);
+
+   CORBA::Boolean GetFreeBoundary(GEOM::GEOM_Object_ptr theObject,
+                                  GEOM::ListOfGO_out theClosedWires,
+                                  GEOM::ListOfGO_out theOpenWires );
 
-   CORBA::Boolean GetFreeBoundary(GEOM::GEOM_Object_ptr theObject, 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);
 
+   GEOM::GEOM_Object_ptr LimitTolerance (GEOM::GEOM_Object_ptr theObject,
+                                         CORBA::Double theTolerance);
+
    ::GEOMImpl_IHealingOperations* GetOperations() { return (::GEOMImpl_IHealingOperations*)GetImpl(); }
 
 private:
-        Handle(TColStd_HArray1OfExtendedString) Convert( const GEOM::string_array& );
-        Handle(TColStd_HArray1OfInteger)        Convert( const GEOM::short_array& );
+         Handle(TColStd_HArray1OfExtendedString) Convert( const GEOM::string_array& );
+         Handle(TColStd_HArray1OfInteger)        Convert( const GEOM::short_array& );
 
 };
 
index ca37dd30b7fbb009509e8fd9c1fcbb026a303f9d..a1607cd43bd5193a1b63fca3197b12556330da33 100644 (file)
@@ -500,6 +500,17 @@ def TestOtherOperations (geompy, math):
   geompy.addToStudyInFather(blocksComp, pb0_top_1, "point from blocksComp (-50,  50,  50)")
   geompy.addToStudyInFather(blocksComp, pb0_bot_1, "point from blocksComp (-50, -50, -50)")
 
+  # GetVertexNearPoint(theShape, thePoint)
+  pb0_top_2_near = geompy.MakeVertex(40, 40, 40)
+  pb0_top_2      = geompy.GetVertexNearPoint(blocksComp, pb0_top_2_near)
+
+  geompy.addToStudyInFather(blocksComp, pb0_top_2, "point from blocksComp near (40,  40,  40)")
+
+  # GetEdge(theShape, thePoint1, thePoint2)
+  edge_top_y50 = geompy.GetEdge(blocksComp, pb0_top_1, pb0_top_2)
+
+  geompy.addToStudyInFather(blocksComp, edge_top_y50, "edge from blocksComp by two points")
+
   # GetEdgeNearPoint(theShape, thePoint)
   pmidle = geompy.MakeVertex(50, 0, 50)
   edge1 = geompy.GetEdgeNearPoint(blocksComp, pmidle)
@@ -511,6 +522,11 @@ def TestOtherOperations (geompy, math):
 
   geompy.addToStudyInFather(blocksComp, b0_image, "b0 image")
 
+  # GetShapesNearPoint(theShape, thePoint, theShapeType, theTolerance)
+  b0_faces_plus = geompy.GetShapesNearPoint(blocksComp, pb0_top_2_near, geompy.ShapeType["FACE"], 0.01)
+
+  geompy.addToStudyInFather(blocksComp, b0_faces_plus, "faces near point (40,  40,  40)")
+
   # GetShapesOnPlane
   faces_on_pln = geompy.GetShapesOnPlane(blocksComp, geompy.ShapeType["FACE"],
                                          v_0pp, geompy.GEOM.ST_ONIN)
index 67657dce1657117c1d5d7f76cb077dc0f15898a0..0f570563f7b0d62df73223995b8cd0682beffa88 100644 (file)
@@ -448,7 +448,7 @@ class geompyDC(GEOM._objref_GEOM_Gen):
         #  @return New GEOM_Object, containing the created point.
         #
         #  @ref tui_creation_point "Example"
-        def MakeVertex(self,theX, theY, theZ):
+        def MakeVertex(self, theX, theY, theZ):
             # Example: see GEOM_TestAll.py
             theX,theY,theZ,Parameters = ParseParameters(theX, theY, theZ)
             anObj = self.BasicOp.MakePointXYZ(theX, theY, theZ)
@@ -2266,11 +2266,22 @@ class geompyDC(GEOM._objref_GEOM_Gen):
         #  @return New GEOM_Object, containing processed shape.
         #
         #  @ref swig_todo "Example"
-        def ChangeOrientationShellCopy(self,theObject):
+        def ChangeOrientationShellCopy(self, theObject):
             anObj = self.HealOp.ChangeOrientationCopy(theObject)
             RaiseIfFailed("ChangeOrientationCopy", self.HealOp)
             return anObj
 
+        ## Try to limit tolerance of the given object by value \a theTolerance.
+        #  @param theObject Shape to be processed.
+        #  @param theTolerance Required tolerance value.
+        #  @return New GEOM_Object, containing processed shape.
+        #
+        #  @ref tui_limit_tolerance "Example"
+        def LimitTolerance(self, theObject, theTolerance = 1e-07):
+            anObj = self.HealOp.LimitTolerance(theObject, theTolerance)
+            RaiseIfFailed("LimitTolerance", self.HealOp)
+            return anObj
+
         ## 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.
@@ -2280,7 +2291,7 @@ class geompyDC(GEOM._objref_GEOM_Gen):
         #  theOpenWires: Open wires on the free boundary of the given shape.
         #
         #  @ref tui_measurement_tools_page "Example"
-        def GetFreeBoundary(self,theObject):
+        def GetFreeBoundary(self, theObject):
             # Example: see GEOM_TestHealing.py
             anObj = self.HealOp.GetFreeBoundary(theObject)
             RaiseIfFailed("GetFreeBoundary", self.HealOp)
@@ -3620,19 +3631,31 @@ class geompyDC(GEOM._objref_GEOM_Gen):
         #  @return New GEOM_Object, containing the found vertex.
         #
         #  @ref swig_GetPoint "Example"
-        def GetPoint(self,theShape, theX, theY, theZ, theEpsilon):
+        def GetPoint(self, theShape, theX, theY, theZ, theEpsilon):
             # Example: see GEOM_TestOthers.py
             anObj = self.BlocksOp.GetPoint(theShape, theX, theY, theZ, theEpsilon)
             RaiseIfFailed("GetPoint", self.BlocksOp)
             return anObj
 
+        ## Find a vertex of the given shape, which has minimal distance to the given point.
+        #  @param theShape Any shape.
+        #  @param thePoint Point, close to the desired vertex.
+        #  @return New GEOM_Object, containing the found vertex.
+        #
+        #  @ref swig_GetVertexNearPoint "Example"
+        def GetVertexNearPoint(self, theShape, thePoint):
+            # Example: see GEOM_TestOthers.py
+            anObj = self.BlocksOp.GetVertexNearPoint(theShape, thePoint)
+            RaiseIfFailed("GetVertexNearPoint", self.BlocksOp)
+            return anObj
+
         ## Get an edge, found in the given shape by two given vertices.
         #  @param theShape Block or a compound of blocks.
         #  @param thePoint1,thePoint2 Points, close to the ends of the desired edge.
         #  @return New GEOM_Object, containing the found edge.
         #
-        #  @ref swig_todo "Example"
-        def GetEdge(self,theShape, thePoint1, thePoint2):
+        #  @ref swig_GetEdge "Example"
+        def GetEdge(self, theShape, thePoint1, thePoint2):
             # Example: see GEOM_Spanner.py
             anObj = self.BlocksOp.GetEdge(theShape, thePoint1, thePoint2)
             RaiseIfFailed("GetEdge", self.BlocksOp)
@@ -3644,7 +3667,7 @@ class geompyDC(GEOM._objref_GEOM_Gen):
         #  @return New GEOM_Object, containing the found edge.
         #
         #  @ref swig_GetEdgeNearPoint "Example"
-        def GetEdgeNearPoint(self,theShape, thePoint):
+        def GetEdgeNearPoint(self, theShape, thePoint):
             # Example: see GEOM_TestOthers.py
             anObj = self.BlocksOp.GetEdgeNearPoint(theShape, thePoint)
             RaiseIfFailed("GetEdgeNearPoint", self.BlocksOp)
@@ -3692,7 +3715,7 @@ class geompyDC(GEOM._objref_GEOM_Gen):
         #  @return New GEOM_Object, containing the found face.
         #
         #  @ref swig_GetFaceNearPoint "Example"
-        def GetFaceNearPoint(self,theShape, thePoint):
+        def GetFaceNearPoint(self, theShape, thePoint):
             # Example: see GEOM_Spanner.py
             anObj = self.BlocksOp.GetFaceNearPoint(theShape, thePoint)
             RaiseIfFailed("GetFaceNearPoint", self.BlocksOp)
@@ -3710,6 +3733,23 @@ class geompyDC(GEOM._objref_GEOM_Gen):
             RaiseIfFailed("GetFaceByNormale", self.BlocksOp)
             return anObj
 
+        ## Find all subshapes of type \a theShapeType of the given shape,
+        #  which have minimal distance to the given point.
+        #  @param theShape Any shape.
+        #  @param thePoint Point, close to the desired shape.
+        #  @param theShapeType Defines what kind of subshapes is searched.
+        #  @param theTolerance The tolerance for distances comparison. All shapes
+        #                      with distances to the given point in interval
+        #                      [minimal_distance, minimal_distance + theTolerance] will be gathered.
+        #  @return New GEOM_Object, containing a group of all found shapes.
+        #
+        #  @ref swig_GetShapesNearPoint "Example"
+        def GetShapesNearPoint(self, theShape, thePoint, theShapeType, theTolerance = 1e-07):
+            # Example: see GEOM_TestOthers.py
+            anObj = self.BlocksOp.GetShapesNearPoint(theShape, thePoint, theShapeType, theTolerance)
+            RaiseIfFailed("GetShapesNearPoint", self.BlocksOp)
+            return anObj
+
         # end of l3_blocks_op
         ## @}
 
index c59c1505699b4134630dbceddb345e67fac5484e..7f8a4fcbe9c0cc9422546fae4aefff65ee976143 100644 (file)
@@ -38,6 +38,7 @@ salomeinclude_HEADERS =                               \
        RepairGUI_FreeFacesDlg.h                \
        RepairGUI_ChangeOrientationDlg.h        \
        RepairGUI_GlueDlg.h                     \
+       RepairGUI_LimitToleranceDlg.h           \
        RepairGUI_RemoveExtraEdgesDlg.h
 
 # Libraries targets
@@ -56,6 +57,7 @@ dist_libRepairGUI_la_SOURCES =                        \
        RepairGUI_FreeFacesDlg.h                \
        RepairGUI_ChangeOrientationDlg.h        \
        RepairGUI_GlueDlg.h                     \
+       RepairGUI_LimitToleranceDlg.h           \
        RepairGUI_RemoveExtraEdgesDlg.h         \
                                                \
        RepairGUI.cxx                           \
@@ -70,6 +72,7 @@ dist_libRepairGUI_la_SOURCES =                        \
        RepairGUI_FreeFacesDlg.cxx              \
        RepairGUI_ChangeOrientationDlg.cxx      \
        RepairGUI_GlueDlg.cxx                   \
+       RepairGUI_LimitToleranceDlg.cxx         \
        RepairGUI_RemoveExtraEdgesDlg.cxx
 
 MOC_FILES =                                    \
@@ -84,6 +87,7 @@ MOC_FILES =                                   \
        RepairGUI_FreeFacesDlg_moc.cxx          \
        RepairGUI_ChangeOrientationDlg_moc.cxx  \
        RepairGUI_GlueDlg_moc.cxx               \
+       RepairGUI_LimitToleranceDlg_moc.cxx     \
        RepairGUI_RemoveExtraEdgesDlg_moc.cxx
 
 nodist_libRepairGUI_la_SOURCES =               \
index 652cdb63a2eeea82943202d7c028b382d3e79d7b..ebfc75fb4326cbb0819cf16de5f01108e7f86623 100644 (file)
 //
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+//  GEOM GEOMGUI : GUI for Geometry component
+//  File   : RepairGUI.cxx
+//  Author : Damien COQUERET, Open CASCADE S.A.S.
 
-// GEOM GEOMGUI : GUI for Geometry component
-// File   : RepairGUI.cxx
-// Author : Damien COQUERET, Open CASCADE S.A.S.
-//
 #include "RepairGUI.h"
 
 #include <GeometryGUI.h>
@@ -43,8 +42,9 @@
 #include "RepairGUI_FreeBoundDlg.h"     // Method FREE BOUNDARIES
 #include "RepairGUI_FreeFacesDlg.h"     // Method FREE FACES
 #include "RepairGUI_GlueDlg.h"          // Method GLUE FACES
+#include "RepairGUI_LimitToleranceDlg.h"    // Method LIMIT TOLERANCE
 #include "RepairGUI_ChangeOrientationDlg.h" // Method CHANGE ORIENTATION
-#include "RepairGUI_RemoveExtraEdgesDlg.h" // Method REMOVE EXTRA EDGES
+#include "RepairGUI_RemoveExtraEdgesDlg.h"  // Method REMOVE EXTRA EDGES
 
 //=======================================================================
 // function : RepairGUI()
@@ -66,7 +66,7 @@ RepairGUI::~RepairGUI()
 
 //=======================================================================
 // function : OnGUIEvent()
-// purpose  : 
+// purpose  :
 //=======================================================================
 bool RepairGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent )
 {
@@ -77,18 +77,19 @@ bool RepairGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent )
 
   QDialog* aDlg = NULL;
   switch ( theCommandID ) {
-  case GEOMOp::OpSewing:           aDlg = new RepairGUI_SewingDlg            ( getGeometryGUI(), parent ); break;
-  case GEOMOp::OpGlueFaces:        aDlg = new RepairGUI_GlueDlg              ( getGeometryGUI(), parent ); break;
-  case GEOMOp::OpSuppressFaces:    aDlg = new RepairGUI_SuppressFacesDlg     ( getGeometryGUI(), parent ); break;
-  case GEOMOp::OpSuppressHoles:    aDlg = new RepairGUI_RemoveHolesDlg       ( getGeometryGUI(), parent ); break;
-  case GEOMOp::OpShapeProcess:     aDlg = new RepairGUI_ShapeProcessDlg      ( getGeometryGUI(), parent ); break;
-  case GEOMOp::OpCloseContour:     aDlg = new RepairGUI_CloseContourDlg      ( getGeometryGUI(), parent ); break;
-  case GEOMOp::OpRemoveIntWires:   aDlg = new RepairGUI_RemoveIntWiresDlg    ( getGeometryGUI(), parent ); break;
-  case GEOMOp::OpAddPointOnEdge:   aDlg = new RepairGUI_DivideEdgeDlg        ( getGeometryGUI(), parent ); break;
-  case GEOMOp::OpFreeBoundaries:   aDlg = new RepairGUI_FreeBoundDlg         ( getGeometryGUI(), parent ); break;
-  case GEOMOp::OpFreeFaces:        aDlg = new RepairGUI_FreeFacesDlg         ( getGeometryGUI(), parent ); break;
-  case GEOMOp::OpOrientation:      aDlg = new RepairGUI_ChangeOrientationDlg ( getGeometryGUI(), parent ); break;
-  case GEOMOp::OpRemoveExtraEdges: aDlg = new RepairGUI_RemoveExtraEdgesDlg  ( getGeometryGUI(), parent ); break;  
+  case GEOMOp::OpSewing:           aDlg = new RepairGUI_SewingDlg            (getGeometryGUI(), parent); break;
+  case GEOMOp::OpGlueFaces:        aDlg = new RepairGUI_GlueDlg              (getGeometryGUI(), parent); break;
+  case GEOMOp::OpLimitTolerance:   aDlg = new RepairGUI_LimitToleranceDlg    (getGeometryGUI(), parent); break;
+  case GEOMOp::OpSuppressFaces:    aDlg = new RepairGUI_SuppressFacesDlg     (getGeometryGUI(), parent); break;
+  case GEOMOp::OpSuppressHoles:    aDlg = new RepairGUI_RemoveHolesDlg       (getGeometryGUI(), parent); break;
+  case GEOMOp::OpShapeProcess:     aDlg = new RepairGUI_ShapeProcessDlg      (getGeometryGUI(), parent); break;
+  case GEOMOp::OpCloseContour:     aDlg = new RepairGUI_CloseContourDlg      (getGeometryGUI(), parent); break;
+  case GEOMOp::OpRemoveIntWires:   aDlg = new RepairGUI_RemoveIntWiresDlg    (getGeometryGUI(), parent); break;
+  case GEOMOp::OpAddPointOnEdge:   aDlg = new RepairGUI_DivideEdgeDlg        (getGeometryGUI(), parent); break;
+  case GEOMOp::OpFreeBoundaries:   aDlg = new RepairGUI_FreeBoundDlg         (getGeometryGUI(), parent); break;
+  case GEOMOp::OpFreeFaces:        aDlg = new RepairGUI_FreeFacesDlg         (getGeometryGUI(), parent); break;
+  case GEOMOp::OpOrientation:      aDlg = new RepairGUI_ChangeOrientationDlg (getGeometryGUI(), parent); break;
+  case GEOMOp::OpRemoveExtraEdges: aDlg = new RepairGUI_RemoveExtraEdgesDlg  (getGeometryGUI(), parent); break;
     default:
       app->putInfo( tr( "GEOM_PRP_COMMAND" ).arg( theCommandID ) );
       break;
diff --git a/src/RepairGUI/RepairGUI_LimitToleranceDlg.cxx b/src/RepairGUI/RepairGUI_LimitToleranceDlg.cxx
new file mode 100644 (file)
index 0000000..19cfe7a
--- /dev/null
@@ -0,0 +1,441 @@
+//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of the GNU Lesser General Public
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//  GEOM RepairGUI : GUI for Geometry component
+//  File   : RepairGUI_LimitToleranceDlg.cxx
+
+#include "RepairGUI_LimitToleranceDlg.h"
+
+#include <DlgRef.h>
+#include <GeometryGUI.h>
+#include <GEOMBase.h>
+#include <SalomeApp_DoubleSpinBox.h>
+
+#include <SalomeApp_Application.h>
+#include <LightApp_SelectionMgr.h>
+#include <SalomeApp_Study.h>
+#include <SalomeApp_Tools.h>
+#include <SUIT_Session.h>
+#include <SUIT_Desktop.h>
+#include <SUIT_MessageBox.h>
+#include <SUIT_OverrideCursor.h>
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_ViewWindow.h>
+#include <SUIT_ViewManager.h>
+#include <OCCViewer_ViewModel.h>
+#include <SALOME_ListIteratorOfListIO.hxx>
+
+#include <GEOMImpl_Types.hxx>
+
+#include <TCollection_AsciiString.hxx>
+
+#define DEFAULT_TOLERANCE_VALUE 1e-07
+
+//=================================================================================
+// class    : RepairGUI_LimitToleranceDlg()
+// purpose  : Constructs a RepairGUI_LimitToleranceDlg  which is a child of 'parent', with the
+//            name 'name' and widget flags set to 'f'.
+//            The dialog will by default be modeless, unless you set 'modal' to
+//            TRUE to construct a modal dialog.
+//=================================================================================
+RepairGUI_LimitToleranceDlg::RepairGUI_LimitToleranceDlg(GeometryGUI* theGeometryGUI,
+                                                         QWidget* parent, bool modal)
+  : GEOMBase_Skeleton(theGeometryGUI, parent, modal)
+{
+  QPixmap image0 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_LIMIT_TOLERANCE")));
+  QPixmap image1 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT")));
+
+  setWindowTitle(tr("GEOM_LIMIT_TOLERANCE_TITLE"));
+
+  /***************************************************************/
+  mainFrame()->GroupConstructors->setTitle(tr("GEOM_LIMIT_TOLERANCE_TITLE"));
+  mainFrame()->RadioButton1->setIcon(image0);
+  mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose);
+  mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
+  mainFrame()->RadioButton2->close();
+  mainFrame()->RadioButton3->close();
+
+  GroupPoints = new DlgRef_1SelExt(centralWidget());
+  GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
+  GroupPoints->TextLabel1->setText(tr("GEOM_SELECTED_SHAPE"));
+  GroupPoints->PushButton1->setIcon(image1);
+  GroupPoints->LineEdit1->setReadOnly(true);
+
+  QLabel* aTolLab = new QLabel(tr("GEOM_TOLERANCE"), GroupPoints->Box);
+  myTolEdt = new SalomeApp_DoubleSpinBox(GroupPoints->Box);
+  initSpinBox(myTolEdt, 0., 100., DEFAULT_TOLERANCE_VALUE, "len_tol_precision");
+  myTolEdt->setValue(DEFAULT_TOLERANCE_VALUE);
+
+  QGridLayout* boxLayout = new QGridLayout(GroupPoints->Box);
+  boxLayout->setMargin(0); boxLayout->setSpacing(6);
+  boxLayout->addWidget(aTolLab,  0, 0);
+  boxLayout->addWidget(myTolEdt, 0, 2);
+
+  QVBoxLayout* layout = new QVBoxLayout(centralWidget());
+  layout->setMargin(0); layout->setSpacing(6);
+  layout->addWidget(GroupPoints);
+
+  setHelpFileName("limit_tolerance_operation_page.html");
+
+  Init();
+}
+
+
+//=================================================================================
+// function : ~RepairGUI_LimitToleranceDlg()
+// purpose  : Destroys the object and frees any allocated resources
+//=================================================================================
+RepairGUI_LimitToleranceDlg::~RepairGUI_LimitToleranceDlg()
+{
+}
+
+
+//=================================================================================
+// function : Init()
+// purpose  :
+//=================================================================================
+void RepairGUI_LimitToleranceDlg::Init()
+{
+  /* init variables */
+  myEditCurrentArgument = GroupPoints->LineEdit1;
+
+  myObject = GEOM::GEOM_Object::_nil();
+
+  //myGeomGUI->SetState(0);
+  //globalSelection(GEOM_COMPOUND);
+
+  mainFrame()->GroupBoxPublish->show();
+
+  /* signals and slots connections */
+  connect(buttonOk(),    SIGNAL(clicked()), this, SLOT(ClickOnOk()));
+  connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
+
+  connect(GroupPoints->PushButton1,  SIGNAL(clicked()),       this, SLOT(SetEditCurrentArgument()));
+  connect(GroupPoints->LineEdit1,    SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
+
+  connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
+          this, SLOT(SelectionIntoArgument()));
+
+  initName(tr("LIMIT_TOLERANCE_NEW_OBJ_NAME"));
+
+  ConstructorsClicked(0);
+
+  activateSelection();
+  updateButtonState();
+}
+
+
+//=================================================================================
+// function : ConstructorsClicked()
+// purpose  : Radio button management
+//=================================================================================
+void RepairGUI_LimitToleranceDlg::ConstructorsClicked(int constructorId)
+{
+  disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
+
+  GroupPoints->show();
+  GroupPoints->LineEdit1->setText("");
+  myEditCurrentArgument = GroupPoints->LineEdit1;
+  myEditCurrentArgument->setFocus();
+
+  connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
+           this, SLOT(SelectionIntoArgument()));
+
+  qApp->processEvents();
+  updateGeometry();
+  resize(minimumSizeHint());
+
+  updateButtonState();
+  activateSelection();
+  SelectionIntoArgument();
+}
+
+
+//=================================================================================
+// function : ClickOnOk()
+// purpose  : Same than click on apply but close this dialog.
+//=================================================================================
+void RepairGUI_LimitToleranceDlg::ClickOnOk()
+{
+  if (ClickOnApply())
+    ClickOnCancel();
+}
+
+//=================================================================================
+// function : ClickOnApply()
+// purpose  :
+//=================================================================================
+bool RepairGUI_LimitToleranceDlg::ClickOnApply()
+{
+  if (!onAcceptLocal())
+    return false;
+
+  initName();
+
+  ConstructorsClicked(0);
+
+  return true;
+}
+
+//=================================================================================
+// function : SelectionIntoArgument()
+// purpose  : Called when selection
+//=================================================================================
+void RepairGUI_LimitToleranceDlg::SelectionIntoArgument()
+{
+  myEditCurrentArgument->setText("");
+  myObject = GEOM::GEOM_Object::_nil();
+
+  LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
+  SALOME_ListIO aSelList;
+  aSelMgr->selectedObjects(aSelList);
+
+  if (aSelList.Extent() == 1) {
+    Handle(SALOME_InteractiveObject) anIO = aSelList.First();
+    Standard_Boolean aRes;
+    myObject = GEOMBase::ConvertIOinGEOMObject(anIO, aRes);
+    if (aRes)
+      myEditCurrentArgument->setText(GEOMBase::GetName(myObject));
+  }
+  updateButtonState();
+}
+
+//=================================================================================
+// function : SetEditCurrentArgument()
+// purpose  :
+//=================================================================================
+void RepairGUI_LimitToleranceDlg::SetEditCurrentArgument()
+{
+  const QObject* send = sender();
+  if (send == GroupPoints->PushButton1)  {
+    myEditCurrentArgument->setFocus();
+    SelectionIntoArgument();
+  }
+}
+
+//=================================================================================
+// function : LineEditReturnPressed()
+// purpose  :
+//=================================================================================
+void RepairGUI_LimitToleranceDlg::LineEditReturnPressed()
+{
+  const QObject* send = sender();
+  if (send == GroupPoints->LineEdit1) {
+    myEditCurrentArgument = GroupPoints->LineEdit1;
+    GEOMBase_Skeleton::LineEditReturnPressed();
+  }
+}
+
+//=================================================================================
+// function : ActivateThisDialog()
+// purpose  :
+//=================================================================================
+void RepairGUI_LimitToleranceDlg::ActivateThisDialog()
+{
+  GEOMBase_Skeleton::ActivateThisDialog();
+  connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
+           this, SLOT(SelectionIntoArgument()));
+  activateSelection();
+}
+
+//=================================================================================
+// function : enterEvent()
+// purpose  : Mouse enter onto the dialog to activate it
+//=================================================================================
+void RepairGUI_LimitToleranceDlg::enterEvent(QEvent*)
+{
+  if (!mainFrame()->GroupConstructors->isEnabled())
+    ActivateThisDialog();
+}
+
+//=================================================================================
+// function : createOperation
+// purpose  :
+//=================================================================================
+GEOM::GEOM_IOperations_ptr RepairGUI_LimitToleranceDlg::createOperation()
+{
+  return getGeomEngine()->GetIHealingOperations(getStudyId());
+}
+
+//=================================================================================
+// function : isValid
+// purpose  :
+//=================================================================================
+bool RepairGUI_LimitToleranceDlg::isValid(QString& msg)
+{
+  double v = myTolEdt->value();
+  bool ok = myTolEdt->isValid(msg, true);
+  return !myObject->_is_nil() && (v > 0.) && ok;
+}
+
+//=================================================================================
+// function : execute
+// purpose  :
+//=================================================================================
+bool RepairGUI_LimitToleranceDlg::execute(ObjectList& objects)
+{
+  bool aResult = false;
+  objects.clear();
+
+  GEOM::GEOM_IHealingOperations_var anOper = GEOM::GEOM_IHealingOperations::_narrow(getOperation());
+  GEOM::GEOM_Object_var anObj = anOper->LimitTolerance(myObject, myTolEdt->value());
+  aResult = !anObj->_is_nil();
+  if (aResult) {
+    QStringList aParameters;
+    aParameters << myTolEdt->text();
+    anObj->SetParameters(aParameters.join(":").toLatin1().constData());
+    objects.push_back(anObj._retn());
+  }
+
+  return aResult;
+}
+
+//================================================================
+// Function : onAccept
+// Purpose  : This method should be called from dialog's slots onOk() and onApply()
+//            It perfroms user input validation, then it
+//            performs a proper operation and manages transactions, etc.
+//================================================================
+bool RepairGUI_LimitToleranceDlg::onAcceptLocal()
+{
+  if (!getStudy() || !(getStudy()->studyDS()))
+    return false;
+
+  _PTR(Study) aStudy = getStudy()->studyDS();
+
+  bool aLocked = aStudy->GetProperties()->IsLocked();
+  if (aLocked) {
+    MESSAGE("GEOMBase_Helper::onAccept - ActiveStudy is locked");
+    SUIT_MessageBox::warning(this, tr("WRN_WARNING"), tr("WRN_STUDY_LOCKED"), tr("BUT_OK"));
+    return false;
+  }
+
+  QString msg;
+  if (!isValid(msg)) {
+    showError(msg);
+    return false;
+  }
+
+  try {
+    if (openCommand()) {
+      SUIT_OverrideCursor wc;
+
+      myGeomGUI->getApp()->putInfo("");
+      ObjectList objects;
+
+      if (!execute(objects)) {
+        wc.suspend();
+        abortCommand();
+        showError();
+      }
+      else {
+        const int nbObjs = objects.size();
+        for (ObjectList::iterator it = objects.begin(); it != objects.end(); ++it) {
+          QString aName = getNewObjectName();
+          if (nbObjs > 1) {
+            if (aName.isEmpty())
+              aName = getPrefix(*it);
+            aName = GEOMBase::GetDefaultName(aName);
+          }
+          else {
+            // PAL6521: use a prefix, if some dialog box doesn't reimplement getNewObjectName()
+            if (aName.isEmpty())
+              aName = GEOMBase::GetDefaultName(getPrefix(*it));
+          }
+          addInStudy(*it, aName.toLatin1().data());
+          display(*it, false);
+        }
+
+        if (nbObjs) {
+          commitCommand();
+          updateObjBrowser();
+          myGeomGUI->getApp()->putInfo(QObject::tr("GEOM_PRP_DONE"));
+        }
+        else {
+          abortCommand();
+        }
+
+        // JFA 28.12.2004 BEGIN // To enable warnings
+        GEOM::GEOM_IHealingOperations_var anOper = GEOM::GEOM_IHealingOperations::_narrow(getOperation());
+        if (!CORBA::is_nil(anOper) && !anOper->IsDone()) {
+          wc.suspend();
+          QString msgw = QObject::tr(anOper->GetErrorCode());
+          SUIT_MessageBox::warning(this, tr("WRN_WARNING"), msgw, tr("BUT_OK"));
+        }
+        // JFA 28.12.2004 END
+      }
+    }
+  }
+  catch(const SALOME::SALOME_Exception& e) {
+    SalomeApp_Tools::QtCatchCorbaException(e);
+    abortCommand();
+  }
+
+  updateViewer();
+  activateSelection();
+  updateButtonState();
+
+  return true;
+}
+
+//=================================================================================
+// function : activateSelection
+// purpose  : Activate selection
+//=================================================================================
+void RepairGUI_LimitToleranceDlg::activateSelection()
+{
+  disconnect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
+             this, SLOT(SelectionIntoArgument()));
+
+  globalSelection(GEOM_ALLSHAPES);
+  if (myObject->_is_nil())
+    SelectionIntoArgument();
+
+  connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
+          this, SLOT(SelectionIntoArgument()));
+  updateViewer();
+}
+
+//=================================================================================
+// function : updateButtonState
+// purpose  : Update button state
+//=================================================================================
+void RepairGUI_LimitToleranceDlg::updateButtonState()
+{
+  bool hasMainObj = !myObject->_is_nil();
+  buttonOk()->setEnabled(hasMainObj);
+  buttonApply()->setEnabled(hasMainObj);
+}
+
+//=================================================================================
+// function : restoreSubShapes
+// purpose  :
+//=================================================================================
+void RepairGUI_LimitToleranceDlg::restoreSubShapes(SALOMEDS::Study_ptr   theStudy,
+                                                   SALOMEDS::SObject_ptr theSObject)
+{
+  if (mainFrame()->CheckBoxRestoreSS->isChecked()) {
+    // empty list of arguments means that all arguments should be restored
+    getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, GEOM::ListOfGO(),
+                                        GEOM::FSM_GetInPlace, /*theInheritFirstArg=*/true,
+                                        mainFrame()->CheckBoxAddPrefix->isChecked());
+  }
+}
diff --git a/src/RepairGUI/RepairGUI_LimitToleranceDlg.h b/src/RepairGUI/RepairGUI_LimitToleranceDlg.h
new file mode 100644 (file)
index 0000000..bba1dbf
--- /dev/null
@@ -0,0 +1,83 @@
+//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of the GNU Lesser General Public
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//  GEOM GEOMGUI : GUI for Geometry component
+//  File   : RepairGUI_LimitToleranceDlg.h
+
+#ifndef REPAIRGUI_LIMITTOLERANCEDLG_H
+#define REPAIRGUI_LIMITTOLERANCEDLG_H
+
+#include <GEOMBase_Skeleton.h>
+
+class DlgRef_1SelExt;
+class SalomeApp_DoubleSpinBox;
+class QPushButton;
+class QCheckBox;
+
+//=================================================================================
+// class    : RepairGUI_LimitToleranceDlg
+// purpose  :
+//=================================================================================
+class RepairGUI_LimitToleranceDlg : public GEOMBase_Skeleton
+{
+  Q_OBJECT
+
+public:
+  RepairGUI_LimitToleranceDlg (GeometryGUI*, QWidget* = 0, bool = false);
+  ~RepairGUI_LimitToleranceDlg();
+
+protected:
+  // redefined from GEOMBase_Helper
+  virtual GEOM::GEOM_IOperations_ptr createOperation();
+  virtual bool                       isValid (QString&);
+  virtual bool                       execute (ObjectList&);
+  virtual void                       restoreSubShapes (SALOMEDS::Study_ptr, SALOMEDS::SObject_ptr);
+
+private:
+  void                               Init();
+  void                               enterEvent (QEvent*);
+  void                               initSelection();
+
+  bool                               onAcceptLocal();
+
+  void                               activateSelection();
+  void                               updateButtonState();
+
+private:
+  GEOM::GEOM_Object_var              myObject;
+
+  DlgRef_1SelExt*                    GroupPoints;
+  SalomeApp_DoubleSpinBox*           myTolEdt;
+
+private slots:
+  void                               ClickOnOk();
+  bool                               ClickOnApply();
+
+  void                               ActivateThisDialog();
+
+  void                               LineEditReturnPressed();
+  void                               SelectionIntoArgument();
+  void                               SetEditCurrentArgument();
+
+  void                               ConstructorsClicked( int );
+};
+
+#endif // REPAIRGUI_LIMITTOLERANCEDLG_H