Salome HOME
Add HexahedronOfNodes and Tria3OfNodes to improve performance
authorjrt <jrt>
Fri, 12 Sep 2003 15:12:19 +0000 (15:12 +0000)
committerjrt <jrt>
Fri, 12 Sep 2003 15:12:19 +0000 (15:12 +0000)
src/SMDS/Makefile.in
src/SMDS/SMDS_HexahedronOfNodes.cxx [new file with mode: 0644]
src/SMDS/SMDS_HexahedronOfNodes.hxx [new file with mode: 0644]
src/SMDS/SMDS_Mesh.cxx
src/SMDS/SMDS_Tria3OfNodes.cxx [new file with mode: 0644]
src/SMDS/SMDS_Tria3OfNodes.hxx [new file with mode: 0644]

index 963d204f20db418ad00d8651ccb5be3c31d84a18..5c3e9abd99e88dcbc3f7451c80aa0836b6caa951 100644 (file)
@@ -56,7 +56,9 @@ LIB_SRC = \
        SMDS_VolumeOfFaces.cxx \
        SMDS_VolumeOfNodes.cxx \
        SMDS_FaceOfEdges.cxx \
        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 \
 
 #SMDSControl_BoundaryEdges.cxx \
 #SMDSControl_BoundaryFaces.cxx \
@@ -104,7 +106,9 @@ EXPORT_HEADERS= \
        SMDS_VolumeOfFaces.hxx \
        SMDS_VolumeOfNodes.hxx \
        SMDS_FaceOfEdges.hxx \
        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 \
 
 #SMDSControl_BoundaryEdges.hxx \
 #SMDSControl_BoundaryFaces.hxx \
diff --git a/src/SMDS/SMDS_HexahedronOfNodes.cxx b/src/SMDS/SMDS_HexahedronOfNodes.cxx
new file mode 100644 (file)
index 0000000..cebd29a
--- /dev/null
@@ -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<const SMDS_MeshElement *> * 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<const SMDS_MeshElement *, 8,
+                       const SMDS_MeshNode*>(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 (file)
index 0000000..2e3f22f
--- /dev/null
@@ -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 <vector>
+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<const SMDS_MeshElement *> *
+               elementsIterator(SMDSAbs_ElementType type) const;
+       const SMDS_MeshNode * myNodes[8];
+};
+#endif
index 6623b37efba33c2c8069c512bb3f98c696c49f17..daabeb0f8818cad87e9675b94e75d5af0a2c3665 100644 (file)
@@ -24,6 +24,8 @@
 #include "SMDS_VolumeOfNodes.hxx"
 #include "SMDS_VolumeOfFaces.hxx"
 #include "SMDS_FaceOfNodes.hxx"
 #include "SMDS_VolumeOfNodes.hxx"
 #include "SMDS_VolumeOfFaces.hxx"
 #include "SMDS_FaceOfNodes.hxx"
+#include "SMDS_Tria3OfNodes.hxx"
+#include "SMDS_HexahedronOfNodes.hxx"
 #include "SMDS_FaceOfEdges.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
 ///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.
 ///////////////////////////////////////////////////////////////////////////////
 
 ///or if input nodes are not found.
 ///////////////////////////////////////////////////////////////////////////////
 
@@ -638,7 +640,7 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(
        }
        else
        {
        }
        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);
        }
                        node7,node8);
                myVolumes.insert(volume);
        }
@@ -690,7 +692,7 @@ SMDS_MeshFace * SMDS_Mesh::createTriangle(SMDS_MeshNode * node1,
        }
        else
        {
        }
        else
        {
-               SMDS_MeshFace * face = new SMDS_FaceOfNodes(node1,node2,node3);
+               SMDS_MeshFace * face = new SMDS_Tria3OfNodes(node1,node2,node3);
                myFaces.insert(face);
                return face;
        }
                myFaces.insert(face);
                return face;
        }
diff --git a/src/SMDS/SMDS_Tria3OfNodes.cxx b/src/SMDS/SMDS_Tria3OfNodes.cxx
new file mode 100644 (file)
index 0000000..c3a9633
--- /dev/null
@@ -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<const SMDS_MeshElement *> * SMDS_Tria3OfNodes::
+       elementsIterator(SMDSAbs_ElementType type) const
+{
+       class MyIterator:public SMDS_Iterator<const SMDS_MeshElement*>
+       {
+               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 (file)
index 0000000..a52dd7a
--- /dev/null
@@ -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 <ostream>
+#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<const SMDS_MeshElement *> *
+               elementsIterator(SMDSAbs_ElementType type) const;
+
+  private:
+       const SMDS_MeshNode* myNodes[3];
+
+};
+
+#endif