本文整理汇总了C++中Viewer3D::addTriangle方法的典型用法代码示例。如果您正苦于以下问题:C++ Viewer3D::addTriangle方法的具体用法?C++ Viewer3D::addTriangle怎么用?C++ Viewer3D::addTriangle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Viewer3D
的用法示例。
在下文中一共展示了Viewer3D::addTriangle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
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);
}
}