From: apo Date: Tue, 28 Dec 2004 13:48:57 +0000 (+0000) Subject: [Bug PAL7252] DEVELOPMENT: Porting to MED2.2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=eb4a560f108c260f2e87f123cc40ab995c8d80ea;p=modules%2Fvisu.git [Bug PAL7252] DEVELOPMENT: Porting to MED2.2 --- 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..6f360813 100644 --- a/src/CONVERTOR/VISUConvertor.cxx +++ b/src/CONVERTOR/VISUConvertor.cxx @@ -45,7 +45,7 @@ static int MYDEBUG = 0; void parseFile(const char* theFileName) { try{ - MESSAGE("'"< aCon(CreateConvertor(theFileName)); //aCon->GetSize(); //return; @@ -103,12 +103,11 @@ void parseFile(const char* theFileName) { aCon->GetMeshOnEntity(aMeshName,anEntity); } } - OK: - MESSAGE("OK"); + MSG(MYDEBUG,"OK"); }catch(std::exception& exc){ - MESSAGE("Follow exception was occured in file:"< -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){ diff --git a/src/CONVERTOR/VISU_Convertor.hxx b/src/CONVERTOR/VISU_Convertor.hxx index 5338d17a..4feb723a 100644 --- a/src/CONVERTOR/VISU_Convertor.hxx +++ b/src/CONVERTOR/VISU_Convertor.hxx @@ -47,6 +47,7 @@ #include #include "VISU_ExtractUnstructuredGrid.hxx" +#include "MED_Common.hxx" #include @@ -129,6 +130,7 @@ namespace VISU{ TCellsConn myCellsConn; TFamilyMap myFamilyMap; TFieldMap myFieldMap; + MED::TGeom myGeom; TMeshOnEntity() : myNbCells(0), myCellsSize(0) {} std::pair GetCellsDims(const std::string& theFamilyName = "") const; @@ -163,6 +165,8 @@ namespace VISU{ TPointsDim myPointsDim; TMeshOnEntityMap myMeshOnEntityMap; TGroupMap myGroupMap; + MED::PMeshInfo myMeshInfo; + MED::TEntityInfo myEntityInfo; TMesh() : myDim(0), myNbPoints(0) {} const TField* GetField(const std::string& theFieldName) const; }; @@ -228,8 +232,6 @@ public: }; 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..ee667fec 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,97 +60,95 @@ 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::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; + } + + + 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{ + + 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); + } + }; + typedef std::auto_ptr TCoordHelperPtr; + void GetPoints(VISU::TVTKSource& theStorage, VISU::TMesh& theMesh) { vtkPoints* aPoints = theMesh.myPoints.GetPointer(); @@ -199,8 +196,7 @@ namespace{ 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 !!!")); + EXCEPTION(runtime_error,"GetCells >> There is no elements on the family !!!"); VISU::TFamily::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() = "<> There is no elements on the family !!!")); + EXCEPTION(runtime_error,"GetCells >> There is no elements on the family !!!"); VISU::TFamily::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() = "<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,8 +562,8 @@ VISU_Convertor::TOutput* VISU_Convertor_impl::GetMeshOnGroup(const string& theMeshName, const string& theGroupName) { - if(MYDEBUG) MESSAGE("GetMeshOnGroup - theMeshName = '"<myMeshName,pVTKMeshOnEntity->myEntity); @@ -691,10 +679,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(...){ @@ -709,8 +697,7 @@ void VISU_Convertor_impl::FindMesh(const string& theMeshName, VISU::TMesh*& theM { 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()); + EXCEPTION(runtime_error,"FindMesh >> There is no mesh with the name - '"<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()); + EXCEPTION(runtime_error,"FindMeshOnEntity >> There is no mesh on the entity - "<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()); + EXCEPTION(runtime_error,"FindMesh >> There is no the group in the mesh!!! - '"<second; } @@ -851,15 +835,14 @@ float VISU_Convertor_impl::GetMeshOnGroupSize(const std::string& theMeshName, aLinksSize = 0; vtkIdType aResult = aPointsSize + aConnectivityAndTypesSize + aLocationsSize + aLinksSize; if(MYDEBUG){ - if(MYVTKDEBUG){ - MESSAGE("GetMeshOnGroupSize - aPointsSize = "<myFieldMap; if(aFieldMap.find(theFieldName) == aFieldMap.end()) - throw std::runtime_error(EXCEPTION("FindField >> There is no field on the mesh!!!")); + EXCEPTION(runtime_error,"FindField >> There is no field on the mesh!!!"); theField = &aFieldMap[theFieldName]; } @@ -904,12 +887,11 @@ float VISU_Convertor_impl::GetFieldOnMeshSize(const std::string& theMeshName, float aMeshSize = GetMeshOnEntitySize(theMeshName,pVTKMeshOnEntity->myEntity); float aFieldOnMeshSize = float(pField->myDataSize*sizeof(float)*pField->myNbValField * 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!!!")); + EXCEPTION(runtime_error,"FindTimeStamp >> There is no field with the timestamp!!!"); theValForTime = &aValField[theStampsNum]; } @@ -943,12 +925,12 @@ float VISU_Convertor_impl::GetTimeStampSize(const std::string& theMeshName, float aMeshSize = GetMeshOnEntitySize(theMeshName,pVTKMeshOnEntity->myEntity); float aTimeStampSize = float(pField->myDataSize*sizeof(float) * ERR_SIZE_CALC); float aResult = aMeshSize + aTimeStampSize; - if(MYDEBUG){ + if(MYDEBUG) if(MYVTKDEBUG) - MESSAGE("GetTimeStampSize - aTimeStampSize = "< -} - #include #include 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..4c7b8d88 100644 --- a/src/CONVERTOR/VISU_MedConvertor.cxx +++ b/src/CONVERTOR/VISU_MedConvertor.cxx @@ -26,16 +26,20 @@ #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; @@ -44,370 +48,373 @@ static int MYDEBUG = 0; #endif -static med_err ret = 0; - -typedef map TVisu2MedEntity; - -static TVisu2MedEntity aVisu2MedEntity; +namespace{ -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(); + + TMesh& aMesh = aMeshMap[aMeshName]; + aMesh.myDim = aDim; + aMesh.myName = aMeshName; + aMesh.myNbPoints = aNodeInfo->GetNbElem(); + aMesh.myMeshInfo = aMeshInfo; + aMesh.myEntityInfo = aEntityInfo; + + INITMSG(MYDEBUG,"aMeshName = '"<first; + const MED::TGeom& aTGeom = anEntityIter->second; + + TEntity aVEntity = MEDEntityToVTK(aMEntity); + VISU::TMeshOnEntity& aMeshOnEntity = aMesh.myMeshOnEntityMap[aVEntity]; + aMeshOnEntity.myEntity = aVEntity; + aMeshOnEntity.myMeshName = aMeshName; + aMeshOnEntity.myGeom = aTGeom; + + INITMSG(MYDEBUG,"aMEntity = "<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 = "<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 = "<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 = "<first; + const TFamilyGroup& aFamilyGroup = aFamilyByEntityIter->second; + + TEntity aVEntity = MEDEntityToVTK(aMEntity); + VISU::TMeshOnEntity& aMeshOnEntity = aMesh.myMeshOnEntityMap[aVEntity]; + + INITMSG(MYDEBUG,"aMEntity = "<GetId() == 0) continue; + VISU::TFamily& aFamily = aMeshOnEntity.myFamilyMap[aFamilyInfo->GetName()]; + + aFamily.myId = aFamilyInfo->GetId(); + aFamily.myName = aFamilyInfo->GetName(); + aFamily.myEntity = aVEntity; + aFamily.myNbCells = aFamilyNbCellsCounterMap[aFamily.myId]; + aFamily.myCellsSize = aFamilyCellsSizeCounterMap[aFamily.myId]; + + INITMSG(MYDEBUG,"aFamilyName = '"<GetNbGroup(); + for(TInt i = 0; i < aNbGroup; i++){ + const string& aGroupName = aFamilyInfo->GetGroupName(i); + aBindGroups.insert(aGroupName); + INITMSG(MYDEBUG,"aGroupName = '"<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); + TGroupInfo::const_iterator aGroupInfoIter = aGroupInfo.begin(); + for(;aGroupInfoIter != aGroupInfo.end(); aGroupInfoIter++){ + const string& aGroupName = aGroupInfoIter->first; + const TFamilyGroup& aFamilyGroup = aGroupInfoIter->second; + VISU::TGroup aGroup; + aGroup.myName = aGroupName; + aGroup.myMeshName = aMesh.myName; + + INITMSG(MYDEBUG,"aGroup.myName = '"<GetName(); + + TEntity aVEntity = TEntity(-1); + + // Find aVisuEntity + const TMeshOnEntityMap& aMeshOnEntityMap = aMesh.myMeshOnEntityMap; + TMeshOnEntityMap::const_iterator aMeshOnEntityIter = aMeshOnEntityMap.begin(); + for (; aMeshOnEntityIter != aMeshOnEntityMap.end(); aMeshOnEntityIter++){ + const TMeshOnEntity& aMeshOnEntity = aMeshOnEntityIter->second; + const TFamilyMap& aFamilyMap = aMeshOnEntity.myFamilyMap; + TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin(); + for (; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){ + const string& aFamilyName = aFamilyMapIter->first; + const TFamily& aFamily = aFamilyMapIter->second; + 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; + } + } + } + } + exit_lable: + if(aVEntity >= 0){ + VISU::TMeshOnEntity& aMeshOnEntity = aMesh.myMeshOnEntityMap[aVEntity]; + VISU::TFamily& aFamily = aMeshOnEntity.myFamilyMap[aFamilyInfo->GetName()]; + VISU::TFamilyAndEntity aFamilyAndEntity(aFamilyName,aVEntity); aGroup.myFamilyAndEntitySet.insert(aFamilyAndEntity); + INITMSG(MYDEBUG,"aFamilyName = '"< 0){ + aGroupMap.insert(VISU::TGroupMap::value_type(aGroupName,aGroup)); } } - } - //Reading information about fields - med_int iFieldEnd = MEDnChamp(fid,0); - if (iFieldEnd < 0) throw std::runtime_error(EXCEPTION("ImportChamps >> 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 = '"<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::TMeshOnEntity& aMeshOnEntity = aMesh.myMeshOnEntityMap[aVEntity]; + VISU::TField& aField = aMeshOnEntity.myFieldMap[aFieldName]; + aField.myId = iField; + aField.myNbComp = aNbComp; + aField.myEntity = aVEntity; + aField.myName = aFieldName; + aField.myMeshName = aMeshName; + aField.myNbValField = aNbTimeStamps; + aField.myDataSize = aMeshOnEntity.myNbCells * aNbComp; + aField.myCompNames.resize(aNbComp); + aField.myUnitNames.resize(aNbComp); + + INITMSG(MYDEBUG,"myName = '"<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); + 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(aDt,anUnitDt); + INITMSG(MYDEBUG,"aDt = "<first; const VISU::TEntity& anEntity = aFamilyAndEntitySetIter->second; VISU::TMeshOnEntity& 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,aMeshOnEntity); }else{ - isPointsUpdated += LoadPoints(fid,theMesh); - isCellsOnEntityUpdated += LoadCellsOnEntity(fid,aMeshOnEntity,aFamilyName); + isPointsUpdated += LoadPoints(aMed,theMesh); + isCellsOnEntityUpdated += LoadCellsOnEntity(aMed,aMeshOnEntity,aFamilyName); } } @@ -443,18 +446,19 @@ int VISU_MedConvertor::LoadFieldOnMesh(VISU::TMesh& theMesh, VISU::TField& theField, VISU::TField::TValForTime& 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,theMeshOnEntity); + int isFieldUpdated = LoadField(aMed,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::TMesh& theMesh, + const string& theFamilyName) { try{ //Check on existing family @@ -469,76 +473,52 @@ int VISU_MedConvertor::LoadPoints(const med_idt& fid, VISU::TMesh& theMesh, cons if(isPointsLoaded) if(!isFamilyPresent) return 0; else if(!aFamily.mySubMesh.empty()) return 0; - if(MYDEBUG) - MESSAGE("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(); + if(!isPointsLoaded){ 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; - } + 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 = "<GetNodeCoord(iElem,iDim); + VISU::TMeshOnEntity::TConnForCellType& aConnForCellType = aMeshOnEntity.myCellsConn[VTK_VERTEX]; - aConnForCellType.resize(iNumElemEnd); - for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) - aConnForCellType[iNumElem] = VISU::TMeshOnEntity::TConnect(1,iNumElem); + aConnForCellType.resize(aNbElem); + for (int iElem = 0; iElem < aNbElem; iElem++) + aConnForCellType[iElem] = VISU::TMeshOnEntity::TConnect(1,iElem); } - if(isFamilyPresent && iNumElemEnd > 0){ - if(MYDEBUG) MESSAGE("LoadPoints - Filling aFamily SubMesh"); + if(isFamilyPresent && aNbElem > 0){ 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); + 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()); + throw; }catch(...){ theMesh.myPointsCoord.clear(); - throw std::runtime_error(EXCEPTION("Unknown exception !!!")); + 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::TMeshOnEntity& theMeshOnEntity, + const string& theFamilyName) { try{ //Check on existing family @@ -550,214 +530,170 @@ int VISU_MedConvertor::LoadCellsOnEntity(const med_idt& fid, VISU::TMeshOnEntity 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 = "<> 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(); + TMeshOnEntity::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::TMeshOnEntity::TConnForCellType& aConnForCellType = aCellsConn[aVTKGeomType]; + aConnForCellType.resize(aNbElem); + + int aMNbNodes = MEDGeom2NbNodes(aGeom); + vector aConnect(aMNbNodes); + + for (int iElem = 0; iElem < aNbElem; iElem++) { + VISU::TMeshOnEntity::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("<GetFamNum(iElem) == aFamily.myId) + aSubMeshOnCellType.insert(iElem); } } return 1; }catch(std::runtime_error& exc){ theMeshOnEntity.myCellsConn.clear(); - throw std::runtime_error(exc.what()); + throw; }catch(...){ theMeshOnEntity.myCellsConn.clear(); - throw std::runtime_error(EXCEPTION("Unknown exception !!!")); + 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, + const VISU::TMeshOnEntity& theMeshOnEntity, + VISU::TField& theField, + VISU::TField::TValForTime& theValForTime) { //Check on loading already done 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 = '"<GetPFieldInfo(aMeshInfo,theField.myId); + + MED::TGeom aTGeom; + EEntiteMaillage aMEntity; + theMed->GetNbTimeStamps(aFieldInfo,aMesh.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 = '"< -} - class VISU_MedConvertor: public VISU_Convertor_impl{ VISU_MedConvertor(); VISU_MedConvertor(const VISU_MedConvertor&); @@ -34,16 +30,20 @@ protected: VISU::TMeshOnEntity& theMeshOnEntity, VISU::TField& theField, VISU::TField::TValForTime& theValForTime); - - int LoadPoints(const med_idt& fid, VISU::TMesh& theMesh, + + int LoadPoints(const MED::PWrapper& theMed, + VISU::TMesh& theMesh, const std::string& theFamilyName = ""); - int LoadCellsOnEntity(const med_idt& fid, VISU::TMeshOnEntity& theMeshOnEntity, + int LoadCellsOnEntity(const MED::PWrapper& theMed, + VISU::TMeshOnEntity& 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, + const VISU::TMeshOnEntity& theMeshOnEntity, + VISU::TField& theField, + VISU::TField::TValForTime& theValForTime); + }; #endif 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/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/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index ee34ad50..e8ed7f96 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 @@ -3845,26 +3844,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(); @@ -3974,8 +3971,6 @@ VISU_Actor* VisuGUI::UpdateViewer(VISU::Prs3d_i* thePrs, bool theDispOnly){ 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..99336d9f 100644 --- a/src/VISU_I/VISU_CorbaMedConvertor.cxx +++ b/src/VISU_I/VISU_CorbaMedConvertor.cxx @@ -33,7 +33,6 @@ #include #include -using namespace VISU; using namespace std; #define USER_INTERLACE MED_FULL_INTERLACE @@ -43,7 +42,6 @@ static int MYDEBUG = 0; #else static int MYDEBUG = 0; #endif -static med_err ret = 0; extern "C" { VISU_Convertor* CreateMEDConvertor(SALOMEDS::SObject_ptr theMedSObject) { @@ -54,205 +52,255 @@ 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; + using namespace VISU; + + 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; } - }else - GetCellsSize(aMeshOnEntity.myNbCells,aMeshOnEntity.myCellsSize,theMEDMesh,theEntity); + 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(); + } + 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 = "<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; + } + }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(); + VISU::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() !!!"); @@ -267,19 +315,19 @@ VISU_Convertor* VISU_MEDFieldConvertor::Build() { aMesh2.myMesh = aMEDMesh; if(MYDEBUG) MESSAGE("VISU_MEDFieldConvertor::Build - aMeshName = "<> 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); @@ -317,7 +368,8 @@ VISU_Convertor* VISU_MEDConvertor::Build() { } -VISU_Convertor* VISU_MEDConvertor::Build(SALOME_MED::MED_ptr theMED) +VISU_Convertor* +VISU_MEDConvertor::Build(SALOME_MED::MED_ptr theMED) { if(theMED->_is_nil()) return NULL; CORBA::Short aTag = mySObject->Tag(); @@ -330,8 +382,8 @@ VISU_Convertor* VISU_MEDConvertor::Build(SALOME_MED::MED_ptr theMED) 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(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aMeshSObj = '"<_is_nil()) continue; @@ -346,33 +398,33 @@ VISU_Convertor* VISU_MEDConvertor::Build(SALOME_MED::MED_ptr theMED) SALOMEDS::ChildIterator_var aSupportIterator = aStudy->NewChildIterator(aMeshSObj); for(; aSupportIterator->More(); aSupportIterator->Next()){ SALOMEDS::SObject_var aSupportSObj = aSupportIterator->Value(); - CORBA::Object_var aMedSupport = SObjectToObject(aSupportSObj); + 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 aMEDEntity = aMEDSupport->getEntity(); - VISU::TEntity anEntity = aMed2VisuEntity[aMEDEntity]; + 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 = '"<NewChildIterator(aFieldSObj); for(int iField = 0; aFieldIterator->More(); aFieldIterator->Next(), iField++){ aFieldSObj = aFieldIterator->Value(); - if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aFieldName = '"<<::GetName(aFieldSObj)<<"'"); + if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aFieldName = '"<NewChildIterator(aFieldSObj); for(int iTimeStamp = 1; aTimeStampIterator->More(); aTimeStampIterator->Next(), iTimeStamp++){ SALOMEDS::SObject_var aTimeStampSObj = aTimeStampIterator->Value(); - if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aTimeStampSObj = '"<<::GetName(aTimeStampSObj)<<"'"); - CORBA::Object_var aMedField = SObjectToObject(aTimeStampSObj); + if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aTimeStampSObj = '"<_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]; + SALOME_MED::medEntityMesh aMEntity = aMEDSupport->getEntity(); + VISU::TEntity anEntity = MEDEntityToVTK(aMEntity); SALOME_MED::MESH_var aMEDMesh = aMEDSupport->getMesh(); if(aMEDMesh->_is_nil()) continue; CORBA::String_var aMeshName = aMEDMesh->getName(); @@ -511,20 +563,21 @@ VISU_Convertor* VISU_MEDConvertor::Build(SALOME_MED::MED_ptr theMED) } -VISU_Convertor* VISU_MEDConvertor::Build(SALOMEDS::ChildIterator_ptr theTimeStampIterator) +VISU_Convertor* +VISU_MEDConvertor::Build(SALOMEDS::ChildIterator_ptr theTimeStampIterator) { if(theTimeStampIterator->_is_nil()) return NULL; for(int iTimeStamp = 1; theTimeStampIterator->More(); theTimeStampIterator->Next(), iTimeStamp++){ SALOMEDS::SObject_var aTimeStampSObj = theTimeStampIterator->Value(); - if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aTimeStampSObj = '"<<::GetName(aTimeStampSObj)<<"'"); - CORBA::Object_var aMedField = SObjectToObject(aTimeStampSObj); + if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aTimeStampSObj = '"<_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]; + SALOME_MED::medEntityMesh aMEntity = aMEDSupport->getEntity(); + VISU::TEntity anEntity = MEDEntityToVTK(aMEntity); SALOME_MED::MESH_var aMEDMesh = aMEDSupport->getMesh(); if(aMEDMesh->_is_nil()) continue; CORBA::String_var aMeshName = aMEDMesh->getName(); @@ -577,8 +630,9 @@ VISU_Convertor* VISU_MEDConvertor::Build(SALOMEDS::ChildIterator_ptr theTimeStam } -int VISU_MEDConvertor::LoadMeshOnEntity(VISU::TMeshOnEntity& theMeshOnEntity, - const string& theFamilyName) +int +VISU_MEDConvertor::LoadMeshOnEntity(VISU::TMeshOnEntity& theMeshOnEntity, + const string& theFamilyName) { //Main part of code const string& aMeshName = theMeshOnEntity.myMeshName; @@ -593,9 +647,11 @@ int VISU_MEDConvertor::LoadMeshOnEntity(VISU::TMeshOnEntity& theMeshOnEntity, return (isPointsUpdated || isCellsOnEntityUpdated); } - -int VISU_MEDConvertor::LoadMeshOnGroup(VISU::TMesh& theMesh, - const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet) + + +int +VISU_MEDConvertor::LoadMeshOnGroup(VISU::TMesh& theMesh, + const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet) { //Main part of code int isPointsUpdated = 0; @@ -617,10 +673,12 @@ int VISU_MEDConvertor::LoadMeshOnGroup(VISU::TMesh& theMesh, 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::TMesh& theMesh, + VISU::TMeshOnEntity& theMeshOnEntity, + VISU::TField& theField, + VISU::TField::TValForTime& theValForTime) { //Main part of code int isPointsUpdated = LoadPoints(theMesh); @@ -630,7 +688,8 @@ int VISU_MEDConvertor::LoadFieldOnMesh(VISU::TMesh& theMesh, return (isPointsUpdated || isCellsOnEntityUpdated || isFieldUpdated); } -int VISU_MEDConvertor::LoadPoints(VISU::TMesh& theMesh, const string& theFamilyName) +int +VISU_MEDConvertor::LoadPoints(VISU::TMesh& theMesh, const string& theFamilyName) { //Check on existing family VISU::TMeshOnEntity& aMeshOnEntity = theMesh.myMeshOnEntityMap[VISU::NODE_ENTITY]; @@ -688,7 +747,9 @@ 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::TMeshOnEntity& theMeshOnEntity, const string& theFamilyName) { //Check on existing family VISU::TFamily* pFamily = VISU::GetFamily(theMeshOnEntity,theFamilyName); @@ -708,38 +769,35 @@ int VISU_MEDConvertor::LoadCellsOnEntity(VISU::TMeshOnEntity& theMeshOnEntity, c MESSAGE("LoadCellsOnEntity - isCellsLoaded = "<> aNbPoints(%d) <= anArray[%d][%d]=%d < 0 !!!",aNbPoints,iNumElem,k,anArray[k]); @@ -769,7 +827,7 @@ 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); + aMeshOnEntity2.myCellsFirstIndex[aGeom] = VISUMED::TMeshOnEntity::TIndexAndSize(aCounter,aSize); aCounter += aSize; } } @@ -778,22 +836,21 @@ int VISU_MEDConvertor::LoadCellsOnEntity(VISU::TMeshOnEntity& theMeshOnEntity, c 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; + SALOME_MED::medGeometryElement_array_var aGeoms = aMedFamily->getTypes(); + iGeomEnd = aGeoms->length(); + if(MYDEBUG) MESSAGE("LoadCellsOnEntity - iGeomEnd = "<getNumber(aGeom); + int aVGeom = MEDGeomToVTK(aGeom); + VISU::TFamily::TSubMeshOnCellType& aSubMeshOnCellType = aFamily.mySubMesh[aVGeom]; + int iNumElemEndTmp = theMeshOnEntity.myCellsConn[aVGeom].size(); + int iNumElemEnd = aCellNumForType->length(); + int aCounter = aMeshOnEntity2.myCellsFirstIndex[aGeom].first; if(MYDEBUG) - MESSAGE("LoadCellsOnEntity - medName = "< int ImportField(TArray& theArray, return 1; } -int VISU_MEDConvertor::LoadField(const VISU::TMeshOnEntity& theMeshOnEntity, - const VISU::TField& theField, VISU::TField::TValForTime& theValForTime) +int +VISU_MEDConvertor::LoadField(const VISU::TMeshOnEntity& theMeshOnEntity, + const VISU::TField& theField, + VISU::TField::TValForTime& theValForTime) { //Check on loading already done if(!theValForTime.myValForCells.empty()) return 0; diff --git a/src/VISU_I/VISU_CorbaMedConvertor.hxx b/src/VISU_I/VISU_CorbaMedConvertor.hxx index 53bd83ad..6500527f 100644 --- a/src/VISU_I/VISU_CorbaMedConvertor.hxx +++ b/src/VISU_I/VISU_CorbaMedConvertor.hxx @@ -35,10 +35,6 @@ #include -extern "C"{ -#include -} - namespace VISUMED{ struct TFamily{ SALOME_MED::FAMILY_var myFamily; diff --git a/src/VISU_I/VISU_Result_i.cc b/src/VISU_I/VISU_Result_i.cc index dc8b0903..3ca6fc27 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){ @@ -301,7 +299,6 @@ VISU::Storable* VISU::Result_i::Build(SALOMEDS::SObject_ptr theSObject) 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(), @@ -526,7 +523,7 @@ VISU::Storable* VISU::Result_i::Restore(SALOMEDS::SObject_ptr theSObject, else mySourceId = eFile; if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - mySourceId = "<