Salome HOME
Replace oe by ?
[modules/smesh.git] / src / SMDS / SMDS_VtkVolume.cxx
index b76fe9d65bbc2e0d2ed2d9ee3d8306a25d0e4375..15664b6107a1f1b7899a97c7528c0ecf5a961f80 100644 (file)
@@ -21,8 +21,8 @@ SMDS_VtkVolume::SMDS_VtkVolume(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh)
  */
 void SMDS_VtkVolume::init(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh)
 {
+  SMDS_MeshVolume::init();
   vtkUnstructuredGrid* grid = mesh->getGrid();
-  myIdInShape = -1;
   myMeshId = mesh->getMeshId();
   vtkIdType aType = VTK_TETRA;
   switch (nodeIds.size())
@@ -63,9 +63,9 @@ void SMDS_VtkVolume::init(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh)
 //#ifdef VTK_HAVE_POLYHEDRON
 void SMDS_VtkVolume::initPoly(std::vector<vtkIdType> nodeIds, std::vector<int> nbNodesPerFace, SMDS_Mesh* mesh)
 {
-  MESSAGE("SMDS_VtkVolume::initPoly");
+  SMDS_MeshVolume::init();
+  //MESSAGE("SMDS_VtkVolume::initPoly");
   SMDS_UnstructuredGrid* grid = mesh->getGrid();
-  // TODO is it useful to orient faces ?
   double center[3];
   this->gravityCenter(grid, &nodeIds[0], nodeIds.size(), &center[0]);
   vector<vtkIdType> ptIds;
@@ -76,14 +76,13 @@ void SMDS_VtkVolume::initPoly(std::vector<vtkIdType> nodeIds, std::vector<int> n
     {
       int nf = nbNodesPerFace[i];
       ptIds.push_back(nf);
-//      double a[3];
-//      double b[3];
-//      double c[3];
-//      grid->GetPoints()->GetPoint(nodeIds[k], a);
-//      grid->GetPoints()->GetPoint(nodeIds[k + 1], b);
-//      grid->GetPoints()->GetPoint(nodeIds[k + 2], c);
-//      bool isFaceForward = this->isForward(a, b, c, center);
-      bool isFaceForward = true;
+      double a[3];
+      double b[3];
+      double c[3];
+      grid->GetPoints()->GetPoint(nodeIds[k], a);
+      grid->GetPoints()->GetPoint(nodeIds[k + 1], b);
+      grid->GetPoints()->GetPoint(nodeIds[k + 2], c);
+      bool isFaceForward = this->isForward(a, b, c, center);
       //MESSAGE("isFaceForward " << i << " " << isFaceForward);
       vtkIdType *facePts = &nodeIds[k];
       if (isFaceForward)
@@ -571,9 +570,10 @@ bool SMDS_VtkVolume::isForward(double* a, double* b, double* c, double* d)
       w[j] = d[j] - a[j];
       //MESSAGE("u,v,w " << u[j] << " " << v[j] << " " << w[j]);
     }
-  double prodmixte = (u[2] * v[3] - u[3] * v[2]) * w[1] + (u[3] * v[1] - u[1] * v[3]) * w[2] + (u[1] * v[2] - u[2]
-      * v[1]) * w[3];
-  return (prodmixte >= 0);
+  double prodmixte = (u[1]*v[2] - u[2]*v[1]) * w[0]
+                   + (u[2]*v[0] - u[0]*v[2]) * w[1]
+                   + (u[0]*v[1] - u[1]*v[0]) * w[2];
+  return (prodmixte < 0);
 }
 
 /*! For polyhedron only