00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #ifndef _OSGSURFACE_H_
00040 #define _OSGSURFACE_H_
00041 #ifdef __sgi
00042 #pragma once
00043 #endif
00044
00045 #include <OSGConfig.h>
00046 #include <OSGVertexProgramChunk.h>
00047
00048 #include "OSGSurfaceBase.h"
00049
00050 OSG_BEGIN_NAMESPACE
00051
00052
00056
00057
00058
00059 class CNurbsPatchSurface;
00060 class BSplineTrimmedSurface;
00061 class BSplineTensorSurface;
00062 class SimplePolygon;
00063 class BSplineCurve2D;
00064
00065
00066
00067 class OSG_SYSTEMLIB_DLLMAPPING Surface : public SurfaceBase
00068 {
00069 private:
00070
00071 typedef SurfaceBase Inherited;
00072
00073
00074
00075 public:
00076
00077 static const osg::BitVector CurveFieldMask;
00078 static const osg::BitVector SurfaceFieldMask;
00079
00080
00084 void addCurve( UInt32 dim,
00085 std::vector<Real64>& knots,
00086 std::vector<Pnt2f>& controlpoints,
00087 bool newloop = false);
00088
00089 void addCurve( UInt32 dim,
00090 std::vector<Real64>& knots,
00091 std::vector<Pnt3f>& controlpoints,
00092 bool newloop = false);
00093
00094 void removeCurves( void );
00095
00096 SurfacePtr clone( void );
00097 void readfromtso( std::istream &infile, bool useTextures = false );
00098 void writetotso( std::ostream &outfile );
00099 UInt32 writetoobj( std::ostream &outfile, UInt32 offset );
00100
00101 Real64 getDesiredError( Pnt3f viewPos, Real64 halfPixelSize );
00102
00103 void forceTessellate(void);
00104
00105 void flip(void);
00106
00108
00112 void setControlPoints (const GeoPositionsPtr &value);
00113 void setTextureControlPoints(const GeoTexCoordsPtr &value);
00114
00115
00119 virtual void changed(BitVector whichField,
00120 UInt32 origin);
00121
00123
00127 virtual void dump( UInt32 uiIndent = 0,
00128 const BitVector bvFlags = 0) const;
00129
00132
00133 protected:
00134
00135 static const UInt32 TESSELLATE = 0x0001;
00136 static const UInt32 RETESSELLATE = 0x0002;
00137 static const UInt32 DONTTESSELLATE = 0x0004;
00138
00139
00140
00141
00145 Surface(void);
00146 Surface(const Surface &source);
00147
00149
00153 virtual ~Surface(void);
00154
00156
00160
00161 void tessellate(void);
00162
00163 void reTessellate(void);
00164 Int32 convertSurface( void );
00165 Int32 tessellateSurface( std::vector< SimplePolygon > &triangles,
00166 std::vector< Pnt3f > &gverts,
00167 std::vector< Vec3f > &norms );
00168 Int32 tessellateSurface( std::vector< SimplePolygon > &triangles,
00169 std::vector< Pnt3f > &gverts,
00170 std::vector< Vec3f > &norms,
00171 std::vector< Pnt2f > &texcoords );
00172 Int32 tessellateSurface( std::vector< SimplePolygon > &triangles,
00173 std::vector< Pnt3f > &gverts,
00174 std::vector< Pnt2f > &texcoords );
00175
00176 Int32 buildSurface ( std::vector< SimplePolygon > &triangles,
00177 std::vector< Pnt3f > &gverts,
00178 std::vector< Vec3f > &norms,
00179 std::vector< Pnt2f > &texcoords );
00180
00181 bool checkOrient( UInt32 ui_v1, UInt32 ui_v2, UInt32 ui_v3,
00182 std::vector< Pnt3f > &m_vclGlobalVertices,
00183 std::vector< Vec3f > &m_vclNormal );
00184
00185
00186 bool updateError( Pnt3f viewPos, Real64 halfPixelSize );
00187 void FindClosestPoint( Vec3f& rDist, const Pnt3f viewPos ) const;
00188 void FindClosestPointExact( Vec3f& rDist, const Pnt3f viewPos ) const;
00189
00190 void onCreate(const Surface *source = NULL);
00191 void onDestroy(void);
00192
00193 void handleGL(Window* win, UInt32 idstatus);
00194
00195 void adjustVolume(Volume & volume);
00196
00197 virtual Action::ResultE drawPrimitives (DrawActionBase * action );
00198
00199
00200 private:
00201
00202 friend class FieldContainer;
00203 friend class SurfaceBase;
00204
00205
00206
00207
00208 BSplineTrimmedSurface *_trimmedSurface;
00209 CNurbsPatchSurface *_surfacePatch;
00210
00211 Pnt3d _min;
00212 Pnt3d _max;
00213 Pnt2d _minParam;
00214 Pnt2d _maxParam;
00215
00216 static void initMethod(void);
00217
00218 void calcIndexMapping(void);
00219
00220
00221
00222
00223 void operator =(const Surface &source);
00224 };
00225
00226 typedef Surface *SurfaceP;
00227
00228 OSG_END_NAMESPACE
00229
00230 #include "OSGSurface.inl"
00231 #include "OSGSurfaceBase.inl"
00232
00233 #define OSGSURFACE_HEADER_CVSID "@(#)$Id: OSGSurface.h,v 1.3 2006-11-09 20:59:39 edhellon Exp $"
00234
00235 #endif