]> Creatis software - cpPlugins.git/blob - lib/cpExtensions/DataStructures/InfinitePlaneSpatialObject.hxx
...
[cpPlugins.git] / lib / cpExtensions / DataStructures / InfinitePlaneSpatialObject.hxx
1 #ifndef __CPEXTENSIONS__DATASTRUCTURES__INFINITEPLANESPATIALOBJECT__HXX__
2 #define __CPEXTENSIONS__DATASTRUCTURES__INFINITEPLANESPATIALOBJECT__HXX__
3
4 // -------------------------------------------------------------------------
5 template< unsigned int D >
6 template< class P >
7 void cpExtensions::DataStructures::InfinitePlaneSpatialObject< D >::
8 SetCenter( const P& p )
9 {
10   for( unsigned int d = 0; d < D; ++d )
11     this->m_Center[ d ] = ScalarType( p[ d ] );
12   this->Modified( );
13 }
14
15 // -------------------------------------------------------------------------
16 template< unsigned int D >
17 template< class N >
18 void cpExtensions::DataStructures::InfinitePlaneSpatialObject< D >::
19 SetNormal( const N& n )
20 {
21   for( unsigned int d = 0; d < D; ++d )
22     this->m_Normal[ d ] = ScalarType( n[ d ] );
23   ScalarType nn = this->m_Normal.GetNorm( );
24   if( nn > ScalarType( 0 ) )
25     this->m_Normal /= nn;
26   this->Modified( );
27 }
28
29 // -------------------------------------------------------------------------
30 template< unsigned int D >
31 bool cpExtensions::DataStructures::InfinitePlaneSpatialObject< D >::
32 ValueAt(
33   const PointType& point, double& value, unsigned int depth, char* name
34   ) const
35 {
36   value = this->m_Normal * ( point - this->m_Center );
37   return( value >= double( 0 ) );
38 }
39
40 // -------------------------------------------------------------------------
41 template< unsigned int D >
42 bool cpExtensions::DataStructures::InfinitePlaneSpatialObject< D >::
43 IsEvaluableAt(
44   const PointType& point, unsigned int depth, char* name
45   ) const
46 {
47   double value;
48   return( this->ValueAt( point, value, depth, name ) );
49 }
50
51 // -------------------------------------------------------------------------
52 template< unsigned int D >
53 bool cpExtensions::DataStructures::InfinitePlaneSpatialObject< D >::
54 IsInside(
55   const PointType& point, unsigned int depth, char* name
56   ) const
57 {
58   double value;
59   return( this->ValueAt( point, value, depth, name ) );
60 }
61
62 // -------------------------------------------------------------------------
63 template< unsigned int D >
64 bool cpExtensions::DataStructures::InfinitePlaneSpatialObject< D >::
65 IsInside( const PointType& point ) const
66 {
67   double value;
68   return( this->ValueAt( point, value, 0, NULL ) );
69 }
70
71 // -------------------------------------------------------------------------
72 template< unsigned int D >
73 bool cpExtensions::DataStructures::InfinitePlaneSpatialObject< D >::
74 ComputeLocalBoundingBox( ) const
75 {
76   return( false );
77 }
78
79 // -------------------------------------------------------------------------
80 template< unsigned int D >
81 cpExtensions::DataStructures::InfinitePlaneSpatialObject< D >::
82 InfinitePlaneSpatialObject( )
83   : Superclass( )
84 {
85   this->m_Center.Fill( ScalarType( 0 ) );
86   this->m_Normal.Fill( ScalarType( 0 ) );
87   this->m_Normal[ 0 ] = ScalarType( 1 );
88 }
89
90 // -------------------------------------------------------------------------
91 template< unsigned int D >
92 cpExtensions::DataStructures::InfinitePlaneSpatialObject< D >::
93 ~InfinitePlaneSpatialObject( )
94 {
95 }
96
97 // -------------------------------------------------------------------------
98 template< unsigned int D >
99 void cpExtensions::DataStructures::InfinitePlaneSpatialObject< D >::
100 PrintSelf( std::ostream& os, itk::Indent indent ) const
101 {
102   this->Superclass::PrintSelf( os, indent );
103   os << indent << "Center: " << this->m_Center << std::endl;
104   os << indent << "Normal: " << this->m_Normal << std::endl;
105 }
106
107 #endif // __CPEXTENSIONS__DATASTRUCTURES__INFINITEPLANESPATIALOBJECT__HXX__
108
109 // eof - $RCSfile$