From 5c3264a88c3ceda665a162879864129d172a457e Mon Sep 17 00:00:00 2001 From: rnv Date: Thu, 22 May 2008 06:41:17 +0000 Subject: [PATCH] Improvement NPAL13676 EDF 318 (VISU Post-processing on quadratic elements). Join modifications from BR_ELNO_visualization branch. --- src/CONVERTOR/Makefile.am | 2 + src/CONVERTOR/VISU_Convertor_impl.cxx | 154 +++--- src/CONVERTOR/VISU_Convertor_impl.hxx | 37 +- src/CONVERTOR/VISU_ElnoMeshValue.hxx | 162 ++++++ src/CONVERTOR/VISU_MedConvertor.cxx | 42 +- src/CONVERTOR/VISU_MeshValue.cxx | 265 +++++---- src/CONVERTOR/VISU_MeshValue.hxx | 3 + src/CONVERTOR/VISU_Structures.hxx | 4 - src/CONVERTOR/VISU_Structures_impl.cxx | 126 +++-- src/CONVERTOR/VISU_Structures_impl.hxx | 38 +- src/CONVERTOR/VISU_TypeList.hxx | 83 ++- src/CONVERTOR/VISU_VTKTypeList.hxx | 120 +++++ src/PIPELINE/Makefile.am | 8 +- src/PIPELINE/VISUPipeLine.cxx | 564 +++++++++----------- src/PIPELINE/VISU_ColoredPL.cxx | 1 + src/PIPELINE/VISU_CutPlanesPL.cxx | 2 + src/PIPELINE/VISU_DataSetMapperHolder.cxx | 26 +- src/PIPELINE/VISU_DataSetMapperHolder.hxx | 9 +- src/PIPELINE/VISU_ElnoAssembleFilter.cxx | 171 ++++++ src/PIPELINE/VISU_ElnoAssembleFilter.hxx | 47 ++ src/PIPELINE/VISU_ElnoDisassembleFilter.cxx | 393 ++++++++++++++ src/PIPELINE/VISU_ElnoDisassembleFilter.hxx | 48 ++ src/PIPELINE/VISU_IsoSurfacesPL.cxx | 2 + src/PIPELINE/VISU_PipeLineUtils.cxx | 1 + src/PIPELINE/VISU_ScalarMapPL.cxx | 20 +- src/PIPELINE/VISU_ScalarMapPL.hxx | 9 +- 26 files changed, 1709 insertions(+), 628 deletions(-) create mode 100644 src/CONVERTOR/VISU_ElnoMeshValue.hxx create mode 100644 src/CONVERTOR/VISU_VTKTypeList.hxx create mode 100644 src/PIPELINE/VISU_ElnoAssembleFilter.cxx create mode 100644 src/PIPELINE/VISU_ElnoAssembleFilter.hxx create mode 100644 src/PIPELINE/VISU_ElnoDisassembleFilter.cxx create mode 100644 src/PIPELINE/VISU_ElnoDisassembleFilter.hxx diff --git a/src/CONVERTOR/Makefile.am b/src/CONVERTOR/Makefile.am index 448bbdca..30a5a876 100644 --- a/src/CONVERTOR/Makefile.am +++ b/src/CONVERTOR/Makefile.am @@ -28,6 +28,7 @@ lib_LTLIBRARIES = libVisuConvertor.la salomeinclude_HEADERS= \ VISU_TypeList.hxx \ + VISU_VTKTypeList.hxx \ VISU_IDMapper.hxx \ VISU_ConvertorDef.hxx \ VISU_Structures.hxx \ @@ -35,6 +36,7 @@ salomeinclude_HEADERS= \ VISU_ConvertorDef_impl.hxx \ VISU_Structures_impl.hxx \ VISU_MeshValue.hxx \ + VISU_ElnoMeshValue.hxx \ VISU_PointCoords.hxx \ VISU_Convertor_impl.hxx \ VISU_ConvertorUtils.hxx \ diff --git a/src/CONVERTOR/VISU_Convertor_impl.cxx b/src/CONVERTOR/VISU_Convertor_impl.cxx index c8bdc2d1..c908ab0b 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.cxx +++ b/src/CONVERTOR/VISU_Convertor_impl.cxx @@ -85,18 +85,12 @@ namespace //--------------------------------------------------------------- + inline void - PrintCells(int& theStartId, - vtkCellArray* theConnectivity, - const VISU::TConnect& theVector) + PrintCells( vtkCellArray* theConnectivity, + const VISU::TConnect& theVector) { - vtkIdList *anIdList = vtkIdList::New(); - int kEnd = theVector.size(); - anIdList->SetNumberOfIds(kEnd); - for(int k = 0; k < kEnd; k++) - anIdList->SetId(k,theVector[k]); - theConnectivity->InsertNextCell(anIdList); - anIdList->Delete(); + theConnectivity->InsertNextCell( theVector.size(), &theVector[ 0 ] ); } @@ -124,7 +118,7 @@ namespace aCellTypesArray->SetNumberOfTuples(aNbCells); for(vtkIdType anID = 0; anID < aNbCells; anID++){ - PrintCells(anID,aConnectivity,anArray[anID]); + PrintCells( aConnectivity, anArray[ anID ] ); aCellTypesArray->SetValue(anID,(unsigned char)theGeom); } @@ -219,7 +213,7 @@ namespace VISU::TSubMeshID::const_iterator aSubMeshIDIter = aSubMeshID.begin(); for(; aSubMeshIDIter != aSubMeshID.end(); aSubMeshIDIter++, aCellId++){ vtkIdType anID = *aSubMeshIDIter; - PrintCells(aCellId, aConnectivity, anArray[anID]); + PrintCells( aConnectivity, anArray[ anID ] ); aCellTypesArray->SetValue(aCellId, (unsigned char)aVGeom); vtkIdType anObjID = aSubMesh.GetElemObjID(anID); anElemObj2VTKID[anObjID] = aCellId; @@ -284,7 +278,7 @@ namespace VISU::TCell2Connect::const_iterator anIter = aCell2Connect.begin(); for(vtkIdType anId = 0, aConnId = 0; anIter != aCell2Connect.end(); anIter++){ const VISU::TConnect& anArray = aCell2Connect[anId]; - PrintCells(aConnId,aConnectivity,anArray); + PrintCells( aConnectivity, anArray ); aCellTypesArray->SetValue(anId,(unsigned char)aVGeom); aConnId += aNbNodes; anId++; @@ -294,7 +288,7 @@ namespace for(vtkIdType anId = 0, aConnId = 0; anIter != aSubMeshID.end(); anIter++){ vtkIdType aSubId = *anIter; const VISU::TConnect& anArray = aCell2Connect[aSubId]; - PrintCells(aConnId,aConnectivity,anArray); + PrintCells( aConnectivity, anArray ); aCellTypesArray->SetValue(anId,(unsigned char)aVGeom); aConnId += aNbNodes; anId++; @@ -847,81 +841,63 @@ VISU_Convertor_impl //--------------------------------------------------------------- vtkUnstructuredGrid* VISU_Convertor_impl -::GetTimeStampOnProfile(const VISU::PMeshImpl& theMesh, - const VISU::PMeshOnEntityImpl& theMeshOnEntity, - const VISU::PFieldImpl& theField, - const VISU::PValForTimeImpl& theValForTime, - const VISU::PUnstructuredGridIDMapperImpl& theUnstructuredGridIDMapper, - const VISU::PProfileImpl& theProfile, - const VISU::TEntity& theEntity) +::GetTimeStampOnProfile( const VISU::PMeshImpl& theMesh, + const VISU::PMeshOnEntityImpl& theMeshOnEntity, + const VISU::PFieldImpl& theField, + const VISU::PValForTimeImpl& theValForTime, + const VISU::PUnstructuredGridIDMapperImpl& theUnstructuredGridIDMapper, + 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; + LoadMeshOnEntity( theMesh, theMeshOnEntity ); + GetMeshOnEntity( theMeshOnEntity->myMeshName, theMeshOnEntity->myEntity ); + GetMeshOnProfile( theMesh, theMeshOnEntity, theProfile ); theUnstructuredGridIDMapper->myIDMapper = theProfile; - if(theMeshOnEntity->myEntity == VISU::NODE_ENTITY){ + + 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; + const VISU::TGeom2SubProfile& aGeom2SubProfile = theProfile->myGeom2SubProfile; + VISU::TGeom2SubProfile::const_iterator aSubProfileIter = aGeom2SubProfile.begin(); + for ( ; aSubProfileIter != aGeom2SubProfile.end(); aSubProfileIter++ ) { + const VISU::EGeometry& aGeom = aSubProfileIter->first; + const VISU::PSubProfileImpl& aSubProfile = aSubProfileIter->second; + if ( aSubProfile->myStatus == VISU::eAddPart && aGeom == VISU::ePOINT1 ) { + const VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap; + VISU::TMeshOnEntityMap::const_reverse_iterator aMeshOnEntityIter = aMeshOnEntityMap.rbegin(); + for( ; aMeshOnEntityIter != aMeshOnEntityMap.rend(); aMeshOnEntityIter++ ) { + VISU::TEntity anEntity = aMeshOnEntityIter->first; + if ( anEntity == VISU::NODE_ENTITY ) + continue; + VISU::PNamedIDMapper aNamedIDMapper = GetMeshOnEntity( theMesh->myName, anEntity ); + if( aNamedIDMapper ) { + theUnstructuredGridIDMapper->SetReferencedMesh( aNamedIDMapper ); + VISU::PUnstructuredGrid aSource = theUnstructuredGridIDMapper->GetSource(); + VISU::GetTimeStampOnProfile( aSource, theField, theValForTime, theEntity ); + + return theUnstructuredGridIDMapper->GetUnstructuredGridOutput(); + } + } } } - if(isNeedInCells){ - theUnstructuredGridIDMapper->myIsSpecialKey = true; - GetTimeStampOnNodalProfile(theMesh,theUnstructuredGridIDMapper,theField,theValForTime,theEntity); - anOutput = theUnstructuredGridIDMapper->GetUnstructuredGridOutput(); - } } - if(!isNeedInCells){ - 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; - } - } + VISU::PUnstructuredGrid aSource = theUnstructuredGridIDMapper->GetSource(); + VISU::GetTimeStampOnProfile( aSource, theField, theValForTime, theEntity ); - theIDMapperFilter->GetUnstructuredGridOutput(); - const VISU::PUnstructuredGrid& aSource = theIDMapperFilter->mySource.GetSource(); - VISU::GetTimeStampOnProfile(aSource,theField,theValForTime,theEntity); + return theUnstructuredGridIDMapper->GetUnstructuredGridOutput(); } + //--------------------------------------------------------------- VISU::PUnstructuredGridIDMapper VISU_Convertor_impl -::GetTimeStampOnMesh(const std::string& theMeshName, - const VISU::TEntity& theEntity, - const std::string& theFieldName, - int theStampsNum) +::GetTimeStampOnMesh( const std::string& theMeshName, + const VISU::TEntity& theEntity, + const std::string& theFieldName, + int theStampsNum ) { INITMSG(MYDEBUG,"GetTimeStampOnMesh"<< "; theMeshName = '"<myIDMapper = aGaussMesh; aGaussPtsIDFilter->myGaussPtsIDMapper = aGaussMesh; - vtkPolyData* anOutput = aGaussPtsIDFilter->GetPolyDataOutput(); - const VISU::PPolyData& aSource = aGaussPtsIDFilter->mySource.GetSource(); + VISU::PPolyData aSource = aGaussPtsIDFilter->GetSource(); VISU::GetTimeStampOnGaussMesh(aSource, aField, aValForTime); + vtkPolyData* anOutput = aGaussPtsIDFilter->GetPolyDataOutput(); aGaussPtsIDFilter->myIsVTKDone = true; @@ -1360,29 +1336,29 @@ VISU_Convertor_impl VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; VISU::PMeshOnEntityImpl aVTKMeshOnEntity = aMeshOnEntity; - if(theEntity == VISU::NODE_ENTITY){ - if(aMeshOnEntityMap.find(VISU::CELL_ENTITY) != aMeshOnEntityMap.end()) - aVTKMeshOnEntity = aMeshOnEntityMap[VISU::CELL_ENTITY]; - else if(aMeshOnEntityMap.find(VISU::FACE_ENTITY) != aMeshOnEntityMap.end()) - aVTKMeshOnEntity = aMeshOnEntityMap[VISU::FACE_ENTITY]; - else if(aMeshOnEntityMap.find(VISU::EDGE_ENTITY) != aMeshOnEntityMap.end()) - aVTKMeshOnEntity = aMeshOnEntityMap[VISU::EDGE_ENTITY]; - else if(aMeshOnEntityMap.find(VISU::NODE_ENTITY) != aMeshOnEntityMap.end()) - aVTKMeshOnEntity = aMeshOnEntityMap[VISU::NODE_ENTITY]; + if ( theEntity == VISU::NODE_ENTITY ) { + if(aMeshOnEntityMap.find( VISU::CELL_ENTITY ) != aMeshOnEntityMap.end()) + aVTKMeshOnEntity = aMeshOnEntityMap[ VISU::CELL_ENTITY ]; + else if (aMeshOnEntityMap.find( VISU::FACE_ENTITY ) != aMeshOnEntityMap.end() ) + aVTKMeshOnEntity = aMeshOnEntityMap[ VISU::FACE_ENTITY ]; + else if (aMeshOnEntityMap.find( VISU::EDGE_ENTITY ) != aMeshOnEntityMap.end() ) + aVTKMeshOnEntity = aMeshOnEntityMap[ VISU::EDGE_ENTITY ]; + else if ( aMeshOnEntityMap.find( VISU::NODE_ENTITY ) != aMeshOnEntityMap.end() ) + aVTKMeshOnEntity = aMeshOnEntityMap[ VISU::NODE_ENTITY ]; }else aVTKMeshOnEntity = aMeshOnEntity; VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap; - VISU::TFieldMap::const_iterator aFieldIter= aFieldMap.find(theFieldName); + VISU::TFieldMap::const_iterator aFieldIter= aFieldMap.find( theFieldName ); if(aFieldIter == aFieldMap.end()) EXCEPTION(std::runtime_error,"FindField >> There is no field on the mesh!!!"); VISU::PFieldImpl aField = aFieldIter->second; - return TFindField(aMesh, - aMeshOnEntity, - aVTKMeshOnEntity, - aField); + return TFindField( aMesh, + aMeshOnEntity, + aVTKMeshOnEntity, + aField ); } diff --git a/src/CONVERTOR/VISU_Convertor_impl.hxx b/src/CONVERTOR/VISU_Convertor_impl.hxx index f6cffc0e..14beaf5e 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.hxx +++ b/src/CONVERTOR/VISU_Convertor_impl.hxx @@ -120,10 +120,10 @@ public: //! Implemention of the VISU_Convertor::GetTimeStampOnMesh virtual VISU::PUnstructuredGridIDMapper - GetTimeStampOnMesh(const std::string& theMeshName, - const VISU::TEntity& theEntity, - const std::string& theFieldName, - int theTimeStampNumber); + GetTimeStampOnMesh( const std::string& theMeshName, + const VISU::TEntity& theEntity, + const std::string& theFieldName, + int theTimeStampNumber ); //! Get amount of memory to build vtkDataSet for corresponding MED TIMESTAMP on mesh virtual @@ -206,9 +206,9 @@ protected: VISU::PMeshOnEntityImpl, VISU::PFieldImpl> TFindField; TFindField - FindField(const std::string& theMeshName, - const VISU::TEntity& theEntity, - const std::string& theFieldName); + FindField( const std::string& theMeshName, + const VISU::TEntity& theEntity, + const std::string& theFieldName ); //! An utility method to find TTimeStamp by name of its parent mesh, corresponding entity, field name and its number typedef boost::tuple + + +/*! + \file VISU_ElnoMeshValue.hxx + \brief The file contains declarations for the acess to the specific ELNO MED data +*/ + +namespace VISU +{ + //--------------------------------------------------------------- + template< int elno_type > + struct TGetElnoNodeData + { + typedef typename TL::TEnum2VTKArrayType< elno_type >::TResult TVTKDataArray; + typedef typename TL::TEnum2VTKBasicType< elno_type >::TResult TDataType; + TVTKDataArray *myElnoDataArray; + vtkIntArray *myElnoDataMapper; + int myElemInfo[3]; + + + //---------------------------------------------------------------------------- + TGetElnoNodeData( vtkDataArray *theElnoDataArray, + vtkDataArray *theElnoDataMapper ) + : myElnoDataArray( TVTKDataArray::SafeDownCast( theElnoDataArray ) ) + , myElnoDataMapper( vtkIntArray::SafeDownCast( theElnoDataMapper ) ) + {} + + + //---------------------------------------------------------------------------- + TDataType* + operator () ( vtkIdType theCellId, vtkIdType theLocalPntId ) + { + myElnoDataMapper->GetTupleValue( theCellId, myElemInfo ); + + vtkIdType aPos = myElemInfo[ 0 ] + theLocalPntId * myElemInfo[ 1 ]; + + return myElnoDataArray->GetPointer( aPos ); + } + + + //---------------------------------------------------------------------------- + int + getNbComp() + { + myElnoDataMapper->GetTupleValue( 0, myElemInfo ); + + return myElemInfo[ 1 ]; + } + }; + + + //---------------------------------------------------------------------------------------------- + template< int elno_type > + struct TSetElnoNodeData + { + typedef typename TL::TEnum2VTKArrayType< elno_type >::TResult TVTKDataArray; + typedef typename TL::TEnum2VTKBasicType< elno_type >::TResult TDataType; + + //---------------------------------------------------------------------------------------------- + TSetElnoNodeData( vtkIdType theEffectNbComp, + vtkIdType theRealNbComp, + vtkIdType theNbTuples, + const char* theDataArrayName, + const char* theMapperArrayName ) + : myElnoDataArray( TVTKDataArray::New() ) + , myElnoDataMapper( vtkIntArray::New() ) + { + myElnoDataArray->SetNumberOfComponents( theEffectNbComp ); + myElnoDataArray->SetNumberOfTuples( theNbTuples ); + myElnoDataArray->SetName( theDataArrayName ); + + myElnoDataMapper->SetNumberOfComponents( 3 ); + myElnoDataMapper->Allocate( theNbTuples * 3 ); + myElnoDataMapper->SetName( theMapperArrayName ); + + myElemInfo[ 0 ] = 0; + myElemInfo[ 1 ] = theRealNbComp; + myElemInfo[ 2 ] = 0; + } + + + //---------------------------------------------------------------------------------------------- + ~TSetElnoNodeData() + { + myElnoDataArray->Delete(); + myElnoDataMapper->Delete(); + } + + + //---------------------------------------------------------------------------------------------- + int + AddNextPointData( TDataType* theDataPtr ) + { + vtkIdType aPos = myElemInfo[ 0 ] + myElemInfo[ 2 ] * myElemInfo[ 1 ]; + + TDataType* aDataPtr = myElnoDataArray->GetPointer( aPos ); + + for ( vtkIdType aCompId = 0; aCompId < myElemInfo[ 1 ]; aCompId++ ) + *aDataPtr++ = *theDataPtr++; + + return myElemInfo[ 2 ]++; + } + + + //---------------------------------------------------------------------------------------------- + void + InsertNextCellData() + { + myElnoDataMapper->InsertNextTupleValue( myElemInfo ); + myElemInfo[ 0 ] += myElemInfo[ 2 ] * myElemInfo[ 1 ]; + myElemInfo[ 2 ] = 0; + } + + + //---------------------------------------------------------------------------------------------- + void + AddData( vtkDataSetAttributes* theDataSetAttributes ) + { + theDataSetAttributes->AddArray( myElnoDataArray ); + theDataSetAttributes->AddArray( myElnoDataMapper ); + } + + protected: + TVTKDataArray *myElnoDataArray; + vtkIntArray *myElnoDataMapper; + int myElemInfo[ 3 ]; + }; + + + //--------------------------------------------------------------- +} + +#endif diff --git a/src/CONVERTOR/VISU_MedConvertor.cxx b/src/CONVERTOR/VISU_MedConvertor.cxx index 1cdb4f0d..35b7570d 100644 --- a/src/CONVERTOR/VISU_MedConvertor.cxx +++ b/src/CONVERTOR/VISU_MedConvertor.cxx @@ -140,15 +140,29 @@ namespace //--------------------------------------------------------------- VISU::TEntity - MEDEntityToVTK(MED::EEntiteMaillage theMEDEntity) + MEDEntityToVTK( MED::EEntiteMaillage theMEDEntity ) { + VISU::TEntity anEntity = VISU::TEntity( -1 ); + switch(theMEDEntity){ - case MED::eNOEUD: return VISU::NODE_ENTITY; - case MED::eARETE: return VISU::EDGE_ENTITY; - case MED::eFACE: return VISU::FACE_ENTITY; - case MED::eMAILLE: return VISU::CELL_ENTITY; + case MED::eNOEUD : + anEntity = VISU::NODE_ENTITY; + break; + case MED::eARETE : + anEntity = VISU::EDGE_ENTITY; + break; + case MED::eFACE : + anEntity = VISU::FACE_ENTITY; + break; + case MED::eMAILLE : + anEntity = VISU::CELL_ENTITY; + break; + case MED::eNOEUD_ELEMENT : + anEntity = VISU::CELL_ENTITY; + break; } - return VISU::TEntity(-1); + + return anEntity; } @@ -756,9 +770,9 @@ namespace if(aNbTimeStamps < 1) continue; - VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity); + VISU::TEntity aVEntity = MEDEntityToVTK( aMEntity ); vtkIdType aDataType = VTK_DOUBLE; - if(aFieldInfo->GetType() != MED::eFLOAT64){ + if ( aFieldInfo->GetType() != MED::eFLOAT64 ) { #if defined(HAVE_F77INT64) aDataType = VTK_LONG; #else @@ -774,6 +788,7 @@ namespace aField->myName = aFieldName; aField->myMeshName = aMeshName; aField->myDataSize = aMeshOnEntity->myNbCells * aNbComp; + aField->myIsELNO = true; // To set it true by default INITMSG(MYDEBUG,"myName = '"<myName<<"'"<< "; myId = "<myId<< @@ -815,11 +830,18 @@ namespace MED::TGeom2NbGauss::const_iterator anIter = aMGeom2NbGauss.begin(); for(; anIter != aMGeom2NbGauss.end(); anIter++){ const MED::EGeometrieElement& aMGeom = anIter->first; - VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom); + VISU::EGeometry aEGeom = MEDGeom2VISU( aMGeom ); TInt aNbGauss = anIter->second; - aVGeom2NbGauss[aEGeom] = aNbGauss; + aVGeom2NbGauss[ aEGeom ] = aNbGauss; + + // ELNO data should satisfy the following condition ( implcitly ) + vtkIdType aNbNodes = MEDGeom2NbNodes( aMGeom ); + aField->myIsELNO &= ( aNbGauss == aNbNodes ); } } + + // ELNO data should satisfy the following condition ( explicitly ) + aField->myIsELNO |= ( aMEntity == MED::eNOEUD_ELEMENT ); } } diff --git a/src/CONVERTOR/VISU_MeshValue.cxx b/src/CONVERTOR/VISU_MeshValue.cxx index 4b7a2785..51b4a72d 100644 --- a/src/CONVERTOR/VISU_MeshValue.cxx +++ b/src/CONVERTOR/VISU_MeshValue.cxx @@ -25,11 +25,12 @@ // Module : VISU #include "VISU_MeshValue.hxx" +#include "VISU_ElnoMeshValue.hxx" #include "VISU_Structures_impl.hxx" #include "VISU_ConvertorUtils.hxx" #include "VISU_PointCoords.hxx" -#include "VISU_TypeList.hxx" +#include "VISU_VTKTypeList.hxx" #include #include @@ -113,76 +114,6 @@ namespace VISU } - namespace TL - { - //---------------------------------------------------------------------------- - typedef TList > > > > > > > > > - TVTKBasicTypeList; - - - //---------------------------------------------------------------------------- - typedef TList > > > > > > > > > - TVTKArrayTypeList; - - - typedef TList, - TList, - TList, - TList, - TList, - TList, - TList, - TList, - TList, - TList, - TNullType> > > > > > > > > > - TVTKBasicEnumList; - - - //---------------------------------------------------------------------------- - template - struct TEnum2VTKBasicType - { - typedef typename TTypeAt >::value >::TResult TResult; - }; - - //---------------------------------------------------------------------------- - template - struct TEnum2VTKArrayType - { - typedef typename TTypeAt >::value >::TResult TResult; - }; - - //---------------------------------------------------------------------------- - template - struct TVTKBasicType2Enum - { - typedef typename TTypeAt::value >::TResult TResult; - }; - - } - - //---------------------------------------------------------------------------- template void @@ -360,46 +291,40 @@ namespace VISU typedef typename TL::TEnum2VTKArrayType::TResult TVTKDataArray; TVTKDataArray *aSelectedDataArray = TVTKDataArray::New(); vtkIdType aNbComp = theField->myNbComp; - switch(aNbComp) { - case 1: - aSelectedDataArray->SetNumberOfComponents(1); - aDataSetAttributes->SetScalars(aSelectedDataArray); - break; - default: - aSelectedDataArray->SetNumberOfComponents(3); - aDataSetAttributes->SetVectors(aSelectedDataArray); - } - aSelectedDataArray->SetNumberOfTuples(aNbTuples); - aSelectedDataArray->SetName(aFieldName.c_str()); + aSelectedDataArray->SetNumberOfComponents( 3 ); + aSelectedDataArray->SetNumberOfTuples( aNbTuples ); + aSelectedDataArray->SetName( aFieldName.c_str() ); + aDataSetAttributes->SetVectors( aSelectedDataArray ); TVTKDataArray *aFullDataArray = TVTKDataArray::New(); - aFullDataArray->SetNumberOfComponents(aNbComp); - aFullDataArray->SetNumberOfTuples(aNbTuples); - aFullDataArray->SetName("VISU_FIELD"); - aDataSetAttributes->AddArray(aFullDataArray); + aFullDataArray->SetNumberOfComponents( aNbComp ); + aFullDataArray->SetNumberOfTuples( aNbTuples ); + aFullDataArray->SetName( "VISU_FIELD" ); + aDataSetAttributes->AddArray( aFullDataArray ); INITMSG(MYDEBUG,"InitTimeStampOnProfile "<< "- theEntity = "<GetGeom2MeshValue(); - typedef typename TL::TEnum2VTKBasicType::TResult TVTKBasicType; - typedef TTMeshValue TMeshValue; - typedef MED::SharedPtr TMeshValuePtr; + typedef typename TL::TEnum2VTKBasicType< EDataType >::TResult TVTKBasicType; + typedef TTMeshValue< TVTKBasicType > TMeshValue; + typedef MED::SharedPtr< TMeshValue > TMeshValuePtr; - typedef TDataArrayHolder TTDataArrayHolder; - typedef MED::SharedPtr PDataArrayHolder; + typedef TDataArrayHolder< EDataType > TTDataArrayHolder; + typedef MED::SharedPtr< TTDataArrayHolder > PDataArrayHolder; TMeshValuePtr aMeshValue = theValForTime->GetFirstMeshValue(); - if(aGeom2MeshValue.size() == 1 && aMeshValue->GetNbGauss() == 1){ + if ( aGeom2MeshValue.size() == 1 && aMeshValue->GetNbGauss() == 1 ) { aFullDataArray->SetVoidArray(aMeshValue->GetPointer(), aMeshValue->size(), true); INITMSG(MYDEBUG,"InitTimeStampOnProfile - aFullDataArray->SetVoidArray()"<SetVoidArray(aMeshValue->GetPointer(), aMeshValue->size(), true); @@ -416,6 +341,66 @@ namespace VISU aSelectedDataArray->Delete(); aFullDataArray->Delete(); + + // Process the case for ELNO data + //------------------------------- + if ( theField->myIsELNO ) { + // To calculate effective number of components for the VTK compatibel ELNO data representation + vtkIdType aEffectNbTuples = 0; + TGeom2MeshValue::const_iterator anIter = aGeom2MeshValue.begin(); + for ( ; anIter != aGeom2MeshValue.end(); anIter++ ) { + const PMeshValue& aMeshValue = anIter->second; + aEffectNbTuples += aMeshValue->GetNbElem() * aMeshValue->GetNbGauss(); + } + + vtkIdType anEffectNbComp = ( aEffectNbTuples * aNbComp ) / aNbTuples + 1; + + // To create corresponding VTK representation for the ELNO data + TSetElnoNodeData< EDataType > aSetElnoNodeData( anEffectNbComp, + aNbComp, + aNbTuples, + "ELNO_FIELD", + "ELNO_COMPONENT_MAPPER" ); + + std::vector< TVTKBasicType > aDataValues( aNbComp ); // To reserve a temproary value holder + + // To initilize these VTK representation for the ELNO data from the MED + anIter = aGeom2MeshValue.begin(); + for ( ; anIter != aGeom2MeshValue.end(); anIter++ ) { + EGeometry aEGeom = anIter->first; + const TMeshValuePtr aMeshValue = anIter->second; + + vtkIdType aNbElem = aMeshValue->GetNbElem(); + vtkIdType aNbGauss = aMeshValue->GetNbGauss(); + + INITMSG(MYDEBUG, + "- aEGeom = "<AddField("VISU_CELLS_MAPPER",aDataSet); - aFilter->AddField("VISU_POINTS_MAPPER",aDataSet); - - myCommonCellsFilter->SetProfileUG(aFilter->GetUnstructuredGridOutput()); + aFilter->SetGeometry( aGeometry ); + aFilter->SetScalars( aDataSet ); + aFilter->SetVectors( aDataSet ); + aFilter->AddField( "VISU_FIELD", aDataSet ); + aFilter->AddField( "VISU_CELLS_MAPPER", aDataSet ); + aFilter->AddField( "ELNO_FIELD", aDataSet ); + aFilter->AddField( "ELNO_COMPONENT_MAPPER", aDataSet ); + aFilter->AddField( "VISU_POINTS_MAPPER", aDataSet ); + + myCommonCellsFilter->SetProfileUG( aFilter->GetUnstructuredGridOutput() ); } + } + + vtkUnstructuredGrid* + TUnstructuredGridIDMapperImpl + ::GetUnstructuredGridOutput() + { + Build(); return myCommonCellsFilter->GetOutput(); } @@ -733,17 +730,25 @@ namespace VISU return GetUnstructuredGridOutput(); } + PUnstructuredGrid + TUnstructuredGridIDMapperImpl + ::GetSource() + { + Build(); + return mySource.GetSource(); + } + unsigned long int TUnstructuredGridIDMapperImpl ::GetMemorySize() { size_t aSize = myIDMapper->GetMemorySize(); + aSize += mySource.GetMemorySize(); - if(vtkUnstructuredGrid* anOutput = myCommonCellsFilter->GetOutput()) + + 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; } @@ -790,26 +795,33 @@ namespace VISU return myIDMapper->GetElemCell(theObjID); } - vtkPolyData* + void TPolyDataIDMapperImpl - ::GetPolyDataOutput() + ::Build() { - if(!myFilter.GetPointer()){ + if ( !myFilter.GetPointer() ) { const PAppendPolyData& anAppendFilter = myIDMapper->GetFilter(); vtkPolyData* aGeometry = anAppendFilter->GetOutput(); const PPolyData& aSource = mySource.GetSource(); vtkPolyData* aDataSet = aSource.GetPointer(); - aDataSet->ShallowCopy(aGeometry); + aDataSet->ShallowCopy( aGeometry ); const PMergeFilter& aFilter = GetFilter(); - aFilter->SetGeometry(aGeometry); - aFilter->SetScalars(aDataSet); - aFilter->SetVectors(aDataSet); - aFilter->AddField("VISU_FIELD",aDataSet); - aFilter->AddField("VISU_CELLS_MAPPER",aDataSet); - aFilter->AddField("VISU_POINTS_MAPPER",aDataSet); + aFilter->SetGeometry( aGeometry ); + aFilter->SetScalars( aDataSet ); + aFilter->SetVectors( aDataSet ); + aFilter->AddField( "VISU_FIELD", aDataSet ); + aFilter->AddField( "VISU_CELLS_MAPPER", aDataSet ); + aFilter->AddField( "VISU_POINTS_MAPPER", aDataSet ); } + } + + vtkPolyData* + TPolyDataIDMapperImpl + ::GetPolyDataOutput() + { + Build(); return myFilter->GetPolyDataOutput(); } @@ -820,6 +832,14 @@ namespace VISU return GetPolyDataOutput(); } + PPolyData + TPolyDataIDMapperImpl + ::GetSource() + { + Build(); + return mySource.GetSource(); + } + unsigned long int TPolyDataIDMapperImpl ::GetMemorySize() @@ -971,7 +991,6 @@ namespace VISU return aResult; size_t aSubMeshEnd = myGaussSubMeshArr.size(); - const PAppendFilter& anAppendFilter = GetFilter(); const PGaussSubMeshImpl& aGaussSubMesh = anIter->second; for ( size_t aSubMeshId = 0; aSubMeshId < aSubMeshEnd; aSubMeshId++ ) { const PGaussSubMeshImpl& aSubMesh = myGaussSubMeshArr[aSubMeshId]; @@ -1337,9 +1356,10 @@ namespace VISU //--------------------------------------------------------------- TFieldImpl - ::TFieldImpl(): - myDataSize(0), - myDataType(0) + ::TFieldImpl() + : myDataSize( 0 ) + , myDataType( 0 ) + , myIsELNO( false ) {} void diff --git a/src/CONVERTOR/VISU_Structures_impl.hxx b/src/CONVERTOR/VISU_Structures_impl.hxx index 35bbc9e3..6b4bc01d 100644 --- a/src/CONVERTOR/VISU_Structures_impl.hxx +++ b/src/CONVERTOR/VISU_Structures_impl.hxx @@ -157,14 +157,6 @@ namespace VISU 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; }; //--------------------------------------------------------------- @@ -348,9 +340,8 @@ namespace VISU struct TUnstructuredGridIDMapperImpl: virtual TMergeFilterHolder, virtual TUnstructuredGridIDMapper { - PAppendFilterHolder myIDMapper; //!< Responsible for numbering - PCommonCellsFilter myCommonCellsFilter; - TUnstructuredGridHolder mySource; //!< Keeps assigned data + PAppendFilterHolder myIDMapper; //!< Responsible for numbering + PCommonCellsFilter myCommonCellsFilter; TUnstructuredGridIDMapperImpl(); @@ -399,13 +390,16 @@ namespace VISU unsigned long int GetMemorySize(); - //! if false, Not using CommonCellsFilter - //! if true, Using CommonCellsFilter - bool myIsSpecialKey; + void + SetReferencedMesh( const PNamedIDMapper& theNamedIDMapper ); + + PUnstructuredGrid + GetSource(); + + protected: + void Build(); - //! Vector of id mappers, which consist of meshonentity in next sequence: - //! CELL_ENTITY,FACE_ENTITY,EDGE_ENTITY - PNamedIDMapperMap myMappers; + TUnstructuredGridHolder mySource; //!< Keeps assigned data }; //--------------------------------------------------------------- @@ -414,7 +408,6 @@ namespace VISU virtual TPolyDataIDMapper { PAppendPolyDataHolder myIDMapper; //!< Responsible for numbering - TPolyDataHolder mySource; //!< Keeps assigned data //! Reimplement the TIDMapper::GetNodeObjID virtual @@ -460,6 +453,14 @@ namespace VISU virtual unsigned long int GetMemorySize(); + + PPolyData + GetSource(); + + protected: + void Build(); + + TPolyDataHolder mySource; //!< Keeps assigned data }; @@ -829,6 +830,7 @@ namespace VISU vtkIdType myDataSize; //!< Keeps size of the assigned data vtkIdType myDataType; //!< Keeps type idetificator of the mesh data TMinMaxArr myMinMaxArr; //!< Keeps min/max values for each component of the MED FIELD + bool myIsELNO; //!< Defines whether this field contains specific "ELNO" data or not }; diff --git a/src/CONVERTOR/VISU_TypeList.hxx b/src/CONVERTOR/VISU_TypeList.hxx index 1a09efc3..a2eda5b7 100644 --- a/src/CONVERTOR/VISU_TypeList.hxx +++ b/src/CONVERTOR/VISU_TypeList.hxx @@ -20,77 +20,122 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // -// File : VISU_ColoredPrs3dCache_i.hh +// File : VISU_TypeList.hxx // Author : Oleg UVAROV // Module : VISU #ifndef VISU_TypeList_HeaderFile #define VISU_TypeList_HeaderFile + +//---------------------------------------------------------------------------- namespace VISU { + //---------------------------------------------------------------------------- namespace TL { //---------------------------------------------------------------------------- - template + struct TNullType {}; + + + //---------------------------------------------------------------------------- + template < class T, class U > struct TList { typedef T THead; typedef U TTail; }; - template + template < int v > struct TInt2Type { enum { value = v }; }; - struct TNullType {}; - + //---------------------------------------------------------------------------- - template + template < class TypeList, unsigned int index > struct TTypeAt; - template - struct TTypeAt, 0> + template < class THead, class TTail > + struct TTypeAt< TList< THead, TTail >, 0 > { typedef THead TResult; }; - template - struct TTypeAt, index> + template < class THead, class TTail, unsigned int index > + struct TTypeAt< TList< THead, TTail >, index > { - typedef typename TTypeAt::TResult TResult; + typedef typename TTypeAt< TTail, index - 1 >::TResult TResult; }; + //---------------------------------------------------------------------------- - template + template < class TypeList, class T > struct TIndexOf; - template - struct TIndexOf + template < class T > + struct TIndexOf< TNullType, T > { enum { value = -1 }; }; - template - struct TIndexOf, T> + template < class T, class TTail > + struct TIndexOf< TList< T, TTail >, T > { enum { value = 0 }; }; - template - struct TIndexOf, T> + template < class THead, class TTail, class T > + struct TIndexOf< TList< THead, TTail >, T > { private: - enum { temp = TIndexOf::value }; + enum { temp = TIndexOf< TTail, T >::value }; public: enum { value = temp == -1? -1 : 1 + temp }; }; + + //---------------------------------------------------------------------------- + template + < + class T01 = TNullType, class T02 = TNullType, class T03 = TNullType, class T04 = TNullType, class T05 = TNullType, + class T06 = TNullType, class T07 = TNullType, class T08 = TNullType, class T09 = TNullType, class T10 = TNullType, + class T11 = TNullType, class T12 = TNullType, class T13 = TNullType, class T14 = TNullType, class T15 = TNullType, + class T16 = TNullType, class T17 = TNullType, class T18 = TNullType, class T19 = TNullType, class T20 = TNullType, + class T21 = TNullType, class T22 = TNullType, class T23 = TNullType, class T24 = TNullType, class T25 = TNullType, + class T26 = TNullType, class T27 = TNullType, class T28 = TNullType, class T29 = TNullType, class T30 = TNullType, + class T31 = TNullType, class T32 = TNullType, class T33 = TNullType, class T34 = TNullType, class T35 = TNullType, + class T36 = TNullType, class T37 = TNullType, class T38 = TNullType, class T39 = TNullType, class T40 = TNullType + > + struct TSequence + { + private: + typedef typename TSequence< T02, T03, T04, T05, T06, T07, T08, T09, T10, + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, + T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, + T31, T32, T33, T34, T35, T36, T37, T38, T39, T40 + >::TResult + TailResult; + public: + typedef TList< T01, TailResult > TResult; + }; + + + //---------------------------------------------------------------------------- + template<> + struct TSequence<> + { + typedef TNullType TResult; + }; + + //---------------------------------------------------------------------------- } + + + //---------------------------------------------------------------------------- } #endif diff --git a/src/CONVERTOR/VISU_VTKTypeList.hxx b/src/CONVERTOR/VISU_VTKTypeList.hxx new file mode 100644 index 00000000..f210f652 --- /dev/null +++ b/src/CONVERTOR/VISU_VTKTypeList.hxx @@ -0,0 +1,120 @@ +// VISU OBJECT : interactive object for VISU entities implementation +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// File : VISU_VTKTypeList.hxx +// Author : Oleg UVAROV +// Module : VISU + +#ifndef VISU_VTKTypeList_HeaderFile +#define VISU_VTKTypeList_HeaderFile + +#include "VISU_TypeList.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +//---------------------------------------------------------------------------- +namespace VISU +{ + //---------------------------------------------------------------------------- + namespace TL + { + //---------------------------------------------------------------------------- + typedef TSequence< char, + unsigned char, + short, + unsigned short, + int, + unsigned int, + long, + unsigned long, + float, + double >::TResult TVTKBasicTypeList; + + + //---------------------------------------------------------------------------- + typedef TSequence< vtkCharArray, + vtkUnsignedCharArray, + vtkShortArray, + vtkUnsignedShortArray, + vtkIntArray, + vtkUnsignedIntArray, + vtkLongArray, + vtkUnsignedLongArray, + vtkFloatArray, + vtkDoubleArray >::TResult TVTKArrayTypeList; + + + //---------------------------------------------------------------------------- + typedef TSequence< TInt2Type< VTK_CHAR >, + TInt2Type< VTK_UNSIGNED_CHAR >, + TInt2Type< VTK_SHORT >, + TInt2Type< VTK_UNSIGNED_SHORT >, + TInt2Type< VTK_INT >, + TInt2Type< VTK_UNSIGNED_INT >, + TInt2Type< VTK_LONG >, + TInt2Type< VTK_UNSIGNED_LONG >, + TInt2Type< VTK_FLOAT >, + TInt2Type< VTK_DOUBLE > >::TResult TVTKBasicEnumList; + + + //---------------------------------------------------------------------------- + template< unsigned int type_enum > + struct TEnum2VTKBasicType + { + typedef typename TTypeAt< TVTKBasicTypeList, TIndexOf< TVTKBasicEnumList, TInt2Type< type_enum > >::value >::TResult TResult; + }; + + + //---------------------------------------------------------------------------- + template< unsigned int type_enum > + struct TEnum2VTKArrayType + { + typedef typename TTypeAt< TVTKArrayTypeList, TIndexOf< TVTKBasicEnumList, TInt2Type< type_enum > >::value >::TResult TResult; + }; + + + //---------------------------------------------------------------------------- + template< class T > + struct TVTKBasicType2Enum + { + typedef typename TTypeAt< TVTKBasicEnumList, TIndexOf< TVTKBasicTypeList, T >::value >::TResult TResult; + }; + + + //---------------------------------------------------------------------------- + } + + + //---------------------------------------------------------------------------- +} + +#endif diff --git a/src/PIPELINE/Makefile.am b/src/PIPELINE/Makefile.am index 82bc4155..5a3a1308 100644 --- a/src/PIPELINE/Makefile.am +++ b/src/PIPELINE/Makefile.am @@ -65,7 +65,9 @@ salomeinclude_HEADERS= \ VISU_WidgetCtrl.hxx \ VISU_DeformedShapeAndScalarMapPL.hxx \ VISUPipeline.hxx \ - VISU_LabelPointsFilter.hxx + VISU_LabelPointsFilter.hxx \ + VISU_ElnoDisassembleFilter.hxx \ + VISU_ElnoAssembleFilter.hxx dist_libVisuPipeLine_la_SOURCES= \ VISU_MapperHolder.cxx \ @@ -103,7 +105,9 @@ dist_libVisuPipeLine_la_SOURCES= \ VISU_WidgetCtrl.cxx \ VISU_ScalarBarCtrl.cxx \ VISU_DeformedShapeAndScalarMapPL.cxx \ - VISU_LabelPointsFilter.cxx + VISU_LabelPointsFilter.cxx \ + VISU_ElnoDisassembleFilter.cxx \ + VISU_ElnoAssembleFilter.cxx libVisuPipeLine_la_CPPFLAGS= \ $(VTK_INCLUDES) \ diff --git a/src/PIPELINE/VISUPipeLine.cxx b/src/PIPELINE/VISUPipeLine.cxx index ff3ba992..83047993 100644 --- a/src/PIPELINE/VISUPipeLine.cxx +++ b/src/PIPELINE/VISUPipeLine.cxx @@ -24,6 +24,11 @@ // Author: Alexey PETROV // Module : VISU + +// Salome includes +#include "VISU_Convertor.hxx" +#include "VISU_ConvertorUtils.hxx" + #include "VISU_MeshPL.hxx" #include "VISU_ScalarMapPL.hxx" #include "VISU_IsoSurfacesPL.hxx" @@ -35,352 +40,293 @@ #include "VISU_GaussPointsPL.hxx" #include "VISU_DeformedShapeAndScalarMapPL.hxx" #include "VISU_Plot3DPL.hxx" -#include "VISU_ScalarBarActor.hxx" - -#include "VISU_DeformedGridPL.hxx" +#include "VISU_ScalarBarActor.hxx" #include "VISU_OpenGLPointSpriteMapper.hxx" #include "VTKViewer_GeometryFilter.h" -#include -#include "VISU_Convertor.hxx" -#include "VISU_TableReader.hxx" -#include "VISU_ConvertorUtils.hxx" +#include "VISU_ElnoDisassembleFilter.hxx" +#include "VISU_ElnoAssembleFilter.hxx" + +typedef VISU_ScalarMapPL TPresent; + +#include +#include -typedef VISU_StreamLinesPL TPresent; +#include +#include +#include + +#include +#include + +// VTK includes +#include +#include #include #include - #include #include #include #include +#include #include #include #include #include - #include -#include - -#include - -//#define _DEBUG_ID_MAPPING_ - -//---------------------------------------------------------------------------- -template -VISU_ColoredPL* -CreateColoredPL(VISU_Convertor* theConvertor, - const std::string& theMeshName, - const VISU::TEntity& theEntity, - const std::string& theFieldName, - int theTimeStampNumber); - - -//---------------------------------------------------------------------------- -template<> -VISU_ColoredPL* -CreateColoredPL(VISU_Convertor* theConvertor, - const std::string& theMeshName, - const VISU::TEntity& theEntity, - const std::string& theFieldName, - int theTimeStampNumber) -{ - VISU_GaussPointsPL* aPresent = VISU_GaussPointsPL::New(); - VISU::PGaussPtsIDMapper aGaussPtsIDMapper = - theConvertor->GetTimeStampOnGaussPts(theMeshName, - theEntity, - theFieldName, - theTimeStampNumber); - aPresent->SetGaussPtsIDMapper(aGaussPtsIDMapper); - - char aMainTexture[80]; - strcpy( aMainTexture, getenv( "VISU_ROOT_DIR" ) ); - strcat( aMainTexture, "/share/salome/resources/visu/sprite_texture.bmp" ); - - char anAlphaTexture[80]; - strcpy( anAlphaTexture, getenv( "VISU_ROOT_DIR" ) ); - strcat( anAlphaTexture, "/share/salome/resources/visu/sprite_alpha.bmp" ); +void PrintMissing(){ + cout<<"VISUPipeLine : "; + cout<<"missing operand after `VISUPipeLine'"< aTextureValue = - VISU_GaussPointsPL::MakeTexture( aMainTexture, anAlphaTexture ); - aPresent->SetImageData( aTextureValue.GetPointer() ); - - aPresent->Update(); - -#ifdef _DEBUG_ID_MAPPING_ - vtkDataSet* aDataSet = aPresent->GetOutput(); - aDataSet->Update(); - int aNbCells = aDataSet->GetNumberOfCells(); - cout<<"aNbCells = "<GetNodeObjID(anCellId); - vtkIdType aVtkID = aPresent->GetNodeVTKID(anObjID); - cout<GetNodeCoord(anObjID); - cout< -VISU_ColoredPL* -CreateColoredPL(VISU_Convertor* theConvertor, - const std::string& theMeshName, - const VISU::TEntity& theEntity, - const std::string& theFieldName, - int theTimeStampNumber) -{ - TPipeLine* aPresent = TPipeLine::New(); - VISU::PUnstructuredGridIDMapper anUnstructuredGridIDMapper = - theConvertor->GetTimeStampOnMesh(theMeshName, - theEntity, - theFieldName, - theTimeStampNumber); - aPresent->SetUnstructuredGridIDMapper(anUnstructuredGridIDMapper); - - //aPresent->ClearGeometry(); - //{ - // VISU::PUnstructuredGridIDMapper anIDMapper = - // theConvertor->GetMeshOnGroup(theMeshName, - // "groupe1"); - // aPresent->AddGeometry(anIDMapper->GetOutput()); - //} - //{ - // VISU::PUnstructuredGridIDMapper anIDMapper = - // theConvertor->GetMeshOnGroup(theMeshName, - // "TUBEH "); - // aPresent->AddGeometry(anIDMapper->GetOutput()); - //} - //{ - // VISU::PUnstructuredGridIDMapper anIDMapper = - // theConvertor->GetMeshOnGroup(theMeshName, - // "STRI "); - // aPresent->AddGeometry(anIDMapper->GetOutput()); - //} - aPresent->Update(); - return aPresent; +void PrintHelp(){ + + cout<<" Usage: VISUPipeLine filename meshname fieldname [timestamp] [component] " < myConvertor; - - TMEDSource(char** argv): myConvertor(CreateConvertor(argv[1])) - { - myConvertor->BuildEntities(); - } -}; - - -//---------------------------------------------------------------------------- -struct TMeshBulder: TMEDSource -{ - TMeshBulder(char** argv): TMEDSource(argv) - {} - - int Publish(vtkRenderer *theRenderer) const - { - const VISU::TMeshMap& aMeshMap = myConvertor->GetMeshMap(); - VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin(); - if(aMeshMapIter == aMeshMap.end()) - return 0; - - const std::string& aMeshName = aMeshMapIter->first; - const VISU::PMesh aMesh = aMeshMapIter->second; - const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; - VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter; - - VISU::TEntity anEntity = VISU::CELL_ENTITY; - aMeshOnEntityMapIter = aMeshOnEntityMap.find(anEntity); - - VISU::PNamedIDMapper anIDMapper = myConvertor->GetMeshOnEntity(aMeshName, anEntity); - - VISU_MeshPL* aPresent = VISU_MeshPL::New(); - aPresent->SetUnstructuredGridIDMapper(anIDMapper); - - vtkActor* anActor = vtkActor::New(); - anActor->SetMapper(aPresent->GetMapper()); - anActor->GetProperty()->SetRepresentation(VTK_WIREFRAME); - - theRenderer->AddActor(anActor); - anActor->Delete(); - - return 0; - } -}; +void PrintErr(){ + cout<<"***************************ERROR*****************************************"<BuildGroups(); - myConvertor->BuildFields(); - myConvertor->BuildMinMax(); - const VISU::TMeshMap& aMeshMap = myConvertor->GetMeshMap(); - VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin(); - if(aMeshMapIter == aMeshMap.end()) - return 0; - - const std::string& aMeshName = aMeshMapIter->first; - 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::PMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second; - const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap; - VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin(); - for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){ - const VISU::PField aField = aFieldMapIter->second; - //if(aField->myNbComp == 1) - // continue; - const std::string& aFieldName = aFieldMapIter->first; - const VISU::TValField& aValField = aField->myValField; - VISU::TValField::const_reverse_iterator aValFieldIter = aValField.rbegin(); - if(aValFieldIter == aValField.rend()) - return 0; - - int aTimeStamp = aValFieldIter->first; - - VISU_ColoredPL* aPresent = NULL; - if(anEntity != VISU::NODE_ENTITY){ - aPresent = CreateColoredPL(myConvertor.get(), - aMeshName, - anEntity, - aFieldName, - aTimeStamp); - - }else{ - continue; - aPresent = CreateColoredPL(myConvertor.get(), - aMeshName, - anEntity, - aFieldName, - aTimeStamp); - } - - vtkActor* anActor = vtkActor::New(); - anActor->SetMapper(aPresent->GetMapper()); - - VISU_ScalarBarActor * aScalarBar = VISU_ScalarBarActor::New(); - aScalarBar->SetLookupTable(aPresent->GetBarTable()); - - theRenderer->AddActor(anActor); - anActor->Delete(); - - theRenderer->AddActor2D(aScalarBar); - aScalarBar->Delete(); - } + try{ + if(argc == 1){ + PrintMissing(); + return 1; + } + if(argc == 2 && !strcmp(argv[1],"-h")) { + PrintHelp(); + return 1; } - return 0; - } -}; - - -//---------------------------------------------------------------------------- -struct TXLSSource -{ - VISU::TTableContainer myContainer; - - TXLSSource(char** argv) - { - VISU::ImportTables( argv[1], myContainer ); - } - - int Publish(vtkRenderer *theRenderer) const - { - if ( myContainer.empty() ) - return 0; - - VISU::PPolyDataIDMapper anIDMapper = myContainer[0]; - - VISU_DeformedGridPL* aPresent = VISU_DeformedGridPL::New(); - aPresent->SetPolyDataIDMapper(anIDMapper); - //aPresent->SetContourPrs( true ); - aPresent->Update(); - - vtkActor* anActor = vtkActor::New(); - anActor->SetMapper(aPresent->GetMapper()); - - theRenderer->AddActor(anActor); - anActor->Delete(); - VISU_ScalarBarActor * aScalarBar = VISU_ScalarBarActor::New(); - aScalarBar->SetLookupTable(aPresent->GetBarTable()); + char* aFileName =0; + char* aMeshName =0; + char* aFieldName =0; + int aTimeStampNumber = 1; + int aComponentNumber = 0; + bool allInit = false; + bool isMeshOk = false; + bool isFieldOk = false; + bool isTimeStampOk = false; + bool isComponentOk = false; + + if(argc == 4 ){ + aFileName = new char[static_cast(strlen(argv[1])) + 1]; + aMeshName = new char[static_cast(strlen(argv[2])) + 1]; + aFieldName = new char[static_cast(strlen(argv[3])) + 1]; + + strcpy(aFileName,argv[1]); + strcpy(aMeshName,argv[2]); + strcpy(aFieldName,argv[3]); + + allInit = true; + } + + if(argc == 5) { + aFileName = new char[static_cast(strlen(argv[1])) + 1]; + aMeshName = new char[static_cast(strlen(argv[2])) + 1]; + aFieldName = new char[static_cast(strlen(argv[3])) + 1]; + + strcpy(aFileName,argv[1]); + strcpy(aMeshName,argv[2]); + strcpy(aFieldName,argv[3]); + + aTimeStampNumber = atoi(argv[4]); + allInit = true; + } - theRenderer->AddActor2D(aScalarBar); - aScalarBar->Delete(); + if(argc == 6) { + aFileName = new char[static_cast(strlen(argv[1])) + 1]; + aMeshName = new char[static_cast(strlen(argv[2])) + 1]; + aFieldName = new char[static_cast(strlen(argv[3])) + 1]; + + strcpy(aFileName,argv[1]); + strcpy(aMeshName,argv[2]); + strcpy(aFieldName,argv[3]); + + aTimeStampNumber = atoi(argv[4]); + aComponentNumber = atoi(argv[5]); + allInit = true; + } - return 0; - } -}; - -//---------------------------------------------------------------------------- -template -int RenderPresentation(const TPrsBuilder& thePrsBuilder) -{ - vtkRenderWindow *aWindow = vtkRenderWindow::New(); - vtkRenderer *aRenderer = vtkRenderer::New(); - - aWindow->AddRenderer(aRenderer); - aRenderer->GetActiveCamera()->ParallelProjectionOn(); - - vtkRenderWindowInteractor *anInteractor = vtkRenderWindowInteractor::New(); - anInteractor->SetRenderWindow(aWindow); - aWindow->Delete(); - - vtkInteractorStyle* aStyle = vtkInteractorStyleTrackballCamera::New(); - anInteractor->SetInteractorStyle(aStyle); - aStyle->Delete(); - - int aRet = thePrsBuilder.Publish(aRenderer); - - aWindow->Render(); - anInteractor->Start(); - - return aRet; -} - - -//---------------------------------------------------------------------------- -int -main(int argc, char** argv) -{ - try{ - if (argc > 1) { - QFileInfo aFileInfo( argv[1] ); - if ( aFileInfo.isFile() ) { - QString anExtension = aFileInfo.extension(); - if ( anExtension == "med" ) { - //TMeshBulder aBuilder( argv ); - TColoredPrsBulder aBuilder( argv ); - return RenderPresentation( aBuilder ); - } else if ( anExtension == "xls" || anExtension == "txt" ) - return RenderPresentation( TXLSSource( argv ) ); + if(allInit){ + + vtkRenderWindow *aWindow = vtkRenderWindow::New(); + vtkRenderer *aRenderer = vtkRenderer::New(); + + aWindow->AddRenderer(aRenderer); + aRenderer->GetActiveCamera()->ParallelProjectionOn(); + + vtkRenderWindowInteractor *anInteractor = vtkRenderWindowInteractor::New(); + anInteractor->SetRenderWindow(aWindow); + aWindow->Delete(); + + vtkInteractorStyle* aStyle = vtkInteractorStyleTrackballCamera::New(); + anInteractor->SetInteractorStyle(aStyle); + aStyle->Delete(); + + VISU_Convertor* aConvertor = CreateConvertor(aFileName); + aConvertor->BuildEntities(); + aConvertor->BuildGroups(); + aConvertor->BuildFields(); + aConvertor->BuildMinMax(); + const VISU::TMeshMap& aMeshMap = aConvertor->GetMeshMap(); + VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin(); + if(aMeshMapIter == aMeshMap.end()) return 0; + //Iterate by meshes + for (;aMeshMapIter != aMeshMap.end();aMeshMapIter++) { + + const std::string& theMeshName = aMeshMapIter->first; + if( strcmp(aMeshName, theMeshName.c_str()) ) + continue; + else + isMeshOk = true; + + const VISU::PMesh aMesh = aMeshMapIter->second; + const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; + VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter; + + aMeshOnEntityMapIter = aMeshOnEntityMap.begin(); + //Iterate by meshes on entity + for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++) { + const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first; + const VISU::PMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second; + + const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap; + VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin(); + + //Iterate by field + for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){ + const VISU::PField aField = aFieldMapIter->second; + const std::string& theFieldName = aFieldMapIter->first; + + if( strcmp(aFieldName, theFieldName.c_str()) ) + continue; + else + isFieldOk = true; + + if(aComponentNumber > aField->myNbComp) + continue; + else + isComponentOk = true; + + const VISU::TValField& aValField = aField->myValField; + VISU::TValField::const_iterator aValFieldIter = 0; + aValFieldIter = aValField.find(aTimeStampNumber); + if(aValFieldIter == aValField.end()) + continue; + else + isTimeStampOk = true; + + int aTimeStamp = aValFieldIter->first; + + vtkActor* anActor = vtkActor::New(); + + if(anEntity != VISU::NODE_ENTITY){ + VISU::PUnstructuredGridIDMapper anUnstructuredGridIDMapper = + aConvertor->GetTimeStampOnMesh(theMeshName, + anEntity, + theFieldName, + aTimeStamp); + + vtkUnstructuredGrid* anUnstructuredGrid = anUnstructuredGridIDMapper->GetUnstructuredGridOutput(); + VISU::WriteToFile( anUnstructuredGrid, "/data/apo/elno_from_id_mapper.vtk" ); + + VISU_ElnoDisassembleFilter* aDisassembleFilter = VISU_ElnoDisassembleFilter::New(); + aDisassembleFilter->SetInput( anUnstructuredGrid ); + aDisassembleFilter->SetShrinkFactor( 0.999 ); + VISU::WriteToFile( aDisassembleFilter->GetOutput(), "/data/apo/elno_from_disassemble.vtk" ); + + vtkCutter *aCutter = vtkCutter::New(); + + vtkPointLocator* aPointLocator = vtkPointLocator::New(); + aCutter->SetLocator( aPointLocator ); + aPointLocator->Delete(); + + TPresent* aPresent = TPresent::New(); + aPresent->SetUnstructuredGridIDMapper( anUnstructuredGridIDMapper ); + //aPresent->SetOrientation( VISU_CutPlanesPL::ZX, 0.0, 0.0, 0 ); + aPresent->Update(); + + aPresent->GetMapper()->InterpolateScalarsBeforeMappingOn(); + anActor->SetMapper( aPresent->GetMapper() ); + + vtkScalarBarActor* aScalarBar = vtkScalarBarActor::New(); + //aScalarBar->SetLookupTable( aMapperTable ); + aScalarBar->SetLookupTable( aPresent->GetBarTable() ); + + + vtkScalarBarWidget* aWidget = vtkScalarBarWidget::New(); + aWidget->SetScalarBarActor( aScalarBar ); + aWidget->SetInteractor( anInteractor ); + aWidget->SetEnabled( true ); + + aRenderer->AddActor(anActor); + aRenderer->AddActor2D(aScalarBar); + }else{ + continue; + } + + aWindow->Render(); + aRenderer->ResetCamera(); + + anInteractor->Start(); + return 0; + } + } } } + else{ + PrintMissing(); + return 1; + } + + if(!isMeshOk) { + PrintErr(); + cout<<"Can not find mesh with name `"<SetInput(myExtractor->GetOutput()); GetMapperHolder()->SetLookupTable(GetMapperTable()); + GetMapper()->InterpolateScalarsBeforeMappingOn(); GetMapper()->SetUseLookupTableScalarRange(true); GetMapper()->SetColorModeToMapScalars(); GetMapper()->ScalarVisibilityOn(); diff --git a/src/PIPELINE/VISU_CutPlanesPL.cxx b/src/PIPELINE/VISU_CutPlanesPL.cxx index 22493a10..6928b498 100644 --- a/src/PIPELINE/VISU_CutPlanesPL.cxx +++ b/src/PIPELINE/VISU_CutPlanesPL.cxx @@ -47,6 +47,8 @@ VISU_CutPlanesPL { SetIsShrinkable(false); + SetElnoDisassembleState( true ); + myAppendPolyData = vtkAppendPolyData::New(); myNbParts = 10; diff --git a/src/PIPELINE/VISU_DataSetMapperHolder.cxx b/src/PIPELINE/VISU_DataSetMapperHolder.cxx index 313c6d68..4a9adf0a 100644 --- a/src/PIPELINE/VISU_DataSetMapperHolder.cxx +++ b/src/PIPELINE/VISU_DataSetMapperHolder.cxx @@ -28,6 +28,7 @@ #include "VISU_DataSetMapperHolder.hxx" #include "SALOME_ExtractGeometry.h" +#include "VISU_ElnoDisassembleFilter.hxx" #include "VISU_LookupTable.hxx" #include "VISU_PipeLineUtils.hxx" @@ -41,6 +42,8 @@ #include #include +#include + #ifdef _DEBUG_ static int MYDEBUG = 0; #else @@ -55,10 +58,13 @@ vtkStandardNewMacro(VISU_DataSetMapperHolder); //---------------------------------------------------------------------------- VISU_DataSetMapperHolder ::VISU_DataSetMapperHolder(): - myExtractGeometry(SALOME_ExtractGeometry::New()) + myElnoDisassembleFilter( VISU_ElnoDisassembleFilter::New() ), + myExtractGeometry( SALOME_ExtractGeometry::New() ) { if(MYDEBUG) MESSAGE("VISU_DataSetMapperHolder::VISU_DataSetMapperHolder - "<Delete(); + // Clipping functionality myExtractGeometry->Delete(); myExtractGeometry->SetStoreMapping(true); @@ -96,6 +102,19 @@ VISU_DataSetMapperHolder } +//---------------------------------------------------------------------------- +void +VISU_DataSetMapperHolder +::SetElnoDisassembleState( bool theIsShrunk ) +{ + vtkFloatingPointType aShrinkFactor = std::abs( myElnoDisassembleFilter->GetShrinkFactor() ); + if ( theIsShrunk ) + myElnoDisassembleFilter->SetShrinkFactor( aShrinkFactor ); + else + myElnoDisassembleFilter->SetShrinkFactor( -aShrinkFactor ); +} + + //---------------------------------------------------------------------------- unsigned long int VISU_DataSetMapperHolder @@ -116,9 +135,10 @@ void VISU_DataSetMapperHolder ::SetUnstructuredGridIDMapper(const VISU::PUnstructuredGridIDMapper& theIDMapper) { - myExtractGeometry->SetInput(theIDMapper->GetUnstructuredGridOutput()); + myElnoDisassembleFilter->SetInput( theIDMapper->GetUnstructuredGridOutput() ); + myExtractGeometry->SetInput( myElnoDisassembleFilter->GetOutput() ); myUnstructuredGridIDMapper = theIDMapper; - SetIDMapper(theIDMapper); + SetIDMapper( theIDMapper ); } diff --git a/src/PIPELINE/VISU_DataSetMapperHolder.hxx b/src/PIPELINE/VISU_DataSetMapperHolder.hxx index 45fa07fe..6588abd9 100644 --- a/src/PIPELINE/VISU_DataSetMapperHolder.hxx +++ b/src/PIPELINE/VISU_DataSetMapperHolder.hxx @@ -32,6 +32,7 @@ class vtkDataSetMapper; class vtkUnstructuredGrid; class SALOME_ExtractGeometry; +class VISU_ElnoDisassembleFilter; //---------------------------------------------------------------------------- @@ -50,6 +51,9 @@ public: ShallowCopy(VISU_MapperHolder *theMapperHolder, bool theIsCopyInput); + void + SetElnoDisassembleState( bool theIsShrunk ); + //! Gets memory size used by the instance (bytes). virtual unsigned long int @@ -158,8 +162,9 @@ protected: private: //---------------------------------------------------------------------------- VISU::PUnstructuredGridIDMapper myUnstructuredGridIDMapper; - vtkSmartPointer myDataSetMapper; - vtkSmartPointer myExtractGeometry; //!< Clipping + vtkSmartPointer< VISU_ElnoDisassembleFilter > myElnoDisassembleFilter; //!< Handling ELNO data + vtkSmartPointer< SALOME_ExtractGeometry > myExtractGeometry; //!< Clipping + vtkSmartPointer< vtkDataSetMapper > myDataSetMapper; }; #endif diff --git a/src/PIPELINE/VISU_ElnoAssembleFilter.cxx b/src/PIPELINE/VISU_ElnoAssembleFilter.cxx new file mode 100644 index 00000000..be843ed3 --- /dev/null +++ b/src/PIPELINE/VISU_ElnoAssembleFilter.cxx @@ -0,0 +1,171 @@ +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com + +#include "VISU_ElnoAssembleFilter.hxx" +#include "VISU_PipeLineUtils.hxx" +#include "VISU_ElnoMeshValue.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include + + +//---------------------------------------------------------------------------- +vtkStandardNewMacro( VISU_ElnoAssembleFilter ); + + +//---------------------------------------------------------------------------- +VISU_ElnoAssembleFilter::VISU_ElnoAssembleFilter() +{ + this->SetInputArrayToProcess( 0, // idx + 0, // port + 0, // connection + vtkDataObject::FIELD_ASSOCIATION_POINTS, // field association + "ELNO_POINT_COORDS" ); // name + + this->myIsRestorePoints = false; +} + + +//---------------------------------------------------------------------------- +VISU_ElnoAssembleFilter::~VISU_ElnoAssembleFilter() +{} + + +//---------------------------------------------------------------------------- +void VISU_ElnoAssembleFilter::SetElnoAssembleState( bool theIsRestorePoints ) +{ + if ( myIsRestorePoints == theIsRestorePoints ) + return; + + myIsRestorePoints = theIsRestorePoints; + this->Modified(); +} + +//---------------------------------------------------------------------------- +namespace +{ + //---------------------------------------------------------------------------- + template < int points_type, int elno_type > + int Execute2( vtkPointSet *theInput, + vtkPointSet *theOutput, + vtkDataArray *theElnoPointCoords ) + { + theOutput->CopyStructure( theInput ); + + vtkCellData *aCellData = theOutput->GetCellData(); + aCellData->PassData( theInput->GetCellData() ); + + vtkPointData *aPointData = theOutput->GetPointData(); + aPointData->PassData( theInput->GetPointData() ); + + vtkPoints *anInputPoints = theInput->GetPoints(); + vtkPoints *aPoints = anInputPoints->New( elno_type ); + vtkIdType aNbPoints = theInput->GetNumberOfPoints(); + aPoints->SetNumberOfPoints( aNbPoints ); + + typedef typename VISU::TL::TEnum2VTKArrayType< elno_type >::TResult TPointsDataArray; + typedef typename VISU::TL::TEnum2VTKBasicType< elno_type >::TResult TPointsDataType; + TPointsDataArray* anOutputPointsArray = TPointsDataArray::SafeDownCast( aPoints->GetData() ); + + TPointsDataArray* anElnoPointCoords = TPointsDataArray::SafeDownCast( theElnoPointCoords ); + + for ( vtkIdType aPointId = 0; aPointId < aNbPoints; aPointId++ ) { + TPointsDataType aCoords[ 3 ]; + anElnoPointCoords->GetTupleValue( aPointId, aCoords ); + anOutputPointsArray->SetTupleValue( aPointId, aCoords ); + } + + theOutput->SetPoints( aPoints ); + + return 1; + } + + + //---------------------------------------------------------------------------- + template < int points_type > + int Execute( vtkPointSet *theInput, + vtkPointSet *theOutput, + vtkDataArray *theElnoPointCoords ) + { + switch( theElnoPointCoords->GetDataType() ){ + case VTK_DOUBLE: + return Execute2< points_type, VTK_DOUBLE >( theInput, theOutput, theElnoPointCoords ); + case VTK_FLOAT: + return Execute2< points_type, VTK_FLOAT >( theInput, theOutput, theElnoPointCoords ); + case VTK_INT: + return Execute2< points_type, VTK_INT >( theInput, theOutput, theElnoPointCoords ); + case VTK_LONG: + return Execute2< points_type, VTK_LONG >( theInput, theOutput, theElnoPointCoords ); + default: + break; + } + + return 0; + } + + + //---------------------------------------------------------------------------- +} + + +//---------------------------------------------------------------------------- +int VISU_ElnoAssembleFilter::RequestData( vtkInformation *vtkNotUsed(request), + vtkInformationVector **inputVector, + vtkInformationVector *outputVector ) +{ + // get the info objects + vtkInformation *inInfo = inputVector[0]->GetInformationObject(0); + vtkInformation *outInfo = outputVector->GetInformationObject(0); + + // get the input and ouptut + vtkPointSet *anInput = vtkPointSet::SafeDownCast( inInfo->Get( vtkDataObject::DATA_OBJECT() ) ); + vtkPointSet *anOutput = vtkPointSet::SafeDownCast( outInfo->Get( vtkDataObject::DATA_OBJECT() ) ); + + vtkDataArray *anElnoPointCoords = this->GetInputArrayToProcess( 0, inputVector ); + + if ( !myIsRestorePoints || !anElnoPointCoords ) { + anOutput->ShallowCopy( anInput ); + return 1; + } + + vtkPoints *aPoints = anInput->GetPoints(); + switch( aPoints->GetDataType() ){ + case VTK_DOUBLE: + return ::Execute< VTK_DOUBLE >( anInput, anOutput, anElnoPointCoords ); + case VTK_FLOAT: + return ::Execute< VTK_FLOAT >( anInput, anOutput, anElnoPointCoords ); + case VTK_INT: + return ::Execute< VTK_INT >( anInput, anOutput, anElnoPointCoords ); + case VTK_LONG: + return ::Execute< VTK_LONG >( anInput, anOutput, anElnoPointCoords ); + default: + break; + } + + return 0; +} + + +//---------------------------------------------------------------------------- diff --git a/src/PIPELINE/VISU_ElnoAssembleFilter.hxx b/src/PIPELINE/VISU_ElnoAssembleFilter.hxx new file mode 100644 index 00000000..8f586c66 --- /dev/null +++ b/src/PIPELINE/VISU_ElnoAssembleFilter.hxx @@ -0,0 +1,47 @@ +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com + +#ifndef VISU_ElnoAssembleFilter_H +#define VISU_ElnoAssembleFilter_H + +#include + +class VISU_ElnoAssembleFilter : public vtkPointSetAlgorithm +{ +public: + typedef vtkPointSetAlgorithm Superclass; + + static VISU_ElnoAssembleFilter *New(); + + void SetElnoAssembleState( bool theIsRestorePoints ); + +protected: + VISU_ElnoAssembleFilter(); + ~VISU_ElnoAssembleFilter(); + + int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *); + + bool myIsRestorePoints; + +private: + VISU_ElnoAssembleFilter(const VISU_ElnoAssembleFilter&); // Not implemented. + void operator=(const VISU_ElnoAssembleFilter&); // Not implemented. +}; + +#endif diff --git a/src/PIPELINE/VISU_ElnoDisassembleFilter.cxx b/src/PIPELINE/VISU_ElnoDisassembleFilter.cxx new file mode 100644 index 00000000..a1d17d6b --- /dev/null +++ b/src/PIPELINE/VISU_ElnoDisassembleFilter.cxx @@ -0,0 +1,393 @@ +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com + +#include "VISU_ElnoDisassembleFilter.hxx" +#include "VISU_PipeLineUtils.hxx" +#include "VISU_ElnoMeshValue.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include + + +//---------------------------------------------------------------------------- +vtkStandardNewMacro( VISU_ElnoDisassembleFilter ); + + +//---------------------------------------------------------------------------- +VISU_ElnoDisassembleFilter::VISU_ElnoDisassembleFilter() +{ + this->SetInputArrayToProcess( 0, // idx + 0, // port + 0, // connection + vtkDataObject::FIELD_ASSOCIATION_CELLS, // field association + "ELNO_FIELD" ); // name + + this->SetInputArrayToProcess( 1, // idx + 0, // port + 0, // connection + vtkDataObject::FIELD_ASSOCIATION_CELLS, // field association + "ELNO_COMPONENT_MAPPER" ); // name + + this->myShrinkFactor = -0.999; +} + + +//---------------------------------------------------------------------------- +VISU_ElnoDisassembleFilter::~VISU_ElnoDisassembleFilter() +{} + + +//---------------------------------------------------------------------------- +void VISU_ElnoDisassembleFilter::SetShrinkFactor( vtkFloatingPointType theValue ) +{ + if ( VISU::CheckIsSameValue( theValue, myShrinkFactor ) ) + return; + + myShrinkFactor = theValue; + this->Modified(); +} + + +//---------------------------------------------------------------------------- +vtkFloatingPointType VISU_ElnoDisassembleFilter::GetShrinkFactor() +{ + return myShrinkFactor; +} + + +//---------------------------------------------------------------------------- +namespace +{ + //---------------------------------------------------------------------------- + template < int points_type, int elno_type > + struct TExecute2 + { + vtkUnstructuredGrid *myInput; + vtkUnstructuredGrid *myOutput; + vtkDataArray *myElnoDataArray; + vtkDataArray *myElnoDataMapper; + vtkFloatingPointType myShrinkFactor; + + typedef typename VISU::TL::TEnum2VTKArrayType< points_type >::TResult TPointsDataArray; + typedef typename VISU::TL::TEnum2VTKBasicType< points_type >::TResult TPointsDataType; + + typedef typename VISU::TL::TEnum2VTKArrayType< elno_type >::TResult TElnoDataArray; + typedef typename VISU::TL::TEnum2VTKBasicType< elno_type >::TResult TElnoDataType; + + VISU::TGetElnoNodeData< elno_type > myGetElnoNodeData; + vtkCellArray *myConnectivity; + vtkPointData *myInputPointData; + vtkPointData *myOutputPointData; + TPointsDataArray *myInputPointsArray; + TPointsDataArray *myOutputPointsArray; + TElnoDataArray* myElnoPointDataArray; + TElnoDataArray* myElnoPointVectors; + TPointsDataArray *myElnoPointCoords; + vtkIntArray* myInputPointsMapper; + vtkIntArray* myOutputPointsMapper; + + //---------------------------------------------------------------------------- + TExecute2( vtkUnstructuredGrid *theInput, + vtkUnstructuredGrid *theOutput, + vtkDataArray *theElnoDataArray, + vtkDataArray *theElnoDataMapper, + vtkFloatingPointType theShrinkFactor ) + : myGetElnoNodeData( theElnoDataArray, theElnoDataMapper ) + , myInput( theInput ) + , myOutput( theOutput ) + , myElnoDataArray( theElnoDataArray ) + , myElnoDataMapper( theElnoDataMapper ) + , myShrinkFactor( theShrinkFactor ) + { + myConnectivity = vtkCellArray::New(); + myConnectivity->DeepCopy( theInput->GetCells() ); + + vtkPoints *anInputPoints = theInput->GetPoints(); + vtkPoints *aPoints = anInputPoints->New( anInputPoints->GetDataType() ); + vtkIdType aNbCells = myConnectivity->GetNumberOfCells(); + vtkIdType aNbPoints = myConnectivity->GetNumberOfConnectivityEntries() - aNbCells; + aPoints->Allocate( aNbPoints ); + + myInputPointsArray = TPointsDataArray::SafeDownCast( anInputPoints->GetData() ); + myOutputPointsArray = TPointsDataArray::SafeDownCast( aPoints->GetData() ); + + myInputPointData = theInput->GetPointData(); + myOutputPointData = theOutput->GetPointData(); + myOutputPointData->Allocate( aNbPoints ); + + vtkCellData *anInputCellData = theInput->GetCellData(); + vtkDataArray* aVectors = anInputCellData->GetVectors(); + + myElnoPointDataArray = TElnoDataArray::New(); + myElnoPointDataArray->SetName( "VISU_FIELD" ); + myElnoPointDataArray->SetNumberOfComponents( myGetElnoNodeData.getNbComp() ); + myElnoPointDataArray->SetNumberOfTuples( aNbPoints ); + + myElnoPointVectors = TElnoDataArray::New(); + myElnoPointVectors->SetName( aVectors->GetName() ); + myElnoPointVectors->SetNumberOfComponents( 3 ); + myElnoPointVectors->SetNumberOfTuples( aNbPoints ); + + myElnoPointCoords = TPointsDataArray::New(); + myElnoPointCoords->SetName( "ELNO_POINT_COORDS" ); + myElnoPointCoords->SetNumberOfComponents( 3 ); + myElnoPointCoords->SetNumberOfTuples( aNbPoints ); + + vtkDataArray* anArray = myInputPointData->GetArray( "VISU_POINTS_MAPPER" ); + myInputPointsMapper = vtkIntArray::SafeDownCast( anArray ); + + myOutputPointsMapper = vtkIntArray::New(); + myOutputPointsMapper->SetName( myInputPointsMapper->GetName() ); + myOutputPointsMapper->SetNumberOfComponents( myInputPointsMapper->GetNumberOfComponents() ); + myOutputPointsMapper->SetNumberOfTuples( aNbPoints ); + + if ( theShrinkFactor > 0.0 ) + this->ShrinkExecute(); + else + this->SimpleExecute(); + + theOutput->SetPoints( aPoints ); + + theOutput->SetCells( theInput->GetCellTypesArray(), + theInput->GetCellLocationsArray(), + myConnectivity ); + + myConnectivity->Delete(); + + vtkCellData *anOutputCellData = theOutput->GetCellData(); + anOutputCellData->PassData( anInputCellData ); + + anOutputCellData->RemoveArray( "ELNO_COMPONENT_MAPPER" ); + anOutputCellData->RemoveArray( "ELNO_FIELD" ); + anOutputCellData->RemoveArray( "VISU_FIELD" ); + anOutputCellData->SetVectors( NULL ); + + //anOutputPointData->PassData( anInputPointData ); + + myOutputPointData->AddArray( myElnoPointDataArray ); + myElnoPointDataArray->Delete(); + + myOutputPointData->SetVectors( myElnoPointVectors ); + myElnoPointVectors->Delete(); + + myOutputPointData->AddArray( myElnoPointCoords ); + myElnoPointCoords->Delete(); + + myOutputPointData->AddArray( myOutputPointsMapper ); + myOutputPointsMapper->Delete(); + } + + //---------------------------------------------------------------------------- + void SimpleExecute() + { + // To reserve a temproary value holder + vtkIdType aNbComp = std::max( 3, myGetElnoNodeData.getNbComp() ); + std::vector< TElnoDataType > anElnoDataValues( aNbComp ); + + std::vector< int > anPointsMapperValues( myInputPointsMapper->GetNumberOfComponents() ); + + myConnectivity->InitTraversal(); + vtkIdType aNbPts = 0, *aPts = 0; + for ( vtkIdType aCellId = 0; myConnectivity->GetNextCell( aNbPts, aPts ); aCellId++ ) { + for ( vtkIdType aPntId = 0; aPntId < aNbPts; aPntId++ ) { + TPointsDataType aCoords[ 3 ]; + vtkIdType aCurrentPntId = aPts[ aPntId ]; + myInputPointsArray->GetTupleValue( aCurrentPntId, aCoords ); + + aPts[ aPntId ] = myOutputPointsArray->InsertNextTupleValue( aCoords ); + vtkIdType aNewPntId = aPts[ aPntId ]; + + myElnoPointCoords->SetTupleValue( aNewPntId, aCoords ); + + myOutputPointData->CopyData( myInputPointData, aCurrentPntId, aNewPntId ); + + TElnoDataType* anElnoData = myGetElnoNodeData( aCellId, aPntId ); + myElnoPointDataArray->SetTupleValue( aNewPntId, anElnoData ); + + myElnoPointDataArray->GetTupleValue( aNewPntId, &anElnoDataValues[ 0 ] ); + myElnoPointVectors->SetTupleValue( aNewPntId, &anElnoDataValues[ 0 ] ); + + myInputPointsMapper->GetTupleValue( aCurrentPntId, &anPointsMapperValues[ 0 ] ); + myOutputPointsMapper->SetTupleValue( aNewPntId, &anPointsMapperValues[ 0 ] ); + } + } + } + + //---------------------------------------------------------------------------- + void ShrinkExecute() + { + // To reserve a temproary value holder + vtkIdType aNbComp = std::max( 3, myGetElnoNodeData.getNbComp() ); + std::vector< TElnoDataType > anElnoDataValues( aNbComp ); + + std::vector< int > anPointsMapperValues( myInputPointsMapper->GetNumberOfComponents() ); + + myConnectivity->InitTraversal(); + vtkIdType aNbPts = 0, *aPts = 0; + for ( vtkIdType aCellId = 0; myConnectivity->GetNextCell( aNbPts, aPts ); aCellId++ ) { + + TPointsDataType aCenter[ 3 ] = { TPointsDataType(), TPointsDataType(), TPointsDataType() }; + + for ( vtkIdType aPntId = 0; aPntId < aNbPts; aPntId++ ) { + TPointsDataType aCoords[ 3 ]; + myInputPointsArray->GetTupleValue( aPts[ aPntId ], aCoords ); + + aCenter[ 0 ] += aCoords[ 0 ]; + aCenter[ 1 ] += aCoords[ 1 ]; + aCenter[ 2 ] += aCoords[ 2 ]; + } + + aCenter[ 0 ] /= aNbPts; + aCenter[ 1 ] /= aNbPts; + aCenter[ 2 ] /= aNbPts; + + for ( vtkIdType aPntId = 0; aPntId < aNbPts; aPntId++ ) { + TPointsDataType aCoords[ 3 ]; + vtkIdType aCurrentPntId = aPts[ aPntId ]; + myInputPointsArray->GetTupleValue( aCurrentPntId, aCoords ); + + TPointsDataType aNewCoords[ 3 ]; + + aNewCoords[ 0 ] = aCenter[ 0 ] + + TPointsDataType( myShrinkFactor * ( aCoords[ 0 ] - aCenter[ 0 ] ) ); + aNewCoords[ 1 ] = aCenter[ 1 ] + + TPointsDataType( myShrinkFactor * ( aCoords[ 1 ] - aCenter[ 1 ] ) ); + aNewCoords[ 2 ] = aCenter[ 2 ] + + TPointsDataType( myShrinkFactor * ( aCoords[ 2 ] - aCenter[ 2 ] ) ); + + aPts[ aPntId ] = myOutputPointsArray->InsertNextTupleValue( aNewCoords ); + vtkIdType aNewPntId = aPts[ aPntId ]; + + myElnoPointCoords->SetTupleValue( aNewPntId, aCoords ); + + myOutputPointData->CopyData( myInputPointData, aCurrentPntId, aNewPntId ); + + TElnoDataType* anElnoData = myGetElnoNodeData( aCellId, aPntId ); + myElnoPointDataArray->SetTupleValue( aNewPntId, anElnoData ); + + myElnoPointDataArray->GetTupleValue( aNewPntId, &anElnoDataValues[ 0 ] ); + myElnoPointVectors->SetTupleValue( aNewPntId, &anElnoDataValues[ 0 ] ); + + myInputPointsMapper->GetTupleValue( aCurrentPntId, &anPointsMapperValues[ 0 ] ); + myOutputPointsMapper->SetTupleValue( aNewPntId, &anPointsMapperValues[ 0 ] ); + } + } + } + }; + + + //---------------------------------------------------------------------------- + template < int points_type, int elno_type > + int Execute2( vtkUnstructuredGrid *theInput, + vtkUnstructuredGrid *theOutput, + vtkDataArray *theElnoDataArray, + vtkDataArray *theElnoDataMapper, + vtkFloatingPointType theShrinkFactor ) + { + TExecute2< points_type, elno_type >( theInput, + theOutput, + theElnoDataArray, + theElnoDataMapper, + theShrinkFactor ); + + return 1; + } + + + //---------------------------------------------------------------------------- + template < int points_type > + int Execute( vtkUnstructuredGrid *theInput, + vtkUnstructuredGrid *theOutput, + vtkDataArray *theElnoDataArray, + vtkDataArray *theElnoDataMapper, + vtkFloatingPointType theShrinkFactor ) + { + switch( theElnoDataArray->GetDataType() ){ + case VTK_DOUBLE: + return Execute2< points_type, VTK_DOUBLE > + ( theInput, theOutput, theElnoDataArray, theElnoDataMapper, theShrinkFactor ); + case VTK_FLOAT: + return Execute2< points_type, VTK_FLOAT > + ( theInput, theOutput, theElnoDataArray, theElnoDataMapper, theShrinkFactor ); + case VTK_INT: + return Execute2< points_type, VTK_INT > + ( theInput, theOutput, theElnoDataArray, theElnoDataMapper, theShrinkFactor ); + case VTK_LONG: + return Execute2< points_type, VTK_LONG > + ( theInput, theOutput, theElnoDataArray, theElnoDataMapper, theShrinkFactor ); + default: + break; + } + + return 0; + } + + + //---------------------------------------------------------------------------- +} + + +//---------------------------------------------------------------------------- +int VISU_ElnoDisassembleFilter::RequestData( vtkInformation *vtkNotUsed(request), + vtkInformationVector **inputVector, + vtkInformationVector *outputVector ) +{ + // get the info objects + vtkInformation *inInfo = inputVector[0]->GetInformationObject(0); + vtkInformation *outInfo = outputVector->GetInformationObject(0); + + // get the input and ouptut + vtkUnstructuredGrid *anInput = + vtkUnstructuredGrid::SafeDownCast( inInfo->Get( vtkDataObject::DATA_OBJECT() ) ); + vtkUnstructuredGrid *anOutput = + vtkUnstructuredGrid::SafeDownCast( outInfo->Get( vtkDataObject::DATA_OBJECT() ) ); + + vtkDataArray *anElnoDataArray = this->GetInputArrayToProcess( 0, inputVector ); + vtkDataArray *anElnoDataMapper = this->GetInputArrayToProcess( 1, inputVector ); + + if ( !anElnoDataArray ) { + anOutput->ShallowCopy( anInput ); + return 1; + } + + vtkPoints *aPoints = anInput->GetPoints(); + switch( aPoints->GetDataType() ){ + case VTK_DOUBLE: + return ::Execute< VTK_DOUBLE >( anInput, anOutput, anElnoDataArray, anElnoDataMapper, myShrinkFactor ); + case VTK_FLOAT: + return ::Execute< VTK_FLOAT >( anInput, anOutput, anElnoDataArray, anElnoDataMapper, myShrinkFactor ); + case VTK_INT: + return ::Execute< VTK_INT >( anInput, anOutput, anElnoDataArray, anElnoDataMapper, myShrinkFactor ); + case VTK_LONG: + return ::Execute< VTK_LONG >( anInput, anOutput, anElnoDataArray, anElnoDataMapper, myShrinkFactor ); + default: + break; + } + + return 0; +} + + +//---------------------------------------------------------------------------- diff --git a/src/PIPELINE/VISU_ElnoDisassembleFilter.hxx b/src/PIPELINE/VISU_ElnoDisassembleFilter.hxx new file mode 100644 index 00000000..0053c13e --- /dev/null +++ b/src/PIPELINE/VISU_ElnoDisassembleFilter.hxx @@ -0,0 +1,48 @@ +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com + +#ifndef VISU_ElnoDisassembleFilter_H +#define VISU_ElnoDisassembleFilter_H + +#include + +class VISU_ElnoDisassembleFilter : public vtkUnstructuredGridAlgorithm +{ +public: + typedef vtkUnstructuredGridAlgorithm Superclass; + + static VISU_ElnoDisassembleFilter *New(); + + void SetShrinkFactor( vtkFloatingPointType theValue ); + vtkFloatingPointType GetShrinkFactor(); + +protected: + VISU_ElnoDisassembleFilter(); + ~VISU_ElnoDisassembleFilter(); + + int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *); + + vtkFloatingPointType myShrinkFactor; + +private: + VISU_ElnoDisassembleFilter(const VISU_ElnoDisassembleFilter&); // Not implemented. + void operator=(const VISU_ElnoDisassembleFilter&); // Not implemented. +}; + +#endif diff --git a/src/PIPELINE/VISU_IsoSurfacesPL.cxx b/src/PIPELINE/VISU_IsoSurfacesPL.cxx index 78ae91af..88359963 100644 --- a/src/PIPELINE/VISU_IsoSurfacesPL.cxx +++ b/src/PIPELINE/VISU_IsoSurfacesPL.cxx @@ -46,6 +46,8 @@ VISU_IsoSurfacesPL { SetIsShrinkable(false); + SetElnoDisassembleState( true ); + myContourFilter = vtkContourFilter::New(); myCellDataToPointData = vtkCellDataToPointData::New(); diff --git a/src/PIPELINE/VISU_PipeLineUtils.cxx b/src/PIPELINE/VISU_PipeLineUtils.cxx index 6c31a356..26e7290e 100644 --- a/src/PIPELINE/VISU_PipeLineUtils.cxx +++ b/src/PIPELINE/VISU_PipeLineUtils.cxx @@ -95,6 +95,7 @@ namespace VISU theTarget->SetScalarMode(theSource->GetScalarMode()); theTarget->SetImmediateModeRendering(theSource->GetImmediateModeRendering()); theTarget->SetUseLookupTableScalarRange(theSource->GetUseLookupTableScalarRange()); + theTarget->SetInterpolateScalarsBeforeMapping(theSource->GetInterpolateScalarsBeforeMapping()); if(theSource->GetArrayAccessMode() == VTK_GET_ARRAY_BY_ID) theTarget->ColorByArrayComponent(theSource->GetArrayId(), theSource->GetArrayComponent()); else diff --git a/src/PIPELINE/VISU_ScalarMapPL.cxx b/src/PIPELINE/VISU_ScalarMapPL.cxx index d7149129..ad739773 100644 --- a/src/PIPELINE/VISU_ScalarMapPL.cxx +++ b/src/PIPELINE/VISU_ScalarMapPL.cxx @@ -28,6 +28,7 @@ #include "VISU_ScalarMapPL.hxx" #include "VISU_DataSetMapperHolder.hxx" +#include "VISU_ElnoAssembleFilter.hxx" #include "VISU_FieldTransform.hxx" #include "VISU_AppendFilter.hxx" @@ -50,11 +51,16 @@ vtkStandardNewMacro(VISU_ScalarMapPL); VISU_ScalarMapPL ::VISU_ScalarMapPL(): VISU_UnstructuredGridPL(this), + myElnoAssembleFilter( VISU_ElnoAssembleFilter::New() ), myAppendFilter(VISU_AppendFilter::New()), myMergeFilter(VISU_MergeFilter::New()) { SetIsShrinkable(true); + SetElnoDisassembleState( false ); + + myElnoAssembleFilter->Delete(); + myAppendFilter->SetMergingInputs(true); myAppendFilter->Delete(); @@ -111,8 +117,11 @@ VISU_ScalarMapPL myMergeFilter->AddField("VISU_FIELD", aDataSet); myMergeFilter->AddField("VISU_CELLS_MAPPER", aDataSet); myMergeFilter->AddField("VISU_POINTS_MAPPER", aDataSet); + myMergeFilter->AddField("ELNO_POINT_COORDS", aDataSet); + + myElnoAssembleFilter->SetInput( InsertCustomPL() ); - GetDataSetMapper()->SetInput(InsertCustomPL()); + GetDataSetMapper()->SetInput( myElnoAssembleFilter->GetOutput() ); } @@ -148,6 +157,15 @@ VISU_ScalarMapPL } +//---------------------------------------------------------------------------- +void +VISU_ScalarMapPL +::SetElnoDisassembleState( bool theIsShrunk ) +{ + GetDataSetMapperHolder()->SetElnoDisassembleState( theIsShrunk ); + myElnoAssembleFilter->SetElnoAssembleState( theIsShrunk ); +} + //---------------------------------------------------------------------------- void VISU_ScalarMapPL diff --git a/src/PIPELINE/VISU_ScalarMapPL.hxx b/src/PIPELINE/VISU_ScalarMapPL.hxx index dff91d39..fdb4ef94 100644 --- a/src/PIPELINE/VISU_ScalarMapPL.hxx +++ b/src/PIPELINE/VISU_ScalarMapPL.hxx @@ -34,6 +34,7 @@ #include "VISU_UnstructuredGridPL.hxx" class VISU_DataSetMapperHolder; +class VISU_ElnoAssembleFilter; class VISU_AppendFilter; class VISU_MergeFilter; @@ -111,12 +112,16 @@ protected: DoShallowCopy(VISU_PipeLine *thePipeLine, bool theIsCopyInput); + void + SetElnoDisassembleState( bool theIsShrunk ); + private: VISU_ScalarMapPL(const VISU_ScalarMapPL&); // Not implemented. void operator=(const VISU_ScalarMapPL&); // Not implemented. - vtkSmartPointer myAppendFilter; - vtkSmartPointer myMergeFilter; + vtkSmartPointer< VISU_ElnoAssembleFilter > myElnoAssembleFilter; + vtkSmartPointer< VISU_AppendFilter > myAppendFilter; + vtkSmartPointer< VISU_MergeFilter > myMergeFilter; }; #endif -- 2.39.2