00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 # ifndef shape_bcell2d_semialgebraic_curve_hpp
00014 # define shape_bcell2d_semialgebraic_curve_hpp
00015
00016 # include <realroot/Seq.hpp>
00017 # include <shape/point.hpp>
00018 # include <shape/solver_implicit.hpp>
00019 # include <shape/semialgebraic_curve.hpp>
00020 # include <shape/bcell2d_algebraic_curve.hpp>
00021
00022
00023 # define TMPL template<class C, class V>
00024 # define SELF bcell2d_semialgebraic_curve<C,V>
00025 # define Cell bcell<C,V>
00026 # define Cell2d bcell2d<C,V>
00027 # define Cell2dAlgebraicCurve bcell2d_algebraic_curve<C,V>
00028 # define SemiAlgebraicCurve semialgebraic_curve<C,V>
00029 # define Solver solver_implicit<C,V>
00030 # undef Cell_t
00031 # undef Polynomial
00032
00033 namespace mmx {
00034 namespace shape {
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 TMPL
00052 struct bcell2d_semialgebraic_curve : public Cell2dAlgebraicCurve {
00053 public:
00054 typedef typename use<point_def,C,V>::Point Point;
00055 typedef typename bcell2d_algebraic_curve<C,V>::Polynomial Polynomial;
00056 typedef typename Cell2d::BoundingBox BoundingBox;
00057
00058 typedef bcell2d_semialgebraic_curve<C,V> Cell_t;
00059
00060 bcell2d_semialgebraic_curve(const Polynomial&, int, const BoundingBox&);
00061 bcell2d_semialgebraic_curve(SemiAlgebraicCurve*, const BoundingBox&);
00062
00063 bcell2d_semialgebraic_curve(const SELF& cl)
00064 : Cell2dAlgebraicCurve(cl.m_polynomial, cl.boundingBox()) {}
00065
00066
00067 Polynomial inequality(void) const { return this->m_polynomial; }
00068
00069 virtual bool is_active (void) ;
00070
00071
00072 bool is_touching(void);
00073
00074 virtual void subdivide(Cell*& left, Cell*& right, int v, double s);
00075
00076
00077
00078 private:
00079
00080 };
00081
00082 TMPL
00083 SELF::bcell2d_semialgebraic_curve(const Polynomial& pol, int s, const BoundingBox& bx)
00084 : Cell2dAlgebraicCurve(pol,bx) { if (s<0) this->m_polynomial*=-1; }
00085
00086 TMPL
00087 SELF::bcell2d_semialgebraic_curve(SemiAlgebraicCurve* cv, const BoundingBox & b)
00088 : Cell2dAlgebraicCurve(cv->inequality(),b) { }
00089
00090
00091 TMPL bool
00092 SELF::is_active() {
00093
00094 return ( Cell2dAlgebraicCurve::is_active() );
00095
00096
00097 if( !Cell2dAlgebraicCurve::is_active() )
00098 return false;
00099
00100 if( ! this->is_regular())
00101 return true;
00102
00103 if( this->m_singular.size()!=0)
00104 return true;
00105
00106
00107 if (this->is_touching() )
00108 return true;
00109 else
00110 return false;
00111 }
00112
00113
00114 TMPL bool
00115 SELF::is_touching(){
00116
00117 const int * sz = this->m_polynomial.rep().szs();
00118 const int * st = this->m_polynomial.rep().str();
00119 if (!((this->m_polynomial[0] >0) ||
00120 (this->m_polynomial[(sz[0]-1)*st[0]] >0)||
00121 (this->m_polynomial[sz[0]*sz[1]-1]>0) ||
00122 (this->m_polynomial[(sz[1]-1)*st[1]] >0)))
00123 return false;
00124 else
00125 return true;
00126 }
00127
00128
00129 TMPL void
00130 SELF::subdivide(Cell*& Left, Cell*& Right, int v, double s) {
00131
00132 Cell2dAlgebraicCurve::subdivide(Left,Right,v,s) ;
00133
00134
00135 }
00136
00137
00138
00139 } ;
00140 } ;
00141
00142 # undef Cell
00143 # undef Cell2d
00144
00145 # undef Cell2dAlgebraicCurve
00146 # undef SemiAlgebraicCurve
00147 # undef Solver
00148 # undef SELF
00149 # undef TMPL
00150 # endif // shape_cell2d_semialgebraic_curve_hpp