nurbsSub.h

00001 /*=============================================================================
00002         File: nurbsSub.h
00003      Purpose:       
00004     Revision: $Id: nurbsSub.h,v 1.2 2002/05/13 21:07:46 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 "nurbsS.h"
00030 #include <vector>
00031 #include <iostream>
00032 
00035 namespace PLib {
00036   
00052   template <class T>
00053     struct SurfSample {
00054       Point_nD<T,3> point ; 
00055       Point_nD<T,3> normal ; 
00056       T normLen ; 
00057       T u,v ; 
00058 
00059       SurfSample<T>& operator=(const SurfSample<T>& s) ;
00060 
00061       SurfSample() : normLen(-1),u(0),v(0) {;}
00062 
00063       static T epsilon ;
00064     };
00065 
00066 
00067 
00078   template <class T>
00079     class RenderMesh {
00080     public:
00081       //virtual ~RenderMesh() = 0 ; 
00082       virtual void drawHeader() = 0;
00083       virtual void drawTriangle(const SurfSample<T>&, const SurfSample<T>&, const SurfSample<T>&) = 0;
00084       virtual void drawFooter() = 0;
00085       virtual void screenProject(const HPoint_nD<T,3> &worldPt, Point_nD<T,3> &screenPt ) = 0 ; 
00086     };
00087 
00088 
00089   template <class T> class NurbSurface ;
00090 
00108   template <class T>
00109     struct NurbsSubSurface  {
00110     public:
00111       NurbsSubSurface(const NurbsSurface<T,3>& s) ;
00112       ~NurbsSubSurface() ;
00113 
00114       void drawSubdivisionPS(ostream& os, T tolerance) ;
00115       void drawSubdivisionPS(const char* f, T tolerance) ;
00116 
00117       void drawSubdivisionVRML(ostream& os, T tolerance, const Color& col=Color(0,0,255)) ;
00118       void drawSubdivisionVRML(const char* f, T tolerance, const Color& col=Color(0,0,255)) ;
00119 
00120       void drawSubdivisionVRML97(ostream& os, T tolerance, const Color& col=Color(0,0,255)) ;
00121       void drawSubdivisionVRML97(const char* f, T tolerance, const Color& col=Color(0,0,255)) ;
00122 
00123       //void drawSubdivisionPoints(deque<Point_nD<T,3> > &pnts, T tolerance) ;
00124       void drawSubdivisionPoints(BasicArray<Point_nD<T,3> > &pnts, T tolerance) ;
00125       void drawSubdivisionPoints(T tolerance) ;
00126 
00127     protected:
00128 
00129       void drawSubdivision(T tolerance) ;
00130       void initSurf() ;
00131       RenderMesh<T> *render;
00132       const NurbsSurface<T,3> &rsurf ; 
00133       NurbSurface<T> *surf ;
00134    };
00135   
00136 
00144   template <class T>
00145     class RenderMeshPS : public RenderMesh<T> {
00146     public:
00147       RenderMeshPS(ostream& os): out(os) {;}
00148       virtual ~RenderMeshPS() {;}
00149       virtual void drawHeader() ;
00150       virtual void drawTriangle( const SurfSample<T> &v0, const SurfSample<T> &v1, const SurfSample<T> & v2 );
00151       void drawLine( const SurfSample<T> &v0, const SurfSample<T> &v1);
00152       virtual void drawFooter() ;
00153       virtual void screenProject(const HPoint_nD<T,3> &worldPt, Point_nD<T,3> &screenPt ) ; 
00154     protected:
00155       ostream& out ;
00156     };
00157 
00158 
00159   //typedef deque<int> IndexSetVector ;
00160 
00168   template <class T>
00169     class RenderMeshVRML : public RenderMesh<T> {
00170     public:
00171       RenderMeshVRML(ostream& os,const Color& col): out(os), color(col) {;}
00172       virtual ~RenderMeshVRML() { ; }
00173       virtual void drawHeader() ;
00174       virtual void drawTriangle( const SurfSample<T> &v0, const SurfSample<T> &v1, const SurfSample<T> & v2 );
00175       virtual void drawFooter() ;
00176       virtual void screenProject(const HPoint_nD<T,3> &worldPt, Point_nD<T,3> &screenPt ) ; 
00177     protected:
00178       int size ;
00179       ostream &out ;
00180       Color color ; 
00181     };
00182 
00190   template <class T>
00191     class RenderMeshVRML97 : public RenderMesh<T> {
00192     public:
00193       RenderMeshVRML97(ostream& os,const Color& col): out(os), color(col) { init = 1 ;}
00194       virtual ~RenderMeshVRML97() { ; }
00195       virtual void drawHeader() ;
00196       virtual void drawTriangle( const SurfSample<T> &v0, const SurfSample<T> &v1, const SurfSample<T> & v2 );
00197       virtual void drawFooter() ;
00198       virtual void screenProject(const HPoint_nD<T,3> &worldPt, Point_nD<T,3> &screenPt ) ; 
00199     protected:
00200       int size ;
00201       ostream &out ;
00202       Color color ; 
00203       Point_nD<T,3> p_min,p_max ; 
00204       int init ;
00205     };
00206 
00217   template <class T>
00218     class RenderMeshPoints : public RenderMesh<T> {
00219     public:
00220       //RenderMeshPoints(deque<Point_nD<T,3> >& pts): points(pts) {;}
00221       RenderMeshPoints(BasicArray<Point_nD<T,3> >& pts): points(pts) {;}
00222       virtual ~RenderMeshPoints() {; }
00223       virtual void drawHeader() ;
00224       virtual void drawTriangle( const SurfSample<T> &v0, const SurfSample<T> &v1, const SurfSample<T> & v2 );
00225       virtual void drawFooter() ;
00226       virtual void screenProject(const HPoint_nD<T,3> &worldPt, Point_nD<T,3> &screenPt ) ; 
00227     protected:
00228       //deque<Point_nD<T,3> > &points ;
00229       //vector<Point_nD<T,3> > &points ;
00230       BasicArray<Point_nD<T,3> > &points;
00231     };
00232 
00233 
00234   
00235 
00236 } // end namespace
00237 
00238 
00239 #endif

Generated on Tue Jun 20 07:10:14 2006 for NURBS++ by  doxygen 1.4.6