Salome HOME
Merge from V6_main 01/04/2013
[modules/smesh.git] / src / SMDS / SMDS_VolumeTool.cxx
index 841d2354078e16761d4f199c4c189b93391d6c91..0f864575b8ed8e323b7aea33c772e67312c62812 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,
@@ -1452,6 +1452,45 @@ double SMDS_VolumeTool::MinLinearSize2() const
   return minSize;
 }
 
+//================================================================================
+/*!
+ * \brief Return maximal square distance between connected corner nodes
+ */
+//================================================================================
+
+double SMDS_VolumeTool::MaxLinearSize2() const
+{
+  double maxSize = -1e+100;
+  int iQ = myVolume->IsQuadratic() ? 2 : 1;
+
+  // store current face data
+  int curFace = myCurFace, nbN = myFaceNbNodes;
+  int* ind = myFaceNodeIndices;
+  myFaceNodeIndices = NULL;
+  const SMDS_MeshNode** nodes = myFaceNodes;
+  myFaceNodes = NULL;
+  
+  // it seems that compute distance twice is faster than organization of a sole computing
+  myCurFace = -1;
+  for ( int iF = 0; iF < myNbFaces; ++iF )
+  {
+    setFace( iF );
+    for ( int iN = 0; iN < myFaceNbNodes; iN += iQ )
+    {
+      XYZ n1( myFaceNodes[ iN ]);
+      XYZ n2( myFaceNodes[(iN + iQ) % myFaceNbNodes]);
+      maxSize = std::max( maxSize, (n1 - n2).SquareMagnitude());
+    }
+  }
+  // restore current face data
+  myCurFace         = curFace;
+  myFaceNbNodes     = nbN;
+  myFaceNodeIndices = ind;
+  delete [] myFaceNodes; myFaceNodes = nodes;
+
+  return maxSize;
+}
+
 //================================================================================
 /*!
  * \brief check that only one volume is build on the face nodes