fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / Contrib / Rhino3DLoader / OSGRhinoSceneFileType.cpp
bloba9183399a7e960db2a7eba4fed2f93e198da9e06
1 /*---------------------------------------------------------------------------*\
2 * OpenSG openNURBS SceneFileType *
3 * *
4 * *
5 * Copyright (C) 2007-2008 by Seac02 S.r.l. http://www.seac02.it *
6 * Copyright (C) 2008 by Patrik Mueller muellerptr@users.sourceforge.net *
7 * Copyright (C) 2008 by Akos Balazs edhellon@cs.uni-bonn.de *
8 * *
9 \*---------------------------------------------------------------------------*/
10 /*---------------------------------------------------------------------------*\
11 * License *
12 * *
13 * This library is free software; you can redistribute it and/or modify it *
14 * under the terms of the GNU Library General Public License as published *
15 * by the Free Software Foundation, version 2. *
16 * *
17 * This library is distributed in the hope that it will be useful, but *
18 * WITHOUT ANY WARRANTY; without even the implied warranty of *
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
20 * Library General Public License for more details. *
21 * *
22 * You should have received a copy of the GNU Library General Public *
23 * License along with this library; if not, write to the Free Software *
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
25 * *
26 \*---------------------------------------------------------------------------*/
27 /*---------------------------------------------------------------------------*\
28 * Changes *
29 * *
30 * *
31 * *
32 * *
33 * *
34 * *
35 \*---------------------------------------------------------------------------*/
37 //-------------------------------
38 // Includes
39 //-------------------------------
41 #if __GNUC__ >= 4 || __GNUC_MINOR__ >=3
42 #pragma GCC diagnostic warning "-Wold-style-cast"
43 #pragma GCC diagnostic warning "-Wignored-qualifiers"
44 #endif
46 #include <stdlib.h>
47 #include <stdio.h>
49 #include <OSGConfig.h>
51 #include <iostream>
52 #include <fstream>
54 #include <OSGLog.h>
56 #include "OSGSceneFileHandler.h"
57 #include "OSGRhinoSceneFileType.h"
59 #include "OSGrhino2osb.h"
61 OSG_BEGIN_NAMESPACE
63 #if defined(OSG_WIN32_ICL) && !defined(OSG_CHECK_FIELDSETARG)
64 #pragma warning (disable : 383)
65 #endif
68 /*! \class OSG::RhinoSceneFileType
69 \ingroup GrpSystemFileIO
73 /*****************************
74 * Types
75 *****************************/
76 // Static Class Varible implementations:
78 const Char8 *RhinoSceneFileType::_suffixA[] = { "3dm" };
80 RhinoSceneFileType RhinoSceneFileType::_the(_suffixA,
81 sizeof(_suffixA),
82 false,
83 10,
84 SceneFileType::OSG_READ_SUPPORTED);
86 NodeTransitPtr RhinoSceneFileType::read3DM(const Char8 *fileName) const
88 bool bImportRenderMeshes = false;
89 int iCurveInterpolationSteps = 100;
90 float fTessellationError = 0.1f;
91 bool bDoTessellation = true;
93 IOFileTypeBase::getOptionAs<Int32 >(this->getOptions(),
94 "curveInterpolationSteps",
95 iCurveInterpolationSteps);
97 IOFileTypeBase::getOptionAs<Real32>(this->getOptions(),
98 "tesselationError",
99 fTessellationError );
101 IOFileTypeBase::getOptionAs<bool> (this->getOptions(),
102 "doTessellation",
103 bDoTessellation );
105 IOFileTypeBase::getOptionAs<bool> (this->getOptions(),
106 "importRenderMeshes",
107 bImportRenderMeshes );
109 if(iCurveInterpolationSteps <= 0)
111 iCurveInterpolationSteps = 100;
114 if(fTessellationError <= 0.f)
116 fTessellationError = 0.1f;
119 rhino2osb ro(iCurveInterpolationSteps,
120 fTessellationError,
121 bDoTessellation,
122 bImportRenderMeshes );
124 NodeTransitPtr root = ro.load(fileName);
126 return root;
130 NodeTransitPtr RhinoSceneFileType::read(
131 std::istream &,
132 const Char8 *fileNameOrExtension,
133 Resolver resolver ) const
135 return read3DM(fileNameOrExtension);
138 RhinoSceneFileType::RhinoSceneFileType(const Char8 *suffixArray[],
139 UInt16 suffixByteCount,
140 bool override,
141 UInt32 overridePriority,
142 UInt32 flags) :
143 SceneFileType(suffixArray,
144 suffixByteCount,
145 override,
146 overridePriority,
147 flags )
151 RhinoSceneFileType &RhinoSceneFileType::the(void)
153 return _the;
156 const Char8 *RhinoSceneFileType::getName(void) const
158 return "Rhinoceros3D";
161 RhinoSceneFileType::~RhinoSceneFileType (void )
165 OSG_END_NAMESPACE