#include <sys/sysinfo.h>
#endif
+// number of added entitis to check memory after
+#define CHECKMEMORY_INTERVAL 1000
+
//================================================================================
/*!
* \brief Raise an exception if free memory (ram+swap) too low
// find the MeshNode corresponding to ID
const SMDS_MeshElement *node = myNodeIDFactory->MeshElement(ID);
if(!node){
- CheckMemory();
+ if ( myNodes.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
SMDS_MeshNode * node=new SMDS_MeshNode(x, y, z);
myNodes.Add(node);
myNodeIDFactory->BindID(ID,node);
{
if ( !n1 || !n2 ) return 0;
- CheckMemory();
+ if ( myEdges.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
+
SMDS_MeshEdge * edge=new SMDS_MeshEdge(n1,n2);
if(myElementIDFactory->BindID(ID, edge)) {
SMDS_MeshNode *node1,*node2;
return NULL;
if ( !e1 || !e2 || !e3 ) return 0;
- CheckMemory();
+ if ( myFaces.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
+
SMDS_MeshFace * face = new SMDS_FaceOfEdges(e1,e2,e3);
myFaces.Add(face);
myInfo.myNbTriangles++;
if (!hasConstructionEdges())
return NULL;
if ( !e1 || !e2 || !e3 || !e4 ) return 0;
- CheckMemory();
+ if ( myFaces.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
SMDS_MeshFace * face = new SMDS_FaceOfEdges(e1,e2,e3,e4);
myFaces.Add(face);
myInfo.myNbQuadrangles++;
{
SMDS_MeshVolume* volume = 0;
if ( !n1 || !n2 || !n3 || !n4) return volume;
- CheckMemory();
+ if ( myVolumes.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
if(hasConstructionFaces()) {
SMDS_MeshFace * f1=FindFaceOrCreate(n1,n2,n3);
SMDS_MeshFace * f2=FindFaceOrCreate(n1,n2,n4);
{
SMDS_MeshVolume* volume = 0;
if ( !n1 || !n2 || !n3 || !n4 || !n5) return volume;
- CheckMemory();
+ if ( myVolumes.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
if(hasConstructionFaces()) {
SMDS_MeshFace * f1=FindFaceOrCreate(n1,n2,n3,n4);
SMDS_MeshFace * f2=FindFaceOrCreate(n1,n2,n5);
{
SMDS_MeshVolume* volume = 0;
if ( !n1 || !n2 || !n3 || !n4 || !n5 || !n6) return volume;
- CheckMemory();
+ if ( myVolumes.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
if(hasConstructionFaces()) {
SMDS_MeshFace * f1=FindFaceOrCreate(n1,n2,n3);
SMDS_MeshFace * f2=FindFaceOrCreate(n4,n5,n6);
{
SMDS_MeshVolume* volume = 0;
if ( !n1 || !n2 || !n3 || !n4 || !n5 || !n6 || !n7 || !n8) return volume;
- CheckMemory();
+ if ( myVolumes.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
if(hasConstructionFaces()) {
SMDS_MeshFace * f1=FindFaceOrCreate(n1,n2,n3,n4);
SMDS_MeshFace * f2=FindFaceOrCreate(n5,n6,n7,n8);
if (!hasConstructionFaces())
return NULL;
if ( !f1 || !f2 || !f3 || !f4) return 0;
- CheckMemory();
+ if ( myVolumes.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
SMDS_MeshVolume * volume = new SMDS_VolumeOfFaces(f1,f2,f3,f4);
myVolumes.Add(volume);
myInfo.myNbTetras++;
if (!hasConstructionFaces())
return NULL;
if ( !f1 || !f2 || !f3 || !f4 || !f5) return 0;
- CheckMemory();
+ if ( myVolumes.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
SMDS_MeshVolume * volume = new SMDS_VolumeOfFaces(f1,f2,f3,f4,f5);
myVolumes.Add(volume);
myInfo.myNbPyramids++;
if (!hasConstructionFaces())
return NULL;
if ( !f1 || !f2 || !f3 || !f4 || !f5 || !f6) return 0;
- CheckMemory();
+ if ( myVolumes.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
SMDS_MeshVolume * volume = new SMDS_VolumeOfFaces(f1,f2,f3,f4,f5,f6);
myVolumes.Add(volume);
myInfo.myNbPrisms++;
{
SMDS_MeshFace * face;
- CheckMemory();
+ if ( myFaces.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
if (hasConstructionEdges())
{
MESSAGE("Error : Not implemented");
const int ID)
{
SMDS_MeshVolume* volume;
- CheckMemory();
+ if ( myVolumes.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
if (hasConstructionFaces()) {
MESSAGE("Error : Not implemented");
return NULL;
const SMDS_MeshNode * node3)
{
if ( !node1 || !node2 || !node3) return 0;
- CheckMemory();
+ if ( myFaces.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
if(hasConstructionEdges())
{
SMDS_MeshEdge *edge1, *edge2, *edge3;
const SMDS_MeshNode * node4)
{
if ( !node1 || !node2 || !node3 || !node4 ) return 0;
- CheckMemory();
+ if ( myFaces.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
if(hasConstructionEdges())
{
SMDS_MeshEdge *edge1, *edge2, *edge3, *edge4;
SMDS_MeshEdge * toReturn=NULL;
toReturn=const_cast<SMDS_MeshEdge*>(FindEdge(node1,node2));
if(toReturn==NULL) {
- CheckMemory();
+ if ( myEdges.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
toReturn=new SMDS_MeshEdge(node1,node2);
myEdges.Add(toReturn);
myInfo.myNbEdges++;