예제 #1
0
/**
 * Example of a test. To be completed.
 *
 */
bool testModifier()
{
  unsigned int nbok = 0;
  unsigned int nb = 0;
  
  trace.beginBlock ( "Testing block ..." );
  
  //scell 2 point
  {
    typedef KhalimskySpaceND<3> K3;
    K3 theKSpace; 
    SCellToPoint<K3> m(theKSpace); 
    K3::SCell s = theKSpace.sPointel( K3::Point(3,3,4) );
    K3::Point aPoint = m.get( s );
    trace.info() << s << aPoint <<std::endl;  
    nbok += ( aPoint == K3::Point(3,3,4) ) ? 1 : 0; 
    nb++;
  }
  //scell 2 midPoint
  {
    typedef KhalimskySpaceND<2> K2;
    K2 theKSpace; 
    SCellToMidPoint<K2> m(theKSpace); 
    K2::SCell s = theKSpace.sCell( K2::Point(0,1) );
    PointVector<K2::dimension,double> aPoint = m.get( s );
    trace.info() << s << aPoint <<std::endl;  
    nbok += ( aPoint == PointVector<K2::dimension,double>(0,0.5) ) ? 1 : 0; 
    nb++;
  }  

    //scell 2 arrow
  {
    typedef KhalimskySpaceND<2> K2;
    K2 theKSpace; 
    SCellToArrow<K2> m(theKSpace); 
    K2::SCell s = theKSpace.sCell( K2::Point(0,1) );
    std::pair<K2::Point, K2::Vector> aArrow = m.get( s );
    trace.info() << s << aArrow.first << aArrow.second <<std::endl;  
    K2::Point p(0,1); 
    K2::Vector v(0,-1); 
    nbok += ( ((aArrow.first == p) && (aArrow.second == v)) ) ? 1 : 0; 
    nb++;
  }  
  
      //scell 2 inner point
  {
    typedef KhalimskySpaceND<2> K2;
    K2 theKSpace; 
    SCellToInnerPoint<K2> m(theKSpace); 
    K2::SCell s = theKSpace.sCell( K2::Point(0,1) );
    K2::Point aPoint = m.get( s );
    trace.info() << s << aPoint <<std::endl;  
    nbok += ( aPoint == K2::Point(-1,0) ) ? 1 : 0; 
    nb++;
  }
  
    //scell 2 outer point
  {
    typedef KhalimskySpaceND<2> K2;
    K2 theKSpace; 
    SCellToOuterPoint<K2> m(theKSpace); 
    K2::SCell s = theKSpace.sCell( K2::Point(0,1) );
    K2::Point aPoint = m.get( s );
    trace.info() << s << aPoint <<std::endl;  
    nbok += ( aPoint == K2::Point(0,0) ) ? 1 : 0; 
    nb++;
  }
  
    //scell 2 incident pixels
  {
    typedef KhalimskySpaceND<2> K2;
    K2 theKSpace; 
    SCellToIncidentPoints<K2> m(theKSpace); 
    K2::SCell s = theKSpace.sCell( K2::Point(0,1) );
    std::pair<K2::Point, K2::Point> aPair = m.get( s );
    trace.info() << s << aPair.first << aPair.second <<std::endl;  
    K2::Point p1(-1,0); 
    K2::Point p2(0,0); 
    nbok += ( ((aPair.first == p1) && (aPair.second == p2)) ) ? 1 : 0; 
    nb++;
  }  
  
   //scell 2 code
  {
    typedef KhalimskySpaceND<2> K2;
    K2 theKSpace; 
    SCellToCode<K2> m(theKSpace); 
    K2::SCell s = theKSpace.sCell( K2::Point(0,1) );
    char aCode = m.get( s );
    trace.info() << s << aCode <<std::endl;  
    nbok += ( aCode == '3' ) ? 1 : 0; 
    nb++;
  }
  
  trace.info() << "(" << nbok << "/" << nb << ") " << std::endl;
  trace.endBlock();
  
  return nbok == nb;
}
예제 #2
0
/**
 * Example of a test. To be completed.
 *
 */
bool testSCellsFunctors()
{
  unsigned int nbok = 0;
  unsigned int nb = 0;
  
  trace.beginBlock ( "Testing block ..." );
  
  //0-scell 2 point
  {
    typedef KhalimskySpaceND<3> K3;
    K3 theKSpace; 
    SCellToPoint<K3> m(theKSpace); 
    K3::SCell s = theKSpace.sPointel( K3::Point(3,3,4) );
    K3::Point aPoint = m( s );
    trace.info() << s << aPoint <<std::endl;  
    nbok += ( aPoint == K3::Point(3,3,4) ) ? 1 : 0; 
    nb++;
  }
  trace.info() << "(" << nbok << "/" << nb << ") " << std::endl;
  //1-scell 2 point
  {
    typedef KhalimskySpaceND<3> K3;
    K3 theKSpace; 
    SCellToPoint<K3> m(theKSpace); 
    K3::SCell s(K3::Point(0,0,0), true); //default point and orientation 
    theKSpace.sSetKCoords( s, K3::Point(5,6,8) );
    K3::Point aPoint = m( s );
    trace.info() << s << aPoint <<std::endl;  
    nbok += ( aPoint == K3::Point(3,3,4) ) ? 1 : 0;
    nb++;
  }
  trace.info() << "(" << nbok << "/" << nb << ") " << std::endl;
  //scell 2 midPoint
  {
    typedef KhalimskySpaceND<2> K2;
    K2 theKSpace; 
    CanonicSCellEmbedder<K2> m(theKSpace);
    K2::SCell s = theKSpace.sCell( K2::Point(0,1) );
    K2::Space::RealPoint aPoint = m( s );
    trace.info() << s << aPoint <<std::endl;  
    nbok += ( aPoint == K2::Space::RealPoint(-0.5,0) ) ? 1 : 0;
    nb++;
  }  
  trace.info() << "(" << nbok << "/" << nb << ") " << std::endl;

    //scell 2 arrow
  {
    typedef KhalimskySpaceND<2> K2;
    K2 theKSpace; 
    SCellToArrow<K2> m(theKSpace); 
    K2::SCell s = theKSpace.sCell( K2::Point(0,1) );
    std::pair<K2::Point, K2::Vector> aArrow = m( s );
    trace.info() << s << aArrow.first << aArrow.second <<std::endl;  
    K2::Point p(0,1); 
    K2::Vector v(0,-1); 
    nbok += ( ((aArrow.first == p) && (aArrow.second == v)) ) ? 1 : 0; 
    nb++;
  }  
  trace.info() << "(" << nbok << "/" << nb << ") " << std::endl;
  
      //scell 2 inner point
  {
    typedef KhalimskySpaceND<2> K2;
    K2 theKSpace; 
    SCellToInnerPoint<K2> m(theKSpace); 
    K2::SCell s = theKSpace.sCell( K2::Point(0,1) );
    K2::Point aPoint = m( s );
    trace.info() << s << aPoint <<std::endl;  
    nbok += ( aPoint == K2::Point(0,0) ) ? 1 : 0; 
    nb++;
  }
  trace.info() << "(" << nbok << "/" << nb << ") " << std::endl;
  
    //scell 2 outer point
  {
    typedef KhalimskySpaceND<2> K2;
    K2 theKSpace; 
    SCellToOuterPoint<K2> m(theKSpace); 
    K2::SCell s = theKSpace.sCell( K2::Point(0,1) );
    K2::Point aPoint = m( s );
    trace.info() << s << aPoint <<std::endl;  
    nbok += ( aPoint == K2::Point(-1,0) ) ? 1 : 0; 
    nb++;
  }
  trace.info() << "(" << nbok << "/" << nb << ") " << std::endl;
  
    //scell 2 incident pixels
  {
    typedef KhalimskySpaceND<2> K2;
    K2 theKSpace; 
    SCellToIncidentPoints<K2> m(theKSpace); 
    K2::SCell s = theKSpace.sCell( K2::Point(0,1) );
    std::pair<K2::Point, K2::Point> aPair = m( s );
    trace.info() << s << aPair.first << aPair.second <<std::endl;  
    K2::Point p1(0,0); 
    K2::Point p2(-1,0); 
    nbok += ( ((aPair.first == p1) && (aPair.second == p2)) ) ? 1 : 0; 
    nb++;
  }  
  trace.info() << "(" << nbok << "/" << nb << ") " << std::endl;
  
   //scell 2 code
  {
    typedef KhalimskySpaceND<2> K2;
    K2 theKSpace; 
    SCellToCode<K2> m(theKSpace); 
    K2::SCell s = theKSpace.sCell( K2::Point(0,1) );
    char aCode = m( s );
    trace.info() << s << aCode <<std::endl;  
    nbok += ( aCode == '3' ) ? 1 : 0; 
    nb++;
  }
  
  trace.info() << "(" << nbok << "/" << nb << ") " << std::endl;
  trace.endBlock();
  
  return nbok == nb;
}