diff --git a/src/osgPlugins/shp/ESRIShapeParser.cpp b/src/osgPlugins/shp/ESRIShapeParser.cpp index 0b7931465..28d41aa01 100644 --- a/src/osgPlugins/shp/ESRIShapeParser.cpp +++ b/src/osgPlugins/shp/ESRIShapeParser.cpp @@ -200,6 +200,12 @@ ESRIShapeParser::ESRIShapeParser( const std::string fileName, bool useDouble ): default: break; } + + if(fd) + { + close(fd); + fd = 0; + } } osg::Geode *ESRIShapeParser::getGeode() @@ -367,15 +373,15 @@ void ESRIShapeParser::_process( const std::vector &mptms std::vector::const_iterator p; for( p = mptms.begin(); p != mptms.end(); p++ ) { - ArrayHelper coords(_useDouble); + osg::ref_ptr coords = new osg::Vec3Array; // Here is where we would use the 'M' (?) for( int i = 0; i < p->numPoints ; i++ ) - coords.add( p->points[i].x, p->points[i].y, 0.0 ); + coords->push_back( osg::Vec3( p->points[i].x, p->points[i].y, 0.0 )); osg::ref_ptr geometry = new osg::Geometry; geometry->setVertexArray(coords.get()); - geometry->addPrimitiveSet( new osg::DrawArrays(osg::PrimitiveSet::POINTS, 0, coords.size())); + geometry->addPrimitiveSet( new osg::DrawArrays(osg::PrimitiveSet::POINTS, 0, coords->size())); _geode->addDrawable( geometry.get() ); } @@ -388,11 +394,11 @@ void ESRIShapeParser::_process(const std::vector &linems ) std::vector::const_iterator p; for( p = linems.begin(); p != linems.end(); p++ ) { - ArrayHelper coords(_useDouble); + osg::ref_ptr coords = new osg::Vec3Array; int i; for( i = 0; i < p->numPoints; i++ ) - coords.add( p->points[i].x, p->points[i].y, 0.0 ); + coords->push_back( osg::Vec3( p->points[i].x, p->points[i].y, 0.0 )); osg::ref_ptr geometry = new osg::Geometry; geometry->setVertexArray(coords.get()); @@ -418,10 +424,10 @@ void ESRIShapeParser::_process( const std::vector &polyms ) std::vector::const_iterator p; for( p = polyms.begin(); p != polyms.end(); p++ ) { - ArrayHelper coords(_useDouble); + osg::ref_ptr coords = new osg::Vec3Array; int i; for( i = 0; i < p->numPoints; i++ ) - coords.add( p->points[i].x, p->points[i].y, 0.0 ); + coords->push_back( osg::Vec3( p->points[i].x, p->points[i].y, 0.0 )); osg::ref_ptr geometry = new osg::Geometry; geometry->setVertexArray(coords.get()); @@ -447,8 +453,8 @@ void ESRIShapeParser::_process( const std::vector &ptzs ) std::vector::const_iterator p; for( p = ptzs.begin(); p != ptzs.end(); p++ ) { - ArrayHelper coords(_useDouble); - coords.add( p->x, p->y, p->z ); + osg::ref_ptr coords = new osg::Vec3Array; + coords->push_back( osg::Vec3( p->x, p->y, p->z )); osg::ref_ptr geometry = new osg::Geometry; geometry->setVertexArray(coords.get()); geometry->addPrimitiveSet( new osg::DrawArrays(osg::PrimitiveSet::POINTS, 0, 1)); @@ -465,15 +471,15 @@ void ESRIShapeParser::_process( const std::vector &mptzs std::vector::const_iterator p; for( p = mptzs.begin(); p != mptzs.end(); p++ ) { - ArrayHelper coords(_useDouble); + osg::ref_ptr coords = new osg::Vec3Array; // Here is where we would use the 'M' (?) for( int i = 0; i < p->numPoints ; i++ ) - coords.add( p->points[i].x, p->points[i].y, p->zArray[i] ); + coords->push_back( osg::Vec3( p->points[i].x, p->points[i].y, p->zArray[i] )); osg::ref_ptr geometry = new osg::Geometry; geometry->setVertexArray(coords.get()); - geometry->addPrimitiveSet( new osg::DrawArrays(osg::PrimitiveSet::POINTS, 0, coords.size())); + geometry->addPrimitiveSet( new osg::DrawArrays(osg::PrimitiveSet::POINTS, 0, coords->size())); _geode->addDrawable( geometry.get() ); } @@ -486,11 +492,11 @@ void ESRIShapeParser::_process(const std::vector &linezs ) std::vector::const_iterator p; for( p = linezs.begin(); p != linezs.end(); p++ ) { - ArrayHelper coords(_useDouble); + osg::ref_ptr coords = new osg::Vec3Array; int i; for( i = 0; i < p->numPoints; i++ ) - coords.add( p->points[i].x, p->points[i].y, p->zArray[i] ); + coords->push_back( osg::Vec3( p->points[i].x, p->points[i].y, p->zArray[i] )); osg::ref_ptr geometry = new osg::Geometry; geometry->setVertexArray(coords.get()); @@ -516,11 +522,11 @@ void ESRIShapeParser::_process( const std::vector &polyzs ) std::vector::const_iterator p; for( p = polyzs.begin(); p != polyzs.end(); p++ ) { - ArrayHelper coords(_useDouble); + osg::ref_ptr coords = new osg::Vec3Array; int i; for( i = 0; i < p->numPoints; i++ ) - coords.add( p->points[i].x, p->points[i].y, p->zArray[i] ); + coords->push_back( osg::Vec3( p->points[i].x, p->points[i].y, p->zArray[i] )); osg::ref_ptr geometry = new osg::Geometry; geometry->setVertexArray(coords.get()); @@ -546,11 +552,11 @@ void ESRIShapeParser::_process( const std::vector &mpatch std::vector::const_iterator p; for( p = mpatches.begin(); p != mpatches.end(); p++ ) { - ArrayHelper coords(_useDouble); + osg::ref_ptr coords = new osg::Vec3Array; int i; for( i = 0; i < p->numPoints; i++ ) - coords.add( p->points[i].x, p->points[i].y, p->zArray[i] ); + coords->push_back( osg::Vec3( p->points[i].x, p->points[i].y, p->zArray[i] )); osg::ref_ptr geometry = new osg::Geometry; geometry->setVertexArray(coords.get());