shape_doc 0.1
|
00001 /***************************************************************************** 00002 * M a t h e m a g i x 00003 ***************************************************************************** 00004 * ImplicitCell 00005 * 2008-03-20 00006 * Julien Wintz & Bernard Mourrain 00007 ***************************************************************************** 00008 * Copyright (C) 2008 INRIA Sophia-Antipolis 00009 ***************************************************************************** 00010 * Comments : 00011 ****************************************************************************/ 00012 00013 # ifndef shape_cell2d_semialgebraic_curve_hpp 00014 # define shape_cell2d_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/cell2d_algebraic_curve.hpp> 00021 00022 00023 # define TMPL template<class C, class V> 00024 # define SELF cell2d_semialgebraic_curve<C,V> 00025 # define Cell cell<C,V> 00026 # define Cell2d cell2d<C,V> 00027 # define Cell2dAlgebraicCurve cell2d_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 // TMPL struct cell2d_semialgebraic_curve; 00037 00038 // TMPL struct with_cell2d_semialgebraic_curve { 00039 // typedef cell2d_semialgebraic_curve<K> Cell2dSemiAlgebraicDomain; 00040 // }; 00041 00042 // TMPL struct cell2d_semialgebraic_curve_def 00043 // :public semialgebraic_curve_def<K> 00044 // ,public with_cell2d_semialgebraic_curve<K> 00045 // { 00046 // typedef typename cell2d_algebraic_curve_def<K>::Polynomial Polynomial; 00047 // typedef typename cell2d_algebraic_curve_def<K>::Topology2d Topology2d; 00048 // }; 00049 00050 00051 TMPL 00052 struct cell2d_semialgebraic_curve : public Cell2dAlgebraicCurve { 00053 public: 00054 typedef point<C,V> Point; 00055 typedef typename cell2d_algebraic_curve<C,V>::Polynomial Polynomial; 00056 typedef typename Cell2d::BoundingBox BoundingBox; 00057 00058 typedef cell2d_semialgebraic_curve<C,V> Cell_t; 00059 00060 cell2d_semialgebraic_curve(const Polynomial&, int, const BoundingBox&); 00061 cell2d_semialgebraic_curve(SemiAlgebraicCurve*, const BoundingBox&); 00062 00063 cell2d_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 //virtual bool is_regular(void) ; 00071 00072 bool is_touching(void); 00073 00074 Point * pair(Point * p, int & sgn) const ; 00075 virtual void subdivide(Cell*& left, Cell*& right, int v, double s); 00076 00077 // virtual bool insert_singular (SemiAlg2d*);// = 0; 00078 00079 private: 00080 // int m_sign; 00081 }; 00082 00083 TMPL 00084 SELF::cell2d_semialgebraic_curve(const Polynomial& pol, int s, const BoundingBox& bx) 00085 : Cell2dAlgebraicCurve(pol,bx) { if (s<0) this->m_polynomial*=-1; } 00086 00087 TMPL 00088 SELF::cell2d_semialgebraic_curve(SemiAlgebraicCurve* cv, const BoundingBox & b) 00089 : Cell2dAlgebraicCurve(cv->inequality(),b) { } 00090 00091 00092 TMPL bool 00093 SELF::is_active() { 00094 00095 return ( Cell2dAlgebraicCurve::is_active() ); 00096 00097 // 00098 if( !Cell2dAlgebraicCurve::is_active() )//intersecting the bound curves 00099 return false; 00100 00101 if( ! this->is_regular()) 00102 return true; 00103 00104 if( this->m_singular.size()!=0) 00105 return true; 00106 00107 00108 if (this->is_touching() )//is touching the set 00109 return true; 00110 else 00111 return false; 00112 } 00113 00114 00115 TMPL bool 00116 SELF::is_touching(){ 00117 00118 const int * sz = this->m_polynomial.rep().szs(); 00119 const int * st = this->m_polynomial.rep().str(); 00120 if (!((this->m_polynomial[0] >0) || 00121 (this->m_polynomial[(sz[0]-1)*st[0]] >0)|| 00122 (this->m_polynomial[sz[0]*sz[1]-1]>0) || 00123 (this->m_polynomial[(sz[1]-1)*st[1]] >0))) 00124 return false; 00125 else 00126 return true; 00127 } 00128 00129 00130 TMPL void 00131 SELF::subdivide(Cell*& Left, Cell*& Right, int v, double s) { 00132 // std::cout<<"subdivide semialg"<< this<<", intsects: "<< this->nb_intersect() <<std::endl; 00133 Cell2dAlgebraicCurve::subdivide(Left,Right,v,s) ; 00134 // std::cout<<"subdivide end"<< this<<", intsects: "<< this->nb_intersect() <<std::endl; 00135 00136 } 00137 00138 00139 //==================================================================== 00140 } ; // namespace shape 00141 } ; // namespace mmx 00142 //==================================================================== 00143 # undef Cell 00144 # undef Cell2d 00145 //# undef AlgebraicCurve 00146 # undef Cell2dAlgebraicCurve 00147 # undef SemiAlgebraicCurve 00148 # undef Solver 00149 # undef SELF 00150 # undef TMPL 00151 # endif // shape_cell2d_semialgebraic_curve_hpp