Main Page   Class Hierarchy   Compound List   File List   Compound Members  

nurbsSub.h

00001 /*=============================================================================
00002         File: nurbsSub.h
00003      Purpose:       
00004     Revision: $Id: nurbsSub.h,v 1.3 2003/01/13 19:42:15 philosophil Exp $
00005   Created by: Philippe Lavoie          (20 January, 1999)
00006  Modified by: 
00007 
00008  Copyright notice:
00009           Copyright (C) 1999 Philippe Lavoie
00010  
00011           This library is free software; you can redistribute it and/or
00012           modify it under the terms of the GNU Library General Public
00013           License as published by the Free Software Foundation; either
00014           version 2 of the License, or (at your option) any later version.
00015  
00016           This library is distributed in the hope that it will be useful,
00017           but WITHOUT ANY WARRANTY; without even the implied warranty of
00018           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019           Library General Public License for more details.
00020  
00021           You should have received a copy of the GNU Library General Public
00022           License along with this library; if not, write to the Free
00023           Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00024 =============================================================================*/
00025 
00026 #ifndef _NURBS_SURFACE_SUBDIVISION_
00027 #define _NURBS_SURFACE_SUBDIVISION_
00028 
00029 #include "nurbs.h"
00030 #include "nurbsS.h"
00031 #include <vector>
00032 #include <iostream>
00033 
00036 namespace PLib {
00037   
00053   template <class T>
00054     struct SurfSample {
00055       Point_nD<T,3> point ; 
00056       Point_nD<T,3> normal ; 
00057       T normLen ; 
00058       T u,v ; 
00059 
00060       SurfSample<T>& operator=(const SurfSample<T>& s) ;
00061 
00062       SurfSample() : normLen(-1),u(0),v(0) {;}
00063 
00064       static T epsilon ;
00065     };
00066 
00067 
00068 
00079   template <class T>
00080     class RenderMesh {
00081     public:
00082       //virtual ~RenderMesh() = 0 ; 
00083       virtual void drawHeader() = 0;
00084       virtual void drawTriangle(const SurfSample<T>&, const SurfSample<T>&, const SurfSample<T>&) = 0;
00085       virtual void drawFooter() = 0;
00086       virtual void screenProject(const HPoint_nD<T,3> &worldPt, Point_nD<T,3> &screenPt ) = 0 ; 
00087     };
00088 
00089 
00090   template <class T> class NurbSurface ;
00091 
00109   template <class T>
00110     struct NurbsSubSurface  {
00111     public:
00112       NurbsSubSurface(const NurbsSurface<T,3>& s) ;
00113       ~NurbsSubSurface() ;
00114 
00115       void drawSubdivisionPS(ostream& os, T tolerance) ;
00116       void drawSubdivisionPS(const char* f, T tolerance) ;
00117 
00118       void drawSubdivisionVRML(ostream& os, T tolerance, const Color& col=Color(0,0,255)) ;
00119       void drawSubdivisionVRML(const char* f, T tolerance, const Color& col=Color(0,0,255)) ;
00120 
00121       void drawSubdivisionVRML97(ostream& os, T tolerance, const Color& col=Color(0,0,255)) ;
00122       void drawSubdivisionVRML97(const char* f, T tolerance, const Color& col=Color(0,0,255)) ;
00123 
00124       //void drawSubdivisionPoints(deque<Point_nD<T,3> > &pnts, T tolerance) ;
00125       void drawSubdivisionPoints(BasicArray<Point_nD<T,3> > &pnts, T tolerance) ;
00126       void drawSubdivisionPoints(T tolerance) ;
00127 
00128     protected:
00129 
00130       void drawSubdivision(T tolerance) ;
00131       void initSurf() ;
00132       RenderMesh<T> *render;
00133       const NurbsSurface<T,3> &rsurf ; 
00134       NurbSurface<T> *surf ;
00135    };
00136   
00137 
00145   template <class T>
00146     class RenderMeshPS : public RenderMesh<T> {
00147     public:
00148       RenderMeshPS(ostream& os): out(os) {;}
00149       virtual ~RenderMeshPS() {;}
00150       virtual void drawHeader() ;
00151       virtual void drawTriangle( const SurfSample<T> &v0, const SurfSample<T> &v1, const SurfSample<T> & v2 );
00152       void drawLine( const SurfSample<T> &v0, const SurfSample<T> &v1);
00153       virtual void drawFooter() ;
00154       virtual void screenProject(const HPoint_nD<T,3> &worldPt, Point_nD<T,3> &screenPt ) ; 
00155     protected:
00156       ostream& out ;
00157     };
00158 
00159 
00160   //typedef deque<int> IndexSetVector ;
00161 
00169   template <class T>
00170     class RenderMeshVRML : public RenderMesh<T> {
00171     public:
00172       RenderMeshVRML(ostream& os,const Color& col): out(os), color(col) {;}
00173       virtual ~RenderMeshVRML() { ; }
00174       virtual void drawHeader() ;
00175       virtual void drawTriangle( const SurfSample<T> &v0, const SurfSample<T> &v1, const SurfSample<T> & v2 );
00176       virtual void drawFooter() ;
00177       virtual void screenProject(const HPoint_nD<T,3> &worldPt, Point_nD<T,3> &screenPt ) ; 
00178     protected:
00179       int size ;
00180       ostream &out ;
00181       Color color ; 
00182     };
00183 
00191   template <class T>
00192     class RenderMeshVRML97 : public RenderMesh<T> {
00193     public:
00194       RenderMeshVRML97(ostream& os,const Color& col): out(os), color(col) { init = 1 ;}
00195       virtual ~RenderMeshVRML97() { ; }
00196       virtual void drawHeader() ;
00197       virtual void drawTriangle( const SurfSample<T> &v0, const SurfSample<T> &v1, const SurfSample<T> & v2 );
00198       virtual void drawFooter() ;
00199       virtual void screenProject(const HPoint_nD<T,3> &worldPt, Point_nD<T,3> &screenPt ) ; 
00200     protected:
00201       int size ;
00202       ostream &out ;
00203       Color color ; 
00204       Point_nD<T,3> p_min,p_max ; 
00205       int init ;
00206     };
00207 
00218   template <class T>
00219     class RenderMeshPoints : public RenderMesh<T> {
00220     public:
00221       //RenderMeshPoints(deque<Point_nD<T,3> >& pts): points(pts) {;}
00222       RenderMeshPoints(BasicArray<Point_nD<T,3> >& pts): points(pts) {;}
00223       virtual ~RenderMeshPoints() {; }
00224       virtual void drawHeader() ;
00225       virtual void drawTriangle( const SurfSample<T> &v0, const SurfSample<T> &v1, const SurfSample<T> & v2 );
00226       virtual void drawFooter() ;
00227       virtual void screenProject(const HPoint_nD<T,3> &worldPt, Point_nD<T,3> &screenPt ) ; 
00228     protected:
00229       //deque<Point_nD<T,3> > &points ;
00230       //vector<Point_nD<T,3> > &points ;
00231       BasicArray<Point_nD<T,3> > &points;
00232     };
00233 
00234 
00235   
00236 
00237 } // end namespace
00238 
00239 
00240 #endif

Generated on Tue Jun 24 13:26:58 2003 for NURBS++ by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002