ajouter ID dans SMDS_Mesh::createTriangle
verifier ID dans SMDS_Mesh::Find*OrCreate
-========================
+===================================================
occupation memoire cube 100*100*100 sans affichage
-Ubuntu 9.10 64 bits 15/12/2009
-/home/prascle/projets/SALOME/SMESH/BR_SMDS_MEMIMP/SMESH_SRC/src/SMESH/SMESH_Gen.cxx:143
-in use bytes = 32843200
-/home/prascle/projets/SALOME/SMESH/BR_SMDS_MEMIMP/SMESH_SRC/src/SMESH/SMESH_Gen.cxx [294] : VSR - SMESH_Gen::Compute() finished, OK = 1
-in use bytes = 498773760
-delta = 460 Mo (45 Mo de plus que sur Sarge 64 bits ?)
-
-Debian Sarge 64 bits
-in use bytes = 17076352
-in use bytes = 431600032
-delta = 415 Mo
+Reference : V513 Debian Sarge 64 bits: --> 463 - 33 = 430 Mo
+-------------------------------------
+Total (incl. mmap):
+system bytes = 43757568
+in use bytes = 32909584 = 33M
+max mmap regions = 41
+max mmap bytes = 16371712
+----
+Total (incl. mmap):
+system bytes = 464670720
+in use bytes = 463105120 = 463M
+max mmap regions = 47
+max mmap bytes = 28188672
+
+Debian Sarge 64 bits, vtkUnstructuredGrid nodes et hexa, 4 janvier 2010 --> 512 - 41 = 471M
+-----------------------------------
+
+Total (incl. mmap):
+system bytes = 52133888
+in use bytes = 41340320 : 41M
+max mmap regions = 72
+max mmap bytes = 24625152
+----
+Total (incl. mmap):
+system bytes = 520560640
+in use bytes = 518735584 : 512M
+max mmap regions = 88
+max mmap bytes = 198385664
+
+idem avec pool SMDS_MeshNodes --> 483 -33 = 450M
+-----------------------------
+Total (incl. mmap):
+system bytes = 43696128
+in use bytes = 32915184 : 33M
+max mmap regions = 41
+max mmap bytes = 16371712
+----
+Total (incl. mmap):
+system bytes = 484806656
+in use bytes = 482980992 : 483M
+max mmap regions = 58
+max mmap bytes = 184557568
+
+idem ci-dessus + pool SMDS_VolumeVtkNodes --> 475 -33 = 442M (git: add ObjectPool.hxx)
+-----------------------------------------
+
+Total (incl. mmap):
+system bytes = 43200512
+in use bytes = 32908576 : 33M
+max mmap regions = 41
+max mmap bytes = 16371712
+----
+Total (incl. mmap):
+system bytes = 478068736
+in use bytes = 475144400 : 475M
+max mmap regions = 59
+max mmap bytes = 184692736
+
+remplacement SMDS_PositionPtr: (boost::shared_ptr<SMDS_Position> --> SMDS_Position*) --> 436 - 35 = 401M (git SMDS_Position)
+------------------------------------------------------------------------------------
+Total (incl. mmap):
+system bytes = 45408256
+in use bytes = 35097680 : 35M
+max mmap regions = 47
+max mmap bytes = 18116608
+----
+Total (incl. mmap):
+system bytes = 438935552
+in use bytes = 436116560 : 436M
+max mmap regions = 65
+max mmap bytes = 186437632
+
+simplification SMDS_SpacePosition (pas de double[3]) --> 418 -33 = 385M (git SMDS_SpacePosition)
+----------------------------------------------------
+Total (incl. mmap):
+system bytes = 42582016
+in use bytes = 32883552 : 33M
+max mmap regions = 41
+max mmap bytes = 16371712
+----
+Total (incl. mmap):
+system bytes = 421728256
+in use bytes = 418378000 : 418M
+max mmap regions = 58
+max mmap bytes = 183640064
+
--- /dev/null
+
+#ifndef _OBJECTPOOL_HXX_
+#define _OBJECTPOOL_HXX_
+
+#include <vector>
+#include <stack>
+#include <iostream>
+
+template <class X> class ObjectPool
+{
+
+private:
+ std::vector<X*> _chunkList;
+ std::vector<bool> _freeList;
+ int _nextFree;
+ int _maxAvail;
+ int _chunkSize;
+
+ int getNextFree()
+ {
+ for (int i=_nextFree; i< _maxAvail; i++)
+ if (_freeList[i] == true)
+ {
+ return i;
+ break;
+ }
+ return _maxAvail;
+ }
+
+ void checkDelete(int chunkId)
+ {
+ int i0 = _chunkSize*chunkId;
+ int i1 =_chunkSize*(chunkId+1);
+ for (int i=i0; i < i1; i++)
+ if (_freeList[i] == false)
+ return;
+ std::cerr << "a chunk to delete" << std::endl;
+ // compactage des vecteurs un peu lourd, pas necessaire
+ //X* chunk = _chunkList[chunkId];
+ //delete [] chunk;
+ }
+
+public:
+ ObjectPool(int nblk)
+ {
+ _chunkSize = nblk;
+ _nextFree = 0;
+ _maxAvail = 0;
+ _chunkList.clear();
+ _freeList.clear();
+ }
+
+ virtual ~ObjectPool()
+ {
+ for (int i=0; i<_chunkList.size(); i++)
+ delete [] _chunkList[i];
+ }
+
+ X* getNew()
+ {
+ X *obj = 0;
+ _nextFree = getNextFree();
+ if (_nextFree == _maxAvail)
+ {
+ X* newChunk = new X[_chunkSize];
+ _chunkList.push_back(newChunk);
+ _freeList.insert(_freeList.end(), _chunkSize, true);
+ _maxAvail += _chunkSize;
+ _freeList[_nextFree] = false;
+ obj = newChunk; // &newChunk[0];
+ }
+ else
+ {
+ int chunkId = _nextFree/_chunkSize;
+ int rank = _nextFree - chunkId*_chunkSize;
+ _freeList[_nextFree] = false;
+ obj = _chunkList[chunkId] + rank; // &_chunkList[chunkId][rank];
+ }
+ //obj->init();
+ return obj;
+ }
+
+ void destroy(X* obj)
+ {
+ long adrobj = (long)(obj);
+ for (int i=0; i< _chunkList.size(); i++)
+ {
+ X* chunk = _chunkList[i];
+ long adrmin = (long)(chunk);
+ if (adrobj < adrmin) continue;
+ long adrmax = (long)(chunk + _chunkSize);
+ if (adrobj >= adrmax) continue;
+ int rank = (adrobj -adrmin)/sizeof(X);
+ int toFree = i*_chunkSize + rank;
+ _freeList[toFree] = true;
+ if (toFree < _nextFree) _nextFree = toFree;
+ //obj->clean();
+ //checkDelete(i); compactage non fait
+ break;
+ }
+ }
+
+};
+
+#endif
#define CHECKMEMORY_INTERVAL 1000
vector<SMDS_Mesh*> SMDS_Mesh::_meshList = vector<SMDS_Mesh*>();
-int SMDS_Mesh::chunkSize = 1000;
+int SMDS_Mesh::chunkSize = 1024;
+
//================================================================================
/*!
myElementIDFactory(new SMDS_MeshElementIDFactory()),
myHasConstructionEdges(false), myHasConstructionFaces(false),
myHasInverseElements(true),
- myNodeMin(0), myNodeMax(0), myCellLinksSize(0)
+ myNodeMin(0), myNodeMax(0), myCellLinksSize(0),
+ myNodePool(0), myVolumePool(0)
{
myMeshId = _meshList.size(); // --- index of the mesh to push back in the vector
MESSAGE("myMeshId=" << myMeshId);
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);
+
myNodes.clear();
myCells.clear();
+ myIDElements.clear();
+ myVtkIndex.clear();
myGrid = vtkUnstructuredGrid::New();
myGrid->Initialize();
myGrid->Allocate();
///////////////////////////////////////////////////////////////////////////////
SMDS_Mesh::SMDS_Mesh(SMDS_Mesh * parent)
:myParent(parent), myNodeIDFactory(parent->myNodeIDFactory),
- myElementIDFactory(parent->myElementIDFactory),
- myHasConstructionEdges(false), myHasConstructionFaces(false),
- myHasInverseElements(true)
+ myElementIDFactory(parent->myElementIDFactory),
+ myHasConstructionEdges(false), myHasConstructionFaces(false),
+ myHasInverseElements(true),
+ myNodePool(parent->myNodePool),
+ myVolumePool(parent->myVolumePool)
{
}
const SMDS_MeshElement *node = myNodeIDFactory->MeshElement(ID);
if(!node){
//if ( myNodes.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
- SMDS_MeshNode * node=new SMDS_MeshNode(ID, myMeshId, -1, x, y, z);
+ //SMDS_MeshNode * node=new SMDS_MeshNode(ID, myMeshId, -1, x, y, z);
+ SMDS_MeshNode * node = myNodePool->getNew();
+ node->init(ID, myMeshId, -1, x, y, z);
if (ID >= myNodes.size())
{
myNodes.resize(ID+SMDS_Mesh::chunkSize, 0);
return NULL;
}
else {
-// volume=new SMDS_HexahedronOfNodes(n1,n2,n3,n4,n5,n6,n7,n8);
- volume=new SMDS_VolumeOfNodes(n1,n2,n3,n4,n5,n6,n7,n8);
+ // --- retreive nodes ID
+ vector<vtkIdType> nodeIds;
+ nodeIds.clear();
+ nodeIds.push_back(n1->getId());
+ nodeIds.push_back(n2->getId());
+ nodeIds.push_back(n3->getId());
+ nodeIds.push_back(n4->getId());
+ nodeIds.push_back(n5->getId());
+ nodeIds.push_back(n6->getId());
+ nodeIds.push_back(n7->getId());
+ nodeIds.push_back(n8->getId());
+
+ //volume = new SMDS_VolumeVtkNodes(nodeIds, this);
+ SMDS_VolumeVtkNodes *volvtk = myVolumePool->getNew();
+ volvtk->init(nodeIds, this);
+ volume = volvtk;
adjustmyCellsCapacity(ID);
myCells[ID] = volume;
myInfo.myNbHexas++;
}
-
+
if (!registerElement(ID, volume)) {
RemoveElement(volume, false);
volume = NULL;
///////////////////////////////////////////////////////////////////////////////
/// Registers element with the given ID, maintains inverse connections
///////////////////////////////////////////////////////////////////////////////
-bool SMDS_Mesh::registerElement(int ID, SMDS_MeshElement * element)
+bool SMDS_Mesh::registerElement(int ID, SMDS_MeshElement* element)
{
- //MESSAGE("registerElement " << ID)
- if (myElementIDFactory->BindID(ID, element)) {
- return true;
+ //MESSAGE("registerElement " << ID)
+ if ((ID < myIDElements.size()) && myIDElements[ID] >= 0) // --- already bound
+ {
+ MESSAGE(" --------------------------------- already bound "<< ID << " " << myIDElements[ID]);
+ return false;
}
- MESSAGE("BindID " << ID << " false!---------------");
- return false;
+
+ element->myID = ID;
+ element->myMeshId = myMeshId;
+
+ SMDS_MeshCell *cell = dynamic_cast<SMDS_MeshCell*>(element);
+ assert(cell);
+ int vtkId = cell->getVtkId();
+ if (vtkId == -1)
+ vtkId = myElementIDFactory->SetInVtkGrid(element);
+
+ if (ID >= myIDElements.size()) // --- resize local vector
+ {
+ MESSAGE(" ------------------- resize myIDElements " << ID << " --> " << ID + SMDS_Mesh::chunkSize);
+ myIDElements.resize(ID + SMDS_Mesh::chunkSize, -1); // fill new elements with -1
+ }
+
+ myIDElements[ID] = vtkId;
+ //MESSAGE("smds:" << ID << " vtk:" << cellId );
+
+ if (vtkId >= myVtkIndex.size()) // --- resize local vector
+ {
+ MESSAGE(" --------------------- resize myVtkIndex " << vtkId << " --> " << vtkId + SMDS_Mesh::chunkSize);
+ myVtkIndex.resize(vtkId + SMDS_Mesh::chunkSize, -1);
+ }
+ myVtkIndex[vtkId] = ID;
+
+ myElementIDFactory->updateMinMax(ID);
+ return true;
}
///////////////////////////////////////////////////////////////////////////////
while (!myNodes[myNodeMax] && (myNodeMin>=0))
myNodeMin--;
}
+
+void SMDS_Mesh::incrementNodesCapacity(int nbNodes)
+{
+ int val = myIDElements.size();
+ MESSAGE(" ------------------- resize myIDElements " << val << " --> " << val + nbNodes);
+ myIDElements.resize(val + nbNodes, -1); // fill new elements with -1
+ val = myNodes.size();
+ MESSAGE(" ------------------- resize myNodes " << val << " --> " << val + nbNodes);
+ myNodes.resize(val +nbNodes, 0);
+}
+
+void SMDS_Mesh::incrementCellsCapacity(int nbCells)
+{
+ int val = myVtkIndex.size();
+ MESSAGE(" ------------------- resize myVtkIndex " << val << " --> " << val + nbCells);
+ myVtkIndex.resize(val + nbCells, -1); // fill new elements with -1
+ val = myCells.size();
+ MESSAGE(" ------------------- resize myCells " << val << " --> " << val + nbCells);
+ myNodes.resize(val +nbCells, 0);
+}
#include "SMDS_MeshElementIDFactory.hxx"
#include "SMDS_MeshInfo.hxx"
#include "SMDS_ElemIterator.hxx"
+#include "SMDS_VolumeOfNodes.hxx"
+#include "ObjectPool.hxx"
#include <boost/shared_ptr.hpp>
#include <set>
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();
typedef std::vector<SMDS_MeshCell *> SetOfCells;
void updateNodeMinMax();
- int fromVtkToSmds(int vtkid) { return myElementIDFactory->fromVtkToSmds(vtkid); };
+ int fromVtkToSmds(int vtkid) { return myVtkIndex[vtkid]; };
+ void incrementNodesCapacity(int nbNodes);
+ void incrementCellsCapacity(int nbCells);
+
int myCellLinksSize;
static int chunkSize;
int myMeshId; // --- index for this mesh in the vector
vtkUnstructuredGrid* myGrid;
-
+ ObjectPool<SMDS_MeshNode>* myNodePool;
+ ObjectPool<SMDS_VolumeVtkNodes>* myVolumePool;
SetOfNodes myNodes;
SetOfCells myCells;
-
-// SetOf0DElements my0DElements;
-// SetOfEdges myEdges;
-// SetOfFaces myFaces;
-// SetOfVolumes myVolumes;
+ std::vector<int> myIDElements; // index = ID client, value = ID vtk
+ std::vector<int> myVtkIndex; // index = ID vtk, value = ID client
SMDS_Mesh * myParent;
std::list<SMDS_Mesh *> myChildren;
using namespace std;
-SMDS_MeshElement::SMDS_MeshElement(int ID):myID(ID)
+int SMDS_MeshCell::nbCells = 0;
+
+SMDS_MeshElement::SMDS_MeshElement(int ID):myID(ID), myMeshId(-1), myShapeId(-1)
{
}
SMDS_MeshCell::SMDS_MeshCell()
{
- myVtkID = -1;
-};
\ No newline at end of file
+ nbCells++;
+ myVtkID = -1;
+};
+
+SMDS_MeshCell::~SMDS_MeshCell()
+{
+ nbCells--;
+}
\ No newline at end of file
class SMDS_MeshNode;
class SMDS_MeshEdge;
-class SMDS_MeshFace;
+class SMDS_MeshFace;
+class SMDS_Mesh;
// ============================================================
/*!
virtual bool IsMediumNode(const SMDS_MeshNode* node) const;
friend SMDS_EXPORT std::ostream & operator <<(std::ostream & OS, const SMDS_MeshElement *);
- friend SMDS_EXPORT bool SMDS_MeshElementIDFactory::BindID(int ID,SMDS_MeshElement*elem);
+ friend SMDS_EXPORT bool SMDS_MeshElementIDFactory::BindID(int ID,SMDS_MeshElement* elem);
+ friend class SMDS_Mesh;
// ===========================
// Access to nodes by index
*/
int GetNodeIndex( const SMDS_MeshNode* node ) const;
- inline int getId() {return myID; };
+ inline int getId() const {return myID; };
inline UShortType getMeshId() {return myMeshId; };
inline ShortType getshapeId() {return myShapeId; };
inline void setShapeId(UShortType shapeId) {myShapeId = shapeId; };
virtual void Print(std::ostream & OS) const;
int myID; // --- element index
- UShortType myMeshId;
+ ShortType myMeshId;
ShortType myShapeId;
};
{
public:
SMDS_MeshCell();
- inline void setVtkId(int vtkId) { myVtkID = vtkId; };
+ virtual ~SMDS_MeshCell();
+ inline void setVtkId(int vtkId) { myVtkID = vtkId; };
inline int getVtkId() const {return myVtkID; };
+ static int nbCells;
protected:
int myVtkID;
};
SMDS_MeshElementIDFactory::SMDS_MeshElementIDFactory():
SMDS_MeshNodeIDFactory()
{
- myIDElements.clear();
- myVtkIndex.clear();
+// myIDElements.clear();
+// myVtkIndex.clear();
myVtkCellTypes.clear();
myVtkCellTypes.reserve(SMDSEntity_Last);
myVtkCellTypes[SMDSEntity_Node] = VTK_VERTEX;
myVtkCellTypes[SMDSEntity_Quad_Polyhedra] = VTK_CONVEX_POINT_SET;
}
-//=======================================================================
-//function : BindID
-//purpose :
-//=======================================================================
-bool SMDS_MeshElementIDFactory::BindID(int ID, SMDS_MeshElement * elem)
+int SMDS_MeshElementIDFactory::SetInVtkGrid(SMDS_MeshElement * elem)
{
- if ((ID < myIDElements.size()) && myIDElements[ID] >= 0) // --- already bound
- {
- MESSAGE(" --------------------------------- already bound "<< ID << " " << myIDElements[ID]);
- return false;
- }
-
- if (ID >= myIDElements.size()) // --- resize local vector
- {
- //MESSAGE(" ------------------- resize myIDElements " << ID << " --> " << ID+SMDS_Mesh::chunkSize);
- myIDElements.resize(ID+SMDS_Mesh::chunkSize,-1); // fill new elements with -1
- }
-
- // --- retreive nodes ID
+ // --- retreive nodes ID
vector<vtkIdType> nodeIds;
SMDS_ElemIteratorPtr it = elem->nodesIterator();
vtkUnstructuredGrid * grid = myMesh->getGrid();
int typ = GetVtkCellType(elem->GetType());
int cellId = grid->InsertNextLinkedCell(typ, nodeIds.size(), &nodeIds[0]);
-
- // --- fill local vector
-
- myIDElements[ID] = cellId;
- //MESSAGE("smds:" << ID << " vtk:" << cellId );
-
- if (cellId >= myVtkIndex.size()) // --- resize local vector
- {
- //MESSAGE(" --------------------- resize myVtkIndex " << cellId << " --> " << cellId+SMDS_Mesh::chunkSize);
- myVtkIndex.resize(cellId+SMDS_Mesh::chunkSize, -1);
- }
- myVtkIndex[cellId] = ID;
-
- elem->myID=ID;
SMDS_MeshCell *cell = dynamic_cast<SMDS_MeshCell*>(elem);
assert(cell);
- cell->setVtkId(cellId);
- updateMinMax (ID);
- return true;
+ cell->setVtkId(cellId);
+ //MESSAGE("SMDS_MeshElementIDFactory::SetInVtkGrid " << cellId);
+ return cellId;
+}
+
+//=======================================================================
+//function : BindID
+//purpose :
+//=======================================================================
+
+bool SMDS_MeshElementIDFactory::BindID(int ID, SMDS_MeshElement * elem)
+{
+ MESSAGE("SMDS_MeshElementIDFactory::BindID " << ID);
+ SetInVtkGrid(elem);
+ return myMesh->registerElement(ID, elem);
}
//=======================================================================
//=======================================================================
SMDS_MeshElement* SMDS_MeshElementIDFactory::MeshElement(int ID)
{
- if ((ID<0) || (ID>myMax) || (myIDElements[ID]<0))
+ if ((ID<0) || (ID>myMax) || (myMesh->myIDElements[ID]<0))
return NULL;
const SMDS_MeshElement* elem = GetMesh()->FindElement(ID);
return (SMDS_MeshElement*)(elem);
//=======================================================================
void SMDS_MeshElementIDFactory::ReleaseID(const int ID)
{
- myIDElements[ID] = -1;
+ myMesh->myIDElements[ID] = -1;
SMDS_MeshIDFactory::ReleaseID(ID);
if (ID == myMax)
myMax = 0;
{
myMin = IntegerLast();
myMax = 0;
- for (int i=0; i<myIDElements.size(); i++)
- if (int id=myIDElements[i] >=0)
+ for (int i=0; i<myMesh->myIDElements.size(); i++)
+ if (int id=myMesh->myIDElements[i] >=0)
{
if (id > myMax) myMax = id;
if (id < myMin) myMin = id;
void SMDS_MeshElementIDFactory::Clear()
{
- myIDElements.clear();
+ myMesh->myIDElements.clear();
myMin = myMax = 0;
SMDS_MeshIDFactory::Clear();
}
#include <vector>
class SMDS_MeshElement;
+class SMDS_Mesh;
class SMDS_EXPORT SMDS_MeshElementIDFactory:public SMDS_MeshNodeIDFactory
{
public:
+ friend class SMDS_Mesh;
+
SMDS_MeshElementIDFactory();
bool BindID(int ID, SMDS_MeshElement * elem);
+ int SetInVtkGrid(SMDS_MeshElement * elem);
SMDS_MeshElement * MeshElement(int ID);
virtual void ReleaseID(int ID);
SMDS_ElemIteratorPtr elementsIterator() const;
virtual void Clear();
int GetVtkCellType(int SMDSType);
- int fromVtkToSmds(int vtkid) { return myVtkIndex[vtkid]; };
protected:
void updateMinMax() const;
if (id < myMin) myMin = id;
}
- std::vector<int> myIDElements; // index = ID client, value = ID vtk
- std::vector<int> myVtkIndex; // index = ID vtk, value = ID client
std::vector<int> myVtkCellTypes;
};
using namespace std;
+int SMDS_MeshNode::nbNodes =0;
+
//=======================================================================
//function : SMDS_MeshNode
//purpose :
//=======================================================================
+SMDS_MeshNode::SMDS_MeshNode() :
+ SMDS_MeshElement(-1, -1, -1),
+ myPosition(SMDS_SpacePosition::originSpacePosition())
+{
+}
SMDS_MeshNode::SMDS_MeshNode(int id, int meshId, int shapeId, double x, double y, double z):
SMDS_MeshElement(id, meshId, shapeId),
myPosition(SMDS_SpacePosition::originSpacePosition())
{
+ init(id, meshId, shapeId, x, y ,z);
+}
+
+void SMDS_MeshNode::init(int id, int meshId, int shapeId, double x, double y, double z)
+{
+ nbNodes++;
+ myID = id;
+ myMeshId = meshId;
+ myShapeId = shapeId;
//MESSAGE("Node " << myID << " (" << x << ", " << y << ", " << z << ")");
SMDS_Mesh* mesh = SMDS_Mesh::_meshList[myMeshId];
vtkUnstructuredGrid * grid = mesh->getGrid();
//setXYZ(x, y, z);
}
+SMDS_MeshNode::~SMDS_MeshNode()
+{
+ nbNodes--;
+}
+
//=======================================================================
//function : RemoveInverseElement
//purpose :
{
public:
+ SMDS_MeshNode();
SMDS_MeshNode(int id, int meshId, int shapeId = -1, double x=0, double y=0, double z=0);
+ virtual ~SMDS_MeshNode();
+ void init(int id, int meshId, int shapeId = -1, double x=0, double y=0, double z=0);
+
double* getCoord() const;
void Print(std::ostream & OS) const;
* \retval const SMDS_MeshNode* - the node
*/
virtual const SMDS_MeshNode* GetNode(const int) const { return this; }
-
+ static int nbNodes;
protected:
SMDS_ElemIteratorPtr
elementsIterator(SMDSAbs_ElementType type) const;
#include <boost/shared_ptr.hpp>
class SMDS_Position;
-typedef boost::shared_ptr<SMDS_Position> SMDS_PositionPtr;
+//typedef boost::shared_ptr<SMDS_Position> SMDS_PositionPtr;
+typedef SMDS_Position* SMDS_PositionPtr;
class SMDS_EXPORT SMDS_Position
{
// Author : Jean-Michel BOULCOURT
// Module : SMESH
//
+
#include "SMDS_SpacePosition.hxx"
-//=======================================================================
-//function : SMDS_SpacePosition
-//purpose :
-//=======================================================================
+SMDS_SpacePosition* SMDS_SpacePosition::_originPosition = new SMDS_SpacePosition();
SMDS_SpacePosition::SMDS_SpacePosition(double x, double y, double z):
- SMDS_Position(0)
+ SMDS_Position(0)
{
- myCoords[0]=x;
- myCoords[1]=y;
- myCoords[2]=z;
}
-/**
-*/
-SMDS_TypeOfPosition SMDS_SpacePosition::GetTypeOfPosition() const
+const double* SMDS_SpacePosition::Coords() const
{
- return SMDS_TOP_3DSPACE;
+ static double origin[]={0,0,0};
+ return origin;
}
-const double * SMDS_SpacePosition::Coords() const
+SMDS_TypeOfPosition SMDS_SpacePosition::GetTypeOfPosition() const
{
- return myCoords;
+ return SMDS_TOP_3DSPACE;
}
SMDS_PositionPtr SMDS_SpacePosition::originSpacePosition()
{
- static SMDS_PositionPtr staticpos (new SMDS_SpacePosition());
- return staticpos;
+ return _originPosition;
}
class SMDS_EXPORT SMDS_SpacePosition:public SMDS_Position
{
- public:
- SMDS_SpacePosition(double x=0, double y=0, double z=0);
- const virtual double * Coords() const;
- virtual inline SMDS_TypeOfPosition GetTypeOfPosition() const;
- inline void SetCoords(const double x, const double y, const double z);
- static SMDS_PositionPtr originSpacePosition();
- private:
- double myCoords[3];
+public:
+ SMDS_SpacePosition(double x=0, double y=0, double z=0);
+ const virtual double * Coords() const;
+ virtual inline SMDS_TypeOfPosition GetTypeOfPosition() const;
+ static SMDS_PositionPtr originSpacePosition();
+private:
+ static SMDS_SpacePosition* _originPosition;
};
#endif
#include "SMDS_MeshNode.hxx"
#include "SMDS_SetIterator.hxx"
#include "SMDS_VolumeTool.hxx"
+#include "SMDS_Mesh.hxx"
#include "utilities.h"
+#include <vtkCell.h>
+
#include <vector>
using namespace std;
{
}
+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)
{
int SMDS_VolumeVtkNodes::NbNodes() const
{
- return 0;
+ vtkUnstructuredGrid* grid =SMDS_Mesh::_meshList[myMeshId]->getGrid();
+ int nbPoints = grid->GetCell(myVtkID)->GetNumberOfPoints();
+ return nbPoints;
}
int SMDS_VolumeVtkNodes::NbEdges() const
#include "SMESH_SMDS.hxx"
#include "SMDS_MeshVolume.hxx"
+#include <vtkUnstructuredGrid.h>
+#include <vector>
class SMDS_EXPORT SMDS_VolumeOfNodes:public SMDS_MeshVolume
{
class SMDS_EXPORT SMDS_VolumeVtkNodes:public SMDS_MeshVolume
{
public:
- SMDS_VolumeVtkNodes();
+ 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);
- ~SMDS_VolumeVtkNodes();
void Print(std::ostream & OS) const;
int NbFaces() const;
const SMDS_PositionPtr& pos = node->GetPosition();
if ( !pos ) continue;
if ( pos->GetTypeOfPosition() == SMDS_TOP_FACE ) {
- fPos = dynamic_cast< const SMDS_FacePosition* >( pos.get() );
+ fPos = dynamic_cast< const SMDS_FacePosition* >( pos );
}
else if ( pos->GetTypeOfPosition() == SMDS_TOP_VERTEX ) {
vID = pos->GetShapeId();
if ( pos->GetTypeOfPosition() != SMDS_TOP_EDGE )
return false;
const SMDS_EdgePosition* epos =
- static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
+ static_cast<const SMDS_EdgePosition*>(node->GetPosition());
if ( !paramSet.insert( epos->GetUParameter() ).second )
return false; // equal parameters
}
if ( pos->GetTypeOfPosition() != SMDS_TOP_EDGE )
return false;
const SMDS_EdgePosition* epos =
- static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
+ static_cast<const SMDS_EdgePosition*>(node->GetPosition());
theNodes.insert( make_pair( epos->GetUParameter(), node ));
++nbNodes;
}
total += subMesh->getSize();
}
cerr << "total elements and nodes in submesh sets:" << total << endl;
+ cerr << "Number of node objects " << SMDS_MeshNode::nbNodes << endl;
+ cerr << "Number of cell objects " << SMDS_MeshCell::nbCells << endl;
return ret;
}
if ( theElem->GetType() == SMDSAbs_Node ) {
const SMDS_PositionPtr& aPosition =
static_cast<const SMDS_MeshNode*>( theElem )->GetPosition();
- if ( aPosition.get() )
+ if ( aPosition )
return aPosition->GetShapeId();
else
return 0;
while ( nodeIt->more() ) {
const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
const SMDS_PositionPtr& aPosition = node->GetPosition();
- if ( aPosition.get() ) {
+ if ( aPosition ) {
int aShapeID = aPosition->GetShapeId();
SMESHDS_SubMesh * sm = aMesh->MeshElements( aShapeID );
if ( sm ) {
while ( nn++ < nbn ) {
node = static_cast<const SMDS_MeshNode*>( itN->next() );
const SMDS_PositionPtr& pos = node->GetPosition();
- posType = pos.get() ? pos->GetTypeOfPosition() : SMDS_TOP_3DSPACE;
+ posType = pos ? pos->GetTypeOfPosition() : SMDS_TOP_3DSPACE;
if (posType != SMDS_TOP_EDGE &&
posType != SMDS_TOP_VERTEX &&
theFixedNodes.find( node ) == theFixedNodes.end())
node = *n;
gp_XY uv( 0, 0 );
const SMDS_PositionPtr& pos = node->GetPosition();
- posType = pos.get() ? pos->GetTypeOfPosition() : SMDS_TOP_3DSPACE;
+ posType = pos ? pos->GetTypeOfPosition() : SMDS_TOP_3DSPACE;
// get existing UV
switch ( posType ) {
case SMDS_TOP_FACE: {
- SMDS_FacePosition* fPos = ( SMDS_FacePosition* ) pos.get();
+ SMDS_FacePosition* fPos = ( SMDS_FacePosition* ) pos;
uv.SetCoord( fPos->GetUParameter(), fPos->GetVParameter() );
break;
}
if ( !S.IsNull() && S.ShapeType() == TopAbs_EDGE )
pcurve = BRep_Tool::CurveOnSurface( TopoDS::Edge( S ), face, f,l );
if ( !pcurve.IsNull() ) {
- double u = (( SMDS_EdgePosition* ) pos.get() )->GetUParameter();
+ double u = (( SMDS_EdgePosition* ) pos )->GetUParameter();
uv = pcurve->Value( u ).XY();
}
break;
while ( aItN->more() ) {
const SMDS_MeshNode* pNode = aItN->next();
const SMDS_EdgePosition* pEPos =
- static_cast<const SMDS_EdgePosition*>( pNode->GetPosition().get() );
+ static_cast<const SMDS_EdgePosition*>( pNode->GetPosition() );
double aT = pEPos->GetUParameter();
aPrms.push_back( aT );
}
while ( aItN->more() ) {
const SMDS_MeshNode* pNode = aItN->next();
const SMDS_EdgePosition* pEPos =
- static_cast<const SMDS_EdgePosition*>( pNode->GetPosition().get() );
+ static_cast<const SMDS_EdgePosition*>( pNode->GetPosition() );
double aT = pEPos->GetUParameter();
aPrms.push_back( aT );
}
const SMDS_MeshNode* pNode = aItN->next();
if( pNode==aN1 || pNode==aN2 ) continue;
const SMDS_EdgePosition* pEPos =
- static_cast<const SMDS_EdgePosition*>( pNode->GetPosition().get() );
+ static_cast<const SMDS_EdgePosition*>( pNode->GetPosition() );
double aT = pEPos->GetUParameter();
aPrms.push_back( aT );
}
while ( aItN->more() ) {
const SMDS_MeshNode* pNode = aItN->next();
const SMDS_EdgePosition* pEPos =
- static_cast<const SMDS_EdgePosition*>( pNode->GetPosition().get() );
+ static_cast<const SMDS_EdgePosition*>( pNode->GetPosition() );
double aT = pEPos->GetUParameter();
aPrms.push_back( aT );
}
{
// node has position on face
const SMDS_FacePosition* fpos =
- static_cast<const SMDS_FacePosition*>(n->GetPosition().get());
+ static_cast<const SMDS_FacePosition*>(n->GetPosition());
uv.SetCoord(fpos->GetUParameter(),fpos->GetVParameter());
uvOK = CheckNodeUV( F, n, uv.ChangeCoord(), BRep_Tool::Tolerance( F ));
}
// corresponding edge from face, get pcurve for this
// edge and retrieve value from this pcurve
const SMDS_EdgePosition* epos =
- static_cast<const SMDS_EdgePosition*>(n->GetPosition().get());
+ static_cast<const SMDS_EdgePosition*>(n->GetPosition());
int edgeID = Pos->GetShapeId();
TopoDS_Edge E = TopoDS::Edge(GetMeshDS()->IndexToShape(edgeID));
double f, l, u = epos->GetUParameter();
const SMDS_PositionPtr Pos = n->GetPosition();
if(Pos->GetTypeOfPosition()==SMDS_TOP_EDGE) {
const SMDS_EdgePosition* epos =
- static_cast<const SMDS_EdgePosition*>(n->GetPosition().get());
+ static_cast<const SMDS_EdgePosition*>(n->GetPosition());
param = epos->GetUParameter();
}
else if(Pos->GetTypeOfPosition()==SMDS_TOP_VERTEX) {
if(IsMedium(node, SMDSAbs_Edge))
continue;
const SMDS_EdgePosition* pos =
- dynamic_cast<const SMDS_EdgePosition*>( node->GetPosition().get() );
+ dynamic_cast<const SMDS_EdgePosition*>( node->GetPosition() );
if ( !pos ) {
return false;
}
if(IsMedium(node))
continue;
const SMDS_EdgePosition* pos =
- dynamic_cast<const SMDS_EdgePosition*>( node->GetPosition().get() );
+ dynamic_cast<const SMDS_EdgePosition*>( node->GetPosition() );
if ( !pos ) {
return false;
}
{
const SMDS_MeshNode* node = smdsNode( nIt->next() );
const SMDS_EdgePosition* epos =
- static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
+ static_cast<const SMDS_EdgePosition*>(node->GetPosition());
double u = epos->GetUParameter();
paramNodeMap.insert( make_pair( u, node ));
}
p->myInitUV = project( node, projector );
else {
const SMDS_FacePosition* pos =
- static_cast<const SMDS_FacePosition*>(node->GetPosition().get());
+ static_cast<const SMDS_FacePosition*>(node->GetPosition());
p->myInitUV.SetCoord( pos->GetUParameter(), pos->GetVParameter() );
}
p->myInitXYZ.SetCoord( p->myInitUV.X(), p->myInitUV.Y(), 0 );
{
const SMDS_MeshNode* node = smdsNode( nIt->next() );
const SMDS_EdgePosition* epos =
- static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
+ static_cast<const SMDS_EdgePosition*>(node->GetPosition());
double u = ( epos->GetUParameter() - f ) / ( l - f );
(*pIt)->myInitXYZ.SetCoord( iCoord, isForward ? u : 1 - u );
}
int SMESHDS_SubMesh::getSize()
{
- int a = sizeof(myElements);
- int b = sizeof(myNodes);
+// int a = sizeof(myElements);
+// int b = sizeof(myNodes);
int c = NbNodes();
int d = NbElements();
cerr << "SMESHDS_SubMesh::NbNodes " << c << endl;
cerr << "SMESHDS_SubMesh::NbElements " << d << endl;
- cerr << "SMESHDS_SubMesh::myNodes " << b << endl;
- cerr << "SMESHDS_SubMesh::myElements " << a << endl;
+// cerr << "SMESHDS_SubMesh::myNodes " << b << endl;
+// cerr << "SMESHDS_SubMesh::myElements " << a << endl;
return c+d;
}
libSMESHEngine_la_LDFLAGS = \
../../idl/libSalomeIDLSMESH.la \
../SMESH/libSMESHimpl.la \
+ ../SMDS/libSMDS.la \
../Controls/libSMESHControls.la \
$(KERNEL_LDFLAGS) \
-lSalomeContainer \
const SMDS_PositionPtr pos = node->GetPosition();
if ( onFace ) { // on FACE
const SMDS_FacePosition* fPos =
- dynamic_cast<const SMDS_FacePosition*>( pos.get() );
+ dynamic_cast<const SMDS_FacePosition*>( pos );
if ( fPos ) {
aUPos[ iNode ] = fPos->GetUParameter();
aVPos[ iNode ] = fPos->GetVParameter();
}
else { // on EDGE
const SMDS_EdgePosition* ePos =
- dynamic_cast<const SMDS_EdgePosition*>( pos.get() );
+ dynamic_cast<const SMDS_EdgePosition*>( pos );
if ( ePos ) {
aUPos[ iNode ] = ePos->GetUParameter();
iNode++;
// not fixed bugs in SMDS_MeshInfo
if ( aPos->GetTypeOfPosition() == SMDS_TOP_FACE ) {
SMDS_FacePosition* fPos = const_cast<SMDS_FacePosition*>
- ( static_cast<const SMDS_FacePosition*>( aPos.get() ));
+ ( static_cast<const SMDS_FacePosition*>( aPos ));
fPos->SetUParameter( aUPos[ iNode ]);
fPos->SetVParameter( aVPos[ iNode ]);
}
// ASSERT( aPos->GetTypeOfPosition() == SMDS_TOP_EDGE );-- issue 20182
if ( aPos->GetTypeOfPosition() == SMDS_TOP_EDGE ) {
SMDS_EdgePosition* fPos = const_cast<SMDS_EdgePosition*>
- ( static_cast<const SMDS_EdgePosition*>( aPos.get() ));
+ ( static_cast<const SMDS_EdgePosition*>( aPos ));
fPos->SetUParameter( aUPos[ iNode ]);
}
}
aNodePosition->shapeType = GEOM::EDGE;
aNodePosition->params.length(1);
aNodePosition->params[0] =
- static_cast<SMDS_EdgePosition*>( pos.get() )->GetUParameter();
+ static_cast<SMDS_EdgePosition*>( pos )->GetUParameter();
break;
case SMDS_TOP_FACE:
aNodePosition->shapeType = GEOM::FACE;
aNodePosition->params.length(2);
aNodePosition->params[0] =
- static_cast<SMDS_FacePosition*>( pos.get() )->GetUParameter();
+ static_cast<SMDS_FacePosition*>( pos )->GetUParameter();
aNodePosition->params[1] =
- static_cast<SMDS_FacePosition*>( pos.get() )->GetVParameter();
+ static_cast<SMDS_FacePosition*>( pos )->GetVParameter();
break;
case SMDS_TOP_VERTEX:
aNodePosition->shapeType = GEOM::VERTEX;
if ( myIgnoreMediumNodes && SMESH_MeshEditor::IsMedium( node, SMDSAbs_Edge ))
continue;
const SMDS_EdgePosition* epos =
- static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
+ static_cast<const SMDS_EdgePosition*>(node->GetPosition());
double u = epos->GetUParameter();
// paramSize is signed so orientation is taken into account
double normPar = prevNormPar + r * ( u - myFirst[i] ) / paramSize;
paramSize = myNormPar[ EdgeIndex ] - prevNormPar;
}
const SMDS_EdgePosition* epos =
- dynamic_cast<const SMDS_EdgePosition*>(uvPt.node->GetPosition().get());
+ dynamic_cast<const SMDS_EdgePosition*>(uvPt.node->GetPosition());
if ( epos ) {
uvPt.param = epos->GetUParameter();
}
static bool findIJ (const SMDS_MeshNode* node, const FaceQuadStruct * quad, int& I, int& J)
{
const SMDS_FacePosition* fpos =
- static_cast<const SMDS_FacePosition*>(node->GetPosition().get());
+ static_cast<const SMDS_FacePosition*>(node->GetPosition());
if ( ! fpos ) return false;
gp_Pnt2d uv( fpos->GetUParameter(), fpos->GetVParameter() );
* -0. - shape and face mesh verification
* -1. - identify faces and vertices of the "cube"
* -2. - Algorithm from:
- * "Application de l'interpolation transfinie à la création de maillages
+ * "Application de l'interpolation transfinie a la creation de maillages
* C0 ou G1 continus sur des triangles, quadrangles, tetraedres, pentaedres
- * et hexaedres déformés."
+ * et hexaedres deformes."
* Alain PERONNET - 8 janvier 1999
*/
//=============================================================================
int i1, j1, nbxyz = nbx * nby * nbz;
Point3DStruct *np = new Point3DStruct[nbxyz];
+
+ aMesh.GetMeshDS()->incrementNodesCapacity(nbx * nby * nbz);
+ aMesh.GetMeshDS()->incrementCellsCapacity((nbx-1) * (nby-1) * (nbz-1));
// 1.9 - store node indexes of faces
if ( theCreateQuadratic && SMESH_MesherHelper::IsMedium( node, SMDSAbs_Edge ))
continue;
const SMDS_EdgePosition* epos =
- static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
+ static_cast<const SMDS_EdgePosition*>(node->GetPosition());
double u = epos->GetUParameter();
if ( u < umin )
umin = u;
//
if ( SMESH_Block::IsEdgeID (aSID)) {
const SMDS_EdgePosition* epos =
- static_cast<const SMDS_EdgePosition*>(aNode->GetPosition().get());
+ static_cast<const SMDS_EdgePosition*>(aNode->GetPosition());
myBlock.ComputeParameters( epos->GetUParameter(), aS, aCoords );
}
else {
if(myTool->IsMedium(node))
continue;
const SMDS_EdgePosition* pos =
- dynamic_cast<const SMDS_EdgePosition*>( node->GetPosition().get() );
+ dynamic_cast<const SMDS_EdgePosition*>( node->GetPosition() );
if ( !pos ) {
return false;
}
if(myTool->IsMedium(node))
continue;
const SMDS_EdgePosition* pos =
- dynamic_cast<const SMDS_EdgePosition*>( node->GetPosition().get() );
+ dynamic_cast<const SMDS_EdgePosition*>( node->GetPosition() );
if ( !pos ) {
return false;
}
while ( nIt->more() ) {
const SMDS_MeshNode* node = nIt->next();
const SMDS_EdgePosition* pos =
- static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
+ static_cast<const SMDS_EdgePosition*>(node->GetPosition());
pos2nodes.insert( make_pair( pos->GetUParameter(), node ));
}
if ( pos2nodes.size() != edgeSM->NbNodes() )
RETURN_BAD_RESULT("Bad node position type: node " << node->GetID() <<
" pos type " << node->GetPosition()->GetTypeOfPosition());
const SMDS_EdgePosition* pos =
- static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
+ static_cast<const SMDS_EdgePosition*>(node->GetPosition());
u2nodes.insert( make_pair( pos->GetUParameter(), node ));
seamNodes.insert( node );
}
}
case SMDS_TOP_EDGE: {
const SMDS_EdgePosition* pos =
- static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
+ static_cast<const SMDS_EdgePosition*>(node->GetPosition());
pos2nodes.insert( make_pair( pos->GetUParameter(), node ));
break;
}