From 53f990a39e763176f8c6c13ebead7435a8965393 Mon Sep 17 00:00:00 2001 From: apo Date: Fri, 2 May 2008 11:36:44 +0000 Subject: [PATCH] Now ElnoDisassembleFilter can generate corresponding vectorial data --- src/PIPELINE/VISUPipeLine.cxx | 8 +++--- src/PIPELINE/VISU_ElnoDisassembleFilter.cxx | 28 ++++++++++++++++++++- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/PIPELINE/VISUPipeLine.cxx b/src/PIPELINE/VISUPipeLine.cxx index 8ab6e28b..96d7f9bb 100644 --- a/src/PIPELINE/VISUPipeLine.cxx +++ b/src/PIPELINE/VISUPipeLine.cxx @@ -287,8 +287,10 @@ main(int argc, char** argv) VISU::WriteToFile( aCutter->GetOutput(), "/data/apo/elno_from_cutter.vtk" ); VISU_ElnoAssembleFilter* anAssembleFilter = VISU_ElnoAssembleFilter::New(); - anAssembleFilter->SetInput( aCutter->GetOutput() ); - VISU::WriteToFile( anAssembleFilter->GetPolyDataOutput(), "/data/apo/elno_from_assemble.vtk" ); + //anAssembleFilter->SetInput( aCutter->GetOutput() ); + //VISU::WriteToFile( anAssembleFilter->GetPolyDataOutput(), "/data/apo/elno_from_assemble.vtk" ); + anAssembleFilter->SetInput( anExtractScalars->GetOutput() ); + VISU::WriteToFile( anAssembleFilter->GetUnstructuredGridOutput(), "/data/apo/elno_from_assemble.vtk" ); //VISU_ElnoWarpVector* anElnoWarpVector = VISU_ElnoWarpVector::New(); //anElnoWarpVector->SetInput( anUnstructuredGridIDMapper->GetUnstructuredGridOutput() ); @@ -303,7 +305,7 @@ main(int argc, char** argv) vtkFloatingPointType aScalarRange[ 2 ]; aGeometryFilter->GetRange( aScalarRange ); anExtractScalars->GetOutput()->GetScalarRange( aScalarRange ); - aCutter->GetOutput()->GetScalarRange( aScalarRange ); + //aCutter->GetOutput()->GetScalarRange( aScalarRange ); // To calculate and apply default scale factor //{ // vtkFloatingPointType aScale = VISU_DeformedShapePL::GetScaleFactor( anElnoWarpVector->GetOutput() ); diff --git a/src/PIPELINE/VISU_ElnoDisassembleFilter.cxx b/src/PIPELINE/VISU_ElnoDisassembleFilter.cxx index b73b5214..45e5c075 100644 --- a/src/PIPELINE/VISU_ElnoDisassembleFilter.cxx +++ b/src/PIPELINE/VISU_ElnoDisassembleFilter.cxx @@ -89,11 +89,16 @@ namespace TPointsDataArray *theOutputPointsArray, VISU::TGetElnoNodeData< elno_type >& theGetElnoNodeData, TElnoDataArray* theElnoPointDataArray, + TElnoDataArray* theElnoPointVectors, TPointsDataArray *theElnoPointCoords ) { typedef typename VISU::TL::TEnum2VTKBasicType< points_type >::TResult TPointsDataType; typedef typename VISU::TL::TEnum2VTKBasicType< elno_type >::TResult TElnoDataType; + // To reserve a temproary value holder + vtkIdType aNbComp = std::max( 3, theGetElnoNodeData.getNbComp() ); + std::vector< TElnoDataType > anElnoDataValues( aNbComp ); + theConnectivity->InitTraversal(); vtkIdType aNbPts = 0, *aPts = 0; for ( vtkIdType aCellId = 0; theConnectivity->GetNextCell( aNbPts, aPts ); aCellId++ ) { @@ -111,6 +116,9 @@ namespace TElnoDataType* anElnoData = theGetElnoNodeData( aCellId, aPntId ); theElnoPointDataArray->SetTupleValue( aNewPntId, anElnoData ); + + theElnoPointDataArray->GetTupleValue( aNewPntId, &anElnoDataValues[ 0 ] ); + theElnoPointVectors->SetTupleValue( aNewPntId, &anElnoDataValues[ 0 ] ); } } } @@ -125,12 +133,17 @@ namespace TPointsDataArray *theOutputPointsArray, VISU::TGetElnoNodeData< elno_type >& theGetElnoNodeData, TElnoDataArray* theElnoPointDataArray, + TElnoDataArray* theElnoPointVectors, TPointsDataArray *theElnoPointCoords, vtkFloatingPointType theShrinkFactor ) { typedef typename VISU::TL::TEnum2VTKBasicType< points_type >::TResult TPointsDataType; typedef typename VISU::TL::TEnum2VTKBasicType< elno_type >::TResult TElnoDataType; + // To reserve a temproary value holder + vtkIdType aNbComp = std::max( 3, theGetElnoNodeData.getNbComp() ); + std::vector< TElnoDataType > anElnoDataValues( aNbComp ); + theConnectivity->InitTraversal(); vtkIdType aNbPts = 0, *aPts = 0; for ( vtkIdType aCellId = 0; theConnectivity->GetNextCell( aNbPts, aPts ); aCellId++ ) { @@ -172,7 +185,10 @@ namespace theOutputPointData->CopyData( theInputPointData, aCurrentPntId, aNewPntId ); TElnoDataType* anElnoData = theGetElnoNodeData( aCellId, aPntId ); - theElnoPointDataArray->SetTupleValue( aNewPntId, anElnoData ); + theElnoPointDataArray->SetTupleValue( aNewPntId, anElnoData ); + + theElnoPointDataArray->GetTupleValue( aNewPntId, &anElnoDataValues[ 0 ] ); + theElnoPointVectors->SetTupleValue( aNewPntId, &anElnoDataValues[ 0 ] ); } } } @@ -211,6 +227,11 @@ namespace anElnoPointDataArray->SetNumberOfTuples( aNbPoints ); anElnoPointDataArray->SetName( "ELNO_POINT_DATA" ); + TElnoDataArray* anElnoPointVectors = TElnoDataArray::New(); + anElnoPointVectors->SetNumberOfComponents( 3 ); + anElnoPointVectors->SetNumberOfTuples( aNbPoints ); + anElnoPointVectors->SetName( "ELNO_POINT_VECTORS" ); + TPointsDataArray* anElnoPointCoords = TPointsDataArray::New(); anElnoPointCoords->SetNumberOfComponents( 3 ); anElnoPointCoords->SetNumberOfTuples( aNbPoints ); @@ -225,6 +246,7 @@ namespace anOutputPointsArray, aGetElnoNodeData, anElnoPointDataArray, + anElnoPointVectors, anElnoPointCoords, theShrinkFactor ); } else { @@ -236,6 +258,7 @@ namespace anOutputPointsArray, aGetElnoNodeData, anElnoPointDataArray, + anElnoPointVectors, anElnoPointCoords ); } @@ -254,6 +277,9 @@ namespace anOutputPointData->AddArray( anElnoPointDataArray ); anElnoPointDataArray->Delete(); + anOutputPointData->AddArray( anElnoPointVectors ); + anElnoPointVectors->Delete(); + anOutputPointData->AddArray( anElnoPointCoords ); anElnoPointCoords->Delete(); -- 2.39.2