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 class vec3d;
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
00109
00113 virtual void changed(BitVector whichField,
00114 UInt32 origin);
00115
00117
00121 virtual void dump( UInt32 uiIndent = 0,
00122 const BitVector bvFlags = 0) const;
00123
00126
00127 protected:
00128
00129 static const UInt32 TESSELLATE = 0x0001;
00130 static const UInt32 RETESSELLATE = 0x0002;
00131 static const UInt32 DONTTESSELLATE = 0x0004;
00132
00133
00134
00135
00139 Surface(void);
00140 Surface(const Surface &source);
00141
00143
00147 virtual ~Surface(void);
00148
00150
00154
00155 void tessellate(void);
00156
00157 void reTessellate(void);
00158 Int32 convertSurface( void );
00159 Int32 tessellateSurface( std::vector< SimplePolygon > &triangles,
00160 std::vector< Pnt3f > &gverts,
00161 std::vector< Vec3f > &norms );
00162 Int32 tessellateSurface( std::vector< SimplePolygon > &triangles,
00163 std::vector< Pnt3f > &gverts,
00164 std::vector< Vec3f > &norms,
00165 std::vector< Pnt2f > &texcoords );
00166 Int32 tessellateSurface( std::vector< SimplePolygon > &triangles,
00167 std::vector< Pnt3f > &gverts,
00168 std::vector< Pnt2f > &texcoords );
00169
00170 Int32 buildSurface ( std::vector< SimplePolygon > &triangles,
00171 std::vector< Pnt3f > &gverts,
00172 std::vector< Vec3f > &norms,
00173 std::vector< Pnt2f > &texcoords );
00174
00175 bool checkOrient( UInt32 ui_v1, UInt32 ui_v2, UInt32 ui_v3,
00176 std::vector< Pnt3f > &m_vclGlobalVertices,
00177 std::vector< Vec3f > &m_vclNormal );
00178
00179
00180 bool updateError( Pnt3f viewPos, Real64 halfPixelSize );
00181 void FindClosestPoint( Vec3f& rDist, const Pnt3f viewPos ) const;
00182 void FindClosestPointExact( Vec3f& rDist, const Pnt3f viewPos ) const;
00183
00184 void onCreate(const Surface *source = NULL);
00185
00186 void handleGL(Window* win, UInt32 idstatus);
00187
00188 void adjustVolume(Volume & volume);
00189
00190 virtual Action::ResultE drawPrimitives (DrawActionBase * action );
00191
00192
00193 private:
00194
00195 friend class FieldContainer;
00196 friend class SurfaceBase;
00197
00198
00199
00200
00201 BSplineTrimmedSurface *_trimmedSurface;
00202 CNurbsPatchSurface *_surfacePatch;
00203
00204 Pnt3d _min;
00205 Pnt3d _max;
00206 Pnt2d _minParam;
00207 Pnt2d _maxParam;
00208
00209 static void initMethod(void);
00210
00211
00212
00213
00214 void operator =(const Surface &source);
00215 };
00216
00217 typedef Surface *SurfaceP;
00218
00219 OSG_END_NAMESPACE
00220
00221 #include "OSGSurface.inl"
00222 #include "OSGSurfaceBase.inl"
00223
00224 #define OSGSURFACE_HEADER_CVSID "@(#)$Id: FCTemplate_h.h,v 1.13 2001/10/30 22:26:17 dirk Exp $"
00225
00226 #endif