CXXFLAGS = @CXXFLAGS@
CXX_DEPEND_FLAG = @CXX_DEPEND_FLAG@
+# BOOST Library
+
+BOOST_CPPFLAGS = @BOOST_CPPFLAGS@
+
# JAVA
JAVA_INCLUDES = @JAVA_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@
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
AC_CXX_HAVE_SSTREAM
+echo
+echo ---------------------------------------------
+echo BOOST Library
+echo ---------------------------------------------
+echo
+
+CHECK_BOOST
+
dnl
dnl ---------------------------------------------
dnl testing MPICH
CHECK_HDF5
-echo
-echo ---------------------------------------------
-echo testing MED2
-echo ---------------------------------------------
-echo
-
-CHECK_MED2
-
echo
echo ---------------------------------------------
echo Testing OpenCascade
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
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@
#endif
void parseFile(const char* theFileName) {
- try{
- MESSAGE("'"<<theFileName<<"'...");
+ //try{
+ MSG(MYDEBUG,"'"<<theFileName<<"'...");
auto_ptr<VISU_Convertor> aCon(CreateConvertor(theFileName));
//aCon->GetSize();
//return;
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);
}
//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;
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;
aCon->GetMeshOnEntity(aMeshName,anEntity);
}
}
- OK:
- MESSAGE("OK");
- }catch(std::exception& exc){
- MESSAGE("Follow exception was occured in file:"<<theFileName<<"\n"<<exc.what());
- }catch(...){
- MESSAGE("Unknown exception was occured in VISU_Convertor_impl in file:"<<theFileName);
- }
+ MSG(MYDEBUG,"OK");
+ //}catch(std::exception& exc){
+ // MSG(MYDEBUG,"Follow exception was occured in file:"<<theFileName<<"\n"<<exc.what());
+ //}catch(...){
+ // MSG(MYDEBUG,"Unknown exception was occured in VISU_Convertor_impl in file:"<<theFileName);
+ //}
}
int main(int argc, char** argv){
- try{
+ //try{
if(argc > 1){
QFileInfo fi(argv[1]);
for(int i = 0; i < 1; i++){
}
return 0;
}
- }catch(std::exception& exc){
- MESSAGE("Follow exception was occured :\n"<<exc.what());
- }catch(...){
- MESSAGE("Unknown exception was occured in VISU_Convertor_impl");
- }
+ //}catch(std::exception& exc){
+ // MSG(MYDEBUG,"Follow exception was occured :\n"<<exc.what());
+ //}catch(...){
+ // MSG(MYDEBUG,"Unknown exception was occured in VISU_Convertor_impl");
+ //}
return 1;
}
#include "VISU_Convertor.hxx"
#include "VISU_ConvertorUtils.hxx"
-using namespace std;
-
-#ifdef _DEBUG_
-static int MYDEBUG = 0;
-#else
-static int MYDEBUG = 0;
-#endif
+#include <qstring.h>
-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;
pair<int,int> 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;
}
}
}
-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)
#include <stdio.h>
-#include <algorithm>
-#include <iterator>
#include <list>
#include <map>
-#include <numeric>
#include <set>
#include <utility>
#include <vector>
#include <string>
#include <stdexcept>
-#include <vtkPoints.h>
-#include <vtkSystemIncludes.h>
-#include <vtkUnstructuredGrid.h>
-#include <vtkMergeDataObjectFilter.h>
-#include <vtkFieldDataToAttributeDataFilter.h>
+#include <boost/shared_ptr.hpp>
-#include "VISU_ExtractUnstructuredGrid.hxx"
-
-#include <vtkSmartPointer.h>
+class vtkUnstructuredGrid;
namespace VISU{
+
+ template<class T> class shared_ptr: public boost::shared_ptr<T>
+ {
+ public:
+ shared_ptr() {}
+
+ template<class Y>
+ explicit shared_ptr(Y * p)
+ {
+ reset(p);
+ }
+
+ template<class Y>
+ shared_ptr(shared_ptr<Y> const & r):
+ boost::shared_ptr<T>(r,boost::detail::dynamic_cast_tag())
+ {}
+
+ template<class Y>
+ shared_ptr & operator=(shared_ptr<Y> const & r)
+ {
+ shared_ptr<T>(r).swap(*this);
+ return *this;
+ }
+
+ template<class Y> shared_ptr& operator()(Y * p) // Y must be complete
+ {
+ if(T* pt = dynamic_cast<T*>(p))
+ boost::shared_ptr<T>::reset(pt);
+ else
+ boost::throw_exception(std::bad_cast());
+ return *this;
+ }
+
+ };
+
+
enum TEntity {NODE_ENTITY, EDGE_ENTITY, FACE_ENTITY, CELL_ENTITY};
- typedef vtkSmartPointer<vtkPoints> TVTKPoints;
- typedef vtkSmartPointer<vtkUnstructuredGrid> TVTKSource;
- typedef vtkSmartPointer<vtkMergeDataObjectFilter> TVTKMergetFilter;
- typedef vtkSmartPointer<VISU_ExtractUnstructuredGrid> TVTKExtractFilter;
- typedef vtkSmartPointer<vtkFieldDataToAttributeDataFilter> TVTKAttribyteFilter;
+ typedef std::pair<std::string,TEntity> TFamilyAndEntity;
+ typedef std::set<TFamilyAndEntity> TFamilyAndEntitySet;
typedef std::set<std::string> TBindGroups;
- struct TFamily{
- TVTKSource myStorage;
- vtkIdType myId;
- std::string myName;
- TEntity myEntity;
- TBindGroups myGroups;
- vtkIdType myNbCells, myCellsSize;
- typedef std::set<vtkIdType> TSubMeshOnCellType;
- typedef std::map<vtkIdType,TSubMeshOnCellType> TSubMesh;
- TSubMesh mySubMesh;
- TFamily() : myNbCells(0), myCellsSize(0) {}
+ typedef std::pair<double,std::string> TTime;
+
+ struct TMesh;
+ typedef shared_ptr<TMesh> PMesh;
+ typedef std::map<std::string,PMesh> TMeshMap;
+
+ struct TMeshOnEntity;
+ typedef shared_ptr<TMeshOnEntity> PMeshOnEntity;
+ typedef std::map<TEntity,PMeshOnEntity> TMeshOnEntityMap;
+
+ struct TFamily;
+ typedef shared_ptr<TFamily> PFamily;
+ typedef std::map<std::string,PFamily> TFamilyMap;
+
+ struct TGroup;
+ typedef shared_ptr<TGroup> PGroup;
+ typedef std::map<std::string,PGroup> TGroupMap;
+
+ struct TField;
+ typedef shared_ptr<TField> PField;
+ typedef std::map<std::string,PField> TFieldMap;
+
+ struct TValForTime;
+ typedef shared_ptr<TValForTime> PValForTime;
+ typedef std::map<int,PValForTime> TValField;
+
+ struct TBaseStructure{
+ virtual ~TBaseStructure(){}
};
- typedef std::map<std::string,TFamily> TFamilyMap;
- struct TField{
- TVTKExtractFilter myExtractFilter;
- vtkIdType myId;
+ typedef std::vector<std::string> TNames;
+
+ struct TMesh: TBaseStructure{
+ int myDim, myNbPoints;
std::string myName;
- TEntity myEntity;
- std::string myMeshName;
- vtkIdType myNbComp, myNbValField, myDataSize, myIsTrimmed;
- typedef std::vector<float> TValForCellsWithType;
- typedef std::map<vtkIdType,TValForCellsWithType> TValForCells;
- typedef std::pair<double,std::string> TTime;
- typedef std::vector<std::string> TCompNames;
- typedef std::vector<std::string> 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<vtkIdType,TValForTime> 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<std::string,TField> TFieldMap;
-
- struct TMeshOnEntity{
- TVTKSource myStorage;
+
+ struct TMeshOnEntity: TBaseStructure{
std::string myMeshName;
TEntity myEntity;
- vtkIdType myNbCells, myCellsSize;
- typedef std::vector<vtkIdType> TConnect;
- typedef std::vector<TConnect> TConnForCellType;
- typedef std::map<vtkIdType,TConnForCellType> TCellsConn;
- TCellsConn myCellsConn;
+ int myNbCells, myCellsSize;
TFamilyMap myFamilyMap;
TFieldMap myFieldMap;
TMeshOnEntity() : myNbCells(0), myCellsSize(0) {}
- std::pair<vtkIdType,vtkIdType> GetCellsDims(const std::string& theFamilyName = "") const;
-
+
+ std::pair<int,int>
+ GetCellsDims(const std::string& theFamilyName = "") const;
};
- typedef std::map<TEntity,TMeshOnEntity> 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<std::string,TEntity> TFamilyAndEntity;
- typedef std::set<TFamilyAndEntity> 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<std::string,TGroup> 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<TCoord> TPointsCoord;
- TPointsCoord myPointsCoord;
- typedef std::vector<std::string> 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<std::string,TMesh> 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{
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) ;
};
// Author : Alexey PETROV
// Module : VISU
-#include "VISU_Convertor.hxx"
#include "VISU_ConvertorUtils.hxx"
-
-#include <vtkCellType.h>
-
-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 <vtkUnstructuredGridWriter.h>
+
+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;
- }
}
#ifndef VISU_ConvertorUtils_HeaderFile
#define VISU_ConvertorUtils_HeaderFile
-extern "C"{
-#include <med.h>
-}
-
-#include <fstream>
-#include <strstream>
#include <string>
#include <vtkCellType.h>
-#include <qstring.h>
-#include <qfileinfo.h>
-
-#ifndef MESSAGE
-#define MESSAGE(msg) std::cout<<__FILE__<<"["<<__LINE__<<"]::"<<msg<<endl
-
-#undef EXCEPT
-#define EXCEPT(msg) QString(QString(__FILE__) + "[" + QString::number(__LINE__) + "]::" + msg)
-
-#undef EXCEPTION
-#define EXCEPTION(msg) EXCEPT(msg).latin1()
+#include "MED_Utilities.hxx"
-#endif
+class vtkUnstructuredGrid;
-template<class T> 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
#include <vtkMergeDataObjectFilter.h>
-#include <vtkUnstructuredGridWriter.h>
-
#include <qstring.h>
#include <qfileinfo.h>
#include <memory>
using namespace std;
+using namespace VISU;
static float ERR_SIZE_CALC = 1.00;
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<ECoordName TheCoordId>
-VISU::TMesh::TCoord GetCoord(const VISU::TMesh::TPointsCoord& thePointsCoord,
- int theStartPos)
-{
- return thePointsCoord[theStartPos+TheCoordId];
-}
-
-template<>
-VISU::TMesh::TCoord GetCoord<eNone>(const VISU::TMesh::TPointsCoord& thePointsCoord,
- int theStartPos)
-{
- return 0.0;
-}
+namespace{
-static TGetCoord aXYZGetCoord[3] = {
- &GetCoord<eX>,
- &GetCoord<eY>,
- &GetCoord<eZ>
-};
-
-
-static TGetCoord aXYGetCoord[3] = {
- &GetCoord<eX>,
- &GetCoord<eY>,
- &GetCoord<eNone>
-};
-
-static TGetCoord aYZGetCoord[3] = {
- &GetCoord<eNone>,
- &GetCoord<eX>,
- &GetCoord<eY>
-};
-
-static TGetCoord aXZGetCoord[3] = {
- &GetCoord<eX>,
- &GetCoord<eNone>,
- &GetCoord<eY>
-};
-
-
-static TGetCoord aXGetCoord[3] = {
- &GetCoord<eX>,
- &GetCoord<eNone>,
- &GetCoord<eNone>
-};
-
-static TGetCoord aYGetCoord[3] = {
- &GetCoord<eNone>,
- &GetCoord<eX>,
- &GetCoord<eNone>
-};
-
-static TGetCoord aZGetCoord[3] = {
- &GetCoord<eNone>,
- &GetCoord<eNone>,
- &GetCoord<eX>
-};
-
-
-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<class T>
+ 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<TCoordHelper> TCoordHelperPtr;
+ enum ECoordName{eX, eY, eZ, eNone};
+ typedef VISU::TCoord (*TGetCoord)(const VISU::TMeshImpl::TPointsCoord&, int);
+
+ template<ECoordName TheCoordId>
+ VISU::TCoord
+ GetCoord(const VISU::TMeshImpl::TPointsCoord& thePointsCoord,
+ int theStartPos)
+ {
+ return thePointsCoord[theStartPos+TheCoordId];
+ }
+
+ template<>
+ VISU::TCoord
+ GetCoord<eNone>(const VISU::TMeshImpl::TPointsCoord& thePointsCoord,
+ int theStartPos)
+ {
+ return 0.0;
+ }
+
+
+ TGetCoord aXYZGetCoord[3] = {
+ &GetCoord<eX>,
+ &GetCoord<eY>,
+ &GetCoord<eZ>
+ };
+
+
+ TGetCoord aXYGetCoord[3] = {
+ &GetCoord<eX>,
+ &GetCoord<eY>,
+ &GetCoord<eNone>
+ };
+
+ TGetCoord aYZGetCoord[3] = {
+ &GetCoord<eNone>,
+ &GetCoord<eX>,
+ &GetCoord<eY>
+ };
+
+ TGetCoord aXZGetCoord[3] = {
+ &GetCoord<eX>,
+ &GetCoord<eNone>,
+ &GetCoord<eY>
+ };
+
+
+ TGetCoord aXGetCoord[3] = {
+ &GetCoord<eX>,
+ &GetCoord<eNone>,
+ &GetCoord<eNone>
+ };
+
+ TGetCoord aYGetCoord[3] = {
+ &GetCoord<eNone>,
+ &GetCoord<eX>,
+ &GetCoord<eNone>
+ };
+
+ TGetCoord aZGetCoord[3] = {
+ &GetCoord<eNone>,
+ &GetCoord<eNone>,
+ &GetCoord<eX>
+ };
-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<TCoordHelper> 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")
}
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 = "<<aNbPoints<<"; myDim = "<<theMesh.myDim);
- for (vtkIdType i = 0, j = 0; i < iEnd; i += theMesh.myDim, j++)
+ MSG(MYDEBUG,"GetPoints - aNbPoints = "<<aNbPoints<<"; myDim = "<<theMesh->myDim);
+ for (vtkIdType i = 0, j = 0; i < iEnd; i += theMesh->myDim, j++)
aPoints->SetPoint(j,
aCoordHelperPtr->GetCoord(i,eX),
aCoordHelperPtr->GetCoord(i,eY),
aCoordHelperPtr->GetCoord(i,eZ));
- theMesh.myPoints = aPoints;
+ theMesh->myPoints = aPoints;
}
theStorage->SetPoints(aPoints);
}
inline void PrintCells(int& theStartId,
vtkCellArray* theConnectivity,
- const VISU::TMeshOnEntity::TConnect& theVector)
+ const VISU::TMeshOnEntityImpl::TConnect& theVector)
{
vtkIdList *anIdList = vtkIdList::New();
int kEnd = theVector.size();
}
void GetCellsOnEntity(VISU::TVTKSource& theStorage,
- const VISU::TMeshOnEntity& theMeshOnEntity,
+ const VISU::PMeshOnEntityImpl theMeshOnEntity,
const string& theFamilyName)
{
//Check on existing family
- const VISU::TFamily* pFamily = VISU::GetFamily(theMeshOnEntity,theFamilyName);
- bool isFamilyPresent = (pFamily != NULL);
- const VISU::TFamily& aFamily = *pFamily;
+ PFamilyImpl aFamily = GetFamily(theMeshOnEntity,theFamilyName);
//Main part of code
- pair<int,int> aCellsDim = theMeshOnEntity.GetCellsDims(theFamilyName);
+ pair<int,int> aCellsDim = theMeshOnEntity->GetCellsDims(theFamilyName);
int aNbCells = aCellsDim.first, aCellsSize = aCellsDim.second;
vtkCellArray* aConnectivity = vtkCellArray::New();
aConnectivity->Allocate(aCellsSize,0);
vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
aCellTypesArray->SetNumberOfComponents(1);
aCellTypesArray->SetNumberOfTuples(aNbCells);
- if(MYDEBUG) MESSAGE("GetCellsOnEntity - isFamilyPresent = "<<isFamilyPresent);
- const VISU::TMeshOnEntity::TCellsConn &aCellsConn = theMeshOnEntity.myCellsConn;
- VISU::TMeshOnEntity::TCellsConn::const_iterator aCellsConnIter = aCellsConn.begin();
+ MSG(MYDEBUG,"GetCellsOnEntity - isFamilyPresent = "<<bool(aFamily));
+ const VISU::TMeshOnEntityImpl::TCellsConn &aCellsConn = theMeshOnEntity->myCellsConn;
+ VISU::TMeshOnEntityImpl::TCellsConn::const_iterator aCellsConnIter = aCellsConn.begin();
for(int i = 0, j = 0; 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("GetCellsOnEntity - aVtkType = "<<aVtkType<<"; anArray.size() = "<<anArray.size());
- if(!isFamilyPresent)
+ MSG(MYDEBUG,"GetCellsOnEntity - aVtkType = "<<aVtkType<<"; anArray.size() = "<<anArray.size());
+ if(!aFamily)
for(int k = 0, kEnd = anArray.size(); k < kEnd; k++, i++){
PrintCells(i,aConnectivity,anArray[k]);
aCellTypesArray->SetValue(j++,(unsigned char)aVtkType);
}
else{
- const VISU::TFamily::TSubMesh& aSubMesh = aFamily.mySubMesh;
+ const VISU::TFamilyImpl::TSubMesh& aSubMesh = aFamily->mySubMesh;
if(aSubMesh.empty())
- throw std::runtime_error(EXCEPTION("GetCells >> 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() = "<<aSubMeshOnCellType.size());
- VISU::TFamily::TSubMeshOnCellType::const_iterator aSubMeshOnCellTypeIter = aSubMeshOnCellType.begin();
+ const VISU::TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aSubMeshIter->second;
+ MSG(MYDEBUG,"GetCellsOnEntity - aSubMeshOnCellType.size() = "<<aSubMeshOnCellType.size());
+ VISU::TFamilyImpl::TSubMeshOnCellType::const_iterator aSubMeshOnCellTypeIter = aSubMeshOnCellType.begin();
for(; aSubMeshOnCellTypeIter != aSubMeshOnCellType.end(); aSubMeshOnCellTypeIter++, i++){
PrintCells(i,aConnectivity,anArray[*aSubMeshOnCellTypeIter]);
aCellTypesArray->SetValue(j++,(unsigned char)aVtkType);
void GetCellsOnGroup(VISU::TVTKSource& theStorage,
- const VISU::TMesh& theMesh,
+ VISU::PMeshImpl theMesh,
const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet)
{
//Calculate dimentions of the group
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<int,int> aCellsDim = aMeshOnEntity.GetCellsDims(aFamilyName);
+ const VISU::PMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[anEntity];
+ pair<int,int> aCellsDim = aMeshOnEntity->GetCellsDims(aFamilyName);
aNbCells += aCellsDim.first;
aCellsSize += aCellsDim.second;
}
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 = "<<aVtkType<<"; anArray.size() = "<<anArray.size());
- const VISU::TFamily::TSubMesh& aSubMesh = aFamily.mySubMesh;
+ MSG(MYDEBUG,"GetCellsOnGroup - aVtkType = "<<aVtkType<<"; anArray.size() = "<<anArray.size());
+ const VISU::TFamilyImpl::TSubMesh& aSubMesh = aFamily->mySubMesh;
if(aSubMesh.empty())
- throw std::runtime_error(EXCEPTION("GetCells >> 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() = "<<aSubMeshOnCellType.size());
- VISU::TFamily::TSubMeshOnCellType::const_iterator aSubMeshOnCellTypeIter = aSubMeshOnCellType.begin();
+ const VISU::TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aSubMeshIter->second;
+ MSG(MYDEBUG,"GetCellsOnGroup - aSubMeshOnCellType.size() = "<<aSubMeshOnCellType.size());
+ VISU::TFamilyImpl::TSubMeshOnCellType::const_iterator aSubMeshOnCellTypeIter = aSubMeshOnCellType.begin();
for(; aSubMeshOnCellTypeIter != aSubMeshOnCellType.end(); aSubMeshOnCellTypeIter++, i++){
PrintCells(i,aConnectivity,anArray[*aSubMeshOnCellTypeIter]);
aCellTypesArray->SetValue(j++,(unsigned char)aVtkType);
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())
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 = "<<theNumberOfTuples);
- const VISU::TField::TValForCells& aValForCells = theValForTime.myValForCells;
- VISU::TField::TValForCells::const_iterator aValForCellsIter = aValForCells.begin();
+ MSG(MYDEBUG,"GetValsOnTimeStamp - theNumberOfTuples = "<<theNumberOfTuples);
+ const VISU::TValForTimeImpl::TValForCells& aValForCells = theValForTime->myValForCells;
+ VISU::TValForTimeImpl::TValForCells::const_iterator aValForCellsIter = aValForCells.begin();
for(int k = 0; aValForCellsIter != aValForCells.end(); aValForCellsIter++) {
- const VISU::TField::TValForCellsWithType& anArray = aValForCellsIter->second;
- int iEnd = anArray.size()/theField.myNbComp;
+ const VISU::TValForTimeImpl::TValForCellsWithType& anArray = aValForCellsIter->second;
+ int iEnd = anArray.size()/theField->myNbComp;
int aVtkType = aValForCellsIter->first;
- if(MYDEBUG) MESSAGE("GetValsOnTimeStamp - iEnd = "<<iEnd<<"; aVtkType = "<<aVtkType);
- switch(theField.myNbComp) {
+ MSG(MYDEBUG,"GetValsOnTimeStamp - iEnd = "<<iEnd<<"; aVtkType = "<<aVtkType);
+ switch(theField->myNbComp) {
case 1:
for (int i = 0; i < iEnd; i++)
theFloatArray->SetTuple1(k++,anArray[i]);
theFloatArray->SetTuple3(k++,anArray[ji],anArray[ji+2],anArray[ji+5]);
break;
default:
- throw std::runtime_error(EXCEPTION("GetValsOnTimeStamp - There is no an algorithm for representation of the field !!!"));
+ EXCEPTION(runtime_error,"GetValsOnTimeStamp - There is no an algorithm for representation of the field !!!");
}
}
}
- string GenerateFieldName(const VISU::TField& theField,
- const VISU::TField::TValForTime& theValForTime)
+ string GenerateFieldName(const VISU::PFieldImpl theField,
+ const VISU::PValForTimeImpl theValForTime)
{
- const VISU::TField::TTime& aTime = theValForTime.myTime;
- string aFieldName = theField.myMeshName + ", " + theField.myName + ": " +
+ const VISU::TTime& aTime = theValForTime->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 = "<<aFieldName<<
- "; aNumberOfTuples = "<<aNumberOfTuples);
-
+ MSG(MYDEBUG,"GetTimeStamp(TVTKSource) - aFieldName = "<<aFieldName<<
+ "; aNumberOfTuples = "<<aNumberOfTuples);
+
vtkDataSetAttributes* aDataSetAttributes;
- switch(theField.myEntity){
+ switch(theField->myEntity){
case VISU::NODE_ENTITY :
aDataSetAttributes = theStorage->GetPointData();
break;
}
vtkFloatArray *aFloatArray = vtkFloatArray::New();
- switch(theField.myNbComp) {
+ switch(theField->myNbComp) {
case 1:
aFloatArray->SetNumberOfComponents(1);
aDataSetAttributes->SetScalars(aFloatArray);
void GetTimeStamp(VISU::TVTKAttribyteFilter& theAttribyteFilter,
VISU::TVTKMergetFilter& theMergeFilter,
VISU::TVTKExtractFilter& theExtractFilter,
- 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(TVTKAttribyteFilter) - aFieldName = "<<aFieldName<<
- "; aNumberOfTuples = "<<aNumberOfTuples);
+ MSG(MYDEBUG,"GetTimeStamp(TVTKAttribyteFilter) - aFieldName = "<<aFieldName<<
+ "; aNumberOfTuples = "<<aNumberOfTuples);
vtkDataObject* aDataObject = vtkDataObject::New();
theMergeFilter->SetDataObject(aDataObject);
theMergeFilter->SetInput(theExtractFilter->GetOutput());
theAttribyteFilter->SetInput(theMergeFilter->GetOutput());
- switch(theField.myEntity){
+ switch(theField->myEntity){
case VISU::NODE_ENTITY :
theMergeFilter->SetOutputFieldToPointDataField();
theAttribyteFilter->SetInputFieldToPointDataField();
}
vtkFloatArray *aFloatArray = vtkFloatArray::New();
- switch(theField.myNbComp) {
+ switch(theField->myNbComp) {
case 1:
aFloatArray->SetNumberOfComponents(1);
theAttribyteFilter->SetScalarComponent(0,aFieldName.c_str(),0);
const VISU::TEntity& theEntity,
const string& theFamilyName)
{
- if(MYDEBUG)
- MESSAGE("GetMeshOnEntity - theMeshName = '"<<theMeshName<<
- "'; theEntity = "<<theEntity<<"; theFamilyName = '"<<theFamilyName<<"'");
+ MSG(MYDEBUG,"GetMeshOnEntity - theMeshName = '"<<theMeshName<<
+ "'; theEntity = "<<theEntity<<"; theFamilyName = '"<<theFamilyName<<"'");
//Cheching possibility do the query
- VISU::TMesh* pMesh = NULL;
- VISU::TFamily* pFamily = NULL;
- VISU::TMeshOnEntity* pMeshOnEntity = NULL;
- FindMeshOnEntity(theMeshName,pMesh,theEntity,pMeshOnEntity,theFamilyName,pFamily);
- VISU::TMesh& aMesh = *pMesh;
- VISU::TMeshOnEntity& aMeshOnEntity = *pMeshOnEntity;
+ TFindMeshOnEntity aFindMeshOnEntity =
+ FindMeshOnEntity(theMeshName,theEntity,theFamilyName);
VISU::TVTKSource* pSource;
- if(pFamily != NULL)
- pSource = &(pFamily->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{
GetMeshOnEntitySize(theMeshName,theEntity,theFamilyName);
vtkUnstructuredGrid* aDataSet = aSource.GetPointer();
aDataSet->Update();
- MESSAGE("GetMeshOnEntity - GetPoints() = "<<float(aDataSet->GetPoints()->GetActualMemorySize()*1000));
- MESSAGE("GetMeshOnEntity - GetCells() = "<<float(aDataSet->GetCells()->GetActualMemorySize()*1000));
- MESSAGE("GetMeshOnEntity - GetCellTypesArray() = "<<float(aDataSet->GetCellTypesArray()->GetActualMemorySize()*1000));
- MESSAGE("GetMeshOnEntity - GetCellLocationsArray() = "<<float(aDataSet->GetCellLocationsArray()->GetActualMemorySize()*1000));
+ MSG(MYVTKDEBUG,"GetMeshOnEntity - GetPoints() = "<<float(aDataSet->GetPoints()->GetActualMemorySize()*1000));
+ MSG(MYVTKDEBUG,"GetMeshOnEntity - GetCells() = "<<float(aDataSet->GetCells()->GetActualMemorySize()*1000));
+ MSG(MYVTKDEBUG,"GetMeshOnEntity - GetCellTypesArray() = "<<float(aDataSet->GetCellTypesArray()->GetActualMemorySize()*1000));
+ MSG(MYVTKDEBUG,"GetMeshOnEntity - GetCellLocationsArray() = "<<float(aDataSet->GetCellLocationsArray()->GetActualMemorySize()*1000));
aDataSet->BuildLinks();
- MESSAGE("GetMeshOnEntity - GetCellLinks() = "<<float(aDataSet->GetCellLinks()->GetActualMemorySize()*1000));
- MESSAGE("GetMeshOnEntity - GetActualMemorySize() = "<<float(aDataSet->GetActualMemorySize()*1000));
+ MSG(MYVTKDEBUG,"GetMeshOnEntity - GetCellLinks() = "<<float(aDataSet->GetCellLinks()->GetActualMemorySize()*1000));
+ MSG(MYVTKDEBUG,"GetMeshOnEntity - GetActualMemorySize() = "<<float(aDataSet->GetActualMemorySize()*1000));
}
}catch(...){
aSource = vtkSmartPointerBase();
VISU_Convertor_impl::GetMeshOnGroup(const string& theMeshName,
const string& theGroupName)
{
- if(MYDEBUG) MESSAGE("GetMeshOnGroup - theMeshName = '"<<theMeshName<<
- "'; theGroupName = '"<<theGroupName<<"'");
+ MSG(MYDEBUG,"GetMeshOnGroup - theMeshName = '"<<theMeshName<<
+ "'; theGroupName = '"<<theGroupName<<"'");
//Cheching possibility do the query
- VISU::TMesh* pMesh = NULL;
- VISU::TGroup* pGroup = NULL;
- FindMeshOnGroup(theMeshName,pMesh,theGroupName,pGroup);
- VISU::TMesh& aMesh = *pMesh;
- VISU::TGroup& aGroup = *pGroup;
- const VISU::TFamilyAndEntitySet& aFamilyAndEntitySet = aGroup.myFamilyAndEntitySet;
- VISU::TVTKSource& aSource = aGroup.myStorage;
+ TFindMeshOnGroup aFindMeshOnGroup = FindMeshOnGroup(theMeshName,theGroupName);
+ PMeshImpl aMesh = boost::get<0>(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){
const string& theFieldName,
int theStampsNum)
{
- if(MYDEBUG){
- MESSAGE("GetTimeStampOnMesh - theMeshName = '"<<theMeshName<<"; theEntity = "<<theEntity);
- MESSAGE("GetTimeStampOnMesh - theFieldName = '"<<theFieldName<<"'; theStampsNum = "<<theStampsNum);
- }
+ MSG(MYDEBUG,"GetTimeStampOnMesh - theMeshName = '"<<theMeshName<<"; theEntity = "<<theEntity);
+ MSG(MYDEBUG,"GetTimeStampOnMesh - theFieldName = '"<<theFieldName<<"'; theStampsNum = "<<theStampsNum);
+
//Cheching possibility do the query
- 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);
- VISU::TMesh& aMesh = *pMesh;
- VISU::TMeshOnEntity& aMeshOnEntity = *pMeshOnEntity;
- VISU::TField& aField = *pField;
- VISU::TField::TValForTime& aValForTime = *pValForTime;
- VISU::TVTKAttribyteFilter& anAttribyteFilter = aValForTime.myAttribyteFilter;
- VISU::TVTKSource& aSource = aValForTime.myStorage;
+ TFindTimeStamp aFindTimeStamp =
+ FindTimeStamp(theMeshName,theEntity,theFieldName,theStampsNum);
+ PMeshImpl aMesh = boost::get<0>(aFindTimeStamp);
+ PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindTimeStamp);
+ PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindTimeStamp);
+ PValForTimeImpl aValForTime = boost::get<4>(aFindTimeStamp);
+ PFieldImpl aField = boost::get<3>(aFindTimeStamp);
+
+ VISU::TVTKAttribyteFilter& anAttribyteFilter = aValForTime->myAttribyteFilter;
+ VISU::TVTKSource& aSource = aValForTime->myStorage;
TOutput* anOutput = NULL;
//Main part of code
try{
else{
LoadFieldOnMesh(aMesh,aMeshOnEntity,aField,aValForTime);
- VISU::TVTKExtractFilter& anExtractFilter = aField.myExtractFilter;
+ VISU::TVTKExtractFilter& anExtractFilter = aField->myExtractFilter;
if(anExtractFilter.GetPointer() == NULL){
anExtractFilter = VISU_ExtractUnstructuredGrid::New();
anExtractFilter->Delete();
//anExtractFilter->DebugOn();
try{
- LoadMeshOnEntity(*pVTKMeshOnEntity);
+ LoadMeshOnEntity(aVTKMeshOnEntity);
}catch(std::exception& exc){
- pVTKMeshOnEntity = pMeshOnEntity;
- MESSAGE("Follow exception was occured :\n"<<exc.what());
+ aVTKMeshOnEntity = aMeshOnEntity;
+ MSG(MYDEBUG,"Follow exception was occured :\n"<<exc.what());
}catch(...){
- pVTKMeshOnEntity = pMeshOnEntity;
- MESSAGE("Unknown exception was occured!");
+ aVTKMeshOnEntity = aMeshOnEntity;
+ MSG(MYDEBUG,"Unknown exception was occured!");
}
- GetMeshOnEntity(pVTKMeshOnEntity->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){
vtkUnstructuredGrid *aDataSet = anAttribyteFilter->GetUnstructuredGridOutput();
aDataSet->Update();
if(theEntity == VISU::NODE_ENTITY)
- MESSAGE("GetTimeStampOnMesh - GetData() = "<<float(aDataSet->GetPointData()->GetActualMemorySize()*1000));
+ MSG(MYVTKDEBUG,"GetTimeStampOnMesh - GetData() = "<<float(aDataSet->GetPointData()->GetActualMemorySize()*1000));
else
- MESSAGE("GetMeshOnEntity - GetData() = "<<float(aDataSet->GetCellData()->GetActualMemorySize()*1000));
- MESSAGE("GetTimeStampOnMesh - GetActualMemorySize() = "<<float(aDataSet->GetActualMemorySize()*1000));
+ MSG(MYVTKDEBUG,"GetMeshOnEntity - GetData() = "<<float(aDataSet->GetCellData()->GetActualMemorySize()*1000));
+ MSG(MYVTKDEBUG,"GetTimeStampOnMesh - GetActualMemorySize() = "<<float(aDataSet->GetActualMemorySize()*1000));
}
}
}catch(...){
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 - '"<<theMeshName<<"'!!!");
+
+ PMeshImpl aMesh = aMeshMapIter->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 - "<<theEntity<<"!!!");
+
+ PMeshOnEntityImpl aMeshOnEntity = aMeshOnEntityMapIter->second;
+
+ return TFindMeshOnEntity(aMesh,
+ aMeshOnEntityMap[theEntity],
+ GetFamily(aMeshOnEntity,theFamilyName));
}
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;
aResult += GetMeshOnEntitySize(aMeshName,anEntity);
}
}
- if(MYDEBUG)
- MESSAGE("GetSize - aResult = "<<float(aResult));
+ MSG(MYDEBUG,"GetSize - aResult = "<<float(aResult));
return aResult;
}
const VISU::TEntity& theEntity,
const std::string& theFamilyName)
{
- VISU::TMesh* pMesh = NULL;
- VISU::TFamily* pFamily = NULL;
- VISU::TMeshOnEntity* pMeshOnEntity = NULL;
- FindMeshOnEntity(theMeshName,pMesh,theEntity,pMeshOnEntity,theFamilyName,pFamily);
- vtkIdType aPointsSize = 3*pMesh->myNbPoints*sizeof(VISU::TMesh::TCoord);
+ TFindMeshOnEntity aFindMeshOnEntity =
+ FindMeshOnEntity(theMeshName,theEntity,theFamilyName);
+ PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);
+ PFamilyImpl aFamily = boost::get<2>(aFindMeshOnEntity);
+ PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity);
+
+ vtkIdType aPointsSize = 3*aMesh->myNbPoints*sizeof(VISU::TCoord);
vtkIdType aNbCells, aCellsSize;
- if(!pFamily){
- aNbCells = pMeshOnEntity->myNbCells;
- aCellsSize = pMeshOnEntity->myCellsSize;
+
+ if(!aFamily){
+ aNbCells = aMeshOnEntity->myNbCells;
+ aCellsSize = aMeshOnEntity->myCellsSize;
}else{
- aNbCells = pFamily->myNbCells;
- aCellsSize = pFamily->myCellsSize;
+ aNbCells = aFamily->myNbCells;
+ aCellsSize = aFamily->myCellsSize;
}
+
vtkIdType aConnectivitySize = aCellsSize*sizeof(vtkIdType);
vtkIdType aTypesSize = aNbCells*sizeof(char);
vtkIdType aLocationsSize = aNbCells*sizeof(int);
float aNbCellsPerPoint = aCellsSize / aNbCells - 1;
- vtkIdType aLinksSize = pMesh->myNbPoints *
+ vtkIdType aLinksSize = aMesh->myNbPoints *
(vtkIdType(sizeof(vtkIdType)*aNbCellsPerPoint) + sizeof(vtkCellLinks::Link));
aLinksSize = 0;
vtkIdType aResult = aPointsSize + aConnectivitySize + aTypesSize + aLocationsSize + aLinksSize;
if(MYDEBUG){
- if(MYVTKDEBUG){
- MESSAGE("GetMeshOnEntitySize - aPointsSize = "<<float(aPointsSize));
- MESSAGE("GetMeshOnEntitySize - aConnectivitySize = "<<float(aConnectivitySize));
- MESSAGE("GetMeshOnEntitySize - aTypesSize = "<<float(aTypesSize));
- MESSAGE("GetMeshOnEntitySize - aLocationsSize = "<<float(aLocationsSize));
- MESSAGE("GetMeshOnEntitySize - aLinksSize = "<<float(aLinksSize));
- }
- MESSAGE("GetMeshOnEntitySize - aResult = "<<float(aResult)<<"; theMeshName = '"<<theMeshName<<
- "'; theEntity = "<<theEntity<<"; theFamilyName = '"<<theFamilyName<<"'");
+ MSG(MYVTKDEBUG,"GetMeshOnEntitySize - aPointsSize = "<<float(aPointsSize));
+ MSG(MYVTKDEBUG,"GetMeshOnEntitySize - aConnectivitySize = "<<float(aConnectivitySize));
+ MSG(MYVTKDEBUG,"GetMeshOnEntitySize - aTypesSize = "<<float(aTypesSize));
+ MSG(MYVTKDEBUG,"GetMeshOnEntitySize - aLocationsSize = "<<float(aLocationsSize));
+ MSG(MYVTKDEBUG,"GetMeshOnEntitySize - aLinksSize = "<<float(aLinksSize));
}
+ MSG(MYDEBUG,"GetMeshOnEntitySize - aResult = "<<float(aResult)<<"; theMeshName = '"<<theMeshName<<
+ "'; theEntity = "<<theEntity<<"; theFamilyName = '"<<theFamilyName<<"'");
+
aResult = vtkIdType(aResult*ERR_SIZE_CALC);
return aResult;
}
-void VISU_Convertor_impl::FindMeshOnGroup(const std::string& theMeshName, VISU::TMesh*& theMesh,
- const std::string& theGroupName, VISU::TGroup*& theGroup)
+VISU_Convertor_impl::TFindMeshOnGroup
+VISU_Convertor_impl::FindMeshOnGroup(const std::string& theMeshName,
+ const std::string& theGroupName)
{
- FindMesh(theMeshName,theMesh);
- VISU::TGroupMap& aGroupMap = theMesh->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!!! - '"<<theGroupName<<"'");
+
+ VISU::PGroupImpl aGroup = aGroupMapIter->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 = "<<float(aPointsSize));
- MESSAGE("GetMeshOnGroupSize - aConnectivityAndTypesSize = "<<float(aConnectivityAndTypesSize));
- MESSAGE("GetMeshOnGroupSize - aLocationsSize = "<<float(aLocationsSize));
- MESSAGE("GetMeshOnGroupSize - aLinksSize = "<<float(aLinksSize));
- }
- MESSAGE("GetMeshOnGroupSize - aResult = "<<float(aResult)<<"; theMeshName = '"
- <<theMeshName<<"'; theGroupName = '"<<theGroupName<<"'");
+ MSG(MYVTKDEBUG,"GetMeshOnGroupSize - aPointsSize = "<<float(aPointsSize));
+ MSG(MYVTKDEBUG,"GetMeshOnGroupSize - aConnectivityAndTypesSize = "<<float(aConnectivityAndTypesSize));
+ MSG(MYVTKDEBUG,"GetMeshOnGroupSize - aLocationsSize = "<<float(aLocationsSize));
+ MSG(MYVTKDEBUG,"GetMeshOnGroupSize - aLinksSize = "<<float(aLinksSize));
}
+ MSG(MYDEBUG,"GetMeshOnGroupSize - aResult = "<<float(aResult)<<"; theMeshName = '"
+ <<theMeshName<<"'; theGroupName = '"<<theGroupName<<"'");
+
aResult = vtkIdType(aResult*ERR_SIZE_CALC);
return aResult;
}
-
-void VISU_Convertor_impl::FindField(const string& theMeshName, VISU::TMesh*& theMesh,
- const VISU::TEntity& theEntity,
- VISU::TMeshOnEntity*& theMeshOnEntity,
- VISU::TMeshOnEntity*& theVTKMeshOnEntity,
- const string& theFieldName, VISU::TField*& theField)
+VISU_Convertor_impl::TFindField
+VISU_Convertor_impl::FindField(const string& theMeshName,
+ const VISU::TEntity& theEntity,
+ const string& theFieldName)
{
- VISU::TFamily* pFamily = NULL;
- VISU::TMeshOnEntity* pMeshOnEntity = NULL;
- FindMeshOnEntity(theMeshName,theMesh,theEntity,pMeshOnEntity,"",pFamily);
- theMeshOnEntity = pMeshOnEntity;
- VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->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);
}
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 = "<<float(aFieldOnMeshSize));
- MESSAGE("GetFieldOnMeshSize - aResult = "<<float(aResult)<<"; theMeshName = '"<<theMeshName<<
- "'; theEntity = "<<theEntity<<"; theFieldName = '"<<theFieldName<<"'");
- }
+ if(MYDEBUG)
+ MSG(MYVTKDEBUG,"GetFieldOnMeshSize - aFieldOnMeshSize = "<<float(aFieldOnMeshSize));
+ MSG(MYDEBUG,"GetFieldOnMeshSize - aResult = "<<float(aResult)<<"; theMeshName = '"<<theMeshName<<
+ "'; theEntity = "<<theEntity<<"; theFieldName = '"<<theFieldName<<"'");
+
return aResult;
}
-void VISU_Convertor_impl::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_Convertor_impl::TFindTimeStamp
+VISU_Convertor_impl::FindTimeStamp(const std::string& theMeshName,
+ const VISU::TEntity& theEntity,
+ const std::string& theFieldName,
+ int theStampsNum)
{
- FindField(theMeshName,theMesh,theEntity,theMeshOnEntity,theVTKMeshOnEntity,theFieldName,theField);
- VISU::TField::TValField& aValField = theField->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);
}
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 = "<<float(aTimeStampSize));
- MESSAGE("GetTimeStampSize - aResult = "<<float(aResult)<<"; theMeshName = '"<<theMeshName<<"'; theEntity = "<<theEntity<<
- "; theFieldName = '"<<theFieldName<<"'; theStampsNum = "<<theStampsNum);
- }
+
+ MSG(MYDEBUG && MYVTKDEBUG,"GetTimeStampSize - aTimeStampSize = "<<float(aTimeStampSize));
+ MSG(MYDEBUG,"GetTimeStampSize - aResult = "<<float(aResult)<<
+ "; theMeshName = '"<<theMeshName<<"'; theEntity = "<<theEntity<<
+ "; theFieldName = '"<<theFieldName<<"'; theStampsNum = "<<theStampsNum);
+
return aResult;
}
-const VISU::TField&
+const VISU::PField
VISU_Convertor_impl::GetField(const string& theMeshName,
VISU::TEntity theEntity,
const string& theFieldName)
{
- VISU::TMesh* pMesh = NULL;
- VISU::TField* pField = NULL;
- VISU::TFamily* pFamily = NULL;
- VISU::TMeshOnEntity *pMeshOnEntity = NULL, *pVTKMeshOnEntity = NULL;
- FindField(theMeshName,pMesh,theEntity,pMeshOnEntity,pVTKMeshOnEntity,
- theFieldName,pField);
- return *pField;
+ TFindField aFindField = FindField(theMeshName,theEntity,theFieldName);
+ PField aField = boost::get<3>(aFindField);
+ return aField;
}
-const VISU::TField::TValForTime&
+const VISU::PValForTime
VISU_Convertor_impl::GetTimeStamp(const std::string& theMeshName,
const VISU::TEntity& theEntity,
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);
- return *pValForTime;
+ TFindTimeStamp aFindTimeStamp =
+ FindTimeStamp(theMeshName,theEntity,theFieldName,theStampsNum);
+ PValForTime aValForTime = boost::get<4>(aFindTimeStamp);
+ return aValForTime;
}
-
-
#include "VISU_Convertor.hxx"
-extern "C"{
-#include <med.h>
-}
+#include <vtkSystemIncludes.h>
+
+#include <vtkPoints.h>
+#include <vtkUnstructuredGrid.h>
+#include <vtkMergeDataObjectFilter.h>
+#include <vtkFieldDataToAttributeDataFilter.h>
+#include "VISU_ExtractUnstructuredGrid.hxx"
#include <qstring.h>
#include <qfileinfo.h>
+#include <vtkSmartPointer.h>
+
+#include <boost/tuple/tuple.hpp>
+
+namespace VISU{
+
+ typedef vtkSmartPointer<vtkPoints> TVTKPoints;
+ typedef vtkSmartPointer<vtkUnstructuredGrid> TVTKSource;
+ typedef vtkSmartPointer<vtkMergeDataObjectFilter> TVTKMergetFilter;
+ typedef vtkSmartPointer<VISU_ExtractUnstructuredGrid> TVTKExtractFilter;
+ typedef vtkSmartPointer<vtkFieldDataToAttributeDataFilter> TVTKAttribyteFilter;
+
+ typedef float TCoord;
+
+ struct TMeshImpl: TMesh{
+ TVTKPoints myPoints;
+
+ typedef std::vector<TCoord> TPointsCoord;
+ TPointsCoord myPointsCoord;
+
+ typedef std::vector<std::string> TPointsDim;
+ TPointsDim myPointsDim;
+ };
+ typedef shared_ptr<TMeshImpl> PMeshImpl;
+
+ struct TMeshOnEntityImpl: TMeshOnEntity{
+ TVTKSource myStorage;
+ typedef std::vector<vtkIdType> TConnect;
+ typedef std::vector<TConnect> TConnForCellType;
+ typedef std::map<vtkIdType,TConnForCellType> TCellsConn;
+ TCellsConn myCellsConn;
+ };
+ typedef shared_ptr<TMeshOnEntityImpl> PMeshOnEntityImpl;
+
+ struct TFamilyImpl: TFamily{
+ TVTKSource myStorage;
+
+ typedef std::set<vtkIdType> TSubMeshOnCellType;
+ typedef std::map<vtkIdType,TSubMeshOnCellType> TSubMesh;
+ TSubMesh mySubMesh;
+ };
+ typedef shared_ptr<TFamilyImpl> PFamilyImpl;
+
+ struct TGroupImpl: TGroup{
+ TVTKSource myStorage;
+ };
+ typedef shared_ptr<TGroupImpl> PGroupImpl;
+
+ struct TFieldImpl: TField{
+ TVTKExtractFilter myExtractFilter;
+ ~TFieldImpl()
+ {
+ if(myExtractFilter.GetPointer())
+ myExtractFilter->UnRegisterAllOutputs();
+ }
+ };
+ typedef shared_ptr<TFieldImpl> PFieldImpl;
+
+ struct TValForTimeImpl: TValForTime{
+ TVTKAttribyteFilter myAttribyteFilter;
+ TVTKMergetFilter myMergeFilter;
+ TVTKSource myStorage;
+
+ typedef std::vector<float> TValForCellsWithType;
+ typedef std::map<vtkIdType,TValForCellsWithType> TValForCells;
+ TValForCells myValForCells;
+
+ ~TValForTimeImpl()
+ {
+ if(myMergeFilter.GetPointer())
+ myMergeFilter->UnRegisterAllOutputs();
+ if(myAttribyteFilter.GetPointer())
+ myAttribyteFilter->UnRegisterAllOutputs();
+ }
+ };
+ typedef shared_ptr<TValForTimeImpl> 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();
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<VISU::PMeshImpl,VISU::PMeshOnEntityImpl,VISU::PFamilyImpl> TFindMeshOnEntity;
+ TFindMeshOnEntity
+ FindMeshOnEntity(const std::string& theMeshName,
+ const VISU::TEntity& theEntity,
+ const std::string& theFamilyName);
+
+ typedef boost::tuple<VISU::PMeshImpl,VISU::PGroupImpl> TFindMeshOnGroup;
+ TFindMeshOnGroup
+ FindMeshOnGroup(const std::string& theMeshName,
+ const std::string& theGroupName);
+
+ typedef boost::tuple<VISU::PMeshImpl,
+ VISU::PMeshOnEntityImpl,
+ VISU::PMeshOnEntityImpl,
+ VISU::PFieldImpl> TFindField;
+ TFindField
+ FindField(const std::string& theMeshName,
+ const VISU::TEntity& theEntity,
+ const std::string& theFieldName);
+
+ typedef boost::tuple<VISU::PMeshImpl,
+ VISU::PMeshOnEntityImpl,
+ VISU::PMeshOnEntityImpl,
+ VISU::PFieldImpl,
+ VISU::PValForTimeImpl> 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
+++ /dev/null
-// 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<int> 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<int>* pCellsType)
-{
- /*
- ifstream &stmIn = *pStmIn;
- vector<int>& 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 = "<<aField.myMeshName<<"; myNbComp = "<<aField.myNbComp);
- for(int i = 0, tmp; i < iEnd; i++) {
- stmIn>>tmp;
- VISU::TField::TTime aTime(0.0,"");
- VISU::TField::TValForCellsWithType &anArray = aField.myValField[aTime][aCellsType[i]];
- for(int j = 0; j < aField.myNbComp; j++){
- float tmp; stmIn>>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 = "<<iEnd);
- vector<float> &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<int>* pCellsType)
-{
- /*
- ifstream &stmIn = *pStmIn;
- vector<int>& 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 - "<<theFileName);
- if(!myIsDone && Build() != NULL) myIsDone = true;
- ofstream stmOut(theFileName.c_str(),ios::out);
- stmOut.precision(PRECISION);
- stmOut.setf(ios::scientific,ios::floatfield);
-
- VISU::TMeshMap::const_iterator aMeshIter = myMeshMap.begin();
- if(aMeshIter != myMeshMap.end()){
- const VISU::TMesh &aMesh = aMeshIter->second;
- if(MYDEBUG) MESSAGE("VISU_Convertor_impl::ToDatFile - aMeshName = "<<aMeshIter->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<<aNbPoints<<"\t"<<aNbCells<<"\t"<<aFieldMap.size()<<endl;
- if(MYDEBUG)
- MESSAGE("VISU_Convertor_impl::ToDatFile - aNbPoints = "<<aNbPoints<<
- "; aNbCells = "<<aNbCells<<"; aNbFields = "<<aFieldMap.size());
- for(int i = 0, j = 0; i < aNbPoints; i++, j = 3*i){
- stmOut<<(i+1)<<"\t";
- stmOut<<aMesh.myPointsCoord[j]<<"\t";
- stmOut<<aMesh.myPointsCoord[j+1]<<"\t";
- stmOut<<aMesh.myPointsCoord[j+2]<<endl;
- }
- const VISU::TMeshOnEntity::TCellsConn &aCellsConn = aMeshOnEntity.myCellsConn;
- VISU::TMeshOnEntity::TCellsConn::const_iterator iter = aCellsConn.begin();
- for(int i = 0; iter != aCellsConn.end(); iter++){
- if(MYDEBUG)
- MESSAGE("VISU_Convertor_impl::ToDatFile - vtkCellType = "<<iter->first);
- const VISU::TMeshOnEntity::TConnForCellType& anArray = iter->second;
- for(int j = 0, jEnd = anArray.size(); j < jEnd; j++){
- stmOut<<(++i)<<"\t";
- stmOut<<vtk2medCellType(iter->first)<<"\t";
- const vector<int>& aVector = anArray[j];
- int kEnd = aVector.size();
- for(int k = 0; k < kEnd; k++)
- stmOut<<aVector[k]<<"\t";
- stmOut<<endl;
- }
- }
- if(MYDEBUG) MESSAGE("VISU_Convertor_impl::ToDatFile - Beginning of Field Conversion");
- VISU::TFieldMap::const_iterator aFieldIter = aFieldMap.begin();
- for(int i = 0; aFieldIter != aFieldMap.end(); aFieldIter++){
- const VISU::TField &aField = aFieldIter->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 = "<<i);
- const VISU::TField::TValForTime& aValForTime = iter->second;
- VISU::TField::TValForTime::const_iterator jter = aValForTime.begin();
- stmOut<<(++i)<<endl;
- int prefix = (aField.myEntity == VISU::CELL_ENTITY? 100: 200);
- int jEnd = (aField.myEntity == VISU::CELL_ENTITY? aNbCells: aNbPoints);
- string aName = GenerateName((aFieldIter->first).c_str(),i);
- stmOut<<aName<<endl;
- stmOut<<(prefix + aField.myNbComp)<<"\t"<<jEnd<<endl;
- if(MYDEBUG)
- MESSAGE("VISU_Convertor_impl::ToDatFile - aName = "<<aName<<"; jEnd = "<<jEnd);
- for(int j = 0; jter != aValForTime.end(); jter++) {
- const VISU::TField::TValForCellsWithType& anArray = jter->second;
- int kEnd = anArray.size(), aVtkType = jter->first;
- switch(aField.myNbComp) {
- case 1:
- for (int k = 0; k < kEnd;) {
- stmOut<<(++j)<<"\t";
- stmOut<<anArray[k++]<<"\n";
- }
- break;
- case 2:
- for (int k = 0; k < kEnd;){
- stmOut<<(++j)<<"\t";
- stmOut<<anArray[k++]<<"\t";
- stmOut<<anArray[k++]<<"\t";
- stmOut<<0.0<<"\n";
- }
- break;
- case 3:
- for (int k = 0; k < kEnd;){
- stmOut<<(++j)<<"\t";
- stmOut<<anArray[k++]<<"\t";
- stmOut<<anArray[k++]<<"\t";
- stmOut<<anArray[k++]<<"\n";
- }
- break;
- }
- }
- }
- }
- }
- }
- return 1;
-}
-*/
+++ /dev/null
-// Copyright (C) 2003 CEA/DEN, EDF R&D
-//
-//
-//
-// File : VISU_DatConvertor.hxx
-// Author : Alexey PETROV
-// Module : VISU
-
-#ifndef VISU_DatConvertor_HeaderFile
-#define VISU_DatConvertor_HeaderFile
-
-#include "VISU_Convertor_impl.hxx"
-#include <fstream>
-
-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<int>* aCellsType) ;
-
- int ImportField(ifstream*, int theNbPoints, vector<int>* 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
vtkUnstructuredGrid *anInput = this->GetInput(), *anOutput = this->GetOutput();
vtkIdType aNbCells = anInput->GetNumberOfCells();
anOutput->Allocate(aNbCells);
- if(MYDEBUG) MESSAGE("Execute - anInput->GetNumberOfCells() = "<<anInput->GetNumberOfCells());
+ MSG(MYDEBUG,"Execute - anInput->GetNumberOfCells() = "<<anInput->GetNumberOfCells());
vtkIdList *aCellIds = vtkIdList::New();
- if(MYDEBUG)
- MESSAGE("Execute - myRemovedCellIds.empty() = "<<myRemovedCellIds.empty()<<
- "; myRemovedCellTypes.empty() = "<<myRemovedCellTypes.empty());
+ MSG(MYDEBUG,"Execute - myRemovedCellIds.empty() = "<<myRemovedCellIds.empty()<<
+ "; myRemovedCellTypes.empty() = "<<myRemovedCellTypes.empty());
if(myRemovedCellIds.empty() && myRemovedCellTypes.empty())
anOutput->CopyStructure(anInput);
else if(!myRemovedCellIds.empty() && myRemovedCellTypes.empty()){
InsertCell(anInput,anOutput,aCellId,aCellIds);
aCellIds->Delete();
anOutput->SetPoints(anInput->GetPoints());
- if(MYDEBUG) MESSAGE("Execute - anOutput->GetNumberOfCells() = "<<anOutput->GetNumberOfCells());
+ MSG(MYDEBUG,"Execute - anOutput->GetNumberOfCells() = "<<anOutput->GetNumberOfCells());
}
#include "VISU_MedConvertor.hxx"
+#include "VISU_Convertor.hxx"
#include "VISU_ConvertorUtils.hxx"
-#include <valarray>
-#include <vtkCellType.h>
+#include "MED_Factory.hxx"
+#include "MED_Algorithm.hxx"
+#include "MED_Utilities.hxx"
-#define USER_INTERLACE MED_FULL_INTERLACE
+#include <vtkCellType.h>
#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<VISU::TEntity,med_entite_maillage> 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 = "<<iMeshEnd<<"; myFileInfo = "<<myFileInfo.filePath());
- for(int iMesh = 1; iMesh <= iMeshEnd; iMesh++){
- med_int aMeshDim;
- char aMeshName[MED_TAILLE_NOM+1] = "";
- MEDmaaInfo(fid,iMesh,aMeshName,&aMeshDim);
- if(MYDEBUG) MESSAGE("ImportInfo - aMeshName = '"<<aMeshName<<"'; aMeshDim = "<<aMeshDim);
- VISU::TMesh &aMesh = myMeshMap[aMeshName];
- aMesh.myDim = aMeshDim;
- aMesh.myName = aMeshName;
- typedef map<med_int,VISU::TEntity> TFamily2EntityMap;
- TFamily2EntityMap aFamily2EntityMap;
- typedef map<med_int,med_int> TFamilyCounterMap;
+ PWrapper aMed = CrWrapper(myFileInfo.absFilePath().latin1());
+ TInt aNbMeshes = aMed->GetNbMeshes();
+ TMeshMap& aMeshMap = myMeshMap;
+
+ MSG(MYDEBUG,"VISU_MedConvertor::Build()");
+ INITMSG(MYDEBUG,"GetNbMeshes() = "<<aNbMeshes<<"\n");
+
+ for(TInt iMesh = 1; iMesh <= aNbMeshes; iMesh++){
+
+ PMeshInfo aMeshInfo = aMed->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<TInt,TInt> 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 = "<<anEntity<<
- "; medName = "<<med2vtk[medId].medName<<
- "; myNbCells = "<<aMeshOnEntity.myNbCells<<
- "; myCellsSize = "<<aMeshOnEntity.myCellsSize);
- med_booleen iname_elem, inum_elem;
- valarray<med_int> num_elem(iNumElemEnd), num_fam_elem(iNumElemEnd);
- valarray<char> name_elem('\0',iNumElemEnd*MED_TAILLE_PNOM+1);
- med_repere rep;
- valarray<char> name_coord('\0',aMesh.myDim*MED_TAILLE_PNOM+1);
- valarray<char> unit_coord('\0',aMesh.myDim*MED_TAILLE_PNOM+1);
- valarray<med_float> coord(aMesh.myDim*iNumElemEnd);
- ret = MEDnoeudsLire(fid,aMeshName,aMesh.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("ImportInfo >> 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 = '"<<aMeshName<<
+ "'; myNbPoints = "<<aMesh->myNbPoints<<
+ "; aDim = "<<aDim<<"\n");
+
+ BEGMSG(MYDEBUG,"aEntityInfo.size() = "<<aEntityInfo.size()<<"\n");
+
+ TMeshOnEntityMap& aMeshOnEntityMap = aMesh->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 = "<<aMEntity<<"; aVEntity = "<<aVEntity<<"\n");
+
+ if(aMEntity == eNOEUD){
+ aMeshOnEntity->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<med_int> num_elem(iNumElemEnd), num_fam_elem(iNumElemEnd);
- valarray<char> 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 = "<<anEntity<<
- "; medName = "<<med2vtk[medId].medName<<
- "; aNbConnForElem = "<<aNbConnForElem<<
- "; myNbCells = "<<aMeshOnEntity.myNbCells<<
- "; myCellsSize = "<<aMeshOnEntity.myCellsSize);
- valarray<med_int> conn(0,aNbConnForElem*iNumElemEnd);
- ret = MEDelementsLire(fid,aMeshName,aMesh.myDim,&conn[0],MED_FULL_INTERLACE,
- &name_elem[0],&iname_elem,&num_elem[0],&inum_elem,
- &num_fam_elem[0],iNumElemEnd,aMedEntity,aMedType,MED_NOD);
- if (ret < 0) throw std::runtime_error(EXCEPTION("ImportInfo >> 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 = "<<aMeshOnEntity->myNbCells<<
+ "; myCellsSize = "<<aMeshOnEntity->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 = "<<aGeom<<"; aNbElem = "<<aNbElem<<
+ "; myNbCells = "<<aMeshOnEntity->myNbCells<<
+ "; myCellsSize = "<<aMeshOnEntity->myCellsSize<<"\n");
+
+ for(TInt iElem = 0; iElem < aMesh->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 = "<<aNbFamily);
- for(int aFamInd = 1; aFamInd <= aNbFamily; aFamInd++){
- med_int aNbAttrib = MEDnFam(fid,aMeshName,aFamInd,MED_ATTR);
- valarray<med_int> anAttId(aNbAttrib), anAttVal(aNbAttrib);
- valarray<char> anAttDesc('\0',aNbAttrib*MED_TAILLE_DESC+1);
- med_int aNbGroup = MEDnFam(fid,aMeshName,aFamInd,MED_GROUPE);
- if(0 && MYDEBUG)
- MESSAGE("ImportInfo - aFamInd = "<<aFamInd<<"; aNbAttrib = "<<aNbAttrib<<"; aNbGroup = "<<aNbGroup);
- valarray<char> aGroupNames('\0',aNbGroup*MED_TAILLE_LNOM+1);
- char aFamilyName[MED_TAILLE_NOM+1] = "";
- med_int aFamilyNum;
- ret = MEDfamInfo(fid,aMeshName,aFamInd,aFamilyName,&aFamilyNum,
- &anAttId[0],&anAttVal[0],&anAttDesc[0],&aNbAttrib,
- &aGroupNames[0],&aNbGroup);
- if(ret < 0) throw std::runtime_error(EXCEPTION("ImportInfo >> MEDfamInfo"));
- if(0 && MYDEBUG)
- MESSAGE("ImportInfo - aFamilyNum = "<<aFamilyNum<<"; aNbGroup = "<<aNbGroup);
- if(aFamily2EntityMap.find(aFamilyNum) == aFamily2EntityMap.end()) {
- if(MYDEBUG) MESSAGE("ImportInfo - a Family with name '"<<aFamilyName<<"' are empty !!!");
- continue;
- }
- VISU::TEntity anEntity = aFamily2EntityMap[aFamilyNum];
- VISU::TMeshOnEntity& aMeshOnEntity = aMesh.myMeshOnEntityMap[anEntity];
- VISU::TFamily& aFamily = aMeshOnEntity.myFamilyMap[aFamilyName];
- aFamily.myName = aFamilyName;
- aFamily.myEntity = anEntity;
- aFamily.myId = aFamilyNum;
- aFamily.myNbCells = aFamilyNbCellsCounterMap[aFamilyNum];
- aFamily.myCellsSize = aFamilyCellsSizeCounterMap[aFamilyNum];
- if(MYDEBUG)
- MESSAGE("ImportInfo - aFamily.myEntity = "<<anEntity<<
- "; myName = '"<<aFamilyName<<
- "'; myId = "<<aFamilyNum<<
- "; myNbCells = "<<aFamily.myNbCells<<
- "; myCellsSize = "<<aFamily.myCellsSize);
- VISU::TBindGroups& aBindGroups = aFamily.myGroups;
- for(int iGroup = 0, iPos = 0; iGroup < aNbGroup; iGroup++, iPos += MED_TAILLE_LNOM){
- char aGroupName[MED_TAILLE_LNOM+1];
- strncpy(aGroupName,&aGroupNames[iPos],MED_TAILLE_LNOM);
- aGroupName[MED_TAILLE_LNOM] = '\0';
- if(MYDEBUG) MESSAGE("ImportInfo - aGroupName["<<iGroup<<"] = '"<<aGroupName<<"'");
- aBindGroups.insert(aGroupName);
- }
- }
- //Calculation 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;
- 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 = "<<aMEntity<<"; aVEntity = "<<aVEntity<<"\n");
+ TFamilyGroup::const_iterator aFamilyGroupIter = aFamilyGroup.begin();
+ for(; aFamilyGroupIter != aFamilyGroup.end(); aFamilyGroupIter++){
+ const PFamilyInfo& aFamilyInfo = *aFamilyGroupIter;
+ if (aFamilyInfo->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 = '"<<aFamily->myName<<
+ "'; myId = "<<aFamily->myId<<"; "<<
+ "; aNbAttr = "<<aFamilyInfo->GetNbAttr()<<
+ "; aNbGroup = "<<aFamilyInfo->GetNbGroup()<<
+ "; myEntity = "<<aFamily->myEntity<<
+ "; myNbCells = "<<aFamily->myNbCells<<
+ "; myCellsSize = "<<aFamily->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 = '"<<aGroupName<<"'\n");
}
}
}
- //Displaing information for the TMesh.TGroupMap
- VISU::TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin();
- if(MYDEBUG) MESSAGE("ImportInfo - aGroupMap.size() = "<<aGroupMap.size());
- for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){
- const VISU::TGroup& aCGroup = aGroupMapIter->second;
- const string& aGroupName = aGroupMapIter->first;
- if(MYDEBUG) MESSAGE("ImportInfo - aGroupName = '"<<aGroupName<<
- "'; myNbCells = "<<aCGroup.myNbCells<<
- "; myCellsSize = "<<aCGroup.myCellsSize);
- const VISU::TGroup& aGroup = aGroupMapIter->second;
- const VISU::TFamilyAndEntitySet& aFamilyAndEntitySet = aGroup.myFamilyAndEntitySet;
- VISU::TFamilyAndEntitySet::const_iterator aFamilyAndEntitySetIter = aFamilyAndEntitySet.begin();
- for(; aFamilyAndEntitySetIter != aFamilyAndEntitySet.end(); aFamilyAndEntitySetIter++){
- const string& aFamilyName = aFamilyAndEntitySetIter->first;
- if(MYDEBUG) MESSAGE("ImportInfo - \t aFamilyName = '"<<aFamilyName<<"'");
- }
- }
- }
- //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 = "<<iFieldEnd);
- for(med_int iField = 1; iField <= iFieldEnd; iField++){
- med_int ncomp = MEDnChamp(fid,iField);
- if(ncomp < 0) throw std::runtime_error(EXCEPTION("ImportChamps >> MEDnChamp(fid,i)"));
- valarray<char> aCompNames('\0',ncomp*MED_TAILLE_PNOM + 1);
- valarray<char> 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 = '"<<name_field<<
- "'; myMeshName = '"<<aMeshName<<
- "'; myEntity = "<<anEntity<<
- "; myNbComp = "<<ncomp<<
- "; myDataSize = "<<aField.myDataSize);
- for(int iComp = 0, iPos = 0; iComp < ncomp; iComp++, iPos += MED_TAILLE_PNOM){
- char aCompName[MED_TAILLE_PNOM+1], aUnitName[MED_TAILLE_PNOM+1];
- strncpy(aCompName,&aCompNames[iPos],MED_TAILLE_PNOM);
- aCompName[MED_TAILLE_PNOM] = '\0';
- aField.myCompNames[iComp] = aCompName;
- strncpy(aUnitName,&aUnitNames[iPos],MED_TAILLE_PNOM);
- aUnitName[MED_TAILLE_PNOM] = '\0';
- aField.myUnitNames[iComp] = aUnitName;
- if(MYDEBUG)
- MESSAGE("ImportInfo - aCompName = '"<<aCompName<<"'; aUnitName = '"<<aUnitName<<"'");
+
+ BEGMSG(MYDEBUG,"VISU::TGroup:\n");
+
+ VISU::TGroupMap& aGroupMap = aMesh->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 = '"<<aGroup->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 = "<<dt<<", "<<dt_unit);
}
}
+ exit_lable:
+ if(aFamily && aVEntity >= 0){
+ aGroup->myFamilyAndEntitySet.insert(TFamilyAndEntity(aFamilyName,aVEntity));
+ INITMSG(MYDEBUG,"aFamilyName = '"<<aFamilyName<<"'; aVEntity = "<<aVEntity<<"\n");
+
+ aGroup->myNbCells += aFamily->myNbCells;
+ aGroup->myCellsSize += aFamily->myCellsSize;
+ }
+ }
+ if(!aGroup->myFamilyAndEntitySet.empty() && aGroup->myNbCells > 0){
+ BEGMSG(MYDEBUG,"myNbCells = "<<aGroup->myNbCells<<
+ "; myCellsSize = "<<aGroup->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 = '"<<aField->myName<<
+ "'; myId = "<<aField->myId<<
+ "; myEntity = "<<aField->myEntity<<
+ "; myDataSize = "<<aField->myDataSize<<
+ "; myNbComp = "<<aField->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 = "<<aDt<<", "<<anUnitDt<<"\n");
}
}
}
+
return this;
}
-int VISU_MedConvertor::LoadMeshOnEntity(VISU::TMeshOnEntity& theMeshOnEntity,
+int VISU_MedConvertor::LoadMeshOnEntity(VISU::PMeshOnEntityImpl theMeshOnEntity,
const string& theFamilyName)
{
- //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
- const string& aMeshName = theMeshOnEntity.myMeshName;
- const VISU::TEntity& anEntity = theMeshOnEntity.myEntity;
- VISU::TMesh& aMesh = myMeshMap[aMeshName];
+ PWrapper aMed = CrWrapper(myFileInfo.absFilePath().latin1());
+ const string& aMeshName = theMeshOnEntity->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 = "<<isPointsLoaded<<"; theFamilyName = '"<<theFamilyName<<"'");
+ if(!aFamily)
+ return 0;
+ else if(!aFamily->mySubMesh.empty())
+ return 0;
+
+ INITMSG(MYDEBUG,"LoadPoints - isPointsLoaded = "<<isPointsLoaded<<"; theFamilyName = '"<<theFamilyName<<"'\n");
+
//Main part of code
- char aMeshName[MED_TAILLE_NOM+1] = "";
- strcpy(aMeshName,theMesh.myName.c_str());
- med_geometrie_element typgeo = (med_geometrie_element)0; //MED_POINT1
- med_connectivite typco = (med_connectivite)0; //MED_NOD
- med_int iNumElemEnd = MEDnEntMaa(fid,aMeshName,MED_COOR,MED_NOEUD,typgeo,typco);
- if (iNumElemEnd <= 0) throw std::runtime_error(EXCEPTION("LoadPoints >> MEDnEntMaa(...)"));
- if(MYDEBUG) MESSAGE("LoadPoints - iNumElemEnd = "<<iNumElemEnd);
- med_repere rep;
- med_booleen iname_elem, inum_elem;
- valarray<med_int> num_elem(iNumElemEnd), num_fam_elem(iNumElemEnd);
- valarray<char> name_elem('\0',iNumElemEnd*MED_TAILLE_PNOM+1);
- valarray<char> name_coord('\0',theMesh.myDim*MED_TAILLE_PNOM+1);
- valarray<char> unit_coord('\0',theMesh.myDim*MED_TAILLE_PNOM+1);
- valarray<med_float> 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 = "<<inum_elem);
- inum_elem = MED_FAUX; // It is workaround
- if(inum_elem == MED_FAUX)
- for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++)
- for(int iDim = 0, iNumElem2Dim = iNumElem*theMesh.myDim; iDim < theMesh.myDim; iDim++, iNumElem2Dim++)
- aPointsCoord[iNumElem2Dim] = coord[iNumElem2Dim];
- else
- for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++)
- for(int iDim = 0, iNumElem2Dim = iNumElem*theMesh.myDim; iDim < theMesh.myDim; iDim++, iNumElem2Dim++)
- aPointsCoord[num_elem[iNumElem2Dim]] = coord[iNumElem2Dim];
- if(MYDEBUG) MESSAGE("LoadPoints - Filling aMeshOnEntity with type NODE_ENTITY");
- 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);
+ VISU::TMeshImpl::TPointsCoord& aPointsCoord = theMesh->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 = '"<<theFamilyName<<"'");
- MESSAGE("LoadCellsOnEntity - isCellsLoaded = "<<isCellsLoaded<<"; isFamilyPresent = "<<isFamilyPresent);
- }
- //Main part of code
- int iGeomElemEnd;
- med_geometrie_element* aGeomElemVector;
- const VISU::TEntity& anEntity = theMeshOnEntity.myEntity;
- GetEntity2Geom(anEntity,aGeomElemVector,&iGeomElemEnd);
- const med_entite_maillage& aMedEntity = aVisu2MedEntity[anEntity];
- char aMeshName[MED_TAILLE_NOM+1] = "";
- strcpy(aMeshName,theMeshOnEntity.myMeshName.c_str());
- if(MYDEBUG)
- MESSAGE("LoadCellsOnEntity - theMeshOnEntity.myEntity = "<<theMeshOnEntity.myEntity<<
- "; iGeomElemEnd = "<<iGeomElemEnd<<"; theFamilyName = '"<<theFamilyName<<"'");
- VISU::TMesh &aMesh = myMeshMap[theMeshOnEntity.myMeshName];
- int aNbPoints = aMesh.myPointsCoord.size()/aMesh.myDim;
- valarray<med_int> 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 = "<<inum_node);
+ if(!aFamily)
+ return 0;
+ else if(!aFamily->mySubMesh.empty())
+ return 0;
+
+ INITMSG(MYDEBUG,"LoadCellsOnEntity - theFamilyName = '"<<theFamilyName<<"'\n");
+ BEGMSG(MYDEBUG,"LoadCellsOnEntity - isCellsLoaded = "<<isCellsLoaded<<"; isFamilyPresent = "<<bool(aFamily)<<endl);
+
+ const VISU::TEntity& aVEntity = theMeshOnEntity->myEntity;
+ const EEntiteMaillage& aMEntity = VTKEntityToMED(aVEntity);
+
+ const PMeshInfo& aMeshInfo = theMesh->myMeshInfo;
+ PNodeInfo aNodeInfo = theMed->GetPNodeInfo(aMeshInfo);
+ TInt aNbPoints = aNodeInfo->GetNbElem();
+
+ std::map<TInt,TInt> aNodeIdMap;
#ifdef _EDF_NODE_IDS_
- inum_node = MED_FAUX;
+ EBooleen anIsNodeNum = eFAUX;
+#else
+ EBooleen anIsNodeNum = aNodeInfo->IsElemNum();
+ if(anIsNodeNum){
+ for(TInt i = 0; i < aNbPoints; i++){
+ aNodeIdMap[aNodeInfo->GetElemNum(i)-1] = i;
+ }
+ }
#endif
- map<med_int,med_int> node_map;
- if(inum_node)
- for(int i = 0; i < aNbPoints; i++)
- node_map[num_node[i]-1] = i;
- for (int iGeomElem = 0; iGeomElem < iGeomElemEnd; iGeomElem++) {
- int medId = getIdMedType(aGeomElemVector[iGeomElem]);
- int nbMedNodes = med2vtk[medId].medNbNodes;
- int nbVtkNodes = med2vtk[medId].vtkNbNodes;
- int aVtkType = med2vtk[medId].vtkType;
- med_geometrie_element aMedType = med2vtk[medId].medType;
- med_int iNumElemEnd = MEDnEntMaa(fid,aMeshName,MED_CONN,aMedEntity,aMedType,MED_NOD);
- if (iNumElemEnd > 0) {
- med_booleen iname_elem, inum_elem;
- valarray<med_int> num_elem(iNumElemEnd), num_fam_elem(iNumElemEnd);
- valarray<char> name_elem('\0',iNumElemEnd*MED_TAILLE_PNOM+1);
- med_int aNbConnForElem = getNbMedConnect(aMedType,anEntity,aMesh.myDim);
- if(MYDEBUG) MESSAGE("LoadCellsOnEntity - medName = "<<med2vtk[medId].medName<<
- "; iNumElemEnd = "<<iNumElemEnd<<"; aNbConnForElem = "<<aNbConnForElem);
- valarray<med_int> conn(aNbConnForElem*iNumElemEnd);
- ret = MEDelementsLire(fid,aMeshName,aMesh.myDim,&conn[0],MED_FULL_INTERLACE,
- &name_elem[0],&iname_elem,&num_elem[0],&inum_elem,
- &num_fam_elem[0],iNumElemEnd,aMedEntity,aMedType,MED_NOD);
- if (ret < 0) throw std::runtime_error(EXCEPTION("LoadCellsOnEntity >> MEDelementsLire(...)"));
- if(!isCellsLoaded){
- VISU::TMeshOnEntity::TConnForCellType& aConnForCellType = theMeshOnEntity.myCellsConn[aVtkType];
- aConnForCellType.resize(iNumElemEnd);
- valarray<med_int> 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<TInt> 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("<<aNbPoints<<") "<<
+ "<= anArray["<<iElem<<"]"<<
+ "["<<iNode<<"]"<<
+ "("<<anArray[iNode]<<") < 0");
+ }
+ }
+ //Filling aFamily SubMesh
+ if(aFamily){
+ VISU::TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aFamily->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<char> comp('\0',ncomp*MED_TAILLE_PNOM + 1);
- valarray<char> 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 = '"<<aMeshName<<"' aFieldName = '"<<aFieldName<<"'; anEntity = "<<anEntity);
- MESSAGE("LoadField - iGeomElemEnd = "<<iGeomElemEnd<<"; ncomp = "<<ncomp<<"; type_field = "<<type_field);
- }
- for (int iGeomElem = 0; iGeomElem < iGeomElemEnd; iGeomElem++) {
- const med_geometrie_element& aGeom = aGeomElemVector[iGeomElem];
- med_int iTimeStampEnd = MEDnPasdetemps(fid,aFieldName,aMedEntity,aGeom);
- //Checking for accordance between the mesh and the field data
- med_int iNumElemEnd = 0;
- if(aMedEntity == MED_NOEUD)
- iNumElemEnd = MEDnEntMaa(fid,aMeshName,MED_COOR,MED_NOEUD,med_geometrie_element(0),med_connectivite(0));
- else
- iNumElemEnd = MEDnEntMaa(fid,aMeshName,MED_CONN,aMedEntity,aGeom,MED_NOD);
- int medId = getIdMedType(aGeomElemVector[iGeomElem]);
- int aVtkType = med2vtk[medId].vtkType;
- if(iTimeStampEnd <= 0){
- if(iNumElemEnd > 0){
- if(!theField.myIsTrimmed){
- theField.myIsTrimmed = true;
- theField.myDataSize -= iNumElemEnd*theField.myNbComp;
- }
- //throw std::runtime_error(EXCEPT("VISU_MedConvertor::LoadField - There is no the data "
- // "for cells with type %1 of the mesh !!!").
- // arg(med2vtk[medId].medName).latin1());
- }
+ const std::string& aMeshName = theMeshOnEntity->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 = '"<<aMeshName<<
+ "'; aFieldName = '"<<aFieldInfo->GetName()<<
+ "'; aMEntity = "<<aMEntity<<
+ "; anId = "<<theValForTime->myId<<endl);
+ BEGMSG(MYDEBUG,"LoadField - aNbComp = "<<aNbComp<<
+ "; aNbGauss = "<<aNbGauss<<endl);
+
+ const MED::TGeom& anEntityTGeom = theMeshOnEntity->myGeom;
+ MED::TGeom::const_iterator aTGeomIter = anEntityTGeom.begin();
+ for(; aTGeomIter != anEntityTGeom.end(); aTGeomIter++){
+ const EGeometrieElement& aGeom = aTGeomIter->first;
+ const TInt& aNbElem = aTGeomIter->second;
+
+ INITMSG(MYDEBUG,"LoadField - aGeom = "<<aGeom<<"; aNbElem = '"<<aNbElem<<endl);
+
+ if(aTGeom.find(aGeom) == aTGeom.end()){
+ theField->myDataSize -= aNbElem*theField->myNbComp;
+ theField->myIsTrimmed = true;
}else{
- med_int ngauss = 0, numdt = 0, numo = 0;
- char dt_unit[MED_TAILLE_PNOM+1] = "";
- med_float dt = 0;
- ret = MEDpasdetempsInfo(fid,aFieldName,aMedEntity,aGeom,theValForTime.myId,
- aMeshName,&ngauss,&numdt,dt_unit,&dt,&numo);
- if(ret < 0) throw std::runtime_error(EXCEPTION("LoadField >> MEDpasdetempsInfo(...)"));
- med_int nval = MEDnVal(fid,aFieldName,aMedEntity,aGeom,numdt,numo);
- if(nval <= 0) throw std::runtime_error(EXCEPTION("LoadField >> MEDnVal(...) - nval <= 0"));
- else{
- //Checking for accordance between the mesh and the field data
- if(iNumElemEnd <= 0)
- throw std::runtime_error(EXCEPTION("LoadField - There is no the geom. elem. on the mesh !!!"));
- static int aMaxNbGaussPts = 52; // the workaround for broken files
- if(ngauss > aMaxNbGaussPts) ngauss = 1;
- if(iNumElemEnd*ngauss != nval)
- throw std::runtime_error(EXCEPT("LoadField - Size of values (%1) and size of mesh (%2) not equal !!!").
- arg(nval).arg(iNumElemEnd*ngauss).latin1());
- VISU::TField::TValForCellsWithType &anArray = theValForTime.myValForCells[aVtkType];
- int jEnd = theField.myNbComp*nval;
- int kEnd = jEnd/ngauss;
- anArray.resize(kEnd);
- char pflname[MED_TAILLE_NOM + 1] = "";
- switch(type_field){
- case MED_REEL64 : {
- valarray<med_float> valr(jEnd);
- ret = MEDchampLire(fid,aMeshName,aFieldName,(unsigned char*)&valr[0],MED_FULL_INTERLACE,MED_ALL,
- pflname,aMedEntity,aGeom,numdt,numo);
- if(ret < 0) throw std::runtime_error(EXCEPTION("LoadField >> MEDchampLire(...)"));
- for (med_int k = 0, j = 0; k < kEnd; k++, j += ngauss){
- for (med_int iGauss = 0; iGauss < ngauss; iGauss++)
- anArray[k] = valr[j+iGauss];
- anArray[k] /= ngauss;
+ int aVTKGeomType = MEDGeomToVTK(aGeom);
+ VISU::TValForTimeImpl::TValForCellsWithType& anArray = theValForTime->myValForCells[aVTKGeomType];
+ anArray.resize(aNbComp*aNbElem);
+ for(TInt iElem = 0, anId = 0; iElem < aNbElem; iElem++){
+ for(TInt iComp = 0; iComp < aNbComp; iComp++, anId++){
+ for(TInt iGauss = 0; iGauss < aNbGauss; iGauss++){
+ anArray[anId] += aTimeStampVal->GetVal(aGeom,iElem,iComp,iGauss);
}
- break;
- }
- //case MED_INT64 : //valarray<long long> valr(jEnd);
- case MED_INT32 : //valarray<long int> valr(jEnd);
- case MED_INT : {
- valarray<med_int> valr(jEnd);
- ret = MEDchampLire(fid,aMeshName,aFieldName,(unsigned char*)&valr[0],MED_FULL_INTERLACE,MED_ALL,
- pflname,aMedEntity,aGeom,numdt,numo);
- if(ret < 0) throw std::runtime_error(EXCEPTION("LoadField >> MEDchampLire(...)"));
- for (med_int k = 0, j = 0; k < kEnd; k++, j += ngauss){
- for (med_int iGauss = 0; iGauss < ngauss; iGauss++)
- anArray[k] = valr[j+iGauss];
- anArray[k] /= ngauss;
- }
- break;
- }
- default :
- throw std::runtime_error(EXCEPTION("LoadField >> Value of med_type_champ for the field is wrong !!!"));
+ anArray[anId] /= aNbGauss;
}
- if(MYDEBUG) MESSAGE("LoadField - aGeom = "<<aGeom<<"; nval = "<<nval<<"; ngauss = "<<ngauss
- <<"; iTimeStampEnd = "<<iTimeStampEnd<<"; pflname = '"<<pflname<<"'");
}
}
}
#include "VISU_Convertor_impl.hxx"
-extern "C"{
-#include <med.h>
-}
+#include "MED_Common.hxx"
+
+namespace VISU{
+
+ struct TMEDMesh: TMeshImpl{
+ MED::PMeshInfo myMeshInfo;
+ MED::TEntityInfo myEntityInfo;
+ };
+ typedef shared_ptr<TMEDMesh> PMEDMesh;
+
+ struct TMEDMeshOnEntity: TMeshOnEntityImpl{
+ MED::TGeom myGeom;
+ };
+ typedef shared_ptr<TMEDMeshOnEntity> PMEDMeshOnEntity;
+
+ struct TMEDFamily: TFamilyImpl{
+ };
+ typedef shared_ptr<TMEDFamily> PMEDFamily;
+
+ struct TMEDGroup: TGroupImpl{
+ };
+ typedef shared_ptr<TMEDGroup> PMEDGroup;
+
+ struct TMEDField: TFieldImpl{
+ };
+ typedef shared_ptr<TMEDField> PMEDField;
+
+ struct TMEDValForTime: TValForTimeImpl{
+ };
+ typedef shared_ptr<TMEDValForTime> PMEDValForTime;
+
+}
class VISU_MedConvertor: public VISU_Convertor_impl{
VISU_MedConvertor();
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
#ifdef _DEBUG_
static int MYDEBUG = 1;
-static int MYDEBUGWITHFILES = 0;
#else
static int MYDEBUG = 0;
-static int MYDEBUGWITHFILES = 0;
#endif
//=======================================================================
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(){
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);
}
virtual void SetRepresentation(int theMode);
-
virtual bool IsShrunkable() { return myIsShrinkable;}
virtual bool IsShrunk() { return myIsShrunk;}
virtual void SetShrink();
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();
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(){
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
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;
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);
SALOMEDS.idl \
SALOME_ModuleCatalog.idl \
SALOME_Component.idl \
- SALOMEDS_Attributes.idl \
+ SALOMEDS_Attributes.idl \
SALOME_Comm.idl
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@
msgstr "OK"
msgid "VISU_WARNING"
-msgstr "Visu Warning"
+msgstr "Post-Pro Warning"
msgid "WARNING"
msgstr "Warning"
//VRV: porting on Qt 3.0.5
#include <qmessagebox.h>
-#include <med.h>
#include CORBA_CLIENT_HEADER(MED_Gen)
#include <vtkActor.h>
#ifdef _DEBUG_
static int MYDEBUG = 0;
-static int MYDEBUGWITHFILES = 0;
#else
static int MYDEBUG = 0;
-static int MYDEBUGWITHFILES = 0;
#endif
class CustomItem : public QCustomMenuItem
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();
case 54:
{
QMenuData* pp;
- QMenuItem* item = parent->menuBar()->findItem(theCommandID,&pp);
bool check = !pp->isItemChecked(theCommandID);
pp->setItemChecked(theCommandID,check);
switch(theCommandID){
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() );
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<VISU::Result_i*>(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<VISU::Result_i*>(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();
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<VISU::Result_i*>(aBase)){
+ if(dynamic_cast<VISU::Result_i*>(aBase)){
try{
//APO - aResult->GetInput()->ToFile(aFile.latin1());
QAD_Application::getDesktop()->putInfo(aFile+" exported.");
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();
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 =
# 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 \
-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 =
// Copyright (C) 2003 CEA/DEN, EDF R&D
#include "VISU_CorbaMedConvertor.hxx"
-#include "VISU_ConvertorUtils.hxx"
-#include <valarray>
#include <vtkCellType.h>
-using namespace VISU;
+#include <boost/tuple/tuple.hpp>
+
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) {
}
}
-typedef map<VISU::TEntity,SALOME_MED::medEntityMesh> TVisu2MedEntity;
-static TVisu2MedEntity aVisu2MedEntity;
-typedef map<SALOME_MED::medEntityMesh,VISU::TEntity> 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 = "<<theEntity);
- for (int iGeomElem = 0, aCounter = 0; iGeomElem < iGeomElemEnd; iGeomElem++) {
- int medId = GetIdMEDType(aGeomElemVector[iGeomElem]);
- SALOME_MED::medGeometryElement aMedType = salome_med2vtk[medId].medType;
- med_int iNumElemEnd = theMEDMesh->getNumberOfElements(aMedEntity,aMedType);
- if(iNumElemEnd > 0){
- if(MYDEBUG) MESSAGE("GetCellsSize - iNumElemEnd = "<<iNumElemEnd);
- theNbCells += iNumElemEnd;
- theCellsSize += iNumElemEnd*(salome_med2vtk[medId].vtkNbNodes + 1);
+
+ int MEDGeomToVTK(medGeometryElement theMEDGeomType)
+ {
+ switch(theMEDGeomType){
+ case MED_NONE: return VTK_EMPTY_CELL;
+ case MED_POINT1: return VTK_VERTEX;
+ case MED_SEG2: return VTK_LINE;
+ case MED_SEG3: return VTK_LINE;
+ case MED_TRIA3: return VTK_TRIANGLE;
+ case MED_TRIA6: return VTK_TRIANGLE;
+ case MED_QUAD4: return VTK_QUAD;
+ case MED_QUAD8: return VTK_QUAD;
+ case MED_TETRA4: return VTK_TETRA;
+ case MED_TETRA10: return VTK_TETRA;
+ case MED_HEXA8: return VTK_HEXAHEDRON;
+ case MED_HEXA20: return VTK_HEXAHEDRON;
+ case MED_PENTA6: return VTK_WEDGE;
+ case MED_PENTA15: return VTK_WEDGE;
+ case MED_PYRA5: return VTK_PYRAMID;
+ case MED_PYRA13: return VTK_PYRAMID;
}
+ return -1;
}
-}
-
-
-static void GetCellsSize(vtkIdType& theNbCells, vtkIdType& theCellsSize,
- SALOME_MED::FAMILY_ptr theMEDFamily)
-{
- SALOME_MED::medGeometryElement_array_var aGeom = theMEDFamily->getTypes();
- med_int iGeomElemEnd = aGeom->length();
- theNbCells = theCellsSize = 0;
- if(MYDEBUG) MESSAGE("GetCellsSize - iGeomElemEnd = "<<iGeomElemEnd);
- for (int iGeomElem = 0; iGeomElem < iGeomElemEnd; iGeomElem++) {
- SALOME_MED::medGeometryElement aGeomType = aGeom[iGeomElem];
- SALOME_MED::long_array_var aCellNumForType = theMEDFamily->getNumber(aGeomType);
- int medId = GetIdMEDType(aGeomType);
- med_int iNumElemEnd = aCellNumForType->length();
- if(iNumElemEnd > 0){
- if(MYDEBUG) MESSAGE("GetCellsSize - iNumElemEnd = "<<iNumElemEnd);
- theNbCells += iNumElemEnd;
- theCellsSize += iNumElemEnd*(salome_med2vtk[medId].vtkNbNodes + 1);
+
+ 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 void GetCellsSize(VISU::TMesh& theMesh,
- SALOME_MED::MESH_ptr theMEDMesh,
- const VISU::TEntity& theEntity)
-{
- VISU::TMeshOnEntity& aMeshOnEntity = theMesh.myMeshOnEntityMap[theEntity];
- if(theEntity == VISU::NODE_ENTITY){
- theMesh.myNbPoints = theMEDMesh->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 = "<<theVEntity);
+ for(int iGeom = 0; iGeom < iGeomEnd; iGeom++){
+ medGeometryElement aMEDGeom = aGeomElems[iGeom];
+ int iNumElemEnd = theMEDMesh->getNumberOfElements(aMEntity,aMEDGeom);
+ if(iNumElemEnd > 0){
+ if(MYDEBUG) MESSAGE("GetCellsSize - iNumElemEnd = "<<iNumElemEnd);
+ theCellsSize += iNumElemEnd*(MEDGeom2NbNodes(aMEDGeom) + 1);
+ theNbCells += iNumElemEnd;
+ }
+ }
+ }
+
+
+ void
+ GetCellsSize(vtkIdType& theNbCells, vtkIdType& theCellsSize,
+ SALOME_MED::FAMILY_ptr theMEDFamily)
+ {
+ medGeometryElement_array_var aGeom = theMEDFamily->getTypes();
+ int iGeomEnd = aGeom->length();
+ theNbCells = theCellsSize = 0;
+ if(MYDEBUG) MESSAGE("GetCellsSize - iGeomEnd = "<<iGeomEnd);
+ for(int iGeom = 0; iGeom < iGeomEnd; iGeom++) {
+ medGeometryElement aMEDGeom = aGeom[iGeom];
+ long_array_var aCellNumForType = theMEDFamily->getNumber(aMEDGeom);
+ int iNumElemEnd = aCellNumForType->length();
+ if(iNumElemEnd > 0){
+ if(MYDEBUG) MESSAGE("GetCellsSize - iNumElemEnd = "<<iNumElemEnd);
+ theNbCells += iNumElemEnd;
+ theCellsSize += iNumElemEnd*(MEDGeom2NbNodes(aMEDGeom) + 1);
+ }
+ }
+ }
+
+
+ void
+ GetCellsSize(VISU::PCMesh theMesh,
+ SALOME_MED::MESH_ptr theMEDMesh,
+ const VISU::TEntity& theEntity)
+ {
+ TMeshOnEntityMap& aMeshOnEntityMap = theMesh->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 = "<<aMeshName<<"; myDim = "<<aMesh.myDim);
-
- 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 = myField->getOrderNumber();
- aField.myName = aFieldName.in();
- aField.myEntity = anEntity;
- aField.myMeshName = aMeshName.in();
- aField.myNbComp = myField->getNumberOfComponents();
- aField.myNbValField = 1;
- aField.myDataSize = aMeshOnEntity.myNbCells * aField.myNbComp;
- aField.myCompNames.resize(aField.myNbComp);
- aField.myUnitNames.resize(aField.myNbComp);
- if(MYDEBUG) MESSAGE("VISU_MEDFieldConvertor::Build - aMeshName = "<<aMeshName<<"; myDim = "<<aMesh.myDim);
- int iTimeStamp = myField->getIterationNumber();
- VISU::TField::TValForTime& aValForTime = aField.myValField[iTimeStamp];
- aValForTime.myId = iTimeStamp;
- double dt = myField->getTime();
- aValForTime.myTime = VISU::TField::TTime(dt,"");
-
- VISUMED::TField& aField2 = aMeshOnEntity2.myFieldMap[aFieldName.in()];
- VISUMED::TField::TValForTime& aValForTime2 = aField2.myValField[iTimeStamp];
- aValForTime2.myField = myField;
+ PCMesh aMesh = myMeshMap[aMeshName.in()](new TCMesh());
+ aMesh->myDim = aMEDMesh->getSpaceDimension();
+ aMesh->myPointsDim.resize(aMesh->myDim);
+ aMesh->myName = aMeshName.in();
+ aMesh->myMesh = aMEDMesh;
+
+ if(MYDEBUG) MESSAGE("VISU_MEDFieldConvertor::Build - aMeshName = "<<aMeshName<<"; myDim = "<<aMesh->myDim);
+
+ TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
+ PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMap[aVEntity](new TCMeshOnEntity());
+ aMeshOnEntity->myEntity = aVEntity;
+ aMeshOnEntity->myMeshName = aMeshName.in();
+ aMeshOnEntity->mySupport = aMEDSupport;
+
+ if(aVEntity == NODE_ENTITY){
+ PCMeshOnEntity aMeshOnEntity2 = aMeshOnEntityMap[CELL_ENTITY](new TCMeshOnEntity());
+ *aMeshOnEntity2 = *aMeshOnEntity;
+ aMeshOnEntity->myEntity = CELL_ENTITY;
+ GetCellsSize(aMesh,aMEDMesh,CELL_ENTITY);
+ }else{
+ PCMeshOnEntity aMeshOnEntity2 = aMeshOnEntityMap[NODE_ENTITY](new TCMeshOnEntity());
+ *aMeshOnEntity2 = *aMeshOnEntity;
+ aMeshOnEntity->myEntity = NODE_ENTITY;
+ GetCellsSize(aMesh,aMEDMesh,NODE_ENTITY);
+ }
+ GetCellsSize(aMesh,aMEDMesh,aVEntity);
+
+ TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
+ PCField aField = aFieldMap[aFieldName.in()](new TCField());
+ aField->myId = myField->getOrderNumber();
+ aField->myName = aFieldName.in();
+ aField->myEntity = aVEntity;
+ aField->myMeshName = aMeshName.in();
+ aField->myNbComp = myField->getNumberOfComponents();
+ aField->myDataSize = aMeshOnEntity->myNbCells * aField->myNbComp;
+ aField->myCompNames.resize(aField->myNbComp);
+ aField->myUnitNames.resize(aField->myNbComp);
+
+ if(MYDEBUG) MESSAGE("VISU_MEDFieldConvertor::Build - aMeshName = "<<aMeshName<<"; myDim = "<<aMesh->myDim);
+
+ TValField& aValField = aField->myValField;
+ int anId = myField->getIterationNumber();
+ PCValForTime aValForTime = aValField[anId](new TCValForTime());
+ aValForTime->myId = anId;
+ CORBA::Double aDT = myField->getTime();
+ aValForTime->myTime = TTime(aDT,"");
+ aValForTime->myField = myField;
+
if(MYDEBUG)
- MESSAGE("VISU_MEDFieldConvertor::Build - aFieldName = '"<<aFieldName<<"'; myId = "<<aField.myId<<"; myTime = "<<dt);
+ MESSAGE("VISU_MEDFieldConvertor::Build - aFieldName = '"<<aFieldName<<
+ "'; myId = "<<anId<<"; myTime = "<<aDT);
+
return this;
}
-VISU_Convertor* VISU_MEDConvertor::Build() {
+
+VISU_Convertor*
+VISU_MEDConvertor::Build()
+{
if(mySObject->_is_nil())
throw std::runtime_error("VISU_MEDConvertor::Build >> 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);
return Build(aTimeStampIterator);
}
+namespace{
+
+ using namespace boost;
+
+ struct TSObjectByName{
+ std::string myName;
+ typedef tuple<SALOMEDS::SObject_var> 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<SALOME_MED::MESH_var,SALOMEDS::SObject_var> 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>
+ 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 = "<<aNbMeshes);
+
SALOMEDS::Study_var aStudy = mySObject->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 = "<<aMeshName<<"; myDim = "<<aMesh.myDim);
- SALOMEDS::ChildIterator_var aSupportIterator = aStudy->NewChildIterator(aMeshSObj);
- for(; aSupportIterator->More(); aSupportIterator->Next()){
- SALOMEDS::SObject_var aSupportSObj = aSupportIterator->Value();
- CORBA::Object_var aMedSupport = 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];
- CORBA::String_var aSupportName = aMEDSupport->getName();
- if(aMEDSupport->isOnAllElements()){
- if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - Support isOnAllElements = '"<<aSupportName<<"' anEntity = "<<anEntity);
- int aNbCells, aCellsSize;
- //Check, if there is any data on the support?
- if(anEntity == VISU::NODE_ENTITY){
- aMesh.myNbPoints = aMeshOnSupport->getNumberOfNodes();
- aNbCells = aMesh.myNbPoints;
- aCellsSize = 2*aMesh.myNbPoints;
- }else{
- GetCellsSize(aNbCells,aCellsSize,aMeshOnSupport,anEntity);
+ SALOMEDS::SObject_var aMedCompSObj = mySObject->GetFather();
+
+ bool anIsSuccess = false;
+ TSObjectByName::TRet aSObjectByNameRet =
+ Find(aMedCompSObj,aStudy,TSObjectByName("MEDMESH"),anIsSuccess);
+ if(anIsSuccess){
+ SALOMEDS::SObject_var aMeshesSObj = boost::get<0>(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 = "<<aMeshName<<"; myDim = "<<aMesh->myDim);
+
+ anIsSuccess = false;
+ std::ostringstream aStream;
+ aStream<<"MEDSUPPORTS_OF_"<<aMeshName.in();
+ std::string aSupportsName(aStream.str());
+ TSObjectByName::TRet aSObjectByNameRet =
+ Find(aMeshesSObj,aStudy,TSObjectByName(aSupportsName.c_str()),anIsSuccess);
+ if(!anIsSuccess)
+ continue;
+
+ TMeshOnEntityMap& aMeshOnEntityMap = aMesh->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 = '"<<aSupportName<<"' aVEntity = "<<aVEntity);
+ int aNbCells, aCellsSize;
+ //Check, if there is any data on the support?
+ if(aVEntity == NODE_ENTITY){
+ aMesh->myNbPoints = aMeshOnSupport->getNumberOfNodes();
+ aNbCells = aMesh->myNbPoints;
+ aCellsSize = 2*aMesh->myNbPoints;
+ }else
+ GetCellsSize(aNbCells,aCellsSize,aMeshOnSupport,aVEntity);
+
+ if(aNbCells > 0){
+ PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMap[aVEntity](new TCMeshOnEntity());
+ aMeshOnEntity->myMeshName = aMeshName.in();
+ aMeshOnEntity->myEntity = aVEntity;
+ aMeshOnEntity->myNbCells = aNbCells;
+ aMeshOnEntity->myCellsSize = aCellsSize;
+ aMeshOnEntity->mySupport = aMEDSupport;
+ }
}
- if(aNbCells == 0) continue;
- VISU::TMeshOnEntity& aMeshOnEntity = aMesh.myMeshOnEntityMap[anEntity];
- aMeshOnEntity.myMeshName = aMeshName.in();
- aMeshOnEntity.myEntity = anEntity;
- aMeshOnEntity.myNbCells = aNbCells;
- aMeshOnEntity.myCellsSize = aCellsSize;
+ }
+
+ // Fill all Family
+ 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();
- VISUMED::TMeshOnEntity& aMeshOnEntity2 = aMesh2.myMeshOnEntityMap[anEntity];
- aMeshOnEntity2.mySupport = aMEDSupport;
- }else{
SALOME_MED::FAMILY_var aMEDFamily = SALOME_MED::FAMILY::_narrow(aMedSupport);
if(!aMEDFamily->_is_nil()) {
int aNbCells, aCellsSize;
GetCellsSize(aNbCells,aCellsSize,aMEDFamily);
if(aNbCells > 0){
- if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aFamily = '"<<aSupportName<<"' anEntity = "<<anEntity);
- VISU::TMeshOnEntity& aMeshOnEntity = aMesh.myMeshOnEntityMap[anEntity];
- VISU::TFamily& aFamily = aMeshOnEntity.myFamilyMap[aSupportName.in()];
- aFamily.myName = aSupportName.in();
- aFamily.myEntity = anEntity;
- aFamily.myNbCells = aNbCells;
- aFamily.myCellsSize = aCellsSize;
- aFamily.myId = aMEDFamily->getIdentifier();
-
- VISUMED::TMeshOnEntity& aMeshOnEntity2 = aMesh2.myMeshOnEntityMap[anEntity];
- VISUMED::TFamily& aFamily2 = aMeshOnEntity2.myFamilyMap[aSupportName.in()];
- aFamily2.myFamily = aMEDFamily;
+ if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aFamily = '"<<aSupportName<<"' aVEntity = "<<aVEntity);
+ TMeshOnEntityMap::iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(aVEntity);
+ if(aMeshOnEntityMapIter == aMeshOnEntityMap.end())
+ continue;
+
+ PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second;
+ TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
+ PCFamily aFamily = aFamilyMap[aSupportName.in()](new TCFamily());
+ aFamily->myName = aSupportName.in();
+ aFamily->myEntity = aVEntity;
+ aFamily->myNbCells = aNbCells;
+ aFamily->myCellsSize = aCellsSize;
+ aFamily->myId = aMEDFamily->getIdentifier();
+ aFamily->myFamily = aMEDFamily;
}
}
+ }
+
+ // Fill all Groups
+ 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();
+
SALOME_MED::GROUP_var aMEDGroup = SALOME_MED::GROUP::_narrow(aMedSupport);
- if(!aMEDGroup->_is_nil()) {
- if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aGroup = '"<<aSupportName<<"' anEntity = "<<anEntity);
- VISUMED::TGroupMap& aGroupMap2 = aMesh2.myGroupMap;
- VISUMED::TGroup& aGroup2 = aGroupMap2[aSupportName.in()];
- aGroup2.myGroup = aMEDGroup;
+ if(!aMEDGroup->_is_nil()){
+ if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aGroup = '"<<aSupportName<<"' aVEntity = "<<aVEntity);
+ TGroupMap& aGroupMap = aMesh->myGroupMap;
+ PCGroup aGroup = aGroupMap[aSupportName.in()](new TCGroup());
+ aGroup->myGroup = aMEDGroup;
SALOME_MED::Family_array_var aFamilies = aMEDGroup->getFamilies();
int iFamilyEnd = aFamilies->length();
for(int iFamaily = 0; iFamaily < iFamilyEnd; iFamaily++){
- aMEDFamily = aFamilies[iFamaily];
+ SALOME_MED::FAMILY_var aMEDFamily = aFamilies[iFamaily];
CORBA::String_var aFamilyName = aMEDFamily->getName();
- VISU::TMeshOnEntity& aMeshOnEntity = aMesh.myMeshOnEntityMap[anEntity];
if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aGroup - aFamilyName = '"<<aFamilyName.in()<<"'");
- VISU::TFamily& aFamily = aMeshOnEntity.myFamilyMap[aFamilyName.in()];
- VISU::TBindGroups& aBindGroups = aFamily.myGroups;
- aBindGroups.insert(aSupportName.in());
+ PFamily aFamily = FindFamily(aMesh,aFamilyName.in());
+ if(aFamily){
+ VISU::TBindGroups& aBindGroups = aFamily->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 = '"<<GetSObjectName(aFieldSObj)<<"'");
SALOMEDS::ChildIterator_var aTimeStampIterator = aStudy->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 = '"<<GetSObjectName(aTimeStampSObj)<<"'");
+ CORBA::Object_var aMedField = VISU::SObjectToObject(aTimeStampSObj);
+ if(CORBA::is_nil(aMedField))
+ continue;
+
SALOME_MED::FIELD_var aMEDField = SALOME_MED::FIELD::_narrow(aMedField);
- if(aMEDField->_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 = "<<aMeshOnEntity.myNbCells);
- aField.myCompNames.resize(aField.myNbComp);
- aField.myUnitNames.resize(aField.myNbComp);
-
+ TMeshMap::iterator aMeshMapIter = myMeshMap.find(aMeshName.in());
+ if(aMeshMapIter == myMeshMap.end())
+ continue;
+
+ PCMesh aMesh = aMeshMapIter->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 = "<<aMeshOnEntity->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 = '"<<aMeshName<<
- "'; myEntity = "<<anEntity<<"; myTime = "<<aValForTime.myTime.first);
+ "'; myEntity = "<<anEntity<<"; myTime = "<<aDT);
}
}
}
}
-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++){
+ for(; theTimeStampIterator->More(); theTimeStampIterator->Next()){
SALOMEDS::SObject_var aTimeStampSObj = theTimeStampIterator->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 = '"<<GetSObjectName(aTimeStampSObj)<<"'");
+
+ CORBA::Object_var aMedField = VISU::SObjectToObject(aTimeStampSObj);
+ if(CORBA::is_nil(aMedField))
+ continue;
+
SALOME_MED::FIELD_var aMEDField = SALOME_MED::FIELD::_narrow(aMedField);
- if(aMEDField->_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 = "<<aMeshName<<"; myDim = "<<aMesh.myDim);
-
- 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()];
- CORBA::Short iField = mySObject->Tag();
- 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 = "<<aMeshOnEntity.myNbCells);
- aField.myCompNames.resize(aField.myNbComp);
- aField.myUnitNames.resize(aField.myNbComp);
+ PCMesh aMesh = myMeshMap[aMeshName.in()](new TCMesh());
+ aMesh->myDim = aMEDMesh->getSpaceDimension();
+ aMesh->myPointsDim.resize(aMesh->myDim);
+ aMesh->myName = aMeshName.in();
+ aMesh->myNbPoints = aMEDMesh->getNumberOfNodes();
+ aMesh->myMesh = aMEDMesh;
+ if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aMeshName = "<<aMeshName<<"; myDim = "<<aMesh->myDim);
+
+ TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
+ PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMap[aVEntity](new TCMeshOnEntity());
+ aMeshOnEntity->myEntity = aVEntity;
+ aMeshOnEntity->myMeshName = aMeshName.in();
+ aMeshOnEntity->mySupport = aMEDSupport;
+
+ if(aVEntity == NODE_ENTITY){
+ PCMeshOnEntity aMeshOnEntity2 = aMeshOnEntityMap[CELL_ENTITY](new TCMeshOnEntity());
+ *aMeshOnEntity2 = *aMeshOnEntity;
+ aMeshOnEntity->myEntity = CELL_ENTITY;
+ GetCellsSize(aMesh,aMEDMesh,CELL_ENTITY);
+ }else{
+ PCMeshOnEntity aMeshOnEntity2 = aMeshOnEntityMap[NODE_ENTITY](new TCMeshOnEntity());
+ *aMeshOnEntity2 = *aMeshOnEntity;
+ aMeshOnEntity->myEntity = NODE_ENTITY;
+ GetCellsSize(aMesh,aMEDMesh,NODE_ENTITY);
+ }
+ GetCellsSize(aMesh,aMEDMesh,aVEntity);
+ TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
+ TFieldMap::iterator aFieldMapIter = aFieldMap.find(aFieldName.in());
+ PCField aField;
+ if(aFieldMapIter == aFieldMap.end()){
+ aField = aFieldMap[aFieldName.in()](new TCField());
+ CORBA::Short iField = mySObject->Tag();
+ aField->myId = iField;
+ aField->myName = aFieldName.in();
+ aField->myEntity = aVEntity;
+ aField->myMeshName = aMeshName.in();
+ aField->myNbComp = aMEDField->getNumberOfComponents();
+ aField->myDataSize = aMeshOnEntity->myNbCells * aField->myNbComp;
+ if(MYDEBUG)
+ MESSAGE("VISU_MEDConvertor::Build - aMeshOnEntity->myNbCells = "<<aMeshOnEntity->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 = '"<<aMeshName<<
- "'; myEntity = "<<anEntity<<"; myTime = "<<aValForTime.myTime.first);
+ "'; myEntity = "<<aVEntity<<"; myTime = "<<aDT);
}
return this;
}
-int VISU_MEDConvertor::LoadMeshOnEntity(VISU::TMeshOnEntity& theMeshOnEntity,
- const string& theFamilyName)
+int
+VISU_MEDConvertor::LoadMeshOnEntity(VISU::PMeshOnEntityImpl theMeshOnEntity,
+ const string& theFamilyName)
{
//Main part of code
- const string& aMeshName = theMeshOnEntity.myMeshName;
- const VISU::TEntity& anEntity = theMeshOnEntity.myEntity;
- VISU::TMesh& aMesh = myMeshMap[aMeshName];
+ const string& aMeshName = theMeshOnEntity->myMeshName;
+ const TEntity& aVEntity = theMeshOnEntity->myEntity;
+ PCMesh aMesh = myMeshMap[aMeshName];
int isPointsUpdated;
- if(anEntity == VISU::NODE_ENTITY)
+ if(aVEntity == NODE_ENTITY)
isPointsUpdated = LoadPoints(aMesh,theFamilyName);
else
isPointsUpdated = LoadPoints(aMesh);
- int isCellsOnEntityUpdated = LoadCellsOnEntity(theMeshOnEntity,theFamilyName);
+ int isCellsOnEntityUpdated = LoadCellsOnEntity(aMesh,theMeshOnEntity,theFamilyName);
return (isPointsUpdated || isCellsOnEntityUpdated);
}
-
-int VISU_MEDConvertor::LoadMeshOnGroup(VISU::TMesh& theMesh,
- const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet)
+
+
+int
+VISU_MEDConvertor::LoadMeshOnGroup(VISU::PMeshImpl theMesh,
+ const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet)
{
//Main part of code
int isPointsUpdated = 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];
- if(anEntity == VISU::NODE_ENTITY){
+ const VISU::TEntity& aVEntity = aFamilyAndEntitySetIter->second;
+ PCMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[aVEntity];
+ if(aVEntity == VISU::NODE_ENTITY){
isPointsUpdated += LoadPoints(theMesh,aFamilyName);
- isCellsOnEntityUpdated += LoadCellsOnEntity(aMeshOnEntity);
+ isCellsOnEntityUpdated += LoadCellsOnEntity(theMesh,aMeshOnEntity);
}else{
isPointsUpdated += LoadPoints(theMesh);
- isCellsOnEntityUpdated += LoadCellsOnEntity(aMeshOnEntity,aFamilyName);
+ isCellsOnEntityUpdated += LoadCellsOnEntity(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)
{
//Main part of code
int isPointsUpdated = LoadPoints(theMesh);
- int isCellsOnEntityUpdated = LoadCellsOnEntity(theMeshOnEntity);
- int isFieldUpdated = LoadField(theMeshOnEntity,theField,theValForTime);
+ int isCellsOnEntityUpdated = LoadCellsOnEntity(theMesh,theMeshOnEntity);
+ int isFieldUpdated = LoadField(theMesh,theMeshOnEntity,theField,theValForTime);
return (isPointsUpdated || isCellsOnEntityUpdated || isFieldUpdated);
}
-int VISU_MEDConvertor::LoadPoints(VISU::TMesh& theMesh, const string& theFamilyName)
+int
+VISU_MEDConvertor::LoadPoints(VISU::PCMesh theMesh,
+ const string& theFamilyName)
{
//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;
+ PCMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[VISU::NODE_ENTITY];
+ PCFamily 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;
- VISUMED::TMesh& aMesh2 = myMeshMap2[theMesh.myName];
- SALOME_MED::MESH_var& aMedMesh = aMesh2.myMesh;
- VISUMED::TMeshOnEntity& aMeshOnEntity2 = aMesh2.myMeshOnEntityMap[VISU::NODE_ENTITY];
+ if(!aFamily)
+ return 0;
+ else if(!aFamily->mySubMesh.empty())
+ return 0;
+
if(MYDEBUG)
MESSAGE("LoadPoints - isPointsLoaded = "<<isPointsLoaded<<"; theFamilyName = '"<<theFamilyName<<"'");
- theMesh.myDim = aMedMesh->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 = "<<iNumElemEnd);
if (iNumElemEnd <= 0) throw std::runtime_error("LoadPoints >> 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;
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 = '"<<theFamilyName<<"'");
- MESSAGE("LoadCellsOnEntity - isCellsLoaded = "<<isCellsLoaded<<"; isFamilyPresent = "<<isFamilyPresent);
+ MESSAGE("LoadCellsOnEntity - isCellsLoaded = "<<isCellsLoaded<<"; isFamilyPresent = "<<bool(aFamily));
}
+
//Main part of code
- int iGeomElemEnd;
- int* aGeomElemVector;
- const VISU::TEntity& anEntity = theMeshOnEntity.myEntity;
- GetEntity2Geom(anEntity,aGeomElemVector,&iGeomElemEnd);
- const SALOME_MED::medEntityMesh& aMedEntity = aVisu2MedEntity[anEntity];
- VISU::TMesh &aMesh = myMeshMap[theMeshOnEntity.myMeshName];
- int aNbPoints = aMesh.myPointsCoord.size()/aMesh.myDim;
+ SALOME_MED::medGeometryElement* aGeomElems;
+ const TEntity& aVEntity = theMeshOnEntity->myEntity;
+ int iGeomEnd = GetEntity2Geom(aVEntity,aGeomElems);
+ const SALOME_MED::medEntityMesh& aMEntity = VTKEntityToMED(aVEntity);
+ int aNbPoints = theMesh->myPointsCoord.size()/theMesh->myDim;
if(!isCellsLoaded){
- for (int iGeomElem = 0, aCounter = 0; iGeomElem < iGeomElemEnd; iGeomElem++) {
- int medId = GetIdMEDType(aGeomElemVector[iGeomElem]);
- int nbMedNodes = salome_med2vtk[medId].medNbNodes;
- int nbVtkNodes = salome_med2vtk[medId].vtkNbNodes;
- int aVtkType = salome_med2vtk[medId].vtkType;
- SALOME_MED::medGeometryElement aMedType = salome_med2vtk[medId].medType;
- med_int iNumElemEnd = aMedMesh->getNumberOfElements(aMedEntity,aMedType);
+ for(int iGeom = 0, aCounter = 0; iGeom < iGeomEnd; iGeom++){
+ SALOME_MED::medGeometryElement aGeom = aGeomElems[iGeom];
+ int aMNbNodes = MEDGeom2NbNodes(aGeom);
+ int aVGeom = MEDGeomToVTK(aGeom);
+ int aVNbNodes = VTKGeom2NbNodes(aVGeom);
+ int iNumElemEnd = aMedMesh->getNumberOfElements(aMEntity,aGeom);
if (iNumElemEnd > 0) {
SALOME_MED::long_array_var conn =
- aMedMesh->getConnectivity(SALOME_MED::MED_FULL_INTERLACE,SALOME_MED::MED_NODAL,aMedEntity,aMedType);
- VISU::TMeshOnEntity::TConnForCellType& aConnForCellType = theMeshOnEntity.myCellsConn[aVtkType];
+ aMedMesh->getConnectivity(SALOME_MED::MED_FULL_INTERLACE,SALOME_MED::MED_NODAL,aMEntity,aGeom);
+ TMeshOnEntityImpl::TConnForCellType& aConnForCellType = theMeshOnEntity->myCellsConn[aVGeom];
//APO - aConnForCellType.resize(iNumElemEnd);
- valarray<med_int> aConnect(nbMedNodes);
+ vector<int> aConnect(aMNbNodes);
int aNbConnForElem = conn->length()/iNumElemEnd;
- if(MYDEBUG) MESSAGE("LoadCellsOnEntity - medName = "<<salome_med2vtk[medId].medName<<
- "; iNumElemEnd = "<<iNumElemEnd<<"; aNbConnForElem = "<<aNbConnForElem);
+ if(MYDEBUG) MESSAGE("LoadCellsOnEntity - aGeom = "<<aGeom<<
+ "; iNumElemEnd = "<<iNumElemEnd<<
+ "; aNbConnForElem = "<<aNbConnForElem);
for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) {
- //APO - VISU::TMeshOnEntity::TConnect& anArray = aConnForCellType[iNumElem];
- //APO - anArray.resize(nbVtkNodes);
- VISU::TMeshOnEntity::TConnect anArray(nbVtkNodes);
- for (int k = 0, kj = iNumElem*aNbConnForElem; k < nbMedNodes; k++) {
+ VISU::TMeshOnEntityImpl::TConnect anArray(aVNbNodes);
+ for (int k = 0, kj = iNumElem*aNbConnForElem; k < aMNbNodes; k++) {
aConnect[k] = conn[kj+k] - 1;
}
- switch(aMedType){
+ switch(aGeom){
case SALOME_MED::MED_TETRA4 :
case SALOME_MED::MED_TETRA10 :
anArray[0] = aConnect[0];
anArray[4] = aConnect[4];
break;
default:
- for (int k = 0; k < nbVtkNodes; k++)
+ for (int k = 0; k < aVNbNodes; k++)
anArray[k] = aConnect[k];
}
- for (int k = 0; k < nbVtkNodes; k++)
+ for (int k = 0; k < aVNbNodes; k++)
if(anArray[k] < 0 || aNbPoints <= anArray[k]){
static QString aString;
aString.sprintf("ImportCells >> aNbPoints(%d) <= anArray[%d][%d]=%d < 0 !!!",aNbPoints,iNumElem,k,anArray[k]);
}
//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 = "<<iGeomElemEnd);
- for (int iGeomElem = 0; iGeomElem < iGeomElemEnd; iGeomElem++) {
- SALOME_MED::medGeometryElement aGeomType = aGeom[iGeomElem];
- SALOME_MED::long_array_var aCellNumForType = aMedFamily->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 = "<<iGeomEnd);
+ for (int iGeom = 0; iGeom < iGeomEnd; iGeom++) {
+ SALOME_MED::medGeometryElement aGeom = aGeoms[iGeom];
+ SALOME_MED::long_array_var aCellNumForType = aMedFamily->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 = "<<salome_med2vtk[medId].medName<<
- "; iNumElemEnd = "<<iNumElemEnd<<"; aCounter = "<<aCounter);
+ MESSAGE("LoadCellsOnEntity - aGeom = "<<aGeom<<
+ "; iNumElemEnd = "<<iNumElemEnd<<
+ "; aCounter = "<<aCounter);
for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) {
int tmp = aCellNumForType[iNumElem]-aCounter-1;
if(0 > tmp || tmp >= iNumElemEndTmp) {
return 1;
}
-template<class TArray> int ImportField(TArray& theArray,
- const VISU::TMesh& theMesh,
- const VISU::TField& theField,
- VISU::TField::TValForTime& theValForTime,
- const VISU::TMeshOnEntity& theMeshOnEntity,
- const VISUMED::TMeshOnEntity& theMeshOnEntity2)
+template<class TArray>
+int
+ImportField(TArray& theArray,
+ VISU::PCMesh theMesh,
+ VISU::PCField theField,
+ VISU::PCValForTime theValForTime,
+ VISU::PCMeshOnEntity theMeshOnEntity)
{
- if(theField.myEntity == VISU::NODE_ENTITY){
- VISU::TField::TValForCellsWithType& aValForCellsWithType = theValForTime.myValForCells[VTK_VERTEX];
- int iNumElemEnd = theMesh.myPointsCoord.size()/theMesh.myDim*theField.myNbComp;
+ if(theField->myEntity == NODE_ENTITY){
+ TValForTimeImpl::TValForCellsWithType& aValForCellsWithType =
+ theValForTime->myValForCells[VTK_VERTEX];
+ int iNumElemEnd = theMesh->myPointsCoord.size()/theMesh->myDim*theField->myNbComp;
if(MYDEBUG) MESSAGE("ImportField - iNumElemEnd = "<<iNumElemEnd);
aValForCellsWithType.resize(iNumElemEnd);
for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++)
aValForCellsWithType[iNumElem] = theArray[iNumElem];
}else{
- int iGeomElemEnd;
- int* aGeomElemVector;
- const VISU::TEntity& anEntity = theField.myEntity;
- GetEntity2Geom(anEntity,aGeomElemVector,&iGeomElemEnd);
- for (int iGeomElem = 0, aCounter = 0; iGeomElem < iGeomElemEnd; iGeomElem++) {
- int medId = GetIdMEDType(aGeomElemVector[iGeomElem]);
- int aVtkType = salome_med2vtk[medId].vtkType;
- SALOME_MED::medGeometryElement aMedType = salome_med2vtk[medId].medType;
- const VISUMED::TMeshOnEntity::TCellsFirstIndex& aCellsFirstIndex = theMeshOnEntity2.myCellsFirstIndex;
- VISUMED::TMeshOnEntity::TCellsFirstIndex::const_iterator aCellsFirstIndexIter = aCellsFirstIndex.find(aMedType);
+ SALOME_MED::medGeometryElement* aGeomElems;
+ const TEntity& aVEntity = theField->myEntity;
+ int iGeomEnd = GetEntity2Geom(aVEntity,aGeomElems);
+ for(int iGeom = 0; iGeom < iGeomEnd; iGeom++){
+ SALOME_MED::medGeometryElement aGeom = aGeomElems[iGeom];
+ int aVGeom = MEDGeomToVTK(aGeom);
+ const TCMeshOnEntity::TCellsFirstIndex& aCellsFirstIndex = theMeshOnEntity->myCellsFirstIndex;
+ TCMeshOnEntity::TCellsFirstIndex::const_iterator aCellsFirstIndexIter = aCellsFirstIndex.find(aGeom);
if(aCellsFirstIndexIter != aCellsFirstIndex.end()){
- const VISU::TMeshOnEntity::TCellsConn& aCellsConn = theMeshOnEntity.myCellsConn;
- VISU::TMeshOnEntity::TCellsConn::const_iterator aCellsConnIter = aCellsConn.find(aVtkType);
- const VISU::TMeshOnEntity::TConnForCellType& aConnForCellType = aCellsConnIter->second;
- const VISUMED::TMeshOnEntity::TIndexAndSize& aIndexAndSize = aCellsFirstIndexIter->second;
+ const TCMeshOnEntity::TIndexAndSize& aIndexAndSize = aCellsFirstIndexIter->second;
int iNumElemEnd = aIndexAndSize.second;
if(MYDEBUG)
- MESSAGE("ImportField - medName = "<<salome_med2vtk[medId].medName<<
- "; aIndexAndSize = {"<<aIndexAndSize.first<<","<<aIndexAndSize.second<<"}");
- VISU::TField::TValForCellsWithType& aValForCellsWithType = theValForTime.myValForCells[aVtkType];
- 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];
+ MESSAGE("ImportField - aGeom = "<<aGeom<<
+ "; aIndexAndSize = {"<<aIndexAndSize.first<<
+ ","<<aIndexAndSize.second<<"}");
+ TValForTimeImpl::TValForCellsWithType& aValForCellsWithType = theValForTime->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 = "<<anArray->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 = "<<anArray->length());
- ::ImportField(anArray,aMesh,theField,theValForTime,theMeshOnEntity,aMeshOnEntity2);
+ ::ImportField(anArray,theMesh,theField,theValForTime,theMeshOnEntity);
}
return 1;
}
#include <string>
-extern "C"{
-#include <med.h>
-}
+namespace VISU{
-namespace VISUMED{
- struct TFamily{
- SALOME_MED::FAMILY_var myFamily;
- };
- typedef std::map<std::string,TFamily> TFamilyMap;
-
- struct TField{
- struct TValForTime{
- SALOME_MED::FIELD_var myField;
- };
- typedef std::map<int,TValForTime> TValField;
- TValField myValField;
+ struct TCMesh: TMeshImpl{
+ SALOME_MED::MESH_var myMesh;
};
- typedef std::map<std::string,TField> TFieldMap;
+ typedef shared_ptr<TCMesh> PCMesh;
- struct TMeshOnEntity{
+ struct TCMeshOnEntity: TMeshOnEntityImpl{
SALOME_MED::SUPPORT_var mySupport;
typedef std::pair<int,int> TIndexAndSize;
typedef std::map<int,TIndexAndSize> TCellsFirstIndex;
TCellsFirstIndex myCellsFirstIndex;
- TFamilyMap myFamilyMap;
- TFieldMap myFieldMap;
};
- typedef std::map<VISU::TEntity,TMeshOnEntity> TMeshOnEntityMap;
+ typedef shared_ptr<TCMeshOnEntity> PCMeshOnEntity;
+
+ struct TCFamily: TFamilyImpl{
+ SALOME_MED::FAMILY_var myFamily;
+ };
+ typedef shared_ptr<TCFamily> PCFamily;
- struct TGroup{
+ struct TCGroup: TGroupImpl{
SALOME_MED::GROUP_var myGroup;
};
- typedef std::map<std::string,TGroup> TGroupMap;
+ typedef shared_ptr<TCGroup> PCGroup;
- struct TMesh{
- SALOME_MED::MESH_var myMesh;
- TMeshOnEntityMap myMeshOnEntityMap;
- TGroupMap myGroupMap;
+ struct TCField: TFieldImpl{
+ };
+ typedef shared_ptr<TCField> PCField;
+
+ struct TCValForTime: TValForTimeImpl{
+ SALOME_MED::FIELD_var myField;
};
- typedef std::map<std::string,TMesh> TMeshMap;
+ typedef shared_ptr<TCValForTime> PCValForTime;
+
}
class VISU_MEDConvertor: public VISU_Convertor_impl{
protected:
- VISUMED::TMeshMap myMeshMap2;
SALOMEDS::SObject_var mySObject;
VISU_MEDConvertor() {};
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);
};
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() ;
};
#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,
void VISU::CutLines_i::SameAs(const CutLines_i* theOrigin){
- CutLines_i* aCutLines = const_cast<CutLines_i*>(theOrigin);
VISU::ScalarMap_i::SameAs(theOrigin);
}
typedef map<int,TXYMap> TXYMapCont;
typedef map<long,long> 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());
#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,
void VISU::CutPlanes_i::SameAs(const CutPlanes_i* theOrigin){
- CutPlanes_i* aCutPlanes = const_cast<CutPlanes_i*>(theOrigin);
VISU::ScalarMap_i::SameAs(theOrigin);
}
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()));
#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,
{
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"<<exc.what());
}catch(...){
#ifdef _DEBUG_
static int MYDEBUG = 0;
-static int MYDEBUGWITHFILES = 0;
#else
static int MYDEBUG = 0;
-static int MYDEBUGWITHFILES = 0;
#endif
int VISU::IsoSurfaces_i::IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity,
void VISU::IsoSurfaces_i::SameAs(const IsoSurfaces_i* theOrigin) {
- IsoSurfaces_i* aIsoSurfaces = const_cast<IsoSurfaces_i*>(theOrigin);
VISU::ScalarMap_i::SameAs(theOrigin);
}
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){
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();
CORBA::String_var aString = GetID();
anIOR->SetValue(aString);
}
- //}catch(std::exception& exc){
- // INFOS("Follow exception was occured :\n"<<exc.what());
- // return NULL;
- //}catch(...){
- // INFOS("Unknown exception was occured!");
- // return NULL;
- //}
+ }catch(std::exception& exc){
+ INFOS("Follow exception was occured :\n"<<exc.what());
+ return NULL;
+ }catch(...){
+ INFOS("Unknown exception was occured!");
+ return NULL;
+ }
aStudyBuilder->CommitCommand();
return this;
}
#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){
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{
}
}
//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;
}
}
//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;
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)){
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;
"","Families","",aComment.latin1(),true);
//Import entities and according families
aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
- typedef map<VISU::TEntity,string> TEntity2Entry;
- TEntity2Entry aEntity2Entry;
+ typedef std::map<std::string,std::string> TComment2EntryMap;
+ TComment2EntryMap aComment2EntryMap;
+ typedef std::map<VISU::TEntity,std::string> 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;
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;
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()]);
}
}
}
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);
}
else
mySourceId = eFile;
if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - mySourceId = "<<mySourceId);
- myInput = CreateMedConvertor(myFileInfo.filePath().latin1());
+ myInput = CreateConvertor(myFileInfo.filePath().latin1());
QString aComment;
aComment.sprintf("myComment=%s;myType=%d;myFileName=%s;myInitFileName=%s",
GetComment(),VISU::TRESULT,myFileInfo.filePath().latin1(),
const SALOMEDS::SObject_var& VISU::Result_i::GetSObject() const { return mySObject;}
const SALOMEDS::Study_var& VISU::Result_i::GetStudyDocument() const { return myStudyDocument;}
const SALOMEDS::SComponent_var& VISU::Result_i::GetSComponent() const { return mySComponent;}
+std::string VISU::Result_i::GetEntry(const std::string& theComment)
+{
+ return FindEntryWithComment(myStudyDocument,GetEntry().c_str(),theComment.c_str());
+}
VISU::Result_i::~Result_i() {
MESSAGE("Result_i::~Result_i() - this = "<<this);
SALOMEDS::SObject_var mySObject;
SALOMEDS::Study_var myStudyDocument;
SALOMEDS::SComponent_var mySComponent;
-
+
public:
std::string GetRefFatherEntry();
std::string GetEntry();
const SALOMEDS::SObject_var& GetSObject() const;
const SALOMEDS::Study_var& GetStudyDocument() const;
const SALOMEDS::SComponent_var& GetSComponent() const;
+ std::string GetEntry(const std::string& theComment);
};
#ifdef _DEBUG_
static int MYDEBUG = 0;
-static int MYDEBUGWITHFILES = 0;
#else
static int MYDEBUG = 0;
-static int MYDEBUGWITHFILES = 0;
#endif
static int INCMEMORY = 4;
myIsFixedRange = (aFixRange.compare("true") == 0);
if(myIsFixedRange){
- float aScalarRange[2];
QString aRangeMin = QAD_CONFIG->getSetting("Visu:SBMinimumValue");
float aMin = (aRangeMin.isEmpty())? 0 : aRangeMin.toFloat();
QString aRangeMax = QAD_CONFIG->getSetting("Visu:SBMaximumValue");
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);
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){
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);
VISU::Prs3d_i::CreateActor(anActor,theIO);
anActor->SetBarVisibility(true);
anActor->SetRepresentation(2);
- anActor->myFieldName = myFieldName;
UpdateActor(anActor);
}catch(...) {
anActor->Delete();
virtual void DoHook();
VISU_ScalarMapPL* myScalarMapPL;
- const TField* myField;
+ PField myField;
string myMeshName;
TEntity myEntity;
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();
#include <vtkDataSetMapper.h>
#include <vtkAppendFilter.h>
+#include <vtkUnstructuredGrid.h>
using namespace VISU;
using namespace std;
using namespace std;
-//QWaitCondition myCondition;
-static int MYDELAY = 1;
//************************************************************************
VISU_TimeAnimation::VISU_TimeAnimation(SALOMEDS::Study_ptr theStudy, VISU::View3D_ptr theView3D) {
bool aNoError = true;
clearView();
- vtkRenderer* aRen = myView->getRenderer();
for (int i = 0; i < getNbFields(); i++) {
FieldData& aData = myFieldsLst[i];
#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;
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);
VISU_Actor* GetActor(VISU::Prs3d_i* thePrs3d, VTKViewer_ViewFrame* theVTKFrame){
- vtkActor *anActor;
vtkActorCollection *anActColl = theVTKFrame->getRenderer()->GetActors();
anActColl->InitTraversal();
while(vtkActor *anActor = anActColl->GetNextActor())
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@