OSG读取DXF

View Code
 1 void osgLines(osg::Group* root, bounds &b)
2 {
3 for(MapVListList::iterator mlitr = _linestrips.begin();
4 mlitr != _linestrips.end();
5 ++mlitr)
6 {
7 for(VListList::iterator itr = mlitr->second.begin();
8 itr != mlitr->second.end();
9 ++itr)
10 {
11 if (itr->size()) {
12 osg::Vec3Array *coords = new osg::Vec3Array;
13 for (VList::iterator vitr = itr->begin();
14 vitr != itr->end(); ++vitr) {
15 osg::Vec3 v(vitr->x() - b._min.x(), vitr->y() - b._min.y(), vitr->z() - b._min.z());
16 coords->push_back(v);
17 }
18 root->addChild(createModel(_name, createLnGeometry(osg::PrimitiveSet::LINE_STRIP, coords, getColor(mlitr->first))));
19 }
20 }
21 }
22 for (MapVList::iterator mitr = _lines.begin();
23 mitr != _lines.end(); ++mitr) {
24 osg::Vec3Array *coords = new osg::Vec3Array;
25 for (VList::iterator itr = mitr->second.begin();
26 itr != mitr->second.end(); ++itr) {
27 osg::Vec3 v(itr->x() - b._min.x(), itr->y() - b._min.y(), itr->z() - b._min.z());
28 coords->push_back(v);
29 }
30 root->addChild(createModel(_name, createLnGeometry(osg::PrimitiveSet::LINES, coords, getColor(mitr->first))));
31 }
32 }

  

posted on 2011-09-06 22:51  Joshua Leung  阅读(1124)  评论(0编辑  收藏  举报

导航