#include "VISU_ElnoDisassembleFilter.hxx"
#include "VISU_ElnoExtractScalars.hxx"
+#include <vtkShrinkFilter.h>
+#include <vtkPointLocator.h>
+
#include <vtkCutter.h>
#include <vtkPlane.h>
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 );
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() );
// 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 );
aMapper->SetColorModeToMapScalars();
aMapper->ScalarVisibilityOn();
- anActor->SetMapper( aMapper );
+ anActor->SetMapper( aMapper );
vtkScalarBarActor* aScalarBar = vtkScalarBarActor::New();
aScalarBar->SetLookupTable( aMapperTable );
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 );
}
}
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;
}
0, // port
0, // connection
vtkDataObject::FIELD_ASSOCIATION_POINTS, // field association
- "ELNO_POINTS_DATA" ); // name
+ "ELNO_POINT_DATA" ); // name
myScalarMode = 1;
}
{}
+//----------------------------------------------------------------------------
+void VISU_ElnoExtractScalars::SetScalarMode( vtkIdType theValue )
+{
+ if ( myScalarMode == theValue )
+ return;
+
+ myScalarMode = theValue;
+ this->Modified();
+}
+
+
+//----------------------------------------------------------------------------
+vtkIdType VISU_ElnoExtractScalars::GetScalarMode()
+{
+ return myScalarMode;
+}
+
+
//----------------------------------------------------------------------------
namespace
{
static VISU_ElnoExtractScalars *New();
- //! Specify value to scale displacement.
void SetScalarMode( vtkIdType theValue );
vtkIdType GetScalarMode();