smesh/src/SMDS/SMDS_VolumeOfFaces.cxx

170 lines
5.1 KiB
C++
Raw Normal View History

2013-04-01 19:05:47 +06:00
// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
2009-02-17 10:27:49 +05:00
//
2012-08-09 16:03:55 +06:00
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
2009-02-17 10:27:49 +05:00
//
2012-08-09 16:03:55 +06:00
// 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.
2003-09-03 23:09:43 +06:00
//
2012-08-09 16:03:55 +06:00
// 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.
2003-09-03 23:09:43 +06:00
//
2012-08-09 16:03:55 +06:00
// 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
2003-09-03 23:09:43 +06:00
//
2012-08-09 16:03:55 +06:00
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
2003-09-03 23:09:43 +06:00
//
2012-08-09 16:03:55 +06:00
2009-02-17 10:27:49 +05:00
// SMESH SMDS : implementaion of Salome mesh data structure
2004-06-18 14:34:31 +06:00
// File : SMDS_VolumeOfFaces.cxx
2003-09-03 23:09:43 +06:00
// Author : Jean-Michel BOULCOURT
// Module : SMESH
2009-02-17 10:27:49 +05:00
//
2005-01-20 11:25:54 +05:00
#ifdef _MSC_VER
#pragma warning(disable:4786)
#endif
2003-09-03 23:09:43 +06:00
#include "SMDS_VolumeOfFaces.hxx"
#include "SMDS_IteratorOfElements.hxx"
2012-08-09 16:03:55 +06:00
#include "utilities.h"
2004-12-01 15:48:31 +05:00
using namespace std;
2003-09-03 23:09:43 +06:00
//=======================================================================
//function : Print
//purpose :
//=======================================================================
void SMDS_VolumeOfFaces::Print(ostream & OS) const
{
2012-08-09 16:03:55 +06:00
OS << "volume <" << GetID() << "> : ";
int i;
for (i = 0; i < NbFaces()-1; ++i) OS << myFaces[i] << ",";
OS << myFaces[i]<< ") " << endl;
2003-09-03 23:09:43 +06:00
}
int SMDS_VolumeOfFaces::NbFaces() const
{
2012-08-09 16:03:55 +06:00
return myNbFaces;
2003-09-03 23:09:43 +06:00
}
2004-06-18 14:34:31 +06:00
class SMDS_VolumeOfFaces_MyIterator:public SMDS_ElemIterator
2003-09-03 23:09:43 +06:00
{
2005-01-20 11:25:54 +05:00
const SMDS_MeshFace* const *mySet;
int myLength;
2004-06-18 14:34:31 +06:00
int index;
public:
2005-01-20 11:25:54 +05:00
SMDS_VolumeOfFaces_MyIterator(const SMDS_MeshFace* const *s, int l):
mySet(s),myLength(l),index(0) {}
2003-09-03 23:09:43 +06:00
2004-06-18 14:34:31 +06:00
bool more()
{
2005-01-20 11:25:54 +05:00
return index<myLength;
2004-06-18 14:34:31 +06:00
}
2003-09-03 23:09:43 +06:00
2004-06-18 14:34:31 +06:00
const SMDS_MeshElement* next()
{
index++;
return mySet[index-1];
}
};
2003-09-03 23:09:43 +06:00
2004-06-18 14:34:31 +06:00
SMDS_ElemIteratorPtr SMDS_VolumeOfFaces::
2012-08-09 16:03:55 +06:00
elementsIterator(SMDSAbs_ElementType type) const
2004-06-18 14:34:31 +06:00
{
switch(type)
{
case SMDSAbs_Volume:
return SMDS_MeshElement::elementsIterator(SMDSAbs_Volume);
case SMDSAbs_Face:
2005-01-20 11:25:54 +05:00
return SMDS_ElemIteratorPtr(new SMDS_VolumeOfFaces_MyIterator(myFaces,myNbFaces));
2004-06-18 14:34:31 +06:00
default:
return SMDS_ElemIteratorPtr
(new SMDS_IteratorOfElements
2005-01-20 11:25:54 +05:00
(this,type,SMDS_ElemIteratorPtr
(new SMDS_VolumeOfFaces_MyIterator(myFaces,myNbFaces))));
2004-06-18 14:34:31 +06:00
}
2003-09-03 23:09:43 +06:00
}
2004-06-18 14:34:31 +06:00
SMDS_VolumeOfFaces::SMDS_VolumeOfFaces(const SMDS_MeshFace * face1,
const SMDS_MeshFace * face2,
const SMDS_MeshFace * face3,
const SMDS_MeshFace * face4)
2003-09-03 23:09:43 +06:00
{
2012-08-09 16:03:55 +06:00
//MESSAGE("****************************************************** SMDS_VolumeOfFaces");
myNbFaces = 4;
myFaces[0]=face1;
myFaces[1]=face2;
myFaces[2]=face3;
myFaces[3]=face4;
myFaces[4]=0;
myFaces[5]=0;
2003-09-03 23:09:43 +06:00
}
2004-06-18 14:34:31 +06:00
SMDS_VolumeOfFaces::SMDS_VolumeOfFaces(const SMDS_MeshFace * face1,
const SMDS_MeshFace * face2,
const SMDS_MeshFace * face3,
const SMDS_MeshFace * face4,
const SMDS_MeshFace * face5)
2003-09-03 23:09:43 +06:00
{
2012-08-09 16:03:55 +06:00
//MESSAGE("****************************************************** SMDS_VolumeOfFaces");
myNbFaces = 5;
myFaces[0]=face1;
myFaces[1]=face2;
myFaces[2]=face3;
myFaces[3]=face4;
myFaces[4]=face5;
myFaces[5]=0;
2003-09-03 23:09:43 +06:00
}
2004-06-18 14:34:31 +06:00
SMDS_VolumeOfFaces::SMDS_VolumeOfFaces(const SMDS_MeshFace * face1,
const SMDS_MeshFace * face2,
const SMDS_MeshFace * face3,
const SMDS_MeshFace * face4,
const SMDS_MeshFace * face5,
const SMDS_MeshFace * face6)
2003-09-03 23:09:43 +06:00
{
2012-08-09 16:03:55 +06:00
//MESSAGE("****************************************************** SMDS_VolumeOfFaces");
myNbFaces = 6;
myFaces[0]=face1;
myFaces[1]=face2;
myFaces[2]=face3;
myFaces[3]=face4;
myFaces[4]=face5;
myFaces[5]=face6;
}
SMDSAbs_EntityType SMDS_VolumeOfFaces::GetEntityType() const
{
SMDSAbs_EntityType aType = SMDSEntity_Tetra;
switch(myNbFaces)
{
case 4: aType = SMDSEntity_Tetra; break;
case 5: aType = SMDSEntity_Pyramid; break;
case 6: aType = SMDSEntity_Penta; break;
case 8:
default: aType = SMDSEntity_Hexa; break;
}
return aType;
2003-09-03 23:09:43 +06:00
}
2012-08-09 16:03:55 +06:00
SMDSAbs_GeometryType SMDS_VolumeOfFaces::GetGeomType() const
{
SMDSAbs_GeometryType aType = SMDSGeom_NONE;
switch(myNbFaces)
{
case 4: aType = SMDSGeom_TETRA; break;
case 5: aType = SMDSGeom_PYRAMID; break;
case 6: aType = SMDSGeom_PENTA; break;
case 8:
default: aType = SMDSGeom_HEXA; break;
}
return aType;
}