]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
PAL12608: Add possibility to check geometry of a shape.
authorjfa <jfa@opencascade.com>
Wed, 14 Jun 2006 09:48:05 +0000 (09:48 +0000)
committerjfa <jfa@opencascade.com>
Wed, 14 Jun 2006 09:48:05 +0000 (09:48 +0000)
idl/GEOM_Gen.idl
src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx
src/GEOMImpl/GEOMImpl_IMeasureOperations.hxx
src/GEOM_I/GEOM_IMeasureOperations_i.cc
src/GEOM_I/GEOM_IMeasureOperations_i.hh
src/GEOM_SWIG/batchmode_geompy.py
src/GEOM_SWIG/geompy.py
src/MeasureGUI/MeasureGUI_CheckShapeDlg.cxx
src/MeasureGUI/MeasureGUI_CheckShapeDlg.h

index d5d18f0fa41cc29c0593d5774605095ba57eae80..dec1d38cb0bc5f2df6fff693263490c48de09860 100644 (file)
@@ -2021,6 +2021,15 @@ module GEOM
     boolean CheckShape (in GEOM_Object theShape,
                        out string     theDescription);
 
+    /*!
+     *  Check a topology and a geometry of the given shape.
+     *  \param theShape Shape to check validity of.
+     *  \param theDescription Output. Description of problems in the shape, if they are.
+     *  \return TRUE, if the shape "seems to be valid".
+     */
+    boolean CheckShapeWithGeometry (in GEOM_Object theShape,
+                                   out string     theDescription);
+
     /*!
      *  Obtain description of the given shape
      *  \param theShape Shape to be described.
index 94ecb8458ea7d0709a8a754271f8b43733741fbf..cf41d11cc4900dfd32046b019ce6bec31460e05a 100644 (file)
@@ -361,6 +361,7 @@ void GEOMImpl_IMeasureOperations::GetTolerance
  */
 //=============================================================================
 bool GEOMImpl_IMeasureOperations::CheckShape (Handle(GEOM_Object)      theShape,
+                                              const Standard_Boolean   theIsCheckGeom,
                                               TCollection_AsciiString& theDump)
 {
   SetErrorCode(KO);
@@ -379,7 +380,7 @@ bool GEOMImpl_IMeasureOperations::CheckShape (Handle(GEOM_Object)      theShape,
   //Compute the parameters
   bool isValid = false;
   try {
-    BRepCheck_Analyzer ana (aShape, false);
+    BRepCheck_Analyzer ana (aShape, theIsCheckGeom);
     if (ana.IsValid()) {
       theDump.Clear();
       isValid = true;
index d60ba91530e0ec07dcc2d28646be75a1404e5367..2edf60025c3324e3851e4f3185c1ea95b24b5622 100644 (file)
@@ -39,38 +39,40 @@ class GEOMImpl_IMeasureOperations : public GEOM_IOperations {
   Standard_EXPORT Handle(GEOM_Object) GetCentreOfMass (Handle(GEOM_Object) theShape);
 
   Standard_EXPORT void GetBasicProperties (Handle(GEOM_Object) theShape,
-                           Standard_Real& theLength,
-                           Standard_Real& theSurfArea,
-                           Standard_Real& theVolume);
+                                           Standard_Real& theLength,
+                                           Standard_Real& theSurfArea,
+                                           Standard_Real& theVolume);
 
   Standard_EXPORT void GetInertia (Handle(GEOM_Object) theShape,
-                   Standard_Real& I11, Standard_Real& I12, Standard_Real& I13,
-                   Standard_Real& I21, Standard_Real& I22, Standard_Real& I23,
-                   Standard_Real& I31, Standard_Real& I32, Standard_Real& I33,
-                   Standard_Real& Ix , Standard_Real& Iy , Standard_Real& Iz);
+                                   Standard_Real& I11, Standard_Real& I12, Standard_Real& I13,
+                                   Standard_Real& I21, Standard_Real& I22, Standard_Real& I23,
+                                   Standard_Real& I31, Standard_Real& I32, Standard_Real& I33,
+                                   Standard_Real& Ix , Standard_Real& Iy , Standard_Real& Iz);
 
   Standard_EXPORT void GetBoundingBox (Handle(GEOM_Object) theShape,
-                       Standard_Real& Xmin, Standard_Real& Xmax,
-                       Standard_Real& Ymin, Standard_Real& Ymax,
-                       Standard_Real& Zmin, Standard_Real& Zmax);
+                                       Standard_Real& Xmin, Standard_Real& Xmax,
+                                       Standard_Real& Ymin, Standard_Real& Ymax,
+                                       Standard_Real& Zmin, Standard_Real& Zmax);
 
   Standard_EXPORT void GetTolerance (Handle(GEOM_Object) theShape,
-                     Standard_Real& FaceMin, Standard_Real& FaceMax,
-                     Standard_Real& EdgeMin, Standard_Real& EdgeMax,
-                     Standard_Real& VertMin, Standard_Real& VertMax);
+                                     Standard_Real& FaceMin, Standard_Real& FaceMax,
+                                     Standard_Real& EdgeMin, Standard_Real& EdgeMax,
+                                     Standard_Real& VertMin, Standard_Real& VertMax);
 
   Standard_EXPORT bool CheckShape (Handle(GEOM_Object)      theShape,
-                   TCollection_AsciiString& theDump);
+                                   const Standard_Boolean   theIsCheckGeom,
+                                   TCollection_AsciiString& theDump);
 
   Standard_EXPORT TCollection_AsciiString WhatIs (Handle(GEOM_Object) theShape);
 
-  Standard_EXPORT Standard_Real GetMinDistance (Handle(GEOM_Object) theShape1, Handle(GEOM_Object) theShape2,
-                                Standard_Real& X1, Standard_Real& Y1, Standard_Real& Z1,
-                                Standard_Real& X2, Standard_Real& Y2, Standard_Real& Z2);
+  Standard_EXPORT Standard_Real GetMinDistance (Handle(GEOM_Object) theShape1,
+                                                Handle(GEOM_Object) theShape2,
+                                                Standard_Real& X1, Standard_Real& Y1, Standard_Real& Z1,
+                                                Standard_Real& X2, Standard_Real& Y2, Standard_Real& Z2);
+
+  Standard_EXPORT void PointCoordinates(Handle(GEOM_Object) theShape,
+                                        Standard_Real& theX, Standard_Real& theY, Standard_Real& theZ );
 
- Standard_EXPORT void PointCoordinates( Handle(GEOM_Object) theShape,
-                        Standard_Real& theX, Standard_Real& theY, Standard_Real& theZ );
  private:
   void StructuralDump (const BRepCheck_Analyzer& theAna,
                        const TopoDS_Shape&       theShape,
index c29bf81d28ca5c947e5cc86b8931156aee46def8..4e7112a223ef0f9712a31221363a55bd9a6b1b34 100644 (file)
@@ -219,7 +219,40 @@ CORBA::Boolean GEOM_IMeasureOperations_i::CheckShape (GEOM::GEOM_Object_ptr theS
 
   // Get shape parameters
   TCollection_AsciiString aDump;
-  if (GetOperations()->CheckShape(aShape, aDump))
+  if (GetOperations()->CheckShape(aShape, /*check_geom = */false, aDump))
+  {
+    theDescription = CORBA::string_dup("OK");
+    return 1;
+  }
+  theDescription = CORBA::string_dup(aDump.ToCString());
+  return 0;
+}
+
+CORBA::Boolean GEOM_IMeasureOperations_i::CheckShapeWithGeometry (GEOM::GEOM_Object_ptr theShape,
+                                                                 CORBA::String_out     theDescription)
+{
+  //Set a not done flag
+  GetOperations()->SetNotDone();
+
+  if (theShape == NULL) 
+  {
+    theDescription = CORBA::string_dup("null");
+    return 0;
+  }
+
+  //Get the reference shape
+  Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
+    (theShape->GetStudyID(), theShape->GetEntry());
+
+  if (aShape.IsNull())
+  {
+    theDescription = CORBA::string_dup("null2");
+    return 0;
+  }
+
+  // Get shape parameters
+  TCollection_AsciiString aDump;
+  if (GetOperations()->CheckShape(aShape, /*check_geom = */true, aDump))
   {
     theDescription = CORBA::string_dup("OK");
     return 1;
index 99713a3bc3718e92c7589a5edf0fefd82d525661..be0eda22dfe313f8dbda447ebdeea1a84fdd7055 100644 (file)
@@ -65,6 +65,9 @@ class GEOM_IMeasureOperations_i :
   CORBA::Boolean CheckShape (GEOM::GEOM_Object_ptr theShape,
                             CORBA::String_out     theDescription);
 
+  CORBA::Boolean CheckShapeWithGeometry (GEOM::GEOM_Object_ptr theShape,
+                                        CORBA::String_out     theDescription);
+
   char* WhatIs (GEOM::GEOM_Object_ptr theShape);
 
   CORBA::Double GetMinDistance (GEOM::GEOM_Object_ptr theShape1,
index 6d280f1f8298f807b73d331296f1476c52f7a6dc..dc34cd4d0e8642b8312317142350d4c35236c725 100644 (file)
@@ -920,8 +920,12 @@ def MakeCDG(aShape):
       print "GetCentreOfMass : ", MeasuOp.GetErrorCode()
     return anObj
 
-def CheckShape(aShape):
-    (IsValid, Status) = MeasuOp.CheckShape(aShape)
+def CheckShape(aShape, theIsCheckGeom = 0):
+    if theIsCheckGeom:
+        (IsValid, Status) = MeasuOp.CheckShapeWithGeometry(theShape)
+    else:
+        (IsValid, Status) = MeasuOp.CheckShape(theShape)
+
     if MeasuOp.IsDone() == 0:
       print "CheckShape : ", MeasuOp.GetErrorCode()
     else:
index b3d72514e5fba832b522455ffa2569035278c5b9..4e597a749269be5086dd63d26591b41b103eda55 100644 (file)
@@ -1775,12 +1775,18 @@ def MakeCDG(theShape):
 
 ## Check a topology of the given shape.
 #  @param theShape Shape to check validity of.
-#  @return TRUE, if the shape "seems to be valid" from the topological point of view.
+#  @param theIsCheckGeom If FALSE, only the shape's topology will be checked,
+#                        if TRUE, the shape's geometry will be checked also.
+#  @return TRUE, if the shape "seems to be valid".
 #  If theShape is invalid, prints a description of problem.
 #
 #  Example: see GEOM_TestMeasures.py
-def CheckShape(theShape):
-    (IsValid, Status) = MeasuOp.CheckShape(theShape)
+def CheckShape(theShape, theIsCheckGeom = 0):
+    if theIsCheckGeom:
+        (IsValid, Status) = MeasuOp.CheckShapeWithGeometry(theShape)
+    else:
+        (IsValid, Status) = MeasuOp.CheckShape(theShape)
+
     if MeasuOp.IsDone() == 0:
       print "CheckShape : ", MeasuOp.GetErrorCode()
     else:
index 848e9ff86ce8fda8473515fda44e9f76cbe72ffe..795107a57f971dd3fea88594c66efbc455d6fcaa 100644 (file)
@@ -17,7 +17,7 @@
 //  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
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 //
 //
@@ -27,7 +27,6 @@
 //  $Header$
 
 #include "MeasureGUI_CheckShapeDlg.h"
-#include "MeasureGUI_1Sel1TextView_QTD.h"
 
 #include "utilities.h"
 #include "SUIT_Session.h"
 #include <qpushbutton.h>
 #include <qradiobutton.h>
 #include <qbuttongroup.h>
+#include <qcheckbox.h>
 
 #define TEXTEDIT_FONT_FAMILY "Courier"
 #define TEXTEDIT_FONT_SIZE 11
 
+MeasureGUI_1Sel1TextView1Check_QTD::MeasureGUI_1Sel1TextView1Check_QTD(QWidget* parent,
+                                                                       const char* name, WFlags fl)
+  : MeasureGUI_1Sel1TextView_QTD(parent, name, fl)
+{
+  CheckBoxGeom = new QCheckBox(GroupBox1, "CheckBoxGeom");
+  CheckBoxGeom->setText(tr("CHECK_SHAPE_GEOMETRY"));
+  Layout1->addMultiCellWidget(CheckBoxGeom, 2, 2, 0, 2);
+
+  CheckBoxGeom->setChecked(false);
+}
+
+MeasureGUI_1Sel1TextView1Check_QTD::~MeasureGUI_1Sel1TextView1Check_QTD()
+{
+  // no need to delete child widgets, Qt does it all for us
+}
+
 //=================================================================================
 // class    : MeasureGUI_CheckShapeDlg()
 // purpose  : Constructs a MeasureGUI_CheckShapeDlg which is a child of 'parent', with the
@@ -66,11 +82,11 @@ MeasureGUI_CheckShapeDlg::MeasureGUI_CheckShapeDlg( GeometryGUI* GUI, QWidget* p
   GroupConstructors->setTitle( tr( "GEOM_CHECK_SHAPE" ) );
   RadioButton1->setPixmap( image0 );
 
-  myGrp = new MeasureGUI_1Sel1TextView_QTD( this, "myGrp" );
+  myGrp = new MeasureGUI_1Sel1TextView1Check_QTD( this, "myGrp" );
   myGrp->GroupBox1->setTitle( tr( "GEOM_CHECK_INFOS" ) );
   myGrp->TextLabel1->setText( tr( "GEOM_OBJECT" ) );
   myGrp->TextEdit1->setReadOnly( TRUE );
-  
+
   QFont aFont( TEXTEDIT_FONT_FAMILY, TEXTEDIT_FONT_SIZE );
   aFont.setStyleHint( QFont::TypeWriter, QFont::PreferAntialias );
   myGrp->TextEdit1->setFont( aFont );
@@ -87,7 +103,6 @@ MeasureGUI_CheckShapeDlg::MeasureGUI_CheckShapeDlg( GeometryGUI* GUI, QWidget* p
   Init();
 }
 
-
 //=================================================================================
 // function : ~MeasureGUI_CheckShapeDlg()
 // purpose  : Destroys the object and frees any allocated resources
@@ -106,6 +121,9 @@ void MeasureGUI_CheckShapeDlg::Init()
   mySelBtn = myGrp->PushButton1;
   mySelEdit = myGrp->LineEdit1;
   MeasureGUI_Skeleton::Init();
+
+  connect(myGrp->CheckBoxGeom, SIGNAL(toggled(bool)), 
+          this, SLOT(SelectionIntoArgument()));
 }
 
 //=================================================================================
@@ -121,7 +139,13 @@ bool MeasureGUI_CheckShapeDlg::getParameters ( bool& theIsValid, QString& theMsg
     try
     {
       char* aMsg;
-      theIsValid = GEOM::GEOM_IMeasureOperations::_narrow( getOperation() )->CheckShape( myObj, aMsg );
+      bool isCheckGeometry = myGrp->CheckBoxGeom->isChecked();
+      GEOM::GEOM_IMeasureOperations_ptr aMeasureOp =
+        GEOM::GEOM_IMeasureOperations::_narrow( getOperation() );
+      if (isCheckGeometry)
+        theIsValid = aMeasureOp->CheckShapeWithGeometry(myObj, aMsg);
+      else
+        theIsValid = aMeasureOp->CheckShape(myObj, aMsg);
       theMsg = aMsg;
     }
     catch( const SALOME::SALOME_Exception& e )
index bedb840fe2d59f373db0b4670f41981c72d023ed..b4d97f6c1bdef05f6ad783ea9f2dd2408c701c69 100644 (file)
 //  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
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 //
 //
 //  File   : MeasureGUI_CheckShapeDlg.h
 //  Author : Nicolas REJNERI
 //  Module : GEOM
-//  $Header$
 
 #ifndef DIALOGBOX_CHECKSHAPEDLG_H
 #define DIALOGBOX_CHECKSHAPEDLG_H
 
 #include "MeasureGUI_Skeleton.h"
+#include "MeasureGUI_1Sel1TextView_QTD.h"
 
-class MeasureGUI_1Sel1TextView_QTD;
+class QCheckBox;
 
 #if defined WNT && defined MEASUREGUI_EXPORTS
 #define MEASUREGUI_EXPORT __declspec( dllexport )
@@ -39,6 +39,21 @@ class MeasureGUI_1Sel1TextView_QTD;
 #define MEASUREGUI_EXPORT
 #endif
 
+//=================================================================================
+// class    : MeasureGUI_1Sel1TextView1Check_QTD
+// purpose  :
+//=================================================================================
+class MeasureGUI_1Sel1TextView1Check_QTD : public MeasureGUI_1Sel1TextView_QTD
+{ 
+    Q_OBJECT
+
+public:
+    MeasureGUI_1Sel1TextView1Check_QTD( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
+    ~MeasureGUI_1Sel1TextView1Check_QTD();
+
+    QCheckBox* CheckBoxGeom;
+};
+
 //=================================================================================
 // class    : MeasureGUI_CheckShapeDlg
 // purpose  :
@@ -48,24 +63,19 @@ class MEASUREGUI_EXPORT MeasureGUI_CheckShapeDlg : public MeasureGUI_Skeleton
     Q_OBJECT
 
 public:
-                                        MeasureGUI_CheckShapeDlg( GeometryGUI* GUI,
-                                                                 QWidget*     parent );
-                                        ~MeasureGUI_CheckShapeDlg();
-protected:
+    MeasureGUI_CheckShapeDlg(GeometryGUI* GUI, QWidget* parent);
+    ~MeasureGUI_CheckShapeDlg();
 
+protected:
     // redefined from GEOMBase_Helper and MeasureGUI_Skeleton
-    virtual void                        processObject();
+    virtual void processObject();
 
 private:
-
-    void                                Init();
-    bool                                getParameters( bool& theIsValid,
-                                                      QString& theMsg);
+    void Init();
+    bool getParameters(bool& theIsValid, QString& theMsg);
 
 private:
-
-    MeasureGUI_1Sel1TextView_QTD*        myGrp;
-
+    MeasureGUI_1Sel1TextView1Check_QTD* myGrp;
 };
 
 #endif // DIALOGBOX_CHECKSHAPEDLG_H