Salome HOME
Join modifications from branch BR_For_OCT_611: migration to OCCT6.1.1 with new except...
[modules/smesh.git] / src / SMESH_I / SMESH_MeshEditor_i.cxx
index 5bc2da5c529e87ededddcfed41f6ec87fab8731d..55fc2330dc48efb2f66ea72cad6967ad88b223e6 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 //
 //
@@ -37,7 +37,6 @@
 #include "SMESH_Gen_i.hxx"
 #include "SMESH_Filter_i.hxx"
 #include "SMESH_PythonDump.hxx"
-#include "CASCatch.hxx"
 
 #include "utilities.h"
 
 #include <gp_Ax2.hxx>
 #include <gp_Vec.hxx>
 
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+#define NO_CAS_CATCH
+#endif
+
+#include <Standard_Failure.hxx>
+
+#ifdef NO_CAS_CATCH
+#include <Standard_ErrorHandler.hxx>
+#else
+#include "CASCatch.hxx"
+#endif
+
 #include <sstream>
 
 typedef map<const SMDS_MeshElement*,
@@ -519,16 +530,18 @@ CORBA::Boolean SMESH_MeshEditor_i::ReorientObject(SMESH::SMESH_IDSource_ptr theO
 //purpose  : auxilary function for conversion long_array to std::map<>
 //           which is used in some methods
 //=======================================================================
-static void ToMap(const SMESH::long_array & IDs,
-                  const SMESHDS_Mesh* aMesh,
-                  std::map<int,const SMDS_MeshElement*>& aMap)
+static void ToMap(const SMESH::long_array &              IDs,
+                  const SMESHDS_Mesh*                    aMesh,
+                  std::map<int,const SMDS_MeshElement*>& aMap,
+                  const SMDSAbs_ElementType              aType = SMDSAbs_All )
 { 
   for (int i=0; i<IDs.length(); i++) {
     CORBA::Long ind = IDs[i];
     std::map<int,const SMDS_MeshElement*>::iterator It = aMap.find(ind);
     if(It==aMap.end()) {
       const SMDS_MeshElement * elem = aMesh->FindElement(ind);
-      aMap.insert( make_pair(ind,elem) );
+      if ( elem && ( aType == SMDSAbs_All || elem->GetType() == aType ))
+        aMap.insert( make_pair( elem->GetID(), elem ));
     }
   }
 }
@@ -548,7 +561,7 @@ CORBA::Boolean SMESH_MeshEditor_i::TriToQuad (const SMESH::long_array &   IDsOfE
 
   SMESHDS_Mesh* aMesh = GetMeshDS();
   map<int,const SMDS_MeshElement*> faces;
-  ToMap(IDsOfElements, aMesh, faces);
+  ToMap(IDsOfElements, aMesh, faces, SMDSAbs_Face);
 
   SMESH::NumericalFunctor_i* aNumericalFunctor =
     dynamic_cast<SMESH::NumericalFunctor_i*>( SMESH_Gen_i::GetServant( Criterion ).in() );
@@ -560,7 +573,7 @@ CORBA::Boolean SMESH_MeshEditor_i::TriToQuad (const SMESH::long_array &   IDsOfE
 
   // Update Python script
   TPythonDump() << "isDone = " << this << ".TriToQuad( "
-                << IDsOfElements << ", None, " << MaxAngle << " )";
+                << IDsOfElements << ", " << aNumericalFunctor << ", " << MaxAngle << " )";
 #ifdef _DEBUG_
   TPythonDump() << "print 'TriToQuad: ', isDone";
 #endif
@@ -597,9 +610,12 @@ CORBA::Boolean SMESH_MeshEditor_i::TriToQuadObject (SMESH::SMESH_IDSource_ptr
   aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
 #endif
 
+  SMESH::NumericalFunctor_i* aNumericalFunctor =
+    SMESH::DownCast<SMESH::NumericalFunctor_i*>( Criterion );
+
   // Update Python script
   TPythonDump() << "isDone = " << this << ".TriToQuadObject("
-                << theObject << ", None, " << MaxAngle << " )";
+                << theObject << ", " << aNumericalFunctor << ", " << MaxAngle << " )";
 #ifdef _DEBUG_
   TPythonDump() << "print 'TriToQuadObject: ', isDone";
 #endif
@@ -621,7 +637,7 @@ CORBA::Boolean SMESH_MeshEditor_i::QuadToTri (const SMESH::long_array &   IDsOfE
 
   SMESHDS_Mesh* aMesh = GetMeshDS();
   map<int,const SMDS_MeshElement*> faces;
-  ToMap(IDsOfElements, aMesh, faces);
+  ToMap(IDsOfElements, aMesh, faces, SMDSAbs_Face);
 
   SMESH::NumericalFunctor_i* aNumericalFunctor =
     dynamic_cast<SMESH::NumericalFunctor_i*>( SMESH_Gen_i::GetServant( Criterion ).in() );
@@ -633,7 +649,7 @@ CORBA::Boolean SMESH_MeshEditor_i::QuadToTri (const SMESH::long_array &   IDsOfE
 
 
   // Update Python script
-  TPythonDump() << "isDone = " << this << ".QuadToTri( " << IDsOfElements << ", None )";
+  TPythonDump() << "isDone = " << this << ".QuadToTri( " << IDsOfElements << ", " << aNumericalFunctor << " )";
 #ifdef _DEBUG_
   TPythonDump() << "print 'QuadToTri: ', isDone";
 #endif
@@ -668,8 +684,11 @@ CORBA::Boolean SMESH_MeshEditor_i::QuadToTriObject (SMESH::SMESH_IDSource_ptr
   aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
 #endif
 
+  SMESH::NumericalFunctor_i* aNumericalFunctor =
+    SMESH::DownCast<SMESH::NumericalFunctor_i*>( Criterion );
+
   // Update Python script
-  TPythonDump() << "isDone = " << this << ".QuadToTriObject(" << theObject << ", None )";
+  TPythonDump() << "isDone = " << this << ".QuadToTriObject( " << theObject << ", " << aNumericalFunctor << " )";
 #ifdef _DEBUG_
   TPythonDump() << "print 'QuadToTriObject: ', isDone";
 #endif
@@ -691,7 +710,7 @@ CORBA::Boolean SMESH_MeshEditor_i::SplitQuad (const SMESH::long_array & IDsOfEle
 
   SMESHDS_Mesh* aMesh = GetMeshDS();
   map<int,const SMDS_MeshElement*> faces;
-  ToMap(IDsOfElements, aMesh, faces);
+  ToMap(IDsOfElements, aMesh, faces, SMDSAbs_Face);
 
   // Update Python script
   TPythonDump() << "isDone = " << this << ".SplitQuad( "
@@ -855,7 +874,7 @@ CORBA::Boolean
   SMESHDS_Mesh* aMesh = GetMeshDS();
 
   map<int,const SMDS_MeshElement*> elements;
-  ToMap(IDsOfElements, aMesh, elements);
+  ToMap(IDsOfElements, aMesh, elements, SMDSAbs_Face);
 
   set<const SMDS_MeshNode*> fixedNodes;
   for (int i = 0; i < IDsOfFixedNodes.length(); i++) {
@@ -1044,15 +1063,20 @@ void SMESH_MeshEditor_i::ExtrusionSweep(const SMESH::long_array & theIDsOfElemen
   myLastCreatedElems = new SMESH::long_array();
   myLastCreatedNodes = new SMESH::long_array();
 
-  CASCatch_TRY {   
+#ifdef NO_CAS_CATCH
+  try {   
+    OCC_CATCH_SIGNALS;
+#else
+  CASCatch_TRY {
+#endif
     SMESHDS_Mesh* aMesh = GetMeshDS();
-    
+
     map<int,const SMDS_MeshElement*> elements;
     ToMap(theIDsOfElements, aMesh, elements);
 
     const SMESH::PointStruct * P = &theStepVector.PS;
     gp_Vec stepVec( P->x, P->y, P->z );
-    
+
     TElemOfElemListMap aHystory;
     ::SMESH_MeshEditor anEditor( _myMesh );
     anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps, aHystory);
@@ -1062,10 +1086,13 @@ void SMESH_MeshEditor_i::ExtrusionSweep(const SMESH::long_array & theIDsOfElemen
     // Update Python script
     TPythonDump() << "stepVector = " << theStepVector;
     TPythonDump() << this << ".ExtrusionSweep( "
-                 << theIDsOfElements << ", stepVector, " << theNbOfSteps << " )";
+                  << theIDsOfElements << ", stepVector, " << theNbOfSteps << " )";
 
-  }
-  CASCatch_CATCH(Standard_Failure) {
+#ifdef NO_CAS_CATCH
+  } catch(Standard_Failure) {
+#else
+  } CASCatch_CATCH(Standard_Failure) {
+#endif
     Handle(Standard_Failure) aFail = Standard_Failure::Caught();          
     INFOS( "SMESH_MeshEditor_i::ExtrusionSweep fails - "<< aFail->GetMessageString() );
   }