if ( anElem->IsQuadratic() ) {
switch ( anElem->GetType() ) {
case SMDSAbs_Edge:
- anIter = static_cast<const SMDS_QuadraticEdge*>
+ anIter = dynamic_cast<const SMDS_VtkEdge*>
(anElem)->interlacedNodesElemIterator();
break;
case SMDSAbs_Face:
- anIter = static_cast<const SMDS_QuadraticFaceOfNodes*>
+ anIter = dynamic_cast<const SMDS_VtkFace*>
(anElem)->interlacedNodesElemIterator();
break;
default:
const SMDS_MeshFace* anElem = anIter->next();
if(anElem->IsQuadratic()) {
- const SMDS_QuadraticFaceOfNodes* F =
- static_cast<const SMDS_QuadraticFaceOfNodes*>(anElem);
+ const SMDS_VtkFace* F =
+ dynamic_cast<const SMDS_VtkFace*>(anElem);
// use special nodes iterator
- SMDS_NodeIteratorPtr anIter = F->interlacedNodesIterator();
+ SMDS_ElemIteratorPtr anIter = F->interlacedNodesElemIterator();
long aNodeId[4];
gp_Pnt P[4];
const SMDS_MeshFace* anElem = anIter->next();
SMDS_ElemIteratorPtr aNodesIter;
if ( anElem->IsQuadratic() )
- aNodesIter = static_cast<const SMDS_QuadraticFaceOfNodes*>
+ aNodesIter = dynamic_cast<const SMDS_VtkFace*>
(anElem)->interlacedNodesElemIterator();
else
aNodesIter = anElem->nodesIterator();
SMDS_ElemIteratorPtr anIter;
if ( aFace->IsQuadratic() ) {
- anIter = static_cast<const SMDS_QuadraticFaceOfNodes*>
+ anIter = dynamic_cast<const SMDS_VtkFace*>
(aFace)->interlacedNodesElemIterator();
}
else {
long anElemId = anElem->GetID();
SMDS_ElemIteratorPtr aNodesIter;
if ( anElem->IsQuadratic() )
- aNodesIter = static_cast<const SMDS_QuadraticFaceOfNodes*>(anElem)->
+ aNodesIter = static_cast<const SMDS_VtkFace*>(anElem)->
interlacedNodesElemIterator();
else
aNodesIter = anElem->nodesIterator();
typedef MED::TVector<int> TQuantities;
TQuantities aQuantities(aNbFaces);
TInt aNbNodes = aPolyedreInfo->GetNbNodes(iElem);
+ //MESSAGE("--- aNbNodes " << aNbNodes);
TNodeIds aNodeIds(aNbNodes);
for(TInt iFace = 0, iNode = 0; iFace < aNbFaces; iFace++){
+ //MESSAGE("--- iface " << aNbFaces << " " << iFace);
MED::TCConnSlice aConnSlice = aConnSliceArr[iFace];
TInt aNbConn = aConnSlice.size();
aQuantities[iFace] = aNbConn;
#ifdef _EDF_NODE_IDS_
+ //MESSAGE(anIsNodeNum);
if(anIsNodeNum)
for(TInt iConn = 0; iConn < aNbConn; iConn++)
- aNodeIds[iNode++] = aNodeInfo->GetElemNum(aConnSlice[iConn] - 1);
+ {
+ //MESSAGE("iConn " << iConn << " aConnSlice[iConn] " << aConnSlice[iConn]);
+ aNodeIds[iNode] = aNodeInfo->GetElemNum(aConnSlice[iConn] - 1);
+ //MESSAGE("aNodeIds[" << iNode << "]=" << aNodeIds[iNode]);
+ iNode++;
+ }
else
for(TInt iConn = 0; iConn < aNbConn; iConn++)
+ {
+ //MESSAGE("iConn " << iConn);
aNodeIds[iNode++] = aConnSlice[iConn];
+ }
#else
for(TInt iConn = 0; iConn < aNbConn; iConn++)
+ {
+ //MESSAGE("iConn " << iConn);
aNodeIds[iNode++] = aConnSlice[iConn];
+ }
#endif
}
// }
#ifndef _DEXCEPT_
}catch(const std::exception& exc){
- INFOS("Following exception was caught:\n\t"<<exc.what());
+ INFOS("The following exception was caught:\n\t"<<exc.what());
aResult = DRS_FAIL;
}catch(...){
INFOS("Unknown exception was caught !!!");
}
#ifndef _DEXCEPT_
}catch(const std::exception& exc){
- INFOS("Follow exception was caught:\n\t"<<exc.what());
+ INFOS("The following exception was caught:\n\t"<<exc.what());
aResult = DRS_FAIL;
}catch(...){
INFOS("Unknown exception was caught !!!");
}
}
}catch(const std::exception& exc){
- INFOS("Follow exception was caught:\n\t"<<exc.what());
+ INFOS("Following exception was caught:\n\t"<<exc.what());
theStatus = DRS_FAIL;
}catch(...){
INFOS("Unknown exception was caught !!!");
nbElemInfo.NbHexas( ORDER_QUADRATIC ),
SMDSAbs_Volume));
if ( polyTypesSupported ) {
+ //MESSAGE("polyTypesSupported");
aTElemTypeDatas.push_back( TElemTypeData(anEntity,
ePOLYEDRE,
nbElemInfo.NbPolyhedrons(),
// ----------------
else if (aElemTypeData->_geomType == ePOLYEDRE )
{
+ //MESSAGE("_geomType == ePOLYEDRE");
if ( nbPolyhedronNodes == 0 ) {
// Count nb of nodes
while ( const SMDS_MeshElement* anElem = elemIterator->next() ) {
- const SMDS_PolyhedralVolumeOfNodes* aPolyedre =
- dynamic_cast<const SMDS_PolyhedralVolumeOfNodes*>( anElem );
- if ( aPolyedre ) {
+ const SMDS_VtkVolume *aPolyedre = dynamic_cast<const SMDS_VtkVolume*>(anElem);
+ if ( aPolyedre && aPolyedre->IsPoly()) {
nbPolyhedronNodes += aPolyedre->NbNodes();
nbPolyhedronFaces += aPolyedre->NbFaces();
if ( ++iElem == aElemTypeData->_nbElems )
break;
}
}
+ //MESSAGE("nbPolyhedronNodes=" << nbPolyhedronNodes);
+ //MESSAGE("nbPolyhedronFaces=" << nbPolyhedronFaces);
+ //MESSAGE("_nbElems="<< aElemTypeData->_nbElems);
}
else {
// Store in med file
TInt iFace = 0, iNode = 0;
while ( const SMDS_MeshElement* anElem = elemIterator->next() )
{
- const SMDS_PolyhedralVolumeOfNodes* aPolyedre =
- dynamic_cast<const SMDS_PolyhedralVolumeOfNodes*>( anElem );
+ const SMDS_VtkVolume *aPolyedre = dynamic_cast<const SMDS_VtkVolume*>(anElem);
if ( !aPolyedre )
continue;
-
+ if ( !aPolyedre->IsPoly() )
+ continue;
+ //MESSAGE("index[" << iElem << "]=" << index[iElem] << " iElem=" << iElem);
// index
TInt aNbFaces = aPolyedre->NbFaces();
index[ iElem+1 ] = index[ iElem ] + aNbFaces;
+ //MESSAGE("index[" << iElem+1 << "]=" << index[iElem+1] << " iElem=" << iElem);
// face index
for (TInt f = 1; f <= aNbFaces; ++f, ++iFace ) {
int aNbFaceNodes = aPolyedre->NbFaceNodes( f );
faces[ iFace+1 ] = faces[ iFace ] + aNbFaceNodes;
+ //MESSAGE("faces[" << iFace+1 << "]=" << faces[iFace+1] << " iFace=" << iFace);
}
// connectivity
SMDS_ElemIteratorPtr nodeIt = anElem->nodesIterator();
const SMDS_MeshElement* aNode = nodeIt->next();
#ifdef _EDF_NODE_IDS_
conn[ iNode ] = aNodeIdMap[aNode->GetID()];
+ //MESSAGE("conn["<< iNode << "]=" << conn[iNode] << " aNode->GetID()=" << aNode->GetID());
#else
conn[ iNode ] = aNode->GetID();
+ //MESSAGE("conn["<< iNode << "]=" << conn[iNode]);
#endif
++iNode;
}
}
catch(const std::exception& exc) {
- INFOS("Follow exception was cought:\n\t"<<exc.what());
+ INFOS("The following exception was caught:\n\t"<<exc.what());
throw;
}
catch(...) {
- INFOS("Unknown exception was cought !!!");
+ INFOS("Unknown exception was caught !!!");
throw;
}
aNodesIter = anElem->nodesIteratorToUNV();
if ( anElem->IsPoly() ) {
MESSAGE("anElem->IsPoly");
- if ( const SMDS_PolyhedralVolumeOfNodes* ph =
- dynamic_cast<const SMDS_PolyhedralVolumeOfNodes*> (anElem))
+ if ( const SMDS_VtkVolume* ph =
+ dynamic_cast<const SMDS_VtkVolume*> (anElem))
{
aNbNodes = ph->NbUniqueNodes();
aNodesIter = ph->uniqueNodesIterator();
// Convertions connectivities from SMDS to VTK
if (anElem->IsPoly() && aNbNodes > 3) { // POLYEDRE
- if ( const SMDS_PolyhedralVolumeOfNodes* ph =
- dynamic_cast<const SMDS_PolyhedralVolumeOfNodes*> (anElem))
+ if ( const SMDS_VtkVolume* ph =
+ dynamic_cast<const SMDS_VtkVolume*> (anElem))
{
aNbNodes = GetConnect(ph->uniqueNodesIterator(),aConnect);
anIdList->SetNumberOfIds( aNbNodes );
return false;
}
- const SMDS_PolyhedralVolumeOfNodes* vol = dynamic_cast<const SMDS_PolyhedralVolumeOfNodes*>(elem);
+ const SMDS_VtkVolume* vol = dynamic_cast<const SMDS_VtkVolume*>(elem);
if (!vol) {
return false;
}
}
// change nodes
- bool Ok = const_cast<SMDS_PolyhedralVolumeOfNodes*>(vol)->ChangeNodes(nodes, quantities);
+ // TODO remove this function
+ //bool Ok = const_cast<SMDS_VtkVolume*>(vol)->ChangeNodes(nodes, quantities);
+ bool Ok = false;
if (!Ok) {
return false;
}
return SMDS_ElemIteratorPtr((SMDS_ElemIterator*) NULL);
}
+//! virtual, redefined in vtkEdge, vtkFace and vtkVolume classes
+SMDS_ElemIteratorPtr SMDS_MeshElement::interlacedNodesElemIterator() const
+{
+ MESSAGE("Iterator not implemented");
+ return SMDS_ElemIteratorPtr((SMDS_ElemIterator*) NULL);
+}
+
///////////////////////////////////////////////////////////////////////////////
///Return the ID of the element
///////////////////////////////////////////////////////////////////////////////
SMDS_ElemIteratorPtr facesIterator() const;
virtual SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type) const;
virtual SMDS_ElemIteratorPtr nodesIteratorToUNV() const;
+ virtual SMDS_ElemIteratorPtr interlacedNodesElemIterator() const;
// std-like iteration on nodes
typedef SMDS_StdIterator< const SMDS_MeshNode*, SMDS_ElemIteratorPtr > iterator;
holes = 0;
compactState = lookHoleStart;
- vtkIdType tmpid[50];
+ // TODO some polyhedron may be huge (only in some tests)
+ vtkIdType tmpid[NBMAXNODESINCELL];
vtkIdType *pointsCell = &tmpid[0]; // --- points id to fill a new cell
for (int i = 0; i < oldCellSize; i++)
vtkIdType nbpts;
vtkIdType *oldPtsCell = 0;
this->Connectivity->GetCell(oldLoc, nbpts, oldPtsCell);
+ assert(nbpts < NBMAXNODESINCELL);
//MESSAGE(j << " " << alreadyCopied << " " << (int)this->Types->GetValue(j) << " " << oldLoc << " " << nbpts );
for (int l = 0; l < nbpts; l++)
{
#define NBMAXNEIGHBORS 10
+// allow very huge polyhedrons in tests
+#define NBMAXNODESINCELL 5000
+
class SMDS_Downward;
class SMDS_Mesh;
#include "SMDS_MeshElement.hxx"
#include "SMDS_MeshNode.hxx"
-#include "SMDS_PolyhedralVolumeOfNodes.hxx"
+#include "SMDS_VtkVolume.hxx"
#include "SMDS_Mesh.hxx"
#include "utilities.h"
}
if (myVolume->IsPoly()) {
- myPolyedre = static_cast<const SMDS_PolyhedralVolumeOfNodes*>( myVolume );
+ myPolyedre = dynamic_cast<const SMDS_VtkVolume*>( myVolume );
if (!myPolyedre) {
MESSAGE("Warning: bad volumic element");
return false;
class SMDS_MeshElement;
class SMDS_MeshNode;
-class SMDS_PolyhedralVolumeOfNodes;
+class SMDS_VtkVolume;
class SMDS_MeshVolume;
#include <vector>
bool setFace( int faceIndex );
const SMDS_MeshElement* myVolume;
- const SMDS_PolyhedralVolumeOfNodes* myPolyedre;
+ const SMDS_VtkVolume* myPolyedre;
bool myVolForward;
int myNbFaces;
break;
}
case SMDSEntity_Polyhedra:
- {
- MESSAGE("SMDS_VtkCellIterator Polyhedra");
- break;
- }
+ MESSAGE("SMDS_VtkCellIterator Polyhedra (iterate on actual nodes)");
+ break;
default:
break;
}
return _mesh->FindNode(id);
}
-SMDS_VtkCellIteratorToUNV::SMDS_VtkCellIteratorToUNV(SMDS_Mesh* mesh,
- int vtkCellId,
- SMDSAbs_EntityType aType)
-: SMDS_VtkCellIterator()
+SMDS_VtkCellIteratorToUNV::SMDS_VtkCellIteratorToUNV(SMDS_Mesh* mesh, int vtkCellId, SMDSAbs_EntityType aType) :
+ SMDS_VtkCellIterator()
{
_mesh = mesh;
_cellId = vtkCellId;
_index = 0;
_type = aType;
- //MESSAGE("SMDS_VtkCellInterlacedIterator " << _type);
+ //MESSAGE("SMDS_VtkCellInterlacedIterator (UNV)" << _type);
_vtkIdList = vtkIdList::New();
vtkIdType* pts;
{
case SMDSEntity_Quad_Edge:
{
- static int id[] = {0,2,1};
+ static int id[] = { 0, 2, 1 };
ids = id;
break;
}
case SMDSEntity_Quad_Triangle:
{
- static int id[] = {0,3,1,4,2,5};
+ 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};
+ static int id[] = { 0, 4, 1, 5, 2, 6, 3, 7 };
ids = id;
break;
}
- case SMDSEntity_Quad_Tetra:
+ case SMDSEntity_Quad_Tetra:
{
- static int id[] = {0,4,1,5,2,6,7,8,9,3};
+ 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};
+ 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};
+ static int id[] = { 0, 2, 1, 3, 5, 4 };
ids = id;
break;
}
- case SMDSEntity_Quad_Penta:
+ case SMDSEntity_Quad_Penta:
{
- static int id[] = {0,8,2,7,1,6,12,14,13,3,11,5,10,4,9};
+ 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};
+ 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;
+ break;
}
case SMDSEntity_Polygon:
case SMDSEntity_Quad_Polygon:
case SMDSEntity_Quad_Polyhedra:
default:
{
- 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};
+ 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 };
ids = id;
break;
}
}
//MESSAGE("_nbNodes " << _nbNodes);
- for (int i=0; i<_nbNodes; i++)
+ for (int i = 0; i < _nbNodes; i++)
_vtkIdList->SetId(i, pts[ids[i]]);
}
{
}
+SMDS_VtkCellIteratorPolyH::SMDS_VtkCellIteratorPolyH(SMDS_Mesh* mesh, int vtkCellId, SMDSAbs_EntityType aType) :
+ SMDS_VtkCellIterator()
+{
+ _mesh = mesh;
+ _cellId = vtkCellId;
+ _index = 0;
+ _type = aType;
+ //MESSAGE("SMDS_VtkCellIteratorPolyH " << _type);
+ _vtkIdList = vtkIdList::New();
+ vtkUnstructuredGrid* grid = _mesh->getGrid();
+ grid->GetCellPoints(_cellId, _vtkIdList);
+ _nbNodes = _vtkIdList->GetNumberOfIds();
+ switch (_type)
+ {
+ case SMDSEntity_Polyhedra:
+ {
+ //MESSAGE("SMDS_VtkCellIterator Polyhedra");
+ vtkIdType nFaces = 0;
+ vtkIdType* ptIds = 0;
+ grid->GetFaceStream(_cellId, nFaces, ptIds);
+ int id = 0;
+ _nbNodesInFaces = 0;
+ for (int i = 0; i < nFaces; i++)
+ {
+ int nodesInFace = ptIds[id]; // nodeIds in ptIds[id+1 .. id+nodesInFace]
+ _nbNodesInFaces += nodesInFace;
+ id += (nodesInFace + 1);
+ }
+ _vtkIdList->SetNumberOfIds(_nbNodesInFaces);
+ id = 0;
+ int n = 0;
+ for (int i = 0; i < nFaces; i++)
+ {
+ int nodesInFace = ptIds[id]; // nodeIds in ptIds[id+1 .. id+nodesInFace]
+ for (int k = 1; k <= nodesInFace; k++)
+ _vtkIdList->SetId(n++, ptIds[id + k]);
+ id += (nodesInFace + 1);
+ }
+ break;
+ }
+ default:
+ assert(0);
+ }
+}
+
+SMDS_VtkCellIteratorPolyH::~SMDS_VtkCellIteratorPolyH()
+{
+}
+
+bool SMDS_VtkCellIteratorPolyH::more()
+{
+ return (_index < _nbNodesInFaces);
+}
virtual ~SMDS_VtkCellIteratorToUNV();
};
+class SMDS_VtkCellIteratorPolyH: public SMDS_VtkCellIterator
+{
+public:
+ SMDS_VtkCellIteratorPolyH(SMDS_Mesh* mesh, int vtkCellId, SMDSAbs_EntityType aType);
+ virtual ~SMDS_VtkCellIteratorPolyH();
+ virtual bool more();
+protected:
+ int _nbNodesInFaces;
+};
+
#endif
{
return SMDS_ElemIteratorPtr(new SMDS_VtkCellIteratorToUNV(SMDS_Mesh::_meshList[myMeshId], myVtkID, GetEntityType()));
}
+
+SMDS_ElemIteratorPtr SMDS_VtkEdge::interlacedNodesElemIterator() const
+{
+ return SMDS_ElemIteratorPtr(new SMDS_VtkCellIteratorToUNV(SMDS_Mesh::_meshList[myMeshId], myVtkID, GetEntityType()));
+}
virtual const SMDS_MeshNode* GetNode(const int ind) const;
virtual bool IsQuadratic() const;
-protected:
virtual SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type) const;
virtual SMDS_ElemIteratorPtr nodesIteratorToUNV() const;
+ virtual SMDS_ElemIteratorPtr interlacedNodesElemIterator() const;
+protected:
};
#endif
{
return SMDS_ElemIteratorPtr(new SMDS_VtkCellIteratorToUNV(SMDS_Mesh::_meshList[myMeshId], myVtkID, GetEntityType()));
}
+
+ SMDS_ElemIteratorPtr SMDS_VtkFace::interlacedNodesElemIterator() const
+ {
+ return SMDS_ElemIteratorPtr(new SMDS_VtkCellIteratorToUNV(SMDS_Mesh::_meshList[myMeshId], myVtkID, GetEntityType()));
+ }
virtual bool IsQuadratic() const;
virtual bool IsPoly() const;
-protected:
virtual SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type) const;
virtual SMDS_ElemIteratorPtr nodesIteratorToUNV() const;
+ virtual SMDS_ElemIteratorPtr interlacedNodesElemIterator() const;
+protected:
};
#endif
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);
+ 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];
for (int n = 0; n < nf; n++)
ptIds.push_back(facePts[n]);
else
- for (int n = nf-1; n >= 0; n--)
+ for (int n = nf - 1; n >= 0; n--)
ptIds.push_back(facePts[n]);
k += nf;
}
MESSAGE("ChangeNodes problem: not the same number of nodes " << npts << " -> " << nbNodes);
return false;
}
- for (int i=0; i<nbNodes; i++)
+ for (int i = 0; i < nbNodes; i++)
{
pts[i] = nodes[i]->GetID();
}
case VTK_HEXAHEDRON:
case VTK_QUADRATIC_HEXAHEDRON:
nbFaces = 6;
- break;
+ break;
case VTK_POLYHEDRON:
{
vtkIdType nFaces = 0;
vtkIdType* ptIds = 0;
grid->GetFaceStream(this->myVtkID, nFaces, ptIds);
nbFaces = nFaces;
+ break;
}
default:
- MESSAGE("invalid volume type");
+ MESSAGE("invalid volume type")
+ ;
nbFaces = 0;
break;
}
int SMDS_VtkVolume::NbNodes() const
{
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
- int nbPoints = grid->GetCell(myVtkID)->GetNumberOfPoints();
+ vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
+ int nbPoints = 0;
+ if (aVtkType != VTK_POLYHEDRON)
+ {
+ nbPoints = grid->GetCell(myVtkID)->GetNumberOfPoints();
+ }
+ else
+ {
+ vtkIdType nFaces = 0;
+ vtkIdType* ptIds = 0;
+ grid->GetFaceStream(this->myVtkID, nFaces, ptIds);
+ int id = 0;
+ for (int i = 0; i < nFaces; i++)
+ {
+ int nodesInFace = ptIds[id];
+ nbPoints += nodesInFace;
+ id += (nodesInFace + 1);
+ }
+ }
return nbPoints;
}
case VTK_HEXAHEDRON:
case VTK_QUADRATIC_HEXAHEDRON:
nbEdges = 12;
- break;
+ break;
case VTK_POLYHEDRON:
{
vtkIdType nFaces = 0;
break;
}
default:
- MESSAGE("invalid volume type");
+ MESSAGE("invalid volume type")
+ ;
nbEdges = 0;
break;
}
return nbEdges;
}
+/*! polyhedron only,
+ * 1 <= face_ind <= NbFaces()
+ */
+int SMDS_VtkVolume::NbFaceNodes(const int face_ind) const
+{
+ vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
+ vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
+ int nbNodes = 0;
+ if (aVtkType == VTK_POLYHEDRON)
+ {
+ vtkIdType nFaces = 0;
+ vtkIdType* ptIds = 0;
+ grid->GetFaceStream(this->myVtkID, nFaces, ptIds);
+ int id = 0;
+ for (int i = 0; i < nFaces; i++)
+ {
+ int nodesInFace = ptIds[id];
+ id += (nodesInFace + 1);
+ if (i == face_ind - 1)
+ {
+ nbNodes = nodesInFace;
+ break;
+ }
+ }
+ }
+ return nbNodes;
+}
+
+/*! polyhedron only,
+ * 1 <= face_ind <= NbFaces()
+ * 1 <= node_ind <= NbFaceNodes()
+ */
+const SMDS_MeshNode* SMDS_VtkVolume::GetFaceNode(const int face_ind, const int node_ind) const
+{
+ SMDS_Mesh *mesh = SMDS_Mesh::_meshList[myMeshId];
+ vtkUnstructuredGrid* grid = mesh->getGrid();
+ vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
+ const SMDS_MeshNode* node = 0;
+ if (aVtkType == VTK_POLYHEDRON)
+ {
+ vtkIdType nFaces = 0;
+ vtkIdType* ptIds = 0;
+ grid->GetFaceStream(this->myVtkID, nFaces, ptIds);
+ int id = 0;
+ for (int i = 0; i < nFaces; i++)
+ {
+ int nodesInFace = ptIds[id]; // nodeIds in ptIds[id+1 .. id+nodesInFace]
+ if (i == face_ind - 1) // first face is number 1
+ {
+ if ((node_ind > 0) && (node_ind <= nodesInFace))
+ node = mesh->FindNode(ptIds[id + node_ind]); // ptIds[id+1] : first node
+ break;
+ }
+ id += (nodesInFace + 1);
+ }
+ }
+ return node;
+}
+
+/*! polyhedron only,
+ * return number of nodes for each face
+ */
+const std::vector<int> & SMDS_VtkVolume::GetQuantities() const
+{
+ vector<int> quantities;
+ quantities.clear();
+ SMDS_Mesh *mesh = SMDS_Mesh::_meshList[myMeshId];
+ vtkUnstructuredGrid* grid = mesh->getGrid();
+ vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
+ if (aVtkType == VTK_POLYHEDRON)
+ {
+ vtkIdType nFaces = 0;
+ vtkIdType* ptIds = 0;
+ grid->GetFaceStream(this->myVtkID, nFaces, ptIds);
+ int id = 0;
+ for (int i = 0; i < nFaces; i++)
+ {
+ int nodesInFace = ptIds[id]; // nodeIds in ptIds[id+1 .. id+nodesInFace]
+ quantities.push_back(nodesInFace);
+ id += (nodesInFace + 1);
+ }
+ }
+ return quantities;
+}
+
SMDS_ElemIteratorPtr SMDS_VtkVolume::elementsIterator(SMDSAbs_ElementType type) const
{
switch (type)
{
case SMDSAbs_Node:
- return SMDS_ElemIteratorPtr(new SMDS_VtkCellIterator(SMDS_Mesh::_meshList[myMeshId], myVtkID, GetEntityType()));
+ {
+ SMDSAbs_EntityType aType = this->GetEntityType();
+ if (aType == SMDSEntity_Polyhedra)
+ return SMDS_ElemIteratorPtr(new SMDS_VtkCellIteratorPolyH(SMDS_Mesh::_meshList[myMeshId], myVtkID, aType));
+ else
+ return SMDS_ElemIteratorPtr(new SMDS_VtkCellIterator(SMDS_Mesh::_meshList[myMeshId], myVtkID, aType));
+ }
default:
MESSAGE("ERROR : Iterator not implemented");
return SMDS_ElemIteratorPtr((SMDS_ElemIterator*) NULL);
return SMDS_ElemIteratorPtr(new SMDS_VtkCellIteratorToUNV(SMDS_Mesh::_meshList[myMeshId], myVtkID, GetEntityType()));
}
+SMDS_ElemIteratorPtr SMDS_VtkVolume::interlacedNodesElemIterator() const
+{
+ return SMDS_ElemIteratorPtr(new SMDS_VtkCellIteratorToUNV(SMDS_Mesh::_meshList[myMeshId], myVtkID, GetEntityType()));
+}
SMDSAbs_ElementType SMDS_VtkVolume::GetType() const
{
*/
const SMDS_MeshNode* SMDS_VtkVolume::GetNode(const int ind) const
{
- return SMDS_MeshElement::GetNode(ind); // --- a optimiser !
+ // TODO optimize if possible (vtkCellIterator)
+ return SMDS_MeshElement::GetNode(ind);
}
bool SMDS_VtkVolume::IsQuadratic() const
return aType;
}
- void SMDS_VtkVolume::gravityCenter(SMDS_UnstructuredGrid* grid, vtkIdType *nodeIds, int nbNodes, double* result)
+void SMDS_VtkVolume::gravityCenter(SMDS_UnstructuredGrid* grid, vtkIdType *nodeIds, int nbNodes, double* result)
{
- for (int j=0; j<3; j++)
+ for (int j = 0; j < 3; j++)
result[j] = 0;
- if (nbNodes <= 0)
+ if (nbNodes <= 0)
return;
- for (int i =0; i< nbNodes; i++)
+ for (int i = 0; i < nbNodes; i++)
{
double *coords = grid->GetPoint(nodeIds[i]);
- for (int j=0; j<3; j++)
+ for (int j = 0; j < 3; j++)
result[j] += coords[j];
}
- for (int j=0; j<3; j++)
- result[j] = result[j]/nbNodes;
+ for (int j = 0; j < 3; j++)
+ result[j] = result[j] / nbNodes;
//MESSAGE("center " << result[0] << " " << result[1] << " " << result[2]);
return;
}
- bool SMDS_VtkVolume::isForward(double* a,double* b,double* c,double* d)
- {
+bool SMDS_VtkVolume::isForward(double* a, double* b, double* c, double* d)
+{
double u[3], v[3], w[3];
for (int j = 0; j < 3; j++)
{
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];
+ 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);
}
+
+/*! For polyhedron only
+ * @return actual number of nodes (not the sum of nodes of all faces)
+ */
+int SMDS_VtkVolume::NbUniqueNodes() const
+{
+ vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
+ return grid->GetCell(myVtkID)->GetNumberOfPoints();
+}
+
+/*! For polyhedron use only
+ * @return iterator on actual nodes (not through the faces)
+ */
+SMDS_ElemIteratorPtr SMDS_VtkVolume::uniqueNodesIterator() const
+{
+ MESSAGE("uniqueNodesIterator");
+ return SMDS_ElemIteratorPtr(new SMDS_VtkCellIterator(SMDS_Mesh::_meshList[myMeshId], myVtkID, GetEntityType()));
+}
int NbFaces() const;
int NbNodes() const;
int NbEdges() const;
+
+ // 1 <= face_ind <= NbFaces()
+ int NbFaceNodes (const int face_ind) const;
+ // 1 <= face_ind <= NbFaces()
+ // 1 <= node_ind <= NbFaceNodes()
+ const SMDS_MeshNode* GetFaceNode (const int face_ind, const int node_ind) const;
+
virtual SMDSAbs_ElementType GetType() const;
virtual vtkIdType GetVtkType() const;
virtual SMDSAbs_EntityType GetEntityType() const;
int nbNodes,
double* result);
static bool isForward(double* a,double* b,double* c,double* d);
+ int NbUniqueNodes() const;
+ SMDS_ElemIteratorPtr uniqueNodesIterator() const;
+ const std::vector<int> & GetQuantities() const;
-protected:
virtual SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type) const;
virtual SMDS_ElemIteratorPtr nodesIteratorToUNV() const;
+ virtual SMDS_ElemIteratorPtr interlacedNodesElemIterator() const;
+
+protected:
};
#endif
#include "SMDS_PolyhedralVolumeOfNodes.hxx"
#include "SMDS_FacePosition.hxx"
#include "SMDS_SpacePosition.hxx"
-#include "SMDS_QuadraticFaceOfNodes.hxx"
+//#include "SMDS_QuadraticFaceOfNodes.hxx"
#include "SMDS_MeshGroup.hxx"
#include "SMDS_LinearEdge.hxx"
#include "SMDS_Downward.hxx"
if (theElem->IsPoly()) {
// TODO reorient vtk polyhedron
MESSAGE("reorient vtk polyhedron ?");
- const SMDS_PolyhedralVolumeOfNodes* aPolyedre =
- static_cast<const SMDS_PolyhedralVolumeOfNodes*>( theElem );
+ const SMDS_VtkVolume* aPolyedre =
+ dynamic_cast<const SMDS_VtkVolume*>( theElem );
if (!aPolyedre) {
MESSAGE("Warning: bad volumic element");
return false;
helper.SetSubShape( face );
list< const SMDS_MeshElement* >::iterator elemIt = elemsOnFace.begin();
for ( ; elemIt != elemsOnFace.end(); ++elemIt ) {
- const SMDS_QuadraticFaceOfNodes* QF =
- dynamic_cast<const SMDS_QuadraticFaceOfNodes*> (*elemIt);
- if(QF) {
+ const SMDS_VtkFace* QF =
+ dynamic_cast<const SMDS_VtkFace*> (*elemIt);
+ if(QF && QF->IsQuadratic()) {
vector<const SMDS_MeshNode*> Ns;
Ns.reserve(QF->NbNodes()+1);
- SMDS_NodeIteratorPtr anIter = QF->interlacedNodesIterator();
+ SMDS_ElemIteratorPtr anIter = QF->interlacedNodesElemIterator();
while ( anIter->more() )
- Ns.push_back( anIter->next() );
+ Ns.push_back( cast2Node(anIter->next()) );
Ns.push_back( Ns[0] );
double x, y, z;
for(int i=0; i<QF->NbNodes(); i=i+2) {
case SMDSAbs_Volume:
{
// ATTENTION: Reversing is not yet done!!!
- const SMDS_PolyhedralVolumeOfNodes* aPolyedre =
- dynamic_cast<const SMDS_PolyhedralVolumeOfNodes*>( elem );
+ const SMDS_VtkVolume* aPolyedre =
+ dynamic_cast<const SMDS_VtkVolume*>( elem );
if (!aPolyedre) {
MESSAGE("Warning: bad volumic element");
continue;
case SMDSAbs_Volume:
{
// ATTENTION: Reversing is not yet done!!!
- const SMDS_PolyhedralVolumeOfNodes* aPolyedre =
- dynamic_cast<const SMDS_PolyhedralVolumeOfNodes*>( elem );
+ const SMDS_VtkVolume* aPolyedre =
+ dynamic_cast<const SMDS_VtkVolume*>( elem );
if (!aPolyedre) {
MESSAGE("Warning: bad volumic element");
continue;
SMDS_ElemIteratorPtr nodeIt = element->nodesIterator();
if ( element->IsQuadratic() )
- if (const SMDS_QuadraticFaceOfNodes* f=dynamic_cast<const SMDS_QuadraticFaceOfNodes*>(element))
+ if (const SMDS_VtkFace* f=dynamic_cast<const SMDS_VtkFace*>(element))
nodeIt = f->interlacedNodesElemIterator();
- else if (const SMDS_QuadraticEdge* e =dynamic_cast<const SMDS_QuadraticEdge*>(element))
+ else if (const SMDS_VtkEdge* e =dynamic_cast<const SMDS_VtkEdge*>(element))
nodeIt = e->interlacedNodesElemIterator();
while ( nodeIt->more() )
if (aShapeId)
aMesh->SetMeshElementOnShape(newElem, aShapeId);
}
- MESSAGE("ChangeElementNodes MergeNodes Poly");
- aMesh->ChangeElementNodes(elem, &polygons_nodes[inode], quantities[nbNew - 1]);
+
+ MESSAGE("ChangeElementNodes MergeNodes Polygon");
+ //aMesh->ChangeElementNodes(elem, &polygons_nodes[inode], quantities[nbNew - 1]);
+ vector<const SMDS_MeshNode *> polynodes(polygons_nodes.begin()+inode,polygons_nodes.end());
+ int quid =0;
+ if (nbNew > 0) quid = nbNew - 1;
+ vector<int> newquant(quantities.begin()+quid, quantities.end());
+ const SMDS_MeshElement* newElem = 0;
+ newElem = aMesh->AddPolyhedralVolume(polynodes, newquant);
+ myLastCreatedElems.Append(newElem);
+ if ( aShapeId && newElem )
+ aMesh->SetMeshElementOnShape( newElem, aShapeId );
+ rmElemIds.push_back(elem->GetID());
}
else {
rmElemIds.push_back(elem->GetID());
rmElemIds.push_back(elem->GetID());
}
else {
- // each face has to be analized in order to check volume validity
- const SMDS_PolyhedralVolumeOfNodes* aPolyedre =
- static_cast<const SMDS_PolyhedralVolumeOfNodes*>( elem );
+ // each face has to be analyzed in order to check volume validity
+ const SMDS_VtkVolume* aPolyedre =
+ dynamic_cast<const SMDS_VtkVolume*>( elem );
if (aPolyedre) {
int nbFaces = aPolyedre->NbFaces();
}
if (quantities.size() > 3)
- aMesh->ChangePolyhedronNodes(elem, poly_nodes, quantities);
- else
- rmElemIds.push_back(elem->GetID());
-
+ {
+ MESSAGE("ChangeElementNodes MergeNodes Polyhedron");
+ //aMesh->ChangePolyhedronNodes(elem, poly_nodes, quantities);
+ const SMDS_MeshElement* newElem = 0;
+ newElem = aMesh->AddPolyhedralVolume(poly_nodes, quantities);
+ myLastCreatedElems.Append(newElem);
+ if ( aShapeId && newElem )
+ aMesh->SetMeshElementOnShape( newElem, aShapeId );
+ rmElemIds.push_back(elem->GetID());
+ }
}
else {
rmElemIds.push_back(elem->GetID());
if ( isOk ) {
if (elem->IsPoly() && elem->GetType() == SMDSAbs_Volume) {
// Change nodes of polyedre
- const SMDS_PolyhedralVolumeOfNodes* aPolyedre =
- static_cast<const SMDS_PolyhedralVolumeOfNodes*>( elem );
+ const SMDS_VtkVolume* aPolyedre =
+ dynamic_cast<const SMDS_VtkVolume*>( elem );
if (aPolyedre) {
int nbFaces = aPolyedre->NbFaces();
if ( !face && elem->IsQuadratic())
{
// analysis for quadratic elements using all nodes
- const SMDS_QuadraticFaceOfNodes* F =
- static_cast<const SMDS_QuadraticFaceOfNodes*>(elem);
+ const SMDS_VtkFace* F =
+ dynamic_cast<const SMDS_VtkFace*>(elem);
+ if (!F) throw SALOME_Exception(LOCALIZED("not an SMDS_VtkFace"));
// use special nodes iterator
- SMDS_NodeIteratorPtr anIter = F->interlacedNodesIterator();
+ SMDS_ElemIteratorPtr anIter = F->interlacedNodesElemIterator();
const SMDS_MeshNode* prevN = cast2Node( anIter->next() );
for ( i1 = -1, i2 = 0; anIter->more() && !face; i1++, i2++ )
{
vector<const SMDS_MeshNode*> nodes(nbNodes+1);
if(e->IsQuadratic()) {
- const SMDS_QuadraticFaceOfNodes* F =
- static_cast<const SMDS_QuadraticFaceOfNodes*>(e);
+ const SMDS_VtkFace* F =
+ dynamic_cast<const SMDS_VtkFace*>(e);
+ if (!F) throw SALOME_Exception(LOCALIZED("not an SMDS_VtkFace"));
// use special nodes iterator
- SMDS_NodeIteratorPtr anIter = F->interlacedNodesIterator();
+ SMDS_ElemIteratorPtr anIter = F->interlacedNodesElemIterator();
while( anIter->more() ) {
- nodes[ iNode++ ] = anIter->next();
+ nodes[ iNode++ ] = cast2Node(anIter->next());
}
}
else {
else if ( elem->GetType()==SMDSAbs_Face ) { // --face
// retrieve all face nodes and find iPrevNode - an index of the prevSideNode
if(elem->IsQuadratic()) {
- const SMDS_QuadraticFaceOfNodes* F =
- static_cast<const SMDS_QuadraticFaceOfNodes*>(elem);
+ const SMDS_VtkFace* F =
+ dynamic_cast<const SMDS_VtkFace*>(elem);
+ if (!F) throw SALOME_Exception(LOCALIZED("not an SMDS_VtkFace"));
// use special nodes iterator
- SMDS_NodeIteratorPtr anIter = F->interlacedNodesIterator();
+ SMDS_ElemIteratorPtr anIter = F->interlacedNodesElemIterator();
while( anIter->more() ) {
- nodes[ iNode ] = anIter->next();
+ nodes[ iNode ] = cast2Node(anIter->next());
if ( nodes[ iNode++ ] == prevSideNode )
iPrevNode = iNode - 1;
}
vector<const SMDS_MeshNode*> nodes( theFace->NbNodes() );
if(theFace->IsQuadratic()) {
- const SMDS_QuadraticFaceOfNodes* F =
- static_cast<const SMDS_QuadraticFaceOfNodes*>(theFace);
+ const SMDS_VtkFace* F =
+ dynamic_cast<const SMDS_VtkFace*>(theFace);
+ if (!F) throw SALOME_Exception(LOCALIZED("not an SMDS_VtkFace"));
// use special nodes iterator
- SMDS_NodeIteratorPtr anIter = F->interlacedNodesIterator();
+ SMDS_ElemIteratorPtr anIter = F->interlacedNodesElemIterator();
while( anIter->more() ) {
- const SMDS_MeshNode* n = anIter->next();
+ const SMDS_MeshNode* n = cast2Node(anIter->next());
if ( n == theBetweenNode1 )
il1 = iNode;
else if ( n == theBetweenNode2 )
bool isFLN = false;
if(theFace->IsQuadratic()) {
- const SMDS_QuadraticFaceOfNodes* F =
- static_cast<const SMDS_QuadraticFaceOfNodes*>(theFace);
+ const SMDS_VtkFace* F =
+ dynamic_cast<const SMDS_VtkFace*>(theFace);
+ if (!F) throw SALOME_Exception(LOCALIZED("not an SMDS_VtkFace"));
// use special nodes iterator
- SMDS_NodeIteratorPtr anIter = F->interlacedNodesIterator();
+ SMDS_ElemIteratorPtr anIter = F->interlacedNodesElemIterator();
while( anIter->more() && !isFLN ) {
- const SMDS_MeshNode* n = anIter->next();
+ const SMDS_MeshNode* n = cast2Node(anIter->next());
poly_nodes[iNode++] = n;
if (n == nodes[il1]) {
isFLN = true;
}
// add nodes of face starting from last node of link
while ( anIter->more() ) {
- poly_nodes[iNode++] = anIter->next();
+ poly_nodes[iNode++] = cast2Node(anIter->next());
}
}
else {
}
}
else { // f->IsQuadratic()
- const SMDS_QuadraticFaceOfNodes* F =
- static_cast<const SMDS_QuadraticFaceOfNodes*>(f);
+ const SMDS_VtkFace* F =
+ dynamic_cast<const SMDS_VtkFace*>(f);
+ if (!F) throw SALOME_Exception(LOCALIZED("not an SMDS_VtkFace"));
// use special nodes iterator
- SMDS_NodeIteratorPtr anIter = F->interlacedNodesIterator();
+ SMDS_ElemIteratorPtr anIter = F->interlacedNodesElemIterator();
while ( anIter->more() ) {
const SMDS_MeshNode* n =
static_cast<const SMDS_MeshNode*>( anIter->next() );
// creates a corresponding element on existent nodes in new mesh
if ( anElem->IsPoly() && anElemType == SMDSAbs_Volume )
{
- const SMDS_PolyhedralVolumeOfNodes* aVolume =
- dynamic_cast<const SMDS_PolyhedralVolumeOfNodes*> (anElem);
+ const SMDS_VtkVolume* aVolume =
+ dynamic_cast<const SMDS_VtkVolume*> (anElem);
if ( aVolume ) {
aNewElem = aNewMeshDS->AddPolyhedralVolume(aNodesArray,
- aVolume->GetQuanities());
+ aVolume->GetQuantities());
elemsMap.insert(make_pair(anElem->GetID(), aNewElem->GetID()));
if( theCommonGroups )
anIDsVolumes[anNbVolumes++] = aNewElem->GetID();
SMDS_MeshElement* anElemCopy = 0;
if ( anElem->IsPoly() && anElem->GetType() == SMDSAbs_Volume )
{
- const SMDS_PolyhedralVolumeOfNodes* ph =
- dynamic_cast<const SMDS_PolyhedralVolumeOfNodes*> (anElem);
+ const SMDS_VtkVolume* ph =
+ dynamic_cast<const SMDS_VtkVolume*> (anElem);
if ( ph )
anElemCopy = _myMeshDS->AddPolyhedralVolumeWithID
- (anElemNodesID, ph->GetQuanities(),anElem->GetID());
+ (anElemNodesID, ph->GetQuantities(),anElem->GetID());
}
else {
anElemCopy = ::SMESH_MeshEditor(this).AddElement( anElemNodesID,
nodes[6],
nodes[7], id, force3d); break;
default: // polyhedron
- const SMDS_PolyhedralVolumeOfNodes * poly =
- dynamic_cast<const SMDS_PolyhedralVolumeOfNodes*>( srcVol );
+ const SMDS_VtkVolume * poly =
+ dynamic_cast<const SMDS_VtkVolume*>( srcVol );
if ( !poly )
RETURN_BAD_RESULT("Unexpected volume type");
- tgtVol = tgtMeshDS->AddPolyhedralVolume( nodes, poly->GetQuanities() );
+ if ( !poly->IsPoly())
+ RETURN_BAD_RESULT("Unexpected volume type");
+ tgtVol = tgtMeshDS->AddPolyhedralVolume( nodes, poly->GetQuantities() );
}
if ( tgtVol ) {
tgtMeshDS->SetMeshElementOnShape( tgtVol, helper.GetSubShapeID() );