[Insight-users] Elliptic cylinder spatial object

Arunachalam Kana Kana.Arunachalam at fh-wels.at
Fri Jul 1 09:28:19 EDT 2011


Hi robert,
Thank you for your idea. I have start to work on it. I have identified the place where the change has to be done. I have done changes in bounding box calculation (shown below) but i do not know what changes have to be done in IsInside function(i cannot understand the function).
Help needed here.

Change made in bounding box calculation:
/** Compute the bounds of the EllipticCylinder */
bool EllipticCylinderSpatialObject
::ComputeLocalBoundingBox() const
{
  itkDebugMacro( "Computing tube bounding box" );

  if( this->GetBoundingBoxChildrenName().empty()
    || strstr(typeid(Self).name(), this->GetBoundingBoxChildrenName().c_str()) )
    {
    // First point
    //m_EllipticRadius is fixed array type which hold majoraxis radius, minoraxis radius, and height.
   PointType ptMin,ptMax;
    ptMin[0] = -m_EllipticRadius[0];
    ptMin[1] = -m_EllipticRadius[1];
    ptMin[2] = -m_EllipticRadius[2]/2;
    ptMin = this->GetIndexToWorldTransform()->TransformPoint(ptMin);
    ptMax[0] = +m_EllipticRadius[0];
    ptMax[1] = +m_EllipticRadius[1];
    ptMax[2] = -m_EllipticRadius[2]/2;
    ptMax = this->GetIndexToWorldTransform()->TransformPoint(ptMax);
    const_cast<BoundingBoxType *>(this->GetBounds())->SetMinimum(ptMin);
   const_cast<BoundingBoxType *>(this->GetBounds())->SetMaximum(ptMax);
    ptMin[0] = -m_EllipticRadius[0];
    ptMin[1] = -m_EllipticRadius[1];
    ptMin[2] = +m_EllipticRadius[2]/2;
    ptMin = this->GetIndexToWorldTransform()->TransformPoint(ptMin);
    ptMax[0] = +m_EllipticRadius[0];
    ptMax[1] = +m_EllipticRadius[1];
    ptMax[2] = +m_EllipticRadius[2]/2;
    ptMax = this->GetIndexToWorldTransform()->TransformPoint(ptMax);
    const_cast<BoundingBoxType *>(this->GetBounds())->ConsiderPoint(ptMin);
    const_cast<BoundingBoxType *>(this->GetBounds())->ConsiderPoint(ptMax);
    }
  return true;
}

/** Test whether a point is inside or outside the object
*  For computational speed purposes, it is faster if the method does not
*  check the name of the class and the current depth */
bool EllipticCylinderSpatialObject
::IsInside( const PointType & point) const
{
  if( !this->SetInternalInverseTransformToWorldToIndexTransform() )
    {
    return false;
    }

  PointType transformedPoint =    this->GetInternalInverseTransform()->TransformPoint(point);

  this->ComputeLocalBoundingBox();
  if( this->GetBounds()->IsInside(point) )
    {
    // Check if the point is on the normal plane
    PointType a,b;
    a[0] = 0;
    a[1] = 0;
    a[2] = -m_Height/2;
    b[0] = 0;
    b[1] = 0;
    b[2] = m_Height/2;
    double A = 0;
    double B = 0;
    for(unsigned int i = 0;i<3;i++)
      {
      A += (b[i]-a[i])*(transformedPoint[i]-a[i]);
      B += (b[i]-a[i])*(b[i]-a[i]);
      }
    double lambda = A/B;
    if( ( (lambda>-(m_Radius/(2*vcl_sqrt(B)))) && (lambda<0)) || ((lambda <= 1.0) && (lambda >= 0.0))     )
      {
      PointType p;
      for(unsigned int i = 0;i<3;i++)
        {
        p[i] = a[i]+lambda*(b[i]-a[i]);
        }
      double tempSquareDist=transformedPoint.EuclideanDistanceTo(p);
      double R =  m_Radius;
      if(tempSquareDist <= R)
        {
        return true;
        }
      }
    }
  return false;
}

Thank you,
regards,
kana

From: robert tamburo [mailto:robert.tamburo at gmail.com]
Sent: 01 July 2011 15:13
To: Arunachalam Kana
Cc: insight-users at itk.org
Subject: Re: [Insight-users] Elliptic cylinder spatial object

Write a new spatial object using the cylinder spatial object as a starting point.
On Fri, Jul 1, 2011 at 7:45 AM, Arunachalam Kana <Kana.Arunachalam at fh-wels.at<mailto:Kana.Arunachalam at fh-wels.at>> wrote:
Dear Itk users,
I need some help in creating a elliptic cylinder spatial object. Any ideas ???
Thanks in advance.
Regards,
Kana Arunachalam Kannappan
Research Associate
FH OÖ Forschungs & Entwicklungs GmbH
Stelzhamer Strasse 23,
4600 Wels,
Austria.
Phone: +43 (0)7242 72811 -4420<tel:%2B43%20%280%297242%2072811%20-4420>
kana.arunachalam at fh-wels.at<mailto:kana.arunachalam at fh-wels.at>
www.fh-ooe.at<http://www.fh-ooe.at>; www.3dct.at<http://www.3dct.at>


_____________________________________
Powered by www.kitware.com<http://www.kitware.com>

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.html

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.itk.org/mailman/listinfo/insight-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110701/98073a19/attachment.htm>


More information about the Insight-users mailing list