本文整理汇总了C++中KSpace::sCell方法的典型用法代码示例。如果您正苦于以下问题:C++ KSpace::sCell方法的具体用法?C++ KSpace::sCell怎么用?C++ KSpace::sCell使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KSpace
的用法示例。
在下文中一共展示了KSpace::sCell方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testRaySurfelIntersection
bool testRaySurfelIntersection()
{
unsigned int nbok = 0;
unsigned int nb = 0;
trace.beginBlock ( "Testing RaySurfel ..." );
using namespace Z3i;
KSpace k;
k.init(Point(0,0,0), Point(10,10,10), true);
typedef RayIntersectionPredicate<KSpace::Cell::Point> Ray;
Ray ray(KSpace::Cell::Point(0,0,0),
KSpace::Cell::Point(2,1,1));
KSpace::Surfel surf = k.sCell( Point( 2,1,1) );
KSpace::Surfel surf2 = k.sCell( Point( 2,7,7) );
trace.info() << "Ray intersection with surf "<<std::endl;
nbok += ray(surf) ? 1 : 0;
nb++;
trace.info() << "(" << nbok << "/" << nb << ") "
<< "true " << std::endl;
trace.info()<<std::endl;
trace.info() << "Ray intersection with surf2 "<<std::endl;
nbok += !ray(surf2 ) ? 1 : 0;
nb++;
trace.info() << "(" << nbok << "/" << nb << ") "
<< "false " << std::endl;
trace.info()<<std::endl;
trace.endBlock();
return nbok == nb;
}
示例2: main
int main( int argc, char** argv )
{
QApplication application(argc,argv);
KSpace K;
Point plow(0,0,0);
Point pup(3,3,2);
Domain domain( plow, pup );
K.init( plow, pup, true );
Viewer3D<Space, KSpace> viewer(K);
viewer.show();
trace.beginBlock ( "Testing display KSCell in Viewer 3D" );
//viewer << SetMode3D( domain.className(), "Paving" );
// if the domain is visible can't see the cubes inside
// viewer << domain;
// Drawing cell of dimension 3
Cell voxelA = K.uCell(Point(1, 1, 1));
SCell voxelB = K.sCell(Point(1, 1, 3));
viewer << voxelB<< voxelA;//
// drawing cells of dimension 2
SCell surfelA = K.sCell( Point( 2, 1, 3 ) );
SCell surfelB = K.sCell( Point( 1, 0, 1 ), false );
Cell surfelC = K.uCell( Point( 1, 2, 1 ) );
SCell surfelD = K.sCell( Point( 1, 1, 0 ) );
Cell surfelE = K.uCell( Point( 1, 1, 2 ) );
viewer << surfelA << surfelB << surfelC << surfelD << surfelE;
Cell linelA = K.uCell(Point(2, 1 ,2));
SCell linelB = K.sCell(Point(2, 2 ,1));
SCell linelC = K.sCell(Point(1, 2 ,2), false);
viewer << linelA << linelB << linelC;
Cell center(Point(5,5,5));
// Testing display of oriented surfels:
SCell ssurfelXZ = K.sCell( Point( 5, 6, 5 ), false );
SCell ssurfelXY = K.sCell( Point( 5, 5, 6 ), false );
SCell ssurfelZY = K.sCell( Point( 6, 5, 5 ), false );
viewer<< center;
SCell ssurfelXZo = K.sCell( Point( 5, 4, 5 ), false );
SCell ssurfelXYo = K.sCell( Point( 5, 5, 4 ), false );
SCell ssurfelZYo = K.sCell( Point( 4, 5, 5 ), false );
viewer << ssurfelXZ << ssurfelXY << ssurfelZY;
viewer << ssurfelXZo << ssurfelXYo << ssurfelZYo;
// Testing display oriented pointels
Cell pointelA = K.uCell(Point(2, 2, 2));
SCell pointelB = K.sCell(Point(4, 4, 4), true);
SCell pointelC = K.sCell(Point(6, 4, 4), false);
SCell linelAC = K.sCell(Point(5, 4, 4), false);
viewer << pointelA << pointelB << pointelC << linelAC;
viewer << Viewer3D<>::updateDisplay;
bool res = application.exec();
trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
trace.endBlock();
return res ? 0 : 1;
}
示例3: testCellularGridSpaceND
bool testCellularGridSpaceND()
{
typedef typename KSpace::Cell Cell;
typedef typename KSpace::SCell SCell;
typedef typename KSpace::Point Point;
typedef typename KSpace::DirIterator DirIterator;
typedef typename KSpace::Cells Cells;
typedef typename KSpace::SCells SCells;
unsigned int nbok = 0;
unsigned int nb = 0;
trace.beginBlock ( "Testing block KSpace instantiation and scan ..." );
KSpace K;
int xlow[ 4 ] = { -3, -2, -2, -1 };
int xhigh[ 4 ] = { 5, 3, 2, 3 };
Point low( xlow );
Point high( xhigh );
bool space_ok = K.init( low, high, true );
nbok += space_ok ? 1 : 0;
nb++;
trace.info() << "(" << nbok << "/" << nb << ") "
<< "K.init( low, high )" << std::endl;
trace.info() << "K.dim()=" << K.dimension << endl;
int spel[ 4 ] = { 1, 1, 1, 1 }; // pixel
Point kp( spel );
Cell center = K.uCell( kp );
Cell c1 = K.uCell( kp );
Cell clow = K.uCell( low, kp );
Cell chigh = K.uCell( high, kp );
trace.info() << c1 << clow << chigh
<< " topo(c1)=" << K.uTopology( c1 ) << " dirs=";
for ( DirIterator q = K.uDirs( clow ); q != 0; ++q )
trace.info() << " " << *q;
trace.info() << endl;
Cell f = K.uFirst( c1 );
Cell l = K.uLast( c1 );
trace.info() << "Loop in " << clow << chigh << endl;
c1 = f;
unsigned int nbelems = 0;
do {
++nbelems;
// trace.info() << c1;
} while ( K.uNext( c1, f, l ) );
trace.info() << " -> " << nbelems << " elements." << endl;
unsigned int exp_nbelems = 1;
for ( Dimension i = 0; i < K.dimension; ++i )
exp_nbelems *= K.size( i );
nbok += nbelems == exp_nbelems ? 1 : 0;
nb++;
trace.info() << "(" << nbok << "/" << nb << ") "
<< nbelems << " scanned elements == "
<< exp_nbelems << " space size."
<< std::endl;
trace.endBlock();
trace.beginBlock ( "Testing neighborhoods in KSpace..." );
Cells N = K.uNeighborhood( center );
nbok += N.size() == ( K.dimension*2 + 1 ) ? 1 : 0;
nb++;
trace.info() << "(" << nbok << "/" << nb << ") "
<< N.size() << "(neighborhood size) == "
<< ( K.dimension*2 + 1 ) << "(2*dim()+1)" << endl;
Cells Np = K.uProperNeighborhood( center );
nbok += Np.size() == ( K.dimension*2 ) ? 1 : 0;
nb++;
trace.info() << "(" << nbok << "/" << nb << ") "
<< Np.size() << "(proper neighborhood size) == "
<< ( K.dimension*2 ) << "(2*dim())" << endl;
trace.endBlock();
trace.beginBlock ( "Testing faces in KSpace..." );
Cells Nf = K.uFaces( center );
nbok += Nf.size() == ceil( std::pow( 3.0 ,(int) K.dimension ) - 1 ) ? 1 : 0;
nb++;
trace.info() << "(" << nbok << "/" << nb << ") "
<< Nf.size() << "(faces size) == "
<< floor( std::pow( 3.0, (int)K.dimension ) - 1 ) << "(3^dim()-1)" << endl;
trace.endBlock();
trace.beginBlock ( "Testing block Incidence in KSpace..." );
SCell sspel = K.sCell( kp, K.POS );
for ( DirIterator q1 = K.sDirs( sspel ); q1 != 0; ++q1 )
for ( DirIterator q2 = K.sDirs( sspel ); q2 != 0; ++q2 )
{
if ( *q1 != *q2 )
{
SCell s0 = K.sIncident( sspel, *q1, true );
SCell s1 = K.sIncident( sspel, *q2, true );
SCell l10 = K.sIncident( s0, *q2, true );
SCell l01 = K.sIncident( s1, *q1, true );
trace.info() << "D+_" << *q2 << "(D+_" << *q1 << "(V))=" << l10
<< " D+_" << *q1 << "(D+_" << *q2 << "(V))=" << l01
<< endl;
nbok += l10 == K.sOpp( l01 ) ? 1 : 0;
nb++;
}
}
trace.info() << "(" << nbok << "/" << nb << ") "
<< "anti-commutativity of incidence operators." << std::endl;
trace.endBlock();
//.........这里部分代码省略.........
示例4: testCellDrawOnBoard
bool testCellDrawOnBoard()
{
typedef typename KSpace::Integer Integer;
typedef typename KSpace::Cell Cell;
typedef typename KSpace::SCell SCell;
typedef typename KSpace::Point Point;
typedef typename KSpace::DirIterator DirIterator;
typedef typename KSpace::Cells Cells;
typedef typename KSpace::SCells SCells;
typedef SpaceND<2, Integer> Z2;
typedef HyperRectDomain<Z2> Domain;
unsigned int nbok = 0;
unsigned int nb = 0;
trace.beginBlock ( "Testing cell draw on digital board ..." );
KSpace K;
int xlow[ 4 ] = { -3, -3 };
int xhigh[ 4 ] = { 5, 3 };
Point low( xlow );
Point high( xhigh );
bool space_ok = K.init( low, high, true );
Domain domain( low, high );
Board2D board;
board.setUnit( LibBoard::Board::UCentimeter );
board << SetMode( domain.className(), "Paving" )
<< domain;
int spel[ 2 ] = { 1, 1 }; // pixel 0,0
Point kp( spel );
Cell uspel = K.uCell( kp );
board << uspel
<< low << high
<< K.uIncident( uspel, 0, false )
<< K.uIncident( uspel, 1, false );
int spel2[ 2 ] = { 5, 1 }; // pixel 2,0
Point kp2( spel2 );
SCell sspel2 = K.sCell( kp2, K.POS );
board << CustomStyle( sspel2.className(),
new CustomPen( Color( 200, 0, 0 ),
Color( 255, 100, 100 ),
2.0,
Board2D::Shape::SolidStyle ) )
<< sspel2
<< K.sIncident( sspel2, 0, K.sDirect( sspel2, 0 ) )
<< K.sIncident( sspel2, 1, K.sDirect( sspel2, 0 ) );
board.saveEPS( "cells-1.eps" );
board.saveSVG( "cells-1.svg" );
trace.endBlock();
board.clear();
board << domain;
SCell slinel0 = K.sIncident( sspel2, 0, K.sDirect( sspel2, 0 ) );
SCell spointel01 = K.sIncident( slinel0, 1, K.sDirect( slinel0, 1 ) );
board << CustomStyle( sspel2.className(),
new CustomColors( Color( 200, 0, 0 ),
Color( 255, 100, 100 ) ) )
<< sspel2
<< CustomStyle( slinel0.className(),
new CustomColors( Color( 0, 200, 0 ),
Color( 100, 255, 100 ) ) )
<< slinel0
<< CustomStyle( spointel01.className(),
new CustomColors( Color( 0, 0, 200 ),
Color( 100, 100, 255 ) ) )
<< spointel01;
board.saveEPS( "cells-3.eps" );
board.saveSVG( "cells-3.svg" );
return ((space_ok) && (nbok == nb));
}
示例5: testSurfelAdjacency
bool testSurfelAdjacency()
{
typedef typename KSpace::Integer Integer;
typedef typename KSpace::Cell Cell;
typedef typename KSpace::SCell SCell;
typedef typename KSpace::Point Point;
typedef typename KSpace::DirIterator DirIterator;
typedef typename KSpace::Cells Cells;
typedef typename KSpace::SCells SCells;
unsigned int nbok = 0;
unsigned int nb = 0;
trace.beginBlock ( "Testing block KSpace instantiation and scan ..." );
KSpace K;
int xlow[ 4 ] = { -3, -3, -3, -3 };
int xhigh[ 4 ] = { 5, 3, 3, 3 };
Point low( xlow );
Point high( xhigh );
bool space_ok = K.init( low, high, true );
nbok += space_ok ? 1 : 0;
nb++;
trace.info() << "(" << nbok << "/" << nb << ") "
<< "K.init( low, high )" << std::endl;
trace.info() << "K.dim()=" << K.dimension << endl;
trace.endBlock();
trace.beginBlock ( "Testing surfel adjacency ..." );
SurfelAdjacency<KSpace::dimension> SAdj( true );
for ( Dimension i = 0; i < K.dimension; ++i )
for ( Dimension j = 0; j < K.dimension; ++j )
if ( i != j )
trace.info() << "(" << i << "," << j << ")="
<< ( SAdj.getAdjacency( i, j ) ? "i2e" : "e2i" );
trace.info() << endl;
trace.endBlock();
int spel[ 4 ] = { 1, 1, 1, 1 }; // pixel
Point kp( spel );
SCell sspel = K.sCell( kp, K.POS );
trace.beginBlock ( "Testing surfel directness ..." );
for ( Dimension k = 0; k < K.dimension; ++k )
{
SCell surfel = K.sIncident( sspel, k, true );
SCell innerspel = K.sDirectIncident( surfel, K.sOrthDir( surfel ) );
trace.info() << "spel=" << sspel << " surfel=" << surfel
<< " innerspel=" << innerspel << endl;
nbok += sspel == innerspel ? 1 : 0;
nb++;
trace.info() << "(" << nbok << "/" << nb << ") "
<< "spel == innerspel" << std::endl;
surfel = K.sIncident( sspel, k, false );
innerspel = K.sDirectIncident( surfel, K.sOrthDir( surfel ) );
trace.info() << "spel=" << sspel << " surfel=" << surfel
<< " innerspel=" << innerspel << endl;
nbok += sspel == innerspel ? 1 : 0;
nb++;
trace.info() << "(" << nbok << "/" << nb << ") "
<< "spel == innerspel" << std::endl;
}
trace.endBlock();
SurfelNeighborhood<KSpace> SN;
trace.beginBlock ( "Testing surfel neighborhood ..." );
SCell surfel = K.sIncident( sspel, 0, false );
SN.init( &K, &SAdj, surfel );
trace.info() << "surfel =" << surfel << endl;
trace.info() << "follower1(+)=" << SN.follower1( 1, true ) << endl;
trace.info() << "follower2(+)=" << SN.follower2( 1, true ) << endl;
trace.info() << "follower3(+)=" << SN.follower3( 1, true ) << endl;
trace.info() << "follower1(-)=" << SN.follower1( 1, false ) << endl;
trace.info() << "follower2(-)=" << SN.follower2( 1, false ) << endl;
trace.info() << "follower3(-)=" << SN.follower3( 1, false ) << endl;
trace.endBlock();
trace.beginBlock ( "Testing surface tracking ..." );
typedef SpaceND< KSpace::dimension, Integer > Space;
typedef HyperRectDomain<Space> Domain;
typedef typename DigitalSetSelector< Domain, BIG_DS+HIGH_BEL_DS >::Type DigitalSet;
Domain domain( low, high );
DigitalSet shape_set( domain );
SetPredicate<DigitalSet> shape_set_predicate( shape_set );
int center[ 4 ] = { 1, 0, 0, 0 }; // pixel
Point pcenter( center );
Shapes<Domain>::addNorm1Ball( shape_set, pcenter, 1 );
trace.info() << "surfel = " << surfel << endl;
SCell other1, other2;
SN.getAdjacentOnDigitalSet( other1, shape_set, 1, K.sDirect( surfel, 1 ) );
SN.getAdjacentOnDigitalSet( other2, shape_set, 1, !K.sDirect( surfel, 1 ) );
trace.info() << "directNext = " << other1 << endl;
trace.info() << "indirectNext= " << other2 << endl;
std::set<SCell> bdry;
// surfel = Surfaces<KSpace>::findABel( K, shape_set );
Surfaces<KSpace>::trackBoundary( bdry,
K, SAdj, shape_set_predicate, surfel );
trace.info() << "tracking finished, size=" << bdry.size()
<< ", should be " << 2*K.dimension*(2*K.dimension-1) << endl;
nbok += bdry.size() == ( 2*K.dimension*(2*K.dimension-1) ) ? 1 : 0;
nb++;
trace.info() << "(" << nbok << "/" << nb << ") "
//.........这里部分代码省略.........
示例6: main
int main( int argc, char** argv )
{
QApplication application(argc,argv);
Viewer3D viewer;
viewer.show();
KSpace K;
Point plow(0,0,0);
Point pup(3,3,2);
Domain domain( plow, pup );
K.init( plow, pup, true );
//viewer << SetMode3D( domain.styleName(), "Paving" );
// viewer << domain;
// Drawing cell of dimension 3
Cell voxelA = K.uCell(Point(1,1,1));
SCell voxelB = K.sCell(Point(1,1,3));
viewer << voxelB<< voxelA;//
// drawing cells of dimension 2
SCell surfelA = K.sCell( Point( 2, 1, 3 ) );
SCell surfelB = K.sCell( Point( 1, 0, 1 ), false );
Cell surfelC = K.uCell( Point( 1, 2, 1 ) );
SCell surfelD = K.sCell( Point( 1, 1, 0 ) );
Cell surfelE = K.uCell( Point( 1, 1, 2 ) );
viewer << surfelA << surfelB << surfelC << surfelD << surfelE;
Cell linelA = K.uCell(Point(2,1 ,2));
SCell linelB = K.sCell(Point(2,2 ,1));
SCell linelC = K.sCell(Point(1,2 ,2), false);
viewer << linelA << linelB << linelC;
Cell center(Point(5,5,5));
// Testing display of oriented surfels:
SCell ssurfelXZ = K.sCell( Point( 5, 6, 5 ), false );
SCell ssurfelXY = K.sCell( Point( 5, 5, 6 ), false );
SCell ssurfelZY = K.sCell( Point( 6, 5, 5 ), false );
viewer<< center;
SCell ssurfelXZo = K.sCell( Point( 5, 4, 5 ), false );
SCell ssurfelXYo = K.sCell( Point( 5, 5, 4 ), false );
SCell ssurfelZYo = K.sCell( Point( 4, 5, 5 ), false );
viewer << ssurfelXZ << ssurfelXY << ssurfelZY;
viewer << ssurfelXZo << ssurfelXYo << ssurfelZYo;
// Testing display oriented pointels
Cell pointelA = K.uCell(Point(2, 2, 2));
SCell pointelB = K.sCell(Point(4, 4, 4), true);
SCell pointelC = K.sCell(Point(6, 4, 4), false);
SCell linelAC = K.sCell(Point(5, 4, 4), false);
viewer << pointelA << pointelB << pointelC << linelAC;
viewer << Viewer3D::updateDisplay;
application.exec();
trace.endBlock();
return true;
}
示例7: main
int main( int argc, char** argv )
{
// for 3D display with Viewer3D
QApplication application(argc,argv);
KSpace K;
Point plow(0,0,0);
Point pup(3,3,2);
Domain domain( plow, pup );
K.init( plow, pup, true );
Viewer3D viewer;
viewer.show();
viewer << SetMode3D( domain.styleName(), "Paving" );
SCell ptlow = K.sPointel( plow ); // pointel (0*2,0*2, 0*2)
SCell ptup1 = K.sPointel( pup ); // pointel (3*2,3*2, 2*2)
SCell ptup2 = K.sTranslation( ptup1, Point::diagonal() ); // pointel (4*2, 4*2, 3*2)
viewer << ptlow << ptup1 << ptup2;
// drawing cells of dimension 0
SCell p1= K.sCell(Point(0,0,2),false); // pointel (0*2,0*2,2*2)
SCell p2= K.sCell(Point(0,2,2)); // ...
SCell p3= K.sCell(Point(2,2,2),false);
SCell p4= K.sCell(Point(2,0,2));
SCell p5= K.sCell(Point(0,0,4),false);
SCell p6= K.sCell(Point(0,2,4));
SCell p7= K.sCell(Point(2,2,4), false);
SCell p8= K.sCell(Point(2,0,4));
viewer << p1 << p2 << p3 << p4 << p5 << p6 << p7 << p8;
// drawing Cells of dimension 1
SCell linel0 = K.sCell( Point( 1, 0, 2 ) ); // linel (2*1+1, 0, 2*2)
SCell linel1 = K.sCell( Point( 1, 2, 2 ) ); // ...
SCell linel2 = K.sCell( Point( 0, 1, 2 ) );
SCell linel3 = K.sCell( Point( 2, 1, 2 ) );
SCell linel4 = K.sCell( Point( 1, 0, 4 ) );
SCell linel5 = K.sCell( Point( 1, 2, 4 ) );
SCell linel6 = K.sCell( Point( 0, 1, 4 ) );
SCell linel7 = K.sCell( Point( 2, 1, 4 ) );
SCell linel8 = K.sCell( Point( 0, 0, 3 ) );
SCell linel9 = K.sCell( Point( 0, 2, 3 ) );
SCell linel10 = K.sCell( Point( 2, 0, 3 ) );
SCell linel11 = K.sCell( Point( 2, 2, 3 ) );
SCell linel12 = K.sCell( Point( 3, 2, 2 ) );
viewer << linel0<< linel1<< linel2 << linel3 ;
viewer << linel4<< linel5<< linel6 << linel7 ;
viewer << linel8<< linel9<< linel10 << linel11 << linel12;
// drawing cells of dimension 2
SCell surfelA = K.sCell( Point( 2, 1, 3 ) ); // surfel (2*2,2*1+1,2*3+1)
SCell surfelB = K.sCell( Point( 1, 0, 1 ) ); // surfel (2*1,2*0,2*1+1)
SCell surfelC = K.sCell( Point( 2, 1, 1 ),false ); // surfel (2*2,2*1+1,2*1+1)
viewer << surfelA << surfelB << surfelC;
// drawing cells of dimension 3
SCell vox1 = K.sCell( Point( 3, 3, 3 ) ); // voxel (2*3+1,2*3+1,2*3+1)
SCell vox2 = K.sCell( Point( 1, 1, 3 ) ,false ); // voxel (2*1+1,2*1+1,2*3+1)
viewer << vox1 << vox2;
viewer << CameraPosition(-2.9, 2.96, 2.64)
<< CameraDirection(0.6, -0.43, 0.65)
<< CameraUpVector(0.32, 0.900, 0.29);
viewer<< Viewer3D::updateDisplay;
return application.exec();
return 0;
}