Exemple #1
0
  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;
  }
Exemple #2
0
void
Selection::removeIndex (const IndexVector &indices)
{
    IndexVector::const_iterator it;
    for(it = indices.begin(); it != indices.end(); ++it)
        removeIndex(*it);
}
    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() );
    }
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;
}
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;
        }
    }
}
    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() );
    }
Exemple #7
0
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]);
			}
		}
	}
}
Exemple #8
0
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);
}
Exemple #9
0
void
Selection::addIndex (const IndexVector &indices)
{
    selected_indices_.insert(indices.begin(), indices.end());
}