From a2b4cffa30d671535d1c62665967bee640e079ec Mon Sep 17 00:00:00 2001 From: admin Date: Thu, 20 Jan 2005 06:26:37 +0000 Subject: [PATCH] Merge with OCC_development_01 --- adm_local/unix/make_commence.in | 13 +- configure.in.base | 18 +- src/CONVERTOR/Makefile.in | 9 +- src/CONVERTOR/VISUConvertor.cxx | 49 +- src/CONVERTOR/VISU_Convertor.cxx | 113 +- src/CONVERTOR/VISU_Convertor.hxx | 252 +-- src/CONVERTOR/VISU_ConvertorUtils.cxx | 66 +- src/CONVERTOR/VISU_ConvertorUtils.hxx | 46 +- src/CONVERTOR/VISU_Convertor_impl.cxx | 759 +++++---- src/CONVERTOR/VISU_Convertor_impl.hxx | 245 ++- src/CONVERTOR/VISU_DatConvertor.cxx | 249 --- src/CONVERTOR/VISU_DatConvertor.hxx | 47 - .../VISU_ExtractUnstructuredGrid.cxx | 9 +- src/CONVERTOR/VISU_MedConvertor.cxx | 1165 +++++++------- src/CONVERTOR/VISU_MedConvertor.hxx | 67 +- src/OBJECT/VISU_Actor.cxx | 19 - src/OBJECT/VISU_Actor.h | 11 +- src/OBJECT/VISU_ScalarMapAct.cxx | 9 +- src/PIPELINE/Makefile.in | 4 +- src/PIPELINE/VISUPipeLine.cxx | 16 +- src/VISUGUI/Makefile.in | 13 +- src/VISUGUI/VISU_msg_en.po | 2 +- src/VISUGUI/VisuGUI.cxx | 49 +- src/VISU_I/Makefile.in | 8 +- src/VISU_I/VISU_CorbaMedConvertor.cxx | 1354 ++++++++++------- src/VISU_I/VISU_CorbaMedConvertor.hxx | 80 +- src/VISU_I/VISU_CutLines_i.cc | 10 +- src/VISU_I/VISU_CutPlanes_i.cc | 5 - src/VISU_I/VISU_DeformedShape_i.cc | 6 +- src/VISU_I/VISU_IsoSurfaces_i.cc | 3 - src/VISU_I/VISU_Mesh_i.cc | 18 +- src/VISU_I/VISU_Result_i.cc | 144 +- src/VISU_I/VISU_Result_i.hh | 3 +- src/VISU_I/VISU_ScalarMap_i.cc | 14 +- src/VISU_I/VISU_ScalarMap_i.hh | 6 +- src/VISU_I/VISU_StreamLines_i.cc | 1 + src/VISU_I/VISU_TimeAnimation.cxx | 3 - src/VISU_I/VISU_Vectors_i.cc | 3 - src/VISU_I/VISU_ViewManager_i.cc | 1 - src/VISU_SWIG/Makefile.in | 4 +- 40 files changed, 2393 insertions(+), 2500 deletions(-) delete mode 100644 src/CONVERTOR/VISU_DatConvertor.cxx delete mode 100644 src/CONVERTOR/VISU_DatConvertor.hxx diff --git a/adm_local/unix/make_commence.in b/adm_local/unix/make_commence.in index f8b9e383..a3aad544 100644 --- a/adm_local/unix/make_commence.in +++ b/adm_local/unix/make_commence.in @@ -34,6 +34,10 @@ CXX = @CXX@ CXXFLAGS = @CXXFLAGS@ CXX_DEPEND_FLAG = @CXX_DEPEND_FLAG@ +# BOOST Library + +BOOST_CPPFLAGS = @BOOST_CPPFLAGS@ + # JAVA JAVA_INCLUDES = @JAVA_INCLUDES@ @@ -89,12 +93,6 @@ HDF5_INCLUDES=@HDF5_INCLUDES@ HDF5_LIBS=@HDF5_LIBS@ HDF5_MT_LIBS=@HDF5_MT_LIBS@ -# MED2 - -MED2_INCLUDES=@MED2_INCLUDES@ -MED2_LIBS=@MED2_LIBS@ -MED2_MT_LIBS=@MED2_MT_LIBS@ - # OpenCasCade OCC_INCLUDES=@CAS_CPPFLAGS@ @@ -251,8 +249,7 @@ ac_cxx_mutable.m4 check_mico.m4 libtool.m4 \ ac_cxx_namespaces.m4 check_omniorb.m4 pyembed.m4 \ ac_cxx_partial_specialization.m4 check_opengl.m4 python.m4 \ ac_cxx_typename.m4 check_pthreads.m4 check_cas.m4 \ -ac_cc_warnings.m4 check_qt.m4 check_med2.m4 \ -check_swig.m4 +ac_cc_warnings.m4 check_qt.m4 check_swig.m4 $(top_srcdir)/aclocal.m4: $(ACLOCAL_SRC:%=@KERNEL_ROOT_DIR@/salome_adm/unix/config_files/%) cd $(top_srcdir) ; aclocal --acdir=adm_local/unix/config_files -I @KERNEL_ROOT_DIR@/salome_adm/unix/config_files diff --git a/configure.in.base b/configure.in.base index 4e6c9634..cd12271f 100644 --- a/configure.in.base +++ b/configure.in.base @@ -113,6 +113,14 @@ dnl AC_CXX_HAVE_SSTREAM +echo +echo --------------------------------------------- +echo BOOST Library +echo --------------------------------------------- +echo + +CHECK_BOOST + dnl dnl --------------------------------------------- dnl testing MPICH @@ -225,14 +233,6 @@ echo CHECK_HDF5 -echo -echo --------------------------------------------- -echo testing MED2 -echo --------------------------------------------- -echo - -CHECK_MED2 - echo echo --------------------------------------------- echo Testing OpenCascade @@ -280,7 +280,7 @@ echo --------------------------------------------- echo echo Configure -variables="cc_ok lex_yacc_ok python_ok swig_ok threads_ok OpenGL_ok qt_ok vtk_ok hdf5_ok med2_ok omniORB_ok occ_ok qwt_ok doxygen_ok graphviz_ok Kernel_ok Med_ok" +variables="cc_ok boost_ok lex_yacc_ok python_ok swig_ok threads_ok OpenGL_ok qt_ok vtk_ok hdf5_ok omniORB_ok occ_ok qwt_ok doxygen_ok graphviz_ok Kernel_ok Med_ok" for var in $variables do diff --git a/src/CONVERTOR/Makefile.in b/src/CONVERTOR/Makefile.in index 2473978c..2fcedade 100644 --- a/src/CONVERTOR/Makefile.in +++ b/src/CONVERTOR/Makefile.in @@ -38,15 +38,14 @@ EXPORT_HEADERS = VISU_Convertor.hxx VISU_Convertor_impl.hxx VISU_ConvertorUtil LIB = libVisuConvertor.la LIB_SRC = VISU_Convertor.cxx VISU_Convertor_impl.cxx VISU_ConvertorUtils.cxx VISU_ExtractUnstructuredGrid.cxx \ - VISU_MedConvertor.cxx VISU_DatConvertor.cxx + VISU_MedConvertor.cxx # Executables targets BIN = VISUConvertor BIN_SRC = -CPPFLAGS+= -ftemplate-depth-32 $(VTK_INCLUDES) $(MED2_INCLUDES) $(QT_INCLUDES) \ - -I${KERNEL_ROOT_DIR}/include/salome -LDFLAGS+= $(VTK_LIBS) $(MED2_LIBS) $(HDF5_LIBS) $(QT_LIBS) \ - -L${KERNEL_ROOT_DIR}/lib/salome +CPPFLAGS+= -ftemplate-depth-32 $(VTK_INCLUDES) $(HDF5_INCLUDES) $(QT_INCLUDES) \ + -I${KERNEL_ROOT_DIR}/include/salome $(BOOST_CPPFLAGS) +LDFLAGS+= $(VTK_LIBS) $(QT_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome -lMEDWrapper @CONCLUDE@ diff --git a/src/CONVERTOR/VISUConvertor.cxx b/src/CONVERTOR/VISUConvertor.cxx index 24f787c2..47cdbeea 100644 --- a/src/CONVERTOR/VISUConvertor.cxx +++ b/src/CONVERTOR/VISUConvertor.cxx @@ -44,8 +44,8 @@ static int MYDEBUG = 0; #endif void parseFile(const char* theFileName) { - try{ - MESSAGE("'"< aCon(CreateConvertor(theFileName)); //aCon->GetSize(); //return; @@ -53,21 +53,21 @@ void parseFile(const char* theFileName) { VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin(); for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){ const string& aMeshName = aMeshMapIter->first; - const VISU::TMesh& aMesh = aMeshMapIter->second; - const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh.myMeshOnEntityMap; + const VISU::PMesh& aMesh = aMeshMapIter->second; + const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter; //Import fields aMeshOnEntityMapIter = aMeshOnEntityMap.begin(); for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){ const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first; - const VISU::TMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second; - const VISU::TFieldMap& aFieldMap = aMeshOnEntity.myFieldMap; + const VISU::PMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second; + const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap; VISU::TFieldMap::const_reverse_iterator aFieldMapIter = aFieldMap.rbegin(); for(; aFieldMapIter != aFieldMap.rend(); aFieldMapIter++){ const string& aFieldName = aFieldMapIter->first; - const VISU::TField& aField = aFieldMapIter->second; - const VISU::TField::TValField& aValField = aField.myValField; - VISU::TField::TValField::const_iterator aValFieldIter = aValField.begin(); + const VISU::PField& aField = aFieldMapIter->second; + const VISU::TValField& aValField = aField->myValField; + VISU::TValField::const_iterator aValFieldIter = aValField.begin(); for(; aValFieldIter != aValField.end(); aValFieldIter++){ int aTimeStamp = aValFieldIter->first; aCon->GetTimeStampOnMesh(aMeshName,anEntity,aFieldName,aTimeStamp); @@ -77,7 +77,7 @@ void parseFile(const char* theFileName) { } //continue; //Importing groups - const VISU::TGroupMap& aGroupMap = aMesh.myGroupMap; + const VISU::TGroupMap& aGroupMap = aMesh->myGroupMap; VISU::TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin(); for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){ const string& aGroupName = aGroupMapIter->first; @@ -87,9 +87,9 @@ void parseFile(const char* theFileName) { aMeshOnEntityMapIter = aMeshOnEntityMap.begin(); for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){ const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first; - const VISU::TMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second; + const VISU::PMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second; //aCon->GetMeshOnEntity(aMeshName,anEntity); - const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity.myFamilyMap; + const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap; VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin(); for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){ const string& aFamilyName = aFamilyMapIter->first; @@ -103,17 +103,16 @@ void parseFile(const char* theFileName) { aCon->GetMeshOnEntity(aMeshName,anEntity); } } - OK: - MESSAGE("OK"); - }catch(std::exception& exc){ - MESSAGE("Follow exception was occured in file:"< 1){ QFileInfo fi(argv[1]); for(int i = 0; i < 1; i++){ @@ -132,10 +131,10 @@ int main(int argc, char** argv){ } return 0; } - }catch(std::exception& exc){ - MESSAGE("Follow exception was occured :\n"< -extern "C" { - VISU_Convertor* CreateConvertor(const string& theFileName) { - if(QFileInfo(theFileName.c_str()).extension(false) == "med") - return CreateMedConvertor(theFileName); - else - return CreateDatConvertor(theFileName); - } -} +using namespace std; namespace VISU{ + inline int GetNbOfPoints(int theVTKCellType){ switch(theVTKCellType){ case VTK_VERTEX : return 1; @@ -61,78 +49,53 @@ namespace VISU{ pair TMeshOnEntity::GetCellsDims(const string& theFamilyName) const { - bool isFamilyPresent = (theFamilyName != ""); - int aNbCells = 0, aCellsSize = 0; - if(!isFamilyPresent){ - TCellsConn::const_iterator aCellsConnIter = myCellsConn.begin(); - for(; aCellsConnIter != myCellsConn.end(); aCellsConnIter++){ - const TConnForCellType& aConnForCellType = aCellsConnIter->second; - if(!aConnForCellType.empty()){ - aNbCells += aConnForCellType.size(); - aCellsSize += aConnForCellType.size()*(aConnForCellType[0].size()+1); - } - } - }else{ - TFamilyMap::const_iterator aFamilyMapIter = myFamilyMap.find(theFamilyName); - if(aFamilyMapIter == myFamilyMap.end()) - throw std::runtime_error("GetCellsDims >> There is no family on the mesh with entity !!!"); - const TFamily& aFamily = aFamilyMapIter->second; - const TFamily::TSubMesh& aSubMesh = aFamily.mySubMesh; - TFamily::TSubMesh::const_iterator aSubMeshIter = aSubMesh.begin(); - for(; aSubMeshIter != aSubMesh.end(); aSubMeshIter++){ - const TFamily::TSubMeshOnCellType& aSubMeshOnCellType = aSubMeshIter->second; - if(!aSubMeshOnCellType.empty()){ - int tmp = aSubMeshOnCellType.size(); - aNbCells += tmp; - int aVtkType = aSubMeshIter->first; - int aVtkSize = GetNbOfPoints(aVtkType); - aCellsSize += tmp*(aVtkSize+1); - } - } - } - return make_pair(aNbCells,aCellsSize); + if(theFamilyName == "") + return make_pair(myNbCells,myCellsSize); + TFamilyMap::const_iterator aFamilyMapIter = myFamilyMap.find(theFamilyName); + if(aFamilyMapIter == myFamilyMap.end()) + throw std::runtime_error("GetCellsDims >> There is no family on the mesh with entity !!!"); + const PFamily& aFamily = aFamilyMapIter->second; + return make_pair(aFamily->myNbCells,aFamily->myCellsSize); } - const TField* TMesh::GetField(const string& theFieldName) const { + const PField TMesh::GetField(const string& theFieldName) const { TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = myMeshOnEntityMap.begin(); for(; aMeshOnEntityMapIter != myMeshOnEntityMap.end(); aMeshOnEntityMapIter++){ - const TFieldMap& aFieldMap = (aMeshOnEntityMapIter->second).myFieldMap; + const TFieldMap& aFieldMap = aMeshOnEntityMapIter->second->myFieldMap; TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin(); for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++) - if(theFieldName == aFieldMapIter->first) return &(aFieldMapIter->second); + if(theFieldName == aFieldMapIter->first) + return aFieldMapIter->second; } - return NULL; + return PField(); } - const TFamily* GetFamily(const VISU::TMeshOnEntity& theMeshOnEntity, const string& theFamilyName) + + PFamily FindFamily(VISU::PMesh theMesh, const string& theFamilyName) { - if(theFamilyName == "") return NULL; - const VISU::TFamilyMap& aFamilyMap = theMeshOnEntity.myFamilyMap; - VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.find(theFamilyName); - if(aFamilyMapIter == aFamilyMap.end()) - throw std::runtime_error("GetFamily >> There is no family on the mesh with entity !!!"); - const VISU::TFamily& aFamily = aFamilyMapIter->second; - return &aFamily; + PFamily aFamily; + const TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap; + TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.begin(); + for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){ + const PMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second; + aFamily = GetFamily(aMeshOnEntity,theFamilyName); + if(aFamily) + break; + } + return aFamily; } - TFamily* GetFamily(VISU::TMeshOnEntity& theMeshOnEntity, const string& theFamilyName) + + PFamily GetFamily(VISU::PMeshOnEntity theMeshOnEntity, const string& theFamilyName) { - if(theFamilyName == "") return NULL; - VISU::TFamilyMap& aFamilyMap = theMeshOnEntity.myFamilyMap; - VISU::TFamilyMap::iterator aFamilyMapIter = aFamilyMap.find(theFamilyName); - if(aFamilyMapIter == aFamilyMap.end()) - throw std::runtime_error("GetFamily >> There is no family on the mesh with entity !!!"); - VISU::TFamily& aFamily = aFamilyMapIter->second; - return &aFamily; - } - - void TField::ShallowCopy(const TField& aField){ - myEntity = aField.myEntity; - myMeshName = aField.myMeshName; - myNbComp = aField.myNbComp; - VISU::TField::TValField::const_iterator iter = aField.myValField.begin(); - for(; iter != aField.myValField.end(); iter++) - myValField[iter->first]; + PFamily aFamily; + if(theFamilyName != ""){ + TFamilyMap& aFamilyMap = theMeshOnEntity->myFamilyMap; + TFamilyMap::iterator aFamilyMapIter = aFamilyMap.find(theFamilyName); + if(aFamilyMapIter != aFamilyMap.end()) + aFamily = aFamilyMapIter->second; + } + return aFamily; } } @@ -143,7 +106,7 @@ const VISU::TMeshMap& VISU_Convertor::GetMeshMap() { } -string VISU_Convertor::GenerateName(const VISU::TField::TTime& aTime){ +string VISU_Convertor::GenerateName(const VISU::TTime& aTime){ static QString aName; const string aUnits = aTime.second, tmp(aUnits.size(),' '); if(aUnits == "" || aUnits == tmp) diff --git a/src/CONVERTOR/VISU_Convertor.hxx b/src/CONVERTOR/VISU_Convertor.hxx index 5338d17a..bebb26f0 100644 --- a/src/CONVERTOR/VISU_Convertor.hxx +++ b/src/CONVERTOR/VISU_Convertor.hxx @@ -29,145 +29,166 @@ #include -#include -#include #include #include -#include #include #include #include #include #include -#include -#include -#include -#include -#include +#include -#include "VISU_ExtractUnstructuredGrid.hxx" - -#include +class vtkUnstructuredGrid; namespace VISU{ + + template class shared_ptr: public boost::shared_ptr + { + public: + shared_ptr() {} + + template + explicit shared_ptr(Y * p) + { + reset(p); + } + + template + shared_ptr(shared_ptr const & r): + boost::shared_ptr(r,boost::detail::dynamic_cast_tag()) + {} + + template + shared_ptr & operator=(shared_ptr const & r) + { + shared_ptr(r).swap(*this); + return *this; + } + + template shared_ptr& operator()(Y * p) // Y must be complete + { + if(T* pt = dynamic_cast(p)) + boost::shared_ptr::reset(pt); + else + boost::throw_exception(std::bad_cast()); + return *this; + } + + }; + + enum TEntity {NODE_ENTITY, EDGE_ENTITY, FACE_ENTITY, CELL_ENTITY}; - typedef vtkSmartPointer TVTKPoints; - typedef vtkSmartPointer TVTKSource; - typedef vtkSmartPointer TVTKMergetFilter; - typedef vtkSmartPointer TVTKExtractFilter; - typedef vtkSmartPointer TVTKAttribyteFilter; + typedef std::pair TFamilyAndEntity; + typedef std::set TFamilyAndEntitySet; typedef std::set TBindGroups; - struct TFamily{ - TVTKSource myStorage; - vtkIdType myId; - std::string myName; - TEntity myEntity; - TBindGroups myGroups; - vtkIdType myNbCells, myCellsSize; - typedef std::set TSubMeshOnCellType; - typedef std::map TSubMesh; - TSubMesh mySubMesh; - TFamily() : myNbCells(0), myCellsSize(0) {} + typedef std::pair TTime; + + struct TMesh; + typedef shared_ptr PMesh; + typedef std::map TMeshMap; + + struct TMeshOnEntity; + typedef shared_ptr PMeshOnEntity; + typedef std::map TMeshOnEntityMap; + + struct TFamily; + typedef shared_ptr PFamily; + typedef std::map TFamilyMap; + + struct TGroup; + typedef shared_ptr PGroup; + typedef std::map TGroupMap; + + struct TField; + typedef shared_ptr PField; + typedef std::map TFieldMap; + + struct TValForTime; + typedef shared_ptr PValForTime; + typedef std::map TValField; + + struct TBaseStructure{ + virtual ~TBaseStructure(){} }; - typedef std::map TFamilyMap; - struct TField{ - TVTKExtractFilter myExtractFilter; - vtkIdType myId; + typedef std::vector TNames; + + struct TMesh: TBaseStructure{ + int myDim, myNbPoints; std::string myName; - TEntity myEntity; - std::string myMeshName; - vtkIdType myNbComp, myNbValField, myDataSize, myIsTrimmed; - typedef std::vector TValForCellsWithType; - typedef std::map TValForCells; - typedef std::pair TTime; - typedef std::vector TCompNames; - typedef std::vector TUnitNames; - struct TValForTime{ - TVTKAttribyteFilter myAttribyteFilter; - TVTKMergetFilter myMergeFilter; - TVTKSource myStorage; - vtkIdType myId; - std::string myMeshName; - TEntity myEntity; - std::string myFieldName; - vtkIdType myNbComp; - TTime myTime; - TValForCells myValForCells; - TValForTime() : myNbComp(0) {} - ~TValForTime() { - if(myMergeFilter.GetPointer()) - myMergeFilter->UnRegisterAllOutputs(); - if(myAttribyteFilter.GetPointer()) - myAttribyteFilter->UnRegisterAllOutputs(); - } - }; - typedef std::map TValField; - TValField myValField; - TCompNames myCompNames; - TUnitNames myUnitNames; - TField() : myNbComp(0), myNbValField(0), myDataSize(0), myIsTrimmed(0) {} - void ShallowCopy(const TField& aField); - ~TField() { - if(myExtractFilter.GetPointer()) - myExtractFilter->UnRegisterAllOutputs(); - } + + TMeshOnEntityMap myMeshOnEntityMap; + TGroupMap myGroupMap; + + TMesh() : myDim(0), myNbPoints(0) {} + const PField GetField(const std::string& theFieldName) const; }; - typedef std::map TFieldMap; - - struct TMeshOnEntity{ - TVTKSource myStorage; + + struct TMeshOnEntity: TBaseStructure{ std::string myMeshName; TEntity myEntity; - vtkIdType myNbCells, myCellsSize; - typedef std::vector TConnect; - typedef std::vector TConnForCellType; - typedef std::map TCellsConn; - TCellsConn myCellsConn; + int myNbCells, myCellsSize; TFamilyMap myFamilyMap; TFieldMap myFieldMap; TMeshOnEntity() : myNbCells(0), myCellsSize(0) {} - std::pair GetCellsDims(const std::string& theFamilyName = "") const; - + + std::pair + GetCellsDims(const std::string& theFamilyName = "") const; }; - typedef std::map TMeshOnEntityMap; - const TFamily* GetFamily(const VISU::TMeshOnEntity& theMeshOnEntity, - const std::string& theFamilyName); - TFamily* GetFamily(VISU::TMeshOnEntity& theMeshOnEntity, - const std::string& theFamilyName); + struct TFamily: TBaseStructure{ + int myId; + std::string myName; + TEntity myEntity; + TBindGroups myGroups; + int myNbCells, myCellsSize; + TFamily() : myNbCells(0), myCellsSize(0) {} + }; - typedef std::pair TFamilyAndEntity; - typedef std::set TFamilyAndEntitySet; - struct TGroup{ - TVTKSource myStorage; + struct TGroup: TBaseStructure{ std::string myName; std::string myMeshName; - vtkIdType myNbCells, myCellsSize; - TGroup() : myNbCells(0), myCellsSize(0) {} + int myNbCells, myCellsSize; TFamilyAndEntitySet myFamilyAndEntitySet; + TGroup() : myNbCells(0), myCellsSize(0) {} }; - typedef std::map TGroupMap; - struct TMesh{ - TVTKPoints myPoints; - vtkIdType myDim, myNbPoints; + struct TField: TBaseStructure{ + int myId; + TEntity myEntity; + bool myIsTrimmed; std::string myName; - typedef float TCoord; - typedef std::vector TPointsCoord; - TPointsCoord myPointsCoord; - typedef std::vector TPointsDim; - TPointsDim myPointsDim; - TMeshOnEntityMap myMeshOnEntityMap; - TGroupMap myGroupMap; - TMesh() : myDim(0), myNbPoints(0) {} - const TField* GetField(const std::string& theFieldName) const; + std::string myMeshName; + int myNbComp, myDataSize; + TValField myValField; + TNames myCompNames; + TNames myUnitNames; + TField() : myNbComp(0), myDataSize(0), myIsTrimmed(0) {} + }; + + struct TValForTime: TBaseStructure{ + int myId; + TEntity myEntity; + std::string myMeshName; + std::string myFieldName; + int myNbComp; + TTime myTime; + + TValForTime() : myNbComp(0) {} }; - typedef std::map TMeshMap; - void WriteToFile(vtkUnstructuredGrid* theDataSet, const std::string& theFileName); + + PFamily FindFamily(VISU::PMesh theMesh, + const std::string& theFamilyName); + + PFamily GetFamily(VISU::PMeshOnEntity theMeshOnEntity, + const std::string& theFamilyName); + + void WriteToFile(vtkUnstructuredGrid* theDataSet, + const std::string& theFileName); + }; class VISU_Convertor{ @@ -213,23 +234,20 @@ public: const VISU::TEntity& theEntity, const std::string& theFieldName) = 0; - virtual const VISU::TField& GetField(const std::string& theMeshName, - VISU::TEntity theEntity, - const std::string& theFieldName) = 0; - - virtual const VISU::TField::TValForTime& GetTimeStamp(const std::string& theMeshName, - const VISU::TEntity& theEntity, - const std::string& theFieldName, - int theStampsNum) = 0; + virtual const VISU::PField GetField(const std::string& theMeshName, + VISU::TEntity theEntity, + const std::string& theFieldName) = 0; + + virtual const VISU::PValForTime GetTimeStamp(const std::string& theMeshName, + const VISU::TEntity& theEntity, + const std::string& theFieldName, + int theStampsNum) = 0; - static std::string GenerateName(const VISU::TField::TTime& aTime); + static std::string GenerateName(const VISU::TTime& aTime); static std::string GenerateName(const std::string& theName, unsigned int theTimeId); - static void WriteToFile(vtkUnstructuredGrid* theDataSet, const std::string& theFileName); }; extern "C"{ - VISU_Convertor* CreateMedConvertor(const std::string& theFileName) ; - VISU_Convertor* CreateDatConvertor(const std::string& theFileName) ; VISU_Convertor* CreateConvertor(const std::string& theFileName) ; }; diff --git a/src/CONVERTOR/VISU_ConvertorUtils.cxx b/src/CONVERTOR/VISU_ConvertorUtils.cxx index 60c0a962..fcfb6f95 100644 --- a/src/CONVERTOR/VISU_ConvertorUtils.cxx +++ b/src/CONVERTOR/VISU_ConvertorUtils.cxx @@ -24,60 +24,20 @@ // Author : Alexey PETROV // Module : VISU -#include "VISU_Convertor.hxx" #include "VISU_ConvertorUtils.hxx" - -#include - -using namespace std; - -#define MED2VTK(MEDTYPE,VTKTYPE,VTKNBNODES) \ - {MEDTYPE,#MEDTYPE,getNbMedNodes(MEDTYPE),VTKTYPE,#VTKTYPE,VTKNBNODES} -Med2vtk med2vtk[MED_NBR_GEOMETRIE_MAILLE] = { - MED2VTK(MED_POINT1,VTK_VERTEX,1), - MED2VTK(MED_SEG2,VTK_LINE,2), - MED2VTK(MED_SEG3,VTK_LINE,2), - MED2VTK(MED_TRIA3,VTK_TRIANGLE,3), - MED2VTK(MED_TRIA6,VTK_TRIANGLE,3), - MED2VTK(MED_QUAD4,VTK_QUAD,4), - MED2VTK(MED_QUAD8,VTK_QUAD,4), - MED2VTK(MED_TETRA4,VTK_TETRA,4), - MED2VTK(MED_TETRA10,VTK_TETRA,4), - MED2VTK(MED_HEXA8,VTK_HEXAHEDRON,8), - MED2VTK(MED_HEXA20,VTK_HEXAHEDRON,8), - MED2VTK(MED_PENTA6,VTK_WEDGE,6), - MED2VTK(MED_PENTA15,VTK_WEDGE,6), - MED2VTK(MED_PYRA5,VTK_PYRAMID,5), - MED2VTK(MED_PYRA13,VTK_PYRAMID,5) -}; -#undef MED2VTK - -extern "C" { - int getNbMedConnect(int theMedType, int theMedEntity, int theMeshDim){ - int anElemDim = theMedType / 100, nsup = 0; - if(theMedEntity == VISU::CELL_ENTITY && anElemDim < theMeshDim) nsup = 1; - return nsup + theMedType % 100; +#include + +namespace VISU{ + + void + WriteToFile(vtkUnstructuredGrid* theDataSet, const std::string& theFileName) + { + vtkUnstructuredGridWriter* aWriter = vtkUnstructuredGridWriter::New(); + //aWriter->SetFileType(VTK_BINARY); + aWriter->SetFileName(theFileName.c_str()); + aWriter->SetInput(theDataSet); + aWriter->Write(); + aWriter->Delete(); } - int getNbMedNodes(int geom){ - return geom % 100; - } - - int getIdMedType(int medType){ - for(int i = 0; i < MED_NBR_GEOMETRIE_MAILLE; i++) - if(med2vtk[i].medType == medType) return i; - return -1; - } - - int med2vtkCellType(int medType){ - for(int i = 0; i < MED_NBR_GEOMETRIE_MAILLE; i++) - if(med2vtk[i].medType == medType) return med2vtk[i].vtkType; - return -1; - } - - int vtk2medCellType(int vtkType){ - for(int i = 0; i < MED_NBR_GEOMETRIE_MAILLE; i++) - if(med2vtk[i].vtkType == vtkType) return med2vtk[i].medType; - return -1; - } } diff --git a/src/CONVERTOR/VISU_ConvertorUtils.hxx b/src/CONVERTOR/VISU_ConvertorUtils.hxx index 80ad171f..1ef42e36 100644 --- a/src/CONVERTOR/VISU_ConvertorUtils.hxx +++ b/src/CONVERTOR/VISU_ConvertorUtils.hxx @@ -27,53 +27,19 @@ #ifndef VISU_ConvertorUtils_HeaderFile #define VISU_ConvertorUtils_HeaderFile -extern "C"{ -#include -} - -#include -#include #include #include -#include -#include - -#ifndef MESSAGE -#define MESSAGE(msg) std::cout<<__FILE__<<"["<<__LINE__<<"]::"< std::string dtos(const std::string& fmt, T val){ - static QString aString; - aString.sprintf(fmt.c_str(),val); - return aString.latin1(); -} +namespace VISU{ -extern "C"{ - int getNbMedConnect(int theMedType, int theMedEntity, int theMeshDim); - int getNbMedNodes(int theMedType); - int med2vtkCellType(int theMedType); - int vtk2medCellType(int theVtkType); - int getIdMedType(int medType); + void + WriteToFile(vtkUnstructuredGrid* theDataSet, const std::string& theFileName); + } -struct Med2vtk { - med_geometrie_element medType; - const char *medName; - int medNbNodes; - int vtkType; - const char *vtkName; - int vtkNbNodes; -}; - -extern Med2vtk med2vtk[MED_NBR_GEOMETRIE_MAILLE]; - #endif diff --git a/src/CONVERTOR/VISU_Convertor_impl.cxx b/src/CONVERTOR/VISU_Convertor_impl.cxx index 1e3aaa61..5fcb2f9e 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.cxx +++ b/src/CONVERTOR/VISU_Convertor_impl.cxx @@ -39,8 +39,6 @@ #include -#include - #include #include @@ -48,6 +46,7 @@ #include using namespace std; +using namespace VISU; static float ERR_SIZE_CALC = 1.00; @@ -61,109 +60,111 @@ static int MYDEBUG = 0; static int MYDEBUGWITHFILES = 0; #endif -void VISU::WriteToFile(vtkUnstructuredGrid* theDataSet, const string& theFileName){ - //vtkUnstructuredGridWriter* aWriter = vtkUnstructuredGridWriter::New(); - //if(MYVTKDEBUG) aWriter->DebugOn(); - ////aWriter->SetFileType(VTK_BINARY); - //aWriter->SetFileName(theFileName.c_str()); - //aWriter->SetInput(theDataSet); - //aWriter->Write(); - //aWriter->Delete(); -} - -enum ECoordName{eX, eY, eZ, eNone}; -typedef VISU::TMesh::TCoord (*TGetCoord)(const VISU::TMesh::TPointsCoord&, int); - -template -VISU::TMesh::TCoord GetCoord(const VISU::TMesh::TPointsCoord& thePointsCoord, - int theStartPos) -{ - return thePointsCoord[theStartPos+TheCoordId]; -} - -template<> -VISU::TMesh::TCoord GetCoord(const VISU::TMesh::TPointsCoord& thePointsCoord, - int theStartPos) -{ - return 0.0; -} +namespace{ -static TGetCoord aXYZGetCoord[3] = { - &GetCoord, - &GetCoord, - &GetCoord -}; - - -static TGetCoord aXYGetCoord[3] = { - &GetCoord, - &GetCoord, - &GetCoord -}; - -static TGetCoord aYZGetCoord[3] = { - &GetCoord, - &GetCoord, - &GetCoord -}; - -static TGetCoord aXZGetCoord[3] = { - &GetCoord, - &GetCoord, - &GetCoord -}; - - -static TGetCoord aXGetCoord[3] = { - &GetCoord, - &GetCoord, - &GetCoord -}; - -static TGetCoord aYGetCoord[3] = { - &GetCoord, - &GetCoord, - &GetCoord -}; - -static TGetCoord aZGetCoord[3] = { - &GetCoord, - &GetCoord, - &GetCoord -}; - - -class TCoordHelper{ - const VISU::TMesh::TPointsCoord& myPointsCoord; - TGetCoord* myGetCoord; -public: - TCoordHelper(const VISU::TMesh::TPointsCoord& thePointsCoord, - TGetCoord* theGetCoord): - myPointsCoord(thePointsCoord), - myGetCoord(theGetCoord) - {} - virtual ~TCoordHelper(){} - VISU::TMesh::TCoord GetCoord(int theStartPos, int theCoodId){ - return (*myGetCoord[theCoodId])(myPointsCoord,theStartPos); + template + std::string dtos(const std::string& fmt, T val){ + static QString aString; + aString.sprintf(fmt.c_str(),val); + return aString.latin1(); } -}; -typedef std::auto_ptr TCoordHelperPtr; + enum ECoordName{eX, eY, eZ, eNone}; + typedef VISU::TCoord (*TGetCoord)(const VISU::TMeshImpl::TPointsCoord&, int); + + template + VISU::TCoord + GetCoord(const VISU::TMeshImpl::TPointsCoord& thePointsCoord, + int theStartPos) + { + return thePointsCoord[theStartPos+TheCoordId]; + } + + template<> + VISU::TCoord + GetCoord(const VISU::TMeshImpl::TPointsCoord& thePointsCoord, + int theStartPos) + { + return 0.0; + } + + + TGetCoord aXYZGetCoord[3] = { + &GetCoord, + &GetCoord, + &GetCoord + }; + + + TGetCoord aXYGetCoord[3] = { + &GetCoord, + &GetCoord, + &GetCoord + }; + + TGetCoord aYZGetCoord[3] = { + &GetCoord, + &GetCoord, + &GetCoord + }; + + TGetCoord aXZGetCoord[3] = { + &GetCoord, + &GetCoord, + &GetCoord + }; + + + TGetCoord aXGetCoord[3] = { + &GetCoord, + &GetCoord, + &GetCoord + }; + + TGetCoord aYGetCoord[3] = { + &GetCoord, + &GetCoord, + &GetCoord + }; + + TGetCoord aZGetCoord[3] = { + &GetCoord, + &GetCoord, + &GetCoord + }; -namespace{ - void GetPoints(VISU::TVTKSource& theStorage, VISU::TMesh& theMesh) + + class TCoordHelper{ + const VISU::TMeshImpl::TPointsCoord& myPointsCoord; + TGetCoord* myGetCoord; + public: + TCoordHelper(const VISU::TMeshImpl::TPointsCoord& thePointsCoord, + TGetCoord* theGetCoord): + myPointsCoord(thePointsCoord), + myGetCoord(theGetCoord) + {} + virtual ~TCoordHelper(){} + VISU::TCoord + GetCoord(int theStartPos, int theCoodId) + { + return (*myGetCoord[theCoodId])(myPointsCoord,theStartPos); + } + }; + typedef std::auto_ptr TCoordHelperPtr; + + void GetPoints(VISU::TVTKSource& theStorage, VISU::PMeshImpl theMesh) { - vtkPoints* aPoints = theMesh.myPoints.GetPointer(); + vtkPoints* aPoints = theMesh->myPoints.GetPointer(); if(!aPoints){ aPoints = vtkPoints::New(); TCoordHelperPtr aCoordHelperPtr; - const VISU::TMesh::TPointsCoord& anArray = theMesh.myPointsCoord; + const VISU::TMeshImpl::TPointsCoord& anArray = theMesh->myPointsCoord; { - int aMeshDimension = theMesh.myDim; + int aMeshDimension = theMesh->myDim; bool anIsDimPresent[3] = {false, false, false}; for(int iDim = 0; iDim < aMeshDimension; iDim++){ - string aDimName = theMesh.myPointsDim[iDim]; + string aDimName = theMesh->myPointsDim[iDim]; if(aDimName == "x" || aDimName == "X") anIsDimPresent[eX] = true; else if(aDimName == "y" || aDimName == "Y") @@ -196,17 +197,16 @@ namespace{ } if(MYVTKDEBUG) aPoints->DebugOn(); - vtkIdType iEnd = theMesh.myPointsCoord.size(); - vtkIdType aNbPoints = iEnd / theMesh.myDim; + vtkIdType iEnd = theMesh->myPointsCoord.size(); + vtkIdType aNbPoints = iEnd / theMesh->myDim; aPoints->SetNumberOfPoints(aNbPoints); - if(MYDEBUG) - MESSAGE("GetPoints - aNbPoints = "<> There is no elements on the family !!!")); - VISU::TFamily::TSubMesh::const_iterator aSubMeshIter = aSubMesh.find(aVtkType); + EXCEPTION(runtime_error,"GetCells >> There is no elements on the family !!!"); + VISU::TFamilyImpl::TSubMesh::const_iterator aSubMeshIter = aSubMesh.find(aVtkType); if(aSubMeshIter == aSubMesh.end()) continue; - const VISU::TFamily::TSubMeshOnCellType& aSubMeshOnCellType = aSubMeshIter->second; - if(MYDEBUG) - MESSAGE("GetCellsOnEntity - aSubMeshOnCellType.size() = "<second; + MSG(MYDEBUG,"GetCellsOnEntity - aSubMeshOnCellType.size() = "<SetValue(j++,(unsigned char)aVtkType); @@ -286,7 +282,7 @@ namespace{ void GetCellsOnGroup(VISU::TVTKSource& theStorage, - const VISU::TMesh& theMesh, + VISU::PMeshImpl theMesh, const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet) { //Calculate dimentions of the group @@ -296,8 +292,8 @@ namespace{ const VISU::TFamilyAndEntity& aFamilyAndEntity = *aFamilyAndEntitySetIter; const string& aFamilyName = aFamilyAndEntity.first; const VISU::TEntity& anEntity = aFamilyAndEntity.second; - const VISU::TMeshOnEntity& aMeshOnEntity = theMesh.myMeshOnEntityMap.find(anEntity)->second; - pair aCellsDim = aMeshOnEntity.GetCellsDims(aFamilyName); + const VISU::PMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[anEntity]; + pair aCellsDim = aMeshOnEntity->GetCellsDims(aFamilyName); aNbCells += aCellsDim.first; aCellsSize += aCellsDim.second; } @@ -311,24 +307,22 @@ namespace{ const VISU::TFamilyAndEntity& aFamilyAndEntity = *aFamilyAndEntitySetIter; const string& aFamilyName = aFamilyAndEntity.first; const VISU::TEntity& anEntity = aFamilyAndEntity.second; - const VISU::TMeshOnEntity& aMeshOnEntity = theMesh.myMeshOnEntityMap.find(anEntity)->second; - const VISU::TFamily& aFamily = *(VISU::GetFamily(aMeshOnEntity,aFamilyName)); - const VISU::TMeshOnEntity::TCellsConn &aCellsConn = aMeshOnEntity.myCellsConn; - VISU::TMeshOnEntity::TCellsConn::const_iterator aCellsConnIter = aCellsConn.begin(); + PMeshOnEntityImpl aMeshOnEntity = theMesh->myMeshOnEntityMap[anEntity]; + PFamilyImpl aFamily = GetFamily(aMeshOnEntity,aFamilyName); + const VISU::TMeshOnEntityImpl::TCellsConn &aCellsConn = aMeshOnEntity->myCellsConn; + VISU::TMeshOnEntityImpl::TCellsConn::const_iterator aCellsConnIter = aCellsConn.begin(); for(; aCellsConnIter != aCellsConn.end(); aCellsConnIter++){ - const VISU::TMeshOnEntity::TConnForCellType& anArray = aCellsConnIter->second; + const VISU::TMeshOnEntityImpl::TConnForCellType& anArray = aCellsConnIter->second; int aVtkType = aCellsConnIter->first; - if(MYDEBUG) - MESSAGE("GetCellsOnGroup - aVtkType = "<> There is no elements on the family !!!")); - VISU::TFamily::TSubMesh::const_iterator aSubMeshIter = aSubMesh.find(aVtkType); + EXCEPTION(runtime_error,"GetCells >> There is no elements on the family !!!"); + VISU::TFamilyImpl::TSubMesh::const_iterator aSubMeshIter = aSubMesh.find(aVtkType); if(aSubMeshIter == aSubMesh.end()) continue; - const VISU::TFamily::TSubMeshOnCellType& aSubMeshOnCellType = aSubMeshIter->second; - if(MYDEBUG) - MESSAGE("GetCellsOnGroup - aSubMeshOnCellType.size() = "<second; + MSG(MYDEBUG,"GetCellsOnGroup - aSubMeshOnCellType.size() = "<SetValue(j++,(unsigned char)aVtkType); @@ -350,12 +344,12 @@ namespace{ void InitProfile(VISU::TVTKExtractFilter& theFilter, - const VISU::TMeshOnEntity& theMeshOnEntity, - const VISU::TField::TValForTime& theValForTime) + PMeshOnEntityImpl theMeshOnEntity, + PValForTimeImpl theValForTime) { - const VISU::TField::TValForCells& aValForCells = theValForTime.myValForCells; - const VISU::TMeshOnEntity::TCellsConn &aCellsConn = theMeshOnEntity.myCellsConn; - VISU::TMeshOnEntity::TCellsConn::const_iterator aCellsConnIter = aCellsConn.begin(); + const VISU::TValForTimeImpl::TValForCells& aValForCells = theValForTime->myValForCells; + const VISU::TMeshOnEntityImpl::TCellsConn &aCellsConn = theMeshOnEntity->myCellsConn; + VISU::TMeshOnEntityImpl::TCellsConn::const_iterator aCellsConnIter = aCellsConn.begin(); for(; aCellsConnIter != aCellsConn.end(); aCellsConnIter++){ const vtkIdType& aCellType = aCellsConnIter->first; if(aValForCells.find(aCellType) == aValForCells.end()) @@ -367,21 +361,21 @@ namespace{ void GetValsOnTimeStamp(vtkFloatArray *theFloatArray, const vtkIdType& theNumberOfTuples, const std::string& theFieldName, - const VISU::TField& theField, - const VISU::TField::TValForTime& theValForTime) + VISU::PFieldImpl theField, + VISU::PValForTimeImpl theValForTime) { //theFloatArray->DebugOn(); theFloatArray->SetNumberOfTuples(theNumberOfTuples); theFloatArray->SetName(theFieldName.c_str()); - if(MYDEBUG) MESSAGE("GetValsOnTimeStamp - theNumberOfTuples = "<myTime; + string aFieldName = theField->myMeshName + ", " + theField->myName + ": " + VISU_Convertor::GenerateName(aTime); return aFieldName; } void GetTimeStamp(VISU::TVTKSource& theStorage, - const VISU::TMesh& theMesh, - const VISU::TMeshOnEntity& theMeshOnEntity, - const VISU::TField& theField, - const VISU::TField::TValForTime& theValForTime) + const VISU::PFieldImpl theField, + const VISU::PValForTimeImpl theValForTime) { - int aNumberOfTuples = theField.myDataSize/theField.myNbComp; + int aNumberOfTuples = theField->myDataSize/theField->myNbComp; string aFieldName = GenerateFieldName(theField,theValForTime); - if(MYDEBUG) - MESSAGE("GetTimeStamp(TVTKSource) - aFieldName = "<myStorage); + PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);; + PFamilyImpl aFamily = boost::get<2>(aFindMeshOnEntity); + PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity); + if(aFamily) + pSource = &(aFamily->myStorage); else - pSource = &(aMeshOnEntity.myStorage); + pSource = &(aMeshOnEntity->myStorage); VISU::TVTKSource& aSource = *pSource; //Main part of code try{ @@ -554,13 +540,13 @@ VISU_Convertor_impl::GetMeshOnEntity(const string& theMeshName, GetMeshOnEntitySize(theMeshName,theEntity,theFamilyName); vtkUnstructuredGrid* aDataSet = aSource.GetPointer(); aDataSet->Update(); - MESSAGE("GetMeshOnEntity - GetPoints() = "<GetPoints()->GetActualMemorySize()*1000)); - MESSAGE("GetMeshOnEntity - GetCells() = "<GetCells()->GetActualMemorySize()*1000)); - MESSAGE("GetMeshOnEntity - GetCellTypesArray() = "<GetCellTypesArray()->GetActualMemorySize()*1000)); - MESSAGE("GetMeshOnEntity - GetCellLocationsArray() = "<GetCellLocationsArray()->GetActualMemorySize()*1000)); + MSG(MYVTKDEBUG,"GetMeshOnEntity - GetPoints() = "<GetPoints()->GetActualMemorySize()*1000)); + MSG(MYVTKDEBUG,"GetMeshOnEntity - GetCells() = "<GetCells()->GetActualMemorySize()*1000)); + MSG(MYVTKDEBUG,"GetMeshOnEntity - GetCellTypesArray() = "<GetCellTypesArray()->GetActualMemorySize()*1000)); + MSG(MYVTKDEBUG,"GetMeshOnEntity - GetCellLocationsArray() = "<GetCellLocationsArray()->GetActualMemorySize()*1000)); aDataSet->BuildLinks(); - MESSAGE("GetMeshOnEntity - GetCellLinks() = "<GetCellLinks()->GetActualMemorySize()*1000)); - MESSAGE("GetMeshOnEntity - GetActualMemorySize() = "<GetActualMemorySize()*1000)); + MSG(MYVTKDEBUG,"GetMeshOnEntity - GetCellLinks() = "<GetCellLinks()->GetActualMemorySize()*1000)); + MSG(MYVTKDEBUG,"GetMeshOnEntity - GetActualMemorySize() = "<GetActualMemorySize()*1000)); } }catch(...){ aSource = vtkSmartPointerBase(); @@ -573,16 +559,14 @@ VISU_Convertor::TOutput* VISU_Convertor_impl::GetMeshOnGroup(const string& theMeshName, const string& theGroupName) { - if(MYDEBUG) MESSAGE("GetMeshOnGroup - theMeshName = '"<(aFindMeshOnGroup); + PGroupImpl aGroup = boost::get<1>(aFindMeshOnGroup); + const VISU::TFamilyAndEntitySet& aFamilyAndEntitySet = aGroup->myFamilyAndEntitySet; + VISU::TVTKSource& aSource = aGroup->myStorage; //Main part of code try{ if(aSource.GetPointer() == NULL){ @@ -612,23 +596,20 @@ VISU_Convertor_impl::GetTimeStampOnMesh(const string& theMeshName, const string& theFieldName, int theStampsNum) { - if(MYDEBUG){ - MESSAGE("GetTimeStampOnMesh - theMeshName = '"<myMeshName,pVTKMeshOnEntity->myEntity); + GetMeshOnEntity(aVTKMeshOnEntity->myMeshName,aVTKMeshOnEntity->myEntity); - anExtractFilter->SetInput(pVTKMeshOnEntity->myStorage.GetPointer()); - ::InitProfile(anExtractFilter,*pMeshOnEntity,aValForTime); + anExtractFilter->SetInput(aVTKMeshOnEntity->myStorage.GetPointer()); + ::InitProfile(anExtractFilter,aMeshOnEntity,aValForTime); } if(!anExtractFilter->IsRemoving()){ aSource = TOutput::New(); aSource->Delete(); - aSource->ShallowCopy(pVTKMeshOnEntity->myStorage.GetPointer()); - ::GetTimeStamp(aSource,aMesh,*pVTKMeshOnEntity,aField,aValForTime); + aSource->ShallowCopy(aVTKMeshOnEntity->myStorage.GetPointer()); + ::GetTimeStamp(aSource,aField,aValForTime); anOutput = aSource.GetPointer(); }else{ anAttribyteFilter = vtkFieldDataToAttributeDataFilter::New(); anAttribyteFilter->Delete(); //anAttribyteFilter->DebugOn(); - VISU::TVTKMergetFilter& aMergeFilter = aValForTime.myMergeFilter; + VISU::TVTKMergetFilter& aMergeFilter = aValForTime->myMergeFilter; aMergeFilter = vtkMergeDataObjectFilter::New(); aMergeFilter->Delete(); //aMergeFilter->DebugOn(); ::GetTimeStamp(anAttribyteFilter,aMergeFilter,anExtractFilter, - aMesh,*pVTKMeshOnEntity,aField,aValForTime); + aField,aValForTime); anOutput = anAttribyteFilter->GetUnstructuredGridOutput(); } if(MYDEBUGWITHFILES){ @@ -691,10 +672,10 @@ VISU_Convertor_impl::GetTimeStampOnMesh(const string& theMeshName, vtkUnstructuredGrid *aDataSet = anAttribyteFilter->GetUnstructuredGridOutput(); aDataSet->Update(); if(theEntity == VISU::NODE_ENTITY) - MESSAGE("GetTimeStampOnMesh - GetData() = "<GetPointData()->GetActualMemorySize()*1000)); + MSG(MYVTKDEBUG,"GetTimeStampOnMesh - GetData() = "<GetPointData()->GetActualMemorySize()*1000)); else - MESSAGE("GetMeshOnEntity - GetData() = "<GetCellData()->GetActualMemorySize()*1000)); - MESSAGE("GetTimeStampOnMesh - GetActualMemorySize() = "<GetActualMemorySize()*1000)); + MSG(MYVTKDEBUG,"GetMeshOnEntity - GetData() = "<GetCellData()->GetActualMemorySize()*1000)); + MSG(MYVTKDEBUG,"GetTimeStampOnMesh - GetActualMemorySize() = "<GetActualMemorySize()*1000)); } } }catch(...){ @@ -705,30 +686,35 @@ VISU_Convertor_impl::GetTimeStampOnMesh(const string& theMeshName, return anOutput; } -void VISU_Convertor_impl::FindMesh(const string& theMeshName, VISU::TMesh*& theMesh) +VISU::PMeshImpl +VISU_Convertor_impl::FindMesh(const string& theMeshName) { GetMeshMap(); - if(myMeshMap.find(theMeshName) == myMeshMap.end()) - throw std::runtime_error(EXCEPT("FindMesh >> There is no mesh with the name - '%1'!!!"). - arg(theMeshName.c_str()).latin1()); - theMesh = &myMeshMap[theMeshName]; + TMeshMap::iterator aMeshMapIter = myMeshMap.find(theMeshName); + if(aMeshMapIter == myMeshMap.end()) + EXCEPTION(runtime_error,"FindMesh >> There is no mesh with the name - '"<second; + return aMesh; } -void VISU_Convertor_impl::FindMeshOnEntity(const string& theMeshName, - VISU::TMesh*& theMesh, - const VISU::TEntity& theEntity, - VISU::TMeshOnEntity*& theMeshOnEntity, - const string& theFamilyName, - VISU::TFamily*& theFamily) +VISU_Convertor_impl::TFindMeshOnEntity +VISU_Convertor_impl::FindMeshOnEntity(const string& theMeshName, + const VISU::TEntity& theEntity, + const string& theFamilyName) { - FindMesh(theMeshName,theMesh); - VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap; - if(aMeshOnEntityMap.find(theEntity) == aMeshOnEntityMap.end()) - throw std::runtime_error(EXCEPT("FindMeshOnEntity >> There is no mesh on the entity - %1!!!"). - arg(int(theEntity)).latin1()); - theMeshOnEntity = &aMeshOnEntityMap[theEntity]; - theFamily = VISU::GetFamily(*theMeshOnEntity,theFamilyName); + PMeshImpl aMesh = FindMesh(theMeshName); + VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; + VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(theEntity); + if(aMeshOnEntityMapIter == aMeshOnEntityMap.end()) + EXCEPTION(runtime_error,"FindMeshOnEntity >> There is no mesh on the entity - "<second; + + return TFindMeshOnEntity(aMesh, + aMeshOnEntityMap[theEntity], + GetFamily(aMeshOnEntity,theFamilyName)); } @@ -738,35 +724,35 @@ float VISU_Convertor_impl::GetSize() { VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin(); for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){ const string& aMeshName = aMeshMapIter->first; - const VISU::TMesh& aMesh = aMeshMapIter->second; - const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh.myMeshOnEntityMap; + const VISU::PMesh aMesh = aMeshMapIter->second; + const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter; //Import fields aMeshOnEntityMapIter = aMeshOnEntityMap.begin(); for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){ const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first; - const VISU::TMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second; - const VISU::TFieldMap& aFieldMap = aMeshOnEntity.myFieldMap; + const VISU::PMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second; + const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap; VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin(); for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){ const string& aFieldName = aFieldMapIter->first; - const VISU::TField& aField = aFieldMapIter->second; - const VISU::TField::TValField& aValField = aField.myValField; - VISU::TField::TValField::const_iterator aValFieldIter = aValField.begin(); + const VISU::PField aField = aFieldMapIter->second; + const VISU::TValField& aValField = aField->myValField; + VISU::TValField::const_iterator aValFieldIter = aValField.begin(); for(; aValFieldIter != aValField.end(); aValFieldIter++){ int aTimeStamp = aValFieldIter->first; aResult += GetTimeStampSize(aMeshName,anEntity,aFieldName,aTimeStamp); } } //Importing groups - const VISU::TGroupMap& aGroupMap = aMesh.myGroupMap; + const VISU::TGroupMap& aGroupMap = aMesh->myGroupMap; VISU::TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin(); for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){ const string& aGroupName = aGroupMapIter->first; aResult += GetMeshOnGroupSize(aMeshName,aGroupName); } //Import families - const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity.myFamilyMap; + const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap; VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin(); for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){ const string& aFamilyName = aFamilyMapIter->first; @@ -776,8 +762,7 @@ float VISU_Convertor_impl::GetSize() { aResult += GetMeshOnEntitySize(aMeshName,anEntity); } } - if(MYDEBUG) - MESSAGE("GetSize - aResult = "<myGroupMap; + PMeshImpl aMesh = FindMesh(theMeshName); + VISU::TGroupMap& aGroupMap = aMesh->myGroupMap; VISU::TGroupMap::iterator aGroupMapIter = aGroupMap.find(theGroupName); if(aGroupMapIter == aGroupMap.end()) - throw std::runtime_error(EXCEPT("FindMesh >> There is no the group in the mesh!!! - '%1'").arg(theGroupName.c_str()).latin1()); - theGroup = &aGroupMapIter->second; + EXCEPTION(runtime_error,"FindMesh >> There is no the group in the mesh!!! - '"<second; + return TFindMeshOnGroup(aMesh,aGroup); } float VISU_Convertor_impl::GetMeshOnGroupSize(const std::string& theMeshName, const std::string& theGroupName) { - VISU::TMesh* pMesh = NULL; - VISU::TGroup* pGroup = NULL; - FindMeshOnGroup(theMeshName,pMesh,theGroupName,pGroup); - vtkIdType aPointsSize = 3*pMesh->myNbPoints*sizeof(VISU::TMesh::TCoord); - vtkIdType aNbCells = pGroup->myNbCells, aCellsSize = pGroup->myCellsSize; + TFindMeshOnGroup aFindMeshOnGroup = FindMeshOnGroup(theMeshName,theGroupName); + PMeshImpl aMesh = boost::get<0>(aFindMeshOnGroup); + PGroupImpl aGroup = boost::get<1>(aFindMeshOnGroup); + + vtkIdType aPointsSize = 3*aMesh->myNbPoints*sizeof(VISU::TCoord); + vtkIdType aNbCells = aGroup->myNbCells, aCellsSize = aGroup->myCellsSize; vtkIdType aConnectivityAndTypesSize = aCellsSize*sizeof(vtkIdType); vtkIdType aLocationsSize = aNbCells*sizeof(int); float aNbCellsPerPoint = aCellsSize / aNbCells - 1; - vtkIdType aLinksSize = pMesh->myNbPoints * + vtkIdType aLinksSize = aMesh->myNbPoints * (vtkIdType(sizeof(vtkIdType)*aNbCellsPerPoint) + sizeof(short)); aLinksSize = 0; vtkIdType aResult = aPointsSize + aConnectivityAndTypesSize + aLocationsSize + aLinksSize; if(MYDEBUG){ - if(MYVTKDEBUG){ - MESSAGE("GetMeshOnGroupSize - aPointsSize = "<myMeshOnEntityMap; + TFindMeshOnEntity aFindMeshOnEntity = FindMeshOnEntity(theMeshName,theEntity,""); + PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);; + PFamilyImpl aFamily = boost::get<2>(aFindMeshOnEntity); + PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity); + + VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; + PMeshOnEntityImpl aVTKMeshOnEntity; if(theEntity == VISU::NODE_ENTITY){ if(aMeshOnEntityMap.find(VISU::CELL_ENTITY) != aMeshOnEntityMap.end()) - pMeshOnEntity = &aMeshOnEntityMap[VISU::CELL_ENTITY]; + aVTKMeshOnEntity = aMeshOnEntityMap[VISU::CELL_ENTITY]; else if(aMeshOnEntityMap.find(VISU::FACE_ENTITY) != aMeshOnEntityMap.end()) - pMeshOnEntity = &aMeshOnEntityMap[VISU::FACE_ENTITY]; + aVTKMeshOnEntity = aMeshOnEntityMap[VISU::FACE_ENTITY]; else if(aMeshOnEntityMap.find(VISU::NODE_ENTITY) != aMeshOnEntityMap.end()) - pMeshOnEntity = &aMeshOnEntityMap[VISU::EDGE_ENTITY]; - } - theVTKMeshOnEntity = pMeshOnEntity; - VISU::TFieldMap& aFieldMap = theMeshOnEntity->myFieldMap; - if(aFieldMap.find(theFieldName) == aFieldMap.end()) - throw std::runtime_error(EXCEPTION("FindField >> There is no field on the mesh!!!")); - theField = &aFieldMap[theFieldName]; + aVTKMeshOnEntity = aMeshOnEntityMap[VISU::EDGE_ENTITY]; + }else + aVTKMeshOnEntity = aMeshOnEntity; + + VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap; + VISU::TFieldMap::const_iterator aFieldIter= aFieldMap.find(theFieldName); + if(aFieldIter == aFieldMap.end()) + EXCEPTION(runtime_error,"FindField >> There is no field on the mesh!!!"); + + PFieldImpl aField = aFieldIter->second; + + return TFindField(aMesh, + aMeshOnEntity, + aVTKMeshOnEntity, + aField); } @@ -896,36 +895,46 @@ float VISU_Convertor_impl::GetFieldOnMeshSize(const std::string& theMeshName, const VISU::TEntity& theEntity, const std::string& theFieldName) { - VISU::TMesh* pMesh = NULL; - VISU::TField* pField = NULL; - VISU::TMeshOnEntity *pMeshOnEntity = NULL, *pVTKMeshOnEntity = NULL; - FindField(theMeshName,pMesh,theEntity,pMeshOnEntity,pVTKMeshOnEntity, - theFieldName,pField); - float aMeshSize = GetMeshOnEntitySize(theMeshName,pVTKMeshOnEntity->myEntity); - float aFieldOnMeshSize = float(pField->myDataSize*sizeof(float)*pField->myNbValField * ERR_SIZE_CALC); + TFindField aFindField = FindField(theMeshName,theEntity,theFieldName); + PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindField); + PField aField = boost::get<3>(aFindField); + + float aMeshSize = GetMeshOnEntitySize(theMeshName,aVTKMeshOnEntity->myEntity); + float aFieldOnMeshSize = float(aField->myDataSize*sizeof(float)*aField->myValField.size()*ERR_SIZE_CALC); float aResult = aMeshSize + aFieldOnMeshSize; - if(MYDEBUG){ - if(MYVTKDEBUG) - MESSAGE("GetFieldOnMeshSize - aFieldOnMeshSize = "<myValField; - if(aValField.find(theStampsNum) == aValField.end()) - throw std::runtime_error(EXCEPTION("FindTimeStamp >> There is no field with the timestamp!!!")); - theValForTime = &aValField[theStampsNum]; + TFindField aFindField = FindField(theMeshName,theEntity,theFieldName); + PField aField = boost::get<3>(aFindField); + + VISU::TValField& aValField = aField->myValField; + VISU::TValField::const_iterator aValFieldIter= aValField.find(theStampsNum); + if(aValFieldIter == aValField.end()) + EXCEPTION(runtime_error,"FindTimeStamp >> There is no field with the timestamp!!!"); + + PMeshImpl aMesh = boost::get<0>(aFindField); + PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindField); + PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindField); + PValForTimeImpl aValForTime = aValFieldIter->second; + + return TFindTimeStamp(aMesh, + aMeshOnEntity, + aVTKMeshOnEntity, + aField, + aValForTime); } @@ -934,53 +943,43 @@ float VISU_Convertor_impl::GetTimeStampSize(const std::string& theMeshName, const std::string& theFieldName, int theStampsNum) { - VISU::TMesh* pMesh = NULL; - VISU::TField* pField = NULL; - VISU::TMeshOnEntity *pMeshOnEntity = NULL, *pVTKMeshOnEntity = NULL; - VISU::TField::TValForTime* pValForTime = NULL; - FindTimeStamp(theMeshName,pMesh,theEntity,pMeshOnEntity,pVTKMeshOnEntity, - theFieldName,pField,theStampsNum,pValForTime); - float aMeshSize = GetMeshOnEntitySize(theMeshName,pVTKMeshOnEntity->myEntity); - float aTimeStampSize = float(pField->myDataSize*sizeof(float) * ERR_SIZE_CALC); + TFindTimeStamp aFindTimeStamp = + FindTimeStamp(theMeshName,theEntity,theFieldName,theStampsNum); + PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindTimeStamp); + PField aField = boost::get<3>(aFindTimeStamp); + + float aMeshSize = GetMeshOnEntitySize(theMeshName,aVTKMeshOnEntity->myEntity); + float aTimeStampSize = float(aField->myDataSize*sizeof(float) * ERR_SIZE_CALC); float aResult = aMeshSize + aTimeStampSize; - if(MYDEBUG){ - if(MYVTKDEBUG) - MESSAGE("GetTimeStampSize - aTimeStampSize = "< -} +#include + +#include +#include +#include +#include +#include "VISU_ExtractUnstructuredGrid.hxx" #include #include +#include + +#include + +namespace VISU{ + + typedef vtkSmartPointer TVTKPoints; + typedef vtkSmartPointer TVTKSource; + typedef vtkSmartPointer TVTKMergetFilter; + typedef vtkSmartPointer TVTKExtractFilter; + typedef vtkSmartPointer TVTKAttribyteFilter; + + typedef float TCoord; + + struct TMeshImpl: TMesh{ + TVTKPoints myPoints; + + typedef std::vector TPointsCoord; + TPointsCoord myPointsCoord; + + typedef std::vector TPointsDim; + TPointsDim myPointsDim; + }; + typedef shared_ptr PMeshImpl; + + struct TMeshOnEntityImpl: TMeshOnEntity{ + TVTKSource myStorage; + typedef std::vector TConnect; + typedef std::vector TConnForCellType; + typedef std::map TCellsConn; + TCellsConn myCellsConn; + }; + typedef shared_ptr PMeshOnEntityImpl; + + struct TFamilyImpl: TFamily{ + TVTKSource myStorage; + + typedef std::set TSubMeshOnCellType; + typedef std::map TSubMesh; + TSubMesh mySubMesh; + }; + typedef shared_ptr PFamilyImpl; + + struct TGroupImpl: TGroup{ + TVTKSource myStorage; + }; + typedef shared_ptr PGroupImpl; + + struct TFieldImpl: TField{ + TVTKExtractFilter myExtractFilter; + ~TFieldImpl() + { + if(myExtractFilter.GetPointer()) + myExtractFilter->UnRegisterAllOutputs(); + } + }; + typedef shared_ptr PFieldImpl; + + struct TValForTimeImpl: TValForTime{ + TVTKAttribyteFilter myAttribyteFilter; + TVTKMergetFilter myMergeFilter; + TVTKSource myStorage; + + typedef std::vector TValForCellsWithType; + typedef std::map TValForCells; + TValForCells myValForCells; + + ~TValForTimeImpl() + { + if(myMergeFilter.GetPointer()) + myMergeFilter->UnRegisterAllOutputs(); + if(myAttribyteFilter.GetPointer()) + myAttribyteFilter->UnRegisterAllOutputs(); + } + }; + typedef shared_ptr PValForTimeImpl; + +} + class VISU_Convertor_impl: public VISU_Convertor{ public: virtual float GetSize() ; - virtual float GetMeshOnEntitySize(const std::string& theMeshName, - const VISU::TEntity& theEntity, - const std::string& theFamilyName = ""); - - virtual float GetMeshOnGroupSize(const std::string& theMeshName, - const std::string& theGroupName); - - virtual float GetTimeStampSize(const std::string& theMeshName, - const VISU::TEntity& theEntity, - const std::string& theFieldName, - int theStampsNum); - - virtual float GetFieldOnMeshSize(const std::string& theMeshName, - const VISU::TEntity& theEntity, - const std::string& theFieldName); - - virtual const VISU::TField& GetField(const std::string& theMeshName, - VISU::TEntity theEntity, - const std::string& theFieldName); - - virtual const VISU::TField::TValForTime& GetTimeStamp(const std::string& theMeshName, - const VISU::TEntity& theEntity, - const std::string& theFieldName, - int theStampsNum); + virtual + float + GetMeshOnEntitySize(const std::string& theMeshName, + const VISU::TEntity& theEntity, + const std::string& theFamilyName = ""); + + virtual + float + GetMeshOnGroupSize(const std::string& theMeshName, + const std::string& theGroupName); + + virtual + float + GetTimeStampSize(const std::string& theMeshName, + const VISU::TEntity& theEntity, + const std::string& theFieldName, + int theStampsNum); + + virtual + float + GetFieldOnMeshSize(const std::string& theMeshName, + const VISU::TEntity& theEntity, + const std::string& theFieldName); + + virtual + const VISU::PField + GetField(const std::string& theMeshName, + VISU::TEntity theEntity, + const std::string& theFieldName); + + virtual + const VISU::PValForTime + GetTimeStamp(const std::string& theMeshName, + const VISU::TEntity& theEntity, + const std::string& theFieldName, + int theStampsNum); public: VISU_Convertor_impl(); @@ -54,52 +149,70 @@ public: virtual VISU_Convertor* Build() { return this;}; - virtual TOutput* GetMeshOnEntity(const std::string& theMeshName, - const VISU::TEntity& theEntity, - const std::string& theFamilyName = ""); - - virtual TOutput* GetMeshOnGroup(const std::string& theMeshName, - const std::string& theGroupName); - - virtual TOutput* GetTimeStampOnMesh(const std::string& theMeshName, - const VISU::TEntity& theEntity, - const std::string& theFieldName, - int theStampsNum); + virtual + TOutput* + GetMeshOnEntity(const std::string& theMeshName, + const VISU::TEntity& theEntity, + const std::string& theFamilyName = ""); + + virtual + TOutput* + GetMeshOnGroup(const std::string& theMeshName, + const std::string& theGroupName); + + virtual + TOutput* + GetTimeStampOnMesh(const std::string& theMeshName, + const VISU::TEntity& theEntity, + const std::string& theFieldName, + int theStampsNum); protected: - void FindMesh(const std::string& theMeshName, VISU::TMesh*& theMesh); - - void FindMeshOnEntity(const std::string& theMeshName, VISU::TMesh*& theMesh, - const VISU::TEntity& theEntity, VISU::TMeshOnEntity*& theMeshOnEntity, - const std::string& theFamilyName, VISU::TFamily*& theFamily); - - void FindMeshOnGroup(const std::string& theMeshName, VISU::TMesh*& theMesh, - const std::string& theGroupName, VISU::TGroup*& theGroup); - - void FindField(const std::string& theMeshName, VISU::TMesh*& theMesh, - const VISU::TEntity& theEntity, - VISU::TMeshOnEntity*& theMeshOnEntity, - VISU::TMeshOnEntity*& theVTKMeshOnEntity, - const std::string& theFieldName, VISU::TField*& theField); - - void FindTimeStamp(const std::string& theMeshName, VISU::TMesh*& theMesh, - const VISU::TEntity& theEntity, - VISU::TMeshOnEntity*& theMeshOnEntity, - VISU::TMeshOnEntity*& theVTKMeshOnEntity, - const std::string& theFieldName, VISU::TField*& theField, - int theStampsNum, VISU::TField::TValForTime*& theValForTime); - + VISU::PMeshImpl + FindMesh(const std::string& theMeshName); + + typedef boost::tuple TFindMeshOnEntity; + TFindMeshOnEntity + FindMeshOnEntity(const std::string& theMeshName, + const VISU::TEntity& theEntity, + const std::string& theFamilyName); + + typedef boost::tuple TFindMeshOnGroup; + TFindMeshOnGroup + FindMeshOnGroup(const std::string& theMeshName, + const std::string& theGroupName); + + typedef boost::tuple TFindField; + TFindField + FindField(const std::string& theMeshName, + const VISU::TEntity& theEntity, + const std::string& theFieldName); + + typedef boost::tuple TFindTimeStamp; + TFindTimeStamp + FindTimeStamp(const std::string& theMeshName, + const VISU::TEntity& theEntity, + const std::string& theFieldName, + int theStampsNum); + protected: - virtual int LoadMeshOnEntity(VISU::TMeshOnEntity& theMeshOnEntity, + virtual int LoadMeshOnEntity(VISU::PMeshOnEntityImpl theMeshOnEntity, const std::string& theFamilyName = "") = 0; - virtual int LoadMeshOnGroup(VISU::TMesh& theMesh, + virtual int LoadMeshOnGroup(VISU::PMeshImpl theMesh, const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet) = 0; - virtual int LoadFieldOnMesh(VISU::TMesh& theMesh, - VISU::TMeshOnEntity& theMeshOnEntity, - VISU::TField& theField, - VISU::TField::TValForTime& theValForTime) = 0; + virtual int LoadFieldOnMesh(VISU::PMeshImpl theMesh, + VISU::PMeshOnEntityImpl theMeshOnEntity, + VISU::PFieldImpl theField, + VISU::PValForTimeImpl theValForTime) = 0; }; #endif diff --git a/src/CONVERTOR/VISU_DatConvertor.cxx b/src/CONVERTOR/VISU_DatConvertor.cxx deleted file mode 100644 index c85ac823..00000000 --- a/src/CONVERTOR/VISU_DatConvertor.cxx +++ /dev/null @@ -1,249 +0,0 @@ -// Copyright (C) 2003 CEA/DEN, EDF R&D -// -// -// -// File : VISU_DatConvertor.cxx -// Author : Alexey PETROV -// Module : VISU - -using namespace std; -#include "VISU_DatConvertor.hxx" -using namespace std; - -#ifdef DEBUG -static int MYDEBUG = 1; -#else -static int MYDEBUG = 0; -#endif -static int PRECISION = 7; - -extern "C" -VISU_Convertor* CreateDatConvertor(const string& theFileName) { - VISU_DatConvertor* aConvertor = new VISU_DatConvertor(theFileName); - aConvertor->Build(); - return aConvertor; -} -VISU_DatConvertor::VISU_DatConvertor(const string& theFileName) { - myFileInfo.setFile(QString(theFileName.c_str())); - myName = (const char*)(myFileInfo.baseName()); -} - -VISU_Convertor* VISU_DatConvertor::Build() { - /* - ifstream stmIn(myFileInfo.absFilePath()); - if(!stmIn.good()) - throw std::runtime_error(string("VISU_DatConvertor::CreateResult() >> can't open file - ") + - (const char*)myFileInfo.absFilePath()); - int aNbPoints, aNbCells, aNbFields; - ImportHead(&stmIn,&aNbPoints,&aNbCells,&aNbFields); - ImportPoints(&stmIn,aNbPoints); - vector aCellsType(aNbCells); - ImportCells(&stmIn,&aCellsType); - for(int i = 0; i < aNbFields; i++) - ImportField(&stmIn,aNbPoints,&aCellsType); - myIsDone = true; - */ - return this; -} - -int VISU_DatConvertor::ImportField(ifstream* pStmIn, int theNbPoints, vector* pCellsType) -{ - /* - ifstream &stmIn = *pStmIn; - vector& aCellsType = *pCellsType; - int aNbCells = aCellsType.size(); - string aName; stmIn>>aName; stmIn>>aName; - VISU::TMesh& aMesh = myMeshMap[myName]; - VISU::TMeshOnEntity& aMeshOnEntity = aMesh.myMeshOnEntityMap[VISU::CELL_ENTITY]; - VISU::TField& aField = aMeshOnEntity.myFieldMap[aName]; - aField.myMeshName = myName; - stmIn>>(aField.myNbComp); - aField.myNbComp %= 100; - int iEnd; stmIn>>iEnd; - if(iEnd == theNbPoints) - aField.myEntity = VISU::NODE_ENTITY; - else if(iEnd == aNbCells) - aField.myEntity = VISU::CELL_ENTITY; - else - throw std::runtime_error("ImportChamp >> elements doesn't connected to points or cells"); - if(MYDEBUG) - MESSAGE("FieldInfo - myMeshName = "<>tmp; - anArray.push_back(tmp); - } - } - */ - return 0; -} - -int VISU_DatConvertor::ImportHead(ifstream* pStmIn, int* theNbPoints, - int* theNbCells, int* theNbFields) -{ - /* - ifstream &stmIn = *pStmIn; - const int BUFSIZE = 256; - char buf[BUFSIZE]; - stmIn.getline(buf,BUFSIZE); - istrstream strIn(buf); - VISU::TMesh& aMesh = myMeshMap[myName]; - *theNbFields = 0; - strIn>>(*theNbPoints); strIn>>(*theNbCells); strIn>>(*theNbFields); - if(MYDEBUG) - MESSAGE("ImportHead - theNbPoints = "<<(*theNbPoints)<< - "; theNbCells = "<<(*theNbCells)<< - "; theNbFields = "<<(*theNbFields)); - */ - return 0; -} - -int VISU_DatConvertor::ImportPoints(ifstream* pStmIn, int theNbPoints) -{ - /* - ifstream &stmIn = *pStmIn; - VISU::TMesh& aMesh = myMeshMap[myName]; - aMesh.myName = myName; - aMesh.myDim = 3; - int iEnd = aMesh.myDim*theNbPoints; - if(MYDEBUG) MESSAGE("ImportPoints - iEnd = "< &aPointsCoord = aMesh.myPointsCoord; - aPointsCoord.resize(iEnd); - for(int i = 0, tmp; i < iEnd;){ - stmIn>>tmp; - stmIn>>aPointsCoord[i++]; stmIn>>aPointsCoord[i++]; stmIn>>aPointsCoord[i++]; - } - */ - return 0; -} - -int VISU_DatConvertor::ImportCells(ifstream* pStmIn, vector* pCellsType) -{ - /* - ifstream &stmIn = *pStmIn; - vector& aCellsType = *pCellsType; - int aNbCells = aCellsType.size(); - if(MYDEBUG) MESSAGE("ImportCells - theNbCells - Beginning"); - VISU::TMesh& aMesh = myMeshMap[myName]; - VISU::TMeshOnEntity& aMeshOnEntity = aMesh.myMeshOnEntityMap[VISU::CELL_ENTITY]; - aMeshOnEntity.myEntity = VISU::CELL_ENTITY; - aMeshOnEntity.myMeshName = myName; - for(int i = 0, aMedType, aVtkType; i < aNbCells; i++){ - stmIn>>aMedType; stmIn>>aMedType; - aCellsType[i] = aVtkType = med2vtkCellType(aMedType); - VISU::TMeshOnEntity::TConnForCellType& anArray = aMeshOnEntity.myCellsConn[aVtkType]; - anArray.push_back(VISU::TMeshOnEntity::TConnect()); - VISU::TMeshOnEntity::TConnect& aVector = anArray.back(); - int jEnd = getNbMedNodes(aMedType); - aVector.resize(jEnd); - for(int j = 0, tmp; j < jEnd; j++){ - stmIn>>tmp; - aVector[j] = tmp - 1; - } - } - if(MYDEBUG) MESSAGE("ImportCells - theNbCells - End"); - */ - return 0; -} - -/* -int VISU_Convertor_impl::ToDatFile(const string& theFileName) throw(std::runtime_error&){ - if(MYDEBUG) MESSAGE("VISU_Convertor_impl::ToDatFile - "<second; - if(MYDEBUG) MESSAGE("VISU_Convertor_impl::ToDatFile - aMeshName = "<first); - VISU::TFieldMap aFieldMap = GetFieldMapForMesh(aMeshIter->first); - const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh.myMeshOnEntityMap; - VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(VISU::CELL_ENTITY); - if(aMeshOnEntityMapIter != aMeshOnEntityMap.end()){ - const VISU::TMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second; - int aNbPoints = aMesh.myPointsCoord.size()/aMesh.myDim; - int aNbCells = aMeshOnEntity.GetCellsDims().first; - stmOut<first)<<"\t"; - const vector& aVector = anArray[j]; - int kEnd = aVector.size(); - for(int k = 0; k < kEnd; k++) - stmOut<second; - const VISU::TField::TValField &aValField = aField.myValField; - VISU::TField::TValField::const_reverse_iterator iter = aField.myValField.rbegin(); - for(int i = 0; iter != aValField.rend(); iter++, i++) { - if(MYDEBUG) MESSAGE("VISU_Convertor_impl::ToDatFile - aTime = "<second; - VISU::TField::TValForTime::const_iterator jter = aValForTime.begin(); - stmOut<<(++i)<first).c_str(),i); - stmOut< - -using namespace std; - -class VISU_DatConvertor: public VISU_Convertor_impl{ - VISU_DatConvertor(); - VISU_DatConvertor(const VISU_DatConvertor&); -public: - VISU_DatConvertor(const string& theFileName) ; - virtual VISU_Convertor* Build() ; -protected: - QFileInfo myFileInfo; - int ImportHead(ifstream* pStmIn, int* theNbPoints, int* theNbCells, int* theNbFields) ; - - int ImportPoints(ifstream*, int theNbPoints) ; - - int ImportCells(ifstream*, vector* aCellsType) ; - - int ImportField(ifstream*, int theNbPoints, vector* aCellsType) ; - - protected: - virtual int LoadMeshOnEntity(VISU::TMeshOnEntity& theMeshOnEntity, - const string& theFamilyName = "") - {return 1;} - virtual int LoadMeshOnGroup(VISU::TMesh& theMesh, - const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet) - {return 1;} - virtual int LoadFieldOnMesh(VISU::TMesh& theMesh, - VISU::TMeshOnEntity& theMeshOnEntity, - VISU::TField& theField, - VISU::TField::TValForTime& theValForTime) - {return 1;} -}; - -#endif diff --git a/src/CONVERTOR/VISU_ExtractUnstructuredGrid.cxx b/src/CONVERTOR/VISU_ExtractUnstructuredGrid.cxx index a8ba1e37..6fc53d05 100644 --- a/src/CONVERTOR/VISU_ExtractUnstructuredGrid.cxx +++ b/src/CONVERTOR/VISU_ExtractUnstructuredGrid.cxx @@ -75,11 +75,10 @@ void VISU_ExtractUnstructuredGrid::Execute(){ vtkUnstructuredGrid *anInput = this->GetInput(), *anOutput = this->GetOutput(); vtkIdType aNbCells = anInput->GetNumberOfCells(); anOutput->Allocate(aNbCells); - if(MYDEBUG) MESSAGE("Execute - anInput->GetNumberOfCells() = "<GetNumberOfCells()); + MSG(MYDEBUG,"Execute - anInput->GetNumberOfCells() = "<GetNumberOfCells()); vtkIdList *aCellIds = vtkIdList::New(); - if(MYDEBUG) - MESSAGE("Execute - myRemovedCellIds.empty() = "<GetNumberOfCells() = "<GetNumberOfCells()); + MSG(MYDEBUG,"Execute - anOutput->GetNumberOfCells() = "<GetNumberOfCells()); } diff --git a/src/CONVERTOR/VISU_MedConvertor.cxx b/src/CONVERTOR/VISU_MedConvertor.cxx index 7cc1162b..a861616a 100644 --- a/src/CONVERTOR/VISU_MedConvertor.cxx +++ b/src/CONVERTOR/VISU_MedConvertor.cxx @@ -26,738 +26,677 @@ #include "VISU_MedConvertor.hxx" +#include "VISU_Convertor.hxx" #include "VISU_ConvertorUtils.hxx" -#include -#include +#include "MED_Factory.hxx" +#include "MED_Algorithm.hxx" +#include "MED_Utilities.hxx" -#define USER_INTERLACE MED_FULL_INTERLACE +#include #define _EDF_NODE_IDS_ using namespace std; +using namespace MED; +using namespace VISU; #ifdef _DEBUG_ -static int MYDEBUG = 0; +static int MYDEBUG = 1; #else static int MYDEBUG = 0; #endif -static med_err ret = 0; - -typedef map TVisu2MedEntity; +namespace{ -static TVisu2MedEntity aVisu2MedEntity; - -static int INIT = ( - aVisu2MedEntity[VISU::NODE_ENTITY] = MED_NOEUD, - aVisu2MedEntity[VISU::EDGE_ENTITY] = MED_ARETE, - aVisu2MedEntity[VISU::FACE_ENTITY] = MED_FACE, - aVisu2MedEntity[VISU::CELL_ENTITY] = MED_MAILLE, - 1); + using namespace MED; + using namespace VISU; + + int MEDGeom2NbNodes(MED::EGeometrieElement theMEDGeomType) + { + return theMEDGeomType % 100; + } -static med_geometrie_element NODEGEOM[1] = {MED_POINT1}; + int MEDGeomToVTK(MED::EGeometrieElement theMEDGeomType) + { + switch(theMEDGeomType){ + case ePOINT1: return VTK_VERTEX; + case eSEG2: return VTK_LINE; + case eSEG3: return VTK_LINE; + case eTRIA3: return VTK_TRIANGLE; + case eTRIA6: return VTK_TRIANGLE; + case eQUAD4: return VTK_QUAD; + case eQUAD8: return VTK_QUAD; + case eTETRA4: return VTK_TETRA; + case eTETRA10: return VTK_TETRA; + case eHEXA8: return VTK_HEXAHEDRON; + case eHEXA20: return VTK_HEXAHEDRON; + case ePENTA6: return VTK_WEDGE; + case ePENTA15: return VTK_WEDGE; + case ePYRA5: return VTK_PYRAMID; + case ePYRA13: return VTK_PYRAMID; + } + return -1; + } -static med_geometrie_element EDGEGEOM[MED_NBR_GEOMETRIE_ARETE] = { - MED_SEG2, MED_SEG3 - }; + int VTKGeom2NbNodes(int theVTKGeomType) + { + switch(theVTKGeomType){ + case VTK_VERTEX: return 1; + case VTK_LINE: return 2; + case VTK_TRIANGLE: return 3; + case VTK_QUAD: return 4; + case VTK_TETRA: return 4; + case VTK_HEXAHEDRON: return 8; + case VTK_WEDGE: return 6; + case VTK_PYRAMID: return 5; + } + return -1; + } -static med_geometrie_element FACEGEOM[MED_NBR_GEOMETRIE_FACE] = { - MED_TRIA3, MED_QUAD4, MED_TRIA6, MED_QUAD8 - }; + MED::EGeometrieElement VTKGeomToMED(int theVTKGeomType) + { + switch(theVTKGeomType){ + case VTK_VERTEX: return ePOINT1; + case VTK_LINE: return eSEG2; + case VTK_TRIANGLE: return eTRIA3; + case VTK_QUAD: return eQUAD4; + case VTK_TETRA: return eTETRA4; + case VTK_HEXAHEDRON: return eHEXA8; + case VTK_WEDGE: return ePENTA6; + case VTK_PYRAMID: return ePYRA5; + } + return EGeometrieElement(-1); + } -static med_geometrie_element CELLGEOM[MED_NBR_GEOMETRIE_MAILLE] = { - MED_POINT1, MED_SEG2, MED_SEG3, MED_TRIA3, - MED_QUAD4, MED_TRIA6, MED_QUAD8, MED_TETRA4, - MED_PYRA5, MED_PENTA6, MED_HEXA8, MED_TETRA10, - MED_PYRA13, MED_PENTA15, MED_HEXA20 - }; + TEntity MEDEntityToVTK(MED::EEntiteMaillage theMEDEntity) + { + switch(theMEDEntity){ + case eNOEUD: return NODE_ENTITY; + case eARETE: return EDGE_ENTITY; + case eFACE: return FACE_ENTITY; + case eMAILLE: return CELL_ENTITY; + } + return TEntity(-1); + } -void GetEntity2Geom(const VISU::TEntity& theEntity, med_geometrie_element*& theVector, int* theEnd) -{ - switch(theEntity){ - case VISU::CELL_ENTITY: theVector = CELLGEOM; *theEnd = MED_NBR_GEOMETRIE_MAILLE; break; - case VISU::FACE_ENTITY: theVector = FACEGEOM; *theEnd = MED_NBR_GEOMETRIE_FACE; break; - case VISU::EDGE_ENTITY: theVector = EDGEGEOM; *theEnd = MED_NBR_GEOMETRIE_ARETE; break; - case VISU::NODE_ENTITY: theVector = NODEGEOM; *theEnd = 1; break; - default: - throw std::runtime_error("GetEntity2Geom >> theEntity is uncorrect"); + MED::EEntiteMaillage VTKEntityToMED(TEntity theVTKEntity) + { + switch(theVTKEntity){ + case NODE_ENTITY: return eNOEUD; + case EDGE_ENTITY: return eARETE; + case FACE_ENTITY: return eFACE; + case CELL_ENTITY: return eMAILLE; + } + return MED::EEntiteMaillage(-1); } + } extern "C" -VISU_Convertor* CreateMedConvertor(const string& theFileName) { +VISU_Convertor* CreateConvertor(const string& theFileName) +{ return new VISU_MedConvertor(theFileName); } -class MedFile{ - char* myFileName; - med_idt myFid; - MedFile(); - MedFile(const MedFile&); -public: - MedFile(const char* theFileName) : - myFileName(strdup(theFileName)) - { - myFid = MEDouvrir(myFileName,MED_LECT); - if(myFid < 0){ - free(myFileName); - throw std::runtime_error(string("MedFile::MedFile >> MEDouvrir(...) - ") + theFileName); - } - } - ~MedFile(){ - free(myFileName); - if(myFid >= 0) - MEDfermer(myFid); - } - const med_idt& GetFid() const { return myFid;}; -}; - VISU_MedConvertor::VISU_MedConvertor(const string& theFileName) { myFileInfo.setFile(QString(theFileName.c_str())); myName = myFileInfo.baseName().latin1(); } VISU_Convertor* VISU_MedConvertor::Build() { - MedFile aMedFile(myFileInfo.absFilePath()); - med_idt fid = aMedFile.GetFid(); - med_int iMeshEnd = MEDnMaa(fid); //Get number of meshes - if (iMeshEnd < 0) throw std::runtime_error(EXCEPTION("ImportInfo >> MEDnMaa(...)")); - if(MYDEBUG) MESSAGE("ImportInfo - MEDnMaa = "<GetPMeshInfo(iMesh); + + PNodeInfo aNodeInfo = aMed->GetPNodeInfo(aMeshInfo); + + MED::TEntityInfo aEntityInfo = aMed->GetEntityInfo(aMeshInfo); + + TCellGroup aCellGroup = GetCellsByEntity(aMed,aMeshInfo,aEntityInfo); + + TFamilyGroup aFamilyGroup = GetFamilies(aMed,aMeshInfo); + + TFamilyByEntity aFamilyByEntity = GetFamiliesByEntity(aMed,aNodeInfo,aCellGroup,aFamilyGroup); + + TGroupInfo aGroupInfo = GetFamiliesByGroup(aFamilyGroup); + + // creating TMesh structure and TMeshOnEntityMap + typedef map TFamilyCounterMap; TFamilyCounterMap aFamilyNbCellsCounterMap, aFamilyCellsSizeCounterMap; - TVisu2MedEntity::const_iterator aVisu2MedEntityIter = aVisu2MedEntity.begin(); - for(; aVisu2MedEntityIter != aVisu2MedEntity.end(); aVisu2MedEntityIter++) { - VISU::TEntity anEntity = aVisu2MedEntityIter->first; - int iGeomElemEnd; - med_geometrie_element* aGeomElemVector; - GetEntity2Geom(anEntity,aGeomElemVector,&iGeomElemEnd); - med_entite_maillage& aMedEntity = aVisu2MedEntity[anEntity]; - for (int iGeomElem = 0; iGeomElem < iGeomElemEnd; iGeomElem++) { - int medId = getIdMedType(aGeomElemVector[iGeomElem]); - int aVtkType = med2vtk[medId].vtkType; - med_geometrie_element aMedType = med2vtk[medId].medType; - if(aMedEntity == MED_NOEUD){ - med_geometrie_element typgeo = (med_geometrie_element)0; - med_connectivite typco = (med_connectivite)0; - med_int iNumElemEnd = MEDnEntMaa(fid,aMeshName,MED_COOR,MED_NOEUD,typgeo,typco); - if(iNumElemEnd > 0){ - VISU::TMeshOnEntity& aMeshOnEntity = aMesh.myMeshOnEntityMap[anEntity]; - aMeshOnEntity.myEntity = anEntity; - aMeshOnEntity.myMeshName = aMeshName; - aMeshOnEntity.myNbCells = iNumElemEnd; - aMeshOnEntity.myCellsSize = 2*iNumElemEnd; - aMesh.myNbPoints = iNumElemEnd; - if(MYDEBUG) - MESSAGE("ImportInfo -\t anEntity = "<> MEDnoeudsLire(...)")); - for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) - if(num_fam_elem[iNumElem] != 0){ - aFamily2EntityMap[num_fam_elem[iNumElem]] = anEntity; - aFamilyNbCellsCounterMap[num_fam_elem[iNumElem]] += 1; - aFamilyCellsSizeCounterMap[num_fam_elem[iNumElem]] += 2; - } + + TInt aDim = aMeshInfo->GetDim(); + const string& aMeshName = aMeshInfo->GetName(); + + PMEDMesh aMesh = aMeshMap[aMeshName](new TMEDMesh()); + aMesh->myDim = aDim; + aMesh->myName = aMeshName; + aMesh->myNbPoints = aNodeInfo->GetNbElem(); + aMesh->myMeshInfo = aMeshInfo; + aMesh->myEntityInfo = aEntityInfo; + + INITMSG(MYDEBUG,"aMeshName = '"<myMeshOnEntityMap; + MED::TEntityInfo::iterator anEntityIter = aEntityInfo.begin(); + for(; anEntityIter != aEntityInfo.end(); anEntityIter++){ + const EEntiteMaillage& aMEntity = anEntityIter->first; + const MED::TGeom& aTGeom = anEntityIter->second; + + TEntity aVEntity = MEDEntityToVTK(aMEntity); + PMEDMeshOnEntity aMeshOnEntity = aMeshOnEntityMap[aVEntity](new TMEDMeshOnEntity()); + aMeshOnEntity->myEntity = aVEntity; + aMeshOnEntity->myMeshName = aMeshName; + aMeshOnEntity->myGeom = aTGeom; + + INITMSG(MYDEBUG,"aMEntity = "<myNbCells = aMesh->myNbPoints; + aMeshOnEntity->myCellsSize = 2*aMesh->myNbPoints; + + for(TInt iElem = 0; iElem < aMesh->myNbPoints; iElem++){ + TInt aFamId = aNodeInfo->GetFamNum(iElem); + if(aFamId != 0){ + aFamilyNbCellsCounterMap[aFamId] += 1; + aFamilyCellsSizeCounterMap[aFamId] += 2; } } - //Get number of connectivities - med_int iNumElemEnd = MEDnEntMaa(fid,aMeshName,MED_CONN,aMedEntity,aMedType,MED_NOD); - if (iNumElemEnd > 0) { - VISU::TMeshOnEntity& aMeshOnEntity = aMesh.myMeshOnEntityMap[anEntity]; - aMeshOnEntity.myEntity = anEntity; - aMeshOnEntity.myMeshName = aMeshName; - med_booleen iname_elem, inum_elem; - valarray num_elem(iNumElemEnd), num_fam_elem(iNumElemEnd); - valarray name_elem('\0',iNumElemEnd*MED_TAILLE_PNOM+1); - med_int aNbConnForElem = getNbMedConnect(aMedType,anEntity,aMesh.myDim); - aMeshOnEntity.myNbCells += iNumElemEnd; - aMeshOnEntity.myCellsSize += iNumElemEnd*(med2vtk[medId].vtkNbNodes + 1); - if(MYDEBUG) - MESSAGE("ImportInfo -\t anEntity = "<> MEDelementsLire(...)")); - for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) - if(num_fam_elem[iNumElem] != 0){ - aFamily2EntityMap[num_fam_elem[iNumElem]] = anEntity; - aFamilyNbCellsCounterMap[num_fam_elem[iNumElem]] += 1; - aFamilyCellsSizeCounterMap[num_fam_elem[iNumElem]] += med2vtk[medId].vtkNbNodes + 1; - } + + INITMSG(MYDEBUG,"myNbCells = "<myNbCells<< + "; myCellsSize = "<myCellsSize<<"\n");; + + }else{ + MED::TGeom::const_iterator anTGeomIter = aTGeom.begin(); + aMeshOnEntity->myNbCells = 0; + aMeshOnEntity->myCellsSize = 0; + for(; anTGeomIter != aTGeom.end(); anTGeomIter++){ + const EGeometrieElement& aGeom = anTGeomIter->first; + int aVNbNodes = VTKGeom2NbNodes(MEDGeomToVTK(aGeom)); + PCellInfo aCellInfo = aMed->GetPCellInfo(aMeshInfo,aMEntity,aGeom); + TInt aNbElem = aCellInfo->GetNbElem(); + aMeshOnEntity->myNbCells += aNbElem; + aMeshOnEntity->myCellsSize += aNbElem*(aVNbNodes+1); + INITMSG(MYDEBUG,"aGeom = "<myNbPoints; iElem++){ + TInt aFamId = aCellInfo->GetFamNum(iElem); + if(aFamId != 0){ + aFamilyNbCellsCounterMap[aFamId] += 1; + aFamilyCellsSizeCounterMap[aFamId] += aVNbNodes + 1; + } + } } } } - med_int aNbFamily = MEDnFam(fid,aMeshName,0,MED_FAMILLE); - if(MYDEBUG) MESSAGE("ImportInfo - aNbFamily = "< anAttId(aNbAttrib), anAttVal(aNbAttrib); - valarray anAttDesc('\0',aNbAttrib*MED_TAILLE_DESC+1); - med_int aNbGroup = MEDnFam(fid,aMeshName,aFamInd,MED_GROUPE); - if(0 && MYDEBUG) - MESSAGE("ImportInfo - aFamInd = "<> MEDfamInfo")); - if(0 && MYDEBUG) - MESSAGE("ImportInfo - aFamilyNum = "<second; - const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity.myFamilyMap; - if(aFamilyMap.empty()) continue; - VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin(); - for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){ - const VISU::TFamily& aFamily = aFamilyMapIter->second; - const VISU::TBindGroups& aBindGroups = aFamily.myGroups; - if(aBindGroups.empty()) continue; - VISU::TBindGroups::const_iterator aBindGroupsIter = aBindGroups.begin(); - for(; aBindGroupsIter != aBindGroups.end(); aBindGroupsIter++){ - const string& aGroupName = *aBindGroupsIter; - VISU::TGroup& aGroup = aGroupMap[aGroupName]; - aGroup.myName = aGroupName; - aGroup.myMeshName = aMesh.myName; - VISU::TFamilyAndEntity aFamilyAndEntity(aFamily.myName,aFamily.myEntity); - aGroup.myFamilyAndEntitySet.insert(aFamilyAndEntity); - aGroup.myNbCells += aFamily.myNbCells; - aGroup.myCellsSize += aFamily.myCellsSize; + + TFamilyByEntity::const_iterator aFamilyByEntityIter = aFamilyByEntity.begin(); + BEGMSG(MYDEBUG,"TFamilyByEntity:\n"); + for(; aFamilyByEntityIter != aFamilyByEntity.end(); aFamilyByEntityIter++){ + const EEntiteMaillage& aMEntity = aFamilyByEntityIter->first; + const TFamilyGroup& aFamilyGroup = aFamilyByEntityIter->second; + + TEntity aVEntity = MEDEntityToVTK(aMEntity); + VISU::PMEDMeshOnEntity aMeshOnEntity = aMesh->myMeshOnEntityMap[aVEntity]; + VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap; + + INITMSG(MYDEBUG,"aMEntity = "<GetId() == 0) + continue; + + const std::string& aFamilyName = aFamilyInfo->GetName(); + PMEDFamily aFamily = aFamilyMap[aFamilyName](new TMEDFamily()); + + aFamily->myId = aFamilyInfo->GetId(); + aFamily->myName = aFamilyInfo->GetName(); + aFamily->myEntity = aVEntity; + aFamily->myNbCells = aFamilyNbCellsCounterMap[aFamily->myId]; + aFamily->myCellsSize = aFamilyCellsSizeCounterMap[aFamily->myId]; + + INITMSG(MYDEBUG,"aFamilyName = '"<myName<< + "'; myId = "<myId<<"; "<< + "; aNbAttr = "<GetNbAttr()<< + "; aNbGroup = "<GetNbGroup()<< + "; myEntity = "<myEntity<< + "; myNbCells = "<myNbCells<< + "; myCellsSize = "<myCellsSize<<"\n"); + + VISU::TBindGroups& aBindGroups = aFamily->myGroups; + const TInt aNbGroup = aFamilyInfo->GetNbGroup(); + for(TInt i = 0; i < aNbGroup; i++){ + const string& aGroupName = aFamilyInfo->GetGroupName(i); + aBindGroups.insert(aGroupName); + INITMSG(MYDEBUG,"aGroupName = '"<> MEDnChamp(fid,0)")); - if(MYDEBUG) MESSAGE("ImportInfo - iFieldEnd = "<> MEDnChamp(fid,i)")); - valarray aCompNames('\0',ncomp*MED_TAILLE_PNOM + 1); - valarray aUnitNames('\0',ncomp*MED_TAILLE_PNOM + 1); - char name_field[MED_TAILLE_NOM + 1] = ""; - med_type_champ type_field; - if(MEDchampInfo(fid,iField,name_field,&type_field,&aCompNames[0],&aUnitNames[0],ncomp) < 0) - throw std::runtime_error(EXCEPTION("ImportInfo >> MEDchampInfo(...)")); - //if(type_field != MED_REEL64) continue; //There is some problem in reading INTXX values - TVisu2MedEntity::const_iterator aVisu2MedEntityIter = aVisu2MedEntity.begin(); - for(; aVisu2MedEntityIter != aVisu2MedEntity.end(); aVisu2MedEntityIter++) { - VISU::TEntity anEntity = aVisu2MedEntityIter->first; - int iGeomElemEnd; - med_geometrie_element* aGeomElemVector; - GetEntity2Geom(anEntity,aGeomElemVector,&iGeomElemEnd); - med_entite_maillage& aMedEntity = aVisu2MedEntity[anEntity]; - for (int iGeomElem = 0; iGeomElem < iGeomElemEnd; iGeomElem++) { - med_geometrie_element& aGeom = aGeomElemVector[iGeomElem]; - med_int iTimeStampEnd = MEDnPasdetemps(fid,name_field,aMedEntity,aGeom); - if(iTimeStampEnd < 0) throw std::runtime_error(EXCEPTION("ImportInfo >> MEDnPasdetemps(...)")); - if(iTimeStampEnd > 0) { - for(med_int iTimeStamp = 1; iTimeStamp <= iTimeStampEnd; iTimeStamp++) { - char aMeshName[MED_TAILLE_NOM+1] = ""; - med_int ngauss = 0, numdt = 0, numo = 0; - char dt_unit[MED_TAILLE_PNOM+1] = ""; - med_float dt = 0; - ret = MEDpasdetempsInfo(fid,name_field,aMedEntity,aGeom,iTimeStamp, - aMeshName,&ngauss,&numdt,dt_unit,&dt,&numo); - if(ret < 0) throw std::runtime_error(EXCEPTION("ImportInfo >> MEDpasdetempsInfo(...) < 0")); - if(myMeshMap.find(aMeshName) == myMeshMap.end()) - throw std::runtime_error(EXCEPTION("ImportInfo >> MEDpasdetempsInfo(...)")); - VISU::TMesh &aMesh = myMeshMap[aMeshName]; - VISU::TMeshOnEntity& aMeshOnEntity = aMesh.myMeshOnEntityMap[anEntity]; - VISU::TFieldMap::iterator aFieldMapIter = aMeshOnEntity.myFieldMap.find(name_field); - //if(MYDEBUG && aFieldMapIter == aMeshOnEntity.myFieldMap.end()){ - VISU::TField& aField = aMeshOnEntity.myFieldMap[name_field]; - if(iTimeStamp == 1){ - aField.myId = iField; - aField.myName = name_field; - aField.myEntity = anEntity; - aField.myMeshName = aMeshName; - aField.myNbComp = ncomp; - aField.myNbValField = iTimeStampEnd; - aField.myDataSize = aMeshOnEntity.myNbCells * ncomp; - aField.myCompNames.resize(ncomp); - aField.myUnitNames.resize(ncomp); - if(MYDEBUG) - MESSAGE("ImportInfo - aField.myName = '"<myGroupMap; + TGroupInfo::const_iterator aGroupInfoIter = aGroupInfo.begin(); + for(;aGroupInfoIter != aGroupInfo.end(); aGroupInfoIter++){ + const string& aGroupName = aGroupInfoIter->first; + const TFamilyGroup& aFamilyGroup = aGroupInfoIter->second; + PMEDGroup aGroup(new TMEDGroup()); + aGroup->myName = aGroupName; + aGroup->myMeshName = aMesh->myName; + + INITMSG(MYDEBUG,"aGroup->myName = '"<myName<<"'\n"); + + TFamilyGroup::const_iterator aFamilyIter = aFamilyGroup.begin(); + for(; aFamilyIter != aFamilyGroup.end(); aFamilyIter++){ + const PFamilyInfo& aFamilyInfo = *aFamilyIter; + const string& aFamilyName = aFamilyInfo->GetName(); + + TEntity aVEntity = TEntity(-1); + PFamily aFamily; + + // Find aVisuEntity + const TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; + TMeshOnEntityMap::const_iterator aMeshOnEntityIter = aMeshOnEntityMap.begin(); + for(; aMeshOnEntityIter != aMeshOnEntityMap.end(); aMeshOnEntityIter++){ + const PMeshOnEntity& aMeshOnEntity = aMeshOnEntityIter->second; + const TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap; + TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin(); + for (; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){ + const string& aFamilyName = aFamilyMapIter->first; + aFamily = aFamilyMapIter->second; + if(aFamily){ + TFamilyGroup::const_iterator aGroupInfoIter = aFamilyGroup.begin(); + for(; aGroupInfoIter != aFamilyGroup.end(); aGroupInfoIter++){ + const PFamilyInfo& aFamilyInfo = *aGroupInfoIter; + if(aFamilyInfo->GetName() == aFamilyName){ + aVEntity = aFamily->myEntity; + goto exit_lable; + } } - } - VISU::TField::TValForTime& aValForTime = aField.myValField[iTimeStamp]; - aValForTime.myId = iTimeStamp; - aValForTime.myFieldName = aField.myName; - aValForTime.myEntity = aField.myEntity; - aValForTime.myMeshName = aField.myMeshName; - aValForTime.myNbComp = aField.myNbComp; - aValForTime.myTime = VISU::TField::TTime(dt,dt_unit); - if(MYDEBUG) - MESSAGE("ImportInfo -\t aValForTime.myTime = "<= 0){ + aGroup->myFamilyAndEntitySet.insert(TFamilyAndEntity(aFamilyName,aVEntity)); + INITMSG(MYDEBUG,"aFamilyName = '"<myNbCells += aFamily->myNbCells; + aGroup->myCellsSize += aFamily->myCellsSize; + } + } + if(!aGroup->myFamilyAndEntitySet.empty() && aGroup->myNbCells > 0){ + BEGMSG(MYDEBUG,"myNbCells = "<myNbCells<< + "; myCellsSize = "<myCellsSize<<"\n\n"); + aGroupMap.insert(VISU::TGroupMap::value_type(aGroupName,aGroup)); + } + } + + BEGMSG(MYDEBUG,"VISU::TField:\n"); + + TInt aNbFields = aMed->GetNbFields(); + for(TInt iField = 1; iField <= aNbFields; iField++){ + PFieldInfo aFieldInfo = aMed->GetPFieldInfo(aMeshInfo,iField); + TInt aNbComp = aFieldInfo->GetNbComp(); + const string& aFieldName = aFieldInfo->GetName(); + + MED::TGeom aTGeom; + EEntiteMaillage aMEntity; + TInt aNbTimeStamps = aMed->GetNbTimeStamps(aFieldInfo,aEntityInfo,aMEntity,aTGeom); + + TEntity aVEntity = MEDEntityToVTK(aMEntity); + VISU::PMeshOnEntity aMeshOnEntity = aMesh->myMeshOnEntityMap[aVEntity]; + TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap; + PMEDField aField = aFieldMap[aFieldName](new TMEDField()); + aField->myId = iField; + aField->myNbComp = aNbComp; + aField->myEntity = aVEntity; + aField->myName = aFieldName; + aField->myMeshName = aMeshName; + aField->myDataSize = aMeshOnEntity->myNbCells * aNbComp; + aField->myCompNames.resize(aNbComp); + aField->myUnitNames.resize(aNbComp); + + INITMSG(MYDEBUG,"myName = '"<myName<< + "'; myId = "<myId<< + "; myEntity = "<myEntity<< + "; myDataSize = "<myDataSize<< + "; myNbComp = "<myNbComp<<"\n"); + + for(TInt iComp = 0; iComp < aNbComp; iComp++){ + aField->myCompNames[iComp] = aFieldInfo->GetCompName(iComp); + aField->myUnitNames[iComp] = aFieldInfo->GetUnitName(iComp); + } + + for(TInt iTimeStamp = 1; iTimeStamp <= aNbTimeStamps; iTimeStamp++){ + PTimeStampInfo aTimeStamp = aMed->GetPTimeStampInfo(aFieldInfo, + aMEntity, + aTGeom, + iTimeStamp); + TFloat aDt = aTimeStamp->GetDt(); + const string& anUnitDt = aTimeStamp->GetUnitDt(); + PTimeStampVal aTimeStampVal = aMed->GetPTimeStampVal(aTimeStamp); + TValField& aValField = aField->myValField; + PMEDValForTime aValForTime = aValField[iTimeStamp](new TMEDValForTime()); + aValForTime->myId = iTimeStamp; + aValForTime->myFieldName = aField->myName; + aValForTime->myEntity = aField->myEntity; + aValForTime->myMeshName = aField->myMeshName; + aValForTime->myNbComp = aField->myNbComp; + aValForTime->myTime = VISU::TTime(aDt,anUnitDt); + INITMSG(MYDEBUG,"aDt = "<myMeshName; + const VISU::TEntity& anEntity = theMeshOnEntity->myEntity; + PMeshImpl aMesh = myMeshMap[aMeshName]; int isPointsUpdated; if(anEntity == VISU::NODE_ENTITY) - isPointsUpdated = LoadPoints(fid,aMesh,theFamilyName); + isPointsUpdated = LoadPoints(aMed,aMesh,theFamilyName); else - isPointsUpdated = LoadPoints(fid,aMesh); - int isCellsOnEntityUpdated = LoadCellsOnEntity(fid,theMeshOnEntity,theFamilyName); + isPointsUpdated = LoadPoints(aMed,aMesh); + int isCellsOnEntityUpdated = LoadCellsOnEntity(aMed,aMesh,theMeshOnEntity,theFamilyName); return (isPointsUpdated || isCellsOnEntityUpdated); } -int VISU_MedConvertor::LoadMeshOnGroup(VISU::TMesh& theMesh, +int VISU_MedConvertor::LoadMeshOnGroup(VISU::PMeshImpl theMesh, const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet) { - //Open the med file (it will be closed by call of destructor) - MedFile aMedFile(myFileInfo.absFilePath()); - med_idt fid = aMedFile.GetFid(); - //Main part of code - int isPointsUpdated = 0; - int isCellsOnEntityUpdated = 0; + PWrapper aMed = CrWrapper(myFileInfo.absFilePath().latin1()); + int isPointsUpdated = 0, isCellsOnEntityUpdated = 0; VISU::TFamilyAndEntitySet::const_iterator aFamilyAndEntitySetIter = theFamilyAndEntitySet.begin(); for(; aFamilyAndEntitySetIter != theFamilyAndEntitySet.end(); aFamilyAndEntitySetIter++){ const string& aFamilyName = aFamilyAndEntitySetIter->first; const VISU::TEntity& anEntity = aFamilyAndEntitySetIter->second; - VISU::TMeshOnEntity& aMeshOnEntity = theMesh.myMeshOnEntityMap[anEntity]; + const VISU::PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[anEntity]; if(anEntity == VISU::NODE_ENTITY){ - isPointsUpdated += LoadPoints(fid,theMesh,aFamilyName); - isCellsOnEntityUpdated += LoadCellsOnEntity(fid,aMeshOnEntity); + isPointsUpdated += LoadPoints(aMed,theMesh,aFamilyName); + isCellsOnEntityUpdated += LoadCellsOnEntity(aMed,theMesh,aMeshOnEntity); }else{ - isPointsUpdated += LoadPoints(fid,theMesh); - isCellsOnEntityUpdated += LoadCellsOnEntity(fid,aMeshOnEntity,aFamilyName); + isPointsUpdated += LoadPoints(aMed,theMesh); + isCellsOnEntityUpdated += LoadCellsOnEntity(aMed,theMesh,aMeshOnEntity,aFamilyName); } } return (isPointsUpdated || isCellsOnEntityUpdated); } -int VISU_MedConvertor::LoadFieldOnMesh(VISU::TMesh& theMesh, - VISU::TMeshOnEntity& theMeshOnEntity, - VISU::TField& theField, - VISU::TField::TValForTime& theValForTime) +int VISU_MedConvertor::LoadFieldOnMesh(VISU::PMeshImpl theMesh, + VISU::PMeshOnEntityImpl theMeshOnEntity, + VISU::PFieldImpl theField, + VISU::PValForTimeImpl theValForTime) { - //Open the med file (it will be closed by call of destructor) - MedFile aMedFile(myFileInfo.absFilePath()); - med_idt fid = aMedFile.GetFid(); - //Main part of code - int isPointsUpdated = LoadPoints(fid,theMesh); - int isCellsOnEntityUpdated = LoadCellsOnEntity(fid,theMeshOnEntity); - int isFieldUpdated = LoadField(fid,theMeshOnEntity,theField,theValForTime); + PWrapper aMed = CrWrapper(myFileInfo.absFilePath().latin1()); + int isPointsUpdated = LoadPoints(aMed,theMesh); + int isCellsOnEntityUpdated = LoadCellsOnEntity(aMed,theMesh,theMeshOnEntity); + int isFieldUpdated = LoadField(aMed,theMesh,theMeshOnEntity,theField,theValForTime); return (isPointsUpdated || isCellsOnEntityUpdated || isFieldUpdated); } -int VISU_MedConvertor::LoadPoints(const med_idt& fid, VISU::TMesh& theMesh, const string& theFamilyName) + +int +VISU_MedConvertor::LoadPoints(const MED::PWrapper& theMed, + VISU::PMEDMesh theMesh, + const string& theFamilyName) { try{ //Check on existing family - VISU::TMeshOnEntity& aMeshOnEntity = theMesh.myMeshOnEntityMap[VISU::NODE_ENTITY]; - aMeshOnEntity.myEntity = VISU::NODE_ENTITY; - aMeshOnEntity.myMeshName = theMesh.myName; - VISU::TFamily* pFamily = VISU::GetFamily(aMeshOnEntity,theFamilyName); - bool isFamilyPresent = (pFamily != NULL); - VISU::TFamily& aFamily = *pFamily; + VISU::PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[VISU::NODE_ENTITY]; + aMeshOnEntity->myEntity = VISU::NODE_ENTITY; + aMeshOnEntity->myMeshName = theMesh->myName; + PFamilyImpl aFamily = GetFamily(aMeshOnEntity,theFamilyName); //Check on loading already done - bool isPointsLoaded = !theMesh.myPointsCoord.empty(); + bool isPointsLoaded = !theMesh->myPointsCoord.empty(); if(isPointsLoaded) - if(!isFamilyPresent) return 0; - else if(!aFamily.mySubMesh.empty()) return 0; - if(MYDEBUG) - MESSAGE("LoadPoints - isPointsLoaded = "<mySubMesh.empty()) + return 0; + + INITMSG(MYDEBUG,"LoadPoints - isPointsLoaded = "<> MEDnEntMaa(...)")); - if(MYDEBUG) MESSAGE("LoadPoints - iNumElemEnd = "< num_elem(iNumElemEnd), num_fam_elem(iNumElemEnd); - valarray name_elem('\0',iNumElemEnd*MED_TAILLE_PNOM+1); - valarray name_coord('\0',theMesh.myDim*MED_TAILLE_PNOM+1); - valarray unit_coord('\0',theMesh.myDim*MED_TAILLE_PNOM+1); - valarray coord(theMesh.myDim*iNumElemEnd); - ret = MEDnoeudsLire(fid,aMeshName,theMesh.myDim,&coord[0],MED_FULL_INTERLACE,&rep, - &name_coord[0],&unit_coord[0],&name_elem[0],&iname_elem, - &num_elem[0],&inum_elem,&num_fam_elem[0],iNumElemEnd); - if(ret < 0) throw std::runtime_error(EXCEPTION("LoadPoints >> MEDnoeudsLire(...)")); - if(!isPointsLoaded){ + PNodeInfo aNodeInfo = theMed->GetPNodeInfo(theMesh->myMeshInfo); + TInt aNbElem = aNodeInfo->GetNbElem(); - VISU::TMesh::TPointsDim& aPointsDim = theMesh.myPointsDim; - aPointsDim.resize(theMesh.myDim); - for(int iDim = 0, iPos = 0; iDim < theMesh.myDim; iDim++, iPos += MED_TAILLE_PNOM){ - char aCoordName[MED_TAILLE_PNOM+1]; - strncpy(aCoordName,&name_coord[iPos],MED_TAILLE_PNOM); - aCoordName[MED_TAILLE_PNOM] = '\0'; - aPointsDim[iDim] = aCoordName; - } + if(!isPointsLoaded){ + VISU::TMeshImpl::TPointsDim& aPointsDim = theMesh->myPointsDim; + aPointsDim.resize(theMesh->myDim); + for(int iDim = 0; iDim < theMesh->myDim; iDim++) + aPointsDim[iDim] = aNodeInfo->GetCoordName(iDim); - VISU::TMesh::TPointsCoord& aPointsCoord = theMesh.myPointsCoord; - aPointsCoord.resize(iNumElemEnd*theMesh.myDim); - if(MYDEBUG) MESSAGE("LoadPoints - Filling coordinates of the mesh - inum_elem = "<myPointsCoord; + aPointsCoord.resize(aNbElem*theMesh->myDim); + for (int iElem = 0; iElem < aNbElem; iElem++) + for(int iDim = 0, iElem2Dim = iElem*theMesh->myDim; iDim < theMesh->myDim; iDim++, iElem2Dim++) + aPointsCoord[iElem2Dim] = aNodeInfo->GetNodeCoord(iElem,iDim); + + VISU::TMeshOnEntityImpl::TConnForCellType& aConnForCellType = aMeshOnEntity->myCellsConn[VTK_VERTEX]; + aConnForCellType.resize(aNbElem); + for (int iElem = 0; iElem < aNbElem; iElem++) + aConnForCellType[iElem] = VISU::TMeshOnEntityImpl::TConnect(1,iElem); } - if(isFamilyPresent && iNumElemEnd > 0){ - if(MYDEBUG) MESSAGE("LoadPoints - Filling aFamily SubMesh"); - VISU::TFamily::TSubMeshOnCellType& aSubMeshOnCellType = aFamily.mySubMesh[VTK_VERTEX]; - for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) - if(num_fam_elem[iNumElem] == aFamily.myId) - aSubMeshOnCellType.insert(iNumElem); + if(aFamily && aNbElem > 0){ + VISU::TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aFamily->mySubMesh[VTK_VERTEX]; + for (int iElem = 0; iElem < aNbElem; iElem++) + if(aNodeInfo->GetElemNum(iElem) == aFamily->myId) + aSubMeshOnCellType.insert(iElem); } return 1; }catch(std::runtime_error& exc){ - theMesh.myPointsCoord.clear(); - throw std::runtime_error(exc.what()); + theMesh->myPointsCoord.clear(); + throw; }catch(...){ - theMesh.myPointsCoord.clear(); - throw std::runtime_error(EXCEPTION("Unknown exception !!!")); + theMesh->myPointsCoord.clear(); + EXCEPTION(runtime_error,"Unknown exception !!!"); } return 0; } -int VISU_MedConvertor::LoadCellsOnEntity(const med_idt& fid, VISU::TMeshOnEntity& theMeshOnEntity, - const string& theFamilyName) + +int +VISU_MedConvertor::LoadCellsOnEntity(const MED::PWrapper& theMed, + VISU::PMEDMesh theMesh, + VISU::PMEDMeshOnEntity theMeshOnEntity, + const string& theFamilyName) { try{ //Check on existing family - VISU::TFamily* pFamily = VISU::GetFamily(theMeshOnEntity,theFamilyName); - bool isFamilyPresent = (pFamily != NULL); - VISU::TFamily& aFamily = *pFamily; + PFamilyImpl aFamily = GetFamily(theMeshOnEntity,theFamilyName); //Check on loading already done - bool isCellsLoaded = !theMeshOnEntity.myCellsConn.empty(); + bool isCellsLoaded = !theMeshOnEntity->myCellsConn.empty(); if(isCellsLoaded) - if(!isFamilyPresent) return 0; - else if(!aFamily.mySubMesh.empty()) return 0; - if(MYDEBUG) { - MESSAGE("LoadCellsOnEntity - theFamilyName = '"< num_node(aNbPoints); - med_booleen inum_node = - med_booleen(MEDnumLire(fid,aMeshName,&num_node[0],aNbPoints,MED_NOEUD,med_geometrie_element(0)) >= 0); - if(MYDEBUG) MESSAGE("LoadCellsOnEntity - inum_node = "<mySubMesh.empty()) + return 0; + + INITMSG(MYDEBUG,"LoadCellsOnEntity - theFamilyName = '"<> MEDelementsLire(...)")); - if(!isCellsLoaded){ - VISU::TMeshOnEntity::TConnForCellType& aConnForCellType = theMeshOnEntity.myCellsConn[aVtkType]; - aConnForCellType.resize(iNumElemEnd); - valarray aConnect(nbMedNodes); - for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) { - VISU::TMeshOnEntity::TConnect& anArray = aConnForCellType[iNumElem]; - anArray.resize(nbVtkNodes); - if(inum_node) - for (int k = 0, kj = iNumElem*aNbConnForElem; k < nbMedNodes; k++) - aConnect[k] = node_map[conn[kj+k]-1]; - else - for (int k = 0, kj = iNumElem*aNbConnForElem; k < nbMedNodes; k++) - aConnect[k] = conn[kj+k] - 1; - switch(aMedType){ - case MED_TETRA4 : - case MED_TETRA10 : - anArray[0] = aConnect[0]; - anArray[1] = aConnect[1]; - anArray[2] = aConnect[3]; - anArray[3] = aConnect[2]; - break; - case MED_PYRA5 : - case MED_PYRA13 : - anArray[0] = aConnect[0]; - anArray[1] = aConnect[3]; - anArray[2] = aConnect[2]; - anArray[3] = aConnect[1]; - anArray[4] = aConnect[4]; - break; - default: - for (int k = 0; k < nbVtkNodes; k++) - anArray[k] = aConnect[k]; - } - for (int k = 0; k < nbVtkNodes; k++) - if(anArray[k] < 0 || aNbPoints <= anArray[k]) - throw std::runtime_error(EXCEPT("ImportCells >> aNbPoints(%1) <= anArray[%2][%3](%4) < 0"). - arg(aNbPoints).arg(iNumElem).arg(k).arg(anArray[k]).latin1()); - } - } - //Filling aFamily SubMesh - if(isFamilyPresent){ - VISU::TFamily::TSubMeshOnCellType& aSubMeshOnCellType = aFamily.mySubMesh[aVtkType]; - for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) - if(num_fam_elem[iNumElem] == aFamily.myId) - aSubMeshOnCellType.insert(iNumElem); - } + + const MED::TGeom& aTGeom = theMeshOnEntity->myGeom; + MED::TGeom::const_iterator anTGeomIter = aTGeom.begin(); + TMeshOnEntityImpl::TCellsConn& aCellsConn = theMeshOnEntity->myCellsConn; + + for(; anTGeomIter != aTGeom.end(); anTGeomIter++){ + const EGeometrieElement& aGeom = anTGeomIter->first; + int aVTKGeomType = MEDGeomToVTK(aGeom); + int aVNbNodes = VTKGeom2NbNodes(aVTKGeomType); + + PCellInfo aCellInfo = theMed->GetPCellInfo(aMeshInfo,aMEntity,aGeom); + TInt aNbElem = aCellInfo->GetNbElem(); + + if(!isCellsLoaded){ + VISU::TMeshOnEntityImpl::TConnForCellType& aConnForCellType = aCellsConn[aVTKGeomType]; + aConnForCellType.resize(aNbElem); + + int aMNbNodes = MEDGeom2NbNodes(aGeom); + vector aConnect(aMNbNodes); + + for (int iElem = 0; iElem < aNbElem; iElem++) { + VISU::TMeshOnEntityImpl::TConnect& anArray = aConnForCellType[iElem]; + anArray.resize(aVNbNodes); + + if(anIsNodeNum){ + for(int i = 0; i < aMNbNodes; i++){ + aConnect[i] = aNodeIdMap[aCellInfo->GetConn(iElem,i)-1]; + } + }else{ + for(int i = 0; i < aMNbNodes; i++){ + aConnect[i] = aCellInfo->GetConn(iElem,i)-1; + } + } + + switch(aGeom){ + case eTETRA4: + case eTETRA10: + anArray[0] = aConnect[0]; + anArray[1] = aConnect[1]; + anArray[2] = aConnect[3]; + anArray[3] = aConnect[2]; + break; + case ePYRA5: + case ePYRA13: + anArray[0] = aConnect[0]; + anArray[1] = aConnect[3]; + anArray[2] = aConnect[2]; + anArray[3] = aConnect[1]; + anArray[4] = aConnect[4]; + break; + default: + for(int iNode = 0; iNode < aVNbNodes; iNode++) + anArray[iNode] = aConnect[iNode]; + } + for(int iNode = 0; iNode < aVNbNodes; iNode++) + if(anArray[iNode] < 0 || aNbPoints <= anArray[iNode]) + EXCEPTION(runtime_error,"ImportCells >> aNbPoints("<mySubMesh[aVTKGeomType]; + for(int iElem = 0; iElem < aNbElem; iElem++) + if(aCellInfo->GetFamNum(iElem) == aFamily->myId) + aSubMeshOnCellType.insert(iElem); } } return 1; }catch(std::runtime_error& exc){ - theMeshOnEntity.myCellsConn.clear(); - throw std::runtime_error(exc.what()); + theMeshOnEntity->myCellsConn.clear(); + throw; }catch(...){ - theMeshOnEntity.myCellsConn.clear(); - throw std::runtime_error(EXCEPTION("Unknown exception !!!")); + theMeshOnEntity->myCellsConn.clear(); + EXCEPTION(runtime_error,"Unknown exception !!!"); } return 0; } -int VISU_MedConvertor::LoadField(const med_idt& fid, const VISU::TMeshOnEntity& theMeshOnEntity, - VISU::TField& theField, VISU::TField::TValForTime& theValForTime) + +int +VISU_MedConvertor::LoadField(const MED::PWrapper& theMed, + VISU::PMEDMesh theMesh, + VISU::PMEDMeshOnEntity theMeshOnEntity, + VISU::PMEDField theField, + VISU::PMEDValForTime theValForTime) { //Check on loading already done - if(!theValForTime.myValForCells.empty()) return 0; + if(!theValForTime->myValForCells.empty()) return 0; + //Main part of code - med_int ncomp = MEDnChamp(fid,theField.myId); - if(ncomp < 0) throw std::runtime_error(EXCEPTION("LoadField >> MEDnChamp(fid,i)")); - valarray comp('\0',ncomp*MED_TAILLE_PNOM + 1); - valarray unit('\0',ncomp*MED_TAILLE_PNOM + 1); - char aFieldName[MED_TAILLE_NOM + 1] = ""; - char aMeshName[MED_TAILLE_NOM+1] = ""; - strcpy(aMeshName,theValForTime.myMeshName.c_str()); - med_type_champ type_field; - if(MEDchampInfo(fid,theField.myId,aFieldName,&type_field,&comp[0],&unit[0],ncomp) < 0) - throw std::runtime_error(EXCEPTION("LoadField >> MEDchampInfo(...)")); - int iGeomElemEnd; - med_geometrie_element* aGeomElemVector; - const VISU::TEntity& anEntity = theField.myEntity; - GetEntity2Geom(anEntity,aGeomElemVector,&iGeomElemEnd); - med_entite_maillage& aMedEntity = aVisu2MedEntity[anEntity]; - const VISU::TMeshOnEntity::TCellsConn& aCellsConn = theMeshOnEntity.myCellsConn; - if(MYDEBUG){ - MESSAGE("LoadField - aMeshName = '"<myMeshName; + const PMeshInfo& aMeshInfo = theMesh->myMeshInfo; + PFieldInfo aFieldInfo = theMed->GetPFieldInfo(aMeshInfo,theField->myId); + + MED::TGeom aTGeom; + EEntiteMaillage aMEntity; + theMed->GetNbTimeStamps(aFieldInfo,theMesh->myEntityInfo,aMEntity,aTGeom); + + PTimeStampInfo aTimeStampInfo = theMed->GetPTimeStampInfo(aFieldInfo, + aMEntity, + aTGeom, + theValForTime->myId); + TInt aNbGauss = aTimeStampInfo->GetNbGauss(); + TInt aNbComp = theField->myNbComp; + + PTimeStampVal aTimeStampVal = theMed->GetPTimeStampVal(aTimeStampInfo); + + INITMSG(MYDEBUG,"LoadField - aMeshName = '"< -} +#include "MED_Common.hxx" + +namespace VISU{ + + struct TMEDMesh: TMeshImpl{ + MED::PMeshInfo myMeshInfo; + MED::TEntityInfo myEntityInfo; + }; + typedef shared_ptr PMEDMesh; + + struct TMEDMeshOnEntity: TMeshOnEntityImpl{ + MED::TGeom myGeom; + }; + typedef shared_ptr PMEDMeshOnEntity; + + struct TMEDFamily: TFamilyImpl{ + }; + typedef shared_ptr PMEDFamily; + + struct TMEDGroup: TGroupImpl{ + }; + typedef shared_ptr PMEDGroup; + + struct TMEDField: TFieldImpl{ + }; + typedef shared_ptr PMEDField; + + struct TMEDValForTime: TValForTimeImpl{ + }; + typedef shared_ptr PMEDValForTime; + +} class VISU_MedConvertor: public VISU_Convertor_impl{ VISU_MedConvertor(); @@ -24,26 +53,32 @@ public: protected: QFileInfo myFileInfo; - virtual int LoadMeshOnEntity(VISU::TMeshOnEntity& theMeshOnEntity, + virtual int LoadMeshOnEntity(VISU::PMeshOnEntityImpl theMeshOnEntity, const std::string& theFamilyName = ""); - virtual int LoadMeshOnGroup(VISU::TMesh& theMesh, + virtual int LoadMeshOnGroup(VISU::PMeshImpl theMesh, const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet); - virtual int LoadFieldOnMesh(VISU::TMesh& theMesh, - VISU::TMeshOnEntity& theMeshOnEntity, - VISU::TField& theField, - VISU::TField::TValForTime& theValForTime); - - int LoadPoints(const med_idt& fid, VISU::TMesh& theMesh, + virtual int LoadFieldOnMesh(VISU::PMeshImpl theMesh, + VISU::PMeshOnEntityImpl theMeshOnEntity, + VISU::PFieldImpl theField, + VISU::PValForTimeImpl theValForTime); + + int LoadPoints(const MED::PWrapper& theMed, + VISU::PMEDMesh theMesh, const std::string& theFamilyName = ""); - int LoadCellsOnEntity(const med_idt& fid, VISU::TMeshOnEntity& theMeshOnEntity, + int LoadCellsOnEntity(const MED::PWrapper& theMed, + VISU::PMEDMesh theMesh, + VISU::PMEDMeshOnEntity theMeshOnEntity, const std::string& theFamilyName = ""); - - int LoadField(const med_idt& fid, const VISU::TMeshOnEntity& theMeshOnEntity, - VISU::TField& theField, VISU::TField::TValForTime& theValForTime); - + + int LoadField(const MED::PWrapper& theMed, + VISU::PMEDMesh theMesh, + VISU::PMEDMeshOnEntity theMeshOnEntity, + VISU::PMEDField theField, + VISU::PMEDValForTime theValForTime); + }; #endif diff --git a/src/OBJECT/VISU_Actor.cxx b/src/OBJECT/VISU_Actor.cxx index 74036d0c..d26af3b9 100644 --- a/src/OBJECT/VISU_Actor.cxx +++ b/src/OBJECT/VISU_Actor.cxx @@ -56,10 +56,8 @@ static int MYVTKDEBUG = 0; #ifdef _DEBUG_ static int MYDEBUG = 1; -static int MYDEBUGWITHFILES = 0; #else static int MYDEBUG = 0; -static int MYDEBUGWITHFILES = 0; #endif //======================================================================= @@ -84,15 +82,6 @@ VISU_Actor::VISU_Actor(){ myIO = NULL; myName = ""; - - vtkProperty* aProperty = GetProperty(); - aProperty->SetAmbient(0.5); - aProperty->SetDiffuse(0.2); - aProperty->SetSpecular(0.2); - aProperty->SetAmbientColor(1, 1, 1); - aProperty->SetDiffuseColor(1, 1, 1); - aProperty->SetSpecularColor(0.5, 0.5, 0.5); - this->SetProperty(aProperty); } VISU_Actor::~VISU_Actor(){ @@ -205,14 +194,6 @@ int VISU_Actor::GetVisibility(){ return SALOME_Actor::GetVisibility(); } -void VISU_Actor::SetProperty(vtkProperty* theProperty){ - SALOME_Actor::SetProperty(theProperty); -} - -vtkProperty* VISU_Actor::GetProperty(){ - return SALOME_Actor::GetProperty(); -} - void VISU_Actor::SetLineWidth(float theLineWidth){ GetProperty()->SetLineWidth(theLineWidth); } diff --git a/src/OBJECT/VISU_Actor.h b/src/OBJECT/VISU_Actor.h index 83b8e75c..4000d318 100644 --- a/src/OBJECT/VISU_Actor.h +++ b/src/OBJECT/VISU_Actor.h @@ -73,7 +73,6 @@ class VTKOCC_EXPORT VISU_Actor : public SALOME_Actor { virtual void SetRepresentation(int theMode); - virtual bool IsShrunkable() { return myIsShrinkable;} virtual bool IsShrunk() { return myIsShrunk;} virtual void SetShrink(); @@ -83,23 +82,15 @@ class VTKOCC_EXPORT VISU_Actor : public SALOME_Actor { virtual void SetShrinkFactor(float theFactor = 0.8); virtual float GetShrinkFactor(); - virtual void SetVisibility(int theMode); virtual int GetVisibility(); - virtual void SetProperty(vtkProperty* theProperty); - virtual vtkProperty* GetProperty(); - virtual void SetLineWidth(float theLineWidth); virtual float GetLineWidth(); - - + virtual int GetNodeObjId(int theVtkID); virtual int GetElemObjId(int theVtkID); - - std::string myFieldName; - protected: VISU_Actor(); diff --git a/src/OBJECT/VISU_ScalarMapAct.cxx b/src/OBJECT/VISU_ScalarMapAct.cxx index 0a138e2c..d50fc26c 100644 --- a/src/OBJECT/VISU_ScalarMapAct.cxx +++ b/src/OBJECT/VISU_ScalarMapAct.cxx @@ -37,8 +37,13 @@ vtkStandardNewMacro(VISU_ScalarMapAct); VISU_ScalarMapAct::VISU_ScalarMapAct(){ myScalarBar = VISU_ScalarBarActor::New(); - GetProperty()->FrontfaceCullingOff(); - GetProperty()->BackfaceCullingOff(); + + vtkProperty* aProperty = GetProperty(); + aProperty->SetAmbient(1.0); + aProperty->SetDiffuse(0.0); + aProperty->SetSpecular(0.0); + + myProperty->DeepCopy(aProperty); } VISU_ScalarMapAct::~VISU_ScalarMapAct(){ diff --git a/src/PIPELINE/Makefile.in b/src/PIPELINE/Makefile.in index ffd9da0f..238425d9 100644 --- a/src/PIPELINE/Makefile.in +++ b/src/PIPELINE/Makefile.in @@ -58,7 +58,9 @@ LIB_SRC = VISU_PipeLine.cxx VISU_PipeLineUtils.cxx \ BIN = VISUPipeLine BIN_SRC = -CPPFLAGS+= $(VTK_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome +CPPFLAGS+= $(VTK_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome \ + -I${KERNEL_ROOT_DIR}/include/salome $(HDF5_INCLUDES) $(BOOST_CPPFLAGS) + LDFLAGS+= $(VTK_LIBS) -lSalomeVTKFilter -lVisuConvertor \ -L${KERNEL_ROOT_DIR}/lib/salome -lSALOMELocalTrace diff --git a/src/PIPELINE/VISUPipeLine.cxx b/src/PIPELINE/VISUPipeLine.cxx index 7f0b646b..6595ae83 100644 --- a/src/PIPELINE/VISUPipeLine.cxx +++ b/src/PIPELINE/VISUPipeLine.cxx @@ -65,8 +65,8 @@ int main(int argc, char** argv){ VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin(); if(aMeshMapIter == aMeshMap.end()) return 0; const string& aMeshName = aMeshMapIter->first; - const VISU::TMesh& aMesh = aMeshMapIter->second; - const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh.myMeshOnEntityMap; + const VISU::PMesh aMesh = aMeshMapIter->second; + const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter; if(isOnlyMesh){ const VISU::TEntity& anEntity = VISU::CELL_ENTITY; @@ -92,15 +92,15 @@ int main(int argc, char** argv){ aMeshOnEntityMapIter = aMeshOnEntityMap.begin(); for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++) { const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first; - const VISU::TMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second; - const VISU::TFieldMap& aFieldMap = aMeshOnEntity.myFieldMap; + const VISU::PMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second; + const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap; VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin(); for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){ - const VISU::TField& aField = aFieldMapIter->second; - if(aField.myNbComp == 1) continue; + const VISU::PField aField = aFieldMapIter->second; + if(aField->myNbComp == 1) continue; const string& aFieldName = aFieldMapIter->first; - const VISU::TField::TValField& aValField = aField.myValField; - VISU::TField::TValField::const_iterator aValFieldIter = aValField.begin(); + const VISU::TValField& aValField = aField->myValField; + VISU::TValField::const_iterator aValFieldIter = aValField.begin(); if(aValFieldIter == aValField.end()) return 0; int aTimeStamp = aValFieldIter->first; vtkUnstructuredGrid* aDataSet = aConvertor->GetTimeStampOnMesh(aMeshName,anEntity,aFieldName,aTimeStamp); diff --git a/src/VISUGUI/Makefile.in b/src/VISUGUI/Makefile.in index cb4b2705..b7a57964 100644 --- a/src/VISUGUI/Makefile.in +++ b/src/VISUGUI/Makefile.in @@ -83,7 +83,7 @@ LIB_CLIENT_IDL = SALOME_Exception.idl \ SALOMEDS.idl \ SALOME_ModuleCatalog.idl \ SALOME_Component.idl \ - SALOMEDS_Attributes.idl \ + SALOMEDS_Attributes.idl \ SALOME_Comm.idl LIB_SERVER_IDL = @@ -91,13 +91,12 @@ LIB_SERVER_IDL = # additionnal information to compil and link file CPPFLAGS += -ftemplate-depth-32 $(QT_INCLUDES) $(VTK_INCLUDES) $(OCC_INCLUDES) \ - $(PYTHON_INCLUDES) $(MED2_INCLUDES) $(HDF5_INCLUDES) $(QWT_INCLUDES) \ - -I${KERNEL_ROOT_DIR}/include/salome -CXXFLAGS += -ftemplate-depth-32 $(OCC_CXXFLAGS) \ - -I${KERNEL_ROOT_DIR}/include/salome + $(PYTHON_INCLUDES) $(HDF5_INCLUDES) $(QWT_INCLUDES) \ + -I${KERNEL_ROOT_DIR}/include/salome $(BOOST_CPPFLAGS) +CXXFLAGS += -ftemplate-depth-32 $(OCC_CXXFLAGS) -I${KERNEL_ROOT_DIR}/include/salome -LDFLAGS += $(MED2_LIBS) $(HDF5_LIBS) $(VTK_LIBS) $(QWT_LIBS) -lSalomeGUI -lSalomeNS \ - -lVisuObject -lVISUEngineImpl -lmed -lVTKViewer -L${KERNEL_ROOT_DIR}/lib/salome +LDFLAGS += $(QWT_LIBS) -lSalomeGUI -lSalomeNS \ + -lVisuObject -lVISUEngineImpl -lVTKViewer -L${KERNEL_ROOT_DIR}/lib/salome @CONCLUDE@ diff --git a/src/VISUGUI/VISU_msg_en.po b/src/VISUGUI/VISU_msg_en.po index 41e5a031..86d82f65 100644 --- a/src/VISUGUI/VISU_msg_en.po +++ b/src/VISUGUI/VISU_msg_en.po @@ -36,7 +36,7 @@ msgid "VISU_BUT_OK" msgstr "OK" msgid "VISU_WARNING" -msgstr "Visu Warning" +msgstr "Post-Pro Warning" msgid "WARNING" msgstr "Warning" diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 12229e66..c9be00a3 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -120,7 +120,6 @@ //VRV: porting on Qt 3.0.5 #include -#include #include CORBA_CLIENT_HEADER(MED_Gen) #include @@ -143,10 +142,8 @@ using namespace std; #ifdef _DEBUG_ static int MYDEBUG = 0; -static int MYDEBUGWITHFILES = 0; #else static int MYDEBUG = 0; -static int MYDEBUGWITHFILES = 0; #endif class CustomItem : public QCustomMenuItem @@ -419,7 +416,6 @@ bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) try{ QString VisuInputDir = getVisuInputDir(); QString VisuOutputDir = getVisuOutputDir(); - vtkRenderer *theRenderer = GetRenderer(); SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument(); //Document OCAF de l'etude active SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); @@ -640,7 +636,6 @@ bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) case 54: { QMenuData* pp; - QMenuItem* item = parent->menuBar()->findItem(theCommandID,&pp); bool check = !pp->isItemChecked(theCommandID); pp->setItemChecked(theCommandID,check); switch(theCommandID){ @@ -2800,7 +2795,6 @@ int GetNbChildren( SALOMEDS::SObject_var SO, bool refToo ) bool VisuGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* thePopup, const QString & theContext, const QString & theParent, const QString & theObject) { - int isViewer = (theParent.compare("ObjectBrowser") != 0), initId = isViewer? 800: 900; QAD_ResourceMgr* rmgr = parent->createResourceManager(); bool aIsLocked = isStudyLocked( GetActiveStudy()->getStudyDocument() ); @@ -3845,26 +3839,24 @@ void VisuGUI::ImportFromFile(TImportFun theImportFun){ Utils_Timer timer; timer.Start(); #endif - if(aFileInfo.extension(false) == "med"){ - QString IsBuild = QAD_CONFIG->getSetting("Visu:BuildResult"); - bool isBuild = (IsBuild.isEmpty()? 0 : IsBuild.toInt()); - if (VisuGUI_FileDlg::IsBuild){ - aResult = GetVisuGen()->ImportFile(aFileInfo.filePath()); - if(!CORBA::is_nil(aResult.in())) - if(VISU::Result_i* pResult = dynamic_cast(GetServant(aResult).in())){ - if(!pResult->IsPossible()) - QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), - tr ("ERR_CANT_BUILD_PRESENTATION"), - tr ("VISU_BUT_OK") ); - else - aResult->BuildAll(); - } - }else{ - QAD_CONFIG->addSetting( "Visu:BuildResult", false ); - //aResult=(GetVisuGen()->*theImportFun)(aFileInfo.filePath()); APO: 18/12/03 - fix crash on Linux RedHat 7.1 - aResult=GetVisuGen()->ImportFile(aFileInfo.filePath()); // APO: 18/12/03 - fix crash on Linux RedHat 7.1 - QAD_CONFIG->addSetting( "Visu:BuildResult", isBuild ); - } + QString IsBuild = QAD_CONFIG->getSetting("Visu:BuildResult"); + bool isBuild = (IsBuild.isEmpty()? 0 : IsBuild.toInt()); + if (VisuGUI_FileDlg::IsBuild){ + aResult = GetVisuGen()->ImportFile(aFileInfo.filePath()); + if(!CORBA::is_nil(aResult.in())) + if(VISU::Result_i* pResult = dynamic_cast(GetServant(aResult).in())){ + if(!pResult->IsPossible()) + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), + tr ("ERR_CANT_BUILD_PRESENTATION"), + tr ("VISU_BUT_OK") ); + else + aResult->BuildAll(); + } + }else{ + QAD_CONFIG->addSetting( "Visu:BuildResult", false ); + //aResult=(GetVisuGen()->*theImportFun)(aFileInfo.filePath()); APO: 18/12/03 - fix crash on Linux RedHat 7.1 + aResult=GetVisuGen()->ImportFile(aFileInfo.filePath()); // APO: 18/12/03 - fix crash on Linux RedHat 7.1 + QAD_CONFIG->addSetting( "Visu:BuildResult", isBuild ); } #ifdef CHECKTIME timer.Stop(); @@ -3901,7 +3893,7 @@ void VisuGUI::ExportToFile(){ QAD_Application::getDesktop()->putInfo( "Exporting To File " + aFile + "..." ); aDir = QAD_Tools::getDirFromPath(aFile); QAD_CONFIG->addSetting("Visu:OutputDir",aDir); - if(VISU::Result_i* aResult = dynamic_cast(aBase)){ + if(dynamic_cast(aBase)){ try{ //APO - aResult->GetInput()->ToFile(aFile.latin1()); QAD_Application::getDesktop()->putInfo(aFile+" exported."); @@ -3972,8 +3964,9 @@ VISU_Actor* VisuGUI::UpdateViewer(VISU::Prs3d_i* thePrs, bool theDispOnly){ vtkActor *anActor; VISU_Actor* anVISUActor = NULL; VISU_Actor* aResActor = NULL; - VISU::Prs3d_i* aSrcAddr = thePrs; for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ){ + if(!SALOME_Actor::SafeDownCast(anActor)) + continue; if(anActor->IsA("VISU_Actor")){ anVISUActor = VISU_Actor::SafeDownCast(anActor); VISU::Prs3d_i* aPrs = anVISUActor->GetPrs3d(); diff --git a/src/VISU_I/Makefile.in b/src/VISU_I/Makefile.in index 057a12f3..1489eb26 100644 --- a/src/VISU_I/Makefile.in +++ b/src/VISU_I/Makefile.in @@ -30,8 +30,7 @@ LIB_MOC = VISU_TimeAnimation.h LIB_SERVER_IDL = VISU_Gen.idl SALOME_Component.idl \ SALOME_Exception.idl SALOME_GenericObj.idl MED.idl -LIB_CLIENT_IDL = SALOMEDS.idl SALOMEDS_Attributes.idl \ - SALOME_Comm.idl +LIB_CLIENT_IDL = SALOMEDS.idl SALOMEDS_Attributes.idl SALOME_Comm.idl # Executables targets BIN = @@ -50,7 +49,7 @@ EXPORT_HEADERS = VISUConfig.hh VISU_Gen_i.hh VISU_Result_i.hh \ # additionnal information to compil and link file CPPFLAGS += -ftemplate-depth-32 $(QT_INCLUDES) $(PYTHON_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) \ - $(MED2_INCLUDES) $(HDF5_INCLUDES) $(QWT_INCLUDES) \ + $(HDF5_INCLUDES) $(QWT_INCLUDES) $(BOOST_CPPFLAGS)\ -I${KERNEL_ROOT_DIR}/include/salome LDFLAGS += $(PYTHON_LIBS) $(QT_MT_LIBS) $(VTK_LIBS) $(QWT_LIBS) -lSalomeNS -lTOOLSDS \ @@ -58,8 +57,7 @@ LDFLAGS += $(PYTHON_LIBS) $(QT_MT_LIBS) $(VTK_LIBS) $(QWT_LIBS) -lSalomeNS -lTO -lVisuConvertor -lVisuPipeLine -lVisuObject -lSalomeGenericObj \ -L${KERNEL_ROOT_DIR}/lib/salome -LIBS+= $(MED2_LIBS) $(HDF5_LIBS) -lPlot2d \ - -L${KERNEL_ROOT_DIR}/lib/salome +LIBS+= -lPlot2d -L${KERNEL_ROOT_DIR}/lib/salome # additional file to be cleaned MOSTLYCLEAN = diff --git a/src/VISU_I/VISU_CorbaMedConvertor.cxx b/src/VISU_I/VISU_CorbaMedConvertor.cxx index 2c1d3a0f..464abb14 100644 --- a/src/VISU_I/VISU_CorbaMedConvertor.cxx +++ b/src/VISU_I/VISU_CorbaMedConvertor.cxx @@ -28,22 +28,21 @@ // Copyright (C) 2003 CEA/DEN, EDF R&D #include "VISU_CorbaMedConvertor.hxx" -#include "VISU_ConvertorUtils.hxx" -#include #include -using namespace VISU; +#include + using namespace std; +using namespace VISU; #define USER_INTERLACE MED_FULL_INTERLACE #ifdef _DEBUG_ -static int MYDEBUG = 0; +static int MYDEBUG = 1; #else static int MYDEBUG = 0; #endif -static med_err ret = 0; extern "C" { VISU_Convertor* CreateMEDConvertor(SALOMEDS::SObject_ptr theMedSObject) { @@ -54,259 +53,327 @@ extern "C" { } } -typedef map TVisu2MedEntity; -static TVisu2MedEntity aVisu2MedEntity; -typedef map TMed2VisuEntity; -static TMed2VisuEntity aMed2VisuEntity; -static int INIT = ( - aVisu2MedEntity[VISU::CELL_ENTITY] = SALOME_MED::MED_CELL, - aVisu2MedEntity[VISU::FACE_ENTITY] = SALOME_MED::MED_FACE, - aVisu2MedEntity[VISU::EDGE_ENTITY] = SALOME_MED::MED_EDGE, - aVisu2MedEntity[VISU::NODE_ENTITY] = SALOME_MED::MED_NODE, - - aMed2VisuEntity[SALOME_MED::MED_CELL] = VISU::CELL_ENTITY, - aMed2VisuEntity[SALOME_MED::MED_FACE] = VISU::FACE_ENTITY, - aMed2VisuEntity[SALOME_MED::MED_EDGE] = VISU::EDGE_ENTITY, - aMed2VisuEntity[SALOME_MED::MED_NODE] = VISU::NODE_ENTITY, - - 1); - -static int CELLGEOM[MED_NBR_GEOMETRIE_MAILLE] = { - SALOME_MED::MED_POINT1, - SALOME_MED::MED_SEG2, - SALOME_MED::MED_SEG3, - SALOME_MED::MED_TRIA3, - SALOME_MED::MED_QUAD4, - SALOME_MED::MED_TRIA6, - SALOME_MED::MED_QUAD8, - SALOME_MED::MED_TETRA4, - SALOME_MED::MED_PYRA5, - SALOME_MED::MED_PENTA6, - SALOME_MED::MED_HEXA8, - SALOME_MED::MED_TETRA10, - SALOME_MED::MED_PYRA13, - SALOME_MED::MED_PENTA15, - SALOME_MED::MED_HEXA20 -}; - -static const int VTKCELLGEOMEND = 8; -static int VTKCELLGEOM[VTKCELLGEOMEND] = { - SALOME_MED::MED_POINT1, - SALOME_MED::MED_SEG2, - SALOME_MED::MED_TRIA3, - SALOME_MED::MED_QUAD4, - SALOME_MED::MED_TETRA4, - SALOME_MED::MED_PYRA5, - SALOME_MED::MED_PENTA6, - SALOME_MED::MED_HEXA8 -}; - -static int FACEGEOM[MED_NBR_GEOMETRIE_FACE] = { - SALOME_MED::MED_TRIA3, - SALOME_MED::MED_QUAD4, - SALOME_MED::MED_TRIA6, - SALOME_MED::MED_QUAD8 -}; - -static int EDGEGEOM[MED_NBR_GEOMETRIE_ARETE] = { - SALOME_MED::MED_SEG2, - SALOME_MED::MED_SEG3 -}; - -static int NODEGEOM[1] = { - SALOME_MED::MED_POINT1, -}; - -void GetEntity2Geom(const VISU::TEntity& theEntity, int*& theVector, int* theEnd) -{ - switch(theEntity){ - case VISU::CELL_ENTITY: theVector = CELLGEOM; *theEnd = MED_NBR_GEOMETRIE_MAILLE; break; - case VISU::FACE_ENTITY: theVector = FACEGEOM; *theEnd = MED_NBR_GEOMETRIE_FACE; break; - case VISU::EDGE_ENTITY: theVector = EDGEGEOM; *theEnd = MED_NBR_GEOMETRIE_ARETE; break; - case VISU::NODE_ENTITY: theVector = NODEGEOM; *theEnd = 1; break; - default: - throw std::runtime_error("GetEntity2Geom >> theEntity is uncorrect !!!"); +namespace{ + using namespace SALOME_MED; + + const int MED_NBR_GEOMETRIE_MAILLE = 15; + + medGeometryElement + CELLGEOM[MED_NBR_GEOMETRIE_MAILLE] = { + MED_POINT1, + MED_SEG2, + MED_SEG3, + MED_TRIA3, + MED_QUAD4, + MED_TRIA6, + MED_QUAD8, + MED_TETRA4, + MED_PYRA5, + MED_PENTA6, + MED_HEXA8, + MED_TETRA10, + MED_PYRA13, + MED_PENTA15, + MED_HEXA20 + }; + + const int MED_NBR_GEOMETRIE_FACE = 4; + + medGeometryElement + FACEGEOM[MED_NBR_GEOMETRIE_FACE] = { + MED_TRIA3, + MED_QUAD4, + MED_TRIA6, + MED_QUAD8 + }; + + const int MED_NBR_GEOMETRIE_ARETE = 2; + + medGeometryElement + EDGEGEOM[MED_NBR_GEOMETRIE_ARETE] = { + MED_SEG2, + MED_SEG3 + }; + + const int MED_NBR_GEOMETRIE_NODE = 1; + + medGeometryElement + NODEGEOM[MED_NBR_GEOMETRIE_NODE] = { + MED_POINT1, + }; + + int GetEntity2Geom(const VISU::TEntity& theEntity, medGeometryElement*& theVector) + { + switch(theEntity){ + case CELL_ENTITY: theVector = CELLGEOM; return MED_NBR_GEOMETRIE_MAILLE; break; + case FACE_ENTITY: theVector = FACEGEOM; return MED_NBR_GEOMETRIE_FACE; break; + case EDGE_ENTITY: theVector = EDGEGEOM; return MED_NBR_GEOMETRIE_ARETE; break; + case NODE_ENTITY: theVector = NODEGEOM; return MED_NBR_GEOMETRIE_NODE; break; + } + return -1; } -} - -struct SalomeMed2vtk { - SALOME_MED::medGeometryElement medType; - char *medName; - int medNbNodes; - int vtkType; - char *vtkName; - int vtkNbNodes; -}; - -#define CORBAMED2VTK(MEDTYPE,VTKTYPE,VTKNBNODES) \ - {SALOME_MED::MEDTYPE,#MEDTYPE,getNbMedNodes(MEDTYPE),VTKTYPE,#VTKTYPE,VTKNBNODES} -static SalomeMed2vtk salome_med2vtk[SALOME_MED::MED_ALL_ELEMENTS] = { - {SALOME_MED::MED_NONE,"MED_NONE",0,VTK_EMPTY_CELL,"VTK_EMPTY_CELL",0}, - CORBAMED2VTK(MED_POINT1,VTK_VERTEX,1), - CORBAMED2VTK(MED_SEG2,VTK_LINE,2), - CORBAMED2VTK(MED_SEG3,VTK_LINE,2), - CORBAMED2VTK(MED_TRIA3,VTK_TRIANGLE,3), - CORBAMED2VTK(MED_QUAD4,VTK_QUAD,4), - CORBAMED2VTK(MED_TRIA6,VTK_TRIANGLE,3), - CORBAMED2VTK(MED_QUAD8,VTK_QUAD,4), - CORBAMED2VTK(MED_TETRA4,VTK_TETRA,4), - CORBAMED2VTK(MED_PYRA5,VTK_PYRAMID,5), - CORBAMED2VTK(MED_PENTA6,VTK_WEDGE,6), - CORBAMED2VTK(MED_HEXA8,VTK_HEXAHEDRON,8), - CORBAMED2VTK(MED_TETRA10,VTK_TETRA,4), - CORBAMED2VTK(MED_PYRA13,VTK_PYRAMID,5), - CORBAMED2VTK(MED_PENTA15,VTK_WEDGE,6), - CORBAMED2VTK(MED_HEXA20,VTK_HEXAHEDRON,8) -}; -#undef CORBAMED2VTK - -int GetIdMEDType(int medType){ - for(int i = 0; i < SALOME_MED::MED_ALL_ELEMENTS; i++) - if(salome_med2vtk[i].medType == medType) return i; - return -1; -} - -string GetName(SALOMEDS::SObject_ptr aSObject){ - SALOMEDS::GenericAttribute_var anAttr; - if (aSObject->FindAttribute(anAttr,"AttributeName")) { - SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr); - CORBA::String_var aString = aName->Value(); - return aString.in(); + + int MEDGeom2NbNodes(int theMEDGeomType) + { + switch(theMEDGeomType){ + case MED_NONE: return 0; + case MED_POINT1: return 1; + case MED_SEG2: return 2; + case MED_SEG3: return 3; + case MED_TRIA3: return 3; + case MED_TRIA6: return 6; + case MED_QUAD4: return 4; + case MED_QUAD8: return 8; + case MED_TETRA4: return 4; + case MED_TETRA10: return 10; + case MED_HEXA8: return 8; + case MED_HEXA20: return 20; + case MED_PENTA6: return 6; + case MED_PENTA15: return 15; + case MED_PYRA5: return 5; + case MED_PYRA13: return 13; + } + return -1; } - return ""; -} - - -static void GetCellsSize(vtkIdType& theNbCells, vtkIdType& theCellsSize, - SALOME_MED::MESH_ptr theMEDMesh, - const VISU::TEntity& theEntity) -{ - int iGeomElemEnd; - int* aGeomElemVector; - GetEntity2Geom(theEntity,aGeomElemVector,&iGeomElemEnd); - theNbCells = theCellsSize = 0; - const SALOME_MED::medEntityMesh& aMedEntity = aVisu2MedEntity[theEntity]; - if(MYDEBUG) MESSAGE("GetCellsSize - theEntity = "<getNumberOfElements(aMedEntity,aMedType); - if(iNumElemEnd > 0){ - if(MYDEBUG) MESSAGE("GetCellsSize - iNumElemEnd = "<getTypes(); - med_int iGeomElemEnd = aGeom->length(); - theNbCells = theCellsSize = 0; - if(MYDEBUG) MESSAGE("GetCellsSize - iGeomElemEnd = "<getNumber(aGeomType); - int medId = GetIdMEDType(aGeomType); - med_int iNumElemEnd = aCellNumForType->length(); - if(iNumElemEnd > 0){ - if(MYDEBUG) MESSAGE("GetCellsSize - iNumElemEnd = "<getNumberOfNodes(); - aMeshOnEntity.myNbCells = theMesh.myNbPoints; - aMeshOnEntity.myCellsSize = 2*theMesh.myNbPoints; - vtkIdType aNbCells, aCellsSize; - GetCellsSize(aNbCells,aCellsSize,theMEDMesh,VISU::CELL_ENTITY); - if(aNbCells > 0){ - VISU::TMeshOnEntity& aMeshOnCells = theMesh.myMeshOnEntityMap[VISU::CELL_ENTITY]; - aMeshOnCells.myEntity = VISU::CELL_ENTITY; - aMeshOnCells.myMeshName = theMesh.myName; - aMeshOnCells.myNbCells = aNbCells; - aMeshOnCells.myCellsSize = aCellsSize; + + medGeometryElement VTKGeomToMED(int theVTKGeomType) + { + switch(theVTKGeomType){ + case VTK_VERTEX: return MED_POINT1; + case VTK_LINE: return MED_SEG2; + case VTK_TRIANGLE: return MED_TRIA3; + case VTK_QUAD: return MED_QUAD4; + case VTK_TETRA: return MED_TETRA4; + case VTK_HEXAHEDRON: return MED_HEXA8; + case VTK_WEDGE: return MED_PENTA6; + case VTK_PYRAMID: return MED_PYRA5; + } + return medGeometryElement(-1); + } + + VISU::TEntity MEDEntityToVTK(medEntityMesh theMEDEntity) + { + switch(theMEDEntity){ + case MED_NODE: return NODE_ENTITY; + case MED_EDGE: return EDGE_ENTITY; + case MED_FACE: return FACE_ENTITY; + case MED_CELL: return CELL_ENTITY; + } + return VISU::TEntity(-1); + } + + medEntityMesh VTKEntityToMED(VISU::TEntity theVTKEntity) + { + switch(theVTKEntity){ + case NODE_ENTITY: return MED_NODE; + case EDGE_ENTITY: return MED_EDGE; + case FACE_ENTITY: return MED_FACE; + case CELL_ENTITY: return MED_CELL; + } + return medEntityMesh(-1); + } + + string GetSObjectName(SALOMEDS::SObject_ptr aSObject){ + SALOMEDS::GenericAttribute_var anAttr; + if (aSObject->FindAttribute(anAttr,"AttributeName")) { + SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr); + CORBA::String_var aString = aName->Value(); + return aString.in(); } - }else - GetCellsSize(aMeshOnEntity.myNbCells,aMeshOnEntity.myCellsSize,theMEDMesh,theEntity); + return ""; + } + + void + GetCellsSize(vtkIdType& theNbCells, vtkIdType& theCellsSize, + SALOME_MED::MESH_ptr theMEDMesh, + const VISU::TEntity& theVEntity) + { + medGeometryElement* aGeomElems; + theNbCells = theCellsSize = 0; + int iGeomEnd = GetEntity2Geom(theVEntity,aGeomElems); + const medEntityMesh& aMEntity = VTKEntityToMED(theVEntity); + if(MYDEBUG) MESSAGE("GetCellsSize - theVEntity = "<getNumberOfElements(aMEntity,aMEDGeom); + if(iNumElemEnd > 0){ + if(MYDEBUG) MESSAGE("GetCellsSize - iNumElemEnd = "<getTypes(); + int iGeomEnd = aGeom->length(); + theNbCells = theCellsSize = 0; + if(MYDEBUG) MESSAGE("GetCellsSize - iGeomEnd = "<getNumber(aMEDGeom); + int iNumElemEnd = aCellNumForType->length(); + if(iNumElemEnd > 0){ + if(MYDEBUG) MESSAGE("GetCellsSize - iNumElemEnd = "<myMeshOnEntityMap; + VISU::PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMap[theEntity]; + if(theEntity == NODE_ENTITY){ + theMesh->myNbPoints = theMEDMesh->getNumberOfNodes(); + aMeshOnEntity->myNbCells = theMesh->myNbPoints; + aMeshOnEntity->myCellsSize = 2*theMesh->myNbPoints; + vtkIdType aNbCells, aCellsSize; + GetCellsSize(aNbCells,aCellsSize,theMEDMesh,CELL_ENTITY); + if(aNbCells > 0){ + PCMeshOnEntity aMeshOnCells = aMeshOnEntityMap[CELL_ENTITY]; + aMeshOnCells->myEntity = VISU::CELL_ENTITY; + aMeshOnCells->myMeshName = theMesh->myName; + aMeshOnCells->myNbCells = aNbCells; + aMeshOnCells->myCellsSize = aCellsSize; + } + }else + GetCellsSize(aMeshOnEntity->myNbCells,aMeshOnEntity->myCellsSize,theMEDMesh,theEntity); + } + } -VISU_Convertor* VISU_MEDFieldConvertor::Build() { +VISU_Convertor* +VISU_MEDFieldConvertor::Build() +{ if(myField->_is_nil()) throw std::runtime_error("VISU_MEDFieldConvertor::Build >> myField->_is_nil() !!!"); SALOME_MED::SUPPORT_var aMEDSupport = myField->getSupport(); if(aMEDSupport->_is_nil()) throw std::runtime_error("VISU_MEDFieldConvertor::Build >> aMEDSupport->_is_nil() !!!"); - SALOME_MED::medEntityMesh aMEDEntity = aMEDSupport->getEntity(); - VISU::TEntity anEntity = aMed2VisuEntity[aMEDEntity]; + + SALOME_MED::medEntityMesh aMEntity = aMEDSupport->getEntity(); + TEntity aVEntity = MEDEntityToVTK(aMEntity); SALOME_MED::MESH_var aMEDMesh = aMEDSupport->getMesh(); if(aMEDMesh->_is_nil()) throw std::runtime_error("VISU_MEDFieldConvertor::Build >> aMEDMesh->_is_nil() !!!"); + CORBA::String_var aMeshName = aMEDMesh->getName(); CORBA::String_var aFieldName = myField->getName(); - VISU::TMesh &aMesh = myMeshMap[aMeshName.in()]; - aMesh.myDim = aMEDMesh->getSpaceDimension(); - aMesh.myPointsDim.resize(aMesh.myDim); - aMesh.myName = aMeshName.in(); - VISUMED::TMesh &aMesh2 = myMeshMap2[aMeshName.in()]; - aMesh2.myMesh = aMEDMesh; - if(MYDEBUG) MESSAGE("VISU_MEDFieldConvertor::Build - aMeshName = "<myDim = aMEDMesh->getSpaceDimension(); + aMesh->myPointsDim.resize(aMesh->myDim); + aMesh->myName = aMeshName.in(); + aMesh->myMesh = aMEDMesh; + + if(MYDEBUG) MESSAGE("VISU_MEDFieldConvertor::Build - aMeshName = "<myField = myField; + if(MYDEBUG) - MESSAGE("VISU_MEDFieldConvertor::Build - aFieldName = '"<> mySObject->_is_nil() !!!"); SALOMEDS::Study_var aStudy = mySObject->GetStudy(); - CORBA::Object_var aMedObject = SObjectToObject(mySObject); + CORBA::Object_var aMedObject = VISU::SObjectToObject(mySObject); if(!CORBA::is_nil(aMedObject)){ SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow(aMedObject); return Build(aMED); @@ -316,194 +383,322 @@ VISU_Convertor* VISU_MEDConvertor::Build() { return Build(aTimeStampIterator); } +namespace{ + + using namespace boost; + + struct TSObjectByName{ + std::string myName; + typedef tuple TRet; + + TSObjectByName(const std::string& theName): + myName(theName) + {} + + TRet operator()(SALOMEDS::SObject_ptr theSObj, bool& theIsSuccess) + { + SALOMEDS::GenericAttribute_var anAttr; + if(theSObj->FindAttribute(anAttr,"AttributeName")){ + SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr); + CORBA::String_var aValue = aName->Value(); + theIsSuccess = (myName == aValue.in()); + if(theIsSuccess) + return TRet(SALOMEDS::SObject::_duplicate(theSObj)); + } + return TRet(); + } -VISU_Convertor* VISU_MEDConvertor::Build(SALOME_MED::MED_ptr theMED) + }; + + struct TMeshByName{ + std::string myName; + typedef tuple TRet; + + TMeshByName(const std::string& theName): + myName(theName) + {} + + TRet operator()(SALOMEDS::SObject_ptr theSObj, bool& theIsSuccess) + { + CORBA::Object_var anObj = VISU::SObjectToObject(theSObj); + if(!CORBA::is_nil(anObj)){ + SALOME_MED::MESH_var aMesh = SALOME_MED::MESH::_narrow(anObj); + if(!CORBA::is_nil(aMesh)){ + CORBA::String_var aName = aMesh->getName(); + theIsSuccess = (myName == aName.in()); + if(theIsSuccess) + return TRet(aMesh,SALOMEDS::SObject::_duplicate(theSObj)); + } + } + return TRet(); + } + }; + + template + typename TFun::TRet + Find(SALOMEDS::SObject_ptr theStartSObj, + SALOMEDS::Study_ptr theStudy, + TFun theFun, + bool& theIsSuccess, + bool theIsAllLevels = true) + { + SALOMEDS::ChildIterator_var anIter = theStudy->NewChildIterator(theStartSObj); + anIter->InitEx(theIsAllLevels); + for(; anIter->More(); anIter->Next()){ + SALOMEDS::SObject_var aSObj = anIter->Value(); + typename TFun::TRet aRet = theFun(aSObj,theIsSuccess); + if(theIsSuccess) + return aRet; + } + return typename TFun::TRet(); + } + +} + +VISU_Convertor* +VISU_MEDConvertor::Build(SALOME_MED::MED_ptr theMED) { - if(theMED->_is_nil()) return NULL; - CORBA::Short aTag = mySObject->Tag(); - SALOMEDS::SObject_var aMedCompSObj = mySObject->GetFather(); - SALOMEDS::SObject_var aMeshSObj; - if(!aMedCompSObj->FindSubObject(aTag+1,aMeshSObj)) - throw std::runtime_error("VISU_MEDConvertor::Build >> Cann't find MEDMESH label !!!"); - if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - MEDMESH found."); + if(CORBA::is_nil(theMED)) + return NULL; + + CORBA::Long aNbMeshes = theMED->getNumberOfMeshes(); + SALOME_MED::string_array_var aMeshNames = theMED->getMeshNames(); + if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aNbMeshes = "<GetStudy(); - SALOMEDS::ChildIterator_var aMeshIterator = aStudy->NewChildIterator(aMeshSObj); - for(; aMeshIterator->More(); aMeshIterator->Next()){ - aMeshSObj = aMeshIterator->Value(); - if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aMeshSObj = '"<<::GetName(aMeshSObj)<<"'"); - CORBA::Object_var aMedMesh = SObjectToObject(aMeshSObj); - if(CORBA::is_nil(aMedMesh)) continue; - SALOME_MED::MESH_var aMEDMesh = SALOME_MED::MESH::_narrow(aMedMesh); - if(aMEDMesh->_is_nil()) continue; - CORBA::String_var aMeshName = aMEDMesh->getName(); - VISU::TMesh &aMesh = myMeshMap[aMeshName.in()]; - aMesh.myDim = aMEDMesh->getSpaceDimension(); - aMesh.myName = aMeshName.in(); - aMesh.myPointsDim.resize(aMesh.myDim); - VISUMED::TMesh &aMesh2 = myMeshMap2[aMeshName.in()]; - aMesh2.myMesh = aMEDMesh; - if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aMeshName = "<(aSObjectByNameRet); + for(int iMesh = 0; iMesh < aNbMeshes; iMesh++){ + anIsSuccess = false; + CORBA::String_var aMeshName = aMeshNames[iMesh]; + TMeshByName::TRet aMeshByNameRet = + Find(aMeshesSObj,aStudy,TMeshByName(aMeshName.in()),anIsSuccess); + if(!anIsSuccess) + continue; + + PCMesh aMesh = myMeshMap[aMeshName.in()](new TCMesh()); + SALOME_MED::MESH_var aMEDMesh = boost::get<0>(aMeshByNameRet); + aMesh->myDim = aMEDMesh->getSpaceDimension(); + aMesh->myName = aMeshName.in(); + aMesh->myPointsDim.resize(aMesh->myDim); + aMesh->myMesh = aMEDMesh; + + if(MYDEBUG) + MESSAGE("VISU_MEDConvertor::Build - aMeshName = "<myMeshOnEntityMap; + SALOMEDS::SObject_var aSupportsSObj = boost::get<0>(aSObjectByNameRet); + SALOMEDS::ChildIterator_var aSupportIterator = aStudy->NewChildIterator(aSupportsSObj); + + // Fill all MeshOnEntity + aSupportIterator->InitEx(true); + for(; aSupportIterator->More(); aSupportIterator->Next()){ + SALOMEDS::SObject_var aSupportSObj = aSupportIterator->Value(); + + CORBA::Object_var aMedSupport = VISU::SObjectToObject(aSupportSObj); + if(CORBA::is_nil(aMedSupport)) + continue; + + SALOME_MED::SUPPORT_var aMEDSupport = SALOME_MED::SUPPORT::_narrow(aMedSupport); + if(aMEDSupport->_is_nil()) + continue; + + SALOME_MED::MESH_var aMeshOnSupport = aMEDSupport->getMesh(); + SALOME_MED::medEntityMesh aMEntity = aMEDSupport->getEntity(); + VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity); + CORBA::String_var aSupportName = aMEDSupport->getName(); + + if(aMEDSupport->isOnAllElements()){ + if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - Support isOnAllElements = '"<myGroups; + aBindGroups.insert(aSupportName.in()); + } } } } } - //Correction of TMesh.TGroupMap - const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh.myMeshOnEntityMap; - if(aMeshOnEntityMap.empty()) continue; - VISU::TGroupMap& aGroupMap = aMesh.myGroupMap; - VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.begin(); - for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){ - const VISU::TMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second; - const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity.myFamilyMap; - if(aFamilyMap.empty()) continue; - VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin(); - for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){ - const VISU::TFamily& aFamily = aFamilyMapIter->second; - const VISU::TBindGroups& aBindGroups = aFamily.myGroups; - if(aBindGroups.empty()) continue; - VISU::TBindGroups::const_iterator aBindGroupsIter = aBindGroups.begin(); - for(; aBindGroupsIter != aBindGroups.end(); aBindGroupsIter++){ - const string& aGroupName = *aBindGroupsIter; - VISU::TGroup& aGroup = aGroupMap[aGroupName]; - aGroup.myName = aGroupName; - aGroup.myMeshName = aMesh.myName; - aGroup.myNbCells += aFamily.myNbCells; - aGroup.myCellsSize += aFamily.myCellsSize; - VISU::TFamilyAndEntity aFamilyAndEntity(aFamily.myName,aFamily.myEntity); - aGroup.myFamilyAndEntitySet.insert(aFamilyAndEntity); - } - } - } } - SALOMEDS::SObject_var aFieldSObj; - if(aMedCompSObj->FindSubObject(aTag+2,aFieldSObj)){ + + anIsSuccess = false; + aSObjectByNameRet = Find(aMedCompSObj,aStudy,TSObjectByName("MEDFIELD"),anIsSuccess); + if(anIsSuccess){ + SALOMEDS::SObject_var aFieldsSObj = boost::get<0>(aSObjectByNameRet); if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - MEDFIELD found."); - SALOMEDS::ChildIterator_var aFieldIterator = aStudy->NewChildIterator(aFieldSObj); + SALOMEDS::ChildIterator_var aFieldIterator = aStudy->NewChildIterator(aFieldsSObj); for(int iField = 0; aFieldIterator->More(); aFieldIterator->Next(), iField++){ - aFieldSObj = aFieldIterator->Value(); - if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aFieldName = '"<<::GetName(aFieldSObj)<<"'"); + SALOMEDS::SObject_var aFieldSObj = aFieldIterator->Value(); + if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aFieldName = '"<NewChildIterator(aFieldSObj); - for(int iTimeStamp = 1; aTimeStampIterator->More(); aTimeStampIterator->Next(), iTimeStamp++){ + for(; aTimeStampIterator->More(); aTimeStampIterator->Next()){ SALOMEDS::SObject_var aTimeStampSObj = aTimeStampIterator->Value(); - if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aTimeStampSObj = '"<<::GetName(aTimeStampSObj)<<"'"); - CORBA::Object_var aMedField = SObjectToObject(aTimeStampSObj); - if(CORBA::is_nil(aMedField)) continue; + if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aTimeStampSObj = '"<_is_nil()) continue; + if(aMEDField->_is_nil()) + continue; + SALOME_MED::SUPPORT_var aMEDSupport = aMEDField->getSupport(); - if(aMEDSupport->_is_nil()) continue; - SALOME_MED::medEntityMesh aMEDEntity = aMEDSupport->getEntity(); - VISU::TEntity anEntity = aMed2VisuEntity[aMEDEntity]; + if(aMEDSupport->_is_nil()) + continue; + + SALOME_MED::medEntityMesh aMEntity = aMEDSupport->getEntity(); + VISU::TEntity anEntity = MEDEntityToVTK(aMEntity); SALOME_MED::MESH_var aMEDMesh = aMEDSupport->getMesh(); - if(aMEDMesh->_is_nil()) continue; + if(aMEDMesh->_is_nil()) + continue; + CORBA::String_var aMeshName = aMEDMesh->getName(); CORBA::String_var aFieldName = aMEDField->getName(); - VISU::TMesh &aMesh = myMeshMap[aMeshName.in()]; - aMesh.myDim = aMEDMesh->getSpaceDimension(); - aMesh.myName = aMeshName.in(); - VISUMED::TMesh &aMesh2 = myMeshMap2[aMeshName.in()]; - aMesh2.myMesh = aMEDMesh; - - VISU::TMeshOnEntity& aMeshOnEntity = aMesh.myMeshOnEntityMap[anEntity]; - aMeshOnEntity.myEntity = anEntity; - aMeshOnEntity.myMeshName = aMeshName.in(); - VISUMED::TMeshOnEntity& aMeshOnEntity2 = aMesh2.myMeshOnEntityMap[anEntity]; - aMeshOnEntity2.mySupport = aMEDSupport; - if(anEntity == VISU::NODE_ENTITY) - aMesh2.myMeshOnEntityMap[VISU::CELL_ENTITY].mySupport = aMEDSupport; - GetCellsSize(aMesh,aMEDMesh,anEntity); - - VISU::TField& aField = aMeshOnEntity.myFieldMap[aFieldName.in()]; - aField.myId = iField; - aField.myName = aFieldName.in(); - aField.myEntity = anEntity; - aField.myMeshName = aMeshName.in(); - aField.myNbComp = aMEDField->getNumberOfComponents(); - aField.myNbValField = iTimeStamp; - aField.myDataSize = aMeshOnEntity.myNbCells * aField.myNbComp; - if(MYDEBUG && !iTimeStamp) - MESSAGE("VISU_MEDConvertor::Build - aMeshOnEntity.myNbCells = "<second; + TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; + TMeshOnEntityMap::iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(anEntity); + if(aMeshOnEntityMapIter == aMeshOnEntityMap.end()) + continue; + + PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second; + TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap; + TFieldMap::iterator aFieldMapIter = aFieldMap.find(aFieldName.in()); + PCField aField; + if(aFieldMapIter == aFieldMap.end()){ + aField = aFieldMap[aFieldName.in()](new TCField()); + aField->myId = iField; + aField->myName = aFieldName.in(); + aField->myEntity = anEntity; + aField->myMeshName = aMeshName.in(); + aField->myNbComp = aMEDField->getNumberOfComponents(); + aField->myDataSize = aMeshOnEntity->myNbCells * aField->myNbComp; + if(MYDEBUG) + MESSAGE("VISU_MEDConvertor::Build - aMeshOnEntity->myNbCells = "<myNbCells); + aField->myCompNames.resize(aField->myNbComp); + aField->myUnitNames.resize(aField->myNbComp); + }else + aField = aFieldMapIter->second; + + TValField& aValField = aField->myValField; int anId = aMEDField->getIterationNumber(); - VISU::TField::TValForTime& aValForTime = aField.myValField[anId]; - aValForTime.myId = anId; - aValForTime.myTime = VISU::TField::TTime(aMEDField->getTime(),""); - VISUMED::TField& aField2 = aMeshOnEntity2.myFieldMap[aFieldName.in()]; - VISUMED::TField::TValForTime& aValForTime2 = aField2.myValField[anId]; - aValForTime2.myField = aMEDField; + PCValForTime aValForTime = aValField[anId](new TCValForTime()); + aValForTime->myId = anId; + CORBA::Double aDT = aMEDField->getTime(); + aValForTime->myTime = TTime(aDT,""); + aValForTime->myField = aMEDField; if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aMeshName = '"<_is_nil()) continue; + if(aMEDField->_is_nil()) + continue; + SALOME_MED::SUPPORT_var aMEDSupport = aMEDField->getSupport(); - if(aMEDSupport->_is_nil()) continue; - SALOME_MED::medEntityMesh aMEDEntity = aMEDSupport->getEntity(); - VISU::TEntity anEntity = aMed2VisuEntity[aMEDEntity]; + if(aMEDSupport->_is_nil()) + continue; + + SALOME_MED::medEntityMesh aMEntity = aMEDSupport->getEntity(); + TEntity aVEntity = MEDEntityToVTK(aMEntity); SALOME_MED::MESH_var aMEDMesh = aMEDSupport->getMesh(); if(aMEDMesh->_is_nil()) continue; CORBA::String_var aMeshName = aMEDMesh->getName(); CORBA::String_var aFieldName = aMEDField->getName(); - VISU::TMesh &aMesh = myMeshMap[aMeshName.in()]; - aMesh.myDim = aMEDMesh->getSpaceDimension(); - aMesh.myPointsDim.resize(aMesh.myDim); - aMesh.myName = aMeshName.in(); - aMesh.myNbPoints = aMEDMesh->getNumberOfNodes(); - VISUMED::TMesh &aMesh2 = myMeshMap2[aMeshName.in()]; - aMesh2.myMesh = aMEDMesh; - if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aMeshName = "<myNbCells = "<myNbCells); + aField->myCompNames.resize(aField->myNbComp); + aField->myUnitNames.resize(aField->myNbComp); + } + + TValField& aValField = aField->myValField; int anId = aMEDField->getIterationNumber(); - VISU::TField::TValForTime& aValForTime = aField.myValField[anId]; - aValForTime.myId = anId; - aValForTime.myTime = VISU::TField::TTime(aMEDField->getTime(),""); - VISUMED::TField& aField2 = aMeshOnEntity2.myFieldMap[aFieldName.in()]; - VISUMED::TField::TValForTime& aValForTime2 = aField2.myValField[anId]; - aValForTime2.myField = aMEDField; + PCValForTime aValForTime = aValField[anId](new TCValForTime()); + aValForTime->myId = anId; + CORBA::Double aDT = aMEDField->getTime(); + aValForTime->myTime = TTime(aDT,""); + aValForTime->myField = aMEDField; if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aMeshName = '"<getSpaceDimension(); + + SALOME_MED::MESH_var& aMedMesh = theMesh->myMesh; int iNumElemEnd = aMedMesh->getNumberOfNodes(); - VISU::TMesh::TPointsCoord& aPointsCoord = theMesh.myPointsCoord; + TMeshImpl::TPointsCoord& aPointsCoord = theMesh->myPointsCoord; if(MYDEBUG) MESSAGE("LoadPoints - iNumElemEnd = "<> There is no points in the mesh !!!"); - aPointsCoord.resize(theMesh.myDim*iNumElemEnd,0.0); - SALOME_MED::double_array_var coord = aMedMesh->getCoordinates(SALOME_MED::MED_FULL_INTERLACE); + aPointsCoord.resize(theMesh->myDim*iNumElemEnd,0.0); + SALOME_MED::double_array_var coord = aMedMesh->getCoordinates(SALOME_MED::MED_FULL_INTERLACE); if(!isPointsLoaded){ for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) - for(int iDim = 0, iNumElem2Dim = iNumElem*theMesh.myDim; iDim < theMesh.myDim; iDim++, iNumElem2Dim++) + for(int iDim = 0, iNumElem2Dim = iNumElem*theMesh->myDim; iDim < theMesh->myDim; iDim++, iNumElem2Dim++) aPointsCoord[iNumElem2Dim] = coord[iNumElem2Dim]; if(MYDEBUG) MESSAGE("LoadPoints - Filling aMeshOnEntity with type NODE_ENTITY"); - VISU::TMeshOnEntity::TConnForCellType& aConnForCellType = aMeshOnEntity.myCellsConn[VTK_VERTEX]; + TMeshOnEntityImpl::TConnForCellType& aConnForCellType = aMeshOnEntity->myCellsConn[VTK_VERTEX]; aConnForCellType.resize(iNumElemEnd); for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) - aConnForCellType[iNumElem] = VISU::TMeshOnEntity::TConnect(1,iNumElem); + aConnForCellType[iNumElem] = TMeshOnEntityImpl::TConnect(1,iNumElem); } - if(isFamilyPresent){ + if(aFamily){ if(MYDEBUG) MESSAGE("LoadPoints - Filling aFamily SubMesh"); - VISUMED::TFamily aFamily2 = aMeshOnEntity2.myFamilyMap[aFamily.myName]; - SALOME_MED::FAMILY_var aMedFamily = aFamily2.myFamily; - VISU::TFamily::TSubMeshOnCellType& aSubMeshOnCellType = aFamily.mySubMesh[VTK_VERTEX]; + SALOME_MED::FAMILY_var aMedFamily = aFamily->myFamily; + TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aFamily->mySubMesh[VTK_VERTEX]; SALOME_MED::medGeometryElement_array_var aGeom = aMedFamily->getTypes(); SALOME_MED::long_array_var aCellNumForType = aMedFamily->getNumber(aGeom[0]); int iNumElemEndTmp = iNumElemEnd; @@ -688,58 +907,58 @@ int VISU_MEDConvertor::LoadPoints(VISU::TMesh& theMesh, const string& theFamilyN return 1; } -int VISU_MEDConvertor::LoadCellsOnEntity(VISU::TMeshOnEntity& theMeshOnEntity, const string& theFamilyName) + +int +VISU_MEDConvertor::LoadCellsOnEntity(VISU::PCMesh theMesh, + VISU::PCMeshOnEntity theMeshOnEntity, + const string& theFamilyName) { //Check on existing family - VISU::TFamily* pFamily = VISU::GetFamily(theMeshOnEntity,theFamilyName); - bool isFamilyPresent = (pFamily != NULL); - VISU::TFamily& aFamily = *pFamily; + PCFamily aFamily = GetFamily(theMeshOnEntity,theFamilyName); //Check on loading already done - bool isCellsLoaded = !theMeshOnEntity.myCellsConn.empty(); + bool isCellsLoaded = !theMeshOnEntity->myCellsConn.empty(); if(isCellsLoaded) - if(!isFamilyPresent) return 0; - else if(!aFamily.mySubMesh.empty()) return 0; - VISUMED::TMesh& aMesh2 = myMeshMap2[theMeshOnEntity.myMeshName]; - VISUMED::TMeshOnEntity& aMeshOnEntity2 = aMesh2.myMeshOnEntityMap[theMeshOnEntity.myEntity]; - SALOME_MED::SUPPORT_var& aMedSupport = aMeshOnEntity2.mySupport; + if(!aFamily) + return 0; + else if(!aFamily->mySubMesh.empty()) + return 0; + + SALOME_MED::SUPPORT_var& aMedSupport = theMeshOnEntity->mySupport; SALOME_MED::MESH_var aMedMesh = aMedSupport->getMesh(); if(MYDEBUG) { MESSAGE("LoadCellsOnEntity - theFamilyName = '"<> aNbPoints(%d) <= anArray[%d][%d]=%d < 0 !!!",aNbPoints,iNumElem,k,anArray[k]); @@ -769,31 +988,29 @@ int VISU_MEDConvertor::LoadCellsOnEntity(VISU::TMeshOnEntity& theMeshOnEntity, c } //Workaround for MED Component data structure int aSize = aConnForCellType.size(); - aMeshOnEntity2.myCellsFirstIndex[aMedType] = VISUMED::TMeshOnEntity::TIndexAndSize(aCounter,aSize); + theMeshOnEntity->myCellsFirstIndex[aGeom] = TCMeshOnEntity::TIndexAndSize(aCounter,aSize); aCounter += aSize; } } } //Filling aFamily SubMesh - if(isFamilyPresent){ - VISUMED::TFamily aFamily2 = aMeshOnEntity2.myFamilyMap[aFamily.myName]; - SALOME_MED::FAMILY_var aMedFamily = aFamily2.myFamily; - SALOME_MED::medGeometryElement_array_var aGeom = aMedFamily->getTypes(); - iGeomElemEnd = aGeom->length(); - if(MYDEBUG) MESSAGE("LoadCellsOnEntity - iGeomElemEnd = "<getNumber(aGeomType); - int medId = GetIdMEDType(aGeomType); - int aVtkType = salome_med2vtk[medId].vtkType; - SALOME_MED::medGeometryElement aMedType = salome_med2vtk[medId].medType; - VISU::TFamily::TSubMeshOnCellType& aSubMeshOnCellType = aFamily.mySubMesh[aVtkType]; - med_int iNumElemEndTmp = theMeshOnEntity.myCellsConn[aVtkType].size(); - med_int iNumElemEnd = aCellNumForType->length(); - int aCounter = aMeshOnEntity2.myCellsFirstIndex[aMedType].first; + if(aFamily){ + SALOME_MED::FAMILY_var aMedFamily = aFamily->myFamily; + SALOME_MED::medGeometryElement_array_var aGeoms = aMedFamily->getTypes(); + iGeomEnd = aGeoms->length(); + if(MYDEBUG) MESSAGE("LoadCellsOnEntity - iGeomEnd = "<getNumber(aGeom); + int aVGeom = MEDGeomToVTK(aGeom); + TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aFamily->mySubMesh[aVGeom]; + int iNumElemEndTmp = theMeshOnEntity->myCellsConn[aVGeom].size(); + int iNumElemEnd = aCellNumForType->length(); + int aCounter = theMeshOnEntity->myCellsFirstIndex[aGeom].first; if(MYDEBUG) - MESSAGE("LoadCellsOnEntity - medName = "<myValForCells[aVGeom]; + aValForCellsWithType.resize(iNumElemEnd*theField->myNbComp); + for(int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) + for(int k = 0, kj = iNumElem*theField->myNbComp; k < theField->myNbComp; k++) + aValForCellsWithType[kj+k] = theArray[aIndexAndSize.first*theField->myNbComp+kj+k]; } } } return 1; } -int VISU_MEDConvertor::LoadField(const VISU::TMeshOnEntity& theMeshOnEntity, - const VISU::TField& theField, VISU::TField::TValForTime& theValForTime) +int +VISU_MEDConvertor::LoadField(VISU::PCMesh theMesh, + VISU::PCMeshOnEntity theMeshOnEntity, + VISU::PField theField, + VISU::PCValForTime theValForTime) { //Check on loading already done - if(!theValForTime.myValForCells.empty()) return 0; - VISU::TMesh& aMesh = myMeshMap[theMeshOnEntity.myMeshName]; - VISUMED::TMesh& aMesh2 = myMeshMap2[theMeshOnEntity.myMeshName]; - VISUMED::TMeshOnEntity& aMeshOnEntity2 = aMesh2.myMeshOnEntityMap[theMeshOnEntity.myEntity]; - VISUMED::TField& aField2 = aMeshOnEntity2.myFieldMap[theField.myName]; - VISUMED::TField::TValForTime& aValForTime2 = aField2.myValField[theValForTime.myId]; - SALOME_MED::FIELD_var aMEDField = aValForTime2.myField; - //Main part of code + if(!theValForTime->myValForCells.empty()) + return 0; + + SALOME_MED::FIELD_var aMEDField = theValForTime->myField; SALOME_MED::FIELDDOUBLE_ptr aFieldDouble = SALOME_MED::FIELDDOUBLE::_narrow(aMEDField); if(!aFieldDouble->_is_nil()){ SALOME_MED::double_array_var anArray = aFieldDouble->getValue(SALOME_MED::MED_FULL_INTERLACE); if(MYDEBUG) MESSAGE("VISU_MEDConvertor::LoadField - There is FIELDDOUBLE = "<length()); - ::ImportField(anArray,aMesh,theField,theValForTime,theMeshOnEntity,aMeshOnEntity2); + ::ImportField(anArray,theMesh,theField,theValForTime,theMeshOnEntity); } SALOME_MED::FIELDINT_ptr aFieldInt = SALOME_MED::FIELDINT::_narrow(aMEDField); if(!aFieldInt->_is_nil()){ SALOME_MED::long_array_var anArray = aFieldInt->getValue(SALOME_MED::MED_FULL_INTERLACE); if(MYDEBUG) MESSAGE("VISU_MEDConvertor::LoadField - There is FIELDINT = "<length()); - ::ImportField(anArray,aMesh,theField,theValForTime,theMeshOnEntity,aMeshOnEntity2); + ::ImportField(anArray,theMesh,theField,theValForTime,theMeshOnEntity); } return 1; } diff --git a/src/VISU_I/VISU_CorbaMedConvertor.hxx b/src/VISU_I/VISU_CorbaMedConvertor.hxx index 53bd83ad..6b7c9410 100644 --- a/src/VISU_I/VISU_CorbaMedConvertor.hxx +++ b/src/VISU_I/VISU_CorbaMedConvertor.hxx @@ -35,52 +35,45 @@ #include -extern "C"{ -#include -} +namespace VISU{ -namespace VISUMED{ - struct TFamily{ - SALOME_MED::FAMILY_var myFamily; - }; - typedef std::map TFamilyMap; - - struct TField{ - struct TValForTime{ - SALOME_MED::FIELD_var myField; - }; - typedef std::map TValField; - TValField myValField; + struct TCMesh: TMeshImpl{ + SALOME_MED::MESH_var myMesh; }; - typedef std::map TFieldMap; + typedef shared_ptr PCMesh; - struct TMeshOnEntity{ + struct TCMeshOnEntity: TMeshOnEntityImpl{ SALOME_MED::SUPPORT_var mySupport; typedef std::pair TIndexAndSize; typedef std::map TCellsFirstIndex; TCellsFirstIndex myCellsFirstIndex; - TFamilyMap myFamilyMap; - TFieldMap myFieldMap; }; - typedef std::map TMeshOnEntityMap; + typedef shared_ptr PCMeshOnEntity; + + struct TCFamily: TFamilyImpl{ + SALOME_MED::FAMILY_var myFamily; + }; + typedef shared_ptr PCFamily; - struct TGroup{ + struct TCGroup: TGroupImpl{ SALOME_MED::GROUP_var myGroup; }; - typedef std::map TGroupMap; + typedef shared_ptr PCGroup; - struct TMesh{ - SALOME_MED::MESH_var myMesh; - TMeshOnEntityMap myMeshOnEntityMap; - TGroupMap myGroupMap; + struct TCField: TFieldImpl{ + }; + typedef shared_ptr PCField; + + struct TCValForTime: TValForTimeImpl{ + SALOME_MED::FIELD_var myField; }; - typedef std::map TMeshMap; + typedef shared_ptr PCValForTime; + } class VISU_MEDConvertor: public VISU_Convertor_impl{ protected: - VISUMED::TMeshMap myMeshMap2; SALOMEDS::SObject_var mySObject; VISU_MEDConvertor() {}; @@ -93,23 +86,28 @@ class VISU_MEDConvertor: public VISU_Convertor_impl{ VISU_Convertor* Build(SALOME_MED::MED_ptr theMED); VISU_Convertor* Build(SALOMEDS::ChildIterator_ptr theTimeStampIterator); - virtual int LoadMeshOnEntity(VISU::TMeshOnEntity& theMeshOnEntity, + virtual int LoadMeshOnEntity(VISU::PMeshOnEntityImpl theMeshOnEntity, const std::string& theFamilyName = ""); - virtual int LoadMeshOnGroup(VISU::TMesh& theMesh, + virtual int LoadMeshOnGroup(VISU::PMeshImpl theMesh, const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet); - virtual int LoadFieldOnMesh(VISU::TMesh& theMesh, - VISU::TMeshOnEntity& theMeshOnEntity, - VISU::TField& theField, - VISU::TField::TValForTime& theValForTime); - - int LoadPoints(VISU::TMesh& theMesh, const std::string& theFamilyName = "") ; + virtual int LoadFieldOnMesh(VISU::PMeshImpl theMesh, + VISU::PMeshOnEntityImpl theMeshOnEntity, + VISU::PFieldImpl theField, + VISU::PValForTimeImpl theValForTime); - int LoadCellsOnEntity(VISU::TMeshOnEntity& theMeshOnEntity, const std::string& theFamilyName = ""); + int LoadPoints(VISU::PCMesh theMesh, + const std::string& theFamilyName = "") ; - int LoadField(const VISU::TMeshOnEntity& theMeshOnEntity, - const VISU::TField& theField, VISU::TField::TValForTime& theValForTime); + int LoadCellsOnEntity(VISU::PCMesh theMesh, + VISU::PCMeshOnEntity theMeshOnEntity, + const std::string& theFamilyName = ""); + + int LoadField(VISU::PCMesh theMesh, + VISU::PCMeshOnEntity theMeshOnEntity, + VISU::PField theField, + VISU::PCValForTime theValForTime); }; @@ -117,7 +115,9 @@ class VISU_MEDFieldConvertor: public VISU_MEDConvertor{ protected: SALOME_MED::FIELD_var myField; public: - VISU_MEDFieldConvertor(SALOME_MED::FIELD_ptr theField) : myField(SALOME_MED::FIELD::_duplicate(theField)) {} + VISU_MEDFieldConvertor(SALOME_MED::FIELD_ptr theField) : + myField(SALOME_MED::FIELD::_duplicate(theField)) + {} virtual VISU_Convertor* Build() ; }; diff --git a/src/VISU_I/VISU_CutLines_i.cc b/src/VISU_I/VISU_CutLines_i.cc index 4021956f..94e2cbc5 100644 --- a/src/VISU_I/VISU_CutLines_i.cc +++ b/src/VISU_I/VISU_CutLines_i.cc @@ -38,10 +38,8 @@ using namespace std; #ifdef _DEBUG_ static int MYDEBUG = 0; -static int MYDEBUGWITHFILES = 0; #else static int MYDEBUG = 0; -static int MYDEBUGWITHFILES = 0; #endif int VISU::CutLines_i::IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity, @@ -68,7 +66,6 @@ VISU::CutLines_i::CutLines_i(Result_i* theResult, bool theAddToStudy, SALOMEDS:: void VISU::CutLines_i::SameAs(const CutLines_i* theOrigin){ - CutLines_i* aCutLines = const_cast(theOrigin); VISU::ScalarMap_i::SameAs(theOrigin); } @@ -251,11 +248,10 @@ void VISU::CutLines_i::BuildTableOfReal(SALOMEDS::SObject_ptr theSObject){ typedef map TXYMapCont; typedef map TLineIdCont; - const VISU::TField::TValField& aValField = myField->myValField; - const VISU::TField::TValForTime& aValForTime = aValField.find((int)myIteration)->second; - const VISU::TField::TTime& aTime = aValForTime.myTime; + const VISU::TValField& aValField = myField->myValField; + const VISU::PValForTime aValForTime = aValField.find((int)myIteration)->second; + const VISU::TTime& aTime = aValForTime->myTime; QString aTitle; - //aTitle.sprintf("%s %s",myTitle.c_str(),aTime.second.c_str()); aTitle.sprintf("%s",myTitle.c_str()); aTitle = aTitle.simplifyWhiteSpace(); aTableOfReal->SetTitle(aTitle.latin1()); diff --git a/src/VISU_I/VISU_CutPlanes_i.cc b/src/VISU_I/VISU_CutPlanes_i.cc index cfa89252..a18f32f3 100644 --- a/src/VISU_I/VISU_CutPlanes_i.cc +++ b/src/VISU_I/VISU_CutPlanes_i.cc @@ -34,10 +34,8 @@ using namespace std; #ifdef _DEBUG_ static int MYDEBUG = 0; -static int MYDEBUGWITHFILES = 0; #else static int MYDEBUG = 0; -static int MYDEBUGWITHFILES = 0; #endif int VISU::CutPlanes_i::IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity, @@ -65,7 +63,6 @@ VISU::CutPlanes_i::CutPlanes_i(Result_i* theResult, bool theAddToStudy, SALOMEDS void VISU::CutPlanes_i::SameAs(const CutPlanes_i* theOrigin){ - CutPlanes_i* aCutPlanes = const_cast(theOrigin); VISU::ScalarMap_i::SameAs(theOrigin); } @@ -98,8 +95,6 @@ VISU::Storable* VISU::CutPlanes_i::Restore(const Storable::TRestoringMap& theMap void VISU::CutPlanes_i::ToStream(std::ostringstream& theStr){ ScalarMap_i::ToStream(theStr); - int aNbPlanes = GetNbPlanes(); - Storable::DataToStream( theStr, "myNbPlanes", int(GetNbPlanes())); Storable::DataToStream( theStr, "myDisplacement", GetDisplacement()); Storable::DataToStream( theStr, "myBasePlane", int(GetOrientationType())); diff --git a/src/VISU_I/VISU_DeformedShape_i.cc b/src/VISU_I/VISU_DeformedShape_i.cc index 8333217f..ed15758d 100644 --- a/src/VISU_I/VISU_DeformedShape_i.cc +++ b/src/VISU_I/VISU_DeformedShape_i.cc @@ -36,10 +36,8 @@ using namespace std; #ifdef _DEBUG_ static int MYDEBUG = 0; -static int MYDEBUGWITHFILES = 0; #else static int MYDEBUG = 0; -static int MYDEBUGWITHFILES = 0; #endif int VISU::DeformedShape_i::IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity, @@ -47,8 +45,8 @@ int VISU::DeformedShape_i::IsPossible(Result_i* theResult, const char* theMeshNa { try{ if(!VISU::ScalarMap_i::IsPossible(theResult,theMeshName,theEntity,theFieldName,theIteration,isMemoryCheck)) return 0; - const VISU::TField& aField = theResult->GetInput()->GetField(theMeshName,(VISU::TEntity)theEntity,theFieldName); - return aField.myNbComp > 1; + const VISU::PField aField = theResult->GetInput()->GetField(theMeshName,(VISU::TEntity)theEntity,theFieldName); + return aField->myNbComp > 1; }catch(std::exception& exc){ INFOS("Follow exception was occured :\n"<(theOrigin); VISU::ScalarMap_i::SameAs(theOrigin); } diff --git a/src/VISU_I/VISU_Mesh_i.cc b/src/VISU_I/VISU_Mesh_i.cc index d5f6e584..9da8c729 100644 --- a/src/VISU_I/VISU_Mesh_i.cc +++ b/src/VISU_I/VISU_Mesh_i.cc @@ -175,7 +175,7 @@ VISU::Mesh_i::~Mesh_i(){ VISU::Storable* VISU::Mesh_i::Build(int theRestoring){ SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); aStudyBuilder->NewCommand(); // There is a transaction - //try{ + try{ if(myResult->GetInput() == NULL) throw std::runtime_error("Mesh_i::Build - myResult->GetInput() == NULL !!!"); if(!theRestoring){ @@ -219,7 +219,7 @@ VISU::Storable* VISU::Mesh_i::Build(int theRestoring){ if(!theRestoring) { //Setting IOR on the label myMeshPL->Init(); string aResultEntry = myResult->GetEntry(); - string anEntry = FindEntryWithComment(myStudy,aResultEntry.c_str(),aComment.latin1()); + string anEntry = myResult->GetEntry(aComment.latin1()); if(anEntry == "") throw std::runtime_error("Mesh_i::Build - anEntry was not found !!!"); mySObject = myStudy->FindObjectID(anEntry.c_str()); SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); @@ -228,13 +228,13 @@ VISU::Storable* VISU::Mesh_i::Build(int theRestoring){ CORBA::String_var aString = GetID(); anIOR->SetValue(aString); } - //}catch(std::exception& exc){ - // INFOS("Follow exception was occured :\n"<CommitCommand(); return this; } diff --git a/src/VISU_I/VISU_Result_i.cc b/src/VISU_I/VISU_Result_i.cc index dc8b0903..d4e1ee61 100644 --- a/src/VISU_I/VISU_Result_i.cc +++ b/src/VISU_I/VISU_Result_i.cc @@ -47,10 +47,8 @@ using namespace std; #ifdef _DEBUG_ static int MYDEBUG = 0; -static int MYDEBUGWITHFILES = 0; #else static int MYDEBUG = 0; -static int MYDEBUGWITHFILES = 0; #endif VISU::Result_var VISU::FindResult(SALOMEDS::SObject_ptr theSObject){ @@ -168,21 +166,21 @@ CORBA::Boolean VISU::Result_i::BuildAll(){ VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin(); for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){ const string& aMeshName = aMeshMapIter->first; - const VISU::TMesh& aMesh = aMeshMapIter->second; - const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh.myMeshOnEntityMap; + const VISU::PMesh aMesh = aMeshMapIter->second; + const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter; //Import fields aMeshOnEntityMapIter = aMeshOnEntityMap.begin(); for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){ const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first; - const VISU::TMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second; - const VISU::TFieldMap& aFieldMap = aMeshOnEntity.myFieldMap; + const VISU::PMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second; + const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap; VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin(); for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){ const string& aFieldName = aFieldMapIter->first; - const VISU::TField& aField = aFieldMapIter->second; - const VISU::TField::TValField& aValField = aField.myValField; - VISU::TField::TValField::const_iterator aValFieldIter = aValField.begin(); + const VISU::PField aField = aFieldMapIter->second; + const VISU::TValField& aValField = aField->myValField; + VISU::TValField::const_iterator aValFieldIter = aValField.begin(); for(; aValFieldIter != aValField.end(); aValFieldIter++){ int aTimeStamp = aValFieldIter->first; try{ @@ -195,7 +193,7 @@ CORBA::Boolean VISU::Result_i::BuildAll(){ } } //Importing groups - const VISU::TGroupMap& aGroupMap = aMesh.myGroupMap; + const VISU::TGroupMap& aGroupMap = aMesh->myGroupMap; VISU::TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin(); for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){ const string& aGroupName = aGroupMapIter->first; @@ -208,7 +206,7 @@ CORBA::Boolean VISU::Result_i::BuildAll(){ } } //Import families - const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity.myFamilyMap; + const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap; VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin(); for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){ const string& aFamilyName = aFamilyMapIter->first; @@ -253,10 +251,19 @@ VISU::Storable* VISU::Result_i::Build(SALOMEDS::SObject_ptr theSObject) string aRefFatherEntry = GetRefFatherEntry(); QString aComment; aComment.sprintf("myComment=%s;myType=%d;myFileName=%s;myInitFileName=%s", - GetComment(),VISU::TRESULT,myFileInfo.filePath().latin1(), + GetComment(), + VISU::TRESULT, + myFileInfo.filePath().latin1(), myInitFileName.c_str()); // Restoring of Python dump - string aResultEntry = CreateAttributes(myStudyDocument,aSComponentEntry,aRefFatherEntry.c_str(), - anIOR,myName.c_str(),"",aComment.latin1(),true); + string aResultEntry = + CreateAttributes(myStudyDocument, + aSComponentEntry, + aRefFatherEntry.c_str(), + anIOR, + myName.c_str(), + "", + aComment.latin1(), + true); mySObject = myStudyDocument->FindObjectID(aResultEntry.c_str()); if(mySObject->_is_nil()) throw std::runtime_error("Build - There is no SObject for the Result !!!"); if(!CORBA::is_nil(theSObject)){ @@ -266,11 +273,11 @@ VISU::Storable* VISU::Result_i::Build(SALOMEDS::SObject_ptr theSObject) TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin(); for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){ const string& aMeshName = aMeshMapIter->first; - const VISU::TMesh& aMesh = aMeshMapIter->second; - const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh.myMeshOnEntityMap; + const VISU::PMesh aMesh = aMeshMapIter->second; + const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter; aComment.sprintf("myComment=MESH;myName=%s;myDim=%d", - aMeshName.c_str(),aMesh.myDim); + aMeshName.c_str(),aMesh->myDim); string aMeshEntry = CreateAttributes(myStudyDocument,aResultEntry.c_str(),aRefFatherEntry.c_str(), "",aMeshName.c_str(),"",aComment.latin1(),true); if(aMeshOnEntityMap.empty()) continue; @@ -279,12 +286,16 @@ VISU::Storable* VISU::Result_i::Build(SALOMEDS::SObject_ptr theSObject) "","Families","",aComment.latin1(),true); //Import entities and according families aMeshOnEntityMapIter = aMeshOnEntityMap.begin(); - typedef map TEntity2Entry; - TEntity2Entry aEntity2Entry; + typedef std::map TComment2EntryMap; + TComment2EntryMap aComment2EntryMap; + typedef std::map TEntity2EntryMap; + TEntity2EntryMap aEntity2EntryMap; for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){ const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first; aComment.sprintf("myComment=ENTITY;myType=%d;myMeshName=%s;myId=%d", - VISU::TENTITY,aMeshName.c_str(),anEntity); + VISU::TENTITY, + aMeshName.c_str(), + anEntity); string anEntityName; switch(anEntity){ case VISU::NODE_ENTITY : anEntityName = "onNodes"; break; @@ -294,26 +305,43 @@ VISU::Storable* VISU::Result_i::Build(SALOMEDS::SObject_ptr theSObject) default: throw std::runtime_error("Build >> Value of entity is incorrect!"); } - aEntity2Entry[anEntity] = CreateAttributes(myStudyDocument,aSubMeshesEntry.c_str(),aRefFatherEntry.c_str(), + aEntity2EntryMap[anEntity] = CreateAttributes(myStudyDocument,aSubMeshesEntry.c_str(),aRefFatherEntry.c_str(), "",anEntityName.c_str(),"",aComment.latin1(),true); - const VISU::TMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second; - const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity.myFamilyMap; + const VISU::PMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second; + const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap; VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin(); for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){ const string& aFamilyName = aFamilyMapIter->first; - const VISU::TFamily& aFamily = aFamilyMapIter->second; aComment.sprintf("myComment=FAMILY;myType=%d;myMeshName=%s;myEntityId=%d;myName=%s", - VISU::TFAMILY,aMeshName.c_str(),anEntity,aFamilyName.c_str()); - CreateAttributes(myStudyDocument,aEntity2Entry[anEntity].c_str(),aRefFatherEntry.c_str(), - "",aFamilyName.c_str(),"",aComment.latin1(),true); + VISU::TFAMILY, + aMeshName.c_str(), + anEntity, + aFamilyName.c_str()); + aComment2EntryMap[aComment.latin1()] = + CreateAttributes(myStudyDocument, + aEntity2EntryMap[anEntity].c_str(), + aRefFatherEntry.c_str(), + "", + aFamilyName.c_str(), + "", + aComment.latin1(), + true); } } //Importing groups - const VISU::TGroupMap& aGroupMap = aMesh.myGroupMap; + const VISU::TGroupMap& aGroupMap = aMesh->myGroupMap; if(aGroupMap.size() > 0){ - aComment.sprintf("myComment=GROUPS;myMeshName=%s",aMeshName.c_str()); - string aGroupsEntry = CreateAttributes(myStudyDocument,aMeshEntry.c_str(),aRefFatherEntry.c_str(), - "","Groups","",aComment.latin1(),true); + aComment.sprintf("myComment=GROUPS;myMeshName=%s", + aMeshName.c_str()); + string aGroupsEntry = + CreateAttributes(myStudyDocument, + aMeshEntry.c_str(), + aRefFatherEntry.c_str(), + "", + "Groups", + "", + aComment.latin1(), + true); VISU::TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin(); for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){ const string& aGroupName = aGroupMapIter->first; @@ -321,17 +349,19 @@ VISU::Storable* VISU::Result_i::Build(SALOMEDS::SObject_ptr theSObject) VISU::TGROUP,aMeshName.c_str(),aGroupName.c_str()); string aGroupEntry = CreateAttributes(myStudyDocument,aGroupsEntry.c_str(),aRefFatherEntry.c_str(), "",aGroupName.c_str(),"",aComment.latin1(),true); - const VISU::TGroup& aGroup = aGroupMapIter->second; - const VISU::TFamilyAndEntitySet& aFamilyAndEntitySet = aGroup.myFamilyAndEntitySet; + const VISU::PGroup aGroup = aGroupMapIter->second; + const VISU::TFamilyAndEntitySet& aFamilyAndEntitySet = aGroup->myFamilyAndEntitySet; VISU::TFamilyAndEntitySet::const_iterator aFamilyAndEntitySetIter = aFamilyAndEntitySet.begin(); for(; aFamilyAndEntitySetIter != aFamilyAndEntitySet.end(); aFamilyAndEntitySetIter++){ const VISU::TFamilyAndEntity& aFamilyAndEntity = *aFamilyAndEntitySetIter; const string& aFamilyName = aFamilyAndEntity.first; const VISU::TEntity& anEntity = aFamilyAndEntity.second; aComment.sprintf("myComment=FAMILY;myType=%d;myMeshName=%s;myEntityId=%d;myName=%s", - VISU::TFAMILY,aMeshName.c_str(),anEntity,aFamilyName.c_str()); - string anEntry = FindEntryWithComment(myStudyDocument,aEntity2Entry[anEntity].c_str(),aComment); - CreateReference(myStudyDocument,aGroupEntry,anEntry); + VISU::TFAMILY, + aMeshName.c_str(), + anEntity, + aFamilyName.c_str()); + CreateReference(myStudyDocument,aGroupEntry,aComment2EntryMap[aComment.latin1()]); } } } @@ -341,32 +371,40 @@ VISU::Storable* VISU::Result_i::Build(SALOMEDS::SObject_ptr theSObject) aMeshOnEntityMapIter = aMeshOnEntityMap.begin(); for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){ const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first; - const VISU::TMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second; - const VISU::TFieldMap& aFieldMap = aMeshOnEntity.myFieldMap; + const VISU::PMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second; + const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap; VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin(); for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){ if(!isFieldEntryCreated){ - aComment.sprintf("myComment=FIELDS;myMeshName=%s",aMeshName.c_str()); - aFieldsEntry = CreateAttributes(myStudyDocument,aMeshEntry.c_str(),aRefFatherEntry.c_str(), - "","Fields","",aComment.latin1(),true); + aComment.sprintf("myComment=FIELDS;myMeshName=%s", + aMeshName.c_str()); + aFieldsEntry = + CreateAttributes(myStudyDocument, + aMeshEntry.c_str(), + aRefFatherEntry.c_str(), + "", + "Fields", + "", + aComment.latin1(), + true); isFieldEntryCreated = true; } const string& aFieldName = aFieldMapIter->first; - const VISU::TField& aField = aFieldMapIter->second; - const VISU::TField::TValField& aValField = aField.myValField; - QString aFieldNameWithUnit = ::GenerateFieldName(aFieldName,aField.myUnitNames[0]); + const VISU::PField aField = aFieldMapIter->second; + const VISU::TValField& aValField = aField->myValField; + QString aFieldNameWithUnit = ::GenerateFieldName(aFieldName,aField->myUnitNames[0]); aComment.sprintf("myComment=FIELD;myType=%d;myMeshName=%s;myEntityId=%d;myName=%s;myNbTimeStamps=%d;myNumComponent=%d", - VISU::TFIELD,aMeshName.c_str(),anEntity,aFieldName.c_str(),aValField.size(),aField.myNbComp); + VISU::TFIELD,aMeshName.c_str(),anEntity,aFieldName.c_str(),aValField.size(),aField->myNbComp); string aFieldEntry = CreateAttributes(myStudyDocument,aFieldsEntry.c_str(),aRefFatherEntry.c_str(), "",aFieldNameWithUnit.latin1(),"",aComment.latin1(),true); - CreateReference(myStudyDocument,aFieldEntry,aEntity2Entry[anEntity]); - VISU::TField::TValField::const_iterator aValFieldIter = aValField.begin(); + CreateReference(myStudyDocument,aFieldEntry,aEntity2EntryMap[anEntity]); + VISU::TValField::const_iterator aValFieldIter = aValField.begin(); for(; aValFieldIter != aValField.end(); aValFieldIter++){ int aTimeStamp = aValFieldIter->first; - const VISU::TField::TValForTime& aValForTime = aValFieldIter->second; + const VISU::PValForTime aValForTime = aValFieldIter->second; aComment.sprintf("myComment=TIMESTAMP;myType=%d;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d", - VISU::TTIMESTAMP,aMeshName.c_str(),anEntity,aFieldName.c_str(),aTimeStamp,aField.myNbComp); - string aTimeStampId = VISU_Convertor::GenerateName(aValForTime.myTime); + VISU::TTIMESTAMP,aMeshName.c_str(),anEntity,aFieldName.c_str(),aTimeStamp,aField->myNbComp); + string aTimeStampId = VISU_Convertor::GenerateName(aValForTime->myTime); CreateAttributes(myStudyDocument,aFieldEntry.c_str(),aRefFatherEntry.c_str(), "",aTimeStampId.c_str(),"",aComment.latin1(),true); } @@ -526,7 +564,7 @@ VISU::Storable* VISU::Result_i::Restore(SALOMEDS::SObject_ptr theSObject, else mySourceId = eFile; if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - mySourceId = "<getSetting("Visu:SBMinimumValue"); float aMin = (aRangeMin.isEmpty())? 0 : aRangeMin.toFloat(); QString aRangeMax = QAD_CONFIG->getSetting("Visu:SBMaximumValue"); @@ -435,7 +432,7 @@ VISU::Storable* VISU::ScalarMap_i::Build(int theRestoring){ try{ if(myResult->GetInput() == NULL) throw std::runtime_error("Mesh_i::Build - myResult->GetInput() == NULL !!!"); - myField = &(myResult->GetInput()->GetField(myMeshName,myEntity,myFieldName)); + myField = myResult->GetInput()->GetField(myMeshName,myEntity,myFieldName); if(myField == NULL) throw std::runtime_error("There is no Field with the parameters !!!"); VISU_Convertor::TOutput *anOutput = myResult->GetInput()->GetTimeStampOnMesh(myMeshName,myEntity,myFieldName,myIteration); @@ -447,9 +444,9 @@ VISU::Storable* VISU::ScalarMap_i::Build(int theRestoring){ if(theRestoring <= 0){ if(theRestoring == 0) myScalarMapPL->Init(); if(!myIsFixedRange) myScalarMapPL->SetSourceRange(); - const VISU::TField::TValField& aValField = myField->myValField; - const VISU::TField::TValForTime& aValForTime = aValField.find(myIteration)->second; - aComment.sprintf("%s %s",myFieldName.c_str(),VISU_Convertor::GenerateName(aValForTime.myTime).c_str()); + const VISU::TValField& aValField = myField->myValField; + const VISU::PValForTime aValForTime = aValField.find(myIteration)->second; + aComment.sprintf("%s %s",myFieldName.c_str(),VISU_Convertor::GenerateName(aValForTime->myTime).c_str()); if (theRestoring == 0) myTitle = aComment.simplifyWhiteSpace().latin1(); } if(myAddToStudy){ @@ -458,7 +455,7 @@ VISU::Storable* VISU::ScalarMap_i::Build(int theRestoring){ VISU::TTIMESTAMP,myMeshName.c_str(),myEntity,myFieldName.c_str(),myIteration,myField->myNbComp); string aResultEntry = myResult->GetEntry(); string aRefFatherEntry = myResult->GetRefFatherEntry(); - string anEntry = FindEntryWithComment(myStudy,aResultEntry.c_str(),aComment.latin1()); + string anEntry = myResult->GetEntry(aComment.latin1()); if(anEntry == "") throw std::runtime_error("There is no Entry for binding the presentation !!!"); aComment.sprintf("myComment=%s;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d", GetComment(),myMeshName.c_str(),myEntity,myFieldName.c_str(),myIteration,myField->myNbComp); @@ -502,7 +499,6 @@ VISU_Actor* VISU::ScalarMap_i::CreateActor(const Handle(SALOME_InteractiveObject VISU::Prs3d_i::CreateActor(anActor,theIO); anActor->SetBarVisibility(true); anActor->SetRepresentation(2); - anActor->myFieldName = myFieldName; UpdateActor(anActor); }catch(...) { anActor->Delete(); diff --git a/src/VISU_I/VISU_ScalarMap_i.hh b/src/VISU_I/VISU_ScalarMap_i.hh index a42b55f0..510ff794 100644 --- a/src/VISU_I/VISU_ScalarMap_i.hh +++ b/src/VISU_I/VISU_ScalarMap_i.hh @@ -125,7 +125,7 @@ namespace VISU{ virtual void DoHook(); VISU_ScalarMapPL* myScalarMapPL; - const TField* myField; + PField myField; string myMeshName; TEntity myEntity; @@ -172,8 +172,8 @@ namespace VISU{ virtual void Update() ; virtual void SetMapScale(double theMapScale = 1.0); - const VISU::TField* GetField() const { return myField;} - const string& GetFieldName() const { return myFieldName;} + const VISU::PField GetField() const { return myField;} + const string& GetFieldName() const { return myFieldName;} virtual bool IsRangeFixed() { return myIsFixedRange; } virtual void SetSourceRange(); diff --git a/src/VISU_I/VISU_StreamLines_i.cc b/src/VISU_I/VISU_StreamLines_i.cc index 66a2305f..f6b5a303 100644 --- a/src/VISU_I/VISU_StreamLines_i.cc +++ b/src/VISU_I/VISU_StreamLines_i.cc @@ -31,6 +31,7 @@ #include #include +#include using namespace VISU; using namespace std; diff --git a/src/VISU_I/VISU_TimeAnimation.cxx b/src/VISU_I/VISU_TimeAnimation.cxx index e1245e97..2f16e023 100644 --- a/src/VISU_I/VISU_TimeAnimation.cxx +++ b/src/VISU_I/VISU_TimeAnimation.cxx @@ -29,8 +29,6 @@ using namespace std; -//QWaitCondition myCondition; -static int MYDELAY = 1; //************************************************************************ VISU_TimeAnimation::VISU_TimeAnimation(SALOMEDS::Study_ptr theStudy, VISU::View3D_ptr theView3D) { @@ -247,7 +245,6 @@ CORBA::Boolean VISU_TimeAnimation::generateFrames() { bool aNoError = true; clearView(); - vtkRenderer* aRen = myView->getRenderer(); for (int i = 0; i < getNbFields(); i++) { FieldData& aData = myFieldsLst[i]; diff --git a/src/VISU_I/VISU_Vectors_i.cc b/src/VISU_I/VISU_Vectors_i.cc index b7ac3c0a..ff44a6c1 100644 --- a/src/VISU_I/VISU_Vectors_i.cc +++ b/src/VISU_I/VISU_Vectors_i.cc @@ -34,10 +34,8 @@ using namespace std; #ifdef _DEBUG_ static int MYDEBUG = 0; -static int MYDEBUGWITHFILES = 0; #else static int MYDEBUG = 0; -static int MYDEBUGWITHFILES = 0; #endif static int INCMEMORY = 4+12; @@ -168,7 +166,6 @@ VISU_Actor* VISU::Vectors_i::CreateActor(const Handle(SALOME_InteractiveObject)& try{ VISU::Prs3d_i::CreateActor(anActor,theIO); anActor->SetBarVisibility(true); - anActor->myFieldName = myFieldName; anActor->GetProperty()->SetColor(myColor.R,myColor.G,myColor.B); anActor->GetProperty()->SetLineWidth(GetLineWidth()); UpdateActor(anActor); diff --git a/src/VISU_I/VISU_ViewManager_i.cc b/src/VISU_I/VISU_ViewManager_i.cc index f2f34ed0..6639b6b6 100644 --- a/src/VISU_I/VISU_ViewManager_i.cc +++ b/src/VISU_I/VISU_ViewManager_i.cc @@ -1607,7 +1607,6 @@ namespace VISU{ VISU_Actor* GetActor(VISU::Prs3d_i* thePrs3d, VTKViewer_ViewFrame* theVTKFrame){ - vtkActor *anActor; vtkActorCollection *anActColl = theVTKFrame->getRenderer()->GetActors(); anActColl->InitTraversal(); while(vtkActor *anActor = anActColl->GetNextActor()) diff --git a/src/VISU_SWIG/Makefile.in b/src/VISU_SWIG/Makefile.in index 8474ef9e..fefef6c6 100644 --- a/src/VISU_SWIG/Makefile.in +++ b/src/VISU_SWIG/Makefile.in @@ -49,8 +49,8 @@ EXPORT_SHAREDPYSCRIPTS = VISU_shared_modules.py LIB_CLIENT_IDL = -CPPFLAGS += -ftemplate-depth-32 $(PYTHON_INCLUDES) $(QT_INCLUDES) \ - $(VTK_INCLUDES) $(MED2_INCLUDES) $(HDF5_INCLUDES) +CPPFLAGS += -ftemplate-depth-32 $(PYTHON_INCLUDES) $(HDF5_INCLUDES) $(QT_INCLUDES) \ + $(VTK_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome $(BOOST_CPPFLAGS) LDFLAGS += $(PYTHON_LIBS) -lVisuConvertor -lVisuPipeLine @CONCLUDE@ -- 2.39.2