#include <vector>
#include <limits>
+unsigned char MEDCOUPLING2VTKTYPETRADUCER[INTERP_KERNEL::NORM_MAXTYPE+1]={1,3,21,5,9,7,22,34,23,28,35,MEDCOUPLING2VTKTYPETRADUCER_NONE,MEDCOUPLING2VTKTYPETRADUCER_NONE,MEDCOUPLING2VTKTYPETRADUCER_NONE,10,14,13,MEDCOUPLING2VTKTYPETRADUCER_NONE,12,MEDCOUPLING2VTKTYPETRADUCER_NONE,24,MEDCOUPLING2VTKTYPETRADUCER_NONE,16,27,MEDCOUPLING2VTKTYPETRADUCER_NONE,26,MEDCOUPLING2VTKTYPETRADUCER_NONE,29,32,MEDCOUPLING2VTKTYPETRADUCER_NONE,25,42,36,4};
+
namespace INTERP_KERNEL
{
const char *CellModel::CELL_TYPES_REPR[]={"NORM_POINT1", "NORM_SEG2", "NORM_SEG3", "NORM_TRI3", "NORM_QUAD4",// 0->4
#include <map>
+constexpr int MEDCOUPLING2VTKTYPETRADUCER_LGTH=INTERP_KERNEL::NORM_MAXTYPE+1;
+
+constexpr unsigned char MEDCOUPLING2VTKTYPETRADUCER_NONE = 255;
+
+INTERPKERNEL_EXPORT extern unsigned char MEDCOUPLING2VTKTYPETRADUCER[INTERP_KERNEL::NORM_MAXTYPE+1];
+
namespace INTERP_KERNEL
{
class DiameterCalculator;
#include <sstream>
#include <fstream>
#include <numeric>
+#include <memory>
#include <cstring>
#include <limits>
#include <list>
double MEDCouplingUMesh::EPS_FOR_POLYH_ORIENTATION=1.e-14;
/// @cond INTERNAL
+
const INTERP_KERNEL::NormalizedCellType MEDCouplingUMesh::MEDMEM_ORDER[N_MEDMEM_ORDER] = { INTERP_KERNEL::NORM_POINT1, INTERP_KERNEL::NORM_SEG2, INTERP_KERNEL::NORM_SEG3, INTERP_KERNEL::NORM_SEG4, INTERP_KERNEL::NORM_POLYL, INTERP_KERNEL::NORM_TRI3, INTERP_KERNEL::NORM_QUAD4, INTERP_KERNEL::NORM_TRI6, INTERP_KERNEL::NORM_TRI7, INTERP_KERNEL::NORM_QUAD8, INTERP_KERNEL::NORM_QUAD9, INTERP_KERNEL::NORM_POLYGON, INTERP_KERNEL::NORM_QPOLYG, INTERP_KERNEL::NORM_TETRA4, INTERP_KERNEL::NORM_PYRA5, INTERP_KERNEL::NORM_PENTA6, INTERP_KERNEL::NORM_HEXA8, INTERP_KERNEL::NORM_HEXGP12, INTERP_KERNEL::NORM_TETRA10, INTERP_KERNEL::NORM_PYRA13, INTERP_KERNEL::NORM_PENTA15, INTERP_KERNEL::NORM_PENTA18, INTERP_KERNEL::NORM_HEXA20, INTERP_KERNEL::NORM_HEXA27, INTERP_KERNEL::NORM_POLYHED };
-const mcIdType MEDCouplingUMesh::MEDCOUPLING2VTKTYPETRADUCER[INTERP_KERNEL::NORM_MAXTYPE+1]={1,3,21,5,9,7,22,34,23,28,-1,-1,-1,-1,10,14,13,-1,12,-1,24,-1,16,27,-1,26,-1,29,32,-1,25,42,36,4};
/// @endcond
MEDCouplingUMesh *MEDCouplingUMesh::New()
w4=std::copy(c.begin(),c.end(),w4);
}
}
- types->transformWithIndArr(MEDCOUPLING2VTKTYPETRADUCER,MEDCOUPLING2VTKTYPETRADUCER+INTERP_KERNEL::NORM_MAXTYPE+1);
+ std::unique_ptr<mcIdType[]> medcoupling2vtkTypeTraducer_mcIdType(new mcIdType[MEDCOUPLING2VTKTYPETRADUCER_LGTH]);
+ for(auto ii = 0; ii<MEDCOUPLING2VTKTYPETRADUCER_LGTH ; ++ii)
+ medcoupling2vtkTypeTraducer_mcIdType[ii] = MEDCOUPLING2VTKTYPETRADUCER[ii]!=MEDCOUPLING2VTKTYPETRADUCER_NONE?MEDCOUPLING2VTKTYPETRADUCER[ii] : -1;
+ types->transformWithIndArr(medcoupling2vtkTypeTraducer_mcIdType.get(),medcoupling2vtkTypeTraducer_mcIdType.get()+MEDCOUPLING2VTKTYPETRADUCER_LGTH);
types->writeVTK(ofs,8,"UInt8","types",byteData);
std::string vtkTypeName = Traits<mcIdType>::VTKReprStr;
offsets->writeVTK(ofs,8,vtkTypeName,"offsets",byteData);
MEDCOUPLING_EXPORT static DataArrayIdType *ComputeRangesFromTypeDistribution(const std::vector<mcIdType>& code);
MEDCOUPLING_EXPORT static const int N_MEDMEM_ORDER=25;
MEDCOUPLING_EXPORT static const INTERP_KERNEL::NormalizedCellType MEDMEM_ORDER[N_MEDMEM_ORDER];
- MEDCOUPLING_EXPORT static const mcIdType MEDCOUPLING2VTKTYPETRADUCER[INTERP_KERNEL::NORM_MAXTYPE+1];
/// @endcond
private:
int _mesh_dim;
{
PyObject *med2vtk_cell_types()
{
- Py_ssize_t sz(sizeof(MEDCouplingUMesh::MEDCOUPLING2VTKTYPETRADUCER)/sizeof(decltype(MEDCouplingUMesh::MEDCOUPLING2VTKTYPETRADUCER[0])));
+ Py_ssize_t sz(sizeof(MEDCOUPLING2VTKTYPETRADUCER)/sizeof(decltype(MEDCOUPLING2VTKTYPETRADUCER[0])));
PyObject *ret(PyList_New(sz));
for(Py_ssize_t i=0;i<sz;i++)
{
- PyList_SetItem(ret,i,PyInt_FromLong(MEDCouplingUMesh::MEDCOUPLING2VTKTYPETRADUCER[i]));
+ mcIdType elt = MEDCOUPLING2VTKTYPETRADUCER[i]!=255 ? MEDCOUPLING2VTKTYPETRADUCER[i] : -1;
+ PyList_SetItem(ret,i,PyInt_FromLong(elt));
}
return ret;
}
PyObject *vtk2med_cell_types()
{
- Py_ssize_t sz(sizeof(MEDCouplingUMesh::MEDCOUPLING2VTKTYPETRADUCER)/sizeof(decltype(MEDCouplingUMesh::MEDCOUPLING2VTKTYPETRADUCER[0])));
- auto maxElt(*std::max_element(MEDCouplingUMesh::MEDCOUPLING2VTKTYPETRADUCER,MEDCouplingUMesh::MEDCOUPLING2VTKTYPETRADUCER+sz));
+ Py_ssize_t sz(sizeof(MEDCOUPLING2VTKTYPETRADUCER)/sizeof(decltype(MEDCOUPLING2VTKTYPETRADUCER[0])));
+ auto maxElt(*std::max_element(MEDCOUPLING2VTKTYPETRADUCER,MEDCOUPLING2VTKTYPETRADUCER+sz,[](unsigned char a, unsigned char b) { if(b==MEDCOUPLING2VTKTYPETRADUCER_NONE) return false; else return a<b; } ));
auto szOut(maxElt+1);
std::vector< mcIdType > retCpp(szOut,-1);
mcIdType id(0);
- for(const mcIdType *it=MEDCouplingUMesh::MEDCOUPLING2VTKTYPETRADUCER;it!=MEDCouplingUMesh::MEDCOUPLING2VTKTYPETRADUCER+sz;it++,id++)
+ for(const unsigned char *it=MEDCOUPLING2VTKTYPETRADUCER;it!=MEDCOUPLING2VTKTYPETRADUCER+sz;it++,id++)
{
- if(*it!=-1)
+ if(*it!=MEDCOUPLING2VTKTYPETRADUCER_NONE)
retCpp[*it]=id;
}
//
extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO];
extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
-extern med_geometry_type typmai3[34];
+extern med_geometry_type typmai3[INTERP_KERNEL::NORM_MAXTYPE];
extern med_geometry_type typmainoeud[1];
using namespace MEDCoupling;
extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
extern med_geometry_type typmainoeud[1];
-extern med_geometry_type typmai3[34];
+extern med_geometry_type typmai3[INTERP_KERNEL::NORM_MAXTYPE];
using namespace MEDCoupling;
extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO];
extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
-extern med_geometry_type typmai3[34];
+extern med_geometry_type typmai3[INTERP_KERNEL::NORM_MAXTYPE];
using namespace MEDCoupling;
MEDlocalizationInfoByName(fid,locName.c_str(),&geotype,&dim,&nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
_dim=FromMedInt<int>(dim);
_nb_gauss_pt=FromMedInt<int>(nb_gauss_pt);
- _gt=new MEDFileGTKeeperSta((INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype))));
+ _gt=new MEDFileGTKeeperSta((INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+INTERP_KERNEL::NORM_MAXTYPE,geotype))));
const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
_nb_node_per_cell=cm.getNumberOfNodes();
_ref_coo.resize(_dim*_nb_node_per_cell);
std::string sectionName(MEDLoaderBase::buildStringFromFortran(sectionmeshname,MED_NAME_SIZE));
if(sectionName.empty())
{
- _gt=new MEDFileGTKeeperSta((INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype))));
+ _gt=new MEDFileGTKeeperSta((INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+INTERP_KERNEL::NORM_MAXTYPE,geotype))));
const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
_nb_node_per_cell=cm.getNumberOfNodes();
}
using namespace MEDCoupling;
-const unsigned char MEDMeshMultiLev::PARAMEDMEM_2_VTKTYPE[MEDMeshMultiLev::PARAMEDMEM_2_VTKTYPE_LGTH]=
-{1,3,21,5,9,7,22,34,23,28,35,255,255,255,10,14,13,255,12,255,24,255,16,27,255,26,255,29,32,255,25,42,36,4};
+const unsigned char *MEDMeshMultiLev::PARAMEDMEM_2_VTKTYPE=MEDCOUPLING2VTKTYPETRADUCER;
const unsigned char MEDMeshMultiLev::HEXA27_PERM_ARRAY[27]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,24,22,21,23,20,25,26};
MCAuto<DataArrayIdType> _node_fam_ids;
MCAuto<DataArrayIdType> _node_num_ids;
public:
- MEDLOADER_EXPORT static const int PARAMEDMEM_2_VTKTYPE_LGTH=34;
- MEDLOADER_EXPORT static const unsigned char PARAMEDMEM_2_VTKTYPE[PARAMEDMEM_2_VTKTYPE_LGTH];
+ MEDLOADER_EXPORT static const int PARAMEDMEM_2_VTKTYPE_LGTH=MEDCOUPLING2VTKTYPETRADUCER_LGTH;
+ MEDLOADER_EXPORT static const unsigned char *PARAMEDMEM_2_VTKTYPE;
MEDLOADER_EXPORT static const unsigned char HEXA27_PERM_ARRAY[27];
};
extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO];
extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
-extern med_geometry_type typmai3[34];
+extern med_geometry_type typmai3[INTERP_KERNEL::NORM_MAXTYPE];
using namespace MEDCoupling;
extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO];
extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
-extern med_geometry_type typmai3[34];
+extern med_geometry_type typmai3[INTERP_KERNEL::NORM_MAXTYPE];
using namespace MEDCoupling;
#include <iostream>
-extern med_geometry_type typmai3[34];
+extern med_geometry_type typmai3[INTERP_KERNEL::NORM_MAXTYPE];
using namespace MEDCoupling;
MEDFileUMeshPerType *MEDFileUMeshPerType::NewPart(med_idt fid, const char *mName, int dt, int it, int mdim, INTERP_KERNEL::NormalizedCellType geoElt2, mcIdType strt, mcIdType stp, mcIdType step, MEDFileMeshReadSelector *mrs)
{
int geoElt2i((int)geoElt2);
- if(geoElt2i<0 || geoElt2i>=34)
+ if(geoElt2i<0 || geoElt2i>=INTERP_KERNEL::NORM_MAXTYPE)
throw INTERP_KERNEL::Exception("MEDFileUMeshPerType::NewPart : Not recognized MEDCoupling/MEDLoader geometric type !");
med_geometry_type geoElt(typmai3[geoElt2]);
med_entity_type whichEntity;
INTERP_KERNEL::NORM_QPOLYG,
INTERP_KERNEL::NORM_POLYHED };
-med_geometry_type typmai3[34] = { MED_POINT1,//0
+med_geometry_type typmai3[INTERP_KERNEL::NORM_MAXTYPE] = { MED_POINT1,//0
MED_SEG2,//1
MED_SEG3,//2
MED_TRIA3,//3
MED_NONE,//29
MED_HEXA20,//30
MED_POLYHEDRON,//31
- MED_POLYGON2,//32
- MED_NONE//33
+ MED_POLYGON2//32
};
double _EPS_FOR_NODE_COMP=1.e-12;