本文整理汇总了C++中IndexVector类的典型用法代码示例。如果您正苦于以下问题:C++ IndexVector类的具体用法?C++ IndexVector怎么用?C++ IndexVector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IndexVector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: removeIndex
void
Selection::removeIndex (const IndexVector &indices)
{
IndexVector::const_iterator it;
for(it = indices.begin(); it != indices.end(); ++it)
removeIndex(*it);
}
示例2:
IndexVector::IndexVector(const IndexVector &rhs){
_length=rhs.length();
if(_length>0) {
_data = new int[_length];
memcpy(_data,rhs.data(),_length*sizeof(int) );
} else{
_data=0;
}
}
示例3:
osg::Vec3f TriangleMeshSmoother::cumulateTriangleNormals(const IndexVector& triangles) const {
osg::Vec3f normal;
normal.set(0.f, 0.f, 0.f);
for(IndexVector::const_iterator triangle = triangles.begin() ; triangle != triangles.end() ; ++ triangle) {
const Triangle& t = _graph->triangle(*triangle);
normal += (t._normal * t._area);
}
return normal;
}
示例4: sparse
IGL_INLINE void igl::sparse(
const IndexVector & I,
const IndexVector & J,
const ValueVector & V,
Eigen::SparseMatrix<T>& X)
{
size_t m = (size_t)I.maxCoeff()+1;
size_t n = (size_t)J.maxCoeff()+1;
return igl::sparse(I,J,V,m,n,X);
}
示例5: buildIndices
IndexVector buildIndices(const std::string& expr, Iterator begin, Iterator end) const {
IndexVector indices;
for (Iterator i = begin; i != end; ++i) {
if (expr.empty() || i->matches(expr)) {
indices.push_back(std::distance(begin, i));
}
}
return indices;
}
示例6: children
/*!
* \brief children Populate a children list for the given contour. No control is made.
* \param _hierarchy OpenCV contour hierarchy used to find children.
* \param _parentIndex Index in _hierarchy of the given contour. _parentIndex must exist in _hierarchy.
* \param _children Output list of the found children.
* \return number of children.
*/
void ContourManager::children(const Hierarchy & _hierarchy, int _parentIndex, IndexVector & _children)
{
_children.clear();
int currentChild = _hierarchy[_parentIndex][HIERARCHY_INDEX_FIRST_CHILD];//First child
while (currentChild >= 0)
{
_children.push_back(currentChild);
currentChild = _hierarchy[currentChild][HIERARCHY_INDEX_NEXT];
}//while (currentChild >= 0)
}//children
示例7: replaceVertexIndexInTriangles
void TriangleMeshSmoother::replaceVertexIndexInTriangles(const IndexVector& triangles, unsigned int oldIndex, unsigned int newIndex) {
for(IndexVector::const_iterator tri = triangles.begin() ; tri != triangles.end() ; ++ tri) {
Triangle& triangle = _graph->triangle(*tri);
if(triangle.v1() == oldIndex) {
triangle.v1() = newIndex;
}
else if(triangle.v2() == oldIndex) {
triangle.v2() = newIndex;
}
else if(triangle.v3() == oldIndex) {
triangle.v3() = newIndex;
}
}
}
示例8: while
void
AdjacencyRansac::InvalidateQueryIndices(IndexVector &query_indices)
{
if (query_indices.empty())
return;
// Figure out the points with those query indices
std::sort(query_indices.begin(), query_indices.end());
IndexVector::iterator end = std::unique(query_indices.begin(), query_indices.end());
query_indices.resize(end - query_indices.begin());
IndexVector indices_to_remove;
indices_to_remove.reserve(query_indices_.size());
IndexVector::const_iterator iter = query_indices.begin();
BOOST_FOREACH(unsigned int index, valid_indices_){
unsigned int query_index = query_indices_[index];
if (query_index < *iter)
continue;
// If the match has a keypoint in the inliers, remove the match
while ((iter != end) && (query_index > *iter))
++iter;
if (query_index == *iter)
{
indices_to_remove.push_back(index);
continue;
}
if (iter == end)
break;
}
示例9: IndexVector
void RemoveUnusedStructField::handleOneRecordDecl(const RecordDecl *RD,
const RecordDecl *BaseRD,
const FieldDecl *FD,
unsigned int Idx)
{
IndexVector *BaseIdxVec = RecordDeclToField[BaseRD];
if (!BaseIdxVec)
return;
IndexVector *NewIdxVec = RecordDeclToField[RD];
if (!NewIdxVec) {
NewIdxVec = new IndexVector();
RecordDeclToField[RD] = NewIdxVec;
}
NewIdxVec->push_back(Idx);
FieldToIdxVector[FD] = BaseIdxVec;
}
示例10: testInterleavedSortingWithPops
void testInterleavedSortingWithPops()
{
DPQ dpq;
IndexVector idVector;
const Index MAXI( 101 );
for( int n( MAXI-1 ); n != 0 ; n-=2 )
{
const Index id( dpq.push( n ) );
if( n == 12 || n == 46 )
{
idVector.push_back( id );
}
}
dpq.pop( idVector.back() );
idVector.pop_back();
BOOST_CHECK_EQUAL( MAXI/2 -1, dpq.getSize() );
BOOST_CHECK( dpq.checkConsistency() );
for( int n( MAXI ); n != -1 ; n-=2 )
{
const Index id( dpq.push( n ) );
if( n == 17 || n == 81 )
{
idVector.push_back( id );
}
}
for( typename IndexVector::const_iterator i( idVector.begin() );
i != idVector.end(); ++i )
{
dpq.pop( *i );
}
BOOST_CHECK( dpq.checkConsistency() );
BOOST_CHECK_EQUAL( MAXI-4, dpq.getSize() );
int n( 0 );
while( ! dpq.isEmpty() )
{
++n;
if( n == 12 || n == 46 || n == 17 || n == 81 )
{
continue;
}
BOOST_CHECK_EQUAL( n, dpq.getTop() );
dpq.popTop();
}
BOOST_CHECK_EQUAL( MAXI, Index( n ) );
BOOST_CHECK( dpq.isEmpty() );
BOOST_CHECK( dpq.checkConsistency() );
}
示例11: testSimpleSortingWithPops
void testSimpleSortingWithPops()
{
DPQ dpq;
IndexVector idVector;
const Index MAXI( 100 );
for( int n( MAXI ); n != 0 ; --n )
{
Index id( dpq.push( n ) );
if( n == 11 || n == 45 )
{
idVector.push_back( id );
}
}
BOOST_CHECK( dpq.checkConsistency() );
BOOST_CHECK_EQUAL( MAXI, dpq.getSize() );
for( typename IndexVector::const_iterator i( idVector.begin() );
i != idVector.end(); ++i )
{
dpq.pop( *i );
}
BOOST_CHECK_EQUAL( MAXI - 2, dpq.getSize() );
int n( 0 );
while( ! dpq.isEmpty() )
{
++n;
if( n == 11 || n == 45 )
{
continue; // skip
}
BOOST_CHECK_EQUAL( int( n ), dpq.getTop() );
dpq.popTop();
}
BOOST_CHECK_EQUAL( MAXI, Index( n ) );
BOOST_CHECK( dpq.isEmpty() );
BOOST_CHECK( dpq.checkConsistency() );
}
示例12:
void
AdjacencyList::node_neighbors(const int& local_index,
IndexVector& global_neighbor_indexes) const
{
BOOST_ASSERT(local_index < p_adjacency.size());
global_neighbor_indexes.clear();
std::copy(p_adjacency[local_index].begin(), p_adjacency[local_index].end(),
std::back_inserter(global_neighbor_indexes));
}
示例13: glGetIntegerv
void
Select2DTool::end (int x, int y, BitMask modifiers, BitMask)
{
if (!cloud_ptr_)
return;
final_x_ = x;
final_y_ = y;
display_box_ = false;
// don't select anything if we don't have a selection box.
if ((final_x_ == origin_x_) || (final_y_ == origin_y_))
return;
GLint viewport[4];
glGetIntegerv(GL_VIEWPORT,viewport);
IndexVector indices;
GLfloat project[16];
glGetFloatv(GL_PROJECTION_MATRIX, project);
Point3DVector ptsvec;
cloud_ptr_->getDisplaySpacePoints(ptsvec);
for(size_t i = 0; i < ptsvec.size(); ++i)
{
Point3D pt = ptsvec[i];
if (isInSelectBox(pt, project, viewport))
indices.push_back(i);
}
if (modifiers & SHFT)
{
selection_ptr_->addIndex(indices);
}
else if (modifiers & CTRL)
{
selection_ptr_->removeIndex(indices);
}
else
{
selection_ptr_->clear();
selection_ptr_->addIndex(indices);
}
cloud_ptr_->setSelection(selection_ptr_);
}
示例14: Table
postTable::postTable (OpenTypeFile &aFont, MemoryBlockPtr memory) : Table (aFont)
{
MemoryPen pen (memory);
version = pen.readFixed();
if (version != 0x00020000 && version != 0x00030000)
throw Exception ("Unsupported table version: " + String (version, 16));
italicAngle = pen.readFixed();
underlinePosition = pen.readFWord();
underlineThickness = pen.readFWord();
isFixedPitch = pen.readULong();
minMemType42 = pen.readULong();
maxMemType42 = pen.readULong();
minMemType1 = pen.readULong();
maxMemType1 = pen.readULong();
if (version == 0x00020000) {
// Read glyph names
UShort glyphNum = pen.readUShort();
typedef vector<UShort> IndexVector;
IndexVector glyphNameIndices;
glyphNameIndices.reserve (glyphNum);
UShort i;
for (i = 0; i < glyphNum; i++)
glyphNameIndices.push_back (pen.readUShort());
vector<String> extraNames;
IndexVector::iterator index;
for (index = glyphNameIndices.begin(); index != glyphNameIndices.end(); index ++) {
if (*index < MACINTOSH_SET_SIZE)
postNames.push_back (macGlyphs [*index]);
else {
UShort extraIndex = *index - MACINTOSH_SET_SIZE;
while (extraNames.size() <= extraIndex) {
Byte nameLength = pen.readByte();
extraNames.push_back (pen.readString (nameLength));
}
postNames.push_back (extraNames [extraIndex]);
}
}
}
}
示例15:
void
TopologyGraph::dumpBoundary(const IndexVector& boundary, const std::string& filename)
{
if (boundary.empty())
return;
osg::Vec3Array* v = new osg::Vec3Array();
for (IndexVector::const_iterator i = boundary.begin(); i != boundary.end(); ++i)
{
const Index& index = *i;
v->push_back(osg::Vec3(index->x(), index->y(), 0));
}
osg::ref_ptr<osg::Geometry> g = new osg::Geometry();
g->setVertexArray(v);
g->addPrimitiveSet(new osg::DrawArrays(GL_LINE_LOOP, 0, v->size()));
g->addPrimitiveSet(new osg::DrawArrays(GL_POINTS, 0, v->size()));
g->getOrCreateStateSet()->setAttributeAndModes(new osg::Point(3));
osgDB::writeNodeFile(*(g.get()), filename);
}