Salome HOME
0022136: EDF 2345 SMESH: Improving documentation of Quadrangle mapping with the type...
[modules/smesh.git] / src / SMDS / SMDS_VolumeTool.cxx
index 2c7c401cb00ecdb4ce3f64d4393b4b927a97804d..982942827e4894c135d20277b890179ff61fdc6c 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2013  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
@@ -292,27 +292,27 @@ static int QuadPenta_RE [5][9] = { // REVERSED -> EXTERNAL
 static int QuadPenta_nbN [] = { 6, 6, 8, 8, 8 };
 
 /*
-//                 13
-//         N5+-----+-----+N6
-//          /|          /|
-//       12+ |       14+ |
-//        /  |        /  |
-//     N4+-----+-----+N7 |           QUADRATIC
-//       |   | 15    |   |           HEXAHEDRON
-//       |   |       |   |
-//       | 17+       |   +18
-//       |   |       |   |
-//       |   |       |   |
-//       |   |       |   |
-//     16+   |       +19 |
-//       |   |       |   |
-//       |   |     9 |   |
-//       | N1+-----+-|---+N2
-//       |  /        |  /
-//       | +8        | +10
-//       |/          |/
-//     N0+-----+-----+N3
-//             11
+//                 13                                                         
+//         N5+-----+-----+N6                          +-----+-----+
+//          /|          /|                           /|          /| 
+//       12+ |       14+ |                          + |   +25   + |    
+//        /  |        /  |                         /  |        /  |    
+//     N4+-----+-----+N7 |       QUADRATIC        +-----+-----+   |  Central nodes
+//       |   | 15    |   |       HEXAHEDRON       |   |       |   |  of tri-quadratic
+//       |   |       |   |                        |   |       |   |  HEXAHEDRON
+//       | 17+       |   +18                      |   +   22+ |   +  
+//       |   |       |   |                        |21 |       |   | 
+//       |   |       |   |                        | + | 26+   | + |    
+//       |   |       |   |                        |   |       |23 |    
+//     16+   |       +19 |                        +   | +24   +   |    
+//       |   |       |   |                        |   |       |   |    
+//       |   |     9 |   |                        |   |       |   |    
+//       | N1+-----+-|---+N2                      |   +-----+-|---+    
+//       |  /        |  /                         |  /        |  /  
+//       | +8        | +10                        | +   20+   | +      
+//       |/          |/                           |/          |/       
+//     N0+-----+-----+N3                          +-----+-----+    
+//             11                              
 */
 static int QuadHexa_F [6][9] = {  // FORWARD
   { 0, 8, 1, 9, 2, 10,3, 11,0 },   // all face normals are external,
@@ -1493,9 +1493,7 @@ double SMDS_VolumeTool::MaxLinearSize2() const
 
 //================================================================================
 /*!
- * \brief check that only one volume is build on the face nodes
- *
- * If a face is shared by one of <ignoreVolumes>, it is considered free
+ * \brief fast check that only one volume is build on the face nodes
  */
 //================================================================================
 
@@ -1503,6 +1501,45 @@ bool SMDS_VolumeTool::IsFreeFace( int faceIndex, const SMDS_MeshElement** otherV
 {
   const bool isFree = true;
 
+  if (!setFace( faceIndex ))
+    return !isFree;
+
+  const SMDS_MeshNode** nodes = GetFaceNodes( faceIndex );
+
+  // a set of facet nodes w/o medium ones and w/o nodes[0]
+  set< const SMDS_MeshNode* > nodeSet;
+  const int di = myVolume->IsQuadratic() ? 2 : 1;
+  for ( int i = di; i < myFaceNbNodes; i += di )
+    nodeSet.insert( nodes[i] );
+
+  SMDS_ElemIteratorPtr eIt = nodes[0]->GetInverseElementIterator( SMDSAbs_Volume );
+  while ( eIt->more() ) {
+    const SMDS_MeshElement* vol = eIt->next();
+    if ( vol != myVolume ) {
+      size_t nbShared = 0;
+      SMDS_NodeIteratorPtr nIt = vol->nodeIterator();
+      while ( nIt->more() )
+        if (( nbShared += nodeSet.count( nIt->next() )) == nodeSet.size() )
+        {
+          if ( otherVol ) *otherVol = vol;
+          return !isFree;
+        }
+    }
+  }
+  if ( otherVol ) *otherVol = 0;
+  return isFree;
+}
+
+//================================================================================
+/*!
+ * \brief Thorough check that only one volume is build on the face nodes
+ */
+//================================================================================
+
+bool SMDS_VolumeTool::IsFreeFaceAdv( int faceIndex, const SMDS_MeshElement** otherVol/*=0*/ ) const
+{
+  const bool isFree = true;
+
   if (!setFace( faceIndex ))
     return !isFree;
 
@@ -1621,14 +1658,16 @@ bool SMDS_VolumeTool::IsFreeFace( int faceIndex, const SMDS_MeshElement** otherV
 
 int SMDS_VolumeTool::GetFaceIndex( const set<const SMDS_MeshNode*>& theFaceNodes ) const
 {
-  for ( int iFace = 0; iFace < myNbFaces; iFace++ ) {
-    const SMDS_MeshNode** nodes = GetFaceNodes( iFace );
-    int nbFaceNodes = NbFaceNodes( iFace );
-    set<const SMDS_MeshNode*> nodeSet;
-    for ( int iNode = 0; iNode < nbFaceNodes; iNode++ )
-      nodeSet.insert( nodes[ iNode ] );
-    if ( theFaceNodes == nodeSet )
-      return iFace;
+  for ( int iFace = 0; iFace < myNbFaces; iFace++ )
+  {
+    const int nbNodes = NbFaceNodes( iFace );
+    if ( nbNodes == (int) theFaceNodes.size() )
+    {
+      const SMDS_MeshNode** nodes = GetFaceNodes( iFace );
+      set<const SMDS_MeshNode*> nodeSet( nodes, nodes + nbNodes);
+      if ( theFaceNodes == nodeSet )
+        return iFace;
+    }
   }
   return -1;
 }