From: apo Date: Fri, 2 May 2008 08:05:09 +0000 (+0000) Subject: Since now ElnoDisassemblyFilter has ability to shrink the newly generated point coord... X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=71204fedb1dd8cb8206883df5803fc763eff0324;p=modules%2Fvisu.git Since now ElnoDisassemblyFilter has ability to shrink the newly generated point coordinates --- diff --git a/src/PIPELINE/VISUPipeLine.cxx b/src/PIPELINE/VISUPipeLine.cxx index 79d4cae4..692c7e74 100644 --- a/src/PIPELINE/VISUPipeLine.cxx +++ b/src/PIPELINE/VISUPipeLine.cxx @@ -51,6 +51,9 @@ #include "VISU_ElnoDisassembleFilter.hxx" #include "VISU_ElnoExtractScalars.hxx" +#include +#include + #include #include @@ -253,11 +256,23 @@ main(int argc, char** argv) VISU::WriteToFile( aDisassembleFilter->GetOutput(), "/data/apo/elno_from_disassemble.vtk" ); VISU_ElnoExtractScalars* anExtractScalars = VISU_ElnoExtractScalars::New(); + anExtractScalars->SetScalarMode( aComponentNumber ); anExtractScalars->SetInput( aDisassembleFilter->GetOutput() ); VISU::WriteToFile( anExtractScalars->GetOutput(), "/data/apo/elno_from_scalars.vtk" ); + vtkShrinkFilter* aShrinkFilter = vtkShrinkFilter::New(); + aShrinkFilter->SetInput( anExtractScalars->GetOutput() ); + aShrinkFilter->SetShrinkFactor( 0.999 ); + VISU::WriteToFile( aShrinkFilter->GetOutput(), "/data/apo/elno_from_shrink.vtk" ); + vtkCutter *aCutter = vtkCutter::New(); - aCutter->SetInput( anUnstructuredGrid ); + + vtkPointLocator* aPointLocator = vtkPointLocator::New(); + aCutter->SetLocator( aPointLocator ); + aPointLocator->Delete(); + + aCutter->SetInput( anExtractScalars->GetOutput() ); + //aCutter->SetInput( aShrinkFilter->GetOutput() ); vtkPlane *aPlane = vtkPlane::New(); //aPlane->SetOrigin( 100.0, 100.0, 100.0 ); @@ -281,7 +296,8 @@ main(int argc, char** argv) vtkFloatingPointType aScalarRange[ 2 ]; aGeometryFilter->GetRange( aScalarRange ); - + anExtractScalars->GetOutput()->GetScalarRange( aScalarRange ); + aCutter->GetOutput()->GetScalarRange( aScalarRange ); // To calculate and apply default scale factor //{ // vtkFloatingPointType aScale = VISU_DeformedShapePL::GetScaleFactor( anElnoWarpVector->GetOutput() ); @@ -289,8 +305,12 @@ main(int argc, char** argv) // anElnoWarpVector->SetScaleFactor( aScale ); //} - VISU_OpenGLElnoMapper* aMapper = VISU_OpenGLElnoMapper::New(); - aMapper->SetInput( aGeometryFilter->GetOutput() ); + //VISU_OpenGLElnoMapper* aMapper = VISU_OpenGLElnoMapper::New(); + vtkDataSetMapper* aMapper = vtkDataSetMapper::New(); + aMapper->SetScalarModeToUsePointData(); + + //aMapper->SetInput( aGeometryFilter->GetOutput() ); + aMapper->SetInput( aCutter->GetOutput() ); VISU_LookupTable* aMapperTable( VISU_LookupTable::New() ); aMapperTable->SetHueRange( 0.667, 0.0 ); @@ -302,7 +322,7 @@ main(int argc, char** argv) aMapper->SetColorModeToMapScalars(); aMapper->ScalarVisibilityOn(); - anActor->SetMapper( aMapper ); + anActor->SetMapper( aMapper ); vtkScalarBarActor* aScalarBar = vtkScalarBarActor::New(); aScalarBar->SetLookupTable( aMapperTable ); diff --git a/src/PIPELINE/VISU_ElnoDisassembleFilter.cxx b/src/PIPELINE/VISU_ElnoDisassembleFilter.cxx index f103f634..e7ecfedf 100644 --- a/src/PIPELINE/VISU_ElnoDisassembleFilter.cxx +++ b/src/PIPELINE/VISU_ElnoDisassembleFilter.cxx @@ -91,21 +91,58 @@ namespace TElnoDataArray* anElnoPointsDataArray = TElnoDataArray::New(); anElnoPointsDataArray->SetNumberOfComponents( aGetElnoNodeData.getNbComp() ); anElnoPointsDataArray->SetNumberOfTuples( aNbPoints ); - anElnoPointsDataArray->SetName( "ELNO_POINTS_DATA" ); + anElnoPointsDataArray->SetName( "ELNO_POINT_DATA" ); + + TPointsDataArray* aPointCoords = TPointsDataArray::New(); + aPointCoords->SetNumberOfComponents( 3 ); + aPointCoords->SetNumberOfTuples( aNbPoints ); + aPointCoords->SetName( "ELNO_POINT_COORDS" ); aConnectivity->InitTraversal(); vtkIdType aNbPts = 0, *aPts = 0; for ( vtkIdType aCellId = 0; aConnectivity->GetNextCell( aNbPts, aPts ); aCellId++ ) { + + TPointsDataType aCenter[ 3 ] = { TPointsDataType(), + TPointsDataType(), + TPointsDataType() }; + + for ( vtkIdType aPntId = 0; aPntId < aNbPts; aPntId++ ) { + TPointsDataType aCoords[ 3 ]; + anInputPointsArray->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 ]; anInputPointsArray->GetTupleValue( aCurrentPntId, aCoords ); - aPts[ aPntId ] = anOutputPointsArray->InsertNextTupleValue( aCoords ); - aPointData->CopyData( anInputPointData, aCurrentPntId, aPts[ aPntId ] ); + TPointsDataType aNewCoords[ 3 ]; + static vtkFloatingPointType SHRINK_FACTOR = 0.999; + + aNewCoords[ 0 ] = aCenter[ 0 ] + + TPointsDataType( SHRINK_FACTOR * ( aCoords[ 0 ] - aCenter[ 0 ] ) ); + aNewCoords[ 1 ] = aCenter[ 1 ] + + TPointsDataType( SHRINK_FACTOR * ( aCoords[ 1 ] - aCenter[ 1 ] ) ); + aNewCoords[ 2 ] = aCenter[ 2 ] + + TPointsDataType( SHRINK_FACTOR * ( aCoords[ 2 ] - aCenter[ 2 ] ) ); + + aPts[ aPntId ] = anOutputPointsArray->InsertNextTupleValue( aNewCoords ); + vtkIdType aNewPntId = aPts[ aPntId ]; + + aPointCoords->SetTupleValue( aNewPntId, aCoords ); + + aPointData->CopyData( anInputPointData, aCurrentPntId, aNewPntId ); TElnoDataType* anElnoData = aGetElnoNodeData( aCellId, aPntId ); - anElnoPointsDataArray->SetTupleValue( aPts[ aPntId ], anElnoData ); + anElnoPointsDataArray->SetTupleValue( aNewPntId, anElnoData ); } } @@ -115,11 +152,18 @@ namespace theInput->GetCellLocationsArray(), aConnectivity ); - theOutput->GetCellData()->PassData( theInput->GetCellData() ); + vtkCellData *aCellData = theOutput->GetCellData(); + aCellData->PassData( theInput->GetCellData() ); + + aCellData->RemoveArray( "ELNO_COMPONENT_MAPPER" ); + aCellData->RemoveArray( "ELNO_FIELD" ); aPointData->AddArray( anElnoPointsDataArray ); anElnoPointsDataArray->Delete(); + aPointData->AddArray( aPointCoords ); + aPointCoords->Delete(); + return 1; } diff --git a/src/PIPELINE/VISU_ElnoExtractScalars.cxx b/src/PIPELINE/VISU_ElnoExtractScalars.cxx index 6af5b7b9..c6178646 100644 --- a/src/PIPELINE/VISU_ElnoExtractScalars.cxx +++ b/src/PIPELINE/VISU_ElnoExtractScalars.cxx @@ -42,7 +42,7 @@ VISU_ElnoExtractScalars::VISU_ElnoExtractScalars() 0, // port 0, // connection vtkDataObject::FIELD_ASSOCIATION_POINTS, // field association - "ELNO_POINTS_DATA" ); // name + "ELNO_POINT_DATA" ); // name myScalarMode = 1; } @@ -53,6 +53,24 @@ VISU_ElnoExtractScalars::~VISU_ElnoExtractScalars() {} +//---------------------------------------------------------------------------- +void VISU_ElnoExtractScalars::SetScalarMode( vtkIdType theValue ) +{ + if ( myScalarMode == theValue ) + return; + + myScalarMode = theValue; + this->Modified(); +} + + +//---------------------------------------------------------------------------- +vtkIdType VISU_ElnoExtractScalars::GetScalarMode() +{ + return myScalarMode; +} + + //---------------------------------------------------------------------------- namespace { diff --git a/src/PIPELINE/VISU_ElnoExtractScalars.hxx b/src/PIPELINE/VISU_ElnoExtractScalars.hxx index fba4ac27..d33ad146 100644 --- a/src/PIPELINE/VISU_ElnoExtractScalars.hxx +++ b/src/PIPELINE/VISU_ElnoExtractScalars.hxx @@ -29,7 +29,6 @@ public: static VISU_ElnoExtractScalars *New(); - //! Specify value to scale displacement. void SetScalarMode( vtkIdType theValue ); vtkIdType GetScalarMode();