Join modifications from BR_ELNO_visualization branch.
salomeinclude_HEADERS= \
VISU_TypeList.hxx \
+ VISU_VTKTypeList.hxx \
VISU_IDMapper.hxx \
VISU_ConvertorDef.hxx \
VISU_Structures.hxx \
VISU_ConvertorDef_impl.hxx \
VISU_Structures_impl.hxx \
VISU_MeshValue.hxx \
+ VISU_ElnoMeshValue.hxx \
VISU_PointCoords.hxx \
VISU_Convertor_impl.hxx \
VISU_ConvertorUtils.hxx \
//---------------------------------------------------------------
+ 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 ] );
}
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);
}
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;
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++;
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++;
//---------------------------------------------------------------
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 = '"<<theMeshName<<"'"<<
aGaussPtsIDFilter->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;
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 );
}
//! 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
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<VISU::PMeshImpl,
int theStampsNum);
vtkUnstructuredGrid*
- GetTimeStampOnProfile(const VISU::PMeshImpl& theMesh,
- const VISU::PMeshOnEntityImpl& theMeshOnEntity,
- const VISU::PFieldImpl& theField,
- const VISU::PValForTimeImpl& theValForTime,
- 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);
-
+ GetTimeStampOnProfile( const VISU::PMeshImpl& theMesh,
+ const VISU::PMeshOnEntityImpl& theMeshOnEntity,
+ const VISU::PFieldImpl& theField,
+ const VISU::PValForTimeImpl& theValForTime,
+ const VISU::PUnstructuredGridIDMapperImpl& theIDMapperFilter,
+ const VISU::PProfileImpl& theProfile,
+ const VISU::TEntity& theEntity );
+
protected:
//! Implemention of the VISU_Convertor::GetTimeStampSize
virtual
--- /dev/null
+// 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_ElnoMeshValue.hxx
+// Author : Alexey PETROV
+// Module : VISU
+
+#ifndef VISU_ElnoMeshValue_HeaderFile
+#define VISU_ElnoMeshValue_HeaderFile
+
+#include "VISU_VTKTypeList.hxx"
+#include <vtkDataSetAttributes.h>
+
+
+/*!
+ \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
//---------------------------------------------------------------
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;
}
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
aField->myName = aFieldName;
aField->myMeshName = aMeshName;
aField->myDataSize = aMeshOnEntity->myNbCells * aNbComp;
+ aField->myIsELNO = true; // To set it true by default
INITMSG(MYDEBUG,"myName = '"<<aField->myName<<"'"<<
"; myId = "<<aField->myId<<
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 );
}
}
// 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 <vtkUnstructuredGrid.h>
#include <vtkPolyData.h>
}
- namespace TL
- {
- //----------------------------------------------------------------------------
- typedef TList<char,
- TList<unsigned char,
- TList<short,
- TList<unsigned short,
- TList<int,
- TList<unsigned int,
- TList<long,
- TList<unsigned long,
- TList<float,
- TList<double,
- TNullType> > > > > > > > > >
- TVTKBasicTypeList;
-
-
- //----------------------------------------------------------------------------
- typedef TList<vtkCharArray,
- TList<vtkUnsignedCharArray,
- TList<vtkShortArray,
- TList<vtkUnsignedShortArray,
- TList<vtkIntArray,
- TList<vtkUnsignedIntArray,
- TList<vtkLongArray,
- TList<vtkUnsignedLongArray,
- TList<vtkFloatArray,
- TList<vtkDoubleArray,
- TNullType> > > > > > > > > >
- TVTKArrayTypeList;
-
-
- typedef TList<TInt2Type<VTK_CHAR>,
- TList<TInt2Type<VTK_UNSIGNED_CHAR>,
- TList<TInt2Type<VTK_SHORT>,
- TList<TInt2Type<VTK_UNSIGNED_SHORT>,
- TList<TInt2Type<VTK_INT>,
- TList<TInt2Type<VTK_UNSIGNED_INT>,
- TList<TInt2Type<VTK_LONG>,
- TList<TInt2Type<VTK_UNSIGNED_LONG>,
- TList<TInt2Type<VTK_FLOAT>,
- TList<TInt2Type<VTK_DOUBLE>,
- TNullType> > > > > > > > > >
- 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;
- };
-
- }
-
-
//----------------------------------------------------------------------------
template<int EDataType>
void
typedef typename TL::TEnum2VTKArrayType<EDataType>::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 = "<<theEntity<<
"; aNbTuples = "<<aNbTuples<<
"; aNbComp = "<<aNbComp<<
std::endl);
+
TTimerLog aTimerLog(MYDEBUG,"InitTimeStampOnProfile");
const TGeom2MeshValue& aGeom2MeshValue = theValForTime->GetGeom2MeshValue();
- typedef typename TL::TEnum2VTKBasicType<EDataType>::TResult TVTKBasicType;
- typedef TTMeshValue<TVTKBasicType> TMeshValue;
- typedef MED::SharedPtr<TMeshValue> TMeshValuePtr;
+ typedef typename TL::TEnum2VTKBasicType< EDataType >::TResult TVTKBasicType;
+ typedef TTMeshValue< TVTKBasicType > TMeshValue;
+ typedef MED::SharedPtr< TMeshValue > TMeshValuePtr;
- typedef TDataArrayHolder<EDataType> TTDataArrayHolder;
- typedef MED::SharedPtr<TTDataArrayHolder> 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()"<<std::endl);
- if(aNbComp == 1){
+ if ( aNbComp == 1 ) {
aSelectedDataArray->SetVoidArray(aMeshValue->GetPointer(),
aMeshValue->size(),
true);
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 = "<<aEGeom<<
+ "; aNbElem = "<<aNbElem<<
+ "; aNbGauss = "<<aNbGauss<<
+ std::endl);
+ std::vector<int> med2visu(aNbGauss);
+ InitMed2VisuArray(med2visu,aEGeom);
+ for ( vtkIdType iElem = 0; iElem < aNbElem; iElem++ ) {
+ const typename TMeshValue::TValueSliceArr& aValueSliceArr = aMeshValue->GetGaussValueSliceArr( iElem );
+
+ for( vtkIdType iGauss = 0; iGauss < aNbGauss; iGauss++ ) {
+ const typename TMeshValue::TCValueSlice& aValueSlice = aValueSliceArr[ med2visu[iGauss] ];
+
+ for( vtkIdType iComp = 0; iComp < aNbComp; iComp++ ) {
+ aDataValues[ iComp ] = aValueSlice[ iComp ];
+ }
+
+ aSetElnoNodeData.AddNextPointData( &aDataValues[ 0 ] );
+ }
+
+ aSetElnoNodeData.InsertNextCellData();
+ }
+ }
+
+ // Assign the ELNO data on the corresponding VTK data set attribute
+ aSetElnoNodeData.AddData( aDataSetAttributes );
+ }
+ //-------------------------------
}
aFullDataArray->Delete();
}
+
+ //----------------------------------------------------------------------------
- //---------------------------------------------------------------
+ void InitMed2VisuArray(std::vector<int>& anArray, EGeometry aEGeom){
+ switch(aEGeom){
+#if !(defined(VTK_QUADRATIC_EDGE) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)
+ case eSEG3:
+ anArray[0] = 0;
+ anArray[2] = 1;
+ anArray[1] = 2;
+ break;
+#endif
+
+#if !(defined(VTK_QUADRATIC_TRIANGLE) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)
+ case eTRIA6:
+ anArray[0] = 0;
+ anArray[2] = 1;
+ anArray[4] = 2;
+
+ anArray[1] = 3;
+ anArray[3] = 4;
+ anArray[5] = 5;
+ break;
+#endif
+
+#if !(defined(VTK_QUADRATIC_QUAD) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)
+ case eQUAD8:
+ anArray[0] = 0;
+ anArray[2] = 1;
+ anArray[4] = 2;
+ anArray[6] = 3;
+
+ anArray[1] = 4;
+ anArray[3] = 5;
+ anArray[5] = 6;
+ anArray[7] = 7;
+ break;
+#endif
+ case eTETRA4:
+ anArray[0] = 0;
+ anArray[1] = 2;
+ anArray[2] = 1;
+ anArray[3] = 3;
+ break;
+ case ePYRA5:
+ anArray[0] = 0;
+ anArray[1] = 3;
+ anArray[2] = 2;
+ anArray[3] = 1;
+ anArray[4] = 4;
+ break;
+#if (defined(VTK_QUADRATIC_TETRA) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)
+ case eTETRA10:
+ anArray[0] = 0;
+ anArray[1] = 2;
+ anArray[2] = 1;
+ anArray[3] = 3;
+
+ anArray[4] = 6;
+ anArray[5] = 5;
+ anArray[6] = 4;
+
+ anArray[7] = 7;
+ anArray[8] = 9;
+ anArray[9] = 8;
+ break;
+#endif
+
+#if (defined(VTK_QUADRATIC_PYRAMID) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)
+ case ePYRA13:
+ anArray[0] = 0;
+ anArray[1] = 3;
+ anArray[2] = 2;
+ anArray[3] = 1;
+ anArray[4] = 4;
+
+ anArray[5] = 5;
+ anArray[6] = 8;
+ anArray[7] = 7;
+ anArray[8] = 6;
+
+ anArray[9] = 9;
+ anArray[10] = 12;
+ anArray[11] = 11;
+ anArray[12] = 10;
+ break;
+#endif
+ default:
+ for(int i=0;i<anArray.size();i++){
+ anArray[i] = i;
+ }
+ break;
+ }
+ }
}
const PFieldImpl& theField,
const PValForTimeImpl& theValForTime);
+ void
+ InitMed2VisuArray(std::vector<int>& anArray, EGeometry aEGeom);
+
//---------------------------------------------------------------
}
std::string myGroupsEntry; //!< To simplify publication of the groups in a data tree
std::string myFieldsEntry; //!< To simplify publication of the fiels in a data tree
-
- // MULTIPR
std::string myPartsEntry; //!< To simplify publication of the parts in a data tree
TMesh();
typedef std::map<std::string, PMesh> TMeshMap;
- typedef std::map<VISU::TEntity,VISU::PNamedIDMapper> PNamedIDMapperMap;
-
//---------------------------------------------------------------
//! Define a basic class which corresponds to MED PROFILE entity
struct VISU_CONVERTOR_EXPORT TSubProfile: virtual TBaseStructure
//---------------------------------------------------------------
TUnstructuredGridIDMapperImpl
- ::TUnstructuredGridIDMapperImpl():
- myIsSpecialKey(false)
+ ::TUnstructuredGridIDMapperImpl()
{
- if(!myCommonCellsFilter.GetPointer()){
+ if ( !myCommonCellsFilter.GetPointer() ) {
myCommonCellsFilter = VISU_CommonCellsFilter::New();
myCommonCellsFilter->Delete();
}
return myIDMapper->GetElemCell(theObjID);
}
- vtkUnstructuredGrid*
+ void
TUnstructuredGridIDMapperImpl
- ::GetUnstructuredGridOutput()
+ ::SetReferencedMesh( const PNamedIDMapper& theNamedIDMapper )
{
- if(!myFilter.GetPointer()){
-
+ myCommonCellsFilter->SetCellsUG( theNamedIDMapper->GetUnstructuredGridOutput() );
+ }
+
+ void
+ TUnstructuredGridIDMapperImpl
+ ::Build()
+ {
+ if ( !myFilter.GetPointer() ) {
const PAppendFilter& anAppendFilter = myIDMapper->GetFilter();
- vtkUnstructuredGrid* aGeometry;
+ vtkUnstructuredGrid* aGeometry = anAppendFilter->GetOutput();
const PUnstructuredGrid& aSource = mySource.GetSource();
- 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);
+ vtkUnstructuredGrid* aDataSet = aSource.GetPointer();
+ 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);
-
- 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();
}
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;
}
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();
}
return GetPolyDataOutput();
}
+ PPolyData
+ TPolyDataIDMapperImpl
+ ::GetSource()
+ {
+ Build();
+ return mySource.GetSource();
+ }
+
unsigned long int
TPolyDataIDMapperImpl
::GetMemorySize()
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];
//---------------------------------------------------------------
TFieldImpl
- ::TFieldImpl():
- myDataSize(0),
- myDataType(0)
+ ::TFieldImpl()
+ : myDataSize( 0 )
+ , myDataType( 0 )
+ , myIsELNO( false )
{}
void
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;
};
//---------------------------------------------------------------
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();
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
};
//---------------------------------------------------------------
virtual TPolyDataIDMapper
{
PAppendPolyDataHolder myIDMapper; //!< Responsible for numbering
- TPolyDataHolder mySource; //!< Keeps assigned data
//! Reimplement the TIDMapper::GetNodeObjID
virtual
virtual
unsigned long int
GetMemorySize();
+
+ PPolyData
+ GetSource();
+
+ protected:
+ void Build();
+
+ TPolyDataHolder mySource; //!< Keeps assigned data
};
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
};
// 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 <class T, class U>
+ struct TNullType {};
+
+
+ //----------------------------------------------------------------------------
+ template < class T, class U >
struct TList
{
typedef T THead;
typedef U TTail;
};
- template <int v>
+ template < int v >
struct TInt2Type
{
enum { value = v };
};
- struct TNullType {};
-
+
//----------------------------------------------------------------------------
- template <class TypeList, unsigned int index>
+ template < class TypeList, unsigned int index >
struct TTypeAt;
- template <class THead, class TTail>
- struct TTypeAt<TList<THead, TTail>, 0>
+ template < class THead, class TTail >
+ struct TTypeAt< TList< THead, TTail >, 0 >
{
typedef THead TResult;
};
- template <class THead, class TTail, unsigned int index>
- struct TTypeAt<TList<THead, TTail>, index>
+ template < class THead, class TTail, unsigned int index >
+ struct TTypeAt< TList< THead, TTail >, index >
{
- typedef typename TTypeAt<TTail, index - 1>::TResult TResult;
+ typedef typename TTypeAt< TTail, index - 1 >::TResult TResult;
};
+
//----------------------------------------------------------------------------
- template <class TypeList, class T>
+ template < class TypeList, class T >
struct TIndexOf;
- template <class T>
- struct TIndexOf<TNullType, T>
+ template < class T >
+ struct TIndexOf< TNullType, T >
{
enum { value = -1 };
};
- template <class T, class TTail>
- struct TIndexOf<TList<T, TTail>, T>
+ template < class T, class TTail >
+ struct TIndexOf< TList< T, TTail >, T >
{
enum { value = 0 };
};
- template <class THead, class TTail, class T>
- struct TIndexOf<TList<THead, TTail>, T>
+ template < class THead, class TTail, class T >
+ struct TIndexOf< TList< THead, TTail >, T >
{
private:
- enum { temp = TIndexOf<TTail, T>::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
--- /dev/null
+// 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 <vtkCharArray.h>
+#include <vtkUnsignedCharArray.h>
+#include <vtkShortArray.h>
+#include <vtkUnsignedShortArray.h>
+#include <vtkIntArray.h>
+#include <vtkUnsignedIntArray.h>
+#include <vtkLongArray.h>
+#include <vtkUnsignedLongArray.h>
+#include <vtkFloatArray.h>
+#include <vtkDoubleArray.h>
+
+
+//----------------------------------------------------------------------------
+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
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 \
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) \
// 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"
#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 <vtkMaskPoints.h>
-#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 <vtkShrinkFilter.h>
+#include <vtkPointLocator.h>
-typedef VISU_StreamLinesPL TPresent;
+#include <vtkCutter.h>
+#include <vtkPlane.h>
+#include <vtkWarpVector.h>
+
+#include <vtkScalarBarActor.h>
+#include <vtkScalarBarWidget.h>
+
+// VTK includes
+#include <vtkMaskPoints.h>
+#include <vtkUnstructuredGridReader.h>
#include <vtkUnstructuredGrid.h>
#include <vtkDataSetMapper.h>
-
#include <vtkInteractorStyleTrackballCamera.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderWindow.h>
#include <vtkImageData.h>
+#include <vtkCellData.h>
#include <vtkRenderer.h>
#include <vtkCamera.h>
#include <vtkActor.h>
#include <vtk3DWidget.h>
-
#include <vtkProperty.h>
-#include <qfileinfo.h>
-
-#include <memory>
-
-//#define _DEBUG_ID_MAPPING_
-
-//----------------------------------------------------------------------------
-template<class TPipeLine>
-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_GaussPointsPL>(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'"<<endl;
- vtkSmartPointer<vtkImageData> 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 = "<<aNbCells<<endl;
- for(int anCellId = 0; anCellId < aNbCells; anCellId++){
- vtkIdType anObjID = aPresent->GetNodeObjID(anCellId);
- vtkIdType aVtkID = aPresent->GetNodeVTKID(anObjID);
- cout<<anObjID<<"; "<<aVtkID<<"; - ";
- vtkFloatingPointType* aCoord = aPresent->GetNodeCoord(anObjID);
- cout<<aCoord[0]<<"; "<<aCoord[1]<<"; "<<aCoord[2]<<endl;
- }
-#endif
-
- return aPresent;
+ cout<<"VISUPipeLine : ";
+ cout<<"Try `VISUPipeLine -h' for more information."<<endl;
}
-
-//----------------------------------------------------------------------------
-template<class TPipeLine>
-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] " <<endl;
+ cout<<"filename - Name of the med file. " <<endl;
+ cout<<"meshname - Name of the mesh in the med file. " <<endl;
+ cout<<"fieldname - Name of the mesh field. " <<endl;
+ cout<<"timestamp - Number of the time stamp in the field 1,2,3 ... (optionally)" <<endl;
+ cout<<" by default used first time stamp. " <<endl;
+ cout<<"component - Number of the component in the field 0,1,2,3 ...(optionally)" <<endl;
+ cout<<" 0 - modulus, 1 - first component, 2 - second component, ... " <<endl;
+ cout<<" by default used modulus. " <<endl;
}
-
-//----------------------------------------------------------------------------
-struct TMEDSource
-{
- std::auto_ptr<VISU_Convertor> 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*****************************************"<<endl;
+}
//----------------------------------------------------------------------------
-struct TColoredPrsBulder: TMEDSource
+int
+main(int argc, char** argv)
{
- TColoredPrsBulder(char** argv): TMEDSource(argv)
- {}
-
- int Publish(vtkRenderer *theRenderer) const
- {
- myConvertor->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<TPresent>(myConvertor.get(),
- aMeshName,
- anEntity,
- aFieldName,
- aTimeStamp);
-
- }else{
- continue;
- aPresent = CreateColoredPL<TPresent>(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<int>(strlen(argv[1])) + 1];
+ aMeshName = new char[static_cast<int>(strlen(argv[2])) + 1];
+ aFieldName = new char[static_cast<int>(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<int>(strlen(argv[1])) + 1];
+ aMeshName = new char[static_cast<int>(strlen(argv[2])) + 1];
+ aFieldName = new char[static_cast<int>(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<int>(strlen(argv[1])) + 1];
+ aMeshName = new char[static_cast<int>(strlen(argv[2])) + 1];
+ aFieldName = new char[static_cast<int>(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<class TPrsBuilder>
-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 `"<<aMeshName<<"' in the file `"<<aFileName<<"'"<<endl;
+ PrintErr();
+ return 1;
+ }
+ if(!isFieldOk) {
+ PrintErr();
+ cout<<"Can not find field with name `"<<aFieldName<<"' on the mesh `"<<aMeshName<<"'"<<endl;
+ PrintErr();
+ return 1;
+ }
+ if(!isComponentOk) {
+ PrintErr();
+ cout<<"Field field with name `"<<aFieldName<<"' containt less then `"<<aComponentNumber<<"' component(s)."<<endl;
+ PrintErr();
+ return 1;
+ }
+ if(!isTimeStampOk) {
+ PrintErr();
+ cout<<"Can not find time stamp with number `"<<aTimeStampNumber<<"' on the field `"<<aFieldName<<"'"<<endl;
+ PrintErr();
+ }
}catch(std::exception& exc){
MSG(true, "Follow exception was occured :\n"<<exc.what());
}catch(...){
- MSG(true, "Unknown exception was occured!");
+ MSG(true, "Unknown exception was occured in VISU_Convertor_impl");
}
return 1;
}
myFieldTransform->SetInput(myExtractor->GetOutput());
GetMapperHolder()->SetLookupTable(GetMapperTable());
+ GetMapper()->InterpolateScalarsBeforeMappingOn();
GetMapper()->SetUseLookupTableScalarRange(true);
GetMapper()->SetColorModeToMapScalars();
GetMapper()->ScalarVisibilityOn();
{
SetIsShrinkable(false);
+ SetElnoDisassembleState( true );
+
myAppendPolyData = vtkAppendPolyData::New();
myNbParts = 10;
#include "VISU_DataSetMapperHolder.hxx"
#include "SALOME_ExtractGeometry.h"
+#include "VISU_ElnoDisassembleFilter.hxx"
#include "VISU_LookupTable.hxx"
#include "VISU_PipeLineUtils.hxx"
#include <vtkImplicitFunctionCollection.h>
#include <vtkMath.h>
+#include <cmath>
+
#ifdef _DEBUG_
static int MYDEBUG = 0;
#else
//----------------------------------------------------------------------------
VISU_DataSetMapperHolder
::VISU_DataSetMapperHolder():
- myExtractGeometry(SALOME_ExtractGeometry::New())
+ myElnoDisassembleFilter( VISU_ElnoDisassembleFilter::New() ),
+ myExtractGeometry( SALOME_ExtractGeometry::New() )
{
if(MYDEBUG) MESSAGE("VISU_DataSetMapperHolder::VISU_DataSetMapperHolder - "<<this);
+ myElnoDisassembleFilter->Delete();
+
// Clipping functionality
myExtractGeometry->Delete();
myExtractGeometry->SetStoreMapping(true);
}
+//----------------------------------------------------------------------------
+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
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 );
}
class vtkDataSetMapper;
class vtkUnstructuredGrid;
class SALOME_ExtractGeometry;
+class VISU_ElnoDisassembleFilter;
//----------------------------------------------------------------------------
ShallowCopy(VISU_MapperHolder *theMapperHolder,
bool theIsCopyInput);
+ void
+ SetElnoDisassembleState( bool theIsShrunk );
+
//! Gets memory size used by the instance (bytes).
virtual
unsigned long int
private:
//----------------------------------------------------------------------------
VISU::PUnstructuredGridIDMapper myUnstructuredGridIDMapper;
- vtkSmartPointer<vtkDataSetMapper> myDataSetMapper;
- vtkSmartPointer<SALOME_ExtractGeometry> myExtractGeometry; //!< Clipping
+ vtkSmartPointer< VISU_ElnoDisassembleFilter > myElnoDisassembleFilter; //!< Handling ELNO data
+ vtkSmartPointer< SALOME_ExtractGeometry > myExtractGeometry; //!< Clipping
+ vtkSmartPointer< vtkDataSetMapper > myDataSetMapper;
};
#endif
--- /dev/null
+// 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 <vtkCellData.h>
+#include <vtkInformation.h>
+#include <vtkInformationVector.h>
+#include <vtkObjectFactory.h>
+#include <vtkPointData.h>
+#include <vtkUnstructuredGrid.h>
+#include <vtkPoints.h>
+#include <vtkCellArray.h>
+
+
+//----------------------------------------------------------------------------
+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;
+}
+
+
+//----------------------------------------------------------------------------
--- /dev/null
+// 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 <vtkPointSetAlgorithm.h>
+
+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
--- /dev/null
+// 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 <vtkCellData.h>
+#include <vtkInformation.h>
+#include <vtkInformationVector.h>
+#include <vtkObjectFactory.h>
+#include <vtkPointData.h>
+#include <vtkUnstructuredGrid.h>
+#include <vtkPoints.h>
+#include <vtkCellArray.h>
+
+
+//----------------------------------------------------------------------------
+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;
+}
+
+
+//----------------------------------------------------------------------------
--- /dev/null
+// 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 <vtkUnstructuredGridAlgorithm.h>
+
+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
{
SetIsShrinkable(false);
+ SetElnoDisassembleState( true );
+
myContourFilter = vtkContourFilter::New();
myCellDataToPointData = vtkCellDataToPointData::New();
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
#include "VISU_ScalarMapPL.hxx"
#include "VISU_DataSetMapperHolder.hxx"
+#include "VISU_ElnoAssembleFilter.hxx"
#include "VISU_FieldTransform.hxx"
#include "VISU_AppendFilter.hxx"
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();
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() );
}
}
+//----------------------------------------------------------------------------
+void
+VISU_ScalarMapPL
+::SetElnoDisassembleState( bool theIsShrunk )
+{
+ GetDataSetMapperHolder()->SetElnoDisassembleState( theIsShrunk );
+ myElnoAssembleFilter->SetElnoAssembleState( theIsShrunk );
+}
+
//----------------------------------------------------------------------------
void
VISU_ScalarMapPL
#include "VISU_UnstructuredGridPL.hxx"
class VISU_DataSetMapperHolder;
+class VISU_ElnoAssembleFilter;
class VISU_AppendFilter;
class VISU_MergeFilter;
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<VISU_AppendFilter> myAppendFilter;
- vtkSmartPointer<VISU_MergeFilter> myMergeFilter;
+ vtkSmartPointer< VISU_ElnoAssembleFilter > myElnoAssembleFilter;
+ vtkSmartPointer< VISU_AppendFilter > myAppendFilter;
+ vtkSmartPointer< VISU_MergeFilter > myMergeFilter;
};
#endif