]> SALOME platform Git repositories - plugins/canrecplugin.git/blobdiff - src/CANRECPLUGINEngine/CANRECPluginImpl_IOperations.cxx
Salome HOME
Copyright update: 2016
[plugins/canrecplugin.git] / src / CANRECPLUGINEngine / CANRECPluginImpl_IOperations.cxx
index 9fdb53282c324d5453398f65549adf4227993a4e..c7575020cc3219ee901ddb2dc1f98994a15120bb 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2015  OPEN CASCADE
+// Copyright (C) 2014-2016  OPEN CASCADE
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -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;
+}