PR: display hexahedron

This commit is contained in:
prascle 2010-01-08 15:53:25 +00:00
parent 7724b590e3
commit 256c68c3f9
18 changed files with 312 additions and 195 deletions

View File

@ -38,6 +38,7 @@ salomeinclude_HEADERS = \
SMDS_Mesh0DElement.hxx \
SMDS_MeshEdge.hxx \
SMDS_MeshElement.hxx \
SMDS_MeshElement.cxx \
SMDS_MeshElementIDFactory.hxx \
SMDS_MeshFace.hxx \
SMDS_MeshGroup.hxx \
@ -53,6 +54,8 @@ salomeinclude_HEADERS = \
SMDS_IteratorOfElements.hxx \
SMDS_VolumeOfFaces.hxx \
SMDS_VolumeOfNodes.hxx \
SMDS_VtkVolume.hxx \
SMDS_VtkCellIterator.hxx \
SMDS_PolyhedralVolumeOfNodes.hxx \
SMDS_FaceOfEdges.hxx \
SMDS_FaceOfNodes.hxx \
@ -72,6 +75,7 @@ lib_LTLIBRARIES = libSMDS.la
dist_libSMDS_la_SOURCES = \
SMDS_MeshObject.cxx \
SMDS_MeshElement.cxx \
SMDS_MeshCell.cxx \
SMDS_Position.cxx \
SMDS_EdgePosition.cxx \
SMDS_FacePosition.cxx \
@ -90,6 +94,8 @@ dist_libSMDS_la_SOURCES = \
SMDS_IteratorOfElements.cxx \
SMDS_VolumeOfFaces.cxx \
SMDS_VolumeOfNodes.cxx \
SMDS_VtkVolume.cxx \
SMDS_VtkCellIterator.cxx \
SMDS_PolyhedralVolumeOfNodes.cxx \
SMDS_FaceOfEdges.cxx \
SMDS_FaceOfNodes.cxx \

View File

@ -60,6 +60,12 @@ verifier ID dans SMDS_Mesh::Find*OrCreate
===================================================
occupation memoire cube 100*100*100 sans affichage
NOTES:
- sur Debian Sarge 64 bits, les mesures malloc_stat() semblent coherentes
avec une mesure externe globale(recherche du passage en swap du process).
- sur Ubuntu 9.10 64 bits, les mesures malloc_stat() donnent des resultats bizarres (surestimation ?),
mais la mesure avec l'outil KDE de surveillance systeme est OK avec la recherche du swap.
Reference : V513 Debian Sarge 64 bits: --> 463 - 33 = 430 Mo
-------------------------------------
@ -175,3 +181,29 @@ system bytes = 429334528
in use bytes = 426424576 : 426M
max mmap regions = 59
max mmap bytes = 184692736
remplacement std::set par std::vector dans SMESHDS_SubMesh --> 347 - 35 = 312M
----------------------------------------------------------
sizeof(SMDS_MeshElement) 24
sizeof(SMDS_MeshNode) 32
sizeof(SMDS_MeshCell) 24
sizeof(SMDS_VolumeVtkNodes) 24
sizeof(SMDS_Position) 16
sizeof(SMDS_SpacePosition) 16
Total (incl. mmap):
system bytes = 45404160
in use bytes = 35132160 --> 35M
max mmap regions = 49
max mmap bytes = 17723392
----
Total (incl. mmap):
system bytes = 349831168
in use bytes = 346885424 --> 347M
max mmap regions = 73
max mmap bytes = 204148736
Ce resultat est coherent avec une recherche de swap sur une machine a 8Go de memoire:
Cube a 270**3 mailles (~20M mailles) --> 6.2 Go (idem Debian Sarge et Ubuntu 9.10, 64 bits)
Le meme avec V5.1.3 --> 14 Go (swap)

View File

@ -123,14 +123,14 @@ SMDS_Mesh::SMDS_Mesh()
MESSAGE("sizeof(SMDS_MeshElement) " << sizeof(SMDS_MeshElement) );
MESSAGE("sizeof(SMDS_MeshNode) " << sizeof(SMDS_MeshNode) );
MESSAGE("sizeof(SMDS_MeshCell) " << sizeof(SMDS_MeshCell) );
MESSAGE("sizeof(SMDS_VolumeVtkNodes) " << sizeof(SMDS_VolumeVtkNodes) );
MESSAGE("sizeof(SMDS_VtkVolume) " << sizeof(SMDS_VtkVolume) );
MESSAGE("sizeof(SMDS_Position) " << sizeof(SMDS_Position) );
MESSAGE("sizeof(SMDS_SpacePosition) " << sizeof(SMDS_SpacePosition) );
myNodeIDFactory->SetMesh(this);
myElementIDFactory->SetMesh(this);
_meshList.push_back(this);
myNodePool = new ObjectPool<SMDS_MeshNode>(SMDS_Mesh::chunkSize);
myVolumePool = new ObjectPool<SMDS_VolumeVtkNodes>(SMDS_Mesh::chunkSize);
myVolumePool = new ObjectPool<SMDS_VtkVolume>(SMDS_Mesh::chunkSize);
myNodes.clear();
myCells.clear();
@ -872,8 +872,7 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
nodeIds.push_back(n7->getId());
nodeIds.push_back(n8->getId());
//volume = new SMDS_VolumeVtkNodes(nodeIds, this);
SMDS_VolumeVtkNodes *volvtk = myVolumePool->getNew();
SMDS_VtkVolume *volvtk = myVolumePool->getNew();
volvtk->init(nodeIds, this);
volume = volvtk;
adjustmyCellsCapacity(ID);

View File

@ -29,6 +29,7 @@
#include "SMESH_SMDS.hxx"
#include "SMDS_MeshNode.hxx"
#include "SMDS_MeshCell.hxx"
#include "SMDS_Mesh0DElement.hxx"
#include "SMDS_MeshEdge.hxx"
#include "SMDS_MeshFace.hxx"
@ -38,6 +39,7 @@
#include "SMDS_MeshInfo.hxx"
#include "SMDS_ElemIterator.hxx"
#include "SMDS_VolumeOfNodes.hxx"
#include "SMDS_VtkVolume.hxx"
#include "ObjectPool.hxx"
#include <boost/shared_ptr.hpp>
@ -52,12 +54,15 @@ class SMDS_EXPORT SMDS_Mesh:public SMDS_MeshObject{
public:
friend class SMDS_MeshElementIDFactory;
friend class SMDS_MeshVolumeVtkNodes;
static std::vector<SMDS_Mesh*> _meshList; // --- to find the SMDS_mesh from its elements
SMDS_Mesh();
//! to retreive this SMDS_Mesh instance from its elements (index stored in SMDS_Elements)
static std::vector<SMDS_Mesh*> _meshList;
//! actual nodes coordinates, cells definition and reverse connectivity are stored in a vtkUnstructuredGrid
inline vtkUnstructuredGrid* getGrid() {return myGrid; };
inline int getMeshId() {return myMeshId; };
SMDS_NodeIteratorPtr nodesIterator() const;
SMDS_0DElementIteratorPtr elements0dIterator() const;
@ -553,7 +558,7 @@ public:
typedef std::vector<SMDS_MeshCell *> SetOfCells;
void updateNodeMinMax();
int fromVtkToSmds(int vtkid) { return myVtkIndex[vtkid]; };
inline int fromVtkToSmds(int vtkid) { return myVtkIndex[vtkid]; };
void incrementNodesCapacity(int nbNodes);
void incrementCellsCapacity(int nbCells);
@ -599,15 +604,29 @@ private:
// Fields PRIVATE
int myMeshId; // --- index for this mesh in the vector
//! index of this SMDS_mesh in the static vector<SMDS_Mesh*> _meshList
int myMeshId;
//! actual nodes coordinates, cells definition and reverse connectivity are stored in a vtkUnstructuredGrid
vtkUnstructuredGrid* myGrid;
//! Small objects like SMDS_MeshNode are allocated by chunks to limit memory costs of new
ObjectPool<SMDS_MeshNode>* myNodePool;
ObjectPool<SMDS_VolumeVtkNodes>* myVolumePool;
//! Small objects like SMDS_VtkVolume are allocated by chunks to limit memory costs of new
ObjectPool<SMDS_VtkVolume>* myVolumePool;
//! SMDS_MeshNodes refer to vtk nodes (vtk id = index in myNodes),store reference to this mesh, and subshape
SetOfNodes myNodes;
//! SMDS_MeshCells refer to vtk cells (vtk id != index in myCells),store reference to this mesh, and subshape
SetOfCells myCells;
std::vector<int> myIDElements; // index = ID client, value = ID vtk
std::vector<int> myVtkIndex; // index = ID vtk, value = ID client
//! for cells only: index = ID for SMDS users, value = ID in vtkUnstructuredGrid
std::vector<int> myIDElements;
//! for cells only: index = ID in vtkUnstructuredGrid, value = ID for SMDS users
std::vector<int> myVtkIndex;
SMDS_Mesh * myParent;
std::list<SMDS_Mesh *> myChildren;

View File

@ -28,7 +28,7 @@
#include "SMESH_SMDS.hxx"
#include "SMDS_MeshElement.hxx"
#include "SMDS_MeshCell.hxx"
#include <iostream>

View File

@ -0,0 +1,19 @@
#include "SMDS_MeshCell.hxx"
#include "utilities.h"
using namespace std;
int SMDS_MeshCell::nbCells = 0;
SMDS_MeshCell::SMDS_MeshCell() : SMDS_MeshElement(-1)
{
nbCells++;
myVtkID = -1;
};
SMDS_MeshCell::~SMDS_MeshCell()
{
nbCells--;
}

View File

@ -0,0 +1,22 @@
#ifndef _SMDS_MESHCELL_HXX_
#define _SMDS_MESHCELL_HXX_
#include "SMDS_MeshElement.hxx"
/*!
* \brief Base class for all cells
*/
class SMDS_EXPORT SMDS_MeshCell:public SMDS_MeshElement
{
public:
SMDS_MeshCell();
virtual ~SMDS_MeshCell();
inline void setVtkId(int vtkId) { myVtkID = vtkId; };
inline int getVtkId() const {return myVtkID; };
static int nbCells;
protected:
int myVtkID;
};
#endif

View File

@ -28,7 +28,7 @@
#include "SMESH_SMDS.hxx"
#include "SMDS_MeshElement.hxx"
#include "SMDS_MeshCell.hxx"
#include <iostream>
class SMDS_EXPORT SMDS_MeshEdge:public SMDS_MeshCell

View File

@ -34,8 +34,6 @@
using namespace std;
int SMDS_MeshCell::nbCells = 0;
SMDS_MeshElement::SMDS_MeshElement(int ID):myID(ID), myMeshId(-1), myShapeId(-1), myIdInShape(-1)
{
}
@ -245,14 +243,3 @@ int SMDS_MeshElement::GetNodeIndex( const SMDS_MeshNode* node ) const
return i;
return -1;
}
SMDS_MeshCell::SMDS_MeshCell() : SMDS_MeshElement(-1)
{
nbCells++;
myVtkID = -1;
};
SMDS_MeshCell::~SMDS_MeshCell()
{
nbCells--;
}

View File

@ -146,24 +146,6 @@ protected:
int myIdInShape;
};
// ============================================================
/*!
* \brief Base class for all cells
*/
// ============================================================
class SMDS_EXPORT SMDS_MeshCell:public SMDS_MeshElement
{
public:
SMDS_MeshCell();
virtual ~SMDS_MeshCell();
inline void setVtkId(int vtkId) { myVtkID = vtkId; };
inline int getVtkId() const {return myVtkID; };
static int nbCells;
protected:
int myVtkID;
};
// ============================================================
/*!

View File

@ -28,7 +28,7 @@
#include "SMESH_SMDS.hxx"
#include "SMDS_MeshElement.hxx"
#include "SMDS_MeshCell.hxx"
class SMDS_EXPORT SMDS_MeshFace:public SMDS_MeshCell
{

View File

@ -28,7 +28,7 @@
#include "SMESH_SMDS.hxx"
#include "SMDS_MeshElement.hxx"
#include "SMDS_MeshCell.hxx"
class SMDS_EXPORT SMDS_MeshVolume:public SMDS_MeshCell
{

View File

@ -32,10 +32,6 @@
#include "SMDS_Mesh.hxx"
#include "utilities.h"
#include <vtkCell.h>
#include <vector>
using namespace std;
///////////////////////////////////////////////////////////////////////////////
@ -254,116 +250,3 @@ SMDSAbs_EntityType SMDS_VolumeOfNodes::GetEntityType() const
}
// *************************************************************************************
//
SMDS_VolumeVtkNodes::SMDS_VolumeVtkNodes()
{
}
SMDS_VolumeVtkNodes::SMDS_VolumeVtkNodes(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh)
{
init(nodeIds, mesh);
}
void SMDS_VolumeVtkNodes::init(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh)
{
vtkUnstructuredGrid* grid = mesh->getGrid();
myVtkID = grid->InsertNextLinkedCell(GetType(), nodeIds.size(), &nodeIds[0]);
}
bool SMDS_VolumeVtkNodes::ChangeNodes(const SMDS_MeshNode* nodes[],
const int nbNodes)
{
// utilise dans SMDS_Mesh
return true;
}
SMDS_VolumeVtkNodes::~SMDS_VolumeVtkNodes()
{
}
void SMDS_VolumeVtkNodes::Print(ostream & OS) const
{
OS << "volume <" << GetID() << "> : ";
}
int SMDS_VolumeVtkNodes::NbFaces() const
{
switch(NbNodes())
{
case 4: return 4;
case 5: return 5;
case 6: return 5;
case 8: return 6;
default: MESSAGE("invalid number of nodes");
}
return 0;
}
int SMDS_VolumeVtkNodes::NbNodes() const
{
vtkUnstructuredGrid* grid =SMDS_Mesh::_meshList[myMeshId]->getGrid();
int nbPoints = grid->GetCell(myVtkID)->GetNumberOfPoints();
return nbPoints;
}
int SMDS_VolumeVtkNodes::NbEdges() const
{
switch(NbNodes())
{
case 4: return 6;
case 5: return 8;
case 6: return 9;
case 8: return 12;
default: MESSAGE("invalid number of nodes");
}
return 0;
}
SMDS_ElemIteratorPtr SMDS_VolumeVtkNodes::elementsIterator(SMDSAbs_ElementType type) const
{
switch(type)
{
// case SMDSAbs_Volume:
// return SMDS_MeshElement::elementsIterator(SMDSAbs_Volume);
// case SMDSAbs_Node:
// return SMDS_ElemIteratorPtr(new SMDS_VolumeVtkNodes_MyIterator(myNodes,myNbNodes));
// case SMDSAbs_Face:
// return SMDS_ElemIteratorPtr(new _MySubWNIterator(this,SMDSAbs_Face));
// case SMDSAbs_Edge:
// return SMDS_ElemIteratorPtr(new _MySubWNIterator(this,SMDSAbs_Edge));
default:
MESSAGE("ERROR : Iterator not implemented");
return SMDS_ElemIteratorPtr((SMDS_ElemIterator*)NULL);
}
}
SMDSAbs_ElementType SMDS_VolumeVtkNodes::GetType() const
{
return SMDSAbs_Volume;
}
/*!
* \brief Return node by its index
* \param ind - node index
* \retval const SMDS_MeshNode* - the node
*/
const SMDS_MeshNode* SMDS_VolumeVtkNodes::GetNode(const int ind) const
{
return 0;
}
SMDSAbs_EntityType SMDS_VolumeVtkNodes::GetEntityType() const
{
SMDSAbs_EntityType aType = SMDSEntity_Tetra;
switch(NbNodes())
{
case 4: aType = SMDSEntity_Tetra; break;
case 5: aType = SMDSEntity_Pyramid; break;
case 6: aType = SMDSEntity_Penta; break;
case 8:
default: aType = SMDSEntity_Hexa; break;
}
return aType;
}

View File

@ -29,8 +29,6 @@
#include "SMESH_SMDS.hxx"
#include "SMDS_MeshVolume.hxx"
#include <vtkUnstructuredGrid.h>
#include <vector>
class SMDS_EXPORT SMDS_VolumeOfNodes:public SMDS_MeshVolume
{
@ -89,34 +87,4 @@ class SMDS_EXPORT SMDS_VolumeOfNodes:public SMDS_MeshVolume
};
class SMDS_EXPORT SMDS_VolumeVtkNodes:public SMDS_MeshVolume
{
public:
SMDS_VolumeVtkNodes();
SMDS_VolumeVtkNodes(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh);
~SMDS_VolumeVtkNodes();
void init(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh);
bool ChangeNodes(const SMDS_MeshNode* nodes[],
const int nbNodes);
void Print(std::ostream & OS) const;
int NbFaces() const;
int NbNodes() const;
int NbEdges() const;
virtual SMDSAbs_ElementType GetType() const;
virtual SMDSAbs_EntityType GetEntityType() const;
/*!
* \brief Return node by its index
* \param ind - node index
* \retval const SMDS_MeshNode* - the node
*/
virtual const SMDS_MeshNode* GetNode(const int ind) const;
protected:
SMDS_ElemIteratorPtr
elementsIterator(SMDSAbs_ElementType type) const;
};
#endif

View File

@ -0,0 +1,21 @@
#include "SMDS_VtkCellIterator.hxx"
SMDS_VtkCellIterator::SMDS_VtkCellIterator(SMDS_Mesh* mesh, int vtkCellId):
_mesh(mesh), _cellId(vtkCellId), _index(0)
{
vtkUnstructuredGrid* grid = _mesh->getGrid();
_vtkIdList = grid->GetCell(_cellId)->GetPointIds();
_nbNodes = _vtkIdList->GetNumberOfIds();
}
bool SMDS_VtkCellIterator::more()
{
return (_index < _nbNodes);
}
const SMDS_MeshElement* SMDS_VtkCellIterator::next()
{
vtkIdType id = _vtkIdList->GetId(_index++);
return _mesh->FindNode(id);
}

View File

@ -0,0 +1,24 @@
#ifndef _SMDS_VTKCELLITERATOR_HXX_
#define _SMDS_VTKCELLITERATOR_HXX_
#include "SMDS_ElemIterator.hxx"
#include "SMDS_Mesh.hxx"
#include <vtkCell.h>
#include <vtkIdList.h>
class SMDS_VtkCellIterator : public SMDS_ElemIterator
{
public:
SMDS_VtkCellIterator(SMDS_Mesh* mesh, int vtkCellId);
virtual bool more();
virtual const SMDS_MeshElement* next();
protected:
SMDS_Mesh* _mesh;
int _cellId;
int _index;
int _nbNodes;
vtkIdList* _vtkIdList;
};
#endif

116
src/SMDS/SMDS_VtkVolume.cxx Normal file
View File

@ -0,0 +1,116 @@
#include "SMDS_VtkVolume.hxx"
#include "SMDS_MeshNode.hxx"
#include "SMDS_Mesh.hxx"
#include "SMDS_VtkCellIterator.hxx"
#include "utilities.h"
#include <vector>
SMDS_VtkVolume::SMDS_VtkVolume()
{
}
SMDS_VtkVolume::SMDS_VtkVolume(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh)
{
init(nodeIds, mesh);
}
void SMDS_VtkVolume::init(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh)
{
vtkUnstructuredGrid* grid = mesh->getGrid();
myMeshId = mesh->getMeshId();
myVtkID = grid->InsertNextLinkedCell(GetType(), nodeIds.size(), &nodeIds[0]);
}
bool SMDS_VtkVolume::ChangeNodes(const SMDS_MeshNode* nodes[],
const int nbNodes)
{
// utilise dans SMDS_Mesh
return true;
}
SMDS_VtkVolume::~SMDS_VtkVolume()
{
}
void SMDS_VtkVolume::Print(ostream & OS) const
{
OS << "volume <" << GetID() << "> : ";
}
int SMDS_VtkVolume::NbFaces() const
{
switch(NbNodes())
{
case 4: return 4;
case 5: return 5;
case 6: return 5;
case 8: return 6;
default: MESSAGE("invalid number of nodes");
}
return 0;
}
int SMDS_VtkVolume::NbNodes() const
{
vtkUnstructuredGrid* grid =SMDS_Mesh::_meshList[myMeshId]->getGrid();
int nbPoints = grid->GetCell(myVtkID)->GetNumberOfPoints();
return nbPoints;
}
int SMDS_VtkVolume::NbEdges() const
{
switch(NbNodes())
{
case 4: return 6;
case 5: return 8;
case 6: return 9;
case 8: return 12;
default: MESSAGE("invalid number of nodes");
}
return 0;
}
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));
default:
MESSAGE("ERROR : Iterator not implemented");
return SMDS_ElemIteratorPtr((SMDS_ElemIterator*)NULL);
}
}
SMDSAbs_ElementType SMDS_VtkVolume::GetType() const
{
return SMDSAbs_Volume;
}
/*!
* \brief Return node by its index
* \param ind - node index
* \retval const SMDS_MeshNode* - the node
*/
const SMDS_MeshNode* SMDS_VtkVolume::GetNode(const int ind) const
{
return 0;
}
SMDSAbs_EntityType SMDS_VtkVolume::GetEntityType() const
{
SMDSAbs_EntityType aType = SMDSEntity_Tetra;
switch(NbNodes())
{
case 4: aType = SMDSEntity_Tetra; break;
case 5: aType = SMDSEntity_Pyramid; break;
case 6: aType = SMDSEntity_Penta; break;
case 8:
default: aType = SMDSEntity_Hexa; break;
}
return aType;
}

View File

@ -0,0 +1,39 @@
#ifndef _SMDS_VTKVOLUME_HXX_
#define _SMDS_VTKVOLUME_HXX_
#include "SMESH_SMDS.hxx"
#include "SMDS_MeshVolume.hxx"
#include <vtkUnstructuredGrid.h>
#include <vector>
class SMDS_EXPORT SMDS_VtkVolume:public SMDS_MeshVolume
{
public:
SMDS_VtkVolume();
SMDS_VtkVolume(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh);
~SMDS_VtkVolume();
void init(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh);
bool ChangeNodes(const SMDS_MeshNode* nodes[],
const int nbNodes);
void Print(std::ostream & OS) const;
int NbFaces() const;
int NbNodes() const;
int NbEdges() const;
virtual SMDSAbs_ElementType GetType() const;
virtual SMDSAbs_EntityType GetEntityType() const;
/*!
* \brief Return node by its index
* \param ind - node index
* \retval const SMDS_MeshNode* - the node
*/
virtual const SMDS_MeshNode* GetNode(const int ind) const;
protected:
SMDS_ElemIteratorPtr
elementsIterator(SMDSAbs_ElementType type) const;
};
#endif