Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

OSGSurface.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002  *                           OpenSG NURBS Library                            *
00003  *                                                                           *
00004  *                                                                           *
00005  * Copyright (C) 2001-2004 by the University of Bonn, Computer Graphics Group*
00006  *                                                                           *
00007  *                         http://cg.cs.uni-bonn.de/                         *
00008  *                                                                           *
00009  * contact: edhellon@cs.uni-bonn.de, guthe@cs.uni-bonn.de, rk@cs.uni-bonn.de *
00010  *                                                                           *
00011 \*---------------------------------------------------------------------------*/
00012 /*---------------------------------------------------------------------------*\
00013  *                                License                                    *
00014  *                                                                           *
00015  * This library is free software; you can redistribute it and/or modify it   *
00016  * under the terms of the GNU Library General Public License as published    *
00017  * by the Free Software Foundation, version 2.                               *
00018  *                                                                           *
00019  * This library is distributed in the hope that it will be useful, but       *
00020  * WITHOUT ANY WARRANTY; without even the implied warranty of                *
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
00022  * Library General Public License for more details.                          *
00023  *                                                                           *
00024  * You should have received a copy of the GNU Library General Public         *
00025  * License along with this library; if not, write to the Free Software       *
00026  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                 *
00027  *                                                                           *
00028 \*---------------------------------------------------------------------------*/
00029 /*---------------------------------------------------------------------------*\
00030  *                                Changes                                    *
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 // Forward References (for internal types)
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     /*==========================  PUBLIC  =================================*/
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     /*=========================  PROTECTED  ===============================*/
00127   protected:
00128 
00129     static const UInt32 TESSELLATE     = 0x0001;
00130     static const UInt32 RETESSELLATE   = 0x0002;
00131     static const UInt32 DONTTESSELLATE = 0x0004;
00132 
00133     // Variables should all be in SurfaceBase.
00134 
00135     /*---------------------------------------------------------------------*/
00139     Surface(void);
00140     Surface(const Surface &source);
00141 
00143     /*---------------------------------------------------------------------*/
00147     virtual ~Surface(void); 
00148 
00150     /*---------------------------------------------------------------------*/
00154     // tessellate from the beginning
00155     void tessellate(void);
00156     // only retessellate because error/delaunay mode change
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     /* protected functions for adaptive tessellation */   
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     /*==========================  PRIVATE  ================================*/
00193   private:
00194 
00195     friend class FieldContainer;
00196     friend class SurfaceBase;
00197 
00198     // private class variables
00199     // FIXME: this is UGLY, having 3 variables for almost the same thing
00200     // OK, it's just two now, but still...
00201     BSplineTrimmedSurface *_trimmedSurface;     // internal representation
00202     CNurbsPatchSurface *_surfacePatch;          // encompassing class 
00203                                                 // (tessellator class)
00204     Pnt3d   _min;                               // trimming curves BB
00205     Pnt3d   _max;
00206     Pnt2d   _minParam;                          // trimming curves BB in
00207     Pnt2d   _maxParam;                          // parameter space
00208                                                 // all the surfaces)
00209     static void initMethod(void);
00210 
00211     // private variables:
00212     // prohibit default functions (move to 'public' if you need one)
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 /* _OSGSURFACE_H_ */

Generated on Thu Aug 25 04:11:06 2005 for OpenSG by  doxygen 1.4.3