Salome HOME
Statistics of the operation
authorskv <skv@opencascade.com>
Fri, 18 Dec 2015 14:30:19 +0000 (17:30 +0300)
committerskv <skv@opencascade.com>
Fri, 18 Dec 2015 14:30:19 +0000 (17:30 +0300)
16 files changed:
doc/salome/examples/canrecplugindemo.py
doc/salome/gui/CANRECPLUGIN/images/canrec_plugin_dlg.png
doc/salome/gui/CANRECPLUGIN/images/canrec_plugin_dlg_stat.png [new file with mode: 0644]
doc/salome/gui/CANRECPLUGIN/input/canrecplugin_usage_page.doc
idl/CANRECPlugin.idl
src/CANRECPLUGINEngine/CANRECPluginEngine_IOperations_i.cc
src/CANRECPLUGINEngine/CANRECPluginEngine_IOperations_i.hh
src/CANRECPLUGINEngine/CANRECPluginImpl_Driver.cxx
src/CANRECPLUGINEngine/CANRECPluginImpl_Driver.hxx
src/CANRECPLUGINEngine/CANRECPluginImpl_ICanRec.hxx
src/CANRECPLUGINEngine/CANRECPluginImpl_IOperations.cxx
src/CANRECPLUGINEngine/CANRECPluginImpl_IOperations.hxx
src/CANRECPLUGINGUI/CANRECPluginGUI_CanonicalRecognitionDlg.cxx
src/CANRECPLUGINGUI/CANRECPluginGUI_CanonicalRecognitionDlg.h
src/CANRECPLUGINGUI/resources/CANRECPlugin_msg_en.ts
src/CANRECPLUGIN_PY/CANRECPluginBuilder.py

index c88ff1eb502c577e6c9094332d6f6c2155d70dbc..82b5541219801c020717762f27900901b0a63ad4 100644 (file)
@@ -13,6 +13,13 @@ shape_igs = geompy.ImportIGES(path)
 # Build Canonical Recognition
 shape_cr = geompy.MakeCanonicalRecognition(shape_igs, True, True, 0.01)
 
+# Get the number of canonical faces
+init_nb_f = geompy.GetNbCanonicalFaces(shape_igs)
+res_nb_f = geompy.GetNbCanonicalFaces(shape_cr)
+
+print "Number of canonical faces in the initial shape: %s" % init_nb_f
+print "Number of canonical faces in the result shape: %s" % res_nb_f
+
 # Publish in the study
 geompy.addToStudy( shape_igs, 'Import from IGS' )
 geompy.addToStudy( shape_cr, 'Canonical Recognition' )
index 1c724a937f2de304e5876f157f8c08416a5d6394..d7729996a0353900917e593b2e92294868333539 100644 (file)
Binary files a/doc/salome/gui/CANRECPLUGIN/images/canrec_plugin_dlg.png and b/doc/salome/gui/CANRECPLUGIN/images/canrec_plugin_dlg.png differ
diff --git a/doc/salome/gui/CANRECPLUGIN/images/canrec_plugin_dlg_stat.png b/doc/salome/gui/CANRECPLUGIN/images/canrec_plugin_dlg_stat.png
new file mode 100644 (file)
index 0000000..3a6a614
Binary files /dev/null and b/doc/salome/gui/CANRECPLUGIN/images/canrec_plugin_dlg_stat.png differ
index c654a5a54f00f54a71e76d411b188dc8753a5b9e..bc2da0b7e5a69abc580b567372dd261fc9aee55d 100644 (file)
@@ -6,19 +6,30 @@ To create a <b>Canonical Recognition</b> in the <b>Main Menu</b> select <b>New E
 
 This Operation constructs a canonical recognition (convert, if possible, a NURBS geometry B-Spline / Bezier curve or surface
 to its analytical form) of an \b Object. To constructs the canonical recognition you need to define the shape.
+\n Once you chose an object you can see the number of canonical faces in this object on the label below.
 \n <b>Merge Surfaces</b> checkbox allows to merge surfaces in the result shape.
 \n <b>Merge Curves</b> checkbox allows to merge curvies in the result shape.
 \n The \b Result of the operation will be any \b GEOM_Object.
 
-\n <b>TUI Command:</b> <em>geompy.MakeCanonicalRecognition(Shape, MergeSurf, MergeCurves), 
+\n <b>TUI Commands:</b> 
+<UL>
+<LI><em>geompy.MakeCanonicalRecognition(Shape, MergeSurf, MergeCurves, theTolerance=0.01), 
 </em> where Shape is a shape to be converted into canonical recognition, 
-MergeSurf and MergeCurv flags to merge surfaces / curves in the result shape.
-
+MergeSurf and MergeCurv flags to merge surfaces / curves in the result shape,
+theTolerance is the tolerance of the operation. Default value is 0.01.</LI>
+<LI><em>geompy.GetNbCanonicalFaces(Shape),</em> where Shape is a shape to be tested.
+Returns the number of canonical faces in this shape.</LI>
+</UL>
 
 \n <b>Arguments:</b> Name + one object.
 
 \image html canrec_plugin_dlg.png
 
+Once the user presses the \b Apply or <b>Apply and Close</b> buttons,
+he will be given with the operation statistics information:
+
+\image html canrec_plugin_dlg_stat.png
+
 \n \b Example:
 
 Our <b>TUI Script</b> provide you with useful example of the use of \ref canrec_example "Canonical Recognition".
index 9bdad0afb4587e3bdf3ef95aad3073ea025cde47..3d57c46d607cf6825cab19ae76558a3ea0bf89ed 100644 (file)
@@ -24,6 +24,8 @@
 
 module CANRECPlugin
 {       
+  typedef sequence<long> ListOfLong;
+
   /*!
    *  \brief Interface to Canonical Recognition modeling functions.
    */
@@ -36,13 +38,33 @@ module CANRECPlugin
      * \param theMergeSurf the flag to switch on/off merging surfaces in the result shape.
      * \param theMergeCurves the flag to switch on/off merging curves in the result shape.
      * \param theTolerance the tolerance of the canonical recognition operation.
+     * \param theStat the statistics of the operation. Output parameter.
+     *                Each integer value in the sequence has its own meaning
+     *                depending on its index:
+     *                0 - total number of faces in the initial shape;
+     *                1 - number of canonical faces in the initial shape;
+     *                2 - number of faces converted to the canonical form;
+     *                3 - number of merged surfaces;
+     *                4 - number of merged curves.
+     *                Nagative value means that this value is not computed.
      *
      * \return New GEOM_Object, containing the canonical recognition of the input object.
      */
-    GEOM::GEOM_Object MakeCanonicalRecognition ( in GEOM::GEOM_Object theObject,
-                                                in boolean theMergeSurf,
-                                                in boolean theMergeCurves,
-                                                in double theTolerance );
+    GEOM::GEOM_Object MakeCanonicalRecognition
+                      (in GEOM::GEOM_Object theObject,
+                       in boolean           theMergeSurf,
+                       in boolean           theMergeCurves,
+                       in double            theTolerance,
+                       out ListOfLong       theStat);
+
+    /*!
+     * \brief Get the number of canonical faces in the shape.
+     *
+     * \param theObject the input object (solid, compound, compsolid).
+     *
+     * \return the number of canonical faces in the object.
+     */
+    long GetNbCanonicalFaces(in GEOM::GEOM_Object theObject);
   };
 };
 
index e6b3b6eab975334a758bdaa46b64639adb26f9a6..677edb72800e5d5228f3a5b068ec2d764dda7caa 100644 (file)
@@ -49,27 +49,79 @@ GEOM::GEOM_Object_ptr
 CANRECPluginEngine_IOperations_i::MakeCanonicalRecognition( GEOM::GEOM_Object_ptr theObject,
                                                             CORBA::Boolean theMergeSurf,
                                                             CORBA::Boolean theMergeCurves,
-                                                            CORBA::Double theTolerance )
+                                                            CORBA::Double theTolerance,
+                                                            CANRECPlugin::ListOfLong_out theStat )
 {
+  theStat = new CANRECPlugin::ListOfLong();
+
   // Set a not done flag
   GetOperations()->SetNotDone();
 
   // Get the reference points
   Handle(GEOM_Object) anInitObject = GetObjectImpl( theObject );
 
-  if ( anInitObject.IsNull() ) return GEOM::GEOM_Object::_nil();
+  if ( anInitObject.IsNull() ) {
+    return GEOM::GEOM_Object::_nil();
+  }
 
   // Make Canonical Recognition
-  Handle(GEOM_Object) anObject = GetOperations()->MakeCanonicalRecognition( anInitObject,
-                                                                            theMergeSurf, 
-                                                                            theMergeCurves, 
-                                                                            theTolerance );
-  if ( !GetOperations()->IsDone() || anObject.IsNull() )
+  Handle(TColStd_HSequenceOfInteger) aStat    = new TColStd_HSequenceOfInteger;
+  Handle(GEOM_Object)                anObject =
+        GetOperations()->MakeCanonicalRecognition(anInitObject,
+                                                  theMergeSurf, 
+                                                  theMergeCurves, 
+                                                  theTolerance,
+                                                  aStat);
+
+  if (!GetOperations()->IsDone() || anObject.IsNull()) {
     return GEOM::GEOM_Object::_nil();
+  }
+
+  // Copy statistics.
+  int nbInts = aStat->Length();
+  int i;
+
+  theStat->length(nbInts);
+
+  for (i = 0; i < nbInts; i++) {
+    theStat[i] = aStat->Value(i + 1);
+  }
 
   return GetObject( anObject );
 }
 
+//=============================================================================
+/*!
+ *  \brief Get the number of canonical faces in the shape. 
+ *
+ *  \param theObject the input object (solid, compound, compsolid).
+ *
+ *  \return the number of canonical faces in the object.
+ */
+//=============================================================================
+CORBA::Long CANRECPluginEngine_IOperations_i::GetNbCanonicalFaces
+                              (GEOM::GEOM_Object_ptr theObject)
+{
+  // Set a not done flag
+  GetOperations()->SetNotDone();
+
+  // Get the reference points
+  Handle(GEOM_Object) anInitObject = GetObjectImpl(theObject);
+
+  if (anInitObject.IsNull()) {
+    return -1;
+  }
+
+  // Get the number of canonical faces.
+  CORBA::Long aResult = GetOperations()->GetNbCanonicalFaces(anInitObject);
+
+  if (!GetOperations()->IsDone()) {
+    return -1;
+  }
+
+  return aResult;
+}
+
 ::CANRECPluginImpl_IOperations* CANRECPluginEngine_IOperations_i::GetOperations()
 {
   return (::CANRECPluginImpl_IOperations*)GetImpl();
index 419c2c0ac12cb6ef8dbee9140dfd1a922cdb47da..14502bb2eaf1e81704eb7c906c897e9feca326d6 100644 (file)
@@ -43,7 +43,10 @@ class CANRECPLUGINENGINE_EXPORT CANRECPluginEngine_IOperations_i :
   GEOM::GEOM_Object_ptr MakeCanonicalRecognition ( GEOM::GEOM_Object_ptr theObject,
                                                    CORBA::Boolean theMergeSurf,
                                                    CORBA::Boolean theMergeCurves,
-                                                   CORBA::Double theTolerance );
+                                                   CORBA::Double theTolerance,
+                                                   CANRECPlugin::ListOfLong_out theStat );
+
+  CORBA::Long GetNbCanonicalFaces(GEOM::GEOM_Object_ptr theObject);
 
   CANRECPluginImpl_IOperations* GetOperations();
 };
index 107776d82a58e5ccc8d41bc5816aa2c88f465ba7..15f07e708e307f7651523a732016880604111697 100644 (file)
 
 #include <GEOM_Function.hxx>
 
+#include <BRep_Tool.hxx>
 #include <BRepOffsetAPI_Sewing.hxx>
+#include <Geom_Plane.hxx>
+#include <Geom_Surface.hxx>
 #include <Standard_Version.hxx>
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Face.hxx>
+
 #include <TFunction_Logbook.hxx>
 #include <ShapeConvert_CanonicAPI.hxx>
+#include <ShapeConvert_Surface.hxx>
 #include <ShapeConvert_UnionFaces.hxx>
 #include <ShapeConvert_UnionEdges.hxx>
 
 #include <Standard_LicenseError.hxx>
 #endif // CANREC_HASLICENSE
 
+/**
+ * This function returns the number of shapes of a certain type.
+ *
+ * \param theShape the shape.
+ * \param theType the required type.
+ * \return the number of shapes of a certain type.
+ */
+static Standard_Integer GetNbShapes(const TopoDS_Shape     &theShape,
+                                    const TopAbs_ShapeEnum  theType)
+{
+  TopTools_IndexedMapOfShape aMapShapes;
+
+  TopExp::MapShapes(theShape, theType, aMapShapes);
+
+  const Standard_Integer aResult = aMapShapes.Extent();
+
+  return aResult;
+}
+
 const Standard_GUID& CANRECPluginImpl_Driver::GetID()
 {
   static Standard_GUID aGUID("7e1492bb-b4cd-4a40-ad8f-102902b0047e");
   return aGUID;
 }
 
+Standard_Integer CANRECPluginImpl_Driver::GetNbCanonicalFaces
+                                  (const TopoDS_Shape &theShape)
+{
+  TopExp_Explorer     anExp(theShape, TopAbs_FACE);
+  TopLoc_Location     aLoc;
+  Standard_Integer    aNbSurf = 0;
+  TopTools_MapOfShape aMapFence;
+
+  for (; anExp.More(); anExp.Next()) {
+    const TopoDS_Shape &aShFace = anExp.Current();
+
+    if (aMapFence.Add(aShFace)) {
+      TopoDS_Face          aFace    = TopoDS::Face(aShFace);
+      Handle(Geom_Surface) aSurface = BRep_Tool::Surface(aFace, aLoc);
+
+      if(aSurface->IsKind(STANDARD_TYPE(Geom_Plane)) ||
+         ShapeConvert_Surface::IsCanonical(aSurface)) {
+        aNbSurf++;
+      }
+    }
+  }
+
+  return aNbSurf;
+}
+
 CANRECPluginImpl_Driver::CANRECPluginImpl_Driver()
 {
 }
@@ -86,6 +139,9 @@ Standard_Integer CANRECPluginImpl_Driver::Execute( TFunction_Logbook& log ) cons
   aRecognizer.SurfaceMode() = isNeedMergeSurf;
   aRecognizer.CurveMode() = isNeedMergeCurves;
 
+  const Standard_Integer anInitNbFaces     = GetNbShapes(aShape, TopAbs_FACE);
+  const Standard_Integer anInitNbCanonical = GetNbCanonicalFaces(aShape);
+
   // 1. Recognizing
   aRecognizer.SetShape( aShape );
   aRecognizer.UnifyMode() = false;
@@ -97,22 +153,41 @@ Standard_Integer CANRECPluginImpl_Driver::Execute( TFunction_Logbook& log ) cons
   aSewing.Add( aResultingShape );
   aSewing.Perform();
   aResultingShape = aSewing.SewedShape();
-  
+
+  const Standard_Integer aNbConverted   =
+    GetNbCanonicalFaces(aResultingShape) - anInitNbCanonical;
+  Standard_Integer       aNbMergedFaces = -1;
+  Standard_Integer       aNbMergedEdges = -1;
+
   // 3.1. Union Surfaces
   if ( isNeedMergeSurf ) {
     ShapeConvert_UnionFaces aFaceUnifier;
     aFaceUnifier.GetTolerance() = aTolerance;
     aResultingShape = aFaceUnifier.Perform( aResultingShape );
+    aNbMergedFaces  = anInitNbFaces - GetNbShapes(aResultingShape, TopAbs_FACE);
   }
   
   // 3.2. Union Curves 
   if ( isNeedMergeCurves ) {
     ShapeConvert_UnionEdges anEdgeUnifier;
-    aResultingShape = anEdgeUnifier.Perform( aResultingShape, aTolerance );
+    aNbMergedEdges   = GetNbShapes(aResultingShape, TopAbs_EDGE);
+    aResultingShape  = anEdgeUnifier.Perform( aResultingShape, aTolerance );
+    aNbMergedEdges  -= GetNbShapes(aResultingShape, TopAbs_EDGE);
   }
   
   if ( aResultingShape.IsNull() ) return 0;
 
+  // Create statistics
+  Handle(TColStd_HArray1OfInteger) aStat = new TColStd_HArray1OfInteger(1, 5);
+
+  aStat->SetValue(1, anInitNbFaces);
+  aStat->SetValue(2, anInitNbCanonical);
+  aStat->SetValue(3, aNbConverted);
+  aStat->SetValue(4, aNbMergedFaces);
+  aStat->SetValue(5, aNbMergedEdges);
+
+  aData.SetStatistics(aStat);
+
   aFunction->SetValue( aResultingShape );
 
   log.SetTouched( Label() );
index 68266ba2bd9ba84e02b88d1c2d39e61cbb4ddf01..1b18418959bcf49b141164bf930a0a0fccccad10 100644 (file)
@@ -22,6 +22,8 @@
 
 #include <GEOM_BaseDriver.hxx>
 
+class TopoDS_Shape;
+
 DEFINE_STANDARD_HANDLE( CANRECPluginImpl_Driver, GEOM_BaseDriver );
 
 class CANRECPluginImpl_Driver : public GEOM_BaseDriver
@@ -31,6 +33,7 @@ public:
   ~CANRECPluginImpl_Driver();
 
   static const Standard_GUID& GetID();
+  static Standard_Integer GetNbCanonicalFaces(const TopoDS_Shape &theShape);
   virtual Standard_Integer Execute( TFunction_Logbook& ) const; 
   Standard_Boolean MustExecute( const TFunction_Logbook& ) const;
   virtual void Validate( TFunction_Logbook& ) const;
index 111aa48c39cfead1b908bd1b55e5fa811d7f08be..41a578e3732be4d41a9961df6c40c04a852ffd48 100644 (file)
 #define __CANRECPLUGINIMPL_ICANREC_HXX
 
 #include <GEOM_Function.hxx>
+#include <TColStd_HArray1OfInteger.hxx>
 
 #define CanonicalRecognition_ARG_NeedMergeSurf    1
 #define CanonicalRecognition_ARG_NeedMergeCurves  2
 #define CanonicalRecognition_ARG_Tolerance        3
 #define CanonicalRecognition_ARG_Object           4
+#define CanonicalRecognition_ARG_Stat             5
 
 class CANRECPluginImpl_ICanRec
 {
@@ -44,6 +46,9 @@ public:
   void SetObject(Handle(GEOM_Function) anInitialObject) { _func->SetReference(CanonicalRecognition_ARG_Object, anInitialObject); }
   Handle(GEOM_Function) GetObject() { return _func->GetReference(CanonicalRecognition_ARG_Object); }
 
+  void SetStatistics(const Handle(TColStd_HArray1OfInteger) &theStat) { _func->SetIntegerArray(CanonicalRecognition_ARG_Stat, theStat); }
+  Handle(TColStd_HArray1OfInteger) GetStatistics() { return _func->GetIntegerArray(CanonicalRecognition_ARG_Stat); }
+
 private:
   Handle(GEOM_Function) _func;
 };
index 9fdb53282c324d5453398f65549adf4227993a4e..81b20d8ffa097c894ed4af3d6d6d934bbccea039 100644 (file)
@@ -46,17 +46,27 @@ CANRECPluginImpl_IOperations::~CANRECPluginImpl_IOperations()
  *  \param theMergeCurves set merging curves
  *  \param theTolerance set tolerance
  *  \param theObject is initial object
+ *  \param theStat is the statistics. A set of integers. For details please
+ *         see CANRECPlugin.idl
  *  \return New GEOM_Object, containing the created shape.
  */
 //=============================================================================
 Handle(GEOM_Object)
-CANRECPluginImpl_IOperations::MakeCanonicalRecognition ( Handle(GEOM_Object) theObject,
-                                                         bool theMergeSurf,
-                                                         bool theMergeCurves,
-                                                         double theTolerance )
+CANRECPluginImpl_IOperations::MakeCanonicalRecognition
+                  (Handle(GEOM_Object)                theObject,
+                   bool                               theMergeSurf,
+                   bool                               theMergeCurves,
+                   double                             theTolerance,
+                   Handle_TColStd_HSequenceOfInteger &theStat)
 {
   SetErrorCode( KO );
 
+  if (theStat.IsNull()) {
+    theStat = new TColStd_HSequenceOfInteger;
+  } else {
+    theStat->Clear();
+  }
+
   if ( theObject.IsNull() ) return NULL;
 
   // Add a new object
@@ -92,6 +102,17 @@ CANRECPluginImpl_IOperations::MakeCanonicalRecognition ( Handle(GEOM_Object) the
     SetErrorCode( aFail->GetMessageString() );
     return NULL;
   }
+
+  Handle(TColStd_HArray1OfInteger) anArray = aData.GetStatistics();
+
+  if (anArray.IsNull() == Standard_False) {
+    Standard_Integer       i   = anArray->Lower();
+    const Standard_Integer iUp = anArray->Upper();
+
+    for (; i <= iUp; ++i) {
+      theStat->Append(anArray->Value(i));
+    }
+  }
   
   // Make a Python command
   GEOM::TPythonDump(aFunction) << aShape << " = " << "geompy.MakeCanonicalRecognition(" << 
@@ -101,3 +122,35 @@ CANRECPluginImpl_IOperations::MakeCanonicalRecognition ( Handle(GEOM_Object) the
 
   return aShape;
 }
+
+//=============================================================================
+/*!
+ *  \brief Get the number of canonical faces in the shape. 
+ *
+ *  \param theObject the input object (solid, compound, compsolid).
+ *
+ *  \return the number of canonical faces in the object.
+ */
+//=============================================================================
+Standard_Integer CANRECPluginImpl_IOperations::GetNbCanonicalFaces
+                                    (const Handle(GEOM_Object) &theObject)
+{
+  SetErrorCode(KO);
+
+  TopoDS_Shape aShape = theObject->GetValue();
+
+  if (aShape.IsNull()) {
+    return -1;
+  }
+
+  const Standard_Integer aResult =
+    CANRECPluginImpl_Driver::GetNbCanonicalFaces(aShape);
+
+  if (aResult >= 0) {
+    SetErrorCode(OK);
+
+    return aResult;
+  }
+
+  return -1;
+}
index 2d7ba1169719845d2cfa08548c50ba58bcf692ac..3be84a96422963dc60e625dab9b63e5ef0797004 100644 (file)
@@ -23,6 +23,8 @@
 #include <GEOM_IOperations.hxx>
 #include <GEOM_Object.hxx>
 
+#include <TColStd_HSequenceOfInteger.hxx>
+
 class GEOM_Engine;
 
 class CANRECPluginImpl_IOperations: public GEOM_IOperations
@@ -31,10 +33,15 @@ public:
   Standard_EXPORT CANRECPluginImpl_IOperations( GEOM_Engine* theEngine, int theDocID );
   Standard_EXPORT ~CANRECPluginImpl_IOperations();
 
-  Standard_EXPORT Handle(GEOM_Object) MakeCanonicalRecognition ( Handle(GEOM_Object) theObject,
-                                                                 bool theMergeSurf,
-                                                                 bool theMergeCurves,
-                                                                 double theTolerance );
+  Standard_EXPORT Handle(GEOM_Object) MakeCanonicalRecognition
+                    (Handle(GEOM_Object)                theObject,
+                     bool                               theMergeSurf,
+                     bool                               theMergeCurves,
+                     double                             theTolerance,
+                     Handle_TColStd_HSequenceOfInteger &theStat);
+
+  Standard_EXPORT Standard_Integer GetNbCanonicalFaces
+                                    (const Handle(GEOM_Object) &theObject);
 };
 
 #endif // __CANRECPLUGINIMPL_IOPERATIONS_HXX
index 8de922282dafccd663760e32daf9fe167c7e659d..8c899a544b133b94c8fc4068c5e13fc2bf02f9ea 100644 (file)
@@ -59,7 +59,8 @@
 // Constructor
 //=================================================================================
 CANRECPluginGUI_CanonicalRecognitionDlg::CANRECPluginGUI_CanonicalRecognitionDlg( GeometryGUI* theGeometryGUI, QWidget* parent )
-: GEOMBase_Skeleton(theGeometryGUI, parent, false)
+: GEOMBase_Skeleton(theGeometryGUI, parent, false),
+  myNbFacesLbl(0)
 {
   QString aPluginName = "CANRECPlugin";
   QPixmap imageOp  (SUIT_Session::session()->resourceMgr()->loadPixmap( aPluginName, tr( "ICO_CANONICALRECOGNITION" ) ) );
@@ -94,6 +95,9 @@ CANRECPluginGUI_CanonicalRecognitionDlg::CANRECPluginGUI_CanonicalRecognitionDlg
   PButton1->setIcon( image1 );
   PButton1->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
 
+  // Label with number of faces.
+  myNbFacesLbl = new QLabel(argGroup);
+
   // 2. Object 
   QLabel* textLabel1 = new QLabel( argGroup );
   textLabel1->setText( tr( "CANRECPLUGIN_ARG_OBJ" ) );
@@ -118,12 +122,13 @@ CANRECPluginGUI_CanonicalRecognitionDlg::CANRECPluginGUI_CanonicalRecognitionDlg
   lay->addWidget( textLabel1, 0, 0 );
   lay->addWidget( PButton1,   0, 1 );
   lay->addWidget( LineEdit1,  0, 2 );
+  lay->addWidget(myNbFacesLbl, 1, 0, 1, 3);
 
-  lay->addWidget( textLabel2, 1, 0, 1, 2 );
-  lay->addWidget( SpinBoxTol, 1, 2 );
+  lay->addWidget( textLabel2, 2, 0, 1, 2 );
+  lay->addWidget( SpinBoxTol, 2, 2 );
 
-  lay->addWidget( CheckButton1, 2, 0, 1, 3 );
-  lay->addWidget( CheckButton2, 3, 0, 1, 3 );
+  lay->addWidget( CheckButton1, 3, 0, 1, 3 );
+  lay->addWidget( CheckButton2, 4, 0, 1, 3 );
 
   myHelpFileName = "canrecplugin_usage_page.html";
   myHelpContext = aPluginName.toUpper();
@@ -253,7 +258,9 @@ bool CANRECPluginGUI_CanonicalRecognitionDlg::execute( ObjectList& objects )
   CORBA::Double aTolerance = SpinBoxTol->value();
 
   // call engine function
-  anObj = anOper->MakeCanonicalRecognition( myObject.get(), aMergeSurf, aMergeCurves, aTolerance );
+  CANRECPlugin::ListOfLong_var aStat;
+
+  anObj = anOper->MakeCanonicalRecognition( myObject.get(), aMergeSurf, aMergeCurves, aTolerance, aStat );
   res = !anObj->_is_nil();
   if ( res && !IsPreview() )
   {
@@ -265,6 +272,31 @@ bool CANRECPluginGUI_CanonicalRecognitionDlg::execute( ObjectList& objects )
 
     if ( aParameters.count() > 0 )
       anObj->SetParameters( aParameters.join(":").toLatin1().constData() );
+
+
+    // Display message box with statistics.
+    // Compose statistics string.
+    QString aStatString = tr("CANRECPLUGIN_INFO_TEXT_CAPTION");
+
+    aStatString += "\n\n\t";
+    aStatString += tr("CANRECPLUGIN_INFO_TEXT_NB_FACES_INIT").arg(aStat[0]);
+    aStatString += "\n\t";
+    aStatString += tr("CANRECPLUGIN_INFO_TEXT_NB_CAN_FACES_INIT").arg(aStat[1]);
+    aStatString += "\n\t";
+    aStatString += tr("CANRECPLUGIN_INFO_TEXT_NB_FACES").arg(aStat[2]);
+
+    if (CheckButton1->isChecked()) {
+      aStatString += "\n\t";
+      aStatString += tr("CANRECPLUGIN_INFO_TEXT_MERGED_SURF").arg(aStat[3]);
+    }
+
+    if (CheckButton2->isChecked()) {
+      aStatString += "\n\t";
+      aStatString += tr("CANRECPLUGIN_INFO_TEXT_MERGED_CURV").arg(aStat[4]);
+    }
+
+    SUIT_MessageBox::information
+              (this, tr("CANRECPLUGIN_INFO_TITLE"), aStatString);
   }
 
   if ( res )
@@ -286,9 +318,32 @@ void CANRECPluginGUI_CanonicalRecognitionDlg::SelectionIntoArgument()
   {
     myObject = selected.first();
     LineEdit1->setText( myObject->GetName() );
+
+    // Get statistics of initial shape.
+    CANRECPlugin::ICanRecOperations_var anOper      =
+      CANRECPlugin::ICanRecOperations::_narrow( getOperation() );
+    const int                           aNbCanFaces =
+      anOper->GetNbCanonicalFaces(myObject.get());
+    TopoDS_Shape                        aShape;
+
+    if (GEOMBase::GetShape(myObject.get(), aShape) && !aShape.IsNull()) {
+      // Get the tolal number of faces.
+      TopTools_IndexedMapOfShape aMapShapes;
+
+      TopExp::MapShapes(aShape, TopAbs_FACE, aMapShapes);
+
+      const Standard_Integer aNbFaces = aMapShapes.Extent();
+
+      myNbFacesLbl->setText(tr("CANRECPLUGIN_ARG_NB_CAN_FACES").
+        arg(aNbCanFaces).arg(aNbFaces));
+    } else {
+      myNbFacesLbl->setText(tr("CANRECPLUGIN_ARG_NB_CAN_FACES_NO_OBJECT"));
+    }
   }
-  else
+  else {
     LineEdit1->setText( "" );
+    myNbFacesLbl->setText(tr("CANRECPLUGIN_ARG_NB_CAN_FACES_NO_OBJECT"));
+  }
 }
 
 //=================================================================================
index 15ae7a583500867289b078bf08b144e40ddc8bbb..1899653c3400f913d5dce4b430e71c0209bbe127 100644 (file)
@@ -63,6 +63,7 @@ private:
   SalomeApp_DoubleSpinBox*          SpinBoxTol;
   QCheckBox*                        CheckButton1;
   QCheckBox*                        CheckButton2;
+  QLabel                    *myNbFacesLbl;
   
   GEOM::GeomObjPtr                   myObject;
 };
index fba0e947a8888caffce03e5d5baa1cd90be747c8..e69d60dfb76dcdca7a3219cec96705a81b202b1a 100644 (file)
         <source>CANRECPLUGIN_ARG_TOLERANCE</source>
         <translation>Tolerance</translation>
     </message>
+    <message>
+        <source>CANRECPLUGIN_ARG_NB_CAN_FACES_NO_OBJECT</source>
+        <translation>Number of canonical faces:</translation>
+    </message>
+    <message>
+        <source>CANRECPLUGIN_ARG_NB_CAN_FACES</source>
+        <translation>Number of canonical faces: %1 of %2</translation>
+    </message>
+    <message>
+        <source>CANRECPLUGIN_INFO_TITLE</source>
+        <translation>Operation Statistics</translation>
+    </message>
+    <message>
+        <source>CANRECPLUGIN_INFO_TEXT_CAPTION</source>
+        <translation>Operation Statistics:</translation>
+    </message>
+    <message>
+        <source>CANRECPLUGIN_INFO_TEXT_NB_FACES_INIT</source>
+        <translation>Total number of faces in the initial shape: %1</translation>
+    </message>
+    <message>
+        <source>CANRECPLUGIN_INFO_TEXT_NB_CAN_FACES_INIT</source>
+        <translation>Number of canonical faces in the initial shape: %1</translation>
+    </message>
+    <message>
+        <source>CANRECPLUGIN_INFO_TEXT_NB_FACES</source>
+        <translation>Number of faces converted to the canonical form: %1</translation>
+    </message>
+    <message>
+        <source>CANRECPLUGIN_INFO_TEXT_MERGED_SURF</source>
+        <translation>Number of merged surfaces: %1</translation>
+    </message>
+    <message>
+        <source>CANRECPLUGIN_INFO_TEXT_MERGED_CURV</source>
+        <translation>Number of merged curves: %1</translation>
+    </message>
 </context>
 </TS>
index e4c9c01f4367b578257ad2aca3d523083a8b97ac..8dfda9a17c449e11c8bbfbf55f4a3814994863ad 100644 (file)
@@ -69,8 +69,37 @@ def MakeCanonicalRecognition(self, theObj, theMergeSurf, theMergeCurves,
     from salome.geom.geomBuilder import ParseParameters, RaiseIfFailed
     anOp = GetCANRECOperations(self)
     theMergeSurf, theMergeCurves, theTolerance, Parameters = ParseParameters(theMergeSurf, theMergeCurves, theTolerance)
-    anObj = anOp.MakeCanonicalRecognition(theObj, theMergeSurf, theMergeCurves, theTolerance)
+    (anObj, aStat) = anOp.MakeCanonicalRecognition(theObj, theMergeSurf, theMergeCurves, theTolerance)
     RaiseIfFailed("MakeCanonicalRecognition", anOp)
     self._autoPublish(anObj, theName, "canonical")
     anOp.UnRegister()
+    print "Total number of faces in the initial shape: %s" % aStat[0]
+    print "Number of canonical faces in the initial shape: %s" % aStat[1]
+    print "Number of faces converted to the canonical form: %s" % aStat[2]
+    if aStat[3] >= 0:
+      print "Number of merged surfaces: %s" % aStat[3]
+    if aStat[4] >= 0:
+      print "Number of merged curves: %s" % aStat[4]
+
     return anObj
+
+## Get the number of canonical faces in the shape.
+#  @param theObj the input object (solid, compound, compsolid).
+#
+#  @return the number of canonical faces in the object.
+def GetNbCanonicalFaces(self, theObj):
+    """
+    Get the number of canonical faces in the shape.
+
+    Parameters:
+        theObj the input object (solid, compound, compsolid).
+
+        Returns:
+            the number of canonical faces in the object.
+    """
+    from salome.geom.geomBuilder import RaiseIfFailed
+    anOp = GetCANRECOperations(self)
+    aNbCanFaces = anOp.GetNbCanonicalFaces(theObj)
+    RaiseIfFailed("GetNbCanonicalFaces", anOp)
+    anOp.UnRegister()
+    return aNbCanFaces