From: jrt Date: Wed, 3 Sep 2003 17:09:43 +0000 (+0000) Subject: Add needed class for the new DS X-Git-Tag: V1_2_2~43 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8d51808a8fa523dc3a98e8eeebea02a28b112f82;p=modules%2Fsmesh.git Add needed class for the new DS --- diff --git a/src/SMDS/SMDS_FaceOfEdges.cxx b/src/SMDS/SMDS_FaceOfEdges.cxx new file mode 100644 index 000000000..0e9243d3f --- /dev/null +++ b/src/SMDS/SMDS_FaceOfEdges.cxx @@ -0,0 +1,135 @@ +// SMESH SMDS : implementaion of Salome mesh data structure +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +#include "SMDS_FaceOfEdges.hxx" +#include "SMDS_IteratorOfElements.hxx" +#include "SMDS_MeshNode.hxx" + +//======================================================================= +//function : NbEdges +//purpose : +//======================================================================= + +int SMDS_FaceOfEdges::NbEdges() const +{ + return myEdges.size(); +} + +int SMDS_FaceOfEdges::NbFaces() const +{ + return 1; +} +//======================================================================= +//function : Print +//purpose : +//======================================================================= + +void SMDS_FaceOfEdges::Print(ostream & OS) const +{ + OS << "face <" << GetID() << " > : "; + int i; + for (i = 0; i < NbEdges() - 1; i++) OS << myEdges[i] << ","; + OS << myEdges[i] << ") " << endl; +} + +SMDSAbs_ElementType SMDS_FaceOfEdges::GetType() const +{ + return SMDSAbs_Face; +} + +SMDS_Iterator * SMDS_FaceOfEdges:: + elementsIterator(SMDSAbs_ElementType type) const +{ + class MyIterator:public SMDS_Iterator + { + const vector& mySet; + int index; + public: + MyIterator(const vector& s):mySet(s),index(0) + {} + + bool more() + { + return index set1,set2; + SMDS_Iterator * it; + const SMDS_MeshNode * n; + + it=f1.nodesIterator(); + + while(it->more()) + { + n=static_cast(it->next()); + set1.insert(*n); + } + + delete it; + it=f2.nodesIterator(); + + while(it->more()) + { + n=static_cast(it->next()); + set2.insert(*n); + } + + delete it; + return set1 +#include "SMDS_MeshFace.hxx" +#include "SMDS_MeshEdge.hxx" +#include "SMDS_Iterator.hxx" + +class SMDS_FaceOfEdges:public SMDS_MeshFace +{ + public: + void Print(ostream & OS) const; + SMDS_FaceOfEdges(SMDS_MeshEdge* edge1, SMDS_MeshEdge* edge2, + SMDS_MeshEdge* edge3); + SMDS_FaceOfEdges(SMDS_MeshEdge* edge1, SMDS_MeshEdge* edge2, + SMDS_MeshEdge* edge3, SMDS_MeshEdge* edge4); + + SMDSAbs_ElementType GetType() const; + int NbEdges() const; + int NbFaces() const; +// friend bool operator<(const SMDS_FaceOfEdges& e1, const SMDS_FaceOfEdges& e2); + + protected: + SMDS_Iterator * + elementsIterator(SMDSAbs_ElementType type) const; + + private: + vector myEdges; + +}; + +#endif diff --git a/src/SMDS/SMDS_FaceOfNodes.cxx b/src/SMDS/SMDS_FaceOfNodes.cxx new file mode 100644 index 000000000..9a9a945f9 --- /dev/null +++ b/src/SMDS/SMDS_FaceOfNodes.cxx @@ -0,0 +1,139 @@ +// SMESH SMDS : implementaion of Salome mesh data structure +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +#include "SMDS_FaceOfNodes.hxx" +#include "SMDS_IteratorOfElements.hxx" +#include "SMDS_MeshNode.hxx" +#include "utilities.h" + +//======================================================================= +//function : NbEdges +//purpose : +//======================================================================= + +int SMDS_FaceOfNodes::NbEdges() const +{ + return NbNodes(); +} + +int SMDS_FaceOfNodes::NbFaces() const +{ + return 1; +} + +int SMDS_FaceOfNodes::NbNodes() const +{ + return myNodes.size(); +} +//======================================================================= +//function : Print +//purpose : +//======================================================================= + +void SMDS_FaceOfNodes::Print(ostream & OS) const +{ + OS << "face <" << GetID() << " > : "; + int i; + for (i = 0; i < NbNodes() - 1; i++) OS << myNodes[i] << ","; + OS << myNodes[i] << ") " << endl; +} + +SMDS_Iterator * SMDS_FaceOfNodes:: + elementsIterator(SMDSAbs_ElementType type) const +{ + class MyIterator:public SMDS_Iterator + { + const vector& mySet; + int index; + public: + MyIterator(const vector& s):mySet(s),index(0) + {} + + bool more() + { + return index set1,set2; + SMDS_Iterator * it; + const SMDS_MeshNode * n; + + it=f1.nodesIterator(); + + while(it->more()) + { + n=static_cast(it->next()); + set1.insert(*n); + } + + delete it; + it=f2.nodesIterator(); + + while(it->more()) + { + n=static_cast(it->next()); + set2.insert(*n); + } + + delete it; + return set1 +#include "SMDS_MeshFace.hxx" +#include "SMDS_MeshNode.hxx" +#include "SMDS_Iterator.hxx" + +class SMDS_FaceOfNodes:public SMDS_MeshFace +{ + public: + void Print(ostream & OS) const; + SMDS_FaceOfNodes(SMDS_MeshNode* node1, SMDS_MeshNode* node2, + SMDS_MeshNode* node3); + SMDS_FaceOfNodes(SMDS_MeshNode* node1, SMDS_MeshNode* node2, + SMDS_MeshNode* node3, SMDS_MeshNode* node4); + + int NbEdges() const; + int NbFaces() const; + int NbNodes() const; + protected: + SMDS_Iterator * + elementsIterator(SMDSAbs_ElementType type) const; + + private: + vector myNodes; + +}; + +#endif diff --git a/src/SMDS/SMDS_VolumeOfFaces.cxx b/src/SMDS/SMDS_VolumeOfFaces.cxx new file mode 100644 index 000000000..c221452ba --- /dev/null +++ b/src/SMDS/SMDS_VolumeOfFaces.cxx @@ -0,0 +1,114 @@ +// SMESH SMDS : implementaion of Salome mesh data structure +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMDS_MeshVolume.cxx +// Author : Jean-Michel BOULCOURT +// Module : SMESH + +#include "SMDS_VolumeOfFaces.hxx" +#include "SMDS_IteratorOfElements.hxx" +//======================================================================= +//function : Print +//purpose : +//======================================================================= + +void SMDS_VolumeOfFaces::Print(ostream & OS) const +{ + OS << "volume <" << GetID() << "> : "; + int i; + for (i = 0; i < myFaces.size()-1; ++i) OS << myFaces[i] << ","; + OS << myFaces[i]<< ") " << endl; +} + + +int SMDS_VolumeOfFaces::NbFaces() const +{ + return myFaces.size(); +} + +SMDS_Iterator * SMDS_VolumeOfFaces:: + elementsIterator(SMDSAbs_ElementType type) const +{ + class MyIterator:public SMDS_Iterator + { + const vector& mySet; + int index; + public: + MyIterator(const vector& s):mySet(s),index(0) + {} + + bool more() + { + return index +#include +using namespace std; + +class SMDS_VolumeOfFaces:public SMDS_MeshVolume +{ + + public: + SMDS_VolumeOfFaces(SMDS_MeshFace * face1, SMDS_MeshFace * face2, + SMDS_MeshFace * face3, SMDS_MeshFace * face4); + SMDS_VolumeOfFaces(SMDS_MeshFace * face1, SMDS_MeshFace * face2, + SMDS_MeshFace * face3, SMDS_MeshFace * face4, + SMDS_MeshFace * face5); + SMDS_VolumeOfFaces(SMDS_MeshFace * face1, SMDS_MeshFace * face2, + SMDS_MeshFace * face3, SMDS_MeshFace * face4, + SMDS_MeshFace * face5,SMDS_MeshFace * face6); + + void Print(ostream & OS) const; + + int NbFaces() const; + + protected: + SMDS_Iterator * + elementsIterator(SMDSAbs_ElementType type) const; + vector myFaces; +}; +#endif diff --git a/src/SMDS/SMDS_VolumeOfNodes.cxx b/src/SMDS/SMDS_VolumeOfNodes.cxx new file mode 100644 index 000000000..f09fa620a --- /dev/null +++ b/src/SMDS/SMDS_VolumeOfNodes.cxx @@ -0,0 +1,112 @@ +// SMESH SMDS : implementaion of Salome mesh data structure +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +#include "utilities.h" +#include "SMDS_VolumeOfNodes.hxx" +#include "SMDS_MeshNode.hxx" + +/////////////////////////////////////////////////////////////////////////////// +/// Create an hexahedron. node 1,2,3,4 and 5,6,7,8 are quadrangle and +/// 5,1 and 7,3 are an edges. +/////////////////////////////////////////////////////////////////////////////// +SMDS_VolumeOfNodes::SMDS_VolumeOfNodes( + SMDS_MeshNode * node1, + SMDS_MeshNode * node2, + SMDS_MeshNode * node3, + SMDS_MeshNode * node4, + SMDS_MeshNode * node5, + SMDS_MeshNode * node6, + SMDS_MeshNode * node7, + SMDS_MeshNode * node8) +{ + myNodes[0]=node1; + myNodes[1]=node2; + myNodes[2]=node3; + myNodes[3]=node4; + myNodes[4]=node5; + myNodes[5]=node6; + myNodes[6]=node7; + myNodes[7]=node8; +} + +//======================================================================= +//function : Print +//purpose : +//======================================================================= + +void SMDS_VolumeOfNodes::Print(ostream & OS) const +{ + OS << "volume <" << GetID() << "> : "; + int i; + for (i = 0; i < 7; ++i) OS << myNodes[i] << ","; + OS << myNodes[7]<< ") " << endl; +} + +int SMDS_VolumeOfNodes::NbFaces() const +{ + return 6; +} + +int SMDS_VolumeOfNodes::NbNodes() const +{ + return 8; +} + +int SMDS_VolumeOfNodes::NbEdges() const +{ + return 12; +} + +SMDS_Iterator * SMDS_VolumeOfNodes:: + elementsIterator(SMDSAbs_ElementType type) const +{ + class MyIterator:public SMDS_Iterator + { + const SMDS_MeshNode * const* mySet; + int index; + public: + MyIterator(const SMDS_MeshNode * const* s):mySet(s),index(0) + {} + + bool more() + { + return index<8; + } + + const SMDS_MeshElement* next() + { + index++; + return mySet[index-1]; + } + }; + + switch(type) + { + case SMDSAbs_Volume:return SMDS_MeshElement::elementsIterator(SMDSAbs_Volume); + case SMDSAbs_Node:return new MyIterator(myNodes); + default: MESSAGE("ERROR : Iterator not implemented"); + } +} + +SMDSAbs_ElementType SMDS_VolumeOfNodes::GetType() const +{ + return SMDSAbs_Volume; +} diff --git a/src/SMDS/SMDS_VolumeOfNodes.hxx b/src/SMDS/SMDS_VolumeOfNodes.hxx new file mode 100644 index 000000000..224067341 --- /dev/null +++ b/src/SMDS/SMDS_VolumeOfNodes.hxx @@ -0,0 +1,56 @@ +// SMESH SMDS : implementaion of Salome mesh data structure +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMDS_MeshVolume.hxx +// Module : SMESH + +#ifndef _SMDS_VolumeOfNodes_HeaderFile +#define _SMDS_VolumeOfNodes_HeaderFile + +#include "SMDS_MeshVolume.hxx" + +class SMDS_VolumeOfNodes:public SMDS_MeshVolume +{ + + public: + SMDS_VolumeOfNodes( + SMDS_MeshNode * node1, + SMDS_MeshNode * node2, + SMDS_MeshNode * node3, + SMDS_MeshNode * node4, + SMDS_MeshNode * node5, + SMDS_MeshNode * node6, + SMDS_MeshNode * node7, + SMDS_MeshNode * node8); + + void Print(ostream & OS) const; + int NbFaces() const; + int NbNodes() const; + int NbEdges() const; + SMDSAbs_ElementType GetType() const; + protected: + SMDS_Iterator * + elementsIterator(SMDSAbs_ElementType type) const; + SMDS_MeshNode * myNodes[8]; +}; +#endif