Main Page   Class Hierarchy   Compound List   File List   Compound Members  

surface.h

00001 /*=============================================================================
00002         File: surface.H
00003      Purpose:       
00004     Revision: $Id: surface.h,v 1.2 2002/05/13 21:07:46 philosophil Exp $
00005   Created by: Philippe Lavoie          (3 Oct, 1996)
00006  Modified by: 
00007 
00008  Copyright notice:
00009           Copyright (C) 1996-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 #ifndef _nurbs_surface_h_
00026 #define _nurbs_surface_h_
00027 
00028 #include "curve.h"
00029 
00030 #include "matrix.h"
00031 #include "color.h"
00032 
00035 namespace PLib {
00036 
00037 template <class T, int N>
00038 struct SurfParam{
00039   T u,v ; 
00040   SurfParam() : u(0), v(0) {; }
00041   SurfParam(T a, T b) : u(a), v(b) { ; }
00042 };
00043 
00044 template <class T, int N>
00045 struct InterPoint {
00046   Point_nD<T,N> tangent ;
00047   Point_nD<T,N> point ; 
00048   SurfParam<T,N> paramA ;
00049   SurfParam<T,N> paramB ; 
00050   InterPoint() : tangent(0), paramA(), paramB() { ; }
00051 
00052   InterPoint<T,N>& operator=(const InterPoint<T,N>& A) 
00053     { point = A.point ; paramA = A.paramA ; paramB = A.paramB ; tangent = A.tangent ; return *this;}
00054 };
00055 
00067 template <class T, int N>
00068 class ParaSurface{
00069 public:
00070   ParaSurface() 
00071     {;}
00072 
00073   virtual HPoint_nD<T,N> operator()(T u, T v) const =0; 
00074   HPoint_nD<T,N> hpointAt(T u, T v) const  
00075     { return operator()(u,v); }
00076   Point_nD<T,N> pointAt(T u, T v) const  
00077     { return project(operator()(u,v)) ; }
00078 
00079 
00080   virtual void deriveAtH(T u, T v, int d, Matrix< HPoint_nD<T,N> >& skl) const =0; 
00081   virtual void deriveAt(T u, T v, int d, Matrix< Point_nD<T,N> >& skl) const =0; 
00082   
00083   virtual T minDist2(const Point_nD<T,N>& p, T& guessU, T& guessV, T error=0.001,T s=0.2,int sep=9,int maxIter=10,T um=0.0, T uM=1.0, T vm=0.0, T vM=1.0) const ;
00084   virtual T minDist2b(const Point_nD<T,N>& p, T& guessU, T& guessV, T error=0.001,T s=0.3,int sep=5,int maxIter=10,T um=0.0, T uM=1.0, T vm=0.0, T vM=1.0) const ;
00085   virtual T minDist2xy(const Point_nD<T,N>& p, T& guessU, T& guessV, T error=0.01,T dU=0.0001, T s=0.3,int sepU=5, int sepV=5, int maxIter=10,T um=0.0, T uM=1.0, T vm=0.0, T vM=1.0) const ;
00086 
00087   int projectOn(const Point_nD<T,N>& p, T& u, T& v, int maxI=100, const T um=0.0, const T uM=1.0, const T vm=0.0, const T vM=1.0) const ;
00088 
00089   T extremum(int findMin, CoordinateType coord, T minDu=0.0001, int sepU=5, int sepV=5, int maxIter=10, T um=0.0, T uM=1.0, T vm=0.0, T vM=1.0) const ;
00090   
00091   int intersectWith(const ParaSurface<T,N> &S, Point_nD<T,N>& p, T& u, T& v, T& s, T& t, int maxI=100, T um=0.0, T uM=1.0, T vm=0.0, T vM=1.0) const ;
00092   int intersectWith(const ParaSurface<T,N> &S, InterPoint<T,N> &iter, int maxI=100, T um=0.0, T uM=1.0, T vm=0.0, T vM=1.0) const ;
00093 
00094   virtual int writeVRML(ostream &fout,const Color& color,int Nu,int Nv, T u_s, T u_e, T v_s, T v_e) const ;
00095   virtual int writeVRML(const char* filename,const Color& color,int Nu,int Nv, T u_s, T u_e, T v_s, T v_e) const ;
00096   virtual int writeVRML(const char* filename, const Color& color=whiteColor, int Nu=20, int Nv=20) const=0 ; 
00097   virtual int writeVRML97(ostream &fout,const Color& color,int Nu,int Nv, T u_s, T u_e, T v_s, T v_e) const ;
00098   virtual int writeVRML97(const char* filename,const Color& color,int Nu,int Nv, T u_s, T u_e, T v_s, T v_e) const ;
00099   virtual int writeVRML97(const char* filename, const Color& color=whiteColor, int Nu=20, int Nv=20) const=0 ; 
00100 };
00101 
00102 
00103 template <class T, int N>
00104 void intersectSurfaces(const PLib::ParaSurface<T,N> &surfA, const PLib::ParaSurface<T,N> &surfB, BasicList<PLib::InterPoint<T,N> > &points, int maxI=100, T um=0.0, T uM=1.0, T vm=0.0, T vM=1.0);
00105 
00106 } // end namespace
00107 
00108 
00109 #ifdef INCLUDE_TEMPLATE_SOURCE
00110 #include "surface.cpp"
00111 #endif
00112 
00113 
00114 #endif 
00115 

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