]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
0022775: Update CheckCompoundOfBlocks to have same bahavior as GetNonBlocks
authorskv <skv@opencascade.com>
Fri, 23 Jan 2015 14:39:09 +0000 (17:39 +0300)
committerskv <skv@opencascade.com>
Fri, 23 Jan 2015 14:39:09 +0000 (17:39 +0300)
12 files changed:
idl/GEOM_Gen.idl
src/AdvancedEngine/AdvancedEngine_IOperations.cxx
src/BlockFix/BlockFix_CheckTool.cxx
src/BlockFix/BlockFix_CheckTool.hxx
src/GEOMImpl/GEOMImpl_IBlocksOperations.cxx
src/GEOMImpl/GEOMImpl_IBlocksOperations.hxx
src/GEOM_I/GEOM_IBlocksOperations_i.cc
src/GEOM_I/GEOM_IBlocksOperations_i.hh
src/GEOM_I_Superv/GEOM_Superv_i.cc
src/GEOM_SWIG/geomBuilder.py
src/MeasureGUI/MeasureGUI_CheckCompoundOfBlocksDlg.cxx
src/MeasureGUI/MeasureGUI_CheckCompoundOfBlocksDlg.h

index 890d9b52ba83f1d22c4184c741b6cc367ec41d61..c30f67405fae9f1ff6b5ff1757cb0c77456bbc98 100644 (file)
@@ -2761,10 +2761,14 @@ module GEOM
      *  - The glue between two quadrangle faces should be applied.
      *    \note Single block is also accepted as a valid compound of blocks.
      *  \param theCompound The compound to check.
+     *  \param theToleranceC1 the tolerance to check if two neighbor edges are
+     *         collinear in the common vertex with this tolerance. Negative
+     *         value means that C1 criterion is not used (old implementation).
      *  \param theErrors Structure, containing discovered errors and incriminated sub-shapes.
      *  \return TRUE, if the given shape is a compound of blocks.
      */
     boolean CheckCompoundOfBlocks (in GEOM_Object theCompound,
+                                   in double      theToleranceC1,
                                    out BCErrors   theErrors);
 
     /*!
index 5d1b969995fee701998cb4b88ebbda543826ca3d..ad7650b00065f58628329c1c92108f9cc500c3c4 100644 (file)
@@ -1583,7 +1583,7 @@ bool AdvancedEngine_IOperations::MakePipeTShapePartition(Handle(GEOM_Object) the
 
     // Last verification: result should be a block
     std::list<GEOMImpl_IBlocksOperations::BCError> errList;
-    if (!myBlocksOperations->CheckCompoundOfBlocks(Te3,errList)) {
+    if (!myBlocksOperations->CheckCompoundOfBlocks(Te3, -1, errList)) {
       SetErrorCode("TShape is not a compound of block");
       return false;
     }
index 32c0714be12bc8ddfe723351794ca404b496ab0a..36e527550605b9afac35c33dc370a3fa6b2eef37 100644 (file)
 
 #include <BRep_Tool.hxx>
 
+#include <Geom_Curve.hxx>
+
+#include <gp_Pnt.hxx>
+#include <gp_Vec.hxx>
+
 #include <TopExp.hxx>
 #include <TopExp_Explorer.hxx>
 
 #include <TopoDS_Face.hxx>
 #include <TopoDS_Solid.hxx>
 #include <TopoDS_Shape.hxx>
+#include <TopoDS_Vertex.hxx>
 
 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
 #include <TopTools_MapOfShape.hxx>
 #include <TopTools_ListOfShape.hxx>
 #include <TopTools_ListIteratorOfListOfShape.hxx>
@@ -49,6 +56,7 @@
 BlockFix_CheckTool::BlockFix_CheckTool( )
 {
   myHasCheck = Standard_False;
+  myAngTolerance = -1.;
   myPossibleBlocks.Clear();
 }
 
@@ -63,6 +71,17 @@ void BlockFix_CheckTool::SetShape(const TopoDS_Shape& aShape)
   myPossibleBlocks.Clear();
 }
 
+//=======================================================================
+//function : SetAngTolerance
+//purpose  :
+//=======================================================================
+void BlockFix_CheckTool::SetAngTolerance(const Standard_Real theTolerance)
+{
+  myHasCheck     = Standard_False;
+  myAngTolerance = theTolerance;
+  myPossibleBlocks.Clear();
+}
+
 //=======================================================================
 //function : Perform
 //purpose  :
@@ -159,7 +178,6 @@ void BlockFix_CheckTool::Perform()
     if (nbe < 12)
       IsBlock = Standard_False;
     if (nbe > 12) {
-      IsBlock = Standard_False;
       // check edges unification
       // creating map of edge faces
       TopTools_IndexedDataMapOfShapeListOfShape aMapEdgeFaces;
@@ -194,9 +212,19 @@ void BlockFix_CheckTool::Perform()
         Standard_Integer i = 1;
         for (; i <= aMapFacesEdges.Extent(); i++) {
           const TopTools_ListOfShape& ListEdges = aMapFacesEdges.FindFromIndex(i);
-          if (ListEdges.Extent() > 1) break;
+          if (ListEdges.Extent() > 1) {
+            if (myAngTolerance < 0.) {
+              break;
+            }
+
+            // Check if edges have C1 continuity.
+            if (!isC1(ListEdges)) {
+              break;
+            }
+          }
         }
         if (i <= aMapFacesEdges.Extent()) {
+          IsBlock = Standard_False;
           MayBeUE = Standard_True;
           break;
         }
@@ -265,3 +293,84 @@ void BlockFix_CheckTool::DumpCheckResult(Standard_OStream& S) const
     S<<"             number of impossible blocks = "<<nbtmp<<endl;
   }
 }
+
+//=======================================================================
+//function : isC1
+//purpose  :
+//=======================================================================
+Standard_Boolean BlockFix_CheckTool::isC1
+          (const TopTools_ListOfShape &theEdges) const
+{
+  // Fill the map vertex - list of ancestor edges
+  TopTools_IndexedDataMapOfShapeListOfShape aMapVE;
+  TopTools_ListIteratorOfListOfShape        anIter(theEdges);
+  TopTools_MapOfShape                       aMapFence;
+  Standard_Integer                          i;
+  Standard_Integer                          aNbVtx;
+
+  for (; anIter.More(); anIter.Next()) {
+    TopTools_IndexedMapOfShape  aMapVtx;
+    const TopoDS_Shape         &anEdge = anIter.Value();
+
+    if (aMapFence.Add(anEdge)) {
+      TopExp::MapShapes(anEdge, TopAbs_VERTEX, aMapVtx);
+      aNbVtx = aMapVtx.Extent();
+
+      for (i = 1; i <= aNbVtx; ++i) {
+        const TopoDS_Shape &aVtx = aMapVtx.FindKey(i);
+
+        if (!aMapVE.Contains(aVtx)) {
+          aMapVE.Add(aVtx, TopTools_ListOfShape());
+        }
+
+        aMapVE.ChangeFromKey(aVtx).Append(anEdge);
+      }
+    }
+  }
+
+  // Check C1 continuity.
+  Standard_Integer aNbEnds = 0;
+
+  for (i = 1, aNbVtx = aMapVE.Extent(); i <= aNbVtx; ++i) {
+    const TopTools_ListOfShape &anEdges  = aMapVE.FindFromIndex(i);
+    Standard_Integer            aNbEdges = anEdges.Extent();
+
+    if (aNbEdges == 1) {
+      ++aNbEnds;
+    } else if (aNbEdges == 2) {
+      TopoDS_Vertex      aCommonVtx = TopoDS::Vertex(aMapVE.FindKey(i));
+      TopoDS_Edge        anEdge1    = TopoDS::Edge(anEdges.First());
+      TopoDS_Edge        anEdge2    = TopoDS::Edge(anEdges.Last());
+      Standard_Real      aParam1    = BRep_Tool::Parameter(aCommonVtx, anEdge1);
+      Standard_Real      aParam2    = BRep_Tool::Parameter(aCommonVtx, anEdge2);
+      Standard_Real      aPar[2];
+      Handle(Geom_Curve) aCurve1    =
+        BRep_Tool::Curve(anEdge1, aPar[0], aPar[1]);
+      Handle(Geom_Curve) aCurve2    =
+        BRep_Tool::Curve(anEdge2, aPar[0], aPar[1]);
+      gp_Pnt             aPnt;
+      gp_Vec             aVec1;
+      gp_Vec             aVec2;
+
+      aCurve1->D1(aParam1, aPnt, aVec1);
+      aCurve2->D1(aParam2, aPnt, aVec2);
+
+      if (anEdge1.Orientation() != anEdge2.Orientation()) {
+        // Orientations are different. One vector should be reversed.
+        aVec1.Reverse();
+      }
+
+      const Standard_Real anAngle = aVec1.Angle(aVec2);
+
+      if (anAngle > myAngTolerance) {
+        // There is no C1 continuity.
+        break;
+      }
+    } else {
+      // Non-manifold case.
+      break;
+    }
+  }
+
+  return (i > aNbVtx && aNbEnds == 2);
+}
index 83bd5b3c158942595f2a0b051b29506ee126ca1b..66711433c9b2d94c7cf422121265f1ca292ddd6b 100644 (file)
@@ -30,6 +30,7 @@
 #include <Standard_OStream.hxx>
 
 class TopoDS_Shape;
+class TopTools_ListOfShape;
 
 #include <Standard.hxx>
 #include <Standard_Macro.hxx>
@@ -38,14 +39,20 @@ class BlockFix_CheckTool {
 
 public:
   Standard_EXPORT BlockFix_CheckTool();
-  Standard_EXPORT void SetShape(const TopoDS_Shape& aShape) ;
+  Standard_EXPORT void SetShape(const TopoDS_Shape& aShape);
+  Standard_EXPORT void SetAngTolerance(const Standard_Real theTolerance);
   Standard_EXPORT void Perform() ;
   Standard_EXPORT Standard_Integer NbPossibleBlocks() const;
   Standard_EXPORT TopoDS_Shape PossibleBlock(const Standard_Integer num) const;
   Standard_EXPORT void DumpCheckResult(Standard_OStream& S) const;
 
 private:
-  TopoDS_Shape myShape;
+
+  Standard_Boolean isC1(const TopTools_ListOfShape &theEdges) const;
+
+private:
+  TopoDS_Shape     myShape;
+  Standard_Real    myAngTolerance;
   Standard_Boolean myHasCheck;
   Standard_Integer myNbSolids;
   Standard_Integer myNbBlocks;
index 8eb8f09da895767c789f60697b8a3885106de316..2a733c51e22ea048d7f36b67027af3e6a8dc3dde 100644 (file)
@@ -1808,6 +1808,7 @@ void GEOMImpl_IBlocksOperations::AddBlocksFrom (const TopoDS_Shape&   theShape,
       // Check, if there are seam or degenerated edges
       BlockFix_CheckTool aTool;
       aTool.SetShape(theShape);
+      aTool.SetAngTolerance(theToleranceC1);
       aTool.Perform();
       if (aTool.NbPossibleBlocks() > 0) {
         EXT.Append(theShape);
@@ -2139,6 +2140,7 @@ TCollection_AsciiString GEOMImpl_IBlocksOperations::PrintBCErrors
 //=============================================================================
 Standard_Boolean GEOMImpl_IBlocksOperations::CheckCompoundOfBlocks
                                               (Handle(GEOM_Object) theCompound,
+                                               const Standard_Real theToleranceC1,
                                                std::list<BCError>& theErrors)
 {
   SetErrorCode(KO);
@@ -2157,7 +2159,7 @@ Standard_Boolean GEOMImpl_IBlocksOperations::CheckCompoundOfBlocks
   TopTools_ListOfShape EXT; // Hexahedral solids, having degenerated and/or seam edges
   TopTools_ListOfShape BLO; // All blocks from the given compound
   TopTools_ListOfShape NOQ; // All non-quadrangular faces
-  AddBlocksFrom(aBlockOrComp, BLO, NOT, EXT, NOQ, -1.);
+  AddBlocksFrom(aBlockOrComp, BLO, NOT, EXT, NOQ, theToleranceC1);
 
   // Report non-blocks
   if (NOT.Extent() > 0) {
index 34162d6ed240873f6325fdaff864678049e2b558..568872a083e0e260570349c79c1a5262b78979f7 100644 (file)
@@ -126,6 +126,7 @@ class GEOMImpl_IBlocksOperations : public GEOM_IOperations {
   };
 
   Standard_EXPORT Standard_Boolean CheckCompoundOfBlocks (Handle(GEOM_Object) theCompound,
+                                                          const Standard_Real theToleranceC1,
                                                           std::list<BCError>& theErrors);
 
   Standard_EXPORT TCollection_AsciiString PrintBCErrors (Handle(GEOM_Object)       theCompound,
index 572cdd7f9135684dbff468b4c9a9f458fb7cfabe..513ffa752b9fd255881e78803c2772286cf764e7 100644 (file)
@@ -614,6 +614,7 @@ CORBA::Boolean GEOM_IBlocksOperations_i::IsCompoundOfBlocks
 //=============================================================================
 CORBA::Boolean GEOM_IBlocksOperations_i::CheckCompoundOfBlocks
                                           (GEOM::GEOM_Object_ptr theCompound,
+                                           const CORBA::Double   theToleranceC1,
                                            GEOM::GEOM_IBlocksOperations::BCErrors_out theErrors)
 {
   CORBA::Boolean isComp = false;
@@ -627,7 +628,8 @@ CORBA::Boolean GEOM_IBlocksOperations_i::CheckCompoundOfBlocks
 
   //Check
   std::list<GEOMImpl_IBlocksOperations::BCError> errList;
-  isComp = GetOperations()->CheckCompoundOfBlocks(aCompound, errList);
+  isComp = GetOperations()->CheckCompoundOfBlocks
+    (aCompound, theToleranceC1, errList);
   if (!GetOperations()->IsDone())
     return isComp;
 
index 482ea8a8e21603cb927b36855d3fdd739bc970e1..7755eeb640b7b5828af10fb044f79e70a7952d66 100644 (file)
@@ -116,6 +116,7 @@ class GEOM_I_EXPORT GEOM_IBlocksOperations_i :
                                     CORBA::Long&          theNbBlocks);
 
   CORBA::Boolean CheckCompoundOfBlocks (GEOM::GEOM_Object_ptr theCompound,
+                                        const CORBA::Double   theToleranceC1,
                                        GEOM::GEOM_IBlocksOperations::BCErrors_out theErrors);
 
   char* PrintBCErrors (GEOM::GEOM_Object_ptr theCompound,
index 867a5c6f7cea632c19746847fad64ae03b00bc4a..0324e6e59bda01f69228d32c2c90427ebd9af8e7 100644 (file)
@@ -2713,7 +2713,7 @@ CORBA::Boolean GEOM_Superv_i::CheckCompoundOfBlocks
   beginService( " GEOM_Superv_i::CheckCompoundOfBlocks" );
   MESSAGE("GEOM_Superv_i::CheckCompoundOfBlocks");
   getBlocksOp();
-  CORBA::Boolean aRes = myBlocksOp->CheckCompoundOfBlocks(theCompound, theErrors);
+  CORBA::Boolean aRes = myBlocksOp->CheckCompoundOfBlocks(theCompound, -1., theErrors);
   endService( " GEOM_Superv_i::CheckCompoundOfBlocks" );
   return aRes;
 }
index 652b4173b2be4307512abcb39596a21addc039a1..8cc95a2621a5c167e047b763c5e3048f632a8e02 100644 (file)
@@ -11393,36 +11393,62 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
         ## Check, if the compound of blocks is given.
         #  To be considered as a compound of blocks, the
         #  given shape must satisfy the following conditions:
-        #  - Each element of the compound should be a Block (6 faces and 12 edges).
+        #  - Each element of the compound should be a Block (6 faces).
+        #  - Each face should be a quadrangle, i.e. it should have only 1 wire
+        #       with 4 edges. If <VAR>theIsUseC1</VAR> is set to True and
+        #       there are more than 4 edges in the only wire of a face,
+        #       this face is considered to be quadrangle if it has 4 bounds
+        #       (1 or more edge) of C1 continuity.
         #  - A connection between two Blocks should be an entire quadrangle face or an entire edge.
         #  - The compound should be connexe.
         #  - The glue between two quadrangle faces should be applied.
         #  @param theCompound The compound to check.
+        #  @param theIsUseC1 Flag to check if there are 4 bounds on a face
+        #         taking into account C1 continuity.
+        #  @param theAngTolerance the angular tolerance to check if two neighbor
+        #         edges are codirectional in the common vertex with this
+        #         tolerance. This parameter is used only if
+        #         <VAR>theIsUseC1</VAR> is set to True.
         #  @return TRUE, if the given shape is a compound of blocks.
         #  If theCompound is not valid, prints all discovered errors.
         #
         #  @ref tui_measurement_tools_page "Example 1"
         #  \n @ref swig_CheckCompoundOfBlocks "Example 2"
         @ManageTransactions("BlocksOp")
-        def CheckCompoundOfBlocks(self,theCompound):
+        def CheckCompoundOfBlocks(self,theCompound, theIsUseC1 = False,
+                                  theAngTolerance = 1.e-12):
             """
             Check, if the compound of blocks is given.
             To be considered as a compound of blocks, the
             given shape must satisfy the following conditions:
-            - Each element of the compound should be a Block (6 faces and 12 edges).
+            - Each element of the compound should be a Block (6 faces).
+            - Each face should be a quadrangle, i.e. it should have only 1 wire
+                 with 4 edges. If theIsUseC1 is set to True and
+                 there are more than 4 edges in the only wire of a face,
+                 this face is considered to be quadrangle if it has 4 bounds
+                 (1 or more edge) of C1 continuity.
             - A connection between two Blocks should be an entire quadrangle face or an entire edge.
             - The compound should be connexe.
             - The glue between two quadrangle faces should be applied.
 
             Parameters:
                 theCompound The compound to check.
+                theIsUseC1 Flag to check if there are 4 bounds on a face
+                           taking into account C1 continuity.
+                theAngTolerance the angular tolerance to check if two neighbor
+                           edges are codirectional in the common vertex with this
+                           tolerance. This parameter is used only if
+                           theIsUseC1 is set to True.
 
             Returns:
                 TRUE, if the given shape is a compound of blocks.
                 If theCompound is not valid, prints all discovered errors.
             """
             # Example: see GEOM_Spanner.py
-            (IsValid, BCErrors) = self.BlocksOp.CheckCompoundOfBlocks(theCompound)
+            aTolerance = -1.0
+            if theIsUseC1:
+                aTolerance = theAngTolerance
+            (IsValid, BCErrors) = self.BlocksOp.CheckCompoundOfBlocks(theCompound, aTolerance)
             RaiseIfFailed("CheckCompoundOfBlocks", self.BlocksOp)
             if IsValid == 0:
                 Descr = self.BlocksOp.PrintBCErrors(theCompound, BCErrors)
index 8d7961412765ad02225d303a9b7aff54f7afb835..eee95b56b0fe355eff832d3fde1757bfae8fe127 100644 (file)
@@ -26,7 +26,6 @@
 //
 #include "MeasureGUI.h"
 #include "MeasureGUI_CheckCompoundOfBlocksDlg.h"
-#include "MeasureGUI_Widgets.h"
 
 #include <SUIT_Session.h>
 #include <SUIT_ResourceMgr.h>
@@ -43,6 +42,8 @@
 #include <GEOMBase.h>
 #include <GEOMImpl_Types.hxx>
 
+#include <QListWidget>
+
 #define TEXTEDIT_FONT_FAMILY "Courier"
 #define TEXTEDIT_FONT_SIZE 11
 
 //            true to construct a modal dialog.
 //=================================================================================
 MeasureGUI_CheckCompoundOfBlocksDlg::MeasureGUI_CheckCompoundOfBlocksDlg( GeometryGUI* GUI, QWidget* parent )
-  : GEOMBase_Skeleton( GUI, parent, false )
+  : GEOMBase_Skeleton(GUI, parent, false),
+    myObjectName     (0),
+    mySelButton      (0),
+    myUseC1Check     (0),
+    myTolLbl         (0),
+    mySpinTol        (0),
+    myTextView       (0),
+    myListBox1       (0),
+    myListBox2       (0)
 {
   SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
   QPixmap image0( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_CHECK_COMPOUND_OF_BLOCKS" ) ) );
@@ -70,29 +79,55 @@ MeasureGUI_CheckCompoundOfBlocksDlg::MeasureGUI_CheckCompoundOfBlocksDlg( Geomet
   mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose );
   mainFrame()->RadioButton3->close();
 
-  myGrp = new MeasureGUI_1Sel1TextView2ListBox( centralWidget() );
-  myGrp->GroupBox1->setTitle( tr( "GEOM_CHECK_INFOS" ) );
-  myGrp->TextLabel1->setText( tr( "GEOM_OBJECT" ) );
-
-  myGrp->TextView1->setReadOnly( true );
-  QFont aFont( TEXTEDIT_FONT_FAMILY, TEXTEDIT_FONT_SIZE );
-  aFont.setStyleHint( QFont::TypeWriter, QFont::PreferAntialias );
-  myGrp->TextView1->setFont( aFont );
-
-  myGrp->PushButton1->setIcon( image1 );
-  myGrp->LineEdit1->setReadOnly( true );
-
-  myGrp->TextLabel2->setText( tr( "GEOM_CHECK_BLOCKS_COMPOUND_ERRORS" ) );
-  myGrp->TextLabel3->setText( tr( "GEOM_CHECK_BLOCKS_COMPOUND_SUBSHAPES" ) );
-
-  myGrp->ListBox2->setSelectionMode( QAbstractItemView::ExtendedSelection );
+  QGroupBox   *aGrpParams    =
+    new QGroupBox(tr("GEOM_CHECK_INFOS"), centralWidget());
+  QGridLayout *aParamsLayout = new QGridLayout(aGrpParams);
+  QLabel      *anObjLbl      = new QLabel(tr("GEOM_OBJECT"), aGrpParams);
+  QLabel      *anErrorsLbl   =
+    new QLabel(tr("GEOM_CHECK_BLOCKS_COMPOUND_ERRORS"), aGrpParams);
+  QLabel      *aNonBlocksLbl =
+    new QLabel(tr("GEOM_CHECK_BLOCKS_COMPOUND_SUBSHAPES"), aGrpParams);
+
+  myObjectName = new QLineEdit(aGrpParams);
+  mySelButton  = new QPushButton(aGrpParams);
+  myUseC1Check = new QCheckBox(tr("GEOM_USE_C1_CRITERION"), aGrpParams);
+  myTolLbl     = new QLabel(tr("GEOM_ANGULAR_TOLERANCE"), aGrpParams);
+  mySpinTol    = new SalomeApp_DoubleSpinBox(aGrpParams);
+  myTextView   = new QTextBrowser(aGrpParams);
+  myListBox1   = new QListWidget(aGrpParams);
+  myListBox2   = new QListWidget(aGrpParams);
+
+  myObjectName->setReadOnly(true);
+  mySelButton->setIcon(image1);
+  mySelButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+  myUseC1Check->setText(tr("GEOM_USE_C1_CRITERION"));
+  myUseC1Check->setChecked(true);
+  myTextView->setReadOnly(true);
+  myListBox2->setSelectionMode(QAbstractItemView::ExtendedSelection);
+
+  // Set text view font.
+  QFont aFont(TEXTEDIT_FONT_FAMILY, TEXTEDIT_FONT_SIZE);
+
+  aFont.setStyleHint(QFont::TypeWriter, QFont::PreferAntialias);
+  myTextView->setFont(aFont);
+
+  aParamsLayout->setMargin(9);
+  aParamsLayout->setSpacing(6);
+  aParamsLayout->addWidget(anObjLbl,      0, 0);
+  aParamsLayout->addWidget(mySelButton,   0, 1);
+  aParamsLayout->addWidget(myObjectName,  0, 2);
+  aParamsLayout->addWidget(myUseC1Check,  1, 0, 1, 3);
+  aParamsLayout->addWidget(myTolLbl,      2, 0);
+  aParamsLayout->addWidget(mySpinTol,     2, 1, 1, 2);
+  aParamsLayout->addWidget(myTextView,    3, 0, 1, 3);
+  aParamsLayout->addWidget(anErrorsLbl,   4, 0);
+  aParamsLayout->addWidget(myListBox1,    5, 0, 1, 2);
+  aParamsLayout->addWidget(aNonBlocksLbl, 4, 2);
+  aParamsLayout->addWidget(myListBox2,    5, 2);
 
   QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
   layout->setMargin( 0 ); layout->setSpacing( 6 );
-  layout->addWidget( myGrp );
-
-  connect( myGrp->ListBox1, SIGNAL( itemSelectionChanged() ), SLOT( onErrorsListSelectionChanged() ) );
-  connect( myGrp->ListBox2, SIGNAL( itemSelectionChanged() ), SLOT( onSubShapesListSelectionChanged() ) );
+  layout->addWidget( aGrpParams );
 
   /***************************************************************/
 
@@ -116,14 +151,24 @@ MeasureGUI_CheckCompoundOfBlocksDlg::~MeasureGUI_CheckCompoundOfBlocksDlg()
 //=================================================================================
 void MeasureGUI_CheckCompoundOfBlocksDlg::Init()
 {
-  myEditCurrentArgument = myGrp->LineEdit1;
+  /* init variables */
+  double SpecificStep = 0.0001;
+  double aDefaultTol  = Precision::Angular();
+
+  initSpinBox(mySpinTol, aDefaultTol, MAX_NUMBER, SpecificStep, "ang_tol_precision");
+  mySpinTol->setValue(aDefaultTol);
+  myEditCurrentArgument = myObjectName;
 
   // signals and slots connections
   connect( buttonOk(),    SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
   connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
 
-  connect( myGrp->LineEdit1,   SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
-  connect( myGrp->PushButton1, SIGNAL( clicked() ),       this, SLOT( SetEditCurrentArgument() ) );
+  connect(myObjectName, SIGNAL(returnPressed()),        this, SLOT(LineEditReturnPressed()));
+  connect(mySelButton,  SIGNAL(clicked()),              this, SLOT(SetEditCurrentArgument()));
+  connect(myListBox1,   SIGNAL(itemSelectionChanged()), this, SLOT(onErrorsListSelectionChanged()));
+  connect(myListBox2,   SIGNAL(itemSelectionChanged()), this, SLOT(onSubShapesListSelectionChanged()));
+  connect(myUseC1Check, SIGNAL(clicked()),              this, SLOT(SetUseC1Tolerance()));
+  connect(mySpinTol,    SIGNAL(valueChanged(double)),   this, SLOT(processObject()));
 
   connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
            this, SLOT( SelectionIntoArgument() ) );
@@ -172,7 +217,7 @@ void MeasureGUI_CheckCompoundOfBlocksDlg::SelectionIntoArgument()
   aSelMgr->selectedObjects(aSelList);
 
   if (aSelList.Extent() != 1) {
-    myGrp->LineEdit1->setText( "" );
+    myObjectName->setText( "" );
     processObject();
     return;
   }
@@ -181,13 +226,13 @@ void MeasureGUI_CheckCompoundOfBlocksDlg::SelectionIntoArgument()
     GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
 
   if ( aSelectedObject->_is_nil() ) {
-    myGrp->LineEdit1->setText( "" );
+    myObjectName->setText( "" );
     processObject();
     return;
   }
 
   myObj = aSelectedObject;
-  myGrp->LineEdit1->setText( GEOMBase::GetName( myObj ) );
+  myObjectName->setText( GEOMBase::GetName( myObj ) );
   processObject();
   DISPLAY_PREVIEW_MACRO;
 }
@@ -198,11 +243,22 @@ void MeasureGUI_CheckCompoundOfBlocksDlg::SelectionIntoArgument()
 //=================================================================================
 void MeasureGUI_CheckCompoundOfBlocksDlg::SetEditCurrentArgument()
 {
-  myGrp->LineEdit1->setFocus();
-  myEditCurrentArgument = myGrp->LineEdit1;
+  myObjectName->setFocus();
+  myEditCurrentArgument = myObjectName;
   SelectionIntoArgument();
 }
 
+//=================================================================================
+// function : SetUseC1Tolerance()
+// purpose  :
+//=================================================================================
+void MeasureGUI_CheckCompoundOfBlocksDlg::SetUseC1Tolerance()
+{
+  myTolLbl->setEnabled(myUseC1Check->isChecked());
+  mySpinTol->setEnabled(myUseC1Check->isChecked());
+  processObject();
+}
+
 //=================================================================================
 // function : LineEditReturnPressed()
 // purpose  :
@@ -210,8 +266,8 @@ void MeasureGUI_CheckCompoundOfBlocksDlg::SetEditCurrentArgument()
 void MeasureGUI_CheckCompoundOfBlocksDlg::LineEditReturnPressed()
 {
   QLineEdit* send = (QLineEdit*)sender();
-  if ( send == myGrp->LineEdit1 ) {
-    myEditCurrentArgument = myGrp->LineEdit1;
+  if ( send == myObjectName ) {
+    myEditCurrentArgument = myObjectName;
     GEOMBase_Skeleton::LineEditReturnPressed();
   }
 }
@@ -245,7 +301,13 @@ bool MeasureGUI_CheckCompoundOfBlocksDlg::getBCErrors( bool& theIsCompoundOfBloc
     GEOM::GEOM_IBlocksOperations_var anOper = GEOM::GEOM_IBlocksOperations::_narrow( getOperation() );
     try {
       GEOM::GEOM_IBlocksOperations::BCErrors_var aErrs;
-      theIsCompoundOfBlocks = anOper->CheckCompoundOfBlocks( myObj, aErrs );
+      double aC1Tol = -1.;
+
+      if (myUseC1Check->isChecked()) {
+        aC1Tol = mySpinTol->value();
+      }
+
+      theIsCompoundOfBlocks = anOper->CheckCompoundOfBlocks( myObj, aC1Tol, aErrs );
       if (anOper->IsDone() && aErrs->length() > 0)
       //if (anOper->IsDone() && !aErrs._is_nil())
         theErrors = aErrs;
@@ -270,9 +332,9 @@ void MeasureGUI_CheckCompoundOfBlocksDlg::processObject()
   GEOM::GEOM_IBlocksOperations::BCErrors aErrs;
   if ( !getBCErrors( isCompoundOfBlocks, aErrs ) ) {
     aMsg += tr( "GEOM_CHECK_BLOCKS_COMPOUND_FAILED" );
-    myGrp->TextView1->setText( aMsg );
-    myGrp->ListBox1->clear();
-    myGrp->ListBox2->clear();
+    myTextView->setText( aMsg );
+    myListBox1->clear();
+    myListBox2->clear();
     erasePreview();
     return;
   }
@@ -287,7 +349,7 @@ void MeasureGUI_CheckCompoundOfBlocksDlg::processObject()
     buttonOk()->setEnabled( true );
     buttonApply()->setEnabled( true );
   }
-  myGrp->TextView1->setText( aMsg );
+  myTextView->setText( aMsg );
 
   QStringList aErrList;
   QString aErrStr( "" );
@@ -321,9 +383,9 @@ void MeasureGUI_CheckCompoundOfBlocksDlg::processObject()
       aErrList.append( aErrStr );
   }
 
-  myGrp->ListBox1->clear();
-  myGrp->ListBox2->clear();
-  myGrp->ListBox1->addItems( aErrList );
+  myListBox1->clear();
+  myListBox2->clear();
+  myListBox1->addItems( aErrList );
 }
 
 //=================================================================================
@@ -342,19 +404,19 @@ GEOM::GEOM_IOperations_ptr MeasureGUI_CheckCompoundOfBlocksDlg::createOperation(
 void MeasureGUI_CheckCompoundOfBlocksDlg::onErrorsListSelectionChanged()
 {
   erasePreview();
-  int aCurItem = myGrp->ListBox1->currentRow();
+  int aCurItem = myListBox1->currentRow();
   if ( aCurItem < 0 )
     return;
   bool isCompoundOfBlocks;
   GEOM::GEOM_IBlocksOperations::BCErrors aErrs;
   if ( !getBCErrors( isCompoundOfBlocks, aErrs ) ) {
-    myGrp->TextView1->setText( "" );
-    myGrp->ListBox1->clear();
-    myGrp->ListBox2->clear();
+    myTextView->setText( "" );
+    myListBox1->clear();
+    myListBox2->clear();
     return;
   }
 
-  myGrp->ListBox2->clear();
+  myListBox2->clear();
 
   if (aCurItem < aErrs.length()) {
     GEOM::GEOM_IBlocksOperations::BCError aErr = aErrs[aCurItem];
@@ -371,7 +433,7 @@ void MeasureGUI_CheckCompoundOfBlocksDlg::onErrorsListSelectionChanged()
           aSubShapeList.append( QString( "%1_%2" ).arg( aType ).arg( aObjLst[i] ) );
       }
     }
-    myGrp->ListBox2->addItems( aSubShapeList );
+    myListBox2->addItems( aSubShapeList );
   }
 }
 
@@ -382,12 +444,12 @@ void MeasureGUI_CheckCompoundOfBlocksDlg::onErrorsListSelectionChanged()
 void MeasureGUI_CheckCompoundOfBlocksDlg::onSubShapesListSelectionChanged()
 {
   erasePreview();
-  int aErrCurItem = myGrp->ListBox1->currentRow();
+  int aErrCurItem = myListBox1->currentRow();
   if ( aErrCurItem < 0 )
     return;
   QList<int> aIds;
-  for ( int i = 0, n = myGrp->ListBox2->count(); i < n; i++ ) {
-    if ( myGrp->ListBox2->item( i )->isSelected() )
+  for ( int i = 0, n = myListBox2->count(); i < n; i++ ) {
+    if ( myListBox2->item( i )->isSelected() )
       aIds.append( i );
   }
   if ( aIds.count() < 1 )
@@ -395,9 +457,9 @@ void MeasureGUI_CheckCompoundOfBlocksDlg::onSubShapesListSelectionChanged()
   bool isCompoundOfBlocks;
   GEOM::GEOM_IBlocksOperations::BCErrors aErrs;
   if ( !getBCErrors( isCompoundOfBlocks, aErrs ) ) {
-    myGrp->TextView1->setText( "" );
-    myGrp->ListBox1->clear();
-    myGrp->ListBox2->clear();
+    myTextView->setText( "" );
+    myListBox1->clear();
+    myListBox2->clear();
     return;
   }
 
@@ -433,6 +495,15 @@ void MeasureGUI_CheckCompoundOfBlocksDlg::onSubShapesListSelectionChanged()
   }
 }
 
+//=================================================================================
+// function : onDisplayPreview
+// purpose  : 
+//=================================================================================
+void MeasureGUI_CheckCompoundOfBlocksDlg::onDisplayPreview()
+{
+  DISPLAY_PREVIEW_MACRO;
+}
+
 //=================================================================================
 // function : activateSelection
 // purpose  : activate selection of faces, shells, and solids
@@ -459,9 +530,9 @@ void MeasureGUI_CheckCompoundOfBlocksDlg::enterEvent( QEvent* )
 // function : isValid
 // purpose  :
 //=================================================================================
-bool MeasureGUI_CheckCompoundOfBlocksDlg::isValid( QString)
+bool MeasureGUI_CheckCompoundOfBlocksDlg::isValid( QString &msg)
 {
-  return !myObj->_is_nil();
+  return !myObj->_is_nil() && mySpinTol->isValid(msg, !IsPreview());
 }
 
 //=================================================================================
index e6a93c4f07e124f6144c766b43e4f5ff705687e9..b2d43ca1fc9009a2da0860b76667094ed4112eb1 100644 (file)
 
 #include <GEOMBase_Skeleton.h>
 
-class MeasureGUI_1Sel1TextView2ListBox;
+class QCheckBox;
+class QLabel;
+class QLineEdit;
+class QListWidget;
+class QPushButton;
+class QTextBrowser;
+class SalomeApp_DoubleSpinBox;
 
 //=================================================================================
 // class    : MeasureGUI_CheckCompoundOfBlocksDlg
@@ -47,7 +53,7 @@ public:
 protected:
   // redefined from GEOMBase_Helper and GEOMBase_Skeleton
   virtual GEOM::GEOM_IOperations_ptr  createOperation();
-  virtual bool                        isValid( QString& );
+  virtual bool                        isValid( QString &msg );
   virtual bool                        execute( ObjectList& );
   virtual void                        processObject();
 
@@ -61,6 +67,8 @@ private slots:
   
   void                                onErrorsListSelectionChanged();
   void                                onSubShapesListSelectionChanged();
+  void                                SetUseC1Tolerance();
+  void                                onDisplayPreview();
   
 private:
   void                                Init();
@@ -71,7 +79,14 @@ private:
 
 private:
   GEOM::GEOM_Object_var               myObj;
-  MeasureGUI_1Sel1TextView2ListBox*   myGrp;
+  QLineEdit                          *myObjectName;
+  QPushButton                        *mySelButton;
+  QCheckBox                          *myUseC1Check;
+  QLabel                             *myTolLbl;
+  SalomeApp_DoubleSpinBox            *mySpinTol;
+  QTextBrowser                       *myTextView;
+  QListWidget                        *myListBox1;
+  QListWidget                        *myListBox2;
 };
 
 #endif // MEASUREGUI_CHECKCOMPOUNDOFBLOCKSDLG_H