INCLUDE(GenerateExportHeader)
+FIND_PACKAGE(VTK REQUIRED)
FIND_PACKAGE(ITK REQUIRED)
INCLUDE(${ITK_USE_FILE})
-FIND_PACKAGE(VTK REQUIRED)
-INCLUDE(${VTK_USE_FILE})
+## Check for required modules
+IF(NOT ITKVtkGlue_LOADED)
+ MESSAGE(FATAL_ERROR "ITKVtkGlue module is required but not available.")
+ENDIF(NOT ITKVtkGlue_LOADED)
IF(USE_QT4)
- IF(NOT WIN32)
- FIND_LIBRARY(
- VTK_USES_QT
- NAMES vtkGUISupportQt-${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION}
- HINTS ${VTK_LIBRARY_DIRS}
- PATHS /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64
- )
- FIND_LIBRARY(
- VTK_USES_QT_OPENGL
- vtkGUISupportQtOpenGL-${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION}
- HINTS ${VTK_LIBRARY_DIRS}
- PATHS /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64
- )
- MARK_AS_ADVANCED(FORCE VTK_USES_QT)
- MARK_AS_ADVANCED(FORCE VTK_USES_QT_OPENGL)
- IF(VTK_USES_QT AND VTK_USES_QT_OPENGL)
- FIND_PACKAGE(Qt4 REQUIRED)
- INCLUDE(${QT_USE_FILE})
- ELSE(VTK_USES_QT AND VTK_USES_QT_OPENGL)
- MESSAGE(FATAL_ERROR "VTK ${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION} was not compiled with Qt4 support!")
- ENDIF(VTK_USES_QT AND VTK_USES_QT_OPENGL)
- ELSE(NOT WIN32)
- FIND_PACKAGE(Qt4 REQUIRED)
- INCLUDE(${QT_USE_FILE})
- ENDIF(NOT WIN32)
+ FIND_PACKAGE(Qt4 REQUIRED)
+ INCLUDE(${QT_USE_FILE})
+
+ ## Check for required modules
+ IF(NOT vtkGUISupportQt_LOADED)
+ MESSAGE(
+ FATAL_ERROR
+ "vtkGUISupportQt module is required but not available."
+ )
+ ENDIF(NOT vtkGUISupportQt_LOADED)
+ IF(NOT vtkGUISupportQtOpenGL_LOADED)
+ MESSAGE(
+ FATAL_ERROR
+ "vtkGUISupportQtOpenGL module is required but not available."
+ )
+ ENDIF(NOT vtkGUISupportQtOpenGL_LOADED)
ENDIF(USE_QT4)
## ================================================
else
this->m_Cov.fill( S( 0 ) );
- /* TODO
- TMatrix Es = ( this->m_S1 * this->m_S1.transpose( ) );
- for( unsigned int i = 0; i < D; ++i )
- {
- this->m_Mean[ i ][ 0 ] = this->m_S1[ i ][ 0 ];
- if( this->m_N > 0 )
- this->m_Mean[ i ][ 0 ] /= S( this->m_N );
-
- for( unsigned int j = 0; j < D; ++j )
- {
- this->m_Cov[ i ][ j ] = S( 0 );
- if( this->m_N > 0 )
- this->m_Cov[ i ][ j ] -= Es[ i ][ j ] / S( this->m_N );
- if( this->m_N > 1 )
- {
- this->m_Cov[ i ][ j ] += this->m_S2[ i ][ j ];
- this->m_Cov[ i ][ j ] /= S( this->m_N - 1 );
-
- } // fi
-
- } // rof
-
- } // rof
- */
-
// Compute inverse and determinant
S det = vnl_determinant( this->m_Cov );
if( !( det > S( 0 ) ) )
} // rof
this->m_Updated = true;
-
- /* DEBUG:
- std::cout << "--------------------" << std::endl;
- std::cout << this->m_Cov << std::endl;
- std::cout << "--------------------" << std::endl;
- std::cout << this->m_InvCov << std::endl;
- std::cout << "--------------------" << std::endl;
- std::cout << this->m_Mean << std::endl;
- */
}
// -------------------------------------------------------------------------
TMatrix c( D, 1 );
for( unsigned int d = 0; d < D; ++d )
c[ d ][ 0 ] = S( sample[ d ] ) - this->m_Mean[ d ][ 0 ];
- double v = double( ( c.transpose( ) * ( this->m_InvCov * c ) )[ 0 ][ 0 ] );
- v /= double( 2 );
+ if( S( 0 ) < this->m_DensityCoeff )
+ {
+ // Covariance is NOT null
+ double v = double( ( c.transpose( ) * ( this->m_InvCov * c ) )[ 0 ][ 0 ] );
+ v /= double( 2 );
- return( S( std::exp( -v ) ) );
+ return( S( std::exp( -v ) ) );
+ }
+ else
+ {
+ // Covariance is null
+ bool equal = true;
+ for( unsigned int d = 0; d < D && equal; ++d )
+ equal &= !( S( 0 ) < S( std::fabs( double( c[ d ][ 0 ] ) ) ) );
+ return( ( equal )? S( 1 ): S( 0 ) );
+
+ } // fi
}
// -------------------------------------------------------------------------
this->m_S1 += s;
this->m_S2 += s * s.transpose( );
- /* DEBUG:
- std::cout
- << sample[ 0 ] << " " << sample[ 1 ] << " " << sample[ 2 ] << std::endl;
- */
-
- /* TODO
- {
- this->m_S1[ i ][ 0 ] += S( sample[ i ] );
- for( unsigned int j = i; j < D; ++j )
- {
- this->m_S2[ i ][ j ] += S( sample[ i ] ) * S( sample[ j ] );
- this->m_S2[ j ][ i ] = this->m_S2[ i ][ j ];
-
- } // rof
-
- } // rof
- */
this->m_Updated = false;
this->Modified( );
}
#include <cpPlugins/Extensions/cpPlugins_Extensions_Export.h>
-/* TODO
- #include <vtkInteractorStyleImage.h>
- #include <vtkLineWidget2.h>
- #include <vtkLineRepresentation.h>
- #include <vtkPlane.h>
- class vtkImageData;
-*/
-
// -------------------------------------------------------------------------
#define cpPlugins_ImageInteractorStyle_ObserverMacro( e ) \
inline unsigned long Add##e##Observer( vtkCommand* observer ) \
#include <cpPlugins/Extensions/Visualization/MPRWithDifferentWindows.h>
+#include <vtkCamera.h>
// -------------------------------------------------------------------------
cpPlugins::Extensions::Visualization::MPRWithDifferentWindows::
this->m_Renderers[ 3 ]
);
+ // Correct cameras positions
+ vtkCamera* zCam = this->m_Renderers[ 2 ]->GetActiveCamera( );
+ zCam->SetViewUp( 0, -1, 0 );
+ zCam->SetPosition( 0, 0, -1 );
+ zCam->SetFocalPoint( 0, 0, 0 );
+
// First rendering
this->ResetCameras( );
this->RenderAll( );