1 /*---------------------------------------------------------------------------*\
2 * OpenSG openNURBS SceneFileType *
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 *
9 \*---------------------------------------------------------------------------*/
10 /*---------------------------------------------------------------------------*\
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. *
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. *
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. *
26 \*---------------------------------------------------------------------------*/
28 // Some portions are based on example_gl.h in the openNURBS distribution:
30 // Copyright (c) 1993-2007 Robert McNeel & Associates. All rights reserved.
31 // Rhinoceros is a registered trademark of Robert McNeel & Assoicates.
33 // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
34 // ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
35 // MERCHANTABILITY ARE HEREBY DISCLAIMED.
37 // For complete openNURBS copyright information see <http://www.opennurbs.org>.
39 ////////////////////////////////////////////////////////////////
45 #if __GNUC__ >= 4 || __GNUC_MINOR__ >=3
46 #pragma GCC diagnostic warning "-Wold-style-cast"
47 #pragma GCC diagnostic warning "-Wignored-qualifiers"
53 #include <opennurbs/opennurbs.h>
55 #include <OSGSimpleMaterial.h>
56 #include <OSGSurface.h>
62 rhino2osb(int curveInterpolationSteps
= 100,
63 float tessError
= 0.1f
,
64 bool doTessellation
= true,
65 bool importRenderMeshes
= false);
67 virtual ~rhino2osb(void);
69 OSG::NodeTransitPtr
load(const OSG::Char8
*fileName
);
73 void doTess ( OSG::Node
*node
);
75 OSG::NodeTransitPtr
process_brep(const ON_Brep
&);
77 // optional transformation applied to curve
78 OSG::NodeTransitPtr
process_curve(const ON_Curve
&,
81 OSG::NodeTransitPtr
process_surface( const ON_Surface
& );
83 OSG::NodeTransitPtr
process_trimcurve( // low level NURBS curve render
88 const double *, // knot_vector[]
91 int = 1, // bPermitKnotScaling - If TRUE, curve knots
92 // maybe rescaled to avoid knot vectors GL
94 double * = NULL
, // knot_scale[2] - If not NULL and
95 // bPermitKnotScaling, the scaling applied to
96 // the knot vector is returned here.
97 double[][4] = NULL
// optional transformation applied to curve
100 OSG::NodeTransitPtr
process_NURBS_surface(
101 const ON_NurbsSurface
&,
102 int = 1, // bPermitKnotScaling - If TRUE,
103 // surface knots may be rescaled to
104 // avoid knot vectors GL cannot
106 double * = NULL
, // knot_scale0[2] - If not NULL and
107 // bPermitKnotScaling, the scaleing
108 // applied to the first parameter
110 double * = NULL
// knot_scale0[2] - If not NULL and
111 // bPermitKnotScaling, the scaleing
112 // applied to the second parameter
116 OSG::NodeTransitPtr
process_brepface(const ON_BrepFace
&);
118 OSG::NodeTransitPtr
convert_knots(
119 const int, // order, ON_NurbsCurve... order
120 const int, // cv_count, ON_NurbsCurve... cv count
121 const double *, // knot, ON_NurbsCurve... knot vector
122 GLfloat
*, // glknot[] - GL knot vector
123 int = 0, // bPermitScaling - TRUE if re-scaling is
125 double * = NULL
// scale[2] - If not NULL and bPermitScaling is
126 // TRUE, then the scaling parameters are
128 // ( glknot = (knot = scale[0])*scale[1] )
131 void process_material (const ONX_Model
&model
,
135 OSG::NodeTransitPtr
buildNode (const ONX_Model
&model
,
137 OSG::NodeTransitPtr
convert_surface_to_osg(const ON_NurbsSurface
&s
,
140 OSG::NodeTransitPtr
process_point (const ON_Point
*theGeo
);
141 OSG::NodeTransitPtr
process_pointcloud (const ON_PointCloud
*theGeo
);
142 OSG::NodeTransitPtr
process_pointgrid (const ON_PointGrid
*theGeo
);
143 OSG::NodeTransitPtr
process_points (const ON_Geometry
*theGeo
);
144 OSG::NodeTransitPtr
process_curve (const ON_Geometry
*theGeo
);
145 OSG::NodeTransitPtr
process_nurbscurve (const ON_NurbsCurve
*theGeo
);
146 OSG::NodeTransitPtr
process_linecurve (const ON_LineCurve
*theGeo
);
147 OSG::NodeTransitPtr
process_polylinecurve (const ON_PolylineCurve
*theGeo
);
148 OSG::NodeTransitPtr
process_mesh (const ON_Mesh
*theGeo
);
152 OSG::NodeUnrecPtr m_pRootNode
;
153 OSG::SimpleMaterialUnrecPtr m_actMaterial
;
154 OSG::SurfaceUnrecPtr m_cCurrentSurface
;
157 // member variables that influence the loading/conversion
158 int m_curveInterpolationSteps
;
159 float m_tessellationError
;
160 bool m_bDoTessellation
;
161 bool m_bImportRenderMeshes
;
163 std::map
<int, OSG::SimpleMaterialUnrecPtr
> m_materials
;
165 #endif // RHINO2OSB_H_