int main(int argc, char **argv) { //Reading the image try { typedef ImageContainerBySTLVector< Z2i::Domain, unsigned char> Image; Image image = GenericReader<Image>::import("church.pgm"); //You can access to image domain and values trace.info() << image.domain()<<std::endl; trace.info() << "Value at (5,5)="<< (int)image( Z2i::Point(5,5) )<<std::endl; //Creating the viewer // press 'h' for help QApplication application(argc,argv); Viewer3D<> viewer; viewer.setWindowTitle("simpleViewer"); viewer.show(); //Display 2 voxels viewer << Z3i::Point(2,3,5) ; viewer << Z3i::Point(3,2,1) ; //Display a triangle Z3i::RealPoint p1(1.0,0.0,0.0), p2(0.0,1.0,0.0), p3(0.0,0.0,1.0); viewer.addTriangle(p1,p2,p3); //Display a green triangle (with shift) Z3i::RealPoint shift(3.0,0.0,0.0); viewer<< CustomColors3D(Color(0, 250,0),Color(0, 250,0)); viewer.addTriangle(p1+shift, p2+shift, p3+shift); //A triangle whose color is given by a colormap on scalar function // (see colormaps http://libdgtal.org/doc/nightly/moduleIO.html) // scalar are 'unsigned char' type here (and we want the 128th color) unsigned char maxscalar=255; unsigned char minscalar=0; HueShadeColorMap<unsigned> huemap(minscalar,maxscalar); Z3i::RealPoint shift2(5.0,0.0,0.0); viewer<< CustomColors3D(huemap(128), huemap(128)); viewer.addTriangle(p1+shift2, p2+shift2, p3+shift2); //Important: we need to update the display viewer << Viewer3D<>::updateDisplay; //infinite loop (ESC to close the viewer) bool res = application.exec(); return res; } catch(const std::exception& ex) { trace.info()<< "Error when reading the file "<< ex.what()<< std::endl; exit(2); } }