VISU_SphereWidget.hxx \
VISU_WidgetCtrl.hxx \
VISU_ScalarMapOnDeformedShapePL.hxx \
- VISU_OpenGLElnoMapper.hxx \
- VISU_ElnoWarpVector.cxx \
- VISU_ElnoGeometryFilter.hxx \
- VISU_ElnoMapperHolder.hxx \
VISU_ElnoScalarMapPL.hxx \
VISUPipeline.hxx
VISU_ScalarMapOnDeformedShapePL.cxx \
VISU_OpenGLElnoMapper.cxx \
VISU_ElnoGeometryFilter.cxx \
+ VISU_ElnoDisassembleFilter.cxx \
+ VISU_ElnoExtractScalars.cxx \
VISU_ElnoMapperHolder.cxx \
VISU_ElnoScalarMapPL.cxx \
VISU_ElnoWarpVector.cxx
#include "VISU_ElnoGeometryFilter.hxx"
#include "VISU_OpenGLElnoMapper.hxx"
+#include "VISU_ElnoDisassembleFilter.hxx"
+#include "VISU_ElnoExtractScalars.hxx"
+
#include <vtkCutter.h>
#include <vtkPlane.h>
vtkUnstructuredGrid* anUnstructuredGrid = anUnstructuredGridIDMapper->GetUnstructuredGridOutput();
VISU::WriteToFile( anUnstructuredGrid, "/data/apo/elno_from_id_mapper.vtk" );
+ VISU_ElnoDisassembleFilter* aDisassembleFilter = VISU_ElnoDisassembleFilter::New();
+ aDisassembleFilter->SetInput( anUnstructuredGrid );
+ VISU::WriteToFile( aDisassembleFilter->GetOutput(), "/data/apo/elno_from_disassemble.vtk" );
+
+ VISU_ElnoExtractScalars* anExtractScalars = VISU_ElnoExtractScalars::New();
+ anExtractScalars->SetInput( aDisassembleFilter->GetOutput() );
+ VISU::WriteToFile( anExtractScalars->GetOutput(), "/data/apo/elno_from_scalars.vtk" );
+
vtkCutter *aCutter = vtkCutter::New();
aCutter->SetInput( anUnstructuredGrid );
--- /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
+}
+
+
+//----------------------------------------------------------------------------
+VISU_ElnoDisassembleFilter::~VISU_ElnoDisassembleFilter()
+{}
+
+
+//----------------------------------------------------------------------------
+namespace
+{
+ template < int points_type, int elno_type >
+ int Execute2( vtkUnstructuredGrid *theInput,
+ vtkUnstructuredGrid *theOutput,
+ vtkDataArray *theElnoDataArray,
+ vtkDataArray *theElnoDataMapper )
+ {
+ VISU::TGetElnoNodeData< elno_type > aGetElnoNodeData( theElnoDataArray, theElnoDataMapper );
+
+ vtkCellArray *aConnectivity = vtkCellArray::New();
+ aConnectivity->DeepCopy( theInput->GetCells() );
+
+ vtkPoints *anInputPoints = theInput->GetPoints();
+ vtkPoints *aPoints = anInputPoints->New( anInputPoints->GetDataType() );
+ vtkIdType aNbCells = aConnectivity->GetNumberOfCells();
+ vtkIdType aNbPoints = aConnectivity->GetNumberOfConnectivityEntries() - aNbCells;
+ aPoints->Allocate( aNbPoints );
+
+ typedef typename VISU::TL::TEnum2VTKArrayType< points_type >::TResult TPointsDataArray;
+ typedef typename VISU::TL::TEnum2VTKBasicType< points_type >::TResult TPointsDataType;
+ TPointsDataArray* anInputPointsArray = TPointsDataArray::SafeDownCast( anInputPoints->GetData() );
+ TPointsDataArray* anOutputPointsArray = TPointsDataArray::SafeDownCast( aPoints->GetData() );
+
+ vtkPointData *anInputPointData = theInput->GetPointData();
+ vtkPointData *aPointData = theOutput->GetPointData();
+ aPointData->Allocate( aNbPoints );
+
+ typedef typename VISU::TL::TEnum2VTKArrayType< elno_type >::TResult TElnoDataArray;
+ typedef typename VISU::TL::TEnum2VTKBasicType< elno_type >::TResult TElnoDataType;
+ TElnoDataArray* anElnoPointsDataArray = TElnoDataArray::New();
+ anElnoPointsDataArray->SetNumberOfComponents( aGetElnoNodeData.getNbComp() );
+ anElnoPointsDataArray->SetNumberOfTuples( aNbPoints );
+ anElnoPointsDataArray->SetName( "ELNO_POINTS_DATA" );
+
+ aConnectivity->InitTraversal();
+ vtkIdType aNbPts = 0, *aPts = 0;
+ for ( vtkIdType aCellId = 0; aConnectivity->GetNextCell( aNbPts, aPts ); aCellId++ ) {
+ for ( vtkIdType aPntId = 0; aPntId < aNbPts; aPntId++ ) {
+ TPointsDataType aCoords[ 3 ];
+ vtkIdType aCurrentPntId = aPts[ aPntId ];
+ anInputPointsArray->GetTupleValue( aCurrentPntId, aCoords );
+ aPts[ aPntId ] = anOutputPointsArray->InsertNextTupleValue( aCoords );
+
+ aPointData->CopyData( anInputPointData, aCurrentPntId, aPts[ aPntId ] );
+
+ TElnoDataType* anElnoData = aGetElnoNodeData( aCellId, aPntId );
+ anElnoPointsDataArray->SetTupleValue( aPts[ aPntId ], anElnoData );
+ }
+ }
+
+ theOutput->SetPoints( aPoints );
+
+ theOutput->SetCells( theInput->GetCellTypesArray(),
+ theInput->GetCellLocationsArray(),
+ aConnectivity );
+
+ theOutput->GetCellData()->PassData( theInput->GetCellData() );
+
+ aPointData->AddArray( anElnoPointsDataArray );
+ anElnoPointsDataArray->Delete();
+
+ return 1;
+ }
+
+
+ //----------------------------------------------------------------------------
+ template < int points_type >
+ int Execute( vtkUnstructuredGrid *theInput,
+ vtkUnstructuredGrid *theOutput,
+ vtkDataArray *theElnoDataArray,
+ vtkDataArray *theElnoDataMapper )
+ {
+ switch( theElnoDataArray->GetDataType() ){
+ case VTK_DOUBLE:
+ return Execute2< points_type, VTK_DOUBLE >( theInput, theOutput, theElnoDataArray, theElnoDataMapper );
+ case VTK_FLOAT:
+ return Execute2< points_type, VTK_FLOAT >( theInput, theOutput, theElnoDataArray, theElnoDataMapper );
+ case VTK_INT:
+ return Execute2< points_type, VTK_INT >( theInput, theOutput, theElnoDataArray, theElnoDataMapper );
+ case VTK_LONG:
+ return Execute2< points_type, VTK_LONG >( theInput, theOutput, theElnoDataArray, theElnoDataMapper );
+ 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 );
+
+ vtkPoints *aPoints = anInput->GetPoints();
+ switch( aPoints->GetDataType() ){
+ case VTK_DOUBLE:
+ return ::Execute< VTK_DOUBLE >( anInput, anOutput, anElnoDataArray, anElnoDataMapper );
+ case VTK_FLOAT:
+ return ::Execute< VTK_FLOAT >( anInput, anOutput, anElnoDataArray, anElnoDataMapper );
+ case VTK_INT:
+ return ::Execute< VTK_INT >( anInput, anOutput, anElnoDataArray, anElnoDataMapper );
+ case VTK_LONG:
+ return ::Execute< VTK_LONG >( anInput, anOutput, anElnoDataArray, anElnoDataMapper );
+ 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();
+
+protected:
+ VISU_ElnoDisassembleFilter();
+ ~VISU_ElnoDisassembleFilter();
+
+ int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
+
+private:
+ VISU_ElnoDisassembleFilter(const VISU_ElnoDisassembleFilter&); // Not implemented.
+ void operator=(const VISU_ElnoDisassembleFilter&); // 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_ElnoExtractScalars.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_ElnoExtractScalars );
+
+
+//----------------------------------------------------------------------------
+VISU_ElnoExtractScalars::VISU_ElnoExtractScalars()
+{
+ this->SetInputArrayToProcess( 0, // idx
+ 0, // port
+ 0, // connection
+ vtkDataObject::FIELD_ASSOCIATION_POINTS, // field association
+ "ELNO_POINTS_DATA" ); // name
+
+ myScalarMode = 1;
+}
+
+
+//----------------------------------------------------------------------------
+VISU_ElnoExtractScalars::~VISU_ElnoExtractScalars()
+{}
+
+
+//----------------------------------------------------------------------------
+namespace
+{
+ template < int elno_type >
+ int Execute( vtkUnstructuredGrid *theInput,
+ vtkUnstructuredGrid *theOutput,
+ vtkDataArray *theElnoPointsDataArray,
+ vtkIdType theScalarMode )
+ {
+ typedef typename VISU::TL::TEnum2VTKArrayType< elno_type >::TResult TElnoDataArray;
+ typedef typename VISU::TL::TEnum2VTKBasicType< elno_type >::TResult TElnoDataType;
+
+ TElnoDataArray* anElnoPointsDataArray = TElnoDataArray::SafeDownCast( theElnoPointsDataArray );
+ vtkIdType aNbComp = anElnoPointsDataArray->GetNumberOfComponents();
+ vtkIdType aNbTuples = anElnoPointsDataArray->GetNumberOfTuples();
+
+ TElnoDataArray* anElnoPointScalars = TElnoDataArray::New();
+ anElnoPointScalars->SetNumberOfComponents( 1 );
+ anElnoPointScalars->SetNumberOfTuples( aNbTuples );
+ anElnoPointScalars->SetName( "ELNO_POINT_SCALARS" );
+
+ std::vector< TElnoDataType > anElnoDataValues( aNbComp ); // To reserve a temproary value holder
+ vtkIdType aNbDim = std::min( 3, aNbComp );
+
+ for ( vtkIdType aTupleId = 0; aTupleId < aNbTuples; aTupleId++ ) {
+ anElnoPointsDataArray->GetTupleValue( aTupleId, &anElnoDataValues[ 0 ] );
+
+ TElnoDataType anElnoValue = 0;
+ if ( theScalarMode > 0 ) {
+ anElnoValue = anElnoDataValues[ theScalarMode - 1 ];
+ } else {
+ for ( vtkIdType aDimId = 0; aDimId < aNbDim; aDimId++ )
+ anElnoValue += anElnoDataValues[ aDimId ] * anElnoDataValues[ aDimId ];
+
+ anElnoValue = TElnoDataType( sqrt( anElnoValue ) );
+ }
+
+ anElnoPointScalars->SetTupleValue( aTupleId, &anElnoValue );
+ }
+
+ theOutput->CopyStructure( theInput );
+
+ theOutput->GetCellData()->PassData( theInput->GetCellData() );
+ theOutput->GetPointData()->PassData( theInput->GetPointData() );
+
+ theOutput->GetPointData()->SetScalars( anElnoPointScalars );
+ anElnoPointScalars->Delete();
+
+ return 1;
+ }
+
+
+ //----------------------------------------------------------------------------
+}
+
+
+//----------------------------------------------------------------------------
+int VISU_ElnoExtractScalars::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 *anElnoPointsDataArray = this->GetInputArrayToProcess( 0, inputVector );
+
+ switch( anElnoPointsDataArray->GetDataType() ){
+ case VTK_DOUBLE:
+ return ::Execute< VTK_DOUBLE >( anInput, anOutput, anElnoPointsDataArray, myScalarMode );
+ case VTK_FLOAT:
+ return ::Execute< VTK_FLOAT >( anInput, anOutput, anElnoPointsDataArray, myScalarMode );
+ case VTK_INT:
+ return ::Execute< VTK_INT >( anInput, anOutput, anElnoPointsDataArray, myScalarMode );
+ case VTK_LONG:
+ return ::Execute< VTK_LONG >( anInput, anOutput, anElnoPointsDataArray, myScalarMode );
+ 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_ElnoExtractScalars_H
+#define VISU_ElnoExtractScalars_H
+
+#include <vtkUnstructuredGridAlgorithm.h>
+
+class VISU_ElnoExtractScalars : public vtkUnstructuredGridAlgorithm
+{
+public:
+ typedef vtkUnstructuredGridAlgorithm Superclass;
+
+ static VISU_ElnoExtractScalars *New();
+
+ //! Specify value to scale displacement.
+ void SetScalarMode( vtkIdType theValue );
+ vtkIdType GetScalarMode();
+
+protected:
+ VISU_ElnoExtractScalars();
+ ~VISU_ElnoExtractScalars();
+
+ int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
+ vtkIdType myScalarMode;
+
+private:
+ VISU_ElnoExtractScalars(const VISU_ElnoExtractScalars&); // Not implemented.
+ void operator=(const VISU_ElnoExtractScalars&); // Not implemented.
+};
+
+#endif
input->GetCellPoints( aCellId, aNbPts, aPts );
for ( vtkIdType aPntId = 0; aPntId < aNbPts; aPntId++ ) {
- vtkIdType aCurrentPntId = aPts[ aPntId ];
- TElnoDataType* anElnoData = aGetElnoNodeData( aCellId, aCurrentPntId );
+ TElnoDataType* anElnoData = aGetElnoNodeData( aCellId, aPntId );
TElnoDataType anElnoValue = 0;
if ( theScalarMode > 0 ) {
vtkPoints *anInputPoints = theInput->GetPoints();
vtkPoints *aPoints = anInputPoints->New( anInputPoints->GetDataType() );
- vtkIdType aNbPoints = aConnectivity->GetNumberOfConnectivityEntries();
- aPoints->SetNumberOfPoints( aNbPoints );
+ vtkIdType aNbCells = aConnectivity->GetNumberOfCells();
+ vtkIdType aNbPoints = aConnectivity->GetNumberOfConnectivityEntries() - aNbCells;
+ aPoints->Allocate( aNbPoints );
typedef typename VISU::TL::TEnum2VTKArrayType< points_type >::TResult TVTKDataArray;
typedef typename VISU::TL::TEnum2VTKBasicType< points_type >::TResult TPointsDataType;
TPointsDataType aCoords[ 3 ];
vtkIdType aCurrentPntId = aPts[ aPntId ];
anInputPointsArray->GetTupleValue( aCurrentPntId, aCoords );
- TElnoDataType* anElnoData = aGetElnoNodeData( aCellId, aCurrentPntId );
+ TElnoDataType* anElnoData = aGetElnoNodeData( aCellId, aPntId );
for ( vtkIdType aDimId = 0; aDimId < aNbDim; aDimId++ )
aCoords[ aDimId ] += TPointsDataType( aScaleFactor * anElnoData[ aDimId ] );