00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef __MMX_SHAPE_IMPLICIT_CURVE_GLUE_HPP
00012 #define __MMX_SHAPE_IMPLICIT_CURVE_GLUE_HPP
00013 #include <basix/glue.hpp>
00014 #include <basix/tuple.hpp>
00015 #include <realroot/ring_sparse_glue.hpp>
00016 #include <glue_axel_viewer.hpp>
00017 #include <shape/BoundingBox.hpp>
00018 #include <shape/AlgebraicCurve.hpp>
00019
00020
00021 namespace mmx {
00022
00023 #define CURVE shape::ImplicitCurve
00024 #define BOX shape::BoundingBox
00025 #define Polynomial polynom< ring<mmx::rational,Sparse<DegReveLex> > >
00026
00027 namespace shape {
00028 inline bool operator ==(const CURVE& v1, const CURVE& v2) {return true;}
00029 inline bool operator !=(const CURVE& v1, const CURVE& v2) {return !(v1==v2);}
00030 inline bool eq(const CURVE& v1, const CURVE& v2) {return v1==v2;}
00031 inline bool neq(const CURVE& v1, const CURVE& v2) {return v1!=v2;}
00032
00033 inline unsigned hash (const CURVE& v)
00034 {
00035 register unsigned i, h= 214365, n=1;
00036 for (i=0; i<n; i++) h= (h<<1) ^ (h<<5) ^ (h>>27) ;
00037 return h;
00038 }
00039 inline unsigned soft_hash (const CURVE& m) {return hash(m);}
00040
00041 syntactic flatten (const CURVE& s)
00042 {
00043 using namespace shape;
00044
00045 syntactic res = "ImplicitCurve";
00046
00047 vector<syntactic> box;
00048 box<<mmx::flatten(s.boundingBox()->xmin());
00049 box<<mmx::flatten(s.boundingBox()->xmax());
00050 box<<mmx::flatten(s.boundingBox()->ymin());
00051 box<<mmx::flatten(s.boundingBox()->ymax());
00052
00053 return apply(res, mmx::flatten(s.equation()), mmx::flatten(box));
00054
00055 }
00056 }
00057
00058 CURVE implicit_curve_string (const string& eq)
00059 {
00060 return CURVE (as_charp(eq));
00061 }
00062
00063 CURVE implicit_curve_string (const string& eq, const BOX& bx)
00064 {
00065 BOX* b = new BOX(bx);
00066 return CURVE(as_charp(eq), b);
00067 }
00068
00069 CURVE implicit_curve(const Polynomial& eq, const BOX& bx)
00070 {
00071 BOX* b = new BOX(bx);
00072 return CURVE(eq, b);
00073 }
00074
00075
00076 axel::ostream& operator<<(axel::ostream& os, const CURVE& c)
00077 {
00078 os<<"<curve type=\"implicit\">\n";
00079 os<<" <domain>"
00080 <<c.boundingBox()->xmin()<<" "<<c.boundingBox()->xmax()<<" "
00081 <<c.boundingBox()->ymin()<<" "<<c.boundingBox()->ymax()
00082 <<"</domain>\n";
00083 os<<" <polynomial>";
00084 MPOLDST::print(os,c.equation(),Variables("x y"));
00085 os<<"</polynomial>\n";
00086 os<<"</curve>\n";
00087 return os;
00088 }
00089
00090
00091 #undef BOX
00092 #undef CURVE
00093 #undef Polynomial
00094
00095 }
00096 #endif // __MMX_IMPLICIT_CURVE_GLUE_HPP