Exemplo n.º 1
0
osg::Node* RhinoReader::BuildEdge(const ON_Brep* theBrep)
{
    osg::ref_ptr<osg::Geode> aGeode = new osg::Geode();

    for (int i = 0; i < theBrep->m_E.Count(); ++i)
    {
        osg::ref_ptr<osg::Geometry> aGeometry = new osg::Geometry();
        osg::ref_ptr<osg::Vec3Array> aVertices = new osg::Vec3Array();

        ON_BrepEdge* anEdge = theBrep->Edge(i);

        double t0 = 0.0;
        double t1 = 0.0;
        double d = 0.0;

        anEdge->GetDomain(&t0, &t1);

        d = (t1 - t0) / 5.0;

        for (double t = t0; (t - t1) < TOLERANCE_EDGE; t += d)
        {
            ON_3dPoint aPoint = anEdge->PointAt(t);

            aVertices->push_back(osg::Vec3(aPoint.x, aPoint.y, aPoint.z));
        }

        aGeometry->setVertexArray(aVertices);
        aGeometry->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINE_LOOP, 0, aVertices->size()));

        aGeode->addDrawable(aGeometry);
    }

    return aGeode.release();
}