Back to index

salome-med  6.5.0
CellModel.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 #include "CellModel.hxx"
00021 
00022 #include "InterpKernelException.hxx"
00023 
00024 #include <algorithm>
00025 #include <sstream>
00026 #include <vector>
00027 #include <limits>
00028 
00029 namespace INTERP_KERNEL
00030 {
00031   const char *CellModel::CELL_TYPES_REPR[]={"NORM_POINT1", "NORM_SEG2", "NORM_SEG3", "NORM_TRI3", "NORM_QUAD4",// 0->4
00032                                             "NORM_POLYGON", "NORM_TRI6", "" , "NORM_QUAD8", "",//5->9
00033                                             "", "", "", "", "NORM_TETRA4",//10->14
00034                                             "NORM_PYRA5", "NORM_PENTA6", "", "NORM_HEXA8", "",//15->19
00035                                             "NORM_TETRA10", "", "NORM_HEXGP12", "NORM_PYRA13", "",//20->24
00036                                             "NORM_PENTA15", "", "", "", "",//25->29
00037                                             "NORM_HEXA20", "NORM_POLYHED", "NORM_QPOLYG", "NORM_POLYL", "",//30->34
00038                                             "", "", "", "", "",//35->39
00039                                             "NORM_ERROR"};
00040 
00041   std::map<NormalizedCellType,CellModel> CellModel::_map_of_unique_instance;
00042 
00043   const CellModel& CellModel::GetCellModel(NormalizedCellType type)
00044   {
00045     if(_map_of_unique_instance.empty())
00046       buildUniqueInstance();
00047     const std::map<NormalizedCellType,CellModel>::iterator iter=_map_of_unique_instance.find(type);
00048     if(iter==_map_of_unique_instance.end())
00049       {
00050         std::ostringstream stream; stream << "no cellmodel for normalized type " << type;
00051         throw Exception(stream.str().c_str());
00052       }
00053     return (*iter).second;
00054   }
00055 
00056   const char *CellModel::getRepr() const
00057   {
00058     return CELL_TYPES_REPR[(int)_type];
00059   }
00060 
00064   bool CellModel::isCompatibleWith(NormalizedCellType type) const
00065   {
00066     if(_type==type)
00067       return true;
00068     const CellModel& other=GetCellModel(type);
00069     if(_dim!=other.getDimension())
00070       return false;
00071     bool b1=isQuadratic();
00072     bool b2=other.isQuadratic();
00073     if((b1 && !b2) || (!b1 && b2))
00074       return false;
00075     b1=isDynamic();
00076     b2=other.isDynamic();
00077     return b1 || b2;
00078   }
00079 
00080   void CellModel::buildUniqueInstance()
00081   {
00082     _map_of_unique_instance.insert(std::make_pair(NORM_POINT1,CellModel(NORM_POINT1)));
00083     _map_of_unique_instance.insert(std::make_pair(NORM_SEG2,CellModel(NORM_SEG2)));
00084     _map_of_unique_instance.insert(std::make_pair(NORM_SEG3,CellModel(NORM_SEG3)));
00085     _map_of_unique_instance.insert(std::make_pair(NORM_TRI3,CellModel(NORM_TRI3)));
00086     _map_of_unique_instance.insert(std::make_pair(NORM_QUAD4,CellModel(NORM_QUAD4)));
00087     _map_of_unique_instance.insert(std::make_pair(NORM_TRI6,CellModel(NORM_TRI6)));
00088     _map_of_unique_instance.insert(std::make_pair(NORM_QUAD8,CellModel(NORM_QUAD8)));
00089     _map_of_unique_instance.insert(std::make_pair(NORM_TETRA4,CellModel(NORM_TETRA4)));
00090     _map_of_unique_instance.insert(std::make_pair(NORM_HEXA8,CellModel(NORM_HEXA8)));
00091     _map_of_unique_instance.insert(std::make_pair(NORM_PYRA5,CellModel(NORM_PYRA5)));
00092     _map_of_unique_instance.insert(std::make_pair(NORM_PENTA6,CellModel(NORM_PENTA6)));
00093     _map_of_unique_instance.insert(std::make_pair(NORM_TETRA10,CellModel(NORM_TETRA10)));
00094     _map_of_unique_instance.insert(std::make_pair(NORM_HEXGP12,CellModel(NORM_HEXGP12)));
00095     _map_of_unique_instance.insert(std::make_pair(NORM_PYRA13,CellModel(NORM_PYRA13)));
00096     _map_of_unique_instance.insert(std::make_pair(NORM_PENTA15,CellModel(NORM_PENTA15)));
00097     _map_of_unique_instance.insert(std::make_pair(NORM_HEXA20,CellModel(NORM_HEXA20)));
00098     _map_of_unique_instance.insert(std::make_pair(NORM_POLYGON,CellModel(NORM_POLYGON)));
00099     _map_of_unique_instance.insert(std::make_pair(NORM_POLYHED,CellModel(NORM_POLYHED)));
00100     _map_of_unique_instance.insert(std::make_pair(NORM_QPOLYG,CellModel(NORM_QPOLYG)));
00101     _map_of_unique_instance.insert(std::make_pair(NORM_POLYL,CellModel(NORM_POLYL)));
00102     _map_of_unique_instance.insert(std::make_pair(NORM_ERROR,CellModel(NORM_ERROR)));
00103   }
00104 
00105   CellModel::CellModel(NormalizedCellType type):_type(type)
00106   {
00107     _is_extruded=false;
00108     _quadratic=false;
00109     _dyn=false;
00110     _extruded_type=NORM_ERROR;
00111     _linear_type=NORM_ERROR;
00112     _quadratic_type=NORM_ERROR;
00113     switch(type)
00114       {
00115       case NORM_POINT1:
00116         {
00117           _nb_of_pts=1; _nb_of_sons=0; _dim=0; _extruded_type=NORM_SEG2; _is_simplex=true;
00118         }
00119         break;
00120       case NORM_SEG2:
00121         {
00122           _nb_of_pts=2; _nb_of_sons=0; _dim=1; _extruded_type=NORM_QUAD4; _quadratic_type=NORM_SEG3; _is_simplex=true; _is_extruded=true;
00123         }
00124         break;
00125       case NORM_SEG3:
00126         {
00127           _nb_of_pts=3; _nb_of_sons=0; _dim=1; _extruded_type=NORM_QUAD8; _linear_type=NORM_SEG2; _quadratic=true; _is_simplex=false;
00128         }
00129         break;
00130       case NORM_TETRA4:
00131         {
00132           _nb_of_pts=4; _nb_of_sons=4; _dim=3; _quadratic_type=NORM_TETRA10; _is_simplex=true;
00133           _sons_type[0]=NORM_TRI3; _sons_type[1]=NORM_TRI3; _sons_type[2]=NORM_TRI3; _sons_type[3]=NORM_TRI3;
00134           _sons_con[0][0]=0; _sons_con[0][1]=1; _sons_con[0][2]=2; _nb_of_sons_con[0]=3;
00135           _sons_con[1][0]=0; _sons_con[1][1]=3; _sons_con[1][2]=1; _nb_of_sons_con[1]=3;
00136           _sons_con[2][0]=1; _sons_con[2][1]=3; _sons_con[2][2]=2; _nb_of_sons_con[2]=3;
00137           _sons_con[3][0]=2; _sons_con[3][1]=3; _sons_con[3][2]=0; _nb_of_sons_con[3]=3;
00138         }
00139         break;
00140       case NORM_HEXA8:
00141         {
00142           _nb_of_pts=8; _nb_of_sons=6; _dim=3; _quadratic_type=NORM_HEXA20; _is_simplex=false; _is_extruded=true;
00143           _sons_type[0]=NORM_QUAD4; _sons_type[1]=NORM_QUAD4; _sons_type[2]=NORM_QUAD4; _sons_type[3]=NORM_QUAD4; _sons_type[4]=NORM_QUAD4; _sons_type[5]=NORM_QUAD4;
00144           _sons_con[0][0]=0; _sons_con[0][1]=1; _sons_con[0][2]=2; _sons_con[0][3]=3; _nb_of_sons_con[0]=4;
00145           _sons_con[1][0]=4; _sons_con[1][1]=7; _sons_con[1][2]=6; _sons_con[1][3]=5; _nb_of_sons_con[1]=4;
00146           _sons_con[2][0]=0; _sons_con[2][1]=4; _sons_con[2][2]=5; _sons_con[2][3]=1; _nb_of_sons_con[2]=4;
00147           _sons_con[3][0]=1; _sons_con[3][1]=5; _sons_con[3][2]=6; _sons_con[3][3]=2; _nb_of_sons_con[3]=4;
00148           _sons_con[4][0]=2; _sons_con[4][1]=6; _sons_con[4][2]=7; _sons_con[4][3]=3; _nb_of_sons_con[4]=4;
00149           _sons_con[5][0]=3; _sons_con[5][1]=7; _sons_con[5][2]=4; _sons_con[5][3]=0; _nb_of_sons_con[5]=4;
00150         }
00151         break;
00152       case NORM_QUAD4:
00153         {
00154           _nb_of_pts=4; _nb_of_sons=4; _dim=2; _quadratic_type=NORM_QUAD8; _is_simplex=false; _is_extruded=true;
00155           _sons_type[0]=NORM_SEG2; _sons_type[1]=NORM_SEG2; _sons_type[2]=NORM_SEG2; _sons_type[3]=NORM_SEG2;
00156           _sons_con[0][0]=0; _sons_con[0][1]=1; _nb_of_sons_con[0]=2;
00157           _sons_con[1][0]=1; _sons_con[1][1]=2; _nb_of_sons_con[1]=2;
00158           _sons_con[2][0]=2; _sons_con[2][1]=3; _nb_of_sons_con[2]=2;
00159           _sons_con[3][0]=3; _sons_con[3][1]=0; _nb_of_sons_con[3]=2; _extruded_type=NORM_HEXA8;
00160         }
00161         break;
00162       case NORM_TRI3:
00163         {
00164           _nb_of_pts=3; _nb_of_sons=3; _dim=2; _quadratic_type=NORM_TRI6; _is_simplex=true;
00165           _sons_type[0]=NORM_SEG2; _sons_type[1]=NORM_SEG2; _sons_type[2]=NORM_SEG2;
00166           _sons_con[0][0]=0; _sons_con[0][1]=1; _nb_of_sons_con[0]=2;
00167           _sons_con[1][0]=1; _sons_con[1][1]=2; _nb_of_sons_con[1]=2;
00168           _sons_con[2][0]=2; _sons_con[2][1]=0; _nb_of_sons_con[2]=2; _extruded_type=NORM_PENTA6;
00169         }
00170         break;
00171       case NORM_TRI6:
00172         {
00173           _nb_of_pts=6; _nb_of_sons=3; _dim=2; _linear_type=NORM_TRI3; _is_simplex=false;
00174           _sons_type[0]=NORM_SEG3; _sons_type[1]=NORM_SEG3; _sons_type[2]=NORM_SEG3;
00175           _sons_con[0][0]=0; _sons_con[0][1]=1; _sons_con[0][2]=3; _nb_of_sons_con[0]=3;
00176           _sons_con[1][0]=1; _sons_con[1][1]=2; _sons_con[1][2]=4; _nb_of_sons_con[1]=3;
00177           _sons_con[2][0]=2; _sons_con[2][1]=0; _sons_con[2][2]=5; _nb_of_sons_con[2]=3; _quadratic=true; _extruded_type=NORM_PENTA15;
00178         }
00179         break;
00180       case NORM_QUAD8:
00181         {
00182           _nb_of_pts=8; _nb_of_sons=4; _dim=2; _linear_type=NORM_QUAD4; _is_simplex=false;
00183           _sons_type[0]=NORM_SEG3; _sons_type[1]=NORM_SEG3; _sons_type[2]=NORM_SEG3; _sons_type[3]=NORM_SEG3;
00184           _sons_con[0][0]=0; _sons_con[0][1]=1; _sons_con[0][2]=4; _nb_of_sons_con[0]=3;
00185           _sons_con[1][0]=1; _sons_con[1][1]=2; _sons_con[1][2]=5; _nb_of_sons_con[1]=3;
00186           _sons_con[2][0]=2; _sons_con[2][1]=3; _sons_con[2][2]=6; _nb_of_sons_con[2]=3;
00187           _sons_con[3][0]=3; _sons_con[3][1]=0; _sons_con[3][2]=7; _nb_of_sons_con[3]=3; _quadratic=true; _extruded_type=NORM_HEXA20;
00188         }
00189         break;
00190       case NORM_PYRA5:
00191         {
00192           _nb_of_pts=5; _nb_of_sons=5; _dim=3; _quadratic_type=NORM_PYRA13; _is_simplex=false;
00193           _sons_type[0]=NORM_QUAD4; _sons_type[1]=NORM_TRI3; _sons_type[2]=NORM_TRI3; _sons_type[3]=NORM_TRI3; _sons_type[4]=NORM_TRI3;
00194           _sons_con[0][0]=0; _sons_con[0][1]=1; _sons_con[0][2]=2; _sons_con[0][3]=3; _nb_of_sons_con[0]=4;
00195           _sons_con[1][0]=0; _sons_con[1][1]=4; _sons_con[1][2]=1; _nb_of_sons_con[1]=3;
00196           _sons_con[2][0]=1; _sons_con[2][1]=4; _sons_con[2][2]=2; _nb_of_sons_con[2]=3;
00197           _sons_con[3][0]=2; _sons_con[3][1]=4; _sons_con[3][2]=3; _nb_of_sons_con[3]=3;
00198           _sons_con[4][0]=3; _sons_con[4][1]=4; _sons_con[4][2]=0; _nb_of_sons_con[4]=3;
00199         }
00200         break;
00201       case NORM_PENTA6:
00202         {
00203           _nb_of_pts=6; _nb_of_sons=5; _dim=3; _quadratic_type=NORM_PENTA15; _is_simplex=false; _is_extruded=true;
00204           _sons_type[0]=NORM_TRI3; _sons_type[1]=NORM_TRI3; _sons_type[2]=NORM_QUAD4; _sons_type[3]=NORM_QUAD4; _sons_type[4]=NORM_QUAD4;
00205           _sons_con[0][0]=0; _sons_con[0][1]=1; _sons_con[0][2]=2; _nb_of_sons_con[0]=3;
00206           _sons_con[1][0]=3; _sons_con[1][1]=5; _sons_con[1][2]=4; _nb_of_sons_con[1]=3;
00207           _sons_con[2][0]=0; _sons_con[2][1]=3; _sons_con[2][2]=4; _sons_con[2][3]=1; _nb_of_sons_con[2]=4;
00208           _sons_con[3][0]=1; _sons_con[3][1]=4; _sons_con[3][2]=5; _sons_con[3][3]=2; _nb_of_sons_con[3]=4;
00209           _sons_con[4][0]=2; _sons_con[4][1]=5; _sons_con[4][2]=3; _sons_con[4][3]=0; _nb_of_sons_con[4]=4;
00210         }
00211         break;
00212       case NORM_TETRA10:
00213         {
00214           _nb_of_pts=10; _nb_of_sons=4; _dim=3; _linear_type=NORM_TETRA4; _is_simplex=false;
00215           _sons_type[0]=NORM_TRI6; _sons_type[1]=NORM_TRI6; _sons_type[2]=NORM_TRI6; _sons_type[3]=NORM_TRI6;
00216           _sons_con[0][0]=0; _sons_con[0][1]=1; _sons_con[0][2]=2; _sons_con[0][3]=4; _sons_con[0][4]=5; _sons_con[0][5]=6; _nb_of_sons_con[0]=6;
00217           _sons_con[1][0]=0; _sons_con[1][1]=3; _sons_con[1][2]=1; _sons_con[1][3]=7; _sons_con[1][4]=8; _sons_con[1][5]=4; _nb_of_sons_con[1]=6;
00218           _sons_con[2][0]=1; _sons_con[2][1]=3; _sons_con[2][2]=2; _sons_con[2][3]=8; _sons_con[2][4]=9; _sons_con[2][5]=5; _nb_of_sons_con[2]=6;
00219           _sons_con[3][0]=2; _sons_con[3][1]=3; _sons_con[3][2]=0; _sons_con[3][3]=9; _sons_con[3][4]=7; _sons_con[3][5]=6; _nb_of_sons_con[3]=6;  _quadratic=true;
00220         }
00221         break;
00222       case NORM_HEXGP12:
00223         {
00224           _nb_of_pts=12; _nb_of_sons=8; _dim=3; _is_simplex=false; _is_extruded=true;
00225           _sons_type[0]=NORM_POLYGON; _sons_type[1]=NORM_POLYGON; _sons_type[2]=NORM_QUAD4; _sons_type[3]=NORM_QUAD4; _sons_type[4]=NORM_QUAD4; _sons_type[5]=NORM_QUAD4;
00226           _sons_type[6]=NORM_QUAD4; _sons_type[7]=NORM_QUAD4;
00227           _sons_con[0][0]=0; _sons_con[0][1]=1; _sons_con[0][2]=2; _sons_con[0][3]=3; _sons_con[0][4]=4; _sons_con[0][5]=5; _nb_of_sons_con[0]=6;
00228           _sons_con[1][0]=6; _sons_con[1][1]=11; _sons_con[1][2]=10; _sons_con[1][3]=9; _sons_con[1][4]=8; _sons_con[1][5]=7; _nb_of_sons_con[1]=6;
00229           _sons_con[2][0]=0; _sons_con[2][1]=6; _sons_con[2][2]=7; _sons_con[2][3]=1; _nb_of_sons_con[2]=4;
00230           _sons_con[3][0]=1; _sons_con[3][1]=7; _sons_con[3][2]=8; _sons_con[3][3]=2; _nb_of_sons_con[3]=4;
00231           _sons_con[4][0]=2; _sons_con[4][1]=8; _sons_con[4][2]=9; _sons_con[4][3]=3; _nb_of_sons_con[4]=4;
00232           _sons_con[5][0]=3; _sons_con[5][1]=9; _sons_con[5][2]=10; _sons_con[5][3]=4; _nb_of_sons_con[5]=4;
00233           _sons_con[6][0]=4; _sons_con[6][1]=10; _sons_con[6][2]=11; _sons_con[6][3]=5; _nb_of_sons_con[6]=4;
00234           _sons_con[7][0]=5; _sons_con[7][1]=11; _sons_con[7][2]=6; _sons_con[7][3]=0; _nb_of_sons_con[7]=4;
00235         }
00236         break;
00237       case NORM_PYRA13:
00238         {
00239           _nb_of_pts=13; _nb_of_sons=5; _dim=3; _linear_type=NORM_PYRA5; _is_simplex=false;
00240           _sons_type[0]=NORM_QUAD8; _sons_type[1]=NORM_TRI6; _sons_type[2]=NORM_TRI6; _sons_type[3]=NORM_TRI6; _sons_type[4]=NORM_TRI6;
00241           _sons_con[0][0]=0; _sons_con[0][1]=1; _sons_con[0][2]=2; _sons_con[0][3]=3; _sons_con[0][4]=5; _sons_con[0][5]=6; _sons_con[0][6]=7; _sons_con[0][7]=8; _nb_of_sons_con[0]=8;
00242           _sons_con[1][0]=0; _sons_con[1][1]=4; _sons_con[1][2]=1; _sons_con[1][3]=9; _sons_con[1][4]=10; _sons_con[1][5]=5; _nb_of_sons_con[1]=6;
00243           _sons_con[2][0]=1; _sons_con[2][1]=4; _sons_con[2][2]=2; _sons_con[2][3]=10; _sons_con[2][4]=11; _sons_con[2][5]=6; _nb_of_sons_con[2]=6;
00244           _sons_con[3][0]=2; _sons_con[3][1]=4; _sons_con[3][2]=3; _sons_con[3][3]=11; _sons_con[3][4]=12; _sons_con[3][5]=7;  _nb_of_sons_con[3]=6;
00245           _sons_con[4][0]=3; _sons_con[4][1]=4; _sons_con[4][2]=0; _sons_con[4][3]=12; _sons_con[4][4]=9; _sons_con[4][5]=8; _nb_of_sons_con[4]=6; _quadratic=true;
00246         }
00247         break;
00248       case NORM_PENTA15:
00249         {
00250           _nb_of_pts=15; _nb_of_sons=5; _dim=3; _linear_type=NORM_PENTA6; _is_simplex=false;
00251           _sons_type[0]=NORM_TRI6; _sons_type[1]=NORM_TRI6; _sons_type[2]=NORM_QUAD8; _sons_type[3]=NORM_QUAD8; _sons_type[4]=NORM_QUAD8;
00252           _sons_con[0][0]=0; _sons_con[0][1]=1; _sons_con[0][2]=2; _sons_con[0][3]=6; _sons_con[0][4]=7; _sons_con[0][5]=8; _nb_of_sons_con[0]=6;
00253           _sons_con[1][0]=3; _sons_con[1][1]=5; _sons_con[1][2]=4; _sons_con[1][3]=11; _sons_con[1][4]=10; _sons_con[1][5]=9; _nb_of_sons_con[1]=6;
00254           _sons_con[2][0]=0; _sons_con[2][1]=3; _sons_con[2][2]=4; _sons_con[2][3]=1; _sons_con[2][4]=12; _sons_con[2][5]=9; _sons_con[2][6]=13; _sons_con[2][7]=6; _nb_of_sons_con[2]=8;
00255           _sons_con[3][0]=1; _sons_con[3][1]=4; _sons_con[3][2]=5; _sons_con[3][3]=2; _sons_con[3][4]=13; _sons_con[3][5]=10; _sons_con[3][6]=14; _sons_con[3][7]=7; _nb_of_sons_con[3]=8;
00256           _sons_con[4][0]=2; _sons_con[4][1]=4; _sons_con[4][2]=5; _sons_con[4][3]=0; _sons_con[4][4]=14; _sons_con[4][5]=11; _sons_con[4][6]=12; _sons_con[4][7]=8; _nb_of_sons_con[4]=8; _quadratic=true;
00257         }
00258         break;
00259       case NORM_HEXA20:
00260         {
00261           _nb_of_pts=20; _nb_of_sons=6; _dim=3; _linear_type=NORM_HEXA8; _is_simplex=false;
00262           _sons_type[0]=NORM_QUAD8; _sons_type[1]=NORM_QUAD8; _sons_type[2]=NORM_QUAD8; _sons_type[3]=NORM_QUAD8; _sons_type[4]=NORM_QUAD8; _sons_type[5]=NORM_QUAD8;
00263           _sons_con[0][0]=0; _sons_con[0][1]=1; _sons_con[0][2]=2; _sons_con[0][3]=3; _sons_con[0][4]=8; _sons_con[0][5]=9; _sons_con[0][6]=10; _sons_con[0][7]=11; _nb_of_sons_con[0]=8;
00264           _sons_con[1][0]=4; _sons_con[1][1]=7; _sons_con[1][2]=6; _sons_con[1][3]=5; _sons_con[1][4]=15; _sons_con[1][5]=14; _sons_con[1][6]=13; _sons_con[1][7]=12; _nb_of_sons_con[1]=8;
00265           _sons_con[2][0]=0; _sons_con[2][1]=4; _sons_con[2][2]=5; _sons_con[2][3]=1; _sons_con[2][4]=16; _sons_con[2][5]=12; _sons_con[2][6]=17; _sons_con[2][7]=8; _nb_of_sons_con[2]=8;
00266           _sons_con[3][0]=1; _sons_con[3][1]=5; _sons_con[3][3]=6; _sons_con[3][3]=2; _sons_con[3][4]=17; _sons_con[3][5]=13; _sons_con[3][6]=18; _sons_con[3][7]=9;_nb_of_sons_con[3]=8;
00267           _sons_con[4][0]=2; _sons_con[4][1]=6; _sons_con[4][3]=7; _sons_con[4][3]=3; _sons_con[4][4]=18; _sons_con[4][5]=14; _sons_con[4][6]=19; _sons_con[4][7]=10; _nb_of_sons_con[4]=8;
00268           _sons_con[5][0]=3; _sons_con[5][1]=7; _sons_con[5][3]=4; _sons_con[5][3]=0; _sons_con[5][4]=19; _sons_con[5][5]=15; _sons_con[5][6]=16; _sons_con[5][7]=11; _nb_of_sons_con[5]=8; _quadratic=true;
00269         }
00270         break;
00271       case NORM_POLYGON:
00272         {
00273           _nb_of_pts=0; _nb_of_sons=0; _dim=2; _dyn=true; _extruded_type=NORM_POLYHED; _is_simplex=false;
00274         }
00275         break;
00276       case NORM_POLYHED:
00277         {
00278           _nb_of_pts=0; _nb_of_sons=0; _dim=3; _dyn=true; _is_simplex=false;
00279         }
00280         break;
00281       case NORM_QPOLYG:
00282         {
00283           _nb_of_pts=0; _nb_of_sons=0; _dim=2; _dyn=true; _is_simplex=false; _quadratic=true;
00284         }
00285         break;
00286       case NORM_POLYL:
00287         {
00288           _nb_of_pts=0; _nb_of_sons=0; _dim=1; _dyn=true; _extruded_type=NORM_POLYGON; _is_simplex=false;
00289         }
00290       case NORM_ERROR:
00291         {
00292           _nb_of_pts=std::numeric_limits<unsigned>::max(); _nb_of_sons=std::numeric_limits<unsigned>::max(); _dim=std::numeric_limits<unsigned>::max();
00293         }
00294         break;
00295       }
00296   }
00297 
00301   unsigned CellModel::getNumberOfSons2(const int *conn, int lgth) const
00302   {
00303     if(!isDynamic())
00304       return getNumberOfSons();
00305     if(_dim==2)
00306       {
00307         if(_type==NORM_POLYGON)
00308           return lgth;
00309         else
00310           return lgth/2;
00311       }
00312     else if(_dim==1)
00313       return lgth;//NORM_POLYL
00314     else
00315       return std::count(conn,conn+lgth,-1)+1;
00316   }
00317 
00321   NormalizedCellType CellModel::getSonType2(unsigned sonId) const
00322   {
00323     if(!isDynamic())
00324       return getSonType(sonId);
00325     if(_dim==2)
00326       {
00327         if(_type==NORM_POLYGON)
00328           return NORM_SEG2;
00329         else
00330           return NORM_SEG3;
00331       }
00332     else if(_dim==1)
00333       return NORM_ERROR;//NORM_POLYL
00334     //polyedron
00335     return NORM_POLYGON;
00336   }
00337 
00341   unsigned CellModel::fillSonCellNodalConnectivity(int sonId, const int *nodalConn, int *sonNodalConn) const
00342   {
00343     unsigned nbOfTurnLoop=_nb_of_sons_con[sonId];
00344     const unsigned *sonConn=_sons_con[sonId];
00345     for(unsigned i=0;i<nbOfTurnLoop;i++)
00346       sonNodalConn[i]=nodalConn[sonConn[i]];
00347     return nbOfTurnLoop;
00348   }
00349 
00350   unsigned CellModel::fillSonCellNodalConnectivity2(int sonId, const int *nodalConn, int lgth, int *sonNodalConn, NormalizedCellType& typeOfSon) const
00351   {
00352     typeOfSon=getSonType2(sonId);
00353     if(!isDynamic())
00354       return fillSonCellNodalConnectivity(sonId,nodalConn,sonNodalConn);
00355     else
00356       {
00357         if(_dim==2)//polygon
00358           {
00359             if(_type==NORM_POLYGON)
00360               {
00361                 sonNodalConn[0]=nodalConn[sonId];
00362                 sonNodalConn[1]=nodalConn[(sonId+1)%lgth];
00363                 return 2;
00364               }
00365             else
00366               {
00367                 sonNodalConn[0]=nodalConn[sonId];
00368                 sonNodalConn[1]=nodalConn[(sonId+1)%lgth];
00369                 sonNodalConn[2]=nodalConn[sonId+lgth];
00370                 return 3;
00371               }
00372           }
00373         else if(_dim==3)
00374           {//polyedron
00375             const int *where=nodalConn;
00376             for(int i=0;i<sonId;i++)
00377               {
00378                 where=std::find(where,nodalConn+lgth,-1);
00379                 where++;
00380               }
00381             const int *where2=std::find(where,nodalConn+lgth,-1);
00382             std::copy(where,where2,sonNodalConn);
00383             return where2-where;
00384           }
00385         else
00386           throw INTERP_KERNEL::Exception("CellModel::fillSonCellNodalConnectivity2 : no sons on NORM_POLYL !");
00387       }
00388   }
00389 
00390   //================================================================================
00394   //================================================================================
00395 
00396   unsigned CellModel::getNumberOfNodesConstituentTheSon2(unsigned sonId, const int *nodalConn, int lgth) const
00397   {
00398     if(!isDynamic())
00399       return getNumberOfNodesConstituentTheSon(sonId);
00400 
00401     if(_dim==2)//polygon
00402       {
00403         if(_type==NORM_POLYGON)
00404           return 2;
00405         else
00406           return 3;
00407       }
00408     else if(_dim==3)
00409       {//polyedron
00410         const int *where=nodalConn;
00411         for(unsigned int i=0;i<sonId;i++)
00412           {
00413             where=std::find(where,nodalConn+lgth,-1);
00414             where++;
00415           }
00416         const int *where2=std::find(where,nodalConn+lgth,-1);
00417         return where2-where;
00418       }
00419     else
00420       throw INTERP_KERNEL::Exception("CellModel::getNumberOfNodesConstituentTheSon2 : no sons on NORM_POLYL !");
00421   }
00422 
00429   bool CellModel::getOrientationStatus(unsigned lgth, const int *conn1, const int *conn2) const
00430   {
00431     if(_dim!=1 && _dim!=2)
00432       throw INTERP_KERNEL::Exception("CellModel::getOrientationStatus : invalid dimension ! Must be 1 or 2 !");
00433     if(!_quadratic)
00434       {
00435         std::vector<int> tmp(2*lgth);
00436         std::vector<int>::iterator it=std::copy(conn1,conn1+lgth,tmp.begin());
00437         std::copy(conn1,conn1+lgth,it);
00438         it=std::search(tmp.begin(),tmp.end(),conn2,conn2+lgth);
00439         if(it==tmp.begin())
00440           return true;
00441         if(it!=tmp.end())
00442           return _dim!=1;
00443         std::vector<int>::reverse_iterator it2=std::search(tmp.rbegin(),tmp.rend(),conn2,conn2+lgth);
00444         if(it2!=tmp.rend())
00445           return false;
00446         throw INTERP_KERNEL::Exception("CellModel::getOrientationStatus : Request of orientation status of non equal connectively cells !");
00447       }
00448     else
00449       {
00450         if(_dim!=1)
00451           {
00452             std::vector<int> tmp(lgth);
00453             std::vector<int>::iterator it=std::copy(conn1,conn1+lgth/2,tmp.begin());
00454             std::copy(conn1,conn1+lgth/2,it);
00455             it=std::search(tmp.begin(),tmp.end(),conn2,conn2+lgth/2);
00456             int d=std::distance(tmp.begin(),it);
00457             if(it==tmp.end())
00458               return false;
00459             it=std::copy(conn1+lgth/2,conn1+lgth,tmp.begin());
00460             std::copy(conn1+lgth/2,conn1+lgth,it);
00461             it=std::search(tmp.begin(),tmp.end(),conn2,conn2+lgth);
00462             if(it==tmp.end())
00463               return false;
00464             int d2=std::distance(tmp.begin(),it);
00465             return d==d2;
00466           }
00467         else
00468           {
00469             int p=(lgth+1)/2;
00470             std::vector<int> tmp(2*p);
00471             std::vector<int>::iterator it=std::copy(conn1,conn1+p,tmp.begin());
00472             std::copy(conn1,conn1+p,it);
00473             it=std::search(tmp.begin(),tmp.end(),conn2,conn2+p);
00474             int d=std::distance(tmp.begin(),it);
00475             if(it==tmp.end())
00476               return false;
00477             tmp.resize(2*p-2);
00478             it=std::copy(conn1+p,conn1+lgth,tmp.begin());
00479             std::copy(conn1+p,conn1+lgth,it);
00480             it=std::search(tmp.begin(),tmp.end(),conn2+p,conn2+lgth);
00481             if(it==tmp.end())
00482               return false;
00483             int d2=std::distance(tmp.begin(),it);
00484             return d==d2;
00485           }
00486       }
00487   }
00488 
00489 }