00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 # ifndef algebraic_curve_axl_hpp
00013 # define algebraic_curve_axl_hpp
00014
00015 # include <shape/algebraic_curve.hpp>
00016 # include <shape/mesher2d.hpp>
00017
00018 # define TMPL template<class C, class V>
00019 # define AlgebraicCurve algebraic_curve<C,V>
00020 # define Viewer viewer<axel,V>
00021
00022 namespace mmx {
00023 namespace shape {
00024
00025 template<class C, class V>
00026 struct use<graphic_def,AlgebraicCurve,V> {
00027 typedef mesher2d<C,V> Output;
00028 };
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062 TMPL struct viewer;
00063 TMPL Viewer&
00064 operator<<(Viewer& os, const AlgebraicCurve& c) {
00065 typedef typename AlgebraicCurve::Polynomial Polynomial;
00066 os<<"<curve type=\"algebraic\" color=\""<<(int)(255*os.color.r)<<" "<<(int)(255*os.color.g)<<" "<<(int)(255*os.color.b)<<"\">\n";
00067 os<<" <domain>"
00068 <<os(0,0)<<" "<<os(0,1)<<" "
00069 <<os(1,0)<<" "<<os(1,1)<<" "
00070 <<os(2,0)<<" "<<os(2,1)
00071 <<"</domain>\n";
00072 for(unsigned i=0; i<c.equations().size();i++)
00073 {
00074 typename use<numeric_def,V>::Integer m=1;
00075 Polynomial p=c.equation(i);
00076 for(typename Polynomial::const_iterator it=p.begin();it!=p.end();it++){
00077 m = lcm(denominator(it->coeff()), m);
00078 }
00079 p*=(typename Polynomial::Scalar)m;
00080 os<<(char*)" <polynomial>";
00081 print(os,p,variables("x y z"));
00082 os<<(char*)"</polynomial>\n";
00083 }
00084 os<<"</curve>\n";
00085 return os;
00086 }
00087
00088
00089 }
00090 }
00091
00092 # undef TMPL
00093 # undef AlgebraicCurve
00094 # undef Viewer
00095 #endif //shape_algebraic_curve