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 #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 }
00107
00108
00109 #ifdef INCLUDE_TEMPLATE_SOURCE
00110 #include "surface.cpp"
00111 #endif
00112
00113
00114 #endif
00115