2010-01-08 15:53:25 +00:00
|
|
|
#include "SMDS_VtkCellIterator.hxx"
|
2010-09-10 14:58:23 +00:00
|
|
|
#include "utilities.h"
|
2010-01-08 15:53:25 +00:00
|
|
|
|
2010-09-10 14:58:23 +00:00
|
|
|
SMDS_VtkCellIterator::SMDS_VtkCellIterator(SMDS_Mesh* mesh, int vtkCellId, SMDSAbs_EntityType aType) :
|
2010-01-22 15:02:34 +00:00
|
|
|
_mesh(mesh), _cellId(vtkCellId), _index(0), _type(aType)
|
|
|
|
{
|
2010-10-15 08:56:06 +00:00
|
|
|
//MESSAGE("SMDS_VtkCellIterator " << _type);
|
2010-01-22 15:02:34 +00:00
|
|
|
_vtkIdList = vtkIdList::New();
|
2010-10-15 08:56:06 +00:00
|
|
|
vtkUnstructuredGrid* grid = _mesh->getGrid();
|
2010-01-22 15:02:34 +00:00
|
|
|
grid->GetCellPoints(_cellId, _vtkIdList);
|
2010-01-08 15:53:25 +00:00
|
|
|
_nbNodes = _vtkIdList->GetNumberOfIds();
|
2010-01-22 15:02:34 +00:00
|
|
|
switch (_type)
|
|
|
|
{
|
|
|
|
case SMDSEntity_Tetra:
|
2010-07-01 14:46:31 +00:00
|
|
|
{
|
|
|
|
this->exchange(1, 2);
|
|
|
|
break;
|
|
|
|
}
|
2010-01-22 15:02:34 +00:00
|
|
|
case SMDSEntity_Pyramid:
|
2010-07-01 14:46:31 +00:00
|
|
|
{
|
|
|
|
this->exchange(1, 3);
|
|
|
|
break;
|
|
|
|
}
|
2010-01-22 15:02:34 +00:00
|
|
|
case SMDSEntity_Penta:
|
2010-07-01 14:46:31 +00:00
|
|
|
{
|
|
|
|
//this->exchange(1, 2);
|
|
|
|
//this->exchange(4, 5);
|
|
|
|
break;
|
|
|
|
}
|
2010-01-22 15:02:34 +00:00
|
|
|
case SMDSEntity_Hexa:
|
2010-07-01 14:46:31 +00:00
|
|
|
{
|
|
|
|
this->exchange(1, 3);
|
|
|
|
this->exchange(5, 7);
|
|
|
|
break;
|
|
|
|
}
|
2010-04-02 13:55:36 +00:00
|
|
|
case SMDSEntity_Quad_Tetra:
|
2010-07-01 14:46:31 +00:00
|
|
|
{
|
|
|
|
this->exchange(1, 2);
|
|
|
|
this->exchange(4, 6);
|
|
|
|
this->exchange(8, 9);
|
|
|
|
break;
|
|
|
|
}
|
2010-04-02 13:55:36 +00:00
|
|
|
case SMDSEntity_Quad_Pyramid:
|
2010-07-01 14:46:31 +00:00
|
|
|
{
|
|
|
|
this->exchange(1, 3);
|
|
|
|
this->exchange(5, 8);
|
|
|
|
this->exchange(6, 7);
|
|
|
|
this->exchange(10, 12);
|
|
|
|
break;
|
|
|
|
}
|
2010-04-02 13:55:36 +00:00
|
|
|
case SMDSEntity_Quad_Penta:
|
2010-07-01 14:46:31 +00:00
|
|
|
{
|
|
|
|
//this->exchange(1, 2);
|
|
|
|
//this->exchange(4, 5);
|
|
|
|
//this->exchange(6, 8);
|
|
|
|
//this->exchange(9, 11);
|
|
|
|
//this->exchange(13, 14);
|
|
|
|
break;
|
|
|
|
}
|
2010-04-02 13:55:36 +00:00
|
|
|
case SMDSEntity_Quad_Hexa:
|
2010-07-01 14:46:31 +00:00
|
|
|
{
|
2010-09-10 14:58:23 +00:00
|
|
|
MESSAGE("SMDS_VtkCellIterator Quad_Hexa");
|
2010-07-01 14:46:31 +00:00
|
|
|
this->exchange(1, 3);
|
|
|
|
this->exchange(5, 7);
|
|
|
|
this->exchange(8, 11);
|
|
|
|
this->exchange(9, 10);
|
|
|
|
this->exchange(12, 15);
|
|
|
|
this->exchange(13, 14);
|
|
|
|
this->exchange(17, 19);
|
|
|
|
break;
|
|
|
|
}
|
2010-09-10 14:58:23 +00:00
|
|
|
case SMDSEntity_Polyhedra:
|
|
|
|
{
|
|
|
|
MESSAGE("SMDS_VtkCellIterator Polyhedra");
|
|
|
|
break;
|
|
|
|
}
|
2010-01-22 15:02:34 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SMDS_VtkCellIterator::~SMDS_VtkCellIterator()
|
|
|
|
{
|
|
|
|
_vtkIdList->Delete();
|
2010-01-08 15:53:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool SMDS_VtkCellIterator::more()
|
|
|
|
{
|
|
|
|
return (_index < _nbNodes);
|
|
|
|
}
|
|
|
|
|
|
|
|
const SMDS_MeshElement* SMDS_VtkCellIterator::next()
|
|
|
|
{
|
|
|
|
vtkIdType id = _vtkIdList->GetId(_index++);
|
|
|
|
return _mesh->FindNode(id);
|
|
|
|
}
|
2010-10-15 08:56:06 +00:00
|
|
|
|
|
|
|
SMDS_VtkCellIteratorToUNV::SMDS_VtkCellIteratorToUNV(SMDS_Mesh* mesh,
|
|
|
|
int vtkCellId,
|
|
|
|
SMDSAbs_EntityType aType)
|
|
|
|
: SMDS_VtkCellIterator()
|
|
|
|
{
|
|
|
|
_mesh = mesh;
|
|
|
|
_cellId = vtkCellId;
|
|
|
|
_index = 0;
|
|
|
|
_type = aType;
|
2010-10-20 15:21:51 +00:00
|
|
|
//MESSAGE("SMDS_VtkCellInterlacedIterator " << _type);
|
2010-10-15 08:56:06 +00:00
|
|
|
|
|
|
|
_vtkIdList = vtkIdList::New();
|
|
|
|
vtkIdType* pts;
|
|
|
|
vtkUnstructuredGrid* grid = _mesh->getGrid();
|
|
|
|
grid->GetCellPoints(_cellId, _nbNodes, pts);
|
|
|
|
_vtkIdList->SetNumberOfIds(_nbNodes);
|
|
|
|
int *ids = 0;
|
|
|
|
switch (_type)
|
|
|
|
{
|
|
|
|
case SMDSEntity_Quad_Edge:
|
|
|
|
{
|
|
|
|
static int id[] = {0,2,1};
|
|
|
|
ids = id;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SMDSEntity_Quad_Triangle:
|
|
|
|
{
|
|
|
|
static int id[] = {0,3,1,4,2,5};
|
|
|
|
ids = id;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SMDSEntity_Quad_Quadrangle:
|
|
|
|
{
|
|
|
|
static int id[] = {0,4,1,5,2,6,3,7};
|
|
|
|
ids = id;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SMDSEntity_Quad_Tetra:
|
|
|
|
{
|
|
|
|
static int id[] = {0,4,1,5,2,6,7,8,9,3};
|
|
|
|
ids = id;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SMDSEntity_Quad_Pyramid:
|
|
|
|
{
|
|
|
|
static int id[] = {0,5,1,6,2,7,3,8,9,10,11,12,4};
|
|
|
|
ids = id;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SMDSEntity_Penta:
|
|
|
|
{
|
|
|
|
static int id[] = {0,2,1,3,5,4};
|
|
|
|
ids = id;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SMDSEntity_Quad_Penta:
|
|
|
|
{
|
|
|
|
static int id[] = {0,8,2,7,1,6,12,14,13,3,11,5,10,4,9};
|
|
|
|
ids = id;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SMDSEntity_Quad_Hexa:
|
|
|
|
{
|
|
|
|
static int id[] = {0,8,1,9,2,10,3,11,16,17,18,19,4,12,5,13,6,14,7,15};
|
|
|
|
ids = id;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SMDSEntity_Polygon:
|
|
|
|
case SMDSEntity_Quad_Polygon:
|
|
|
|
case SMDSEntity_Polyhedra:
|
|
|
|
case SMDSEntity_Quad_Polyhedra:
|
|
|
|
default:
|
|
|
|
{
|
2010-10-20 15:21:51 +00:00
|
|
|
static int id[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29};
|
2010-10-15 08:56:06 +00:00
|
|
|
ids = id;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//MESSAGE("_nbNodes " << _nbNodes);
|
|
|
|
for (int i=0; i<_nbNodes; i++)
|
|
|
|
_vtkIdList->SetId(i, pts[ids[i]]);
|
|
|
|
}
|
|
|
|
|
|
|
|
SMDS_VtkCellIteratorToUNV::~SMDS_VtkCellIteratorToUNV()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|