Salome HOME
Add "Deflection 2D" quality control
[modules/smesh.git] / src / SMESH_I / SMESH_Filter_i.cxx
index 7ceeb904fac40eabe1104e54b046fe5bbadb9a00..3ae548024c4bc8eda5a39db17a3653e8b4570f3b 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -40,6 +40,8 @@
 #include <SALOMEDS_wrap.hxx>
 #include <GEOM_wrap.hxx>
 
+#include <Basics_OCCTVersion.hxx>
+
 #include <BRep_Tool.hxx>
 #include <Geom_CylindricalSurface.hxx>
 #include <Geom_Plane.hxx>
@@ -170,21 +172,21 @@ static TopoDS_Shape getShapeByID (const char* theID)
   return TopoDS_Shape();
 }
 
-static std::string getShapeNameByID (const char* theID)
-{
-  if ( theID && strlen( theID ) > 0 ) {
-    SMESH_Gen_i*     aSMESHGen = SMESH_Gen_i::GetSMESHGen();
-    SALOMEDS::Study_var aStudy = aSMESHGen->GetCurrentStudy();
-    if ( !aStudy->_is_nil() ) {
-      SALOMEDS::SObject_wrap aSObj = aStudy->FindObjectID(theID);
-      if ( !aSObj->_is_nil() ) {
-        CORBA::String_var name = aSObj->GetName();
-        return name.in();
-      }
-    }
-  }
-  return "";
-}
+// static std::string getShapeNameByID (const char* theID)
+// {
+//   if ( theID && strlen( theID ) > 0 ) {
+//     SMESH_Gen_i*     aSMESHGen = SMESH_Gen_i::GetSMESHGen();
+//     SALOMEDS::Study_var aStudy = aSMESHGen->GetCurrentStudy();
+//     if ( !aStudy->_is_nil() ) {
+//       SALOMEDS::SObject_wrap aSObj = aStudy->FindObjectID(theID);
+//       if ( !aSObj->_is_nil() ) {
+//         CORBA::String_var name = aSObj->GetName();
+//         return name.in();
+//       }
+//     }
+//   }
+//   return "";
+// }
 
 /*
                                 FUNCTORS
@@ -532,6 +534,21 @@ SMESH::Length2D::Values* Length2D_i::GetValues()
   return aResult._retn();
 }
 
+/*
+  Class       : Deflection2D_i
+  Description : Functor for calculating distance between a face and geometry
+*/
+Deflection2D_i::Deflection2D_i()
+{
+  myNumericalFunctorPtr.reset( new Controls::Deflection2D() );
+  myFunctorPtr = myNumericalFunctorPtr;
+}
+
+FunctorType Deflection2D_i::GetFunctorType()
+{
+  return SMESH::FT_Deflection2D;
+}
+
 /*
   Class       : MultiConnection_i
   Description : Functor for calculating number of faces conneted to the edge
@@ -562,6 +579,21 @@ FunctorType BallDiameter_i::GetFunctorType()
   return SMESH::FT_BallDiameter;
 }
 
+/*
+  Class       : NodeConnectivityNumber_i
+  Description : Functor returning diameter of a ball element
+*/
+NodeConnectivityNumber_i::NodeConnectivityNumber_i()
+{
+  myNumericalFunctorPtr.reset( new Controls::NodeConnectivityNumber() );
+  myFunctorPtr = myNumericalFunctorPtr;
+}
+
+FunctorType NodeConnectivityNumber_i::GetFunctorType()
+{
+  return SMESH::FT_NodeConnectivityNumber;
+}
+
 /*
   Class       : MultiConnection2D_i
   Description : Functor for calculating number of faces conneted to the edge
@@ -1412,7 +1444,7 @@ FunctorType LinearOrQuadratic_i::GetFunctorType()
 
 /*
   Class       : GroupColor_i
-  Description : Functor for check color of group to whic mesh element belongs to
+  Description : Functor for check color of group to which mesh element belongs to
 */
 GroupColor_i::GroupColor_i()
 {
@@ -1628,7 +1660,7 @@ void ConnectedElements_i::SetThreshold ( const char*
   {
   case SMESH::ConnectedElements::POINT: // read 3 node coordinates ///////////////////
     {
-      vector< double > xyz;
+      std::vector< double > xyz;
       char* endptr;
       do
       {
@@ -1830,9 +1862,9 @@ FunctorType EqualTo_i::GetFunctorType()
   Class       : LogicalNOT_i
   Description : Logical NOT predicate
 */
-LogicalNOT_i::LogicalNOT_i()
-: myPredicate( NULL ),
-  myLogicalNOTPtr( new Controls::LogicalNOT() )
+LogicalNOT_i::LogicalNOT_i():
+  myLogicalNOTPtr( new Controls::LogicalNOT() ),
+  myPredicate( NULL )
 {
   myFunctorPtr = myPredicatePtr = myLogicalNOTPtr;
 }
@@ -2096,6 +2128,14 @@ Length2D_ptr FilterManager_i::CreateLength2D()
   return anObj._retn();
 }
 
+Deflection2D_ptr FilterManager_i::CreateDeflection2D()
+{
+  SMESH::Deflection2D_i* aServant = new SMESH::Deflection2D_i();
+  SMESH::Deflection2D_var   anObj = aServant->_this();
+  TPythonDump()<<aServant<<" = "<<this<<".CreateLength2D()";
+  return anObj._retn();
+}
+
 MultiConnection_ptr FilterManager_i::CreateMultiConnection()
 {
   SMESH::MultiConnection_i* aServant = new SMESH::MultiConnection_i();
@@ -2120,6 +2160,14 @@ BallDiameter_ptr FilterManager_i::CreateBallDiameter()
   return anObj._retn();
 }
 
+NodeConnectivityNumber_ptr FilterManager_i::CreateNodeConnectivityNumber()
+{
+  SMESH::NodeConnectivityNumber_i* aServant = new SMESH::NodeConnectivityNumber_i();
+  SMESH::NodeConnectivityNumber_var anObj = aServant->_this();
+  TPythonDump()<<aServant<<" = "<<this<<".CreateNodeConnectivityNumber()";
+  return anObj._retn();
+}
+
 BelongToMeshGroup_ptr FilterManager_i::CreateBelongToMeshGroup()
 {
   SMESH::BelongToMeshGroup_i* aServant = new SMESH::BelongToMeshGroup_i();
@@ -2931,6 +2979,9 @@ CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria
       case SMESH::FT_Length2D:
         aFunctor = aFilterMgr->CreateLength2D();
         break;
+      case SMESH::FT_Deflection2D:
+        aFunctor = aFilterMgr->CreateDeflection2D();
+        break;
       case SMESH::FT_AspectRatio:
         aFunctor = aFilterMgr->CreateAspectRatio();
         break;
@@ -2964,6 +3015,9 @@ CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria
       case SMESH::FT_BallDiameter:
         aFunctor = aFilterMgr->CreateBallDiameter();
         break;
+      case SMESH::FT_NodeConnectivityNumber:
+        aFunctor = aFilterMgr->CreateNodeConnectivityNumber();
+        break;
 
       // Predicates
 
@@ -3423,9 +3477,10 @@ static inline LDOMString toString( CORBA::Long theType )
     case FT_EqualFaces            : return "Equal faces";
     case FT_EqualVolumes          : return "Equal volumes";
     case FT_MultiConnection       : return "Borders at multi-connections";
-    case FT_MultiConnection2D     :return "Borders at multi-connections 2D";
+    case FT_MultiConnection2D     : return "Borders at multi-connections 2D";
     case FT_Length                : return "Length";
     case FT_Length2D              : return "Length 2D";
+    case FT_Deflection2D          : return "Deflection 2D";
     case FT_LessThan              : return "Less than";
     case FT_MoreThan              : return "More than";
     case FT_EqualTo               : return "Equal to";
@@ -3474,6 +3529,7 @@ static inline SMESH::FunctorType toFunctorType( const LDOMString& theStr )
   //  else if ( theStr.equals( "Borders at multi-connections 2D" ) ) return FT_MultiConnection2D;
   else if ( theStr.equals( "Length"                       ) ) return FT_Length;
   //  else if ( theStr.equals( "Length2D"                     ) ) return FT_Length2D;
+  else if ( theStr.equals( "Deflection"                   ) ) return FT_Deflection2D;
   else if ( theStr.equals( "Range of IDs"                 ) ) return FT_RangeOfIds;
   else if ( theStr.equals( "Bad Oriented Volume"          ) ) return FT_BadOrientedVolume;
   else if ( theStr.equals( "Volumes with bare border"     ) ) return FT_BareBorderVolume;
@@ -3913,6 +3969,7 @@ CORBA::Boolean FilterLibrary_i::Save()
   if ( myFileName == 0 || strlen( myFileName ) == 0 )
     return false;
 
+#if OCC_VERSION_MAJOR < 7
   FILE* aOutFile = fopen( myFileName, "wt" );
   if ( !aOutFile )
     return false;
@@ -3921,6 +3978,17 @@ CORBA::Boolean FilterLibrary_i::Save()
   aWriter.SetIndentation( 2 );
   aWriter << myDoc;
   fclose( aOutFile );
+#else
+  std::filebuf fb;
+  fb.open( myFileName, std::ios::out );
+
+  Standard_OStream os( &fb );
+
+  LDOM_XmlWriter aWriter;
+  aWriter.SetIndentation( 2 );
+  aWriter.Write( os, myDoc );
+  fb.close();
+#endif
 
   TPythonDump()<<this<<".Save()";
   return true;
@@ -4038,6 +4106,8 @@ static const char** getFunctNames()
     "FT_MultiConnection2D",
     "FT_Length",
     "FT_Length2D",
+    "FT_Deflection2D",
+    "FT_NodeConnectivityNumber",
     "FT_BelongToMeshGroup",
     "FT_BelongToGeom",
     "FT_BelongToPlane",
@@ -4053,7 +4123,7 @@ static const char** getFunctNames()
     "FT_LinearOrQuadratic",
     "FT_GroupColor",
     "FT_ElemGeomType",
-    "FT_EntityType", 
+    "FT_EntityType",
     "FT_CoplanarFaces",
     "FT_BallDiameter",
     "FT_ConnectedElements",
@@ -4068,7 +4138,7 @@ static const char** getFunctNames()
 #ifdef _DEBUG_
   // check if functName is complete, compilation failure means that enum FunctorType changed
   const int nbFunctors = sizeof(functName) / sizeof(const char*);
-  int _assert[( nbFunctors == SMESH::FT_Undefined + 1 ) ? 1 : -1 ];
+  int _assert[( nbFunctors == SMESH::FT_Undefined + 1 ) ? 2 : -1 ]; _assert[0]=_assert[1]=0;
 #endif
 
   return functName;