Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

simplex_filter.H

Go to the documentation of this file.
00001 /*****************************************************************
00002  * simplex_filter.H
00003  *****************************************************************/
00004 #ifndef SIMPLEX_FILTER_H_IS_INCLUDED
00005 #define SIMPLEX_FILTER_H_IS_INCLUDED
00006 
00007 #include "bsimplex.H"
00008 
00009 // Base class SimplexFilter is defined in Bsimplex.H
00010 
00011 /*****************************************************************
00012  * BitSetSimplexFilter:
00013  *
00014  *   Accept a simplex if a given bit is set (in its flag).
00015  *****************************************************************/
00016 class BitSetSimplexFilter : public SimplexFilter {
00017  public:
00018    BitSetSimplexFilter(uint b) : _b(b) {}
00019 
00020    virtual bool accept(CBsimplex* s) const {
00021       return (s && s->is_set(_b));
00022    }
00023 
00024  protected:
00025    uint _b;
00026 };
00027 typedef const BitSetSimplexFilter CBitSetSimplexFilter;
00028 
00029 /*****************************************************************
00030  * BitClearSimplexFilter:
00031  *
00032  *   Accept a simplex if a given bit is clear (in its flag).
00033  *****************************************************************/
00034 class BitClearSimplexFilter : public SimplexFilter {
00035  public:
00036    BitClearSimplexFilter(uint b) : _b(b) {}
00037 
00038    virtual bool accept(CBsimplex* s) const {
00039       return (s && s->is_clear(_b));
00040    }
00041 
00042  protected:
00043    uint _b;
00044 };
00045 typedef const BitClearSimplexFilter CBitClearSimplexFilter;
00046 
00047 /*****************************************************************
00048  * MeshSimplexFilter:
00049  *
00050  *   Accept a simplex from the given mesh
00051  *****************************************************************/
00052 class MeshSimplexFilter : public SimplexFilter {
00053  public:
00054    MeshSimplexFilter(BMESH* m) : _mesh(m) {}
00055 
00056    virtual bool accept(CBsimplex* s) const {
00057      return (s && s->mesh()==_mesh);
00058    }
00059 
00060  protected:
00061    BMESH* _mesh;
00062 };
00063 typedef const MeshSimplexFilter CMeshSimplexFilter;
00064 
00065 /*****************************************************************
00066  * BvertFilter:
00067  *
00068  *      Accepts Bverts.
00069  *****************************************************************/
00070 class BvertFilter : public SimplexFilter {
00071  public:
00072    //******** SOLE JOB ********
00073    virtual bool accept(CBsimplex* s) const { return is_vert(s); }
00074 };
00075 typedef const BvertFilter CBvertFilter;
00076 
00077 /*****************************************************************
00078  * BedgeFilter:
00079  *
00080  *      Accepts Bedges.
00081  *****************************************************************/
00082 class BedgeFilter : public SimplexFilter {
00083  public:
00084    //******** SOLE JOB ********
00085    virtual bool accept(CBsimplex* s) const { return is_edge(s); }
00086 };
00087 typedef const BedgeFilter CBedgeFilter;
00088 
00089 /*****************************************************************
00090  * BfaceFilter:
00091  *
00092  *      Accepts Bfaces.
00093  *****************************************************************/
00094 class BfaceFilter : public SimplexFilter {
00095  public:
00096    //******** SOLE JOB ********
00097    virtual bool accept(CBsimplex* s) const { return is_face(s); }
00098 };
00099 typedef const BfaceFilter CBfaceFilter;
00100 
00101 /*****************************************************************
00102  * SimplexFlagFilter:
00103  *
00104  *      Accepts a simplex if its flag has a given value.
00105  *****************************************************************/
00106 class SimplexFlagFilter : public SimplexFilter {
00107  public:
00108    SimplexFlagFilter(uchar f=1) : _flag(f) {}
00109 
00110    uchar flag()                 const   { return _flag; }
00111    void  set_flag(uchar f)              { _flag = f; }
00112 
00113    //******** SOLE JOB ********
00114    virtual bool accept(CBsimplex* s) const {
00115       return s && (s->flag() == _flag);
00116    }
00117 
00118  protected:
00119    uchar  _flag;        // required value
00120 };
00121 
00122 /*****************************************************************
00123  * UnreachedSimplexFilter:
00124  *
00125  *      Accepts a simplex if its flag is not set (i.e. is zero),
00126  *      AND SETS THE FLAG, so next time it won't be accepted.
00127  *****************************************************************/
00128 class UnreachedSimplexFilter : public SimplexFilter {
00129  public:
00130    virtual bool accept(CBsimplex* s) const {
00131       if (!s || s->flag())
00132           return 0;
00133       ((Bsimplex*)s)->set_flag();
00134       return 1;
00135    }
00136 };
00137 
00138 /*****************************************************************
00139  * AndFilter:
00140  *
00141  *      Accepts the AND of two filters
00142  *****************************************************************/
00143 class AndFilter : public SimplexFilter {
00144  public:
00145    AndFilter(CSimplexFilter& f1, CSimplexFilter& f2) :
00146       _f1(f1), _f2(f2) {}
00147 
00148    virtual bool accept(CBsimplex* s) const {
00149       return _f1.accept(s) && _f2.accept(s);
00150    }
00151 
00152  protected:
00153    CSimplexFilter& _f1;
00154    CSimplexFilter& _f2;
00155 };
00156 
00157 inline AndFilter
00158 operator+(CSimplexFilter& f1, CSimplexFilter& f2)
00159 {
00160    return AndFilter(f1,f2);
00161 }
00162 
00163 /*****************************************************************
00164  * OrFilter:
00165  *
00166  *      Accepts the OR of two filters
00167  *****************************************************************/
00168 class OrFilter : public SimplexFilter {
00169  public:
00170    OrFilter(CSimplexFilter& f1, CSimplexFilter& f2) :
00171       _f1(f1), _f2(f2) {}
00172 
00173    virtual bool accept(CBsimplex* s) const {
00174       return _f1.accept(s) || _f2.accept(s);
00175    }
00176 
00177  protected:
00178    CSimplexFilter& _f1;
00179    CSimplexFilter& _f2;
00180 };
00181 
00182 inline OrFilter
00183 operator||(CSimplexFilter& f1, CSimplexFilter& f2)
00184 {
00185    return OrFilter(f1,f2);
00186 }
00187 
00188 /*****************************************************************
00189  * NotFilter:
00190  *
00191  *      Accepts the NOT of a filter
00192  *****************************************************************/
00193 class NotFilter : public SimplexFilter {
00194  public:
00195    NotFilter(CSimplexFilter& f) : _filter(f) {}
00196 
00197    virtual bool accept(CBsimplex* s) const {
00198       return !_filter.accept(s);
00199    }
00200 
00201  protected:
00202    CSimplexFilter& _filter;
00203 };
00204 
00205 inline NotFilter
00206 operator!(CSimplexFilter& f)
00207 {
00208    return NotFilter(f);
00209 }
00210 
00211 /*****************************************************************
00212  * SelectedSimplexFilter:
00213  *
00214  *      Accepts selected simplices.
00215  *****************************************************************/
00216 class SelectedSimplexFilter : public SimplexFilter {
00217  public:
00218    //******** SOLE JOB ********
00219    virtual bool accept(CBsimplex* s) const {
00220       return s && s->is_selected();
00221    }
00222 };
00223 typedef const SelectedSimplexFilter CSelectedSimplexFilter;
00224 
00225 #endif // SIMPLEX_FILTER_H_IS_INCLUDED
00226 
00227 // end of file simplex_filter.H

Generated on Mon Sep 18 11:39:33 2006 for jot by  doxygen 1.4.4