From: enk Date: Thu, 6 Dec 2007 13:15:37 +0000 (+0000) Subject: Fix for IPAL 17888 X-Git-Tag: mergefrom_MERGE_MULTIPR_EVOLUTION_07-Dec-07~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c6578a3155487d622ab3cf885913e57815cda0cc;p=modules%2Fvisu.git Fix for IPAL 17888 --- diff --git a/src/CONVERTOR/VISU_ConvertorDef_impl.hxx b/src/CONVERTOR/VISU_ConvertorDef_impl.hxx index 9d310121..eb7fbcd0 100644 --- a/src/CONVERTOR/VISU_ConvertorDef_impl.hxx +++ b/src/CONVERTOR/VISU_ConvertorDef_impl.hxx @@ -46,13 +46,18 @@ class vtkUnstructuredGrid; class VISU_AppendFilter; class VISU_MergeFilter; +class VISU_CommonCellsFilter; namespace VISU { //--------------------------------------------------------------- typedef vtkSmartPointer PMergeFilter; - - + typedef vtkSmartPointer PCommonCellsFilter; + + struct TCommonCellsFilterHolder; + typedef MED::SharedPtr PCommonCellsFilterHolder; + + //--------------------------------------------------------------- typedef vtkSmartPointer PPolyData; typedef vtkSmartPointer PAppendPolyData; diff --git a/src/CONVERTOR/VISU_Convertor_impl.cxx b/src/CONVERTOR/VISU_Convertor_impl.cxx index 66f53771..fb2c0db1 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.cxx +++ b/src/CONVERTOR/VISU_Convertor_impl.cxx @@ -32,6 +32,7 @@ #include "VISU_AppendFilter.hxx" #include "VISU_AppendPolyData.hxx" #include "VTKViewer_CellLocationsArray.h" +#include "VISU_CommonCellsFilter.hxx" #include "VISU_ConvertorUtils.hxx" @@ -873,17 +874,66 @@ VISU_Convertor_impl const VISU::PProfileImpl& theProfile, const VISU::TEntity& theEntity) { + vtkUnstructuredGrid* anOutput = NULL; + LoadMeshOnEntity(theMesh, theMeshOnEntity); GetMeshOnEntity(theMeshOnEntity->myMeshName, theMeshOnEntity->myEntity); GetMeshOnProfile(theMesh, theMeshOnEntity, theProfile); - + + bool isNeedInCells = false; + theUnstructuredGridIDMapper->myIDMapper = theProfile; + if(theMeshOnEntity->myEntity == VISU::NODE_ENTITY){ + // add geometry elements to output, + // if timestamp on NODE_ENTITY and + // on profiles with status eAddPart + VISU::TGeom2SubProfile::const_iterator anIter = theProfile->myGeom2SubProfile.begin(); + for(; anIter != (theProfile->myGeom2SubProfile).end(); anIter++){ + const VISU::EGeometry aGeom = anIter->first; + const VISU::PSubProfileImpl aSubProfile = anIter->second; + if(aSubProfile->myStatus == VISU::eAddPart && aGeom == VISU::ePOINT1){ + isNeedInCells = true; + break; + } + } + if(isNeedInCells){ + theUnstructuredGridIDMapper->myIsSpecialKey = true; + GetTimeStampOnNodalProfile(theMesh,theUnstructuredGridIDMapper,theField,theValForTime,theEntity); + anOutput = theUnstructuredGridIDMapper->GetUnstructuredGridOutput(); + } + } + /* vtkUnstructuredGrid* anOutput = theUnstructuredGridIDMapper->GetUnstructuredGridOutput(); const VISU::PUnstructuredGrid& aSource = theUnstructuredGridIDMapper->mySource.GetSource(); VISU::GetTimeStampOnProfile(aSource, theField, theValForTime, theEntity); + */ return anOutput; } +void +VISU_Convertor_impl +::GetTimeStampOnNodalProfile(const VISU::PMeshImpl& theMesh, + const VISU::PUnstructuredGridIDMapperImpl& theIDMapperFilter, + const VISU::PFieldImpl& theField, + const VISU::PValForTimeImpl& theValForTime, + const VISU::TEntity& theEntity) +{ + const VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap; + VISU::TMeshOnEntityMap::const_iterator aIter = aMeshOnEntityMap.begin(); + for(;aIter!=aMeshOnEntityMap.end();aIter++){ + VISU::TEntity aEntity = aIter->first; + if(aEntity != VISU::NODE_ENTITY){ + VISU::PNamedIDMapper aMapper = GetMeshOnEntity(theMesh->myName,aEntity); + if(aMapper) + theIDMapperFilter->myMappers[aEntity] = aMapper; + } + } + + theIDMapperFilter->GetUnstructuredGridOutput(); + const VISU::PUnstructuredGrid& aSource = theIDMapperFilter->mySource.GetSource(); + VISU::GetTimeStampOnProfile(aSource,theField,theValForTime,theEntity); +} + //--------------------------------------------------------------- VISU::PUnstructuredGridIDMapper VISU_Convertor_impl diff --git a/src/CONVERTOR/VISU_Convertor_impl.hxx b/src/CONVERTOR/VISU_Convertor_impl.hxx index 403ef72f..f6cffc0e 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.hxx +++ b/src/CONVERTOR/VISU_Convertor_impl.hxx @@ -230,6 +230,13 @@ protected: const VISU::PUnstructuredGridIDMapperImpl& theIDMapperFilter, const VISU::PProfileImpl& theProfile, const VISU::TEntity& theEntity); + + void + GetTimeStampOnNodalProfile(const VISU::PMeshImpl& theMesh, + const VISU::PUnstructuredGridIDMapperImpl& theIDMapperFilter, + const VISU::PFieldImpl& theField, + const VISU::PValForTimeImpl& theValForTime, + const VISU::TEntity& theEntity); protected: //! Implemention of the VISU_Convertor::GetTimeStampSize diff --git a/src/CONVERTOR/VISU_Structures.hxx b/src/CONVERTOR/VISU_Structures.hxx index 22146504..7c2257ff 100644 --- a/src/CONVERTOR/VISU_Structures.hxx +++ b/src/CONVERTOR/VISU_Structures.hxx @@ -99,6 +99,8 @@ namespace VISU typedef std::map TMeshMap; + typedef std::map PNamedIDMapperMap; + //--------------------------------------------------------------- //! Define a basic class which corresponds to MED PROFILE entity struct VISU_CONVERTOR_EXPORT TSubProfile: virtual TBaseStructure diff --git a/src/CONVERTOR/VISU_Structures_impl.cxx b/src/CONVERTOR/VISU_Structures_impl.cxx index 34e202e8..8a922fc0 100644 --- a/src/CONVERTOR/VISU_Structures_impl.cxx +++ b/src/CONVERTOR/VISU_Structures_impl.cxx @@ -33,6 +33,7 @@ #include "VISU_MergeFilter.hxx" #include "VISU_ConvertorUtils.hxx" +#include "VISU_CommonCellsFilter.hxx" #include #include @@ -157,7 +158,6 @@ namespace VISU return 0; } - //--------------------------------------------------------------- unsigned long int TMemoryCheckIDMapper @@ -416,6 +416,18 @@ namespace VISU //--------------------------------------------------------------- + + + TUnstructuredGridIDMapperImpl + ::TUnstructuredGridIDMapperImpl(): + myIsSpecialKey(false) + { + if(!myCommonCellsFilter.GetPointer()){ + myCommonCellsFilter = VISU_CommonCellsFilter::New(); + myCommonCellsFilter->Delete(); + } + } + vtkIdType TUnstructuredGridIDMapperImpl ::GetNodeObjID(vtkIdType theID) const @@ -463,13 +475,31 @@ namespace VISU ::GetUnstructuredGridOutput() { if(!myFilter.GetPointer()){ - const PAppendFilter& anAppendFilter = myIDMapper->GetFilter(); - vtkUnstructuredGrid* aGeometry = anAppendFilter->GetOutput(); + const PAppendFilter& anAppendFilter = myIDMapper->GetFilter(); + vtkUnstructuredGrid* aGeometry; + const PUnstructuredGrid& aSource = mySource.GetSource(); - vtkUnstructuredGrid* aDataSet = aSource.GetPointer(); - aDataSet->ShallowCopy(aGeometry); + vtkUnstructuredGrid* aDataSet; + if(myIsSpecialKey){ + PNamedIDMapperMap::iterator aIter; + aIter = myMappers.find(VISU::CELL_ENTITY); + if(aIter!=myMappers.end()) myCommonCellsFilter->SetCellsUG((aIter->second)->GetUnstructuredGridOutput()); + else { + aIter = myMappers.find(VISU::FACE_ENTITY); + if(aIter!=myMappers.end()) myCommonCellsFilter->SetCellsUG((aIter->second)->GetUnstructuredGridOutput()); + else { + aIter = myMappers.find(VISU::EDGE_ENTITY); + if(aIter!=myMappers.end()) myCommonCellsFilter->SetCellsUG((aIter->second)->GetUnstructuredGridOutput()); + } + } + } + + aGeometry = anAppendFilter->GetOutput(); + aDataSet = aSource.GetPointer(); + aDataSet->ShallowCopy(aGeometry); + const PMergeFilter& aFilter = GetFilter(); aFilter->SetGeometry(aGeometry); aFilter->SetScalars(aDataSet); @@ -477,8 +507,10 @@ namespace VISU aFilter->AddField("VISU_FIELD",aDataSet); aFilter->AddField("VISU_CELLS_MAPPER",aDataSet); aFilter->AddField("VISU_POINTS_MAPPER",aDataSet); - } - return myFilter->GetUnstructuredGridOutput(); + + myCommonCellsFilter->SetProfileUG(aFilter->GetUnstructuredGridOutput()); + } + return myCommonCellsFilter->GetOutput(); } vtkDataSet* @@ -494,10 +526,14 @@ namespace VISU { size_t aSize = myIDMapper->GetMemorySize(); aSize += mySource.GetMemorySize(); + if(vtkUnstructuredGrid* anOutput = myCommonCellsFilter->GetOutput()) + aSize += anOutput->GetActualMemorySize() * 1024; + PNamedIDMapperMap::const_iterator aIter = myMappers.begin(); + for(;aIter!=myMappers.end();aIter++) + aSize += (aIter->second)->GetMemorySize(); return aSize; } - //--------------------------------------------------------------- vtkIdType TPolyDataIDMapperImpl diff --git a/src/CONVERTOR/VISU_Structures_impl.hxx b/src/CONVERTOR/VISU_Structures_impl.hxx index baf47957..08461db1 100644 --- a/src/CONVERTOR/VISU_Structures_impl.hxx +++ b/src/CONVERTOR/VISU_Structures_impl.hxx @@ -134,6 +134,38 @@ namespace VISU GetUnstructuredGridOutput(); }; + /*! + This container allow to combine other VTK representation into single one. + */ + class VISU_CONVERTOR_EXPORT TCommonCellsFilterHolder: public virtual TMemoryCheckIDMapper + { + protected: + mutable PCommonCellsFilter myFilter; + mutable PMergeFilter myMergeFilter; + public: + TCommonCellsFilterHolder(); + + //! This method allow to create corresponding VTK filter by demand (not at once) + const PCommonCellsFilter& + GetFilter() const; + + //! Reimplement the TNamedIDMapper::GetUnstructuredGridOutput + virtual + vtkUnstructuredGrid* + GetUnstructuredGridOutput(); + + virtual + unsigned long int + GetMemorySize(); + + //! if false, TIDCommonCellsFilter - same as TIDMapperFilter + //! if true, TIDCommonCellsFilter - use VISU_CommonCellsFilter + bool myIsSpecialKey; + + //! Vector of id mappers, which consist of meshonentity in next sequence: + //! CELL_ENTITY,FACE_ENTITY,EDGE_ENTITY + PNamedIDMapperMap myMappers; + }; //--------------------------------------------------------------- //! Define a container for VTK representation @@ -311,9 +343,12 @@ namespace VISU struct TUnstructuredGridIDMapperImpl: virtual TMergeFilterHolder, virtual TUnstructuredGridIDMapper { - PAppendFilterHolder myIDMapper; //!< Responsible for numbering - TUnstructuredGridHolder mySource; //!< Keeps assigned data + PAppendFilterHolder myIDMapper; //!< Responsible for numbering + PCommonCellsFilter myCommonCellsFilter; + TUnstructuredGridHolder mySource; //!< Keeps assigned data + TUnstructuredGridIDMapperImpl(); + //! Reimplement the TIDMapper::GetNodeObjID virtual vtkIdType @@ -358,8 +393,15 @@ namespace VISU virtual unsigned long int GetMemorySize(); - }; + + //! if false, Not using CommonCellsFilter + //! if true, Using CommonCellsFilter + bool myIsSpecialKey; + //! Vector of id mappers, which consist of meshonentity in next sequence: + //! CELL_ENTITY,FACE_ENTITY,EDGE_ENTITY + PNamedIDMapperMap myMappers; + }; //--------------------------------------------------------------- //! Specialize TIDMapper to provide VTK mapping for MED TIMESTAMP mesh