mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-12-27 09:50:34 +05:00
Improve SMDS: replace std::vector with simple array
for storage of links to nodes in mesh elements
This commit is contained in:
parent
40e9d61119
commit
61d5fb0e6a
@ -19,6 +19,10 @@
|
|||||||
//
|
//
|
||||||
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
|
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(disable:4786)
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "SMDS_FaceOfEdges.hxx"
|
#include "SMDS_FaceOfEdges.hxx"
|
||||||
#include "SMDS_IteratorOfElements.hxx"
|
#include "SMDS_IteratorOfElements.hxx"
|
||||||
#include "SMDS_MeshNode.hxx"
|
#include "SMDS_MeshNode.hxx"
|
||||||
@ -32,7 +36,7 @@ using namespace std;
|
|||||||
|
|
||||||
int SMDS_FaceOfEdges::NbEdges() const
|
int SMDS_FaceOfEdges::NbEdges() const
|
||||||
{
|
{
|
||||||
return myEdges.size();
|
return myNbEdges;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SMDS_FaceOfEdges::NbFaces() const
|
int SMDS_FaceOfEdges::NbFaces() const
|
||||||
@ -57,17 +61,23 @@ SMDSAbs_ElementType SMDS_FaceOfEdges::GetType() const
|
|||||||
return SMDSAbs_Face;
|
return SMDSAbs_Face;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : elementsIterator
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
class SMDS_FaceOfEdges_MyIterator:public SMDS_ElemIterator
|
class SMDS_FaceOfEdges_MyIterator:public SMDS_ElemIterator
|
||||||
{
|
{
|
||||||
const vector<const SMDS_MeshEdge*>& mySet;
|
const SMDS_MeshEdge* const *mySet;
|
||||||
|
int myLength;
|
||||||
int index;
|
int index;
|
||||||
public:
|
public:
|
||||||
SMDS_FaceOfEdges_MyIterator(const vector<const SMDS_MeshEdge*>& s):
|
SMDS_FaceOfEdges_MyIterator(const SMDS_MeshEdge* const *s, int l):
|
||||||
mySet(s),index(0) {}
|
mySet(s),myLength(l),index(0) {}
|
||||||
|
|
||||||
bool more()
|
bool more()
|
||||||
{
|
{
|
||||||
return index<mySet.size();
|
return index<myLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SMDS_MeshElement* next()
|
const SMDS_MeshElement* next()
|
||||||
@ -76,30 +86,33 @@ class SMDS_FaceOfEdges_MyIterator:public SMDS_ElemIterator
|
|||||||
return mySet[index-1];
|
return mySet[index-1];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
SMDS_ElemIteratorPtr SMDS_FaceOfEdges::
|
|
||||||
elementsIterator(SMDSAbs_ElementType type) const
|
SMDS_ElemIteratorPtr SMDS_FaceOfEdges::elementsIterator
|
||||||
|
(SMDSAbs_ElementType type) const
|
||||||
{
|
{
|
||||||
switch(type)
|
switch(type)
|
||||||
{
|
{
|
||||||
case SMDSAbs_Face:
|
case SMDSAbs_Face:
|
||||||
return SMDS_MeshElement::elementsIterator(SMDSAbs_Face);
|
return SMDS_MeshElement::elementsIterator(SMDSAbs_Face);
|
||||||
case SMDSAbs_Edge:
|
case SMDSAbs_Edge:
|
||||||
return SMDS_ElemIteratorPtr(new SMDS_FaceOfEdges_MyIterator(myEdges));
|
return SMDS_ElemIteratorPtr(new SMDS_FaceOfEdges_MyIterator(myEdges,myNbEdges));
|
||||||
default:
|
default:
|
||||||
return SMDS_ElemIteratorPtr
|
return SMDS_ElemIteratorPtr
|
||||||
(new SMDS_IteratorOfElements
|
(new SMDS_IteratorOfElements
|
||||||
(this,type, SMDS_ElemIteratorPtr(new SMDS_FaceOfEdges_MyIterator(myEdges))));
|
(this,type, SMDS_ElemIteratorPtr
|
||||||
}
|
(new SMDS_FaceOfEdges_MyIterator(myEdges,myNbEdges))));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SMDS_FaceOfEdges::SMDS_FaceOfEdges(const SMDS_MeshEdge* edge1,
|
SMDS_FaceOfEdges::SMDS_FaceOfEdges(const SMDS_MeshEdge* edge1,
|
||||||
const SMDS_MeshEdge* edge2,
|
const SMDS_MeshEdge* edge2,
|
||||||
const SMDS_MeshEdge* edge3)
|
const SMDS_MeshEdge* edge3)
|
||||||
{
|
{
|
||||||
myEdges.resize(3);
|
myNbEdges = 3;
|
||||||
myEdges[0]=edge1;
|
myEdges[0]=edge1;
|
||||||
myEdges[1]=edge2;
|
myEdges[1]=edge2;
|
||||||
myEdges[2]=edge3;
|
myEdges[2]=edge3;
|
||||||
|
myEdges[3]=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SMDS_FaceOfEdges::SMDS_FaceOfEdges(const SMDS_MeshEdge* edge1,
|
SMDS_FaceOfEdges::SMDS_FaceOfEdges(const SMDS_MeshEdge* edge1,
|
||||||
@ -107,7 +120,7 @@ SMDS_FaceOfEdges::SMDS_FaceOfEdges(const SMDS_MeshEdge* edge1,
|
|||||||
const SMDS_MeshEdge* edge3,
|
const SMDS_MeshEdge* edge3,
|
||||||
const SMDS_MeshEdge* edge4)
|
const SMDS_MeshEdge* edge4)
|
||||||
{
|
{
|
||||||
myEdges.resize(4);
|
myNbEdges = 4;
|
||||||
myEdges[0]=edge1;
|
myEdges[0]=edge1;
|
||||||
myEdges[1]=edge2;
|
myEdges[1]=edge2;
|
||||||
myEdges[2]=edge3;
|
myEdges[2]=edge3;
|
||||||
|
@ -51,7 +51,8 @@ class SMDS_FaceOfEdges:public SMDS_MeshFace
|
|||||||
elementsIterator(SMDSAbs_ElementType type) const;
|
elementsIterator(SMDSAbs_ElementType type) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<const SMDS_MeshEdge*> myEdges;
|
const SMDS_MeshEdge* myEdges[4];
|
||||||
|
int myNbEdges;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -19,6 +19,10 @@
|
|||||||
//
|
//
|
||||||
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
|
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(disable:4786)
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "SMDS_FaceOfNodes.hxx"
|
#include "SMDS_FaceOfNodes.hxx"
|
||||||
#include "SMDS_IteratorOfElements.hxx"
|
#include "SMDS_IteratorOfElements.hxx"
|
||||||
#include "SMDS_MeshNode.hxx"
|
#include "SMDS_MeshNode.hxx"
|
||||||
@ -43,8 +47,9 @@ int SMDS_FaceOfNodes::NbFaces() const
|
|||||||
|
|
||||||
int SMDS_FaceOfNodes::NbNodes() const
|
int SMDS_FaceOfNodes::NbNodes() const
|
||||||
{
|
{
|
||||||
return myNodes.size();
|
return myNbNodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : Print
|
//function : Print
|
||||||
//purpose :
|
//purpose :
|
||||||
@ -58,17 +63,23 @@ void SMDS_FaceOfNodes::Print(ostream & OS) const
|
|||||||
OS << myNodes[i] << ") " << endl;
|
OS << myNodes[i] << ") " << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : elementsIterator
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
class SMDS_FaceOfNodes_MyIterator:public SMDS_ElemIterator
|
class SMDS_FaceOfNodes_MyIterator:public SMDS_ElemIterator
|
||||||
{
|
{
|
||||||
const vector<const SMDS_MeshNode*>& mySet;
|
const SMDS_MeshNode* const *mySet;
|
||||||
|
int myLength;
|
||||||
int index;
|
int index;
|
||||||
public:
|
public:
|
||||||
SMDS_FaceOfNodes_MyIterator(const vector<const SMDS_MeshNode*>& s):
|
SMDS_FaceOfNodes_MyIterator(const SMDS_MeshNode* const *s, int l):
|
||||||
mySet(s),index(0) {}
|
mySet(s),myLength(l),index(0) {}
|
||||||
|
|
||||||
bool more()
|
bool more()
|
||||||
{
|
{
|
||||||
return index<mySet.size();
|
return index<myLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SMDS_MeshElement* next()
|
const SMDS_MeshElement* next()
|
||||||
@ -77,22 +88,24 @@ class SMDS_FaceOfNodes_MyIterator:public SMDS_ElemIterator
|
|||||||
return mySet[index-1];
|
return mySet[index-1];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
SMDS_ElemIteratorPtr SMDS_FaceOfNodes::
|
|
||||||
elementsIterator(SMDSAbs_ElementType type) const
|
SMDS_ElemIteratorPtr SMDS_FaceOfNodes::elementsIterator
|
||||||
|
(SMDSAbs_ElementType type) const
|
||||||
{
|
{
|
||||||
switch(type)
|
switch(type)
|
||||||
{
|
{
|
||||||
case SMDSAbs_Face:
|
case SMDSAbs_Face:
|
||||||
return SMDS_MeshElement::elementsIterator(SMDSAbs_Face);
|
return SMDS_MeshElement::elementsIterator(SMDSAbs_Face);
|
||||||
case SMDSAbs_Node:
|
case SMDSAbs_Node:
|
||||||
return SMDS_ElemIteratorPtr(new SMDS_FaceOfNodes_MyIterator(myNodes));
|
return SMDS_ElemIteratorPtr(new SMDS_FaceOfNodes_MyIterator(myNodes,myNbNodes));
|
||||||
case SMDSAbs_Edge:
|
case SMDSAbs_Edge:
|
||||||
MESSAGE("Error : edge iterator for SMDS_FaceOfNodes not implemented");
|
MESSAGE("Error : edge iterator for SMDS_FaceOfNodes not implemented");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return SMDS_ElemIteratorPtr
|
return SMDS_ElemIteratorPtr
|
||||||
(new SMDS_IteratorOfElements
|
(new SMDS_IteratorOfElements
|
||||||
(this,type,SMDS_ElemIteratorPtr(new SMDS_FaceOfNodes_MyIterator(myNodes))));
|
(this,type,SMDS_ElemIteratorPtr
|
||||||
|
(new SMDS_FaceOfNodes_MyIterator(myNodes,myNbNodes))));
|
||||||
}
|
}
|
||||||
return SMDS_ElemIteratorPtr();
|
return SMDS_ElemIteratorPtr();
|
||||||
}
|
}
|
||||||
@ -101,10 +114,11 @@ SMDS_FaceOfNodes::SMDS_FaceOfNodes(const SMDS_MeshNode* node1,
|
|||||||
const SMDS_MeshNode* node2,
|
const SMDS_MeshNode* node2,
|
||||||
const SMDS_MeshNode* node3)
|
const SMDS_MeshNode* node3)
|
||||||
{
|
{
|
||||||
myNodes.resize(3);
|
myNbNodes = 3;
|
||||||
myNodes[0]=node1;
|
myNodes[0]=node1;
|
||||||
myNodes[1]=node2;
|
myNodes[1]=node2;
|
||||||
myNodes[2]=node3;
|
myNodes[2]=node3;
|
||||||
|
myNodes[3]=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SMDS_FaceOfNodes::SMDS_FaceOfNodes(const SMDS_MeshNode* node1,
|
SMDS_FaceOfNodes::SMDS_FaceOfNodes(const SMDS_MeshNode* node1,
|
||||||
@ -112,7 +126,7 @@ SMDS_FaceOfNodes::SMDS_FaceOfNodes(const SMDS_MeshNode* node1,
|
|||||||
const SMDS_MeshNode* node3,
|
const SMDS_MeshNode* node3,
|
||||||
const SMDS_MeshNode* node4)
|
const SMDS_MeshNode* node4)
|
||||||
{
|
{
|
||||||
myNodes.resize(4);
|
myNbNodes = 4;
|
||||||
myNodes[0]=node1;
|
myNodes[0]=node1;
|
||||||
myNodes[1]=node2;
|
myNodes[1]=node2;
|
||||||
myNodes[2]=node3;
|
myNodes[2]=node3;
|
||||||
@ -121,20 +135,13 @@ SMDS_FaceOfNodes::SMDS_FaceOfNodes(const SMDS_MeshNode* node1,
|
|||||||
bool SMDS_FaceOfNodes::ChangeNodes(const SMDS_MeshNode* nodes[],
|
bool SMDS_FaceOfNodes::ChangeNodes(const SMDS_MeshNode* nodes[],
|
||||||
const int nbNodes)
|
const int nbNodes)
|
||||||
{
|
{
|
||||||
if (nbNodes == 3) {
|
myNbNodes = nbNodes;
|
||||||
myNodes.resize(3);
|
myNodes[0]=nodes[0];
|
||||||
myNodes[0]=nodes[0];
|
myNodes[1]=nodes[1];
|
||||||
myNodes[1]=nodes[1];
|
myNodes[2]=nodes[2];
|
||||||
myNodes[2]=nodes[2];
|
if (nbNodes == 4)
|
||||||
}
|
|
||||||
else if ( nbNodes == 4) {
|
|
||||||
myNodes.resize(4);
|
|
||||||
myNodes[0]=nodes[0];
|
|
||||||
myNodes[1]=nodes[1];
|
|
||||||
myNodes[2]=nodes[2];
|
|
||||||
myNodes[3]=nodes[3];
|
myNodes[3]=nodes[3];
|
||||||
}
|
else if (nbNodes != 3)
|
||||||
else
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -49,7 +49,8 @@ class SMDS_FaceOfNodes:public SMDS_MeshFace
|
|||||||
elementsIterator(SMDSAbs_ElementType type) const;
|
elementsIterator(SMDSAbs_ElementType type) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<const SMDS_MeshNode*> myNodes;
|
const SMDS_MeshNode* myNodes[4];
|
||||||
|
int myNbNodes;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -25,6 +25,10 @@
|
|||||||
// Author : Jean-Michel BOULCOURT
|
// Author : Jean-Michel BOULCOURT
|
||||||
// Module : SMESH
|
// Module : SMESH
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(disable:4786)
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "SMDS_VolumeOfFaces.hxx"
|
#include "SMDS_VolumeOfFaces.hxx"
|
||||||
#include "SMDS_IteratorOfElements.hxx"
|
#include "SMDS_IteratorOfElements.hxx"
|
||||||
|
|
||||||
@ -39,27 +43,28 @@ void SMDS_VolumeOfFaces::Print(ostream & OS) const
|
|||||||
{
|
{
|
||||||
OS << "volume <" << GetID() << "> : ";
|
OS << "volume <" << GetID() << "> : ";
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < myFaces.size()-1; ++i) OS << myFaces[i] << ",";
|
for (i = 0; i < NbFaces()-1; ++i) OS << myFaces[i] << ",";
|
||||||
OS << myFaces[i]<< ") " << endl;
|
OS << myFaces[i]<< ") " << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int SMDS_VolumeOfFaces::NbFaces() const
|
int SMDS_VolumeOfFaces::NbFaces() const
|
||||||
{
|
{
|
||||||
return myFaces.size();
|
return myNbFaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
class SMDS_VolumeOfFaces_MyIterator:public SMDS_ElemIterator
|
class SMDS_VolumeOfFaces_MyIterator:public SMDS_ElemIterator
|
||||||
{
|
{
|
||||||
const vector<const SMDS_MeshFace*>& mySet;
|
const SMDS_MeshFace* const *mySet;
|
||||||
|
int myLength;
|
||||||
int index;
|
int index;
|
||||||
public:
|
public:
|
||||||
SMDS_VolumeOfFaces_MyIterator(const vector<const SMDS_MeshFace*>& s):
|
SMDS_VolumeOfFaces_MyIterator(const SMDS_MeshFace* const *s, int l):
|
||||||
mySet(s),index(0) {}
|
mySet(s),myLength(l),index(0) {}
|
||||||
|
|
||||||
bool more()
|
bool more()
|
||||||
{
|
{
|
||||||
return index<mySet.size();
|
return index<myLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SMDS_MeshElement* next()
|
const SMDS_MeshElement* next()
|
||||||
@ -77,11 +82,12 @@ SMDS_ElemIteratorPtr SMDS_VolumeOfFaces::
|
|||||||
case SMDSAbs_Volume:
|
case SMDSAbs_Volume:
|
||||||
return SMDS_MeshElement::elementsIterator(SMDSAbs_Volume);
|
return SMDS_MeshElement::elementsIterator(SMDSAbs_Volume);
|
||||||
case SMDSAbs_Face:
|
case SMDSAbs_Face:
|
||||||
return SMDS_ElemIteratorPtr(new SMDS_VolumeOfFaces_MyIterator(myFaces));
|
return SMDS_ElemIteratorPtr(new SMDS_VolumeOfFaces_MyIterator(myFaces,myNbFaces));
|
||||||
default:
|
default:
|
||||||
return SMDS_ElemIteratorPtr
|
return SMDS_ElemIteratorPtr
|
||||||
(new SMDS_IteratorOfElements
|
(new SMDS_IteratorOfElements
|
||||||
(this,type,SMDS_ElemIteratorPtr(new SMDS_VolumeOfFaces_MyIterator(myFaces))));
|
(this,type,SMDS_ElemIteratorPtr
|
||||||
|
(new SMDS_VolumeOfFaces_MyIterator(myFaces,myNbFaces))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,11 +96,13 @@ SMDS_VolumeOfFaces::SMDS_VolumeOfFaces(const SMDS_MeshFace * face1,
|
|||||||
const SMDS_MeshFace * face3,
|
const SMDS_MeshFace * face3,
|
||||||
const SMDS_MeshFace * face4)
|
const SMDS_MeshFace * face4)
|
||||||
{
|
{
|
||||||
myFaces.resize(4);
|
myNbFaces = 4;
|
||||||
myFaces[0]=face1;
|
myFaces[0]=face1;
|
||||||
myFaces[1]=face2;
|
myFaces[1]=face2;
|
||||||
myFaces[2]=face3;
|
myFaces[2]=face3;
|
||||||
myFaces[3]=face4;
|
myFaces[3]=face4;
|
||||||
|
myFaces[4]=0;
|
||||||
|
myFaces[5]=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SMDS_VolumeOfFaces::SMDS_VolumeOfFaces(const SMDS_MeshFace * face1,
|
SMDS_VolumeOfFaces::SMDS_VolumeOfFaces(const SMDS_MeshFace * face1,
|
||||||
@ -103,12 +111,13 @@ SMDS_VolumeOfFaces::SMDS_VolumeOfFaces(const SMDS_MeshFace * face1,
|
|||||||
const SMDS_MeshFace * face4,
|
const SMDS_MeshFace * face4,
|
||||||
const SMDS_MeshFace * face5)
|
const SMDS_MeshFace * face5)
|
||||||
{
|
{
|
||||||
myFaces.resize(5);
|
myNbFaces = 5;
|
||||||
myFaces[0]=face1;
|
myFaces[0]=face1;
|
||||||
myFaces[1]=face2;
|
myFaces[1]=face2;
|
||||||
myFaces[2]=face3;
|
myFaces[2]=face3;
|
||||||
myFaces[3]=face4;
|
myFaces[3]=face4;
|
||||||
myFaces[4]=face5;
|
myFaces[4]=face5;
|
||||||
|
myFaces[5]=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SMDS_VolumeOfFaces::SMDS_VolumeOfFaces(const SMDS_MeshFace * face1,
|
SMDS_VolumeOfFaces::SMDS_VolumeOfFaces(const SMDS_MeshFace * face1,
|
||||||
@ -118,7 +127,7 @@ SMDS_VolumeOfFaces::SMDS_VolumeOfFaces(const SMDS_MeshFace * face1,
|
|||||||
const SMDS_MeshFace * face5,
|
const SMDS_MeshFace * face5,
|
||||||
const SMDS_MeshFace * face6)
|
const SMDS_MeshFace * face6)
|
||||||
{
|
{
|
||||||
myFaces.resize(6);
|
myNbFaces = 6;
|
||||||
myFaces[0]=face1;
|
myFaces[0]=face1;
|
||||||
myFaces[1]=face2;
|
myFaces[1]=face2;
|
||||||
myFaces[2]=face3;
|
myFaces[2]=face3;
|
||||||
|
@ -30,7 +30,6 @@
|
|||||||
#include "SMDS_MeshVolume.hxx"
|
#include "SMDS_MeshVolume.hxx"
|
||||||
#include "SMDS_MeshFace.hxx"
|
#include "SMDS_MeshFace.hxx"
|
||||||
#include "SMDS_Iterator.hxx"
|
#include "SMDS_Iterator.hxx"
|
||||||
#include <vector>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
@ -61,6 +60,7 @@ class SMDS_VolumeOfFaces:public SMDS_MeshVolume
|
|||||||
protected:
|
protected:
|
||||||
SMDS_ElemIteratorPtr
|
SMDS_ElemIteratorPtr
|
||||||
elementsIterator(SMDSAbs_ElementType type) const;
|
elementsIterator(SMDSAbs_ElementType type) const;
|
||||||
std::vector<const SMDS_MeshFace *> myFaces;
|
const SMDS_MeshFace * myFaces[6];
|
||||||
|
int myNbFaces;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
@ -19,6 +19,10 @@
|
|||||||
//
|
//
|
||||||
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
|
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(disable:4786)
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "SMDS_VolumeOfNodes.hxx"
|
#include "SMDS_VolumeOfNodes.hxx"
|
||||||
#include "SMDS_MeshNode.hxx"
|
#include "SMDS_MeshNode.hxx"
|
||||||
#include "utilities.h"
|
#include "utilities.h"
|
||||||
@ -39,7 +43,8 @@ SMDS_VolumeOfNodes::SMDS_VolumeOfNodes(
|
|||||||
const SMDS_MeshNode * node7,
|
const SMDS_MeshNode * node7,
|
||||||
const SMDS_MeshNode * node8)
|
const SMDS_MeshNode * node8)
|
||||||
{
|
{
|
||||||
myNodes.resize(8);
|
myNbNodes = 8;
|
||||||
|
myNodes = new const SMDS_MeshNode* [myNbNodes];
|
||||||
myNodes[0]=node1;
|
myNodes[0]=node1;
|
||||||
myNodes[1]=node2;
|
myNodes[1]=node2;
|
||||||
myNodes[2]=node3;
|
myNodes[2]=node3;
|
||||||
@ -56,7 +61,8 @@ SMDS_VolumeOfNodes::SMDS_VolumeOfNodes(
|
|||||||
const SMDS_MeshNode * node3,
|
const SMDS_MeshNode * node3,
|
||||||
const SMDS_MeshNode * node4)
|
const SMDS_MeshNode * node4)
|
||||||
{
|
{
|
||||||
myNodes.resize(4);
|
myNbNodes = 4;
|
||||||
|
myNodes = new const SMDS_MeshNode* [myNbNodes];
|
||||||
myNodes[0]=node1;
|
myNodes[0]=node1;
|
||||||
myNodes[1]=node2;
|
myNodes[1]=node2;
|
||||||
myNodes[2]=node3;
|
myNodes[2]=node3;
|
||||||
@ -70,7 +76,8 @@ SMDS_VolumeOfNodes::SMDS_VolumeOfNodes(
|
|||||||
const SMDS_MeshNode * node4,
|
const SMDS_MeshNode * node4,
|
||||||
const SMDS_MeshNode * node5)
|
const SMDS_MeshNode * node5)
|
||||||
{
|
{
|
||||||
myNodes.resize(5);
|
myNbNodes = 5;
|
||||||
|
myNodes = new const SMDS_MeshNode* [myNbNodes];
|
||||||
myNodes[0]=node1;
|
myNodes[0]=node1;
|
||||||
myNodes[1]=node2;
|
myNodes[1]=node2;
|
||||||
myNodes[2]=node3;
|
myNodes[2]=node3;
|
||||||
@ -86,7 +93,8 @@ SMDS_VolumeOfNodes::SMDS_VolumeOfNodes(
|
|||||||
const SMDS_MeshNode * node5,
|
const SMDS_MeshNode * node5,
|
||||||
const SMDS_MeshNode * node6)
|
const SMDS_MeshNode * node6)
|
||||||
{
|
{
|
||||||
myNodes.resize(6);
|
myNbNodes = 6;
|
||||||
|
myNodes = new const SMDS_MeshNode* [myNbNodes];
|
||||||
myNodes[0]=node1;
|
myNodes[0]=node1;
|
||||||
myNodes[1]=node2;
|
myNodes[1]=node2;
|
||||||
myNodes[2]=node3;
|
myNodes[2]=node3;
|
||||||
@ -94,18 +102,30 @@ SMDS_VolumeOfNodes::SMDS_VolumeOfNodes(
|
|||||||
myNodes[4]=node5;
|
myNodes[4]=node5;
|
||||||
myNodes[5]=node6;
|
myNodes[5]=node6;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SMDS_VolumeOfNodes::ChangeNodes(const SMDS_MeshNode* nodes[],
|
bool SMDS_VolumeOfNodes::ChangeNodes(const SMDS_MeshNode* nodes[],
|
||||||
const int nbNodes)
|
const int nbNodes)
|
||||||
{
|
{
|
||||||
if (nbNodes < 4 || nbNodes > 8 || nbNodes == 7)
|
if (nbNodes < 4 || nbNodes > 8 || nbNodes == 7)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
myNodes.resize( nbNodes );
|
delete [] myNodes;
|
||||||
|
myNbNodes = nbNodes;
|
||||||
|
myNodes = new const SMDS_MeshNode* [myNbNodes];
|
||||||
for ( int i = 0; i < nbNodes; i++ )
|
for ( int i = 0; i < nbNodes; i++ )
|
||||||
myNodes[ i ] = nodes [ i ];
|
myNodes[ i ] = nodes [ i ];
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SMDS_VolumeOfNodes::~SMDS_VolumeOfNodes()
|
||||||
|
{
|
||||||
|
if (myNodes != NULL) {
|
||||||
|
delete [] myNodes;
|
||||||
|
myNodes = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : Print
|
//function : Print
|
||||||
//purpose :
|
//purpose :
|
||||||
@ -134,7 +154,7 @@ int SMDS_VolumeOfNodes::NbFaces() const
|
|||||||
|
|
||||||
int SMDS_VolumeOfNodes::NbNodes() const
|
int SMDS_VolumeOfNodes::NbNodes() const
|
||||||
{
|
{
|
||||||
return myNodes.size();
|
return myNbNodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SMDS_VolumeOfNodes::NbEdges() const
|
int SMDS_VolumeOfNodes::NbEdges() const
|
||||||
@ -152,15 +172,16 @@ int SMDS_VolumeOfNodes::NbEdges() const
|
|||||||
|
|
||||||
class SMDS_VolumeOfNodes_MyIterator:public SMDS_ElemIterator
|
class SMDS_VolumeOfNodes_MyIterator:public SMDS_ElemIterator
|
||||||
{
|
{
|
||||||
const vector<const SMDS_MeshNode*>& mySet;
|
const SMDS_MeshNode* const* mySet;
|
||||||
|
int myLength;
|
||||||
int index;
|
int index;
|
||||||
public:
|
public:
|
||||||
SMDS_VolumeOfNodes_MyIterator(const vector<const SMDS_MeshNode*>& s):
|
SMDS_VolumeOfNodes_MyIterator(const SMDS_MeshNode* const* s, int l):
|
||||||
mySet(s),index(0) {}
|
mySet(s),myLength(l),index(0) {}
|
||||||
|
|
||||||
bool more()
|
bool more()
|
||||||
{
|
{
|
||||||
return index<mySet.size();
|
return index<myLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SMDS_MeshElement* next()
|
const SMDS_MeshElement* next()
|
||||||
@ -178,7 +199,7 @@ SMDS_ElemIteratorPtr SMDS_VolumeOfNodes::
|
|||||||
case SMDSAbs_Volume:
|
case SMDSAbs_Volume:
|
||||||
return SMDS_MeshElement::elementsIterator(SMDSAbs_Volume);
|
return SMDS_MeshElement::elementsIterator(SMDSAbs_Volume);
|
||||||
case SMDSAbs_Node:
|
case SMDSAbs_Node:
|
||||||
return SMDS_ElemIteratorPtr(new SMDS_VolumeOfNodes_MyIterator(myNodes));
|
return SMDS_ElemIteratorPtr(new SMDS_VolumeOfNodes_MyIterator(myNodes,myNbNodes));
|
||||||
default:
|
default:
|
||||||
MESSAGE("ERROR : Iterator not implemented");
|
MESSAGE("ERROR : Iterator not implemented");
|
||||||
return SMDS_ElemIteratorPtr((SMDS_ElemIterator*)NULL);
|
return SMDS_ElemIteratorPtr((SMDS_ElemIterator*)NULL);
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
#define _SMDS_VolumeOfNodes_HeaderFile
|
#define _SMDS_VolumeOfNodes_HeaderFile
|
||||||
|
|
||||||
#include "SMDS_MeshVolume.hxx"
|
#include "SMDS_MeshVolume.hxx"
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
|
|
||||||
class SMDS_VolumeOfNodes:public SMDS_MeshVolume
|
class SMDS_VolumeOfNodes:public SMDS_MeshVolume
|
||||||
@ -64,6 +63,7 @@ class SMDS_VolumeOfNodes:public SMDS_MeshVolume
|
|||||||
const SMDS_MeshNode * node8);
|
const SMDS_MeshNode * node8);
|
||||||
bool ChangeNodes(const SMDS_MeshNode* nodes[],
|
bool ChangeNodes(const SMDS_MeshNode* nodes[],
|
||||||
const int nbNodes);
|
const int nbNodes);
|
||||||
|
~SMDS_VolumeOfNodes();
|
||||||
|
|
||||||
void Print(std::ostream & OS) const;
|
void Print(std::ostream & OS) const;
|
||||||
int NbFaces() const;
|
int NbFaces() const;
|
||||||
@ -73,6 +73,7 @@ class SMDS_VolumeOfNodes:public SMDS_MeshVolume
|
|||||||
protected:
|
protected:
|
||||||
SMDS_ElemIteratorPtr
|
SMDS_ElemIteratorPtr
|
||||||
elementsIterator(SMDSAbs_ElementType type) const;
|
elementsIterator(SMDSAbs_ElementType type) const;
|
||||||
std::vector<const SMDS_MeshNode *> myNodes;
|
const SMDS_MeshNode** myNodes;
|
||||||
|
int myNbNodes;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user