shape_doc 0.1
|
00001 /***************************************************************************** 00002 * M a t h e m a g i x 00003 ***************************************************************************** 00004 * AlgebraicSurface 00005 * 2008-03-28 00006 * Julien Wintz 00007 ***************************************************************************** 00008 * Copyright (C) 2006 INRIA Sophia-Antipolis 00009 ***************************************************************************** 00010 * Comments : 00011 ****************************************************************************/ 00012 # ifndef shape_surface_algebraic_hpp 00013 # define shape_surface_algebraic_hpp 00014 00015 # include <realroot/GMP.hpp> 00016 # include <shape/algebraic_set.hpp> 00017 # include <shape/surface.hpp> 00018 # define TMPL template<class C, class V> 00019 # define TMPL1 template<class V> 00020 # define SELF surface_algebraic<C,V> 00021 # define Viewer viewer<axel,V> 00022 //==================================================================== 00023 namespace mmx { 00024 namespace shape { 00025 00026 TMPL struct surface_algebraic; 00027 //-------------------------------------------------------------------- 00028 struct surface_algebraic_def {}; 00029 00030 // template<> struct use<surface_algebraic_def> 00031 // : public use<algebraic_set_def> { 00032 // typedef surface_algebraic<double,double> AlgebraicSurface; 00033 // }; 00034 //-------------------------------------------------------------------- 00035 template<class C, class V=default_env> 00036 class surface_algebraic : public surface<REF_OF(V)> 00037 { 00038 public: 00039 typedef REF_OF(V) Ref; 00040 typedef typename algebraic_set<C,Ref>::Polynomial Polynomial; 00041 //typedef polynomial<C, with<Sparse,DegRevLex> > Polynomial; 00042 typedef bounding_box<C,Ref> BoundingBox; 00043 typedef surface<Ref> Surface; 00044 00045 surface_algebraic(void) {} ; 00046 00047 surface_algebraic(char *) ; 00048 surface_algebraic(const Polynomial &) ; 00049 00050 ~surface_algebraic(void) {}; 00051 00052 Polynomial set_equation(const Polynomial& p) { return this->m_polynomial=p; } 00053 00054 Polynomial equation() const { return this->m_polynomial ; } 00055 00056 00057 00058 private: 00059 Polynomial m_polynomial ; 00060 } ; 00061 00062 TMPL 00063 SELF::surface_algebraic(char * s): Surface() 00064 { 00065 this->set_equation(Polynomial(s)); 00066 } 00067 00068 TMPL 00069 SELF::surface_algebraic(const Polynomial& p) : Surface() 00070 { 00071 this->set_equation(p); 00072 } 00073 00074 00075 //-------------------------------------------------------------------- 00076 TMPL struct viewer; struct axel; 00077 TMPL Viewer& 00078 operator<<(Viewer& os, const SELF& s) { 00079 os<<"<surface type=\"implicit\" color=\"" 00080 <<int(os.color.r*255)<<" " 00081 <<int(os.color.g*255)<<" " 00082 <<int(os.color.b*255)<<"\">\n"; 00083 os<<" <domain>" 00084 <<os(0,0)<<" "<<os(0,1)<<" " 00085 <<os(1,0)<<" "<<os(1,1)<<" " 00086 <<os(2,0)<<" "<<os(2,1) 00087 <<"</domain>\n"; 00088 os<<" <polynomial>"; 00089 print_as_double(os,s.equation().rep(),variables("x y z")); 00090 os<<"</polynomial>\n"; 00091 os<<"</surface>\n"; 00092 return os; 00093 } 00094 00095 //==================================================================== 00096 } ; // namespace shape 00097 //==================================================================== 00098 } ; // namespace mmx 00099 //==================================================================== 00100 # undef TMPL 00101 # undef TMPL1 00102 # undef Surface 00103 # undef SELF 00104 # undef Viewer 00105 # endif // IMPLICITSURFACE_H