Esempio n. 1
0
/**
 * Example of a test. To be completed.
 *
 */
bool testIVViewer( int argc, char** argv )
{
  unsigned int nbok = 0;
  unsigned int nb = 0;
  
  trace.beginBlock ( "Testing block ..." );
  string s = "testIVViewer";
  for ( int i = 1; i < argc; ++i )
    s += " " + string( argv[ i ] );

  IVViewer ivv( argc, argv );
  //ivv.show();
  // Setting camera
  ivv.setCamera( 30.0, 25.0 );
  // Gives hand to Inventor
  ivv.setTitle( s.c_str() );

  DGtalInventor<Space> inventor;
  typedef DGtalInventor<Space>::Color Color;
  inventor.setDiffuseColor( Color( 1.0, 0.0, 0.0 ) );
  inventor.drawPoint( Point( 1, 0, 0 ) );
  inventor.setDiffuseColor( Color( 0.0, 1.0, 0.0 ) );
  inventor.drawPoint( Point( 0, 1, 0 ) );
  inventor.setDiffuseColor( Color( 0.0, 0.0, 1.0 ) );
  inventor.drawPoint( Point( 0, 0, 1 ) );

  Point p1( -4, -4, -4 );
  Point p2( 17, 17, 17 );
  Domain domain( p1, p2 );
  DigitalSet shape_set( domain );
  Shapes<Domain>::addNorm1Ball( shape_set, Point( 3, 13, 3 ), 7 );
  Shapes<Domain>::addNorm1Ball( shape_set, Point( 14, 5, 2 ), 12 );
  inventor.setDiffuseColor( Color( 0.7, 0.7, 0.7 ) );
  for ( DigitalSet::ConstIterator it = shape_set.begin(); 
	it != shape_set.end();
	++it )
    {
      const Point & p = *it;
      if ( ( p[ 0 ] < 0 ) || ( p[ 1 ] < 0 ) ||( p[ 2 ] < 0 ) )
	inventor.setDiffuseColor( Color( 0.7, 0.7, 1.0 ) );
      else
	inventor.setDiffuseColor( Color( 1.0, 1.0, 0.7 ) );
      inventor.drawPoint( *it );
    }
  inventor.generate( ivv.root() );
  // ivv->addChild( node );
  ivv.show();
  nbok += true ? 1 : 0; 
  nb++;
  trace.info() << "(" << nbok << "/" << nb << ") "
	       << "true == true" << std::endl;
  trace.endBlock();
  
  return nbok == nb;
}
Esempio n. 2
0
void addAxis( DGtalInventor<Space> & inventor, 
	      const Point & low,
	      const Point & up,
	      Dimension k, 
	      const LibBoard::Color & c1,
	      const LibBoard::Color & c2 )
{
  typedef DGtalInventor<Space>::Color Color;
  // @todo GradientColorMap seems to have a bug
  GradientColorMap<int> cmap_grad( 0, up[ k ] - low[ k ] );
  cmap_grad.clearColors();
  cmap_grad.addColor( c1 );
  cmap_grad.addColor( c2 );
  Point p( low );
  for ( Point::Component x = low[ k ]; x <= up[ k ]; ++x )
    {
      p[ k ] = x;
      LibBoard::Color c( cmap_grad( x - low[ k ] ) );
      inventor.setDiffuseColor( Color( c.red(), c.green(), c.blue() ) );
      inventor.drawPoint( p );
    }
}
Esempio n. 3
0
void addBounds( DGtalInventor<Space> & inventor, 
		const Point & low, 
		const Point & up )
{
  typedef DGtalInventor<Space>::Color Color;
  Point p( low );
  for ( Dimension i = 0; i < 8; ++i )
    {
      Color c;
      for ( Dimension j = 0; j < 3; ++j )
	{
	  p[ j ] = ( i & ( 1 << j ) ) ? up[ j ] : low[ j ];
	  c[ j ] = ( i & ( 1 << j ) ) ? 1.0 : 0.1 ;
	}
      inventor.setDiffuseColor( c ); //Color( 0.1, 0.1, 0.1 ) );
      inventor.drawPoint( p );
    }
  // addAxis( inventor, low, up, 0, 
  // 	   LibBoard::Color::Black, LibBoard::Color::Blue );
  // addAxis( inventor, low, up, 1, 
  //  	   LibBoard::Color::Black, LibBoard::Color::Green );
  // addAxis( inventor, low, up, 2, 
  //  	   LibBoard::Color::Black, LibBoard::Color::Red );
}