7 #include <vtkCellArray.h> 8 #include <vtkCellData.h> 9 #include <vtkContourFilter.h> 10 #include <vtkDoubleArray.h> 11 #include <vtkFloatArray.h> 12 #include <vtkFollower.h> 13 #include <vtkHedgeHog.h> 15 #include <vtkLookupTable.h> 16 #include <vtkPointData.h> 17 #include <vtkPoints.h> 18 #include <vtkPolyData.h> 19 #include <vtkPolyDataMapper.h> 20 #include <vtkPolyDataNormals.h> 21 #include <vtkPolyLine.h> 22 #include <vtkProperty.h> 23 #include <vtkScalarBarActor.h> 24 #include <vtkVectorText.h> 25 #include <vtkWarpScalar.h> 27 #include <vtkWindowedSincPolyDataFilter.h> 38 , m_pContentIR( pContentIR )
40 , m_iScaling( SCALING_LINEAR )
44 , m_pCarpetPolyData( 0 )
45 , m_pCarpetMapper( 0 )
60 , m_pContentIR( pContentIR )
66 , m_pCarpetPolyData( 0 )
67 , m_pCarpetMapper( 0 )
80 void CarpetPlot::Init()
82 if( m_pContentIR ==
nullptr )
86 m_pCarpetPolyData = vtkSmartPointer< vtkPolyData >::New();
90 m_pCarpetMapper = vtkSmartPointer< vtkPolyDataMapper >::New();
93 vtkSmartPointer< vtkLookupTable > lut = vtkSmartPointer< vtkLookupTable>::New();
94 vtkSmartPointer< vtkLookupTable > refLut = vtkSmartPointer< vtkLookupTable >::New();
98 for(
int i = 0; i < 256; i++ )
99 lut->SetTableValue( i, refLut->GetTableValue( 255 - i ) );
101 m_pCarpetMapper->SetLookupTable( lut );
111 m_pWarp = vtkSmartPointer< vtkWarpScalar >::New();
112 m_pWarp->SetInputData( m_pCarpetPolyData );
114 m_pWarp->UseNormalOff();
117 m_pCarpetMapper->SetInputConnection( m_pWarp->GetOutputPort() );
121 m_pCarpetActor = vtkSmartPointer< vtkActor >::New();
122 m_pCarpetActor->SetMapper( m_pCarpetMapper );
123 m_pCarpetActor->GetProperty()->SetInterpolationToPhong();
124 m_pCarpetActor->RotateX( -90 );
125 m_pCarpetActor->RotateZ( 180 );
184 void CarpetPlot::InitCarpetMesh()
190 int iNumPointsX, iIndexMaxX;
195 iIndexMaxX = iNumPointsX + 1;
197 iIndexMaxX = iNumPointsX;
202 iIndexMaxX = iNumPointsX;
207 vtkIdType quadface[ 4 ];
208 vtkSmartPointer< vtkPoints > points = vtkSmartPointer< vtkPoints >::New();
209 vtkSmartPointer< vtkCellArray > cells = vtkSmartPointer< vtkCellArray >::New();
210 for(
int i = 0; i < iIndexMaxX; i++ )
212 for(
int j = 0; j < iNumPointsY; j++ )
214 if( ( i != iIndexMaxX - 1 ) && ( j != iNumPointsY - 1 ) )
216 quadface[ 0 ] = ( i + 1 )*iNumPointsY + j + 1;
217 quadface[ 1 ] = ( i + 1 )*iNumPointsY + j;
218 quadface[ 2 ] = ( i ) *iNumPointsY + j;
219 quadface[ 3 ] = ( i ) *iNumPointsY + j + 1;
220 for(
int k = 0; k < 4; k++ )
221 assert( ( quadface[ k ] >= 0 ) && ( quadface[ k ] < iIndexMaxX*iNumPointsY ) );
222 cells->InsertNextCell( 4, quadface );
224 vtkIdType iPointiD = i*iNumPointsY + j;
225 double dX = 2.0f * double( i ) / double( iNumPointsX ) - 1.0f;
226 double dY = 2.0f * double( j ) / double( iNumPointsY ) - 1.0f;
228 points->InsertPoint( iPointiD, dX, dY, dZ );
232 m_pCarpetPolyData->SetPoints( points );
233 m_pCarpetPolyData->SetPolys( cells );
244 assert( m_pContentIR != 0 );
247 std::ostringstream s;
251 float dPosX=0, dPosY=0, dPosZ=0;
252 dPosY = 2*m_dProbeY/iLen - 1;
254 dPosZ = (m_dMin)/(m_dMax-m_dMin);
263 m_pProbe->SetPosition(dPosX, dPosZ, dPosY);
264 m_pLabel->SetPosition(dPosX, dPosZ+1.01, dPosY);
267 pBuf =
new float[iLen];
269 fMag = pBuf[(int)m_dProbeY];
273 fMag = factor2decibel( (
double ) fabs( fMag ) );
278 m_pProbeLabel->SetText(s.str().c_str());
291 m_pProbe->SetVisibility(bVisible);
292 m_pLabel->SetVisibility(bVisible);
310 m_iScaling = iScaling;
322 m_iFixedAngle = iFixedAngle;
328 return m_iFixedAngle;
333 assert( m_pContentIR !=
NULL);
334 assert( dMin < dMax );
343 m_dMin = decibel2factor( dMin );
344 m_dMax = decibel2factor( dMax );
351 m_pCarpetMapper->SetScalarVisibility( bVisible );
356 return m_pCarpetMapper->GetScalarVisibility();
369 return factor2decibel( m_dMin );
377 return factor2decibel(m_dMax);
384 m_pCarpetMapper->SetInputConnection( m_pWarp->GetOutputPort() );
386 m_pCarpetMapper->SetInputData( m_pCarpetPolyData );
401 void CarpetPlot::updatePlotOffset()
405 if( ( m_iScaling ==
SCALING_LINEAR ) && ( ( m_dMin < 0 ) && ( m_dMax > 0 ) ) )
406 m_pCarpetActor->SetPosition( 0, m_dMin / ( m_dMax - m_dMin ), 0 );
408 m_pCarpetActor->SetPosition( 0, 0, 0 );
410 m_pCarpetActor->SetPosition( 0, 0, 0 );
412 m_pCarpetActor->SetPosition( 0, 0, 0 );
416 void CarpetPlot::SetScalars()
419 assert( m_pContentIR !=
NULL);
420 assert( m_dMin < m_dMax );
422 vtkSmartPointer< vtkFloatArray > pIRWarpArray = vtkSmartPointer< vtkFloatArray >::New();
423 pIRWarpArray->SetName(
"DAFFIRWarpData" );
430 for(
int i = 0; i <= iNumPoints; i++ )
445 coeff = ( float ) factor2decibel( (
double ) fabs( coeff ) );
448 float DECIBEL_LOWER = -100;
450 DECIBEL_LOWER = factor2decibel( m_dMin );
451 float DECIBEL_UPPER = factor2decibel( m_dMax );
455 coeff = std::max(coeff, DECIBEL_LOWER);
456 coeff = std::min(coeff, DECIBEL_UPPER);
458 coeff = 1.0 / ( DECIBEL_UPPER - DECIBEL_LOWER )*coeff + DECIBEL_LOWER / ( DECIBEL_LOWER - DECIBEL_UPPER );
463 coeff = std::max( coeff, m_dMin );
464 coeff = std::min( coeff, m_dMax );
466 coeff = ( coeff - m_dMin ) / ( m_dMax - m_dMin );
469 pIRWarpArray->InsertNextTuple1( coeff );
493 coeff = ( float ) factor2decibel( (
double ) fabs( coeff ) );
496 float DECIBEL_LOWER = -100;
498 DECIBEL_LOWER = factor2decibel( m_dMin );
499 float DECIBEL_UPPER = factor2decibel( m_dMax );
503 coeff = std::max( coeff, DECIBEL_LOWER );
504 coeff = std::min( coeff, DECIBEL_UPPER );
506 coeff = 1.0/(DECIBEL_UPPER-DECIBEL_LOWER)*coeff + DECIBEL_LOWER/(DECIBEL_LOWER-DECIBEL_UPPER);
511 coeff = std::max( coeff, m_dMin );
512 coeff = std::min( coeff, m_dMax );
514 coeff = ( coeff - m_dMin ) / ( m_dMax - m_dMin );
517 pIRWarpArray->InsertNextTuple1( coeff );
523 m_pCarpetPolyData->GetPointData()->SetScalars( pIRWarpArray );
532 double CarpetPlot::factor2decibel(
double x )
const 536 if( x <= 0.0000000001 )
return -100;
537 return 10 * log( x ) / log( (
double ) 10 );
540 double CarpetPlot::decibel2factor(
double x )
const 542 return pow( 10.0, .1*x );
548 m_pCarpetActor->GetProperty()->SetRepresentationToSurface();
550 m_pCarpetActor->GetProperty()->SetRepresentationToWireframe();
552 m_pCarpetActor->GetProperty()->SetRepresentationToPoints();
557 m_iChannel = iChannel;
void AddActor(vtkSmartPointer< vtkActor > pActor)
Add a VTK actor to the node.
int getScalarVisibility()
Get whether scalars should be used to color the model.
int GetChannel()
get active channel
int GetScaling() const
Get scaling (SCALING_LINEAR | SCALING_DECIBEL)
void RemoveActor(vtkSmartPointer< vtkActor > pActor)
Remove a VTK actor from the assembly of the node.
virtual void getNearestNeighbour(int iView, float fAngle1Deg, float fAngle2Deg, int &iRecordIndex) const =0
Determine the nearest neighbour record and return its index.
void SetScalarVisibility(bool bVisible)
Set whether scalars should be used to color the model.
void SetProbeAngles(double dAlpha, double dBeta)
Set probe angles.
virtual float getAlphaStart() const =0
void SetDisplayMode(int iMode)
Set display mode (MODE_SURFACE | MODE_WIREFRAME | MODE_POINT)
virtual int getFilterLength() const =0
Returns the number of filter coefficients.
virtual float getBetaEnd() const =0
float GetSelectedAngle() const
Returns the currently selected angle in degree (interval [-90° 90°])
virtual float getBetaStart() const =0
virtual float getBetaSpan() const =0
virtual int getAlphaPoints() const =0
Base class for scene graph nodes.
virtual int getFilterCoeffs(int iRecordIndex, int iChannel, float *pfDest, float fGain=1.0F) const =0
Retrieves filter coefficients for record and channel.
void SetFixedAngle(int iFixedAngle)
Set fixed angle (ALPHA_FIXED | BETA_FIXED)
double GetRangeMin() const
Set minimum of data range (in dB or absolute values depending on currently used scaling) ...
void SetRange(double dMin, double dMax)
Set data range (in dB or absolute values depending on currently used scaling)
void SetChannel(int iChannel)
Set active channel.
virtual const DAFFProperties * getProperties() const =0
Returns the properties.
int getFixedAngle()
Get fixed angle (ALPHA_FIXED | BETA_FIXED)
Impulse response content interface.
void SetProbeVisible(bool bVisible)
Enables/disables probe.
void UpdateProbe()
Update probe nodes.
void SetWarpingEnabled(bool bEnabled)
virtual float getAlphaEnd() const =0
virtual float getAlphaSpan() const =0
double GetRangeMax() const
Set minimum of data range (in dB or absolute values depending on currently used scaling) ...
virtual int getBetaPoints() const =0
Properties of a DAFF file that uses regular sphere grids (or parts of a regular grid) ...
void SetScaling(int iScaling)
Set scaling (SCALING_LINEAR | SCALING_DECIBEL)
void EnableWarp()
Enable/Disable warping (WARP_DISABLE | WARP_ENABLE)
CarpetPlot(SGNode *pParent, const DAFFContentIR *pContentIR)
void SetSelectedAngle(float fAngle)
Sets the currently selected angle in degree.
Data-related view referring to data spherical coordinates (DSC)
virtual bool coversFullAlphaRange() const =0
Indicates whether the data covers the full alpha range [0°, 360°)