| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | |
|---|
| 24 | #include <osg/Notify> |
|---|
| 25 | #include <osg/Endian> |
|---|
| 26 | |
|---|
| 27 | #include <osgDB/Registry> |
|---|
| 28 | #include <osgDB/ReadFile> |
|---|
| 29 | #include <osgDB/FileNameUtils> |
|---|
| 30 | #include <osgDB/FileUtils> |
|---|
| 31 | |
|---|
| 32 | #include <osgUtil/TriStripVisitor> |
|---|
| 33 | #include <osgUtil/SmoothingVisitor> |
|---|
| 34 | #include <osg/TriangleFunctor> |
|---|
| 35 | |
|---|
| 36 | #include <osg/Geode> |
|---|
| 37 | #include <osg/Geometry> |
|---|
| 38 | |
|---|
| 39 | #include <stdio.h> |
|---|
| 40 | #include <sys/types.h> |
|---|
| 41 | #include <sys/stat.h> |
|---|
| 42 | |
|---|
| 43 | #include <string.h> |
|---|
| 44 | |
|---|
| 45 | |
|---|
| 46 | |
|---|
| 47 | |
|---|
| 48 | class ReaderWriterSTL : public osgDB::ReaderWriter |
|---|
| 49 | { |
|---|
| 50 | public: |
|---|
| 51 | ReaderWriterSTL() |
|---|
| 52 | { |
|---|
| 53 | supportsExtension("stl","STL binary format"); |
|---|
| 54 | supportsExtension("sta","STL ASCII format"); |
|---|
| 55 | supportsOption("smooth", "run SmoothingVisitor"); |
|---|
| 56 | supportsOption("separateFiles", "Save every geode in a different file. Can be a Huge amount of Files!!!"); |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | virtual const char* className() const { |
|---|
| 60 | return "STL Reader"; |
|---|
| 61 | } |
|---|
| 62 | |
|---|
| 63 | virtual ReadResult readNode(const std::string& fileName, const osgDB::ReaderWriter::Options*) const; |
|---|
| 64 | virtual WriteResult writeNode(const osg::Node& ,const std::string& ,const Options* =NULL) const ; |
|---|
| 65 | private: |
|---|
| 66 | |
|---|
| 67 | struct ReaderObject |
|---|
| 68 | { |
|---|
| 69 | ReaderObject(): |
|---|
| 70 | _generateNormal(true), |
|---|
| 71 | _numFacets(0) {} |
|---|
| 72 | |
|---|
| 73 | bool _generateNormal; |
|---|
| 74 | unsigned int _numFacets; |
|---|
| 75 | |
|---|
| 76 | osg::ref_ptr<osg::Vec3Array> _vertex; |
|---|
| 77 | osg::ref_ptr<osg::Vec3Array> _normal; |
|---|
| 78 | osg::ref_ptr<osg::Vec4Array> _color; |
|---|
| 79 | |
|---|
| 80 | bool readStlAscii(FILE* fp); |
|---|
| 81 | bool readStlBinary(FILE* fp); |
|---|
| 82 | }; |
|---|
| 83 | |
|---|
| 84 | class CreateStlVisitor : public osg::NodeVisitor { |
|---|
| 85 | public: |
|---|
| 86 | |
|---|
| 87 | CreateStlVisitor( std::string const & fout, const osgDB::ReaderWriter::Options* options = 0): osg::NodeVisitor( osg::NodeVisitor::TRAVERSE_ACTIVE_CHILDREN ), counter(0), m_fout(fout), m_options(options) |
|---|
| 88 | { |
|---|
| 89 | if (options && (options->getOptionString() == "separateFiles")) |
|---|
| 90 | { |
|---|
| 91 | osg::notify(osg::INFO) << "ReaderWriterSTL::writeNode: Files are seperated written" << std::endl; |
|---|
| 92 | } else { |
|---|
| 93 | m_f = new std::ofstream(m_fout.c_str()); |
|---|
| 94 | *m_f << "solid " << counter << std::endl; |
|---|
| 95 | } |
|---|
| 96 | }; |
|---|
| 97 | |
|---|
| 98 | std::string i2s( int i) { |
|---|
| 99 | char buf[16]; |
|---|
| 100 | sprintf(buf,"%d",i); |
|---|
| 101 | return buf; |
|---|
| 102 | } |
|---|
| 103 | |
|---|
| 104 | virtual void apply( osg::Geode& node ){ |
|---|
| 105 | osg::Matrix mat = osg::computeLocalToWorld( getNodePath() ); |
|---|
| 106 | |
|---|
| 107 | if (m_options && (m_options->getOptionString() == "separateFiles")) { |
|---|
| 108 | std::string sepFile = m_fout + i2s(counter); |
|---|
| 109 | m_f = new std::ofstream(sepFile.c_str()); |
|---|
| 110 | *m_f << "solid " << std::endl; |
|---|
| 111 | } |
|---|
| 112 | |
|---|
| 113 | for ( unsigned int i = 0; i < node.getNumDrawables(); ++i ) { |
|---|
| 114 | osg::TriangleFunctor<PushPoints> tf; |
|---|
| 115 | tf.m_stream = m_f; |
|---|
| 116 | tf.m_mat = mat; |
|---|
| 117 | node.getDrawable( i )->accept( tf ); |
|---|
| 118 | } |
|---|
| 119 | |
|---|
| 120 | if (m_options && (m_options->getOptionString() == "separateFiles")) { |
|---|
| 121 | *m_f << "endsolid " << std::endl; |
|---|
| 122 | m_f->close(); |
|---|
| 123 | delete m_f; |
|---|
| 124 | } |
|---|
| 125 | |
|---|
| 126 | ++counter; |
|---|
| 127 | traverse(node); |
|---|
| 128 | |
|---|
| 129 | } |
|---|
| 130 | |
|---|
| 131 | ~CreateStlVisitor() { |
|---|
| 132 | if (m_options && (m_options->getOptionString() == "separateFiles")) { |
|---|
| 133 | osg::notify(osg::INFO) << "ReaderWriterSTL::writeNode: " << counter-1 << "Files were written" << std::endl; |
|---|
| 134 | } else { |
|---|
| 135 | *m_f << "endsolid " << std::endl; |
|---|
| 136 | m_f->close(); |
|---|
| 137 | delete m_f; |
|---|
| 138 | } |
|---|
| 139 | } |
|---|
| 140 | private: |
|---|
| 141 | int counter; |
|---|
| 142 | std::ofstream* m_f; |
|---|
| 143 | std::string m_fout; |
|---|
| 144 | osgDB::ReaderWriter::Options const * m_options; |
|---|
| 145 | |
|---|
| 146 | |
|---|
| 147 | struct PushPoints { |
|---|
| 148 | std::ofstream* m_stream; |
|---|
| 149 | osg::Matrix m_mat; |
|---|
| 150 | inline void operator () ( const osg::Vec3& _v1, const osg::Vec3& _v2, const osg::Vec3& _v3, bool treatVertexDataAsTemporary ) { |
|---|
| 151 | osg::Vec3 v1 = _v1 * m_mat; |
|---|
| 152 | osg::Vec3 v2 = _v2 * m_mat; |
|---|
| 153 | osg::Vec3 v3 = _v3 * m_mat; |
|---|
| 154 | osg::Vec3 vV1V2 = v2-v1; |
|---|
| 155 | osg::Vec3 vV1V3 = v3-v1; |
|---|
| 156 | osg::Vec3 vNormal = vV1V2.operator ^(vV1V3); |
|---|
| 157 | *m_stream << "facet normal " << vNormal[0] << " " << vNormal[1] << " " << vNormal[2] << std::endl; |
|---|
| 158 | *m_stream << "outer loop" << std::endl; |
|---|
| 159 | *m_stream << "vertex " << v1[0] << " " << v1[1] << " " << v1[2] << std::endl; |
|---|
| 160 | *m_stream << "vertex " << v2[0] << " " << v2[1] << " " << v2[2] << std::endl; |
|---|
| 161 | *m_stream << "vertex " << v3[0] << " " << v3[1] << " " << v3[2] << std::endl; |
|---|
| 162 | *m_stream << "endloop" << std::endl; |
|---|
| 163 | *m_stream << "endfacet " << std::endl; |
|---|
| 164 | } |
|---|
| 165 | |
|---|
| 166 | }; |
|---|
| 167 | |
|---|
| 168 | |
|---|
| 169 | }; |
|---|
| 170 | |
|---|
| 171 | |
|---|
| 172 | |
|---|
| 173 | }; |
|---|
| 174 | |
|---|
| 175 | |
|---|
| 176 | |
|---|
| 177 | REGISTER_OSGPLUGIN(stl, ReaderWriterSTL) |
|---|
| 178 | |
|---|
| 179 | |
|---|
| 180 | |
|---|
| 181 | |
|---|
| 182 | |
|---|
| 183 | struct StlHeader { |
|---|
| 184 | char text[80]; |
|---|
| 185 | unsigned int numFacets; |
|---|
| 186 | }; |
|---|
| 187 | const unsigned int sizeof_StlHeader = 84; |
|---|
| 188 | |
|---|
| 189 | struct StlVector { |
|---|
| 190 | float x,y,z; |
|---|
| 191 | }; |
|---|
| 192 | struct StlFacet { |
|---|
| 193 | StlVector normal; |
|---|
| 194 | StlVector vertex[3]; |
|---|
| 195 | unsigned short color; |
|---|
| 196 | }; |
|---|
| 197 | const unsigned int sizeof_StlFacet = 50; |
|---|
| 198 | |
|---|
| 199 | const unsigned short StlHasColor = 0x8000; |
|---|
| 200 | const unsigned short StlColorSize = 0x1f; |
|---|
| 201 | const float StlColorDepth = float(StlColorSize); |
|---|
| 202 | |
|---|
| 203 | |
|---|
| 204 | |
|---|
| 205 | osgDB::ReaderWriter::ReadResult ReaderWriterSTL::readNode(const std::string& file, const osgDB::ReaderWriter::Options* options) const |
|---|
| 206 | { |
|---|
| 207 | std::string ext = osgDB::getLowerCaseFileExtension(file); |
|---|
| 208 | if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED; |
|---|
| 209 | |
|---|
| 210 | std::string fileName = osgDB::findDataFile( file, options ); |
|---|
| 211 | if (fileName.empty()) return ReadResult::FILE_NOT_FOUND; |
|---|
| 212 | |
|---|
| 213 | osg::notify(osg::INFO) << "ReaderWriterSTL::readNode(" << fileName.c_str() << ")\n"; |
|---|
| 214 | |
|---|
| 215 | |
|---|
| 216 | FILE* fp = osgDB::fopen(fileName.c_str(), "rb"); |
|---|
| 217 | if (!fp) { |
|---|
| 218 | return ReadResult::FILE_NOT_FOUND; |
|---|
| 219 | } |
|---|
| 220 | |
|---|
| 221 | ReaderObject readerObject; |
|---|
| 222 | |
|---|
| 223 | |
|---|
| 224 | StlHeader header; |
|---|
| 225 | if (fread((void*) &header, sizeof(header), 1, fp) != 1) { |
|---|
| 226 | fclose(fp); |
|---|
| 227 | return ReadResult::ERROR_IN_READING_FILE; |
|---|
| 228 | } |
|---|
| 229 | bool isBinary = false; |
|---|
| 230 | |
|---|
| 231 | |
|---|
| 232 | unsigned int expectFacets = header.numFacets; |
|---|
| 233 | if (osg::getCpuByteOrder() == osg::BigEndian) { |
|---|
| 234 | osg::swapBytes4((char*) &expectFacets); |
|---|
| 235 | } |
|---|
| 236 | off_t expectLen = sizeof_StlHeader + expectFacets * sizeof_StlFacet; |
|---|
| 237 | |
|---|
| 238 | struct stat stb; |
|---|
| 239 | if (fstat(fileno(fp), &stb) < 0) |
|---|
| 240 | { |
|---|
| 241 | osg::notify(osg::FATAL) << "ReaderWriterSTL::readNode: Unable to stat '" << fileName << "'" << std::endl; |
|---|
| 242 | fclose(fp); |
|---|
| 243 | return ReadResult::ERROR_IN_READING_FILE; |
|---|
| 244 | } |
|---|
| 245 | |
|---|
| 246 | if (stb.st_size == expectLen) |
|---|
| 247 | { |
|---|
| 248 | |
|---|
| 249 | readerObject._numFacets = expectFacets; |
|---|
| 250 | isBinary = true; |
|---|
| 251 | } |
|---|
| 252 | else if (strstr(header.text, "solid") != 0) |
|---|
| 253 | { |
|---|
| 254 | |
|---|
| 255 | isBinary = false; |
|---|
| 256 | } |
|---|
| 257 | else { |
|---|
| 258 | osg::notify(osg::FATAL) << "ReaderWriterSTL::readNode(" << fileName.c_str() << ") unable to determine file format" << std::endl; |
|---|
| 259 | fclose(fp); |
|---|
| 260 | return ReadResult::ERROR_IN_READING_FILE; |
|---|
| 261 | } |
|---|
| 262 | |
|---|
| 263 | if (!isBinary) |
|---|
| 264 | { |
|---|
| 265 | fclose(fp); |
|---|
| 266 | fp = osgDB::fopen(fileName.c_str(), "r"); |
|---|
| 267 | } |
|---|
| 268 | |
|---|
| 269 | |
|---|
| 270 | rewind(fp); |
|---|
| 271 | bool ok = (isBinary ? readerObject.readStlBinary(fp) : readerObject.readStlAscii(fp)); |
|---|
| 272 | fclose(fp); |
|---|
| 273 | |
|---|
| 274 | if (!ok) |
|---|
| 275 | { |
|---|
| 276 | return ReadResult::FILE_NOT_HANDLED; |
|---|
| 277 | } |
|---|
| 278 | |
|---|
| 279 | osg::notify(osg::INFO) << "STL loader found " << readerObject._numFacets << " facets" << std::endl; |
|---|
| 280 | |
|---|
| 281 | |
|---|
| 282 | |
|---|
| 283 | |
|---|
| 284 | osg::Geometry* geom = new osg::Geometry; |
|---|
| 285 | geom->setVertexArray(readerObject._vertex.get()); |
|---|
| 286 | |
|---|
| 287 | geom->setNormalArray(readerObject._normal.get()); |
|---|
| 288 | geom->setNormalBinding(osg::Geometry::BIND_PER_PRIMITIVE); |
|---|
| 289 | |
|---|
| 290 | if (readerObject._color.valid()) { |
|---|
| 291 | osg::notify(osg::INFO) << "STL file with color" << std::endl; |
|---|
| 292 | geom->setColorArray(readerObject._color.get()); |
|---|
| 293 | geom->setColorBinding(osg::Geometry::BIND_PER_PRIMITIVE); |
|---|
| 294 | } |
|---|
| 295 | |
|---|
| 296 | geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::TRIANGLES, 0, readerObject._numFacets*3)); |
|---|
| 297 | |
|---|
| 298 | osg::Geode* geode = new osg::Geode; |
|---|
| 299 | geode->addDrawable(geom); |
|---|
| 300 | |
|---|
| 301 | if (options && (options->getOptionString() == "smooth")) { |
|---|
| 302 | osgUtil::SmoothingVisitor smooter; |
|---|
| 303 | geode->accept(smooter); |
|---|
| 304 | } |
|---|
| 305 | |
|---|
| 306 | osgUtil::TriStripVisitor tristripper; |
|---|
| 307 | tristripper.stripify(*geom); |
|---|
| 308 | |
|---|
| 309 | return geode; |
|---|
| 310 | } |
|---|
| 311 | |
|---|
| 312 | |
|---|
| 313 | |
|---|
| 314 | |
|---|
| 315 | |
|---|
| 316 | |
|---|
| 317 | |
|---|
| 318 | |
|---|
| 319 | bool ReaderWriterSTL::ReaderObject::readStlAscii(FILE* fp) |
|---|
| 320 | { |
|---|
| 321 | |
|---|
| 322 | unsigned int vertexCount = 0; |
|---|
| 323 | unsigned int facetIndex[] = { 0,0,0 }; |
|---|
| 324 | unsigned int vertexIndex = 0; |
|---|
| 325 | unsigned int normalIndex = 0; |
|---|
| 326 | |
|---|
| 327 | const int MaxLineSize = 256; |
|---|
| 328 | char buf[MaxLineSize]; |
|---|
| 329 | char sx[MaxLineSize],sy[MaxLineSize],sz[MaxLineSize]; |
|---|
| 330 | |
|---|
| 331 | while (fgets(buf, sizeof(buf), fp)) { |
|---|
| 332 | |
|---|
| 333 | |
|---|
| 334 | unsigned int len = strlen(buf)-1; |
|---|
| 335 | while (len && (buf[len] == '\n' || buf[len] == '\r' || isspace(buf[len]))) { |
|---|
| 336 | buf[len--] = '\0'; |
|---|
| 337 | } |
|---|
| 338 | if (len == 0 || buf[0] == '\0') { |
|---|
| 339 | continue; |
|---|
| 340 | } |
|---|
| 341 | |
|---|
| 342 | |
|---|
| 343 | char* bp = buf; |
|---|
| 344 | while (isspace(*bp)) { |
|---|
| 345 | ++bp; |
|---|
| 346 | } |
|---|
| 347 | |
|---|
| 348 | if (strncmp(bp, "vertex", 6) == 0) |
|---|
| 349 | { |
|---|
| 350 | if (sscanf(bp+6, "%s %s %s", sx,sy,sz) == 3) { |
|---|
| 351 | if (!_vertex.valid()) |
|---|
| 352 | _vertex = new osg::Vec3Array; |
|---|
| 353 | |
|---|
| 354 | float vx = osg::asciiToFloat(sx); |
|---|
| 355 | float vy = osg::asciiToFloat(sy); |
|---|
| 356 | float vz = osg::asciiToFloat(sz); |
|---|
| 357 | |
|---|
| 358 | vertexIndex = _vertex->size(); |
|---|
| 359 | if (vertexCount < 3) { |
|---|
| 360 | _vertex->push_back(osg::Vec3(vx,vy,vz)); |
|---|
| 361 | facetIndex[vertexCount++] = vertexIndex; |
|---|
| 362 | } |
|---|
| 363 | else { |
|---|
| 364 | |
|---|
| 365 | |
|---|
| 366 | |
|---|
| 367 | |
|---|
| 368 | |
|---|
| 369 | _normal->push_back((*_normal)[normalIndex]); |
|---|
| 370 | _vertex->push_back((*_vertex)[facetIndex[0]]); |
|---|
| 371 | _vertex->push_back((*_vertex)[facetIndex[2]]); |
|---|
| 372 | _vertex->push_back(osg::Vec3(vx,vy,vz)); |
|---|
| 373 | facetIndex[1] = facetIndex[2]; |
|---|
| 374 | facetIndex[2] = vertexIndex; |
|---|
| 375 | _numFacets++; |
|---|
| 376 | } |
|---|
| 377 | } |
|---|
| 378 | } |
|---|
| 379 | else if (strncmp(bp, "facet", 5) == 0) |
|---|
| 380 | { |
|---|
| 381 | if (sscanf(bp+5, "%*s %s %s %s", sx,sy,sz) == 3) { |
|---|
| 382 | |
|---|
| 383 | float nx = osg::asciiToFloat(sx); |
|---|
| 384 | float ny = osg::asciiToFloat(sy); |
|---|
| 385 | float nz = osg::asciiToFloat(sz); |
|---|
| 386 | |
|---|
| 387 | if (!_normal.valid()) |
|---|
| 388 | _normal = new osg::Vec3Array; |
|---|
| 389 | |
|---|
| 390 | osg::Vec3 normal(nx,ny,nz); |
|---|
| 391 | normal.normalize(); |
|---|
| 392 | |
|---|
| 393 | normalIndex = _normal->size(); |
|---|
| 394 | _normal->push_back(normal); |
|---|
| 395 | |
|---|
| 396 | _numFacets++; |
|---|
| 397 | vertexCount = 0; |
|---|
| 398 | } |
|---|
| 399 | } |
|---|
| 400 | else if (strncmp(bp, "solid", 5) == 0) { |
|---|
| 401 | osg::notify(osg::INFO) << "STL loader parsing '" << bp + 6 << "'" << std::endl; |
|---|
| 402 | } |
|---|
| 403 | } |
|---|
| 404 | |
|---|
| 405 | return true; |
|---|
| 406 | } |
|---|
| 407 | |
|---|
| 408 | bool ReaderWriterSTL::ReaderObject::readStlBinary(FILE* fp) |
|---|
| 409 | { |
|---|
| 410 | |
|---|
| 411 | ::fseek(fp, sizeof_StlHeader, SEEK_SET); |
|---|
| 412 | |
|---|
| 413 | StlFacet facet; |
|---|
| 414 | for (unsigned int i = 0; i < _numFacets; ++i) { |
|---|
| 415 | |
|---|
| 416 | if (::fread((void*) &facet, sizeof_StlFacet, 1, fp) != 1) { |
|---|
| 417 | osg::notify(osg::FATAL) << "ReaderWriterSTL::readStlBinary: Failed to read facet " << i << std::endl; |
|---|
| 418 | return false; |
|---|
| 419 | } |
|---|
| 420 | |
|---|
| 421 | |
|---|
| 422 | if (!_vertex) |
|---|
| 423 | _vertex = new osg::Vec3Array; |
|---|
| 424 | osg::Vec3 v0(facet.vertex[0].x,facet.vertex[0].y,facet.vertex[0].z); |
|---|
| 425 | osg::Vec3 v1(facet.vertex[1].x,facet.vertex[1].y,facet.vertex[1].z); |
|---|
| 426 | osg::Vec3 v2(facet.vertex[2].x,facet.vertex[2].y,facet.vertex[2].z); |
|---|
| 427 | _vertex->push_back(v0); |
|---|
| 428 | _vertex->push_back(v1); |
|---|
| 429 | _vertex->push_back(v2); |
|---|
| 430 | |
|---|
| 431 | |
|---|
| 432 | osg::Vec3 normal; |
|---|
| 433 | if (_generateNormal) { |
|---|
| 434 | osg::Vec3 d01 = v1 - v0; |
|---|
| 435 | osg::Vec3 d02 = v2 - v0; |
|---|
| 436 | normal = d01 ^ d02; |
|---|
| 437 | normal.normalize(); |
|---|
| 438 | } |
|---|
| 439 | else { |
|---|
| 440 | normal.set(facet.normal.x,facet.normal.y,facet.normal.z); |
|---|
| 441 | } |
|---|
| 442 | if (!_normal.valid()) |
|---|
| 443 | _normal = new osg::Vec3Array; |
|---|
| 444 | _normal->push_back(normal); |
|---|
| 445 | |
|---|
| 446 | |
|---|
| 447 | |
|---|
| 448 | |
|---|
| 449 | |
|---|
| 450 | if (facet.color & StlHasColor) { |
|---|
| 451 | if (!_color) { |
|---|
| 452 | _color = new osg::Vec4Array; |
|---|
| 453 | } |
|---|
| 454 | float r = ((facet.color >> 10) & StlColorSize) / StlColorDepth; |
|---|
| 455 | float g = ((facet.color >> 5) & StlColorSize) / StlColorDepth; |
|---|
| 456 | float b = (facet.color & StlColorSize) / StlColorDepth; |
|---|
| 457 | _color->push_back(osg::Vec4(r,g,b,1.0f)); |
|---|
| 458 | } |
|---|
| 459 | } |
|---|
| 460 | |
|---|
| 461 | return true; |
|---|
| 462 | } |
|---|
| 463 | |
|---|
| 464 | osgDB::ReaderWriter::WriteResult ReaderWriterSTL::writeNode(const osg::Node& node,const std::string& fileName, const Options* opts) const |
|---|
| 465 | { |
|---|
| 466 | if (fileName.empty()) return WriteResult::FILE_NOT_HANDLED; |
|---|
| 467 | |
|---|
| 468 | std::string ext = osgDB::getLowerCaseFileExtension(fileName); |
|---|
| 469 | if (ext != "stl" ) |
|---|
| 470 | { |
|---|
| 471 | |
|---|
| 472 | osg::notify(osg::INFO) << "ReaderWriterSTL::writeNode: Only STL-ASCII-files supported'" << std::endl; |
|---|
| 473 | return WriteResult::FILE_NOT_HANDLED; |
|---|
| 474 | } |
|---|
| 475 | |
|---|
| 476 | try { |
|---|
| 477 | CreateStlVisitor createStlVisitor( fileName, opts ); |
|---|
| 478 | const_cast<osg::Node&>(node).accept( createStlVisitor ); |
|---|
| 479 | } catch(...) { |
|---|
| 480 | return WriteResult::ERROR_IN_WRITING_FILE; |
|---|
| 481 | } |
|---|
| 482 | |
|---|
| 483 | return WriteResult::FILE_SAVED; |
|---|
| 484 | } |
|---|