本文整理汇总了C++中KSpace::sDirect方法的典型用法代码示例。如果您正苦于以下问题:C++ KSpace::sDirect方法的具体用法?C++ KSpace::sDirect怎么用?C++ KSpace::sDirect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KSpace
的用法示例。
在下文中一共展示了KSpace::sDirect方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testCellularGridSpaceND
//.........这里部分代码省略.........
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();
trace.beginBlock ( "Testing direct Incidence in KSpace..." );
for ( DirIterator q1 = K.sDirs( sspel ); q1 != 0; ++q1 )
for ( DirIterator q2 = K.sDirs( sspel ); q2 != 0; ++q2 )
{
if ( *q1 != *q2 )
{
SCell s0 = K.sDirectIncident( sspel, *q1 );
SCell l10 = K.sDirectIncident( s0, *q2 );
SCell s1 = K.sDirectIncident( sspel, *q2 );
SCell l01 = K.sDirectIncident( s1, *q1 );
trace.info() << "Dd_" << *q2 << "(Dd_" << *q1 << "(V))=" << l10
<< " Dd_" << *q1 << "(Dd_" << *q2 << "(V))=" << l01
<< endl;
nbok += l10 != l01 ? 1 : 0;
nbok += K.sSign( s0 ) == K.POS ? 1 : 0;
nbok += K.sSign( s1 ) == K.POS ? 1 : 0;
nbok += K.sSign( l10 ) == K.POS ? 1 : 0;
nbok += K.sSign( l01 ) == K.POS ? 1 : 0;
nbok += s0 == K.sIncident( sspel, *q1, K.sDirect( sspel, *q1 ) )
? 1 : 0;
nbok += s1 == K.sIncident( sspel, *q2, K.sDirect( sspel, *q2 ) )
? 1 : 0;
nbok += l10 == K.sIncident( s0, *q2, K.sDirect( s0, *q2 ) )
? 1 : 0;
nbok += l01 == K.sIncident( s1, *q1, K.sDirect( s1, *q1 ) )
? 1 : 0;
nb += 9;
}
}
trace.info() << "(" << nbok << "/" << nb << ") "
<< "correctness of direct and indirect orientations." << std::endl;
trace.endBlock();
return nbok == nb;
}
示例2: 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 << ") "
//.........这里部分代码省略.........
示例3: 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));
}
示例4: main
//.........这里部分代码省略.........
viewer.setFillColor( Color( 200, 200, 250 ) );
Display3DFactory<Space,KSpace>::drawOrientedSurfelWithNormal( viewer, *it, n_estimations[ *it ], false );
}
viewer << Viewer3D<>::updateDisplay;
trace.endBlock();
//-----------------------------------------------------------------------------
// Defining Discrete Calculus.
typedef CubicalComplex< KSpace > CComplex;
typedef DiscreteExteriorCalculus<2,3, EigenLinearAlgebraBackend> Calculus;
typedef Calculus::Index Index;
typedef Calculus::PrimalForm0 PrimalForm0;
typedef Calculus::PrimalForm1 PrimalForm1;
typedef Calculus::PrimalForm2 PrimalForm2;
typedef Calculus::PrimalIdentity0 PrimalIdentity0;
typedef Calculus::PrimalIdentity1 PrimalIdentity1;
typedef Calculus::PrimalIdentity2 PrimalIdentity2;
trace.beginBlock( "Creating Discrete Exterior Calculus. " );
Calculus calculus;
calculus.initKSpace<Domain>( domain );
const KSpace& Kc = calculus.myKSpace; // should not be used.
// Use a cubical complex to find all lower incident cells easily.
CComplex complex( K );
for ( ConstIterator it = digSurf.begin(), itE = digSurf.end(); it != itE; ++it )
complex.insertCell( 2, K.unsigns( *it ) );
complex.close();
for ( CComplex::CellMapIterator it = complex.begin( 0 ), itE = complex.end( 0 ); it != itE; ++it )
calculus.insertSCell( K.signs( it->first, K.POS ) );
for ( CComplex::CellMapIterator it = complex.begin( 1 ), itE = complex.end( 1 ); it != itE; ++it )
{
SCell linel = K.signs( it->first, K.POS );
Dimension k = * K.sDirs( linel );
bool pos = K.sDirect( linel, k );
calculus.insertSCell( pos ? linel : K.sOpp( linel ) );
// calculus.insertSCell( K.signs( it->first, K.POS ) );
}
// for ( CComplex::CellMapIterator it = complex.begin( 2 ), itE = complex.end( 2 ); it != itE; ++it )
// calculus.insertSCell( K.signs( it->first, K.POS ) );
for ( ConstIterator it = digSurf.begin(), itE = digSurf.end(); it != itE; ++it )
{
calculus.insertSCell( *it );
// SCell surfel = *it;
// Dimension k = K.sOrthDir( surfel );
// bool pos = K.sDirect( surfel, k );
// calculus.insertSCell( pos ? *it : K.sOpp( *it ) );
}
calculus.updateIndexes();
trace.info() << calculus << endl;
std::vector<PrimalForm2> g;
g.reserve( 3 );
g.push_back( PrimalForm2( calculus ) );
g.push_back( PrimalForm2( calculus ) );
g.push_back( PrimalForm2( calculus ) );
Index nb2 = g[ 0 ].myContainer.rows();
for ( Index index = 0; index < nb2; index++)
{
const Calculus::SCell& cell = g[ 0 ].getSCell( index );
if ( theSetOfSurfels.isInside( cell ) )
{
const RealVector& n = n_estimations[ cell ];
g[ 0 ].myContainer( index ) = n[ 0 ];
g[ 1 ].myContainer( index ) = n[ 1 ];