Update of /cvsroot/artoolkit/artoolkit/lib/SRC/ARvrml
In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv1943
Modified Files:
arViewerCapi.cpp arViewer.cpp arViewer.h
Log Message:
Update ARvrml for OpenVRML-0.16.1.
Index: arViewer.cpp
===================================================================
RCS file: /cvsroot/artoolkit/artoolkit/lib/SRC/ARvrml/arViewer.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** arViewer.cpp 28 May 2006 09:24:49 -0000 1.2
--- arViewer.cpp 17 Nov 2006 03:21:19 -0000 1.3
***************
*** 1,10 ****
/*
! modif:
! version 0.14.3
! remove vrmlScene since we use reference now.
! remove culling pb
*/
-
/*
*
--- 1,12 ----
/*
! Original version for VRML97-0.8.7 by Hirokazu Kato.
!
! Updated for OpenVRML-0.14.3 by Raphael Grasset.
! -remove vrmlScene since we use reference now.
! -remove culling pb
! Updated for OpenVRML-0.16.1 by Philip Lamb. 2006-11-15.
! - add arVrmlBrowser class and Boost dependencies.
*/
/*
*
***************
*** 44,48 ****
using namespace openvrml;
! arVrmlViewer::arVrmlViewer(openvrml::browser& browser) : gl::viewer(browser)
{
internal_light = true;
--- 46,141 ----
using namespace openvrml;
! arVrmlBrowser::arVrmlBrowser(): openvrml::browser(std::cout, std::cerr)
! {
! }
!
! std::auto_ptr<openvrml::resource_istream>
! arVrmlBrowser::do_get_resource(const std::string & uri)
! {
! using std::auto_ptr;
! using std::invalid_argument;
! using std::string;
! using openvrml::resource_istream;
!
! class file_resource_istream : public resource_istream {
! std::string url_;
! std::filebuf buf_;
!
! public:
! explicit file_resource_istream(const std::string & path): resource_istream(&this->buf_)
! {
! if (!this->buf_.open(path.c_str(), ios_base::in)) {
! this->setstate(ios_base::failbit);
! }
! }
!
! void url(const std::string & str) throw (std::bad_alloc)
! {
! this->url_ = str;
! }
!
! private:
! virtual const std::string do_url() const throw ()
! {
! return this->url_;
! }
!
! virtual const std::string do_type() const throw ()
! {
! //
! // A real application should use OS facilities for this. This
! // is a crude hack.
! //
! using std::find;
! using std::string;
! using boost::algorithm::iequals;
! using boost::next;
! string media_type = "application/octet-stream";
! const string::const_reverse_iterator dot_pos =
! find(this->url_.rbegin(), this->url_.rend(), '.');
! if (dot_pos == this->url_.rend()
! || next(dot_pos.base()) == this->url_.end()) {
! return media_type;
! }
! const string::const_iterator hash_pos =
! find(next(dot_pos.base()), this->url_.end(), '#');
! const string ext(dot_pos.base(), hash_pos);
! if (iequals(ext, "wrl")) {
! media_type = "model/vrml";
! } else if (iequals(ext, "x3dv")) {
! media_type = "model/x3d+vrml";
! } else if (iequals(ext, "png")) {
! media_type = "image/png";
! } else if (iequals(ext, "jpg") || iequals(ext, "jpeg")) {
! media_type = "image/jpeg";
! }
! return media_type;
! }
!
! virtual bool do_data_available() const throw ()
! {
! return !!(*this);
! }
! }; // class file_resource_istream
!
! const string scheme = uri.substr(0, uri.find_first_of(':'));
! if (scheme != "file") {
! throw invalid_argument('\"' + scheme + "\" URI scheme not supported");
! }
! //
! // file://
! // ^
! // 01234567
! //
! string path = uri.substr(uri.find_first_of('/', 7));
!
! auto_ptr<resource_istream> in(new file_resource_istream(path));
! static_cast<file_resource_istream *>(in.get())->url(uri);
!
! return in;
! }
!
!
! arVrmlViewer::arVrmlViewer() : gl::viewer::viewer()
{
internal_light = true;
***************
*** 62,66 ****
}
! arVrmlViewer::~arVrmlViewer()
{
--- 155,159 ----
}
! arVrmlViewer::~arVrmlViewer() throw()
{
***************
*** 69,73 ****
void arVrmlViewer::timerUpdate()
{
! this->update(0.0);
}
--- 162,166 ----
void arVrmlViewer::timerUpdate()
{
! this->update(0.0);
}
***************
*** 81,85 ****
void arVrmlViewer::redraw()
{
! double start = browser::current_time();
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
--- 174,178 ----
void arVrmlViewer::redraw()
{
! //double start = browser::current_time();
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
***************
*** 123,127 ****
sensitive = 0;
! this->browser.render(*this);
if (internal_light) {
--- 216,220 ----
sensitive = 0;
! browser()->render();
if (internal_light) {
Index: arViewerCapi.cpp
===================================================================
RCS file: /cvsroot/artoolkit/artoolkit/lib/SRC/ARvrml/arViewerCapi.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** arViewerCapi.cpp 1 Dec 2004 22:48:03 -0000 1.2
--- arViewerCapi.cpp 17 Nov 2006 03:21:19 -0000 1.3
***************
*** 50,54 ****
FILE *fp;
! openvrml::browser * myBrowser = 0;
char buf[256], buf1[256];
char buf2[256];
--- 50,54 ----
FILE *fp;
! openvrml::browser * myBrowser = NULL;
char buf[256], buf1[256];
char buf2[256];
***************
*** 66,70 ****
id = i;
-
if( (fp=fopen(file, "r")) == NULL ) return -1;
--- 66,69 ----
***************
*** 78,96 ****
sprintf(buf, "%s%s", buf2, buf1);
! myBrowser = new openvrml::browser(std::cout, std::cerr);
! if( !myBrowser) {fclose(fp); return -1;}
!
! std::vector<std::string> uri(1, buf);
! std::vector<std::string> parameter;
! myBrowser->load_url(uri, parameter);
! viewer[id] = new arVrmlViewer(*myBrowser);
! if(!viewer[id])
! {
delete myBrowser;
fclose(fp);
return -1;
}
! strcpy( viewer[id]->filename, buf );
get_buff(buf, 256, fp);
--- 77,99 ----
sprintf(buf, "%s%s", buf2, buf1);
! myBrowser = new arVrmlBrowser;
! if (!myBrowser) {
! fclose(fp);
! return -1;
! }
! viewer[id] = new arVrmlViewer();
! if (!viewer[id]) {
delete myBrowser;
fclose(fp);
return -1;
}
! strcpy(viewer[id]->filename, buf); // Save filename in viewer.
! myBrowser->viewer(viewer[id]);
!
! std::vector<std::string> uri(1, buf);
! std::vector<std::string> parameter;
! myBrowser->load_url(uri, parameter);
!
get_buff(buf, 256, fp);
Index: arViewer.h
===================================================================
RCS file: /cvsroot/artoolkit/artoolkit/lib/SRC/ARvrml/arViewer.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** arViewer.h 19 Nov 2004 03:26:52 -0000 1.1
--- arViewer.h 17 Nov 2006 03:21:19 -0000 1.2
***************
*** 23,35 ****
#define AR_VRMLINT_H
#include <openvrml/browser.h>
#include <openvrml/gl/viewer.h>
#include <openvrml/bounding_volume.h>
class arVrmlViewer : public openvrml::gl::viewer {
public:
! arVrmlViewer(openvrml::browser& browser);
! ~arVrmlViewer();
char filename[512];
--- 23,51 ----
#define AR_VRMLINT_H
+ #include <iostream>
+ #include <fstream>
+ #include <boost/algorithm/string/predicate.hpp>
+ #include <boost/utility.hpp>
#include <openvrml/browser.h>
#include <openvrml/gl/viewer.h>
#include <openvrml/bounding_volume.h>
+ #ifdef _WIN32
+ # include <windows.h>
+ #endif
+
+ class arVrmlBrowser : public openvrml::browser {
+ public:
+ arVrmlBrowser();
+
+ private:
+ virtual std::auto_ptr<openvrml::resource_istream>
+ do_get_resource(const std::string & uri);
+ };
class arVrmlViewer : public openvrml::gl::viewer {
public:
! arVrmlViewer();
! ~arVrmlViewer() throw ();
char filename[512];
|