root/OpenSceneGraph/trunk/src/osgPlugins/ply/ReaderWriterPLY.cpp @ 10012

Revision 10012, 2.9 kB (checked in by robert, 5 years ago)

From Santosh Gaikwad, ply plugin, based on Equalizer and other LGPL compatible sources.

"Attached is the osg-plugin for reading ply ( Stanford Triangle Format ) file. I have written the plugin according to OSG standard and have also added cmake build system. The plugin is working fine on both Linux and Windows and should behave similarly on other OS as well."

"I developed this plugin while working on a project based on Equalizer. So VertexData? which I am using is taken from equalizer and modified to make them work as separate OSG plugin.
Before contributing this plugin to OSG community, I asked project manager of Equalizer project Stefen regarding potential licensing issues and this is what he has said

"The kd-Tree (VertexBuffer?*) is LGPL-licensed, and the base ply loader (ply*) is BSD. As long as you leave the copyright notices intact, there is no issue."

so I think using these files in OSG should not be a problem.

As far as author of ReaderWriterPLY.cpp is concerned I am the author. I am working for Darshan3d which is a subsidiary of VizExperts? thats why I have put VizExperts? copyright."

RevLine 
[10012]1/*
2 * PLY  ( Stanford Triangle Format )  File Loader for OSG
3 * Copyright (C) 2009 by VizExperts Limited
4 * All rights reserved.
5 *
6 * This program is  free  software;  you can redistribute it and/or modify it
7 * under the terms of the  GNU Lesser General Public License  as published by
8 * the  Free Software Foundation;  either version 2.1 of the License,  or (at
9 * your option) any later version.
10 *
11 * This  program  is  distributed in  the  hope that it will  be useful,  but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or  FITNESS FOR A  PARTICULAR PURPOSE.  See the  GNU Lesser General Public 
14 * License for more details.
15 *
16 * You should  have received  a copy of the GNU Lesser General Public License
17 * along with  this program;  if not, write to the  Free Software Foundation,
18 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21#include <osgDB/Registry>
22#include <osgDB/ReadFile>
23#include <osgDB/FileUtils>
24#include <osgDB/FileNameUtils>
25
26
27#include "vertexData.h"
28
29using namespace osg;
30using namespace osgDB;
31using namespace std;
32
33///////////////////////////////////////////////////////////////////////////////
34//!
35//! \class ReaderWriterPLY
36//! \brief This is the Reader for the ply file format
37//!
38//////////////////////////////////////////////////////////////////////////////
39class ReaderWriterPLY : public osgDB::ReaderWriter
40{
41public:
42    ReaderWriterPLY()
43    {
44        supportsExtension("ply","Stanford Triangle Format");
45    }
46
47    virtual const char* className() { return "ReaderWriterPLY"; }
48    virtual ReadResult readNode(const std::string& fileName, const osgDB::ReaderWriter::Options*) const;
49protected:
50};
51
52// register with Registry to instantiate the above reader/writer.
53REGISTER_OSGPLUGIN(ply, ReaderWriterPLY)
54
55///////////////////////////////////////////////////////////////////////////////
56//!
57//! \brief Function which is called when any ply file is requested to load in
58//! \osgDB. Load read ply file and if it successes return the osg::Node
59//!
60///////////////////////////////////////////////////////////////////////////////
61osgDB::ReaderWriter::ReadResult ReaderWriterPLY::readNode(const std::string& filename, const osgDB::ReaderWriter::Options* options) const
62{
63    // Get the file extension
64    std::string ext = osgDB::getFileExtension(filename);
65   
66    // If the file extension does not support then return that file is not handled
67    if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
68
69    // Check whether or not file exist or not 
70    std::string fileName = osgDB::findDataFile(filename, options);
71    if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
72
73    //Instance of vertex data which will read the ply file and convert in to osg::Node
74    ply::VertexData vertexData;
75    osg::Node* node = vertexData.readPlyFile(filename.c_str());
76
77    if (node)
78        return node;
79
80    return ReadResult::FILE_NOT_HANDLED;
81}
Note: See TracBrowser for help on using the browser.