00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 # ifndef shape_algebraic_surface_hpp
00013 # define shape_algebraic_surface_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 algebraic_surface<C,V>
00021 # define Viewer viewer<axel,V>
00022
00023 namespace mmx {
00024 namespace shape {
00025
00026
00027
00028 TMPL class algebraic_surface;
00029
00030
00031 struct algebraic_surface_def {};
00032
00033
00034
00035
00036
00037
00038 template<class C, class V=default_env>
00039 class algebraic_surface : public surface<REF_OF(V)>
00040 {
00041 public:
00042 typedef REF_OF(V) Ref;
00043 typedef typename algebraic_set<C,Ref>::Polynomial Polynomial;
00044
00045 typedef bounding_box<C,Ref> BoundingBox;
00046 typedef surface<Ref> Surface;
00047
00048 algebraic_surface(void) {} ;
00049
00050 algebraic_surface(char *) ;
00051 algebraic_surface(const Polynomial &) ;
00052
00053 ~algebraic_surface(void) {};
00054
00055 Polynomial set_equation(const Polynomial& p) { return this->m_polynomial=p; }
00056
00057 Polynomial equation() const { return this->m_polynomial ; }
00058
00059
00060
00061 private:
00062 Polynomial m_polynomial ;
00063 } ;
00064
00065 TMPL
00066 SELF::algebraic_surface(char * s): Surface()
00067 {
00068 this->set_equation(Polynomial(s));
00069 }
00070
00071 TMPL
00072 SELF::algebraic_surface(const Polynomial& p) : Surface()
00073 {
00074 this->set_equation(p);
00075 }
00076
00077
00078
00079 TMPL struct viewer; struct axel;
00080 TMPL Viewer&
00081 operator<<(Viewer& os, const SELF& s) {
00082 os<<"<surface type=\"implicit\" color=\""
00083 <<int(os.color.r*255)<<" "
00084 <<int(os.color.g*255)<<" "
00085 <<int(os.color.b*255)<<"\">\n";
00086 os<<" <domain>"
00087 <<os(0,0)<<" "<<os(0,1)<<" "
00088 <<os(1,0)<<" "<<os(1,1)<<" "
00089 <<os(2,0)<<" "<<os(2,1)
00090 <<"</domain>\n";
00091 os<<" <polynomial>";
00092 print_as_double(os,s.equation().rep(),variables("x y z"));
00093 os<<"</polynomial>\n";
00094 os<<"</surface>\n";
00095 return os;
00096 }
00097
00098
00099 } ;
00100
00101 } ;
00102
00103 # undef TMPL
00104 # undef TMPL1
00105 # undef Surface
00106 # undef SELF
00107 # undef Viewer
00108 # endif // IMPLICITSURFACE_H