本文整理汇总了C++中Viewer3D::addLine方法的典型用法代码示例。如果您正苦于以下问题:C++ Viewer3D::addLine方法的具体用法?C++ Viewer3D::addLine怎么用?C++ Viewer3D::addLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Viewer3D
的用法示例。
在下文中一共展示了Viewer3D::addLine方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: displayDSS2d
void displayDSS2d( Viewer3D<space, kspace> & viewer,
const KSpace & ks, const StandardDSS6Computer & dss3d,
const DGtal::Color & color2d )
{
typedef typename StandardDSS6Computer::ConstIterator ConstIterator3d;
typedef typename StandardDSS6Computer::ArithmeticalDSSComputer2d ArithmeticalDSSComputer2d;
typedef typename ArithmeticalDSSComputer2d::ConstIterator ConstIterator2d;
typedef typename ArithmeticalDSSComputer2d::Point Point2d;
typedef typename KSpace::Cell Cell;
typedef typename KSpace::Point Point3d;
typedef DGtal::PointVector<2,double> PointD2d;
typedef typename Display3D<>::BallD3D PointD3D;
Point3d b = ks.lowerBound();
for ( DGtal::Dimension i = 0; i < 3; ++i )
{
const typename ArithmeticalDSSComputer2d::Primitive & dss2d
= dss3d.arithmeticalDSS2d( i ).primitive();
// draw 2D bounding boxes for each arithmetical dss 2D.
std::vector<PointD2d> pts2d;
pts2d.push_back( dss2d.project(dss2d.back(), dss2d.Uf()) );
pts2d.push_back( dss2d.project(dss2d.back(), dss2d.Lf()) );
pts2d.push_back( dss2d.project(dss2d.front(), dss2d.Lf()) );
pts2d.push_back( dss2d.project(dss2d.front(), dss2d.Uf()) );
std::vector<PointD3D> bb;
PointD3D p3;
for ( unsigned int j = 0; j < pts2d.size(); ++j )
{
switch (i) {
case 0: p3.center[0] = (double) b[ i ]-0.5; p3.center[1] = pts2d[ j ][ 0 ]; p3.center[2] = pts2d[ j ][ 1 ]; break;
case 1: p3.center[0] = pts2d[ j ][ 0 ]; p3.center[1] = (double) b[ i ]-0.5; p3.center[2] = pts2d[ j ][ 1 ]; break;
case 2: p3.center[0] = pts2d[ j ][ 0 ]; p3.center[1] = pts2d[ j ][ 1 ]; p3.center[2] = (double) b[ i ]-0.5; break;
}
bb.push_back( p3 );
}
for ( unsigned int j = 0; j < pts2d.size(); ++j ){
viewer.setLineColor(color2d);
viewer.addLine( DGtal::Z3i::RealPoint(bb[ j ].center[0], bb[ j ].center[1], bb[ j ].center[2]),
DGtal::Z3i::RealPoint(bb[ (j+1)%4 ].center[0], bb[ (j+1)%4 ].center[1], bb[ (j+1)%4 ].center[2]),
MS3D_LINESIZE );
}
} // for ( DGtal::Dimension i = 0; i < 3; ++i )
}
示例2: displayDSS3dTangent
void displayDSS3dTangent( Viewer3D<space, kspace> & viewer,
const KSpace & ks, const StandardDSS6Computer & dss3d,
const DGtal::Color & color3d )
{
typedef typename StandardDSS6Computer::Point3d Point;
typedef typename StandardDSS6Computer::PointD3d PointD3d;
typedef typename Display3D<>::BallD3D PointD3D;
Point directionZ3;
PointD3d P1, P2, direction, intercept, thickness;
dss3d.getParameters( directionZ3, intercept, thickness );
assign( direction, directionZ3 );
direction /= direction.norm();
assign( P1, *dss3d.begin() );
assign( P2, *(dss3d.end()-1) );
double t1 = (P1 - intercept).dot( direction );
double t2 = (P2 - intercept).dot( direction );
PointD3d Q1 = intercept + t1 * direction;
PointD3d Q2 = intercept + t2 * direction;
viewer.setLineColor(color3d);
viewer.addLine( DGtal::Z3i::RealPoint(Q1[ 0 ]-0.5, Q1[ 1 ]-0.5, Q1[ 2 ]-0.5),
DGtal::Z3i::RealPoint(Q2[ 0 ]-0.5, Q2[ 1 ]-0.5, Q2[ 2 ]-0.5),
MS3D_LINESIZE );
}
示例3: main
//.........这里部分代码省略.........
float m = 0.0f;
for ( typename Domain::ConstIterator it = d2.domain().begin(),
itE = d2.domain().end(); it != itE; ++it )
{
Point p = *it;
float v = sqrt( d2( p ) );
m = std::max( v, m );
}
// GradientColorMap<float> cmap_grad( 0, m );
// cmap_grad.addColor( Color( 255, 255, 255 ) );
// cmap_grad.addColor( Color( 255, 255, 0 ) );
// cmap_grad.addColor( Color( 255, 0, 0 ) );
// cmap_grad.addColor( Color( 0, 255, 0 ) );
// cmap_grad.addColor( Color( 0, 0, 255 ) );
// cmap_grad.addColor( Color( 0, 0, 0 ) );
// QApplication application(argc,argv);
// Viewer3D<> viewer;
// viewer.show();
// for ( typename Domain::ConstIterator it = d2.domain().begin(),
// itE = d2.domain().end(); it != itE; ++it )
// {
// Point p = *it;
// float v = sqrt( d2( p ) );
// v = std::min( (float)m, std::max( v, 0.0f ) );
// viewer << CustomColors3D(Color(cmap_grad(v).red(), cmap_grad(v).green(), cmap_grad(v).blue(), 120), Color(cmap_grad(v).red(), cmap_grad(v).green(), cmap_grad(v).blue(),120) )
// << p;
// RealVector grad = delta.projection( p );
// viewer.addLine( p, p+grad );
// }
// std::cout << endl;
// viewer << Viewer3D<>::updateDisplay;
// application.exec();
trace.beginBlock( "Computing delta-VCM." );
typedef DeltaVCM< Distance > DVCM;
typedef DVCM::Matrix Matrix;
DVCM dvcm( delta, R, r );
trace.endBlock();
typedef EigenDecomposition<3,float> LinearAlgebraTool;
typedef functors::HatPointFunction<Point,float> KernelFunction;
KernelFunction chi( 1.0, r );
// Flat zones are metallic blue, slightly curved zones are white,
// more curved zones are yellow till red.
double size = 1.0;
GradientColorMap<double> colormap( 0.0, T2 );
colormap.addColor( Color( 128, 128, 255 ) );
colormap.addColor( Color( 255, 255, 255 ) );
colormap.addColor( Color( 255, 255, 0 ) );
colormap.addColor( Color( 255, 0, 0 ) );
Matrix vcm_r, evec, null;
typedef PointVector<3,float> RealVector3f;
RealVector3f eval;
Viewer3D<> viewer;
viewer.show();
for ( Domain::ConstIterator it = dvcm.domain().begin(), itE = dvcm.domain().end();
it != itE; ++it )
{
// Compute VCM and diagonalize it.
Point p = *it;
vcm_r = dvcm.measure( chi, p );
if ( vcm_r == null ) continue;
LinearAlgebraTool::getEigenDecomposition( vcm_r, evec, eval );
//double feature = eval[ 0 ] / ( eval[ 0 ] + eval[ 1 ] );
eval[ 0 ] = std::max( eval[ 0 ], 0.00001f );
float tubular = ( eval[ 2 ] <= 0.00001f ) // (R*R/4.0) )
? 0
: ( ( eval[ 1 ] + eval[ 2 ] ) / ( eval[ 0 ] + eval[ 1 ] + eval[ 2 ] ) );
float bound = T1;
float tubular2 = tubular * (eval[ 0 ] + eval[ 1 ] + eval[ 2 ] ) / (R*R*r*r*3.14f/12.0f);
float display = tubular2 <= bound ? 0.0f : ( tubular2 - bound ) / (1.0f - bound);
//: eval[ 1 ] / ( 1.0 + eval[ 0 ] ) / ( 1.0 + delta( p )*delta( p ) );
//: eval[ 1 ] * eval[ 1 ] / ( 1.0 + eval[ 0 ] ) / ( 1.0 + delta( p ) );
if (display > 0.01f)
trace.info() << "l0=" << eval[ 0 ] << " l1=" << eval[ 1 ]
<< " tub=" << tubular
<< " tub2=" << tubular2
<< " disp=" << display << std::endl;
if (display > 0.5f*T2 )
{
viewer << CustomColors3D( Color::Black,
colormap( display > T2 ? T2 : display ) )
<< p;
RealVector normal = evec.column( 0 );
RealPoint rp( p[ 0 ], p[ 1 ] );
viewer.addLine( rp - size*normal, rp + size*normal );
}
}
viewer << Viewer3D<>::updateDisplay;
application.exec();
return 0;
}
示例4: main
int main( int argc, char** argv )
{
using namespace DGtal;
using namespace DGtal::Z3i;
typedef ImageContainerBySTLVector<Domain,unsigned char> GrayLevelImage3D;
typedef ImageContainerBySTLVector<Domain,float> FloatImage3D;
typedef DistanceToMeasure<FloatImage3D> Distance;
if ( argc <= 3 ) return 1;
GrayLevelImage3D img = GenericReader<GrayLevelImage3D>::import( argv[ 1 ] );
double mass = atof( argv[ 2 ] );
double rmax = atof( argv[ 3 ] );
FloatImage3D fimg( img.domain() );
FloatImage3D::Iterator outIt = fimg.begin();
for ( GrayLevelImage3D::ConstIterator it = img.begin(), itE = img.end();
it != itE; ++it )
{
float v = ((float)*it) / 255.0;
*outIt++ = v;
}
trace.beginBlock( "Computing delta-distance." );
Distance delta( mass, fimg, rmax );
const FloatImage3D& d2 = delta.myDistance2;
trace.endBlock();
float m = 0.0f;
for ( typename Domain::ConstIterator it = d2.domain().begin(),
itE = d2.domain().end(); it != itE; ++it )
{
Point p = *it;
float v = sqrt( d2( p ) );
m = std::max( v, m );
}
GradientColorMap<float> cmap_grad( 0, m );
cmap_grad.addColor( Color( 255, 255, 255 ) );
cmap_grad.addColor( Color( 255, 255, 0 ) );
cmap_grad.addColor( Color( 255, 0, 0 ) );
cmap_grad.addColor( Color( 0, 255, 0 ) );
cmap_grad.addColor( Color( 0, 0, 255 ) );
cmap_grad.addColor( Color( 0, 0, 0 ) );
QApplication application(argc,argv);
Viewer3D<> viewer;
viewer.show();
//board << SetMode( d2.domain().className(), "Paving" );
for ( typename Domain::ConstIterator it = d2.domain().begin(),
itE = d2.domain().end(); it != itE; ++it )
{
Point p = *it;
float v = sqrt( d2( p ) );
v = std::min( (float)m, std::max( v, 0.0f ) );
viewer << CustomColors3D(Color(cmap_grad(v).red(), cmap_grad(v).green(), cmap_grad(v).blue(), 120), Color(cmap_grad(v).red(), cmap_grad(v).green(), cmap_grad(v).blue(),120) )
<< p;
RealVector grad = delta.projection( p );
// / ( 1.1 - ( (double)img( *it ) ) / 255.0 ) ;
viewer.addLine( p, p+grad );
}
std::cout << endl;
viewer << Viewer3D<>::updateDisplay;
application.exec();
return 0;
}
示例5: main
//.........这里部分代码省略.........
}
if(vm.count("customColorSDP")) {
std::vector<unsigned int > vectCol = vm["customColorSDP"].as<std::vector<unsigned int> >();
if(vectCol.size()!=4) {
trace.error() << "colors specification should contain R,G,B and Alpha values"<< std::endl;
}
sdpColorR = vectCol[0];
sdpColorG = vectCol[1];
sdpColorB = vectCol[2];
sdpColorA = vectCol[3];
}
QApplication application(argc,argv);
Viewer3D<> viewer;
std::stringstream title;
title << "Simple Mesh Viewer: " << inputFilenameVect[0];
viewer.setWindowTitle(title.str().c_str());
viewer.show();
viewer.myGLLineMinWidth = lineWidth;
viewer.setGLScale(sx, sy, sz);
bool invertNormal= vm.count("invertNormal");
double ballRadius = vm["SDPradius"].as<double>();
trace.info() << "Importing mesh... ";
std::vector<Mesh<DGtal::Z3i::RealPoint> > vectMesh;
for(unsigned int i = 0; i< inputFilenameVect.size(); i++) {
Mesh<DGtal::Z3i::RealPoint> aMesh(!vm.count("customColorMesh"));
aMesh << inputFilenameVect[i];
vectMesh.push_back(aMesh);
}
bool import = vectMesh.size()==inputFilenameVect.size();
if(!import) {
trace.info() << "File import failed. " << std::endl;
return 0;
}
trace.info() << "[done]. "<< std::endl;
if(vm.count("displaySDP")) {
std::string filenameSDP = vm["displaySDP"].as<std::string>();
vector<Z3i::RealPoint> vectPoints;
vectPoints = PointListReader<Z3i::RealPoint>::getPointsFromFile(filenameSDP);
viewer << CustomColors3D(Color(sdpColorR, sdpColorG, sdpColorB, sdpColorA),
Color(sdpColorR, sdpColorG, sdpColorB, sdpColorA));
for(unsigned int i=0; i< vectPoints.size(); i++) {
viewer.addBall(vectPoints.at(i), ballRadius);
}
}
if(invertNormal) {
for(unsigned int i=0; i<vectMesh.size(); i++) {
vectMesh[i].invertVertexFaceOrder();
}
}
viewer << CustomColors3D(Color(meshColorRLine, meshColorGLine, meshColorBLine, meshColorALine),
Color(meshColorR, meshColorG, meshColorB, meshColorA));
for(unsigned int i=0; i<vectMesh.size(); i++) {
viewer << vectMesh[i];
}
if(vm.count("drawVertex")) {
for(unsigned int i=0; i<vectMesh.size(); i++) {
for( Mesh<DGtal::Z3i::RealPoint>::VertexStorage::const_iterator it = vectMesh[i].vertexBegin();
it!=vectMesh[i].vertexEnd(); ++it) {
DGtal::Z3i::Point pt;
pt[0]=(*it)[0];
pt[1]=(*it)[1];
pt[2]=(*it)[2];
viewer << pt;
}
}
}
if (displayVectorField) {
std::vector<unsigned int > vectFieldIndices1 = {vectFieldIndices[0],vectFieldIndices[1], vectFieldIndices[2]};
std::vector<unsigned int > vectFieldIndices2 = {vectFieldIndices[3],vectFieldIndices[4], vectFieldIndices[5]};
std::vector<DGtal::Z3i::RealPoint> vectPt1 = PointListReader<DGtal::Z3i::RealPoint>::getPointsFromFile(vm["displayVectorField"].as<std::string>(), vectFieldIndices1);
std::vector<DGtal::Z3i::RealPoint> vectPt2 = PointListReader<DGtal::Z3i::RealPoint>::getPointsFromFile(vm["displayVectorField"].as<std::string>(), vectFieldIndices2);
viewer.createNewLineList();
for (unsigned int i = 0; i < vectPt1.size(); i++) {
viewer.setLineColor(vFieldLineColor);
viewer.addLine(vectPt1[i], vectPt2[i]);
}
}
viewer << Viewer3D<>::updateDisplay;
return application.exec();
}
示例6: displayAxes
void displayAxes( Viewer3D<space, kspace> & viewer,
const Point & lowerBound, const Point & upperBound,
const std::string & mode )
{
RealPoint p0( (double)lowerBound[ 0 ]-0.5,
(double)lowerBound[ 1 ]-0.5,
(double)lowerBound[ 2 ]-0.5 );
RealPoint p1( (double)upperBound[ 0 ]-0.5,
(double)upperBound[ 1 ]-0.5,
(double)upperBound[ 2 ]-0.5 );
if ( ( mode == "WIRED" ) || ( mode == "COLORED" ) )
{
viewer.setLineColor(AXIS_COLOR);
viewer.addLine( DGtal::Z3i::RealPoint(p0[ 0 ], p0[ 1 ], p0[ 2 ]),
DGtal::Z3i::RealPoint(p1[ 0 ], p0[ 1 ], p0[ 2 ]), AXIS_LINESIZE );
viewer.addLine( DGtal::Z3i::RealPoint(p0[ 0 ], p0[ 1 ], p0[ 2 ]),
DGtal::Z3i::RealPoint(p0[ 0 ], p1[ 1 ], p0[ 2 ]), AXIS_LINESIZE );
viewer.addLine( DGtal::Z3i::RealPoint(p0[ 0 ], p0[ 1 ], p0[ 2 ]),
DGtal::Z3i::RealPoint(p0[ 0 ], p0[ 1 ], p1[ 2 ]), AXIS_LINESIZE );
viewer.addLine( DGtal::Z3i::RealPoint(p1[ 0 ], p0[ 1 ], p0[ 2 ]),
DGtal::Z3i::RealPoint(p1[ 0 ], p1[ 1 ], p0[ 2 ]), AXIS_LINESIZE );
viewer.addLine( DGtal::Z3i::RealPoint(p1[ 0 ], p0[ 1 ], p0[ 2 ]),
DGtal::Z3i::RealPoint(p1[ 0 ], p0[ 1 ], p1[ 2 ]), AXIS_LINESIZE );
viewer.addLine( DGtal::Z3i::RealPoint(p0[ 0 ], p1[ 1 ], p0[ 2 ]),
DGtal::Z3i::RealPoint(p1[ 0 ], p1[ 1 ], p0[ 2 ]), AXIS_LINESIZE );
viewer.addLine( DGtal::Z3i::RealPoint(p0[ 0 ], p1[ 1 ], p0[ 2 ]),
DGtal::Z3i::RealPoint(p0[ 0 ], p1[ 1 ], p1[ 2 ]), AXIS_LINESIZE );
viewer.addLine( DGtal::Z3i::RealPoint(p0[ 0 ], p0[ 1 ], p1[ 2 ]),
DGtal::Z3i::RealPoint(p1[ 0 ], p0[ 1 ], p1[ 2 ]), AXIS_LINESIZE );
viewer.addLine( DGtal::Z3i::RealPoint(p0[ 0 ], p0[ 1 ], p1[ 2 ]),
DGtal::Z3i::RealPoint(p0[ 0 ], p1[ 1 ], p1[ 2 ]), AXIS_LINESIZE );
viewer.addLine( DGtal::Z3i::RealPoint(p1[ 0 ], p1[ 1 ], p0[ 2 ]),
DGtal::Z3i::RealPoint(p1[ 0 ], p1[ 1 ], p1[ 2 ]), AXIS_LINESIZE );
viewer.addLine( DGtal::Z3i::RealPoint(p1[ 0 ], p0[ 1 ], p1[ 2 ]),
DGtal::Z3i::RealPoint(p1[ 0 ], p1[ 1 ], p1[ 2 ]), AXIS_LINESIZE );
viewer.addLine( DGtal::Z3i::RealPoint(p0[ 0 ], p1[ 1 ], p1[ 2 ]),
DGtal::Z3i::RealPoint(p1[ 0 ], p1[ 1 ], p1[ 2 ]), AXIS_LINESIZE );
}
if ( mode == "COLORED" )
{
viewer.setFillColor(XY_COLOR);
viewer.addQuad(DGtal::Z3i::RealPoint(p1[ 0 ], p1[ 1 ], p1[ 2 ]),
DGtal::Z3i::RealPoint(p1[ 0 ], p0[ 1 ], p1[ 2 ]),
DGtal::Z3i::RealPoint(p0[ 0 ], p0[ 1 ], p1[ 2 ]),
DGtal::Z3i::RealPoint(p0[ 0 ], p1[ 1 ], p1[ 2 ]) );
viewer.setFillColor(XZ_COLOR);
viewer.addQuad(DGtal::Z3i::RealPoint(p1[ 0 ], p1[ 1 ], p1[ 2 ]),
DGtal::Z3i::RealPoint(p0[ 0 ], p1[ 1 ], p1[ 2 ]),
DGtal::Z3i::RealPoint(p0[ 0 ], p1[ 1 ], p0[ 2 ]),
DGtal::Z3i::RealPoint(p1[ 0 ], p1[ 1 ], p0[ 2 ]));
viewer.setFillColor(YZ_COLOR);
viewer.addQuad(DGtal::Z3i::RealPoint(p1[ 0 ], p1[ 1 ], p1[ 2 ]),
DGtal::Z3i::RealPoint(p1[ 0 ], p0[ 1 ], p1[ 2 ]),
DGtal::Z3i::RealPoint(p1[ 0 ], p0[ 1 ], p0[ 2 ]),
DGtal::Z3i::RealPoint(p1[ 0 ], p1[ 1 ], p0[ 2 ]));
}
}