From: jrt Date: Fri, 12 Sep 2003 15:12:19 +0000 (+0000) Subject: Add HexahedronOfNodes and Tria3OfNodes to improve performance X-Git-Tag: V1_2_2~6 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e0b529896b95749166851a7fc9bb83d7f52b43cf;p=modules%2Fsmesh.git Add HexahedronOfNodes and Tria3OfNodes to improve performance --- diff --git a/src/SMDS/Makefile.in b/src/SMDS/Makefile.in index 963d204f2..5c3e9abd9 100644 --- a/src/SMDS/Makefile.in +++ b/src/SMDS/Makefile.in @@ -56,7 +56,9 @@ LIB_SRC = \ SMDS_VolumeOfFaces.cxx \ SMDS_VolumeOfNodes.cxx \ SMDS_FaceOfEdges.cxx \ - SMDS_FaceOfNodes.cxx + SMDS_FaceOfNodes.cxx \ + SMDS_Tria3OfNodes.cxx \ + SMDS_HexahedronOfNodes.cxx #SMDSControl_BoundaryEdges.cxx \ #SMDSControl_BoundaryFaces.cxx \ @@ -104,7 +106,9 @@ EXPORT_HEADERS= \ SMDS_VolumeOfFaces.hxx \ SMDS_VolumeOfNodes.hxx \ SMDS_FaceOfEdges.hxx \ - SMDS_FaceOfNodes.hxx + SMDS_FaceOfNodes.hxx \ + SMDS_Tria3OfNodes.hxx \ + SMDS_HexahedronOfNodes.hxx #SMDSControl_BoundaryEdges.hxx \ #SMDSControl_BoundaryFaces.hxx \ diff --git a/src/SMDS/SMDS_HexahedronOfNodes.cxx b/src/SMDS/SMDS_HexahedronOfNodes.cxx new file mode 100644 index 000000000..cebd29a11 --- /dev/null +++ b/src/SMDS/SMDS_HexahedronOfNodes.cxx @@ -0,0 +1,95 @@ +// 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_HexahedronOfNodes.hxx" +#include "SMDS_IteratorOfArray.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_HexahedronOfNodes::SMDS_HexahedronOfNodes( + 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_HexahedronOfNodes::Print(ostream & OS) const +{ + OS << "volume <" << GetID() << "> : "; + int i; + for (i = 0; i < 7; ++i) OS << myNodes[i] << ","; + OS << myNodes[7]<< ") " << endl; +} + +int SMDS_HexahedronOfNodes::NbFaces() const +{ + return 6; +} + +int SMDS_HexahedronOfNodes::NbNodes() const +{ + return 8; +} + +int SMDS_HexahedronOfNodes::NbEdges() const +{ + return 12; +} + +SMDS_Iterator * SMDS_HexahedronOfNodes:: + elementsIterator(SMDSAbs_ElementType type) const +{ + switch(type) + { + case SMDSAbs_Volume: + return SMDS_MeshElement::elementsIterator(SMDSAbs_Volume); + case SMDSAbs_Node: + return new SMDS_IteratorOfArray(myNodes); + default: MESSAGE("ERROR : Iterator not implemented"); + } +} + +SMDSAbs_ElementType SMDS_HexahedronOfNodes::GetType() const +{ + return SMDSAbs_Volume; +} diff --git a/src/SMDS/SMDS_HexahedronOfNodes.hxx b/src/SMDS/SMDS_HexahedronOfNodes.hxx new file mode 100644 index 000000000..2e3f22f4a --- /dev/null +++ b/src/SMDS/SMDS_HexahedronOfNodes.hxx @@ -0,0 +1,58 @@ +// 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_HexahedronOfNodes_HeaderFile +#define _SMDS_HexahedronOfNodes_HeaderFile + +#include "SMDS_MeshVolume.hxx" +#include +using namespace std; + +class SMDS_HexahedronOfNodes:public SMDS_MeshVolume +{ + + public: + SMDS_HexahedronOfNodes( + 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; + const SMDS_MeshNode * myNodes[8]; +}; +#endif diff --git a/src/SMDS/SMDS_Mesh.cxx b/src/SMDS/SMDS_Mesh.cxx index 6623b37ef..daabeb0f8 100644 --- a/src/SMDS/SMDS_Mesh.cxx +++ b/src/SMDS/SMDS_Mesh.cxx @@ -24,6 +24,8 @@ #include "SMDS_VolumeOfNodes.hxx" #include "SMDS_VolumeOfFaces.hxx" #include "SMDS_FaceOfNodes.hxx" +#include "SMDS_Tria3OfNodes.hxx" +#include "SMDS_HexahedronOfNodes.hxx" #include "SMDS_FaceOfEdges.hxx" /////////////////////////////////////////////////////////////////////////////// @@ -593,10 +595,10 @@ SMDS_MeshVolume * SMDS_Mesh::AddVolumeWithID(int idnode1, int idnode2, } /////////////////////////////////////////////////////////////////////////////// -///Create a new prism and add it to the mesh. +///Create a new hexahedron and add it to the mesh. ///Nodes 1,2,3,4 and 5,6,7,8 are quadrangle and 5,1 and 7,3 are an edges. ///@param ID The ID of the new volume -///@return The created prism or NULL if an edge with this ID already exists +///@return The created prism or NULL if an hexadron with this ID already exists ///or if input nodes are not found. /////////////////////////////////////////////////////////////////////////////// @@ -638,7 +640,7 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID( } else { - volume=new SMDS_VolumeOfNodes(node1,node2,node3,node4,node5,node6, + volume=new SMDS_HexahedronOfNodes(node1,node2,node3,node4,node5,node6, node7,node8); myVolumes.insert(volume); } @@ -690,7 +692,7 @@ SMDS_MeshFace * SMDS_Mesh::createTriangle(SMDS_MeshNode * node1, } else { - SMDS_MeshFace * face = new SMDS_FaceOfNodes(node1,node2,node3); + SMDS_MeshFace * face = new SMDS_Tria3OfNodes(node1,node2,node3); myFaces.insert(face); return face; } diff --git a/src/SMDS/SMDS_Tria3OfNodes.cxx b/src/SMDS/SMDS_Tria3OfNodes.cxx new file mode 100644 index 000000000..c3a96337d --- /dev/null +++ b/src/SMDS/SMDS_Tria3OfNodes.cxx @@ -0,0 +1,101 @@ +// 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_Tria3OfNodes.hxx" +#include "SMDS_IteratorOfElements.hxx" +#include "SMDS_MeshNode.hxx" +#include "utilities.h" + +//======================================================================= +//function : NbEdges +//purpose : +//======================================================================= + +int SMDS_Tria3OfNodes::NbEdges() const +{ + return 3; +} + +int SMDS_Tria3OfNodes::NbFaces() const +{ + return 3; +} + +int SMDS_Tria3OfNodes::NbNodes() const +{ + return 3; +} +//======================================================================= +//function : Print +//purpose : +//======================================================================= + +void SMDS_Tria3OfNodes::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_Tria3OfNodes:: + 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<3; + } + + const SMDS_MeshElement* next() + { + index++; + return mySet[index-1]; + } + }; + + switch(type) + { + case SMDSAbs_Face:return SMDS_MeshElement::elementsIterator(SMDSAbs_Face); + case SMDSAbs_Node:return new MyIterator(myNodes); + case SMDSAbs_Edge: + MESSAGE("Error : edge iterator for SMDS_FaceOfNodes not implemented"); + break; + default:return new SMDS_IteratorOfElements(this,type,new MyIterator(myNodes)); + } +} + +SMDS_Tria3OfNodes::SMDS_Tria3OfNodes(SMDS_MeshNode* node1, SMDS_MeshNode* node2, + SMDS_MeshNode* node3) +{ + myNodes[0]=node1; + myNodes[1]=node2; + myNodes[2]=node3; +} + + diff --git a/src/SMDS/SMDS_Tria3OfNodes.hxx b/src/SMDS/SMDS_Tria3OfNodes.hxx new file mode 100644 index 000000000..a52dd7a1f --- /dev/null +++ b/src/SMDS/SMDS_Tria3OfNodes.hxx @@ -0,0 +1,49 @@ +// 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 + +#ifndef _SMDS_Tria3OfNodes_HeaderFile +#define _SMDS_Tria3OfNodes_HeaderFile + +#include +#include "SMDS_MeshFace.hxx" +#include "SMDS_MeshNode.hxx" +#include "SMDS_Iterator.hxx" + +class SMDS_Tria3OfNodes:public SMDS_MeshFace +{ + public: + void Print(ostream & OS) const; + SMDS_Tria3OfNodes(SMDS_MeshNode* node1, SMDS_MeshNode* node2, + SMDS_MeshNode* node3); + + int NbEdges() const; + int NbFaces() const; + int NbNodes() const; + protected: + SMDS_Iterator * + elementsIterator(SMDSAbs_ElementType type) const; + + private: + const SMDS_MeshNode* myNodes[3]; + +}; + +#endif