From: msv Date: Fri, 14 Jan 2005 13:26:34 +0000 (+0000) Subject: Improve SMDS: replace std::vector with simple array X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=61d5fb0e6af3cb09f55c9c995be5b2a9b0c2a357;p=modules%2Fsmesh.git Improve SMDS: replace std::vector with simple array for storage of links to nodes in mesh elements --- diff --git a/src/SMDS/SMDS_FaceOfEdges.cxx b/src/SMDS/SMDS_FaceOfEdges.cxx index de9092f44..640c55d30 100644 --- a/src/SMDS/SMDS_FaceOfEdges.cxx +++ b/src/SMDS/SMDS_FaceOfEdges.cxx @@ -19,6 +19,10 @@ // // 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_IteratorOfElements.hxx" #include "SMDS_MeshNode.hxx" @@ -32,7 +36,7 @@ using namespace std; int SMDS_FaceOfEdges::NbEdges() const { - return myEdges.size(); + return myNbEdges; } int SMDS_FaceOfEdges::NbFaces() const @@ -57,17 +61,23 @@ SMDSAbs_ElementType SMDS_FaceOfEdges::GetType() const return SMDSAbs_Face; } +//======================================================================= +//function : elementsIterator +//purpose : +//======================================================================= + class SMDS_FaceOfEdges_MyIterator:public SMDS_ElemIterator { - const vector& mySet; + const SMDS_MeshEdge* const *mySet; + int myLength; int index; public: - SMDS_FaceOfEdges_MyIterator(const vector& s): - mySet(s),index(0) {} + SMDS_FaceOfEdges_MyIterator(const SMDS_MeshEdge* const *s, int l): + mySet(s),myLength(l),index(0) {} bool more() { - return index myEdges; + const SMDS_MeshEdge* myEdges[4]; + int myNbEdges; }; diff --git a/src/SMDS/SMDS_FaceOfNodes.cxx b/src/SMDS/SMDS_FaceOfNodes.cxx index 2ef48ca8a..aa6870824 100644 --- a/src/SMDS/SMDS_FaceOfNodes.cxx +++ b/src/SMDS/SMDS_FaceOfNodes.cxx @@ -19,6 +19,10 @@ // // 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_IteratorOfElements.hxx" #include "SMDS_MeshNode.hxx" @@ -43,8 +47,9 @@ int SMDS_FaceOfNodes::NbFaces() const int SMDS_FaceOfNodes::NbNodes() const { - return myNodes.size(); + return myNbNodes; } + //======================================================================= //function : Print //purpose : @@ -58,41 +63,49 @@ void SMDS_FaceOfNodes::Print(ostream & OS) const OS << myNodes[i] << ") " << endl; } +//======================================================================= +//function : elementsIterator +//purpose : +//======================================================================= + class SMDS_FaceOfNodes_MyIterator:public SMDS_ElemIterator { - const vector& mySet; + const SMDS_MeshNode* const *mySet; + int myLength; int index; public: - SMDS_FaceOfNodes_MyIterator(const vector& s): - mySet(s),index(0) {} + SMDS_FaceOfNodes_MyIterator(const SMDS_MeshNode* const *s, int l): + mySet(s),myLength(l),index(0) {} bool more() { - return index myNodes; + const SMDS_MeshNode* myNodes[4]; + int myNbNodes; }; diff --git a/src/SMDS/SMDS_VolumeOfFaces.cxx b/src/SMDS/SMDS_VolumeOfFaces.cxx index a710a8ffe..51e71f86c 100644 --- a/src/SMDS/SMDS_VolumeOfFaces.cxx +++ b/src/SMDS/SMDS_VolumeOfFaces.cxx @@ -25,6 +25,10 @@ // Author : Jean-Michel BOULCOURT // Module : SMESH +#ifdef _MSC_VER +#pragma warning(disable:4786) +#endif + #include "SMDS_VolumeOfFaces.hxx" #include "SMDS_IteratorOfElements.hxx" @@ -39,27 +43,28 @@ void SMDS_VolumeOfFaces::Print(ostream & OS) const { OS << "volume <" << GetID() << "> : "; 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; } int SMDS_VolumeOfFaces::NbFaces() const { - return myFaces.size(); + return myNbFaces; } class SMDS_VolumeOfFaces_MyIterator:public SMDS_ElemIterator { - const vector& mySet; + const SMDS_MeshFace* const *mySet; + int myLength; int index; public: - SMDS_VolumeOfFaces_MyIterator(const vector& s): - mySet(s),index(0) {} + SMDS_VolumeOfFaces_MyIterator(const SMDS_MeshFace* const *s, int l): + mySet(s),myLength(l),index(0) {} bool more() { - return index #include @@ -61,6 +60,7 @@ class SMDS_VolumeOfFaces:public SMDS_MeshVolume protected: SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type) const; - std::vector myFaces; + const SMDS_MeshFace * myFaces[6]; + int myNbFaces; }; #endif diff --git a/src/SMDS/SMDS_VolumeOfNodes.cxx b/src/SMDS/SMDS_VolumeOfNodes.cxx index 25c0bf567..cd893f484 100644 --- a/src/SMDS/SMDS_VolumeOfNodes.cxx +++ b/src/SMDS/SMDS_VolumeOfNodes.cxx @@ -19,6 +19,10 @@ // // 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_MeshNode.hxx" #include "utilities.h" @@ -39,7 +43,8 @@ SMDS_VolumeOfNodes::SMDS_VolumeOfNodes( const SMDS_MeshNode * node7, const SMDS_MeshNode * node8) { - myNodes.resize(8); + myNbNodes = 8; + myNodes = new const SMDS_MeshNode* [myNbNodes]; myNodes[0]=node1; myNodes[1]=node2; myNodes[2]=node3; @@ -56,7 +61,8 @@ SMDS_VolumeOfNodes::SMDS_VolumeOfNodes( const SMDS_MeshNode * node3, const SMDS_MeshNode * node4) { - myNodes.resize(4); + myNbNodes = 4; + myNodes = new const SMDS_MeshNode* [myNbNodes]; myNodes[0]=node1; myNodes[1]=node2; myNodes[2]=node3; @@ -70,7 +76,8 @@ SMDS_VolumeOfNodes::SMDS_VolumeOfNodes( const SMDS_MeshNode * node4, const SMDS_MeshNode * node5) { - myNodes.resize(5); + myNbNodes = 5; + myNodes = new const SMDS_MeshNode* [myNbNodes]; myNodes[0]=node1; myNodes[1]=node2; myNodes[2]=node3; @@ -86,7 +93,8 @@ SMDS_VolumeOfNodes::SMDS_VolumeOfNodes( const SMDS_MeshNode * node5, const SMDS_MeshNode * node6) { - myNodes.resize(6); + myNbNodes = 6; + myNodes = new const SMDS_MeshNode* [myNbNodes]; myNodes[0]=node1; myNodes[1]=node2; myNodes[2]=node3; @@ -94,18 +102,30 @@ SMDS_VolumeOfNodes::SMDS_VolumeOfNodes( myNodes[4]=node5; myNodes[5]=node6; } + bool SMDS_VolumeOfNodes::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes) { if (nbNodes < 4 || nbNodes > 8 || nbNodes == 7) return false; - myNodes.resize( nbNodes ); + delete [] myNodes; + myNbNodes = nbNodes; + myNodes = new const SMDS_MeshNode* [myNbNodes]; for ( int i = 0; i < nbNodes; i++ ) myNodes[ i ] = nodes [ i ]; return true; } + +SMDS_VolumeOfNodes::~SMDS_VolumeOfNodes() +{ + if (myNodes != NULL) { + delete [] myNodes; + myNodes = NULL; + } +} + //======================================================================= //function : Print //purpose : @@ -134,7 +154,7 @@ int SMDS_VolumeOfNodes::NbFaces() const int SMDS_VolumeOfNodes::NbNodes() const { - return myNodes.size(); + return myNbNodes; } int SMDS_VolumeOfNodes::NbEdges() const @@ -152,15 +172,16 @@ int SMDS_VolumeOfNodes::NbEdges() const class SMDS_VolumeOfNodes_MyIterator:public SMDS_ElemIterator { - const vector& mySet; + const SMDS_MeshNode* const* mySet; + int myLength; int index; public: - SMDS_VolumeOfNodes_MyIterator(const vector& s): - mySet(s),index(0) {} + SMDS_VolumeOfNodes_MyIterator(const SMDS_MeshNode* const* s, int l): + mySet(s),myLength(l),index(0) {} bool more() { - return index class SMDS_VolumeOfNodes:public SMDS_MeshVolume @@ -64,6 +63,7 @@ class SMDS_VolumeOfNodes:public SMDS_MeshVolume const SMDS_MeshNode * node8); bool ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes); + ~SMDS_VolumeOfNodes(); void Print(std::ostream & OS) const; int NbFaces() const; @@ -73,6 +73,7 @@ class SMDS_VolumeOfNodes:public SMDS_MeshVolume protected: SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type) const; - std::vector myNodes; + const SMDS_MeshNode** myNodes; + int myNbNodes; }; #endif