+// Copyright (C) 2010-2011 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
#include "SMDS_VtkVolume.hxx"
#include "SMDS_MeshNode.hxx"
#include "SMDS_Mesh.hxx"
*/
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())
//#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(), ¢er[0]);
vector<vtkIdType> ptIds;
{
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;
+ // EAP: a right approach is:
+ // - either the user should care of order of nodes or
+ // - the user should use a service method arranging nodes if he
+ // don't want or can't to do it by him-self
+ // The method below works OK only with planar faces
+ //
+ // 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)
+ //if (isFaceForward)
for (int n = 0; n < nf; n++)
ptIds.push_back(facePts[n]);
- else
- for (int n = nf - 1; n >= 0; n--)
- ptIds.push_back(facePts[n]);
+ // else
+ // for (int n = nf - 1; n >= 0; n--)
+ // ptIds.push_back(facePts[n]);
k += nf;
}
myVtkID = grid->InsertNextLinkedCell(VTK_POLYHEDRON, nbFaces, &ptIds[0]);
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