Salome HOME
Porting to DEV version of OCCT.
[modules/smesh.git] / src / Controls / SMESH_Controls.cxx
index efb84e2406c7a41f112a973acdf9f1b53ed341dc..ee372e22239ca26fdeede963c30de29d18e2beaf 100644 (file)
@@ -134,7 +134,7 @@ namespace {
     //  +-----+------+  +-----+------+ 
     //  |            |  |            |
     //  |            |  |            |
-    // result sould be 2 in both cases
+    // result should be 2 in both cases
     //
     int aResult0 = 0, aResult1 = 0;
      // last node, it is a medium one in a quadratic edge
@@ -2116,6 +2116,42 @@ SMDSAbs_ElementType BallDiameter::GetType() const
   return SMDSAbs_Ball;
 }
 
+//================================================================================
+/*
+  Class       : NodeConnectivityNumber
+  Description : Functor returning number of elements connected to a node
+*/
+//================================================================================
+
+double NodeConnectivityNumber::GetValue( long theId )
+{
+  double nb = 0;
+
+  if ( const SMDS_MeshNode* node = myMesh->FindNode( theId ))
+  {
+    SMDSAbs_ElementType type;
+    if ( myMesh->NbVolumes() > 0 )
+      type = SMDSAbs_Volume;
+    else if ( myMesh->NbFaces() > 0 )
+      type = SMDSAbs_Face;
+    else if ( myMesh->NbEdges() > 0 )
+      type = SMDSAbs_Edge;
+    else
+      return 0;
+    nb = node->NbInverseElements( type );
+  }
+  return nb;
+}
+
+double NodeConnectivityNumber::GetBadRate( double Value, int /*nbNodes*/ ) const
+{
+  return Value;
+}
+
+SMDSAbs_ElementType NodeConnectivityNumber::GetType() const
+{
+  return SMDSAbs_Node;
+}
 
 /*
                             PREDICATES
@@ -2614,7 +2650,7 @@ bool FreeFaces::IsSatisfy( long theId )
   for ( ; volItr != volEnd; ++volItr )
     if ( (*volItr).second >= nbNode )
        nbVol++;
-  // face is not free if number of volumes constructed on thier nodes more than one
+  // face is not free if number of volumes constructed on their nodes more than one
   return (nbVol < 2);
 }
 
@@ -2662,7 +2698,7 @@ SMDSAbs_ElementType LinearOrQuadratic::GetType() const
 //================================================================================
 /*
   Class       : GroupColor
-  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
 */
 //================================================================================
 
@@ -3220,7 +3256,7 @@ bool RangeOfIds::SetRangeStr( const TCollection_AsciiString& theStr )
   {
     char c = aStr.Value( i );
     if ( !isdigit( c ) && c != ',' && c != '-' )
-      aStr.SetValue( i, ' ');
+      aStr.SetValue( i, ',');
   }
   aStr.RemoveAll( ' ' );
 
@@ -4097,7 +4133,8 @@ namespace {
 
 struct ElementsOnShape::Classifier
 {
-  //Classifier(const TopoDS_Shape& s, double tol) { Init(s,tol); }
+  Classifier() { mySolidClfr = 0; myFlags = 0; }
+  ~Classifier();
   void Init(const TopoDS_Shape& s, double tol, const Bnd_B3d* box = 0 );
   bool IsOut(const gp_Pnt& p)        { return SetChecked( true ), (this->*myIsOutFun)( p ); }
   TopAbs_ShapeEnum ShapeType() const { return myShape.ShapeType(); }
@@ -4108,6 +4145,7 @@ struct ElementsOnShape::Classifier
   void SetChecked( bool is ) { is ? SetFlag( theIsCheckedFlag ) : UnsetFlag( theIsCheckedFlag ); }
   void SetFlag  ( int flag ) { myFlags |= flag; }
   void UnsetFlag( int flag ) { myFlags &= ~flag; }
+
 private:
   bool isOutOfSolid (const gp_Pnt& p);
   bool isOutOfBox   (const gp_Pnt& p);
@@ -4116,15 +4154,15 @@ private:
   bool isOutOfVertex(const gp_Pnt& p);
   bool isBox        (const TopoDS_Shape& s);
 
-  bool (Classifier::*         myIsOutFun)(const gp_Pnt& p);
-  BRepClass3d_SolidClassifier mySolidClfr;
-  Bnd_B3d                     myBox;
-  GeomAPI_ProjectPointOnSurf  myProjFace;
-  GeomAPI_ProjectPointOnCurve myProjEdge;
-  gp_Pnt                      myVertexXYZ;
-  TopoDS_Shape                myShape;
-  double                      myTol;
-  int                         myFlags;
+  bool (Classifier::*          myIsOutFun)(const gp_Pnt& p);
+  BRepClass3d_SolidClassifier* mySolidClfr; // ptr because of a run-time forbidden copy-constructor
+  Bnd_B3d                      myBox;
+  GeomAPI_ProjectPointOnSurf   myProjFace;
+  GeomAPI_ProjectPointOnCurve  myProjEdge;
+  gp_Pnt                       myVertexXYZ;
+  TopoDS_Shape                 myShape;
+  double                       myTol;
+  int                          myFlags;
 };
 
 struct ElementsOnShape::OctreeClassifier : public SMESH_Octree
@@ -4364,6 +4402,7 @@ void ElementsOnShape::Classifier::Init( const TopoDS_Shape& theShape,
 {
   myShape = theShape;
   myTol   = theTol;
+  myFlags = 0;
 
   bool isShapeBox = false;
   switch ( myShape.ShapeType() )
@@ -4376,7 +4415,7 @@ void ElementsOnShape::Classifier::Init( const TopoDS_Shape& theShape,
     }
     else
     {
-      mySolidClfr.Load(theShape);
+      mySolidClfr = new BRepClass3d_SolidClassifier(theShape);
       myIsOutFun = & ElementsOnShape::Classifier::isOutOfSolid;
     }
     break;
@@ -4432,10 +4471,15 @@ void ElementsOnShape::Classifier::Init( const TopoDS_Shape& theShape,
   }
 }
 
+ElementsOnShape::Classifier::~Classifier()
+{
+  delete mySolidClfr; mySolidClfr = 0;
+}
+
 bool ElementsOnShape::Classifier::isOutOfSolid (const gp_Pnt& p)
 {
-  mySolidClfr.Perform( p, myTol );
-  return ( mySolidClfr.State() != TopAbs_IN && mySolidClfr.State() != TopAbs_ON );
+  mySolidClfr->Perform( p, myTol );
+  return ( mySolidClfr->State() != TopAbs_IN && mySolidClfr->State() != TopAbs_ON );
 }
 
 bool ElementsOnShape::Classifier::isOutOfBox (const gp_Pnt& p)
@@ -4449,7 +4493,7 @@ bool ElementsOnShape::Classifier::isOutOfFace  (const gp_Pnt& p)
   if ( myProjFace.IsDone() && myProjFace.LowerDistance() <= myTol )
   {
     // check relatively to the face
-    Quantity_Parameter u, v;
+    Standard_Real u, v;
     myProjFace.LowerDistanceParameters(u, v);
     gp_Pnt2d aProjPnt (u, v);
     BRepClass_FaceClassifier aClsf ( TopoDS::Face( myShape ), aProjPnt, myTol );
@@ -4524,7 +4568,7 @@ OctreeClassifier::OctreeClassifier( const OctreeClassifier*
   }
   else if ( otherTree->myChildren )
   {
-    myChildren = new SMESH_Tree*[ 8 ];
+    myChildren = new SMESH_Tree< Bnd_B3d, 8 > * [ 8 ];
     for ( int i = 0; i < nbChildren(); i++ )
       myChildren[i] =
         new OctreeClassifier( static_cast<const OctreeClassifier*>( otherTree->myChildren[i]),