Hi Alex,

In the AddFace method of itk::QuadEdgeMesh, there is a preprocessor condition (#ifndef NDEBUG, see code below). Is it correct to make these tests only when NDEBUG is undefined? Is it the other way around? or should it be tested all the time?

Thanks,
Arnaud

---

template< typename TPixel, unsigned int VDimension, typename TTraits >
typename QuadEdgeMesh< TPixel, VDimension, TTraits >::QEPrimal *
QuadEdgeMesh< TPixel, VDimension, TTraits >
::AddFace(const PointIdList & points)
{
#ifndef NDEBUG
  // Check that there are no duplicate points
  for ( size_t i = 0; i < points.size(); i++ )
    {
    typename PointIdList::const_iterator itr = points.begin();
    typename PointIdList::const_iterator end = points.end();
    PointIdentifier count = NumericTraits< PointIdentifier >::Zero;
    const PointIdentifier pointId = points[i];
    while ( itr != end )
      {
      if ( *itr == pointId )
        {
        ++count;
        }
      ++itr;
      }
    if ( count != 1 )
      {
      itkDebugMacro("Point " << i << " is duplicated");
      return ( (QEPrimal *)NULL );
      }
    }

  // Check that all points exist
  for ( size_t i = 0; i < points.size(); i++ )
    {
    if ( !this->GetPoints()->IndexExists(points[i]) )
      {
      itkDebugMacro("Point " << i << " is missing in the mesh");
      return (QEPrimal *)NULL;
      }
    }
#endif

  // Check if existing edges have no face on the left.
  for ( size_t i = 0; i < points.size(); i++ )
    {
    PointIdentifier pid0 = points[i];
    PointIdentifier pid1 = points[( i + 1 ) % points.size()];

    QEPrimal *edge = this->FindEdge(pid0, pid1);

    if ( edge )
      {
      if ( edge->IsLeftSet() )
        {
        itkDebugMacro("Edge [" << i << " " << ( ( i + 1 ) % points.size() )
<< " has a left face.");
        return (QEPrimal *)NULL;
        }
      }
    }

  return AddFaceWithSecurePointList(points);
}
_______________________________________________
Powered by 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://kitware.com/products/protraining.php

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-developers

Reply via email to