17 #ifndef __itkArrowSpatialObject_txx
18 #define __itkArrowSpatialObject_txx
27 template<
unsigned int TDimension >
31 this->SetDimension(TDimension);
32 this->SetTypeName (
"ArrowSpatialObject");
33 this->GetProperty()->SetRed(1);
34 this->GetProperty()->SetGreen(0);
35 this->GetProperty()->SetBlue(0);
36 this->GetProperty()->SetAlpha(1);
43 this->ComputeBoundingBox();
47 template<
unsigned int TDimension >
55 template<
unsigned int TDimension >
61 double spacing[TDimension];
62 spacing[0] = m_Length;
64 for(
unsigned int i=1;i<TDimension;i++)
68 this->SetSpacing(spacing);
74 template<
unsigned int TDimension >
79 itkDebugMacro(
"Computing Rectangle bounding box" );
81 if( this->GetBoundingBoxChildrenName().empty()
82 || strstr(
typeid(
Self).name(), this->GetBoundingBoxChildrenName().c_str()) )
86 for(
unsigned int i=0; i<TDimension;i++)
88 pnt2[i]=pnt[i]+m_Length*m_Direction[i];
91 pnt = this->GetIndexToWorldTransform()->TransformPoint(pnt);
92 pnt2 = this->GetIndexToWorldTransform()->TransformPoint(pnt2);
94 const_cast<typename Superclass::BoundingBoxType*
>(
95 this->GetBounds())->SetMinimum(pnt);
96 const_cast<typename Superclass::BoundingBoxType*
>(
97 this->GetBounds())->SetMaximum(pnt2);
103 template<
unsigned int TDimension >
108 itkDebugMacro(
"Checking the point [" << point <<
"] is on the Line" );
117 else if(strstr(
typeid(
Self).name(), name))
125 return Superclass::IsInside(point, depth, name);
132 template<
unsigned int TDimension >
137 if( !this->SetInternalInverseTransformToWorldToIndexTransform() )
143 this->GetInternalInverseTransform()->TransformPoint(point);
145 this->ComputeLocalBoundingBox();
147 if( this->GetBounds()->IsInside(transformedPoint) )
152 for(
unsigned int i=0; i<TDimension;i++)
154 pnt2[i]=pnt[i]+m_Length*m_Direction[i];
174 template<
unsigned int TDimension >
180 for(
unsigned int i=0;i<TDimension;i++)
182 offset[i] = m_Position[i];
184 this->GetObjectToParentTransform()->SetOffset(offset);
192 m_Length = vcl_sqrt(m_Length);
200 m_Direction.Normalize();
206 EulerTransformType::Pointer euler = EulerTransformType::New();
212 const double PI = 4.0 * vcl_atan(1.0 );
215 if(m_Direction[0] == 0.0)
217 if(m_Direction[1]>0.0)
221 else if(m_Direction[1]<0.0)
228 if(m_Direction[0]<0.0)
230 anglez = PI+vcl_atan(m_Direction[1]/m_Direction[0]);
234 anglez = vcl_atan(m_Direction[1]/m_Direction[0]);
237 angley = -asin(m_Direction[2]);
238 euler->SetRotation(0,angley,anglez);
239 this->GetObjectToParentTransform()->SetMatrix(euler->GetRotationMatrix());
247 template<
unsigned int TDimension >
252 os << indent <<
"ArrowSpatialObject(" <<
this <<
")" << std::endl;
253 Superclass::PrintSelf( os, indent );
254 os << indent <<
"Position = " << m_Position << std::endl;
255 os << indent <<
"Direction = " << m_Direction << std::endl;
256 os << indent <<
"Length = " << m_Length << std::endl;
261 #endif // end __itkArrowSpatialObject_txx