4 * Created on: Jun 3, 2010
8 #include "SMDS_Downward.hxx"
9 #include "SMDS_Mesh.hxx"
10 #include "utilities.h"
12 #include <vtkCellType.h>
13 #include <vtkCellLinks.h>
19 // ---------------------------------------------------------------------------
21 vector<int> SMDS_Downward::_cellDimension;
23 /*! get the dimension of a cell (1,2,3 for 1D, 2D 3D) given the vtk cell type
25 * @param cellType vtk cell type @see vtkCellType.h
28 int SMDS_Downward::getCellDimension(unsigned char cellType)
30 if (_cellDimension.empty())
32 _cellDimension.resize(VTK_MAXTYPE + 1, 0);
33 _cellDimension[VTK_LINE] = 1;
34 _cellDimension[VTK_QUADRATIC_EDGE] = 1;
35 _cellDimension[VTK_TRIANGLE] = 2;
36 _cellDimension[VTK_QUADRATIC_TRIANGLE] = 2;
37 _cellDimension[VTK_QUAD] = 2;
38 _cellDimension[VTK_QUADRATIC_QUAD] = 2;
39 _cellDimension[VTK_TETRA] = 3;
40 _cellDimension[VTK_QUADRATIC_TETRA] = 3;
41 _cellDimension[VTK_HEXAHEDRON] = 3;
42 _cellDimension[VTK_QUADRATIC_HEXAHEDRON] = 3;
43 _cellDimension[VTK_WEDGE] = 3;
44 _cellDimension[VTK_QUADRATIC_WEDGE] = 3;
45 _cellDimension[VTK_PYRAMID] = 3;
46 _cellDimension[VTK_QUADRATIC_PYRAMID] = 3;
48 return _cellDimension[cellType];
51 // ---------------------------------------------------------------------------
53 /*! Generic constructor for all the downward connectivity structures (one per vtk cell type).
54 * The static structure for cell dimension is set only once.
55 * @param grid unstructured grid associated to the mesh.
56 * @param nbDownCells number of downward entities associated to this vtk type of cell.
59 SMDS_Downward::SMDS_Downward(SMDS_UnstructuredGrid *grid, int nbDownCells) :
60 _grid(grid), _nbDownCells(nbDownCells)
63 this->_cellIds.clear();
64 this->_cellTypes.clear();
65 if (_cellDimension.empty())
67 _cellDimension.resize(VTK_MAXTYPE + 1, 0);
68 _cellDimension[VTK_LINE] = 1;
69 _cellDimension[VTK_QUADRATIC_EDGE] = 1;
70 _cellDimension[VTK_TRIANGLE] = 2;
71 _cellDimension[VTK_QUADRATIC_TRIANGLE] = 2;
72 _cellDimension[VTK_QUAD] = 2;
73 _cellDimension[VTK_QUADRATIC_QUAD] = 2;
74 _cellDimension[VTK_TETRA] = 3;
75 _cellDimension[VTK_QUADRATIC_TETRA] = 3;
76 _cellDimension[VTK_HEXAHEDRON] = 3;
77 _cellDimension[VTK_QUADRATIC_HEXAHEDRON] = 3;
78 _cellDimension[VTK_WEDGE] = 3;
79 _cellDimension[VTK_QUADRATIC_WEDGE] = 3;
80 _cellDimension[VTK_PYRAMID] = 3;
81 _cellDimension[VTK_QUADRATIC_PYRAMID] = 3;
85 SMDS_Downward::~SMDS_Downward()
89 /*! Give or create an entry for downward connectivity structure relative to a cell.
90 * If the entry already exists, just return its id, otherwise, create it.
91 * The internal storage memory is allocated if needed.
92 * The SMDS_UnstructuredGrid::_cellIdToDownId vector is completed for vtkUnstructuredGrid cells.
93 * @param vtkId for a vtkUnstructuredGrid cell or -1 (default) for a created downward cell.
94 * @return the rank in downward[vtkType] structure.
96 int SMDS_Downward::addCell(int vtkId)
100 localId = _grid->CellIdToDownId(vtkId);
104 localId = this->_maxId;
106 this->allocate(_maxId);
109 this->_vtkCellIds[localId] = vtkId;
110 _grid->setCellIdToDownId(vtkId, localId);
112 this->initCell(localId);
116 /*! generic method do nothing. see derived methods
120 void SMDS_Downward::initCell(int cellId)
124 /*! Get the number of downward entities associated to a cell (always the same for a given vtk type of cell)
126 * @param cellId not used here.
129 int SMDS_Downward::getNumberOfDownCells(int cellId)
134 /*! get a pointer on the downward entities id's associated to a cell.
135 * @see SMDS_Downward::getNumberOfDownCells for the number of downward entities.
136 * @see SMDS_Downward::getDownTypes for the vtk cell types associated to the downward entities.
137 * @param cellId index of the cell in the downward structure relative to a given vtk cell type.
138 * @return table of downward entities id's.
140 const int* SMDS_Downward::getDownCells(int cellId)
142 //ASSERT((cellId >=0) && (cellId < _maxId));
143 return &_cellIds[_nbDownCells * cellId];
146 /*! get a list of vtk cell types associated to downward entities of a given cell, in the same order
147 * than the downward entities id's list (@see SMDS_Downward::getDownCells).
149 * @param cellId index of the cell in the downward structure relative to a vtk cell type.
150 * @return table of downward entities types.
152 const unsigned char* SMDS_Downward::getDownTypes(int cellId)
154 return &_cellTypes[0];
157 /*! add a downward entity of dimension n-1 (cell or node) to a given cell.
158 * Actual implementation is done in derived methods.
159 * @param cellId index of the parent cell (dimension n) in the downward structure relative to a vtk cell type.
160 * @param lowCellId index of the children cell to add (dimension n-1)
161 * @param aType vtk cell type of the cell to add (needed to find the SMDS_Downward structure containing the cell to add).
163 void SMDS_Downward::addDownCell(int cellId, int lowCellId, unsigned char aType)
165 ASSERT(0); // must be re-implemented in derived class
168 /*! add a downward entity of dimension n+1 to a given cell.
169 * Actual implementation is done in derived methods.
170 * @param cellId index of the children cell (dimension n) in the downward structure relative to a vtk cell type.
171 * @param upCellId index of the parent cell to add (dimension n+1)
172 * @param aType vtk cell type of the cell to add (needed to find the SMDS_Downward structure containing the cell to add).
174 void SMDS_Downward::addUpCell(int cellId, int upCellId, unsigned char aType)
176 ASSERT(0); // must be re-implemented in derived class
179 int SMDS_Downward::getNodeSet(int cellId, int* nodeSet)
184 // ---------------------------------------------------------------------------
186 SMDS_Down1D::SMDS_Down1D(SMDS_UnstructuredGrid *grid, int nbDownCells) :
187 SMDS_Downward(grid, nbDownCells)
189 _upCellIdsVector.clear();
190 _upCellTypesVector.clear();
192 _upCellTypes.clear();
193 _upCellIndex.clear();
196 SMDS_Down1D::~SMDS_Down1D()
200 /*! clear vectors used to reference 2D cells containing the edge
204 void SMDS_Down1D::initCell(int cellId)
206 _upCellIdsVector[cellId].clear();
207 _upCellTypesVector[cellId].clear();
210 /*! Resize the downward connectivity storage vector if needed.
212 * @param nbElems total number of elements of the same type required
214 void SMDS_Down1D::allocate(int nbElems)
216 if (nbElems >= _vtkCellIds.size())
218 _vtkCellIds.resize(nbElems + SMDS_Mesh::chunkSize, -1);
219 _cellIds.resize(_nbDownCells * (nbElems + SMDS_Mesh::chunkSize), -1);
220 _upCellIdsVector.resize(nbElems + SMDS_Mesh::chunkSize);
221 _upCellTypesVector.resize(nbElems + SMDS_Mesh::chunkSize);
225 void SMDS_Down1D::compactStorage()
227 _cellIds.resize(_nbDownCells * _maxId);
228 _vtkCellIds.resize(_maxId);
231 for (int i = 0; i < _maxId; i++)
232 sizeUpCells += _upCellIdsVector[i].size();
233 _upCellIds.resize(sizeUpCells, -1);
234 _upCellTypes.resize(sizeUpCells);
235 _upCellIndex.resize(_maxId + 1, -1); // id and types of rank i correspond to [ _upCellIndex[i], _upCellIndex[i+1] [
237 for (int i = 0; i < _maxId; i++)
239 _upCellIndex[i] = current;
240 for (int j = 0; j < _upCellIdsVector[i].size(); j++)
242 _upCellIds[current] = _upCellIdsVector[i][j];
243 _upCellTypes[current] = _upCellTypesVector[i][j];
247 _upCellIndex[_maxId] = current;
249 _upCellIdsVector.clear();
250 _upCellTypesVector.clear();
253 void SMDS_Down1D::addUpCell(int cellId, int upCellId, unsigned char aType)
255 //ASSERT((cellId >=0) && (cellId < _maxId));
256 int nbFaces = _upCellIdsVector[cellId].size();
257 for (int i = 0; i < nbFaces; i++)
259 if ((_upCellIdsVector[cellId][i] == upCellId) && (_upCellTypesVector[cellId][i] == aType))
261 return; // already done
264 _upCellIdsVector[cellId].push_back(upCellId);
265 _upCellTypesVector[cellId].push_back(aType);
268 int SMDS_Down1D::getNumberOfUpCells(int cellId)
270 //ASSERT((cellId >=0) && (cellId < _maxId));
271 return _upCellIndex[cellId + 1] - _upCellIndex[cellId];
274 const int* SMDS_Down1D::getUpCells(int cellId)
276 //ASSERT((cellId >=0) && (cellId < _maxId));
277 return &_upCellIds[_upCellIndex[cellId]];
280 const unsigned char* SMDS_Down1D::getUpTypes(int cellId)
282 //ASSERT((cellId >=0) && (cellId < _maxId));
283 return &_upCellTypes[_upCellIndex[cellId]];
286 void SMDS_Down1D::getNodeIds(int cellId, std::set<int>& nodeSet)
288 for (int i = 0; i < _nbDownCells; i++)
289 nodeSet.insert(_cellIds[_nbDownCells * cellId + i]);
292 int SMDS_Down1D::getNodeSet(int cellId, int* nodeSet)
294 for (int i = 0; i < _nbDownCells; i++)
295 nodeSet[i] = _cellIds[_nbDownCells * cellId + i];
299 void SMDS_Down1D::setNodes(int cellId, int vtkId)
302 vtkIdType *pts; // will refer to the point id's of the face
303 _grid->GetCellPoints(vtkId, npts, pts);
304 // MESSAGE(vtkId << " " << npts << " " << _nbDownCells);
305 //ASSERT(npts == _nbDownCells);
306 for (int i = 0; i < npts; i++)
308 _cellIds[_nbDownCells * cellId + i] = pts[i];
312 void SMDS_Down1D::setNodes(int cellId, const int* nodeIds)
314 //ASSERT(nodeIds.size() == _nbDownCells);
315 for (int i = 0; i < _nbDownCells; i++)
317 _cellIds[_nbDownCells * cellId + i] = nodeIds[i];
321 /*! Build the list of vtkUnstructuredGrid cells containing the edge.
322 * We keep in the list the cells that contains all the nodes, we keep only volumes and faces.
323 * @param cellId id of the edge in the downward structure
324 * @param vtkIds vector of vtk id's
325 * @return number of vtk cells (size of vector)
327 int SMDS_Down1D::computeVtkCells(int cellId, std::vector<int>& vtkIds)
331 // --- find all the cells the points belong to, and how many of the points belong to a given cell
333 int *pts = &_cellIds[_nbDownCells * cellId];
334 int ncells = this->computeVtkCells(pts, vtkIds);
338 /*! Build the list of vtkUnstructuredGrid cells containing the edge.
340 * @param pts list of points id's defining an edge
341 * @param vtkIds vector of vtk id's
342 * @return number of vtk cells (size of vector)
344 int SMDS_Down1D::computeVtkCells(int *pts, std::vector<int>& vtkIds)
347 // --- find all the cells the points belong to, and how many of the points belong to a given cell
352 for (int i = 0; i < _nbDownCells; i++)
354 vtkIdType point = pts[i];
355 int numCells = _grid->GetLinks()->GetNcells(point);
356 vtkIdType *cells = _grid->GetLinks()->GetCells(point);
357 for (int j = 0; j < numCells; j++)
359 int vtkCellId = cells[j];
361 for (int k = 0; k < cnt; k++)
363 if (cellIds[k] == vtkCellId)
372 cellIds[cnt] = vtkCellId;
374 // TODO ASSERT(cnt<1000);
380 // --- find the face and volume cells: they contains all the points and are of type volume or face
383 for (int i = 0; i < cnt; i++)
385 if (cellCnt[i] == _nbDownCells)
387 int vtkElemId = cellIds[i];
388 int vtkType = _grid->GetCellType(vtkElemId);
389 if (SMDS_Downward::getCellDimension(vtkType) > 1)
391 vtkIds.push_back(vtkElemId);
400 /*! Build the list of downward faces from a list of vtk cells.
402 * @param cellId id of the edge in the downward structure
403 * @param vtkIds vector of vtk id's
404 * @param downFaces vector of face id's in downward structures
405 * @param downTypes vector of face types
406 * @return number of downward faces
408 int SMDS_Down1D::computeFaces(int cellId, int* vtkIds, int nbcells, int* downFaces, unsigned char* downTypes)
410 int *pts = &_cellIds[_nbDownCells * cellId];
411 int nbFaces = this->computeFaces(pts, vtkIds, nbcells, downFaces, downTypes);
415 /*! Build the list of downward faces from a list of vtk cells.
417 * @param pts list of points id's defining an edge
418 * @param vtkIds vector of vtk id's
419 * @param downFaces vector of face id's in downward structures
420 * @param downTypes vector of face types
421 * @return number of downward faces
423 int SMDS_Down1D::computeFaces(int* pts, int* vtkIds, int nbcells, int* downFaces, unsigned char* downTypes)
426 for (int i = 0; i < nbcells; i++)
428 int vtkId = vtkIds[i];
429 int vtkType = _grid->GetCellType(vtkId);
430 if (SMDS_Downward::getCellDimension(vtkType) == 2)
432 int faceId = _grid->CellIdToDownId(vtkId);
433 downFaces[cnt] = faceId;
434 downTypes[cnt] = vtkType;
437 else if (SMDS_Downward::getCellDimension(vtkType) == 3)
439 int volId = _grid->CellIdToDownId(vtkId);
440 SMDS_Downward * downvol = _grid->getDownArray(vtkType);
441 //const int *downIds = downvol->getDownCells(volId);
442 const unsigned char* downTypesVol = downvol->getDownTypes(volId);
443 int nbFaces = downvol->getNumberOfDownCells(volId);
444 const int* faceIds = downvol->getDownCells(volId);
445 for (int n = 0; n < nbFaces; n++)
447 SMDS_Down2D *downFace = static_cast<SMDS_Down2D*> (_grid->getDownArray(downTypesVol[n]));
448 bool isInFace = downFace->isInFace(faceIds[n], pts, _nbDownCells);
451 bool alreadySet = false;
452 for (int k = 0; k < cnt; k++)
453 if (faceIds[n] == downFaces[k])
460 downFaces[cnt] = faceIds[n];
461 downTypes[cnt] = downTypesVol[n];
471 // ---------------------------------------------------------------------------
473 SMDS_Down2D::SMDS_Down2D(SMDS_UnstructuredGrid *grid, int nbDownCells) :
474 SMDS_Downward(grid, nbDownCells)
477 _upCellTypes.clear();
482 SMDS_Down2D::~SMDS_Down2D()
486 int SMDS_Down2D::getNumberOfUpCells(int cellId)
489 if (_upCellIds[2 * cellId] >= 0)
491 if (_upCellIds[2 * cellId + 1] >= 0)
496 const int* SMDS_Down2D::getUpCells(int cellId)
498 //ASSERT((cellId >=0) && (cellId < _maxId));
499 return &_upCellIds[2 * cellId];
502 const unsigned char* SMDS_Down2D::getUpTypes(int cellId)
504 //ASSERT((cellId >=0) && (cellId < _maxId));
505 return &_upCellTypes[2 * cellId];
508 void SMDS_Down2D::getNodeIds(int cellId, std::set<int>& nodeSet)
510 for (int i = 0; i < _nbDownCells; i++)
512 int downCellId = _cellIds[_nbDownCells * cellId + i];
513 unsigned char cellType = _cellTypes[i];
514 this->_grid->getDownArray(cellType)->getNodeIds(downCellId, nodeSet);
518 /*! Find in vtkUnstructuredGrid the volumes containing a face already stored in vtkUnstructuredGrid.
519 * Search the volumes containing a face, to store the info in SMDS_Down2D for later uses
520 * with SMDS_Down2D::getUpCells and SMDS_Down2D::getUpTypes.
521 * A face belongs to 0, 1 or 2 volumes, identified by their id in vtkUnstructuredGrid.
522 * @param cellId the face cell id in vkUnstructuredGrid
523 * @param ids a couple of vtkId, initialized at -1 (no parent volume)
524 * @return number of volumes (0, 1 or 2)
526 int SMDS_Down2D::computeVolumeIds(int cellId, int* ids)
528 // --- find point id's of the face
531 vtkIdType *pts; // will refer to the point id's of the face
532 _grid->GetCellPoints(cellId, npts, pts);
534 for (int i = 0; i < npts; i++)
535 nodes.push_back(pts[i]);
536 int nvol = this->computeVolumeIdsFromNodesFace(&nodes[0], npts, ids);
540 /*! Find in vtkUnstructuredGrid the volumes containing a face described by it's nodes
541 * Search the volumes containing a face, to store the info in SMDS_Down2D for later uses
542 * with SMDS_Down2D::getUpCells and SMDS_Down2D::getUpTypes.
543 * A face belongs to 0, 1 or 2 volumes, identified by their id in vtkUnstructuredGrid.
545 * @param ids a couple of vtkId, initialized at -1 (no parent volume)
546 * @return number of volumes (0, 1 or 2)
548 int SMDS_Down2D::computeVolumeIds(ElemByNodesType& faceByNodes, int* ids)
550 int nvol = this->computeVolumeIdsFromNodesFace(&faceByNodes.nodeIds[0], faceByNodes.nbNodes, ids);
554 /*! Find in vtkUnstructuredGrid the volumes containing a face described by it's nodes
555 * Search the volumes containing a face, to store the info in SMDS_Down2D for later uses
556 * with SMDS_Down2D::getUpCells and SMDS_Down2D::getUpTypes.
557 * A face belongs to 0, 1 or 2 volumes, identified by their id in vtkUnstructuredGrid.
558 * @param pts array of vtk node id's
559 * @param npts number of nodes
561 * @return number of volumes (0, 1 or 2)
563 int SMDS_Down2D::computeVolumeIdsFromNodesFace(int* pts, int npts, int* ids)
566 // --- find all the cells the points belong to, and how many of the points belong to a given cell
571 for (int i = 0; i < npts; i++)
573 vtkIdType point = pts[i];
574 int numCells = _grid->GetLinks()->GetNcells(point);
575 //MESSAGE("cells pour " << i << " " << numCells);
576 vtkIdType *cells = _grid->GetLinks()->GetCells(point);
577 for (int j = 0; j < numCells; j++)
579 int vtkCellId = cells[j];
581 for (int k = 0; k < cnt; k++)
583 if (cellIds[k] == vtkCellId)
592 cellIds[cnt] = vtkCellId;
594 // TODO ASSERT(cnt<1000);
600 // --- find the volume cells: they contains all the points and are of type volume
603 for (int i = 0; i < cnt; i++)
605 //MESSAGE("cell " << cellIds[i] << " points " << cellCnt[i]);
606 if (cellCnt[i] == npts)
608 int vtkElemId = cellIds[i];
609 int vtkType = _grid->GetCellType(vtkElemId);
610 if (SMDS_Downward::getCellDimension(vtkType) == 3)
612 ids[nvol] = vtkElemId; // store the volume id in given vector
623 void SMDS_Down2D::setTempNodes(int cellId, int vtkId)
626 vtkIdType *pts; // will refer to the point id's of the face
627 _grid->GetCellPoints(vtkId, npts, pts);
628 // MESSAGE(vtkId << " " << npts << " " << _nbNodes);
629 //ASSERT(npts == _nbNodes);
630 for (int i = 0; i < npts; i++)
632 _tempNodes[_nbNodes * cellId + i] = pts[i];
636 void SMDS_Down2D::setTempNodes(int cellId, ElemByNodesType& faceByNodes)
638 for (int i = 0; i < faceByNodes.nbNodes; i++)
639 _tempNodes[_nbNodes * cellId + i] = faceByNodes.nodeIds[i];
642 /*! Find if all the nodes belongs to the face.
644 * @param cellId the face cell Id
645 * @param nodeSet set of node id's to be found in the face list of nodes
648 bool SMDS_Down2D::isInFace(int cellId, int *pts, int npts)
651 int *nodes = &_tempNodes[_nbNodes * cellId];
652 for (int j = 0; j < npts; j++)
655 for (int i = 0; i < _nbNodes; i++)
657 if (nodes[i] == point)
664 return (nbFound == npts);
667 /*! Resize the downward connectivity storage vector if needed.
669 * @param nbElems total number of elements of the same type required
671 void SMDS_Down2D::allocate(int nbElems)
673 if (nbElems >= _vtkCellIds.size())
675 _cellIds.resize(_nbDownCells * (nbElems + SMDS_Mesh::chunkSize), -1);
676 _vtkCellIds.resize(nbElems + SMDS_Mesh::chunkSize, -1);
677 _upCellIds.resize(2 * (nbElems + SMDS_Mesh::chunkSize), -1);
678 _upCellTypes.resize(2 * (nbElems + SMDS_Mesh::chunkSize), -1);
679 _tempNodes.resize(_nbNodes * (nbElems + SMDS_Mesh::chunkSize), -1);
683 void SMDS_Down2D::compactStorage()
685 _cellIds.resize(_nbDownCells * _maxId);
686 _upCellIds.resize(2 * _maxId);
687 _upCellTypes.resize(2 * _maxId);
688 _vtkCellIds.resize(_maxId);
692 void SMDS_Down2D::addUpCell(int cellId, int upCellId, unsigned char aType)
694 //ASSERT((cellId >=0)&& (cellId < _maxId));
695 int *vols = &_upCellIds[2 * cellId];
696 unsigned char *types = &_upCellTypes[2 * cellId];
697 for (int i = 0; i < 2; i++)
701 vols[i] = upCellId; // use non affected volume
705 if ((vols[i] == upCellId) && (types[i] == aType)) // already done
711 int SMDS_Down2D::getNodeSet(int cellId, int* nodeSet)
713 for (int i = 0; i < _nbNodes; i++)
714 nodeSet[i] = _tempNodes[_nbNodes * cellId + i];
718 int SMDS_Down2D::FindEdgeByNodes(int cellId, ElemByNodesType& edgeByNodes)
720 int *edges = &_cellIds[_nbDownCells * cellId];
721 for (int i = 0; i < _nbDownCells; i++)
723 if ((edges[i] >= 0) && (edgeByNodes.vtkType == _cellTypes[i]))
726 int npts = this->_grid->getDownArray(edgeByNodes.vtkType)->getNodeSet(edges[i], nodeSet);
728 for (int j = 0; j < npts; j++)
730 int point = edgeByNodes.nodeIds[j];
732 for (int k = 0; k < npts; k++)
734 if (nodeSet[k] == point)
750 // ---------------------------------------------------------------------------
752 SMDS_Down3D::SMDS_Down3D(SMDS_UnstructuredGrid *grid, int nbDownCells) :
753 SMDS_Downward(grid, nbDownCells)
757 SMDS_Down3D::~SMDS_Down3D()
761 void SMDS_Down3D::allocate(int nbElems)
763 if (nbElems >= _vtkCellIds.size())
765 _cellIds.resize(_nbDownCells * (nbElems + SMDS_Mesh::chunkSize), -1);
766 _vtkCellIds.resize(nbElems + SMDS_Mesh::chunkSize, -1);
770 void SMDS_Down3D::compactStorage()
772 // nothing to do, size was known before
775 int SMDS_Down3D::getNumberOfUpCells(int cellId)
780 const int* SMDS_Down3D::getUpCells(int cellId)
785 const unsigned char* SMDS_Down3D::getUpTypes(int cellId)
790 void SMDS_Down3D::getNodeIds(int cellId, std::set<int>& nodeSet)
792 int vtkId = this->_vtkCellIds[cellId];
794 vtkIdType *nodes; // will refer to the point id's of the volume
795 _grid->GetCellPoints(vtkId, npts, nodes);
796 for (int i = 0; i < npts; i++)
797 nodeSet.insert(nodes[i]);
800 int SMDS_Down3D::FindFaceByNodes(int cellId, ElemByNodesType& faceByNodes)
802 int *faces = &_cellIds[_nbDownCells * cellId];
806 for (int i = 0; i < _nbDownCells; i++)
808 if ((faces[i] >= 0) && (faceByNodes.vtkType == _cellTypes[i]))
812 for (int j = 0; j < faceByNodes.nbNodes; j++)
813 faceNodeSet[j] = faceByNodes.nodeIds[j];
814 npoints = faceByNodes.nbNodes;
818 int npts = this->_grid->getDownArray(faceByNodes.vtkType)->getNodeSet(faces[i], nodeSet);
820 continue; // skip this face
822 for (int j = 0; j < npts; j++)
824 int point = faceByNodes.nodeIds[j];
826 for (int k = 0; k < npts; k++)
828 if (nodeSet[k] == point)
831 break; // point j is in the 2 faces, skip remaining k values
835 break; // point j is not in the 2 faces, skip the remaining tests
844 // ---------------------------------------------------------------------------
846 SMDS_DownEdge::SMDS_DownEdge(SMDS_UnstructuredGrid *grid) :
849 _cellTypes.push_back(VTK_VERTEX);
850 _cellTypes.push_back(VTK_VERTEX);
853 SMDS_DownEdge::~SMDS_DownEdge()
857 // ---------------------------------------------------------------------------
859 SMDS_DownQuadEdge::SMDS_DownQuadEdge(SMDS_UnstructuredGrid *grid) :
862 _cellTypes.push_back(VTK_VERTEX);
863 _cellTypes.push_back(VTK_VERTEX);
864 _cellTypes.push_back(VTK_VERTEX);
867 SMDS_DownQuadEdge::~SMDS_DownQuadEdge()
871 // ---------------------------------------------------------------------------
873 SMDS_DownTriangle::SMDS_DownTriangle(SMDS_UnstructuredGrid *grid) :
876 _cellTypes.push_back(VTK_LINE);
877 _cellTypes.push_back(VTK_LINE);
878 _cellTypes.push_back(VTK_LINE);
882 SMDS_DownTriangle::~SMDS_DownTriangle()
886 void SMDS_DownTriangle::computeEdgesWithNodes(int cellId, ListElemByNodesType& edgesWithNodes)
888 int *nodes = &_tempNodes[_nbNodes * cellId];
889 edgesWithNodes.nbElems = 3;
891 edgesWithNodes.elems[0].nodeIds[0] = nodes[0];
892 edgesWithNodes.elems[0].nodeIds[1] = nodes[1];
893 edgesWithNodes.elems[0].nbNodes = 2;
894 edgesWithNodes.elems[0].vtkType = VTK_LINE;
896 edgesWithNodes.elems[1].nodeIds[0] = nodes[1];
897 edgesWithNodes.elems[1].nodeIds[1] = nodes[2];
898 edgesWithNodes.elems[1].nbNodes = 2;
899 edgesWithNodes.elems[1].vtkType = VTK_LINE;
901 edgesWithNodes.elems[2].nodeIds[0] = nodes[2];
902 edgesWithNodes.elems[2].nodeIds[1] = nodes[0];
903 edgesWithNodes.elems[2].nbNodes = 2;
904 edgesWithNodes.elems[2].vtkType = VTK_LINE;
907 void SMDS_DownTriangle::addDownCell(int cellId, int lowCellId, unsigned char aType)
909 //ASSERT((cellId >=0)&& (cellId < _maxId));
910 //ASSERT(aType == VTK_LINE);
911 int *faces = &_cellIds[_nbDownCells * cellId];
912 for (int i = 0; i < _nbDownCells; i++)
916 faces[i] = lowCellId;
919 if (faces[i] == lowCellId)
925 // ---------------------------------------------------------------------------
927 SMDS_DownQuadTriangle::SMDS_DownQuadTriangle(SMDS_UnstructuredGrid *grid) :
930 _cellTypes.push_back(VTK_QUADRATIC_EDGE);
931 _cellTypes.push_back(VTK_QUADRATIC_EDGE);
932 _cellTypes.push_back(VTK_QUADRATIC_EDGE);
936 SMDS_DownQuadTriangle::~SMDS_DownQuadTriangle()
940 void SMDS_DownQuadTriangle::computeEdgesWithNodes(int cellId, ListElemByNodesType& edgesWithNodes)
942 int *nodes = &_tempNodes[_nbNodes * cellId];
943 edgesWithNodes.nbElems = 3;
945 edgesWithNodes.elems[0].nodeIds[0] = nodes[0];
946 edgesWithNodes.elems[0].nodeIds[1] = nodes[1];
947 edgesWithNodes.elems[0].nodeIds[2] = nodes[3];
948 edgesWithNodes.elems[0].nbNodes = 3;
949 edgesWithNodes.elems[0].vtkType = VTK_QUADRATIC_EDGE;
951 edgesWithNodes.elems[1].nodeIds[0] = nodes[1];
952 edgesWithNodes.elems[1].nodeIds[1] = nodes[2];
953 edgesWithNodes.elems[1].nodeIds[2] = nodes[4];
954 edgesWithNodes.elems[1].nbNodes = 3;
955 edgesWithNodes.elems[1].vtkType = VTK_QUADRATIC_EDGE;
957 edgesWithNodes.elems[2].nodeIds[0] = nodes[2];
958 edgesWithNodes.elems[2].nodeIds[1] = nodes[0];
959 edgesWithNodes.elems[2].nodeIds[2] = nodes[5];
960 edgesWithNodes.elems[2].nbNodes = 3;
961 edgesWithNodes.elems[2].vtkType = VTK_QUADRATIC_EDGE;
964 void SMDS_DownQuadTriangle::addDownCell(int cellId, int lowCellId, unsigned char aType)
966 //ASSERT((cellId >=0)&& (cellId < _maxId));
967 //ASSERT(aType == VTK_QUADRATIC_EDGE);
968 int *edges = &_cellIds[_nbDownCells * cellId];
969 for (int i = 0; i < _nbDownCells; i++)
973 edges[i] = lowCellId;
976 if (edges[i] == lowCellId)
982 // ---------------------------------------------------------------------------
984 SMDS_DownQuadrangle::SMDS_DownQuadrangle(SMDS_UnstructuredGrid *grid) :
987 _cellTypes.push_back(VTK_LINE);
988 _cellTypes.push_back(VTK_LINE);
989 _cellTypes.push_back(VTK_LINE);
990 _cellTypes.push_back(VTK_LINE);
994 SMDS_DownQuadrangle::~SMDS_DownQuadrangle()
998 void SMDS_DownQuadrangle::computeEdgesWithNodes(int cellId, ListElemByNodesType& edgesWithNodes)
1000 int *nodes = &_tempNodes[_nbNodes * cellId];
1001 edgesWithNodes.nbElems = 4;
1003 edgesWithNodes.elems[0].nodeIds[0] = nodes[0];
1004 edgesWithNodes.elems[0].nodeIds[1] = nodes[1];
1005 edgesWithNodes.elems[0].nbNodes = 2;
1006 edgesWithNodes.elems[0].vtkType = VTK_LINE;
1008 edgesWithNodes.elems[1].nodeIds[0] = nodes[1];
1009 edgesWithNodes.elems[1].nodeIds[1] = nodes[2];
1010 edgesWithNodes.elems[1].nbNodes = 2;
1011 edgesWithNodes.elems[1].vtkType = VTK_LINE;
1013 edgesWithNodes.elems[2].nodeIds[0] = nodes[2];
1014 edgesWithNodes.elems[2].nodeIds[1] = nodes[3];
1015 edgesWithNodes.elems[2].nbNodes = 2;
1016 edgesWithNodes.elems[2].vtkType = VTK_LINE;
1018 edgesWithNodes.elems[3].nodeIds[0] = nodes[3];
1019 edgesWithNodes.elems[3].nodeIds[1] = nodes[0];
1020 edgesWithNodes.elems[3].nbNodes = 2;
1021 edgesWithNodes.elems[3].vtkType = VTK_LINE;
1024 void SMDS_DownQuadrangle::addDownCell(int cellId, int lowCellId, unsigned char aType)
1026 //ASSERT((cellId >=0)&& (cellId < _maxId));
1027 //ASSERT(aType == VTK_LINE);
1028 int *faces = &_cellIds[_nbDownCells * cellId];
1029 for (int i = 0; i < _nbDownCells; i++)
1033 faces[i] = lowCellId;
1036 if (faces[i] == lowCellId)
1042 // ---------------------------------------------------------------------------
1044 SMDS_DownQuadQuadrangle::SMDS_DownQuadQuadrangle(SMDS_UnstructuredGrid *grid) :
1045 SMDS_Down2D(grid, 4)
1047 _cellTypes.push_back(VTK_QUADRATIC_EDGE);
1048 _cellTypes.push_back(VTK_QUADRATIC_EDGE);
1049 _cellTypes.push_back(VTK_QUADRATIC_EDGE);
1050 _cellTypes.push_back(VTK_QUADRATIC_EDGE);
1054 SMDS_DownQuadQuadrangle::~SMDS_DownQuadQuadrangle()
1058 void SMDS_DownQuadQuadrangle::computeEdgesWithNodes(int cellId, ListElemByNodesType& edgesWithNodes)
1060 int *nodes = &_tempNodes[_nbNodes * cellId];
1061 edgesWithNodes.nbElems = 4;
1063 edgesWithNodes.elems[0].nodeIds[0] = nodes[0];
1064 edgesWithNodes.elems[0].nodeIds[1] = nodes[1];
1065 edgesWithNodes.elems[0].nodeIds[2] = nodes[4];
1066 edgesWithNodes.elems[0].nbNodes = 3;
1067 edgesWithNodes.elems[0].vtkType = VTK_QUADRATIC_EDGE;
1069 edgesWithNodes.elems[1].nodeIds[0] = nodes[1];
1070 edgesWithNodes.elems[1].nodeIds[1] = nodes[2];
1071 edgesWithNodes.elems[1].nodeIds[2] = nodes[5];
1072 edgesWithNodes.elems[1].nbNodes = 3;
1073 edgesWithNodes.elems[1].vtkType = VTK_QUADRATIC_EDGE;
1075 edgesWithNodes.elems[2].nodeIds[0] = nodes[2];
1076 edgesWithNodes.elems[2].nodeIds[1] = nodes[3];
1077 edgesWithNodes.elems[2].nodeIds[2] = nodes[6];
1078 edgesWithNodes.elems[2].nbNodes = 3;
1079 edgesWithNodes.elems[2].vtkType = VTK_QUADRATIC_EDGE;
1081 edgesWithNodes.elems[3].nodeIds[0] = nodes[3];
1082 edgesWithNodes.elems[3].nodeIds[1] = nodes[0];
1083 edgesWithNodes.elems[3].nodeIds[2] = nodes[7];
1084 edgesWithNodes.elems[3].nbNodes = 3;
1085 edgesWithNodes.elems[3].vtkType = VTK_QUADRATIC_EDGE;
1088 void SMDS_DownQuadQuadrangle::addDownCell(int cellId, int lowCellId, unsigned char aType)
1090 //ASSERT((cellId >=0)&& (cellId < _maxId));
1091 //ASSERT(aType == VTK_QUADRATIC_EDGE);
1092 int *faces = &_cellIds[_nbDownCells * cellId];
1093 for (int i = 0; i < _nbDownCells; i++)
1097 faces[i] = lowCellId;
1100 if (faces[i] == lowCellId)
1106 // ---------------------------------------------------------------------------
1108 SMDS_DownTetra::SMDS_DownTetra(SMDS_UnstructuredGrid *grid) :
1109 SMDS_Down3D(grid, 4)
1111 _cellTypes.push_back(VTK_TRIANGLE);
1112 _cellTypes.push_back(VTK_TRIANGLE);
1113 _cellTypes.push_back(VTK_TRIANGLE);
1114 _cellTypes.push_back(VTK_TRIANGLE);
1117 SMDS_DownTetra::~SMDS_DownTetra()
1121 void SMDS_DownTetra::getOrderedNodesOfFace(int cellId, std::vector<vtkIdType>& orderedNodes)
1125 for (int i = 0; i < orderedNodes.size(); i++)
1126 setNodes.insert(orderedNodes[i]);
1127 //MESSAGE("cellId = " << cellId);
1130 vtkIdType *nodes; // will refer to the point id's of the volume
1131 _grid->GetCellPoints(this->_vtkCellIds[cellId], npts, nodes);
1134 int ids[12] = { 0, 1, 2, 0, 3, 1, 2, 3, 0, 1, 3, 2 };
1135 //int ids[12] = { 2, 1, 0, 1, 3, 0, 0, 3, 2, 2, 3, 1 };
1136 for (int k = 0; k < 4; k++)
1139 for (int i = 0; i < 3; i++)
1140 tofind.insert(nodes[ids[3 * k + i]]);
1141 if (setNodes == tofind)
1143 for (int i = 0; i < 3; i++)
1144 orderedNodes[i] = nodes[ids[3 * k + i]];
1148 MESSAGE("=== Problem volume " << _vtkCellIds[cellId] << " " << _grid->_mesh->fromVtkToSmds(_vtkCellIds[cellId]));
1149 MESSAGE(orderedNodes[0] << " " << orderedNodes[1] << " " << orderedNodes[2]);
1150 MESSAGE(nodes[0] << " " << nodes[1] << " " << nodes[2] << " " << nodes[3]);
1153 void SMDS_DownTetra::addDownCell(int cellId, int lowCellId, unsigned char aType)
1155 //ASSERT((cellId >=0)&& (cellId < _maxId));
1156 //ASSERT(aType == VTK_TRIANGLE);
1157 int *faces = &_cellIds[_nbDownCells * cellId];
1158 for (int i = 0; i < _nbDownCells; i++)
1162 faces[i] = lowCellId;
1165 if (faces[i] == lowCellId)
1171 /*! Create a list of faces described by a vtk Type and an ordered set of Node Id's
1172 * The linear tetrahedron is defined by four points.
1173 * @see vtkTetra.h in Filtering.
1174 * @param cellId volumeId in vtkUnstructuredGrid
1175 * @param facesWithNodes vector of face descriptors to be filled
1177 void SMDS_DownTetra::computeFacesWithNodes(int cellId, ListElemByNodesType& facesWithNodes)
1179 // --- find point id's of the volume
1182 vtkIdType *nodes; // will refer to the point id's of the volume
1183 _grid->GetCellPoints(cellId, npts, nodes);
1185 // --- create all the ordered list of node id's for each face
1187 facesWithNodes.nbElems = 4;
1189 facesWithNodes.elems[0].nodeIds[0] = nodes[0];
1190 facesWithNodes.elems[0].nodeIds[1] = nodes[1];
1191 facesWithNodes.elems[0].nodeIds[2] = nodes[2];
1192 facesWithNodes.elems[0].nbNodes = 3;
1193 facesWithNodes.elems[0].vtkType = VTK_TRIANGLE;
1195 facesWithNodes.elems[1].nodeIds[0] = nodes[0];
1196 facesWithNodes.elems[1].nodeIds[1] = nodes[1];
1197 facesWithNodes.elems[1].nodeIds[2] = nodes[3];
1198 facesWithNodes.elems[1].nbNodes = 3;
1199 facesWithNodes.elems[1].vtkType = VTK_TRIANGLE;
1201 facesWithNodes.elems[2].nodeIds[0] = nodes[0];
1202 facesWithNodes.elems[2].nodeIds[1] = nodes[2];
1203 facesWithNodes.elems[2].nodeIds[2] = nodes[3];
1204 facesWithNodes.elems[2].nbNodes = 3;
1205 facesWithNodes.elems[2].vtkType = VTK_TRIANGLE;
1207 facesWithNodes.elems[3].nodeIds[0] = nodes[1];
1208 facesWithNodes.elems[3].nodeIds[1] = nodes[2];
1209 facesWithNodes.elems[3].nodeIds[2] = nodes[3];
1210 facesWithNodes.elems[3].nbNodes = 3;
1211 facesWithNodes.elems[3].vtkType = VTK_TRIANGLE;
1214 // ---------------------------------------------------------------------------
1216 SMDS_DownQuadTetra::SMDS_DownQuadTetra(SMDS_UnstructuredGrid *grid) :
1217 SMDS_Down3D(grid, 4)
1219 _cellTypes.push_back(VTK_QUADRATIC_TRIANGLE);
1220 _cellTypes.push_back(VTK_QUADRATIC_TRIANGLE);
1221 _cellTypes.push_back(VTK_QUADRATIC_TRIANGLE);
1222 _cellTypes.push_back(VTK_QUADRATIC_TRIANGLE);
1225 SMDS_DownQuadTetra::~SMDS_DownQuadTetra()
1229 void SMDS_DownQuadTetra::getOrderedNodesOfFace(int cellId, std::vector<vtkIdType>& orderedNodes)
1233 for (int i = 0; i < orderedNodes.size(); i++)
1234 setNodes.insert(orderedNodes[i]);
1235 //MESSAGE("cellId = " << cellId);
1238 vtkIdType *nodes; // will refer to the point id's of the volume
1239 _grid->GetCellPoints(this->_vtkCellIds[cellId], npts, nodes);
1242 int ids[24] = { 0, 1, 2, 4, 5, 6, 0, 3, 1, 7, 8, 4, 2, 3, 0, 9, 7, 6, 1, 3, 2, 8, 9, 5 };
1243 //int ids[24] = { 2, 1, 0, 5, 4, 6, 1, 3, 0, 8, 7, 4, 0, 3, 2, 7, 9, 6, 2, 3, 1, 9, 8, 5 };
1244 for (int k = 0; k < 4; k++)
1247 for (int i = 0; i < 6; i++)
1248 tofind.insert(nodes[ids[6 * k + i]]);
1249 if (setNodes == tofind)
1251 for (int i = 0; i < 6; i++)
1252 orderedNodes[i] = nodes[ids[6 * k + i]];
1256 MESSAGE("=== Problem volume " << _vtkCellIds[cellId] << " " << _grid->_mesh->fromVtkToSmds(_vtkCellIds[cellId]));
1257 MESSAGE(orderedNodes[0] << " " << orderedNodes[1] << " " << orderedNodes[2]);
1258 MESSAGE(nodes[0] << " " << nodes[1] << " " << nodes[2] << " " << nodes[3]);
1261 void SMDS_DownQuadTetra::addDownCell(int cellId, int lowCellId, unsigned char aType)
1263 //ASSERT((cellId >=0)&& (cellId < _maxId));
1264 //ASSERT(aType == VTK_QUADRATIC_TRIANGLE);
1265 int *faces = &_cellIds[_nbDownCells * cellId];
1266 for (int i = 0; i < _nbDownCells; i++)
1270 faces[i] = lowCellId;
1273 if (faces[i] == lowCellId)
1279 /*! Create a list of faces described by a vtk Type and an ordered set of Node Id's
1280 * The ordering of the ten points defining the quadratic tetrahedron cell is point id's (0-3,4-9)
1281 * where id's 0-3 are the four tetrahedron vertices;
1282 * and point id's 4-9 are the mid-edge nodes between (0,1), (1,2), (2,0), (0,3), (1,3), and (2,3).
1283 * @see vtkQuadraticTetra.h in Filtering.
1284 * @param cellId volumeId in vtkUnstructuredGrid
1285 * @param facesWithNodes vector of face descriptors to be filled
1287 void SMDS_DownQuadTetra::computeFacesWithNodes(int cellId, ListElemByNodesType& facesWithNodes)
1289 // --- find point id's of the volume
1292 vtkIdType *nodes; // will refer to the point id's of the volume
1293 _grid->GetCellPoints(cellId, npts, nodes);
1295 // --- create all the ordered list of node id's for each face
1297 facesWithNodes.nbElems = 4;
1299 facesWithNodes.elems[0].nodeIds[0] = nodes[0];
1300 facesWithNodes.elems[0].nodeIds[1] = nodes[1];
1301 facesWithNodes.elems[0].nodeIds[2] = nodes[2];
1302 facesWithNodes.elems[0].nodeIds[3] = nodes[4];
1303 facesWithNodes.elems[0].nodeIds[4] = nodes[5];
1304 facesWithNodes.elems[0].nodeIds[5] = nodes[6];
1305 facesWithNodes.elems[0].nbNodes = 6;
1306 facesWithNodes.elems[0].vtkType = VTK_QUADRATIC_TRIANGLE;
1308 facesWithNodes.elems[1].nodeIds[0] = nodes[0];
1309 facesWithNodes.elems[1].nodeIds[1] = nodes[1];
1310 facesWithNodes.elems[1].nodeIds[2] = nodes[3];
1311 facesWithNodes.elems[1].nodeIds[3] = nodes[4];
1312 facesWithNodes.elems[1].nodeIds[4] = nodes[8];
1313 facesWithNodes.elems[1].nodeIds[5] = nodes[7];
1314 facesWithNodes.elems[1].nbNodes = 6;
1315 facesWithNodes.elems[1].vtkType = VTK_QUADRATIC_TRIANGLE;
1317 facesWithNodes.elems[2].nodeIds[0] = nodes[0];
1318 facesWithNodes.elems[2].nodeIds[1] = nodes[2];
1319 facesWithNodes.elems[2].nodeIds[2] = nodes[3];
1320 facesWithNodes.elems[2].nodeIds[3] = nodes[6];
1321 facesWithNodes.elems[2].nodeIds[4] = nodes[9];
1322 facesWithNodes.elems[2].nodeIds[5] = nodes[7];
1323 facesWithNodes.elems[2].nbNodes = 6;
1324 facesWithNodes.elems[2].vtkType = VTK_QUADRATIC_TRIANGLE;
1326 facesWithNodes.elems[3].nodeIds[0] = nodes[1];
1327 facesWithNodes.elems[3].nodeIds[1] = nodes[2];
1328 facesWithNodes.elems[3].nodeIds[2] = nodes[3];
1329 facesWithNodes.elems[3].nodeIds[3] = nodes[5];
1330 facesWithNodes.elems[3].nodeIds[4] = nodes[9];
1331 facesWithNodes.elems[3].nodeIds[5] = nodes[8];
1332 facesWithNodes.elems[3].nbNodes = 6;
1333 facesWithNodes.elems[3].vtkType = VTK_QUADRATIC_TRIANGLE;
1336 // ---------------------------------------------------------------------------
1338 SMDS_DownPyramid::SMDS_DownPyramid(SMDS_UnstructuredGrid *grid) :
1339 SMDS_Down3D(grid, 5)
1341 _cellTypes.push_back(VTK_QUAD);
1342 _cellTypes.push_back(VTK_TRIANGLE);
1343 _cellTypes.push_back(VTK_TRIANGLE);
1344 _cellTypes.push_back(VTK_TRIANGLE);
1345 _cellTypes.push_back(VTK_TRIANGLE);
1348 SMDS_DownPyramid::~SMDS_DownPyramid()
1352 void SMDS_DownPyramid::getOrderedNodesOfFace(int cellId, std::vector<vtkIdType>& orderedNodes)
1356 for (int i = 0; i < orderedNodes.size(); i++)
1357 setNodes.insert(orderedNodes[i]);
1358 //MESSAGE("cellId = " << cellId);
1361 vtkIdType *nodes; // will refer to the point id's of the volume
1362 _grid->GetCellPoints(this->_vtkCellIds[cellId], npts, nodes);
1365 int ids[16] = { 0, 1, 2, 3, 0, 3, 4, 3, 2, 4, 2, 1, 4, 1, 0, 4 };
1368 for (int i = 0; i < 4; i++)
1369 tofind.insert(nodes[ids[i]]);
1370 if (setNodes == tofind)
1372 for (int i = 0; i < 4; i++)
1373 orderedNodes[i] = nodes[ids[i]];
1376 for (int k = 0; k < 4; k++)
1379 for (int i = 0; i < 3; i++)
1380 tofind.insert(nodes[ids[4 + 3 * k + i]]);
1381 if (setNodes == tofind)
1383 for (int i = 0; i < 3; i++)
1384 orderedNodes[i] = nodes[ids[4 + 3 * k + i]];
1388 MESSAGE("=== Problem volume " << _vtkCellIds[cellId] << " " << _grid->_mesh->fromVtkToSmds(_vtkCellIds[cellId]));
1389 MESSAGE(orderedNodes[0] << " " << orderedNodes[1] << " " << orderedNodes[2]);
1390 MESSAGE(nodes[0] << " " << nodes[1] << " " << nodes[2] << " " << nodes[3]);
1393 void SMDS_DownPyramid::addDownCell(int cellId, int lowCellId, unsigned char aType)
1395 //ASSERT((cellId >=0) && (cellId < _maxId));
1396 int *faces = &_cellIds[_nbDownCells * cellId];
1397 if (aType == VTK_QUAD)
1401 faces[0] = lowCellId;
1404 if (faces[0] == lowCellId)
1409 //ASSERT(aType == VTK_TRIANGLE);
1410 for (int i = 1; i < _nbDownCells; i++)
1414 faces[i] = lowCellId;
1417 if (faces[i] == lowCellId)
1424 /*! Create a list of faces described by a vtk Type and an ordered set of Node Id's
1425 * The pyramid is defined by the five points (0-4) where (0,1,2,3) is the base of the pyramid which,
1426 * using the right hand rule, forms a quadrilateral whose normal points in the direction of the
1427 * pyramid apex at vertex #4.
1428 * @see vtkPyramid.h in Filtering.
1429 * @param cellId volumeId in vtkUnstructuredGrid
1430 * @param facesWithNodes vector of face descriptors to be filled
1432 void SMDS_DownPyramid::computeFacesWithNodes(int cellId, ListElemByNodesType& facesWithNodes)
1434 // --- find point id's of the volume
1437 vtkIdType *nodes; // will refer to the point id's of the volume
1438 _grid->GetCellPoints(cellId, npts, nodes);
1440 // --- create all the ordered list of node id's for each face
1442 facesWithNodes.nbElems = 5;
1444 facesWithNodes.elems[0].nodeIds[0] = nodes[0];
1445 facesWithNodes.elems[0].nodeIds[1] = nodes[1];
1446 facesWithNodes.elems[0].nodeIds[2] = nodes[2];
1447 facesWithNodes.elems[0].nodeIds[3] = nodes[3];
1448 facesWithNodes.elems[0].nbNodes = 4;
1449 facesWithNodes.elems[0].vtkType = VTK_QUAD;
1451 facesWithNodes.elems[1].nodeIds[0] = nodes[0];
1452 facesWithNodes.elems[1].nodeIds[1] = nodes[1];
1453 facesWithNodes.elems[1].nodeIds[2] = nodes[4];
1454 facesWithNodes.elems[1].nbNodes = 3;
1455 facesWithNodes.elems[1].vtkType = VTK_TRIANGLE;
1457 facesWithNodes.elems[2].nodeIds[0] = nodes[1];
1458 facesWithNodes.elems[2].nodeIds[1] = nodes[2];
1459 facesWithNodes.elems[2].nodeIds[2] = nodes[4];
1460 facesWithNodes.elems[2].nbNodes = 3;
1461 facesWithNodes.elems[2].vtkType = VTK_TRIANGLE;
1463 facesWithNodes.elems[3].nodeIds[0] = nodes[2];
1464 facesWithNodes.elems[3].nodeIds[1] = nodes[3];
1465 facesWithNodes.elems[3].nodeIds[2] = nodes[4];
1466 facesWithNodes.elems[3].nbNodes = 3;
1467 facesWithNodes.elems[3].vtkType = VTK_TRIANGLE;
1469 facesWithNodes.elems[4].nodeIds[0] = nodes[3];
1470 facesWithNodes.elems[4].nodeIds[1] = nodes[0];
1471 facesWithNodes.elems[4].nodeIds[2] = nodes[4];
1472 facesWithNodes.elems[4].nbNodes = 3;
1473 facesWithNodes.elems[4].vtkType = VTK_TRIANGLE;
1476 // ---------------------------------------------------------------------------
1478 SMDS_DownQuadPyramid::SMDS_DownQuadPyramid(SMDS_UnstructuredGrid *grid) :
1479 SMDS_Down3D(grid, 5)
1481 _cellTypes.push_back(VTK_QUADRATIC_QUAD);
1482 _cellTypes.push_back(VTK_QUADRATIC_TRIANGLE);
1483 _cellTypes.push_back(VTK_QUADRATIC_TRIANGLE);
1484 _cellTypes.push_back(VTK_QUADRATIC_TRIANGLE);
1485 _cellTypes.push_back(VTK_QUADRATIC_TRIANGLE);
1488 SMDS_DownQuadPyramid::~SMDS_DownQuadPyramid()
1492 void SMDS_DownQuadPyramid::getOrderedNodesOfFace(int cellId, std::vector<vtkIdType>& orderedNodes)
1497 void SMDS_DownQuadPyramid::addDownCell(int cellId, int lowCellId, unsigned char aType)
1499 //ASSERT((cellId >=0) && (cellId < _maxId));
1500 int *faces = &_cellIds[_nbDownCells * cellId];
1501 if (aType == VTK_QUADRATIC_QUAD)
1505 faces[0] = lowCellId;
1508 if (faces[0] == lowCellId)
1513 //ASSERT(aType == VTK_QUADRATIC_TRIANGLE);
1514 for (int i = 1; i < _nbDownCells; i++)
1518 faces[i] = lowCellId;
1521 if (faces[i] == lowCellId)
1528 /*! Create a list of faces described by a vtk Type and an ordered set of Node Id's
1529 * The ordering of the thirteen points defining the quadratic pyramid cell is point id's (0-4,5-12)
1530 * where point id's 0-4 are the five corner vertices of the pyramid; followed
1531 * by eight mid-edge nodes (5-12). Note that these mid-edge nodes lie on the edges defined by
1532 * 5(0,1), 6(1,2), 7(2,3), 8(3,0), 9(0,4), 10(1,4), 11(2,4), 12(3,4).
1533 * @see vtkQuadraticPyramid.h in Filtering.
1534 * @param cellId volumeId in vtkUnstructuredGrid
1535 * @param facesWithNodes vector of face descriptors to be filled
1537 void SMDS_DownQuadPyramid::computeFacesWithNodes(int cellId, ListElemByNodesType& facesWithNodes)
1539 // --- find point id's of the volume
1542 vtkIdType *nodes; // will refer to the point id's of the volume
1543 _grid->GetCellPoints(cellId, npts, nodes);
1545 // --- create all the ordered list of node id's for each face
1547 facesWithNodes.nbElems = 5;
1549 facesWithNodes.elems[0].nodeIds[0] = nodes[0];
1550 facesWithNodes.elems[0].nodeIds[1] = nodes[1];
1551 facesWithNodes.elems[0].nodeIds[2] = nodes[2];
1552 facesWithNodes.elems[0].nodeIds[3] = nodes[3];
1553 facesWithNodes.elems[0].nodeIds[4] = nodes[5];
1554 facesWithNodes.elems[0].nodeIds[5] = nodes[6];
1555 facesWithNodes.elems[0].nodeIds[6] = nodes[7];
1556 facesWithNodes.elems[0].nodeIds[7] = nodes[8];
1557 facesWithNodes.elems[0].nbNodes = 8;
1558 facesWithNodes.elems[0].vtkType = VTK_QUADRATIC_QUAD;
1560 facesWithNodes.elems[1].nodeIds[0] = nodes[0];
1561 facesWithNodes.elems[1].nodeIds[1] = nodes[1];
1562 facesWithNodes.elems[1].nodeIds[2] = nodes[4];
1563 facesWithNodes.elems[1].nodeIds[3] = nodes[5];
1564 facesWithNodes.elems[1].nodeIds[4] = nodes[9];
1565 facesWithNodes.elems[1].nodeIds[5] = nodes[10];
1566 facesWithNodes.elems[1].nbNodes = 6;
1567 facesWithNodes.elems[1].vtkType = VTK_QUADRATIC_TRIANGLE;
1569 facesWithNodes.elems[2].nodeIds[0] = nodes[1];
1570 facesWithNodes.elems[2].nodeIds[1] = nodes[2];
1571 facesWithNodes.elems[2].nodeIds[2] = nodes[4];
1572 facesWithNodes.elems[2].nodeIds[3] = nodes[6];
1573 facesWithNodes.elems[2].nodeIds[4] = nodes[10];
1574 facesWithNodes.elems[2].nodeIds[5] = nodes[11];
1575 facesWithNodes.elems[2].nbNodes = 6;
1576 facesWithNodes.elems[2].vtkType = VTK_QUADRATIC_TRIANGLE;
1578 facesWithNodes.elems[3].nodeIds[0] = nodes[2];
1579 facesWithNodes.elems[3].nodeIds[1] = nodes[3];
1580 facesWithNodes.elems[3].nodeIds[2] = nodes[4];
1581 facesWithNodes.elems[3].nodeIds[3] = nodes[7];
1582 facesWithNodes.elems[3].nodeIds[4] = nodes[11];
1583 facesWithNodes.elems[3].nodeIds[5] = nodes[12];
1584 facesWithNodes.elems[3].nbNodes = 6;
1585 facesWithNodes.elems[3].vtkType = VTK_QUADRATIC_TRIANGLE;
1587 facesWithNodes.elems[4].nodeIds[0] = nodes[3];
1588 facesWithNodes.elems[4].nodeIds[1] = nodes[0];
1589 facesWithNodes.elems[4].nodeIds[2] = nodes[4];
1590 facesWithNodes.elems[4].nodeIds[3] = nodes[8];
1591 facesWithNodes.elems[4].nodeIds[4] = nodes[9];
1592 facesWithNodes.elems[4].nodeIds[5] = nodes[12];
1593 facesWithNodes.elems[4].nbNodes = 6;
1594 facesWithNodes.elems[4].vtkType = VTK_QUADRATIC_TRIANGLE;
1597 // ---------------------------------------------------------------------------
1599 SMDS_DownPenta::SMDS_DownPenta(SMDS_UnstructuredGrid *grid) :
1600 SMDS_Down3D(grid, 5)
1602 _cellTypes.push_back(VTK_QUAD);
1603 _cellTypes.push_back(VTK_QUAD);
1604 _cellTypes.push_back(VTK_QUAD);
1605 _cellTypes.push_back(VTK_TRIANGLE);
1606 _cellTypes.push_back(VTK_TRIANGLE);
1609 SMDS_DownPenta::~SMDS_DownPenta()
1613 void SMDS_DownPenta::getOrderedNodesOfFace(int cellId, std::vector<vtkIdType>& orderedNodes)
1617 for (int i = 0; i < orderedNodes.size(); i++)
1618 setNodes.insert(orderedNodes[i]);
1619 //MESSAGE("cellId = " << cellId);
1622 vtkIdType *nodes; // will refer to the point id's of the volume
1623 _grid->GetCellPoints(this->_vtkCellIds[cellId], npts, nodes);
1626 //int ids[18] = { 0, 2, 1, 3, 4, 5, 0, 1, 4, 3, 1, 2, 5, 4, 2, 0, 3, 5 };
1627 int ids[18] = { 0, 1, 2, 3, 5, 4, 0, 3, 4, 1, 1, 4, 5, 2, 2, 5, 3, 0 };
1629 for (int k = 0; k < 2; k++)
1632 for (int i = 0; i < 3; i++)
1633 tofind.insert(nodes[ids[3 * k + i]]);
1634 if (setNodes == tofind)
1636 for (int i = 0; i < 3; i++)
1637 orderedNodes[i] = nodes[ids[3 * k + i]];
1641 for (int k = 0; k < 3; k++)
1644 for (int i = 0; i < 4; i++)
1645 tofind.insert(nodes[ids[6 + 4 * k + i]]);
1646 if (setNodes == tofind)
1648 for (int i = 0; i < 4; i++)
1649 orderedNodes[i] = nodes[ids[6 + 4 * k + i]];
1653 MESSAGE("=== Problem volume " << _vtkCellIds[cellId] << " " << _grid->_mesh->fromVtkToSmds(_vtkCellIds[cellId]));
1654 MESSAGE(orderedNodes[0] << " " << orderedNodes[1] << " " << orderedNodes[2]);
1655 MESSAGE(nodes[0] << " " << nodes[1] << " " << nodes[2] << " " << nodes[3]);
1658 void SMDS_DownPenta::addDownCell(int cellId, int lowCellId, unsigned char aType)
1660 //ASSERT((cellId >=0) && (cellId < _maxId));
1661 int *faces = &_cellIds[_nbDownCells * cellId];
1662 if (aType == VTK_QUAD)
1663 for (int i = 0; i < 3; i++)
1667 faces[i] = lowCellId;
1670 if (faces[i] == lowCellId)
1675 //ASSERT(aType == VTK_TRIANGLE);
1676 for (int i = 3; i < _nbDownCells; i++)
1680 faces[i] = lowCellId;
1683 if (faces[i] == lowCellId)
1690 /*! Create a list of faces described by a vtk Type and an ordered set of Node Id's.
1691 * A wedge or pentahedron consists of two triangular and three quadrilateral faces
1692 * and is defined by the six points (0-5) where (0,1,2) is the base of the wedge which,
1693 * using the right hand rule, forms a triangle whose normal points outward
1694 * (away from the triangular face (3,4,5)).
1695 * @see vtkWedge.h in Filtering
1696 * @param cellId volumeId in vtkUnstructuredGrid
1697 * @param facesWithNodes vector of face descriptors to be filled
1699 void SMDS_DownPenta::computeFacesWithNodes(int cellId, ListElemByNodesType& facesWithNodes)
1701 // --- find point id's of the volume
1704 vtkIdType *nodes; // will refer to the point id's of the volume
1705 _grid->GetCellPoints(cellId, npts, nodes);
1707 // --- create all the ordered list of node id's for each face
1709 facesWithNodes.nbElems = 5;
1711 facesWithNodes.elems[0].nodeIds[0] = nodes[0];
1712 facesWithNodes.elems[0].nodeIds[1] = nodes[2];
1713 facesWithNodes.elems[0].nodeIds[2] = nodes[5];
1714 facesWithNodes.elems[0].nodeIds[3] = nodes[3];
1715 facesWithNodes.elems[0].nbNodes = 4;
1716 facesWithNodes.elems[0].vtkType = VTK_QUAD;
1718 facesWithNodes.elems[1].nodeIds[0] = nodes[1];
1719 facesWithNodes.elems[1].nodeIds[1] = nodes[2];
1720 facesWithNodes.elems[1].nodeIds[2] = nodes[5];
1721 facesWithNodes.elems[1].nodeIds[3] = nodes[4];
1722 facesWithNodes.elems[1].nbNodes = 4;
1723 facesWithNodes.elems[1].vtkType = VTK_QUAD;
1725 facesWithNodes.elems[2].nodeIds[0] = nodes[0];
1726 facesWithNodes.elems[2].nodeIds[1] = nodes[1];
1727 facesWithNodes.elems[2].nodeIds[2] = nodes[4];
1728 facesWithNodes.elems[2].nodeIds[3] = nodes[3];
1729 facesWithNodes.elems[2].nbNodes = 4;
1730 facesWithNodes.elems[2].vtkType = VTK_QUAD;
1732 facesWithNodes.elems[3].nodeIds[0] = nodes[0];
1733 facesWithNodes.elems[3].nodeIds[1] = nodes[1];
1734 facesWithNodes.elems[3].nodeIds[2] = nodes[2];
1735 facesWithNodes.elems[3].nbNodes = 3;
1736 facesWithNodes.elems[3].vtkType = VTK_TRIANGLE;
1738 facesWithNodes.elems[4].nodeIds[0] = nodes[3];
1739 facesWithNodes.elems[4].nodeIds[1] = nodes[4];
1740 facesWithNodes.elems[4].nodeIds[2] = nodes[5];
1741 facesWithNodes.elems[4].nbNodes = 3;
1742 facesWithNodes.elems[4].vtkType = VTK_TRIANGLE;
1745 // ---------------------------------------------------------------------------
1747 SMDS_DownQuadPenta::SMDS_DownQuadPenta(SMDS_UnstructuredGrid *grid) :
1748 SMDS_Down3D(grid, 5)
1750 _cellTypes.push_back(VTK_QUADRATIC_QUAD);
1751 _cellTypes.push_back(VTK_QUADRATIC_QUAD);
1752 _cellTypes.push_back(VTK_QUADRATIC_QUAD);
1753 _cellTypes.push_back(VTK_QUADRATIC_TRIANGLE);
1754 _cellTypes.push_back(VTK_QUADRATIC_TRIANGLE);
1757 SMDS_DownQuadPenta::~SMDS_DownQuadPenta()
1761 void SMDS_DownQuadPenta::getOrderedNodesOfFace(int cellId, std::vector<vtkIdType>& orderedNodes)
1766 void SMDS_DownQuadPenta::addDownCell(int cellId, int lowCellId, unsigned char aType)
1768 //ASSERT((cellId >=0) && (cellId < _maxId));
1769 int *faces = &_cellIds[_nbDownCells * cellId];
1770 if (aType == VTK_QUADRATIC_QUAD)
1771 for (int i = 0; i < 2; i++)
1775 faces[i] = lowCellId;
1778 if (faces[i] == lowCellId)
1783 //ASSERT(aType == VTK_QUADRATIC_TRIANGLE);
1784 for (int i = 2; i < _nbDownCells; i++)
1788 faces[i] = lowCellId;
1791 if (faces[i] == lowCellId)
1798 /*! Create a list of faces described by a vtk Type and an ordered set of Node Id's
1799 * The quadratic wedge (or pentahedron) is defined by fifteen points.
1800 * The ordering of the fifteen points defining the cell is point id's (0-5,6-14)
1801 * where point id's 0-5 are the six corner vertices of the wedge, followed by
1802 * nine mid-edge nodes (6-14). Note that these mid-edge nodes lie on the edges defined by
1803 * (0,1), (1,2), (2,0), (3,4), (4,5), (5,3), (0,3), (1,4), (2,5).
1804 * @see vtkQuadraticWedge.h in Filtering
1805 * @param cellId volumeId in vtkUnstructuredGrid
1806 * @param facesWithNodes vector of face descriptors to be filled
1808 void SMDS_DownQuadPenta::computeFacesWithNodes(int cellId, ListElemByNodesType& facesWithNodes)
1810 // --- find point id's of the volume
1813 vtkIdType *nodes; // will refer to the point id's of the volume
1814 _grid->GetCellPoints(cellId, npts, nodes);
1816 // --- create all the ordered list of node id's for each face
1818 facesWithNodes.nbElems = 5;
1820 facesWithNodes.elems[0].nodeIds[0] = nodes[0];
1821 facesWithNodes.elems[0].nodeIds[1] = nodes[2];
1822 facesWithNodes.elems[0].nodeIds[2] = nodes[5];
1823 facesWithNodes.elems[0].nodeIds[3] = nodes[3];
1824 facesWithNodes.elems[0].nodeIds[4] = nodes[8];
1825 facesWithNodes.elems[0].nodeIds[5] = nodes[14];
1826 facesWithNodes.elems[0].nodeIds[6] = nodes[11];
1827 facesWithNodes.elems[0].nodeIds[7] = nodes[12];
1828 facesWithNodes.elems[0].nbNodes = 8;
1829 facesWithNodes.elems[0].vtkType = VTK_QUADRATIC_QUAD;
1831 facesWithNodes.elems[1].nodeIds[0] = nodes[1];
1832 facesWithNodes.elems[1].nodeIds[1] = nodes[2];
1833 facesWithNodes.elems[1].nodeIds[2] = nodes[5];
1834 facesWithNodes.elems[1].nodeIds[3] = nodes[4];
1835 facesWithNodes.elems[1].nodeIds[4] = nodes[7];
1836 facesWithNodes.elems[1].nodeIds[5] = nodes[14];
1837 facesWithNodes.elems[1].nodeIds[6] = nodes[10];
1838 facesWithNodes.elems[1].nodeIds[7] = nodes[13];
1839 facesWithNodes.elems[1].nbNodes = 8;
1840 facesWithNodes.elems[1].vtkType = VTK_QUADRATIC_QUAD;
1842 facesWithNodes.elems[2].nodeIds[0] = nodes[0];
1843 facesWithNodes.elems[2].nodeIds[1] = nodes[1];
1844 facesWithNodes.elems[2].nodeIds[2] = nodes[4];
1845 facesWithNodes.elems[2].nodeIds[3] = nodes[3];
1846 facesWithNodes.elems[2].nodeIds[4] = nodes[6];
1847 facesWithNodes.elems[2].nodeIds[5] = nodes[13];
1848 facesWithNodes.elems[2].nodeIds[6] = nodes[9];
1849 facesWithNodes.elems[2].nodeIds[7] = nodes[12];
1850 facesWithNodes.elems[2].nbNodes = 8;
1851 facesWithNodes.elems[2].vtkType = VTK_QUADRATIC_QUAD;
1853 facesWithNodes.elems[3].nodeIds[0] = nodes[0];
1854 facesWithNodes.elems[3].nodeIds[1] = nodes[1];
1855 facesWithNodes.elems[3].nodeIds[2] = nodes[2];
1856 facesWithNodes.elems[3].nodeIds[3] = nodes[6];
1857 facesWithNodes.elems[3].nodeIds[4] = nodes[7];
1858 facesWithNodes.elems[3].nodeIds[5] = nodes[8];
1859 facesWithNodes.elems[3].nbNodes = 6;
1860 facesWithNodes.elems[3].vtkType = VTK_QUADRATIC_TRIANGLE;
1862 facesWithNodes.elems[4].nodeIds[0] = nodes[3];
1863 facesWithNodes.elems[4].nodeIds[1] = nodes[4];
1864 facesWithNodes.elems[4].nodeIds[2] = nodes[5];
1865 facesWithNodes.elems[4].nodeIds[3] = nodes[9];
1866 facesWithNodes.elems[4].nodeIds[4] = nodes[10];
1867 facesWithNodes.elems[4].nodeIds[5] = nodes[11];
1868 facesWithNodes.elems[4].nbNodes = 6;
1869 facesWithNodes.elems[4].vtkType = VTK_QUADRATIC_TRIANGLE;
1872 // ---------------------------------------------------------------------------
1874 SMDS_DownHexa::SMDS_DownHexa(SMDS_UnstructuredGrid *grid) :
1875 SMDS_Down3D(grid, 6)
1877 _cellTypes.push_back(VTK_QUAD);
1878 _cellTypes.push_back(VTK_QUAD);
1879 _cellTypes.push_back(VTK_QUAD);
1880 _cellTypes.push_back(VTK_QUAD);
1881 _cellTypes.push_back(VTK_QUAD);
1882 _cellTypes.push_back(VTK_QUAD);
1885 SMDS_DownHexa::~SMDS_DownHexa()
1889 void SMDS_DownHexa::getOrderedNodesOfFace(int cellId, std::vector<vtkIdType>& orderedNodes)
1893 for (int i = 0; i < orderedNodes.size(); i++)
1894 setNodes.insert(orderedNodes[i]);
1895 //MESSAGE("cellId = " << cellId);
1898 vtkIdType *nodes; // will refer to the point id's of the volume
1899 _grid->GetCellPoints(this->_vtkCellIds[cellId], npts, nodes);
1902 //int ids[24] = { 0, 1, 2, 3, 7, 6, 5, 4, 4, 0, 3, 7, 5, 1, 0, 4, 6, 2, 1, 5, 7, 3, 2, 6};
1903 int ids[24] = { 3, 2, 1, 0, 4, 5, 6, 7, 7, 3, 0, 4, 4, 0, 1, 5, 5, 1, 2, 6, 6, 2, 3, 7};
1904 for (int k = 0; k < 6; k++) // loop on the 6 faces
1907 for (int i = 0; i < 4; i++)
1908 tofind.insert(nodes[ids[4 * k + i]]); // node ids of the face i
1909 if (setNodes == tofind)
1911 for (int i = 0; i < 4; i++)
1912 orderedNodes[i] = nodes[ids[4 * k + i]];
1916 MESSAGE("=== Problem volume " << _vtkCellIds[cellId] << " " << _grid->_mesh->fromVtkToSmds(_vtkCellIds[cellId]));
1917 MESSAGE(orderedNodes[0] << " " << orderedNodes[1] << " " << orderedNodes[2] << " " << orderedNodes[3]);
1918 MESSAGE(nodes[0] << " " << nodes[1] << " " << nodes[2] << " " << nodes[3]);
1919 MESSAGE(nodes[4] << " " << nodes[5] << " " << nodes[6] << " " << nodes[7]);
1922 void SMDS_DownHexa::addDownCell(int cellId, int lowCellId, unsigned char aType)
1924 //ASSERT((cellId >=0)&& (cellId < _maxId));
1925 int *faces = &_cellIds[_nbDownCells * cellId];
1926 for (int i = 0; i < _nbDownCells; i++)
1930 faces[i] = lowCellId;
1933 if (faces[i] == lowCellId)
1937 // MESSAGE("-------------------------------------> trop de faces ! " << cellId << " " << lowCellId);
1940 /*! Create a list of faces described by a vtk Type and an ordered set of Node Id's
1941 * The hexahedron is defined by the eight points (0-7), where (0,1,2,3) is the base
1942 * of the hexahedron which, using the right hand rule, forms a quadrilateral whose normal
1943 * points in the direction of the opposite face (4,5,6,7).
1944 * @see vtkHexahedron.h in Filtering
1945 * @param cellId volumeId in vtkUnstructuredGrid
1946 * @param facesWithNodes vector of face descriptors to be filled
1948 void SMDS_DownHexa::computeFacesWithNodes(int cellId, ListElemByNodesType& facesWithNodes)
1950 // --- find point id's of the volume
1953 vtkIdType *nodes; // will refer to the point id's of the volume
1954 _grid->GetCellPoints(cellId, npts, nodes);
1956 // --- create all the ordered list of node id's for each face
1958 facesWithNodes.nbElems = 6;
1960 facesWithNodes.elems[0].nodeIds[0] = nodes[0];
1961 facesWithNodes.elems[0].nodeIds[1] = nodes[1];
1962 facesWithNodes.elems[0].nodeIds[2] = nodes[2];
1963 facesWithNodes.elems[0].nodeIds[3] = nodes[3];
1964 facesWithNodes.elems[0].nbNodes = 4;
1965 facesWithNodes.elems[0].vtkType = VTK_QUAD;
1967 facesWithNodes.elems[1].nodeIds[0] = nodes[4];
1968 facesWithNodes.elems[1].nodeIds[1] = nodes[5];
1969 facesWithNodes.elems[1].nodeIds[2] = nodes[6];
1970 facesWithNodes.elems[1].nodeIds[3] = nodes[7];
1971 facesWithNodes.elems[1].nbNodes = 4;
1972 facesWithNodes.elems[1].vtkType = VTK_QUAD;
1974 facesWithNodes.elems[2].nodeIds[0] = nodes[0];
1975 facesWithNodes.elems[2].nodeIds[1] = nodes[1];
1976 facesWithNodes.elems[2].nodeIds[2] = nodes[5];
1977 facesWithNodes.elems[2].nodeIds[3] = nodes[4];
1978 facesWithNodes.elems[2].nbNodes = 4;
1979 facesWithNodes.elems[2].vtkType = VTK_QUAD;
1981 facesWithNodes.elems[3].nodeIds[0] = nodes[1];
1982 facesWithNodes.elems[3].nodeIds[1] = nodes[2];
1983 facesWithNodes.elems[3].nodeIds[2] = nodes[6];
1984 facesWithNodes.elems[3].nodeIds[3] = nodes[5];
1985 facesWithNodes.elems[3].nbNodes = 4;
1986 facesWithNodes.elems[3].vtkType = VTK_QUAD;
1988 facesWithNodes.elems[4].nodeIds[0] = nodes[2];
1989 facesWithNodes.elems[4].nodeIds[1] = nodes[6];
1990 facesWithNodes.elems[4].nodeIds[2] = nodes[7];
1991 facesWithNodes.elems[4].nodeIds[3] = nodes[3];
1992 facesWithNodes.elems[4].nbNodes = 4;
1993 facesWithNodes.elems[4].vtkType = VTK_QUAD;
1995 facesWithNodes.elems[5].nodeIds[0] = nodes[3];
1996 facesWithNodes.elems[5].nodeIds[1] = nodes[7];
1997 facesWithNodes.elems[5].nodeIds[2] = nodes[4];
1998 facesWithNodes.elems[5].nodeIds[3] = nodes[0];
1999 facesWithNodes.elems[5].nbNodes = 4;
2000 facesWithNodes.elems[5].vtkType = VTK_QUAD;
2003 // ---------------------------------------------------------------------------
2005 SMDS_DownQuadHexa::SMDS_DownQuadHexa(SMDS_UnstructuredGrid *grid) :
2006 SMDS_Down3D(grid, 6)
2008 _cellTypes.push_back(VTK_QUADRATIC_QUAD);
2009 _cellTypes.push_back(VTK_QUADRATIC_QUAD);
2010 _cellTypes.push_back(VTK_QUADRATIC_QUAD);
2011 _cellTypes.push_back(VTK_QUADRATIC_QUAD);
2012 _cellTypes.push_back(VTK_QUADRATIC_QUAD);
2013 _cellTypes.push_back(VTK_QUADRATIC_QUAD);
2016 SMDS_DownQuadHexa::~SMDS_DownQuadHexa()
2020 void SMDS_DownQuadHexa::getOrderedNodesOfFace(int cellId, std::vector<vtkIdType>& orderedNodes)
2024 for (int i = 0; i < orderedNodes.size(); i++)
2025 setNodes.insert(orderedNodes[i]);
2026 //MESSAGE("cellId = " << cellId);
2029 vtkIdType *nodes; // will refer to the point id's of the volume
2030 _grid->GetCellPoints(this->_vtkCellIds[cellId], npts, nodes);
2033 //int ids[24] = { 3, 2, 1, 0, 4, 5, 6, 7, 7, 3, 0, 4, 4, 0, 1, 5, 5, 1, 2, 6, 6, 2, 3, 7};
2034 int ids[48] = { 3, 2, 1, 0,10, 9, 8,11, 4, 5, 6, 7,12,13,14,15, 7, 3, 0, 4,19,11,16,15,
2035 4, 0, 1, 5,16, 8,17,12, 5, 1, 2, 6,17, 9,18,13, 6, 2, 3, 7,18,10,19,14};
2036 for (int k = 0; k < 6; k++)
2039 for (int i = 0; i < 8; i++)
2040 tofind.insert(nodes[ids[8 * k + i]]);
2041 if (setNodes == tofind)
2043 for (int i = 0; i < 8; i++)
2044 orderedNodes[i] = nodes[ids[8 * k + i]];
2048 MESSAGE("=== Problem volume " << _vtkCellIds[cellId] << " " << _grid->_mesh->fromVtkToSmds(_vtkCellIds[cellId]));
2049 MESSAGE(orderedNodes[0] << " " << orderedNodes[1] << " " << orderedNodes[2] << " " << orderedNodes[3]);
2050 MESSAGE(nodes[0] << " " << nodes[1] << " " << nodes[2] << " " << nodes[3]);
2053 void SMDS_DownQuadHexa::addDownCell(int cellId, int lowCellId, unsigned char aType)
2055 //ASSERT((cellId >=0)&& (cellId < _maxId));
2056 int *faces = &_cellIds[_nbDownCells * cellId];
2057 for (int i = 0; i < _nbDownCells; i++)
2061 faces[i] = lowCellId;
2064 if (faces[i] == lowCellId)
2070 /*! Create a list of faces described by a vtk Type and an ordered set of Node Id's
2071 * The ordering of the twenty points defining the quadratic hexahedron cell is point id's (0-7,8-19)
2072 * where point id's 0-7 are the eight corner vertices of the cube, followed by twelve mid-edge nodes (8-19).
2073 * Note that these mid-edge nodes lie on the edges defined by
2074 * (0,1), (1,2), (2,3), (3,0), (4,5), (5,6), (6,7), (7,4), (0,4), (1,5), (2,6), (3,7).
2075 * @see vtkQuadraticHexahedron.h in Filtering
2076 * @param cellId volumeId in vtkUnstructuredGrid
2077 * @param facesWithNodes vector of face descriptors to be filled
2079 void SMDS_DownQuadHexa::computeFacesWithNodes(int cellId, ListElemByNodesType& facesWithNodes)
2081 // --- find point id's of the volume
2084 vtkIdType *nodes; // will refer to the point id's of the volume
2085 _grid->GetCellPoints(cellId, npts, nodes);
2087 // --- create all the ordered list of node id's for each face
2089 facesWithNodes.nbElems = 6;
2091 facesWithNodes.elems[0].nodeIds[0] = nodes[0];
2092 facesWithNodes.elems[0].nodeIds[1] = nodes[1];
2093 facesWithNodes.elems[0].nodeIds[2] = nodes[2];
2094 facesWithNodes.elems[0].nodeIds[3] = nodes[3];
2095 facesWithNodes.elems[0].nodeIds[4] = nodes[8];
2096 facesWithNodes.elems[0].nodeIds[5] = nodes[9];
2097 facesWithNodes.elems[0].nodeIds[6] = nodes[10];
2098 facesWithNodes.elems[0].nodeIds[7] = nodes[11];
2099 facesWithNodes.elems[0].nbNodes = 8;
2100 facesWithNodes.elems[0].vtkType = VTK_QUADRATIC_QUAD;
2102 facesWithNodes.elems[1].nodeIds[0] = nodes[4];
2103 facesWithNodes.elems[1].nodeIds[1] = nodes[5];
2104 facesWithNodes.elems[1].nodeIds[2] = nodes[6];
2105 facesWithNodes.elems[1].nodeIds[3] = nodes[7];
2106 facesWithNodes.elems[1].nodeIds[4] = nodes[12];
2107 facesWithNodes.elems[1].nodeIds[5] = nodes[13];
2108 facesWithNodes.elems[1].nodeIds[6] = nodes[14];
2109 facesWithNodes.elems[1].nodeIds[7] = nodes[15];
2110 facesWithNodes.elems[1].nbNodes = 8;
2111 facesWithNodes.elems[1].vtkType = VTK_QUADRATIC_QUAD;
2113 facesWithNodes.elems[2].nodeIds[0] = nodes[0];
2114 facesWithNodes.elems[2].nodeIds[1] = nodes[1];
2115 facesWithNodes.elems[2].nodeIds[2] = nodes[5];
2116 facesWithNodes.elems[2].nodeIds[3] = nodes[4];
2117 facesWithNodes.elems[2].nodeIds[4] = nodes[8];
2118 facesWithNodes.elems[2].nodeIds[5] = nodes[17];
2119 facesWithNodes.elems[2].nodeIds[6] = nodes[12];
2120 facesWithNodes.elems[2].nodeIds[7] = nodes[16];
2121 facesWithNodes.elems[2].nbNodes = 8;
2122 facesWithNodes.elems[2].vtkType = VTK_QUADRATIC_QUAD;
2124 facesWithNodes.elems[3].nodeIds[0] = nodes[1];
2125 facesWithNodes.elems[3].nodeIds[1] = nodes[2];
2126 facesWithNodes.elems[3].nodeIds[2] = nodes[6];
2127 facesWithNodes.elems[3].nodeIds[3] = nodes[5];
2128 facesWithNodes.elems[3].nodeIds[4] = nodes[9];
2129 facesWithNodes.elems[3].nodeIds[5] = nodes[18];
2130 facesWithNodes.elems[3].nodeIds[6] = nodes[13];
2131 facesWithNodes.elems[3].nodeIds[7] = nodes[17];
2132 facesWithNodes.elems[3].nbNodes = 8;
2133 facesWithNodes.elems[3].vtkType = VTK_QUADRATIC_QUAD;
2135 facesWithNodes.elems[4].nodeIds[0] = nodes[2];
2136 facesWithNodes.elems[4].nodeIds[1] = nodes[6];
2137 facesWithNodes.elems[4].nodeIds[2] = nodes[7];
2138 facesWithNodes.elems[4].nodeIds[3] = nodes[3];
2139 facesWithNodes.elems[4].nodeIds[4] = nodes[18];
2140 facesWithNodes.elems[4].nodeIds[5] = nodes[14];
2141 facesWithNodes.elems[4].nodeIds[6] = nodes[19];
2142 facesWithNodes.elems[4].nodeIds[7] = nodes[10];
2143 facesWithNodes.elems[4].nbNodes = 8;
2144 facesWithNodes.elems[4].vtkType = VTK_QUADRATIC_QUAD;
2146 facesWithNodes.elems[5].nodeIds[0] = nodes[3];
2147 facesWithNodes.elems[5].nodeIds[1] = nodes[7];
2148 facesWithNodes.elems[5].nodeIds[2] = nodes[4];
2149 facesWithNodes.elems[5].nodeIds[3] = nodes[0];
2150 facesWithNodes.elems[5].nodeIds[4] = nodes[19];
2151 facesWithNodes.elems[5].nodeIds[5] = nodes[15];
2152 facesWithNodes.elems[5].nodeIds[6] = nodes[16];
2153 facesWithNodes.elems[5].nodeIds[7] = nodes[11];
2154 facesWithNodes.elems[5].nbNodes = 8;
2155 facesWithNodes.elems[5].vtkType = VTK_QUADRATIC_QUAD;
2158 // ---------------------------------------------------------------------------