Back to index

salome-smesh  6.5.0
SMDS_VolumeOfFaces.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  SMESH SMDS : implementaion of Salome mesh data structure
00024 //  File   : SMDS_VolumeOfFaces.cxx
00025 //  Author : Jean-Michel BOULCOURT
00026 //  Module : SMESH
00027 //
00028 #ifdef _MSC_VER
00029 #pragma warning(disable:4786)
00030 #endif
00031 
00032 #include "SMDS_VolumeOfFaces.hxx"
00033 #include "SMDS_IteratorOfElements.hxx"
00034 #include "utilities.h"
00035 
00036 using namespace std;
00037 
00038 //=======================================================================
00039 //function : Print
00040 //purpose  : 
00041 //=======================================================================
00042 
00043 void SMDS_VolumeOfFaces::Print(ostream & OS) const
00044 {
00045         OS << "volume <" << GetID() << "> : ";
00046         int i;
00047         for (i = 0; i < NbFaces()-1; ++i) OS << myFaces[i] << ",";
00048         OS << myFaces[i]<< ") " << endl;
00049 }
00050 
00051 
00052 int SMDS_VolumeOfFaces::NbFaces() const
00053 {
00054         return myNbFaces;
00055 }
00056 
00057 class SMDS_VolumeOfFaces_MyIterator:public SMDS_ElemIterator
00058 {
00059   const SMDS_MeshFace* const *mySet;
00060   int myLength;
00061   int index;
00062  public:
00063   SMDS_VolumeOfFaces_MyIterator(const SMDS_MeshFace* const *s, int l):
00064     mySet(s),myLength(l),index(0) {}
00065 
00066   bool more()
00067   {
00068     return index<myLength;
00069   }
00070 
00071   const SMDS_MeshElement* next()
00072   {
00073     index++;
00074     return mySet[index-1];
00075   }
00076 };
00077 
00078 SMDS_ElemIteratorPtr SMDS_VolumeOfFaces::
00079         elementsIterator(SMDSAbs_ElementType type) const
00080 {
00081   switch(type)
00082   {
00083   case SMDSAbs_Volume:
00084     return SMDS_MeshElement::elementsIterator(SMDSAbs_Volume);
00085   case SMDSAbs_Face:
00086     return SMDS_ElemIteratorPtr(new SMDS_VolumeOfFaces_MyIterator(myFaces,myNbFaces));
00087   default:
00088     return SMDS_ElemIteratorPtr
00089       (new SMDS_IteratorOfElements
00090        (this,type,SMDS_ElemIteratorPtr
00091         (new SMDS_VolumeOfFaces_MyIterator(myFaces,myNbFaces))));
00092   }
00093 }
00094 
00095 SMDS_VolumeOfFaces::SMDS_VolumeOfFaces(const SMDS_MeshFace * face1,
00096                                        const SMDS_MeshFace * face2,
00097                                        const SMDS_MeshFace * face3,
00098                                        const SMDS_MeshFace * face4)
00099 {
00100   //MESSAGE("****************************************************** SMDS_VolumeOfFaces");
00101         myNbFaces = 4;
00102         myFaces[0]=face1;
00103         myFaces[1]=face2;
00104         myFaces[2]=face3;
00105         myFaces[3]=face4;
00106         myFaces[4]=0;
00107         myFaces[5]=0;
00108 }
00109 
00110 SMDS_VolumeOfFaces::SMDS_VolumeOfFaces(const SMDS_MeshFace * face1,
00111                                        const SMDS_MeshFace * face2,
00112                                        const SMDS_MeshFace * face3,
00113                                        const SMDS_MeshFace * face4,
00114                                        const SMDS_MeshFace * face5)
00115 {
00116   //MESSAGE("****************************************************** SMDS_VolumeOfFaces");
00117         myNbFaces = 5;
00118         myFaces[0]=face1;
00119         myFaces[1]=face2;
00120         myFaces[2]=face3;
00121         myFaces[3]=face4;
00122         myFaces[4]=face5;
00123         myFaces[5]=0;
00124 }
00125 
00126 SMDS_VolumeOfFaces::SMDS_VolumeOfFaces(const SMDS_MeshFace * face1,
00127                                        const SMDS_MeshFace * face2,
00128                                        const SMDS_MeshFace * face3,
00129                                        const SMDS_MeshFace * face4,
00130                                        const SMDS_MeshFace * face5,
00131                                        const SMDS_MeshFace * face6)
00132 {
00133   //MESSAGE("****************************************************** SMDS_VolumeOfFaces");
00134         myNbFaces = 6;
00135         myFaces[0]=face1;
00136         myFaces[1]=face2;
00137         myFaces[2]=face3;
00138         myFaces[3]=face4;
00139         myFaces[4]=face5;
00140         myFaces[5]=face6;
00141 }
00142 
00143 SMDSAbs_EntityType SMDS_VolumeOfFaces::GetEntityType() const
00144 {
00145   SMDSAbs_EntityType aType = SMDSEntity_Tetra;
00146   switch(myNbFaces)
00147   {
00148   case 4: aType = SMDSEntity_Tetra;   break;
00149   case 5: aType = SMDSEntity_Pyramid; break;
00150   case 6: aType = SMDSEntity_Penta;   break;
00151   case 8:
00152   default: aType = SMDSEntity_Hexa;    break;
00153   }
00154   return aType;
00155 }