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

patch.H

Go to the documentation of this file.
00001 #ifndef PATCH_H_IS_INCLUDED
00002 #define PATCH_H_IS_INCLUDED
00003 
00004 /*!
00005  *  \file patch.H
00006  *  \brief Contains the definition of the Patch class and related classes.
00007  *
00008  *  \sa patch.C
00009  *
00010  */
00011 
00012 #include "geom/appear.H"        // base class of Patch
00013 
00014 #include "bmesh.H"              // meshes
00015 #include "tex_coord_gen.H"      // for generating tex coords
00016 #include <vector>
00017 
00018 class GTexture;
00019 typedef const GTexture CGTexture;
00020 /*!
00021  *  \brief Convenience methods defined in gtexture.H
00022  *
00023  */
00024 class GTexture_list : public BMD_array<GTexture> {
00025    
00026  public:
00027       
00028    //******** MANAGERS ********
00029    GTexture_list(int n=0)                   : BMD_array<GTexture>(n)    {}
00030    GTexture_list(const GTexture_list& list) : BMD_array<GTexture>(list) {}
00031    GTexture_list(GTexture* g) : BMD_array<GTexture>(1) {
00032       add(g);
00033    }
00034    GTexture_list(GTexture* g1, GTexture* g2) : BMD_array<GTexture>(2) {
00035       add(g1);
00036       add(g2);
00037    }
00038    GTexture_list(GTexture* g1, GTexture* g2, GTexture* g3) :
00039       BMD_array<GTexture>(3) {
00040       add(g1);
00041       add(g2);
00042       add(g3);
00043    }
00044    GTexture_list(GTexture* g1, GTexture* g2, GTexture* g3, GTexture* g4) :
00045       BMD_array<GTexture>(4) {
00046       add(g1);
00047       add(g2);
00048       add(g3);
00049       add(g4);
00050    }
00051    GTexture_list(GTexture* g1, GTexture* g2, GTexture* g3, GTexture* g4,
00052                  GTexture* g5) :
00053       BMD_array<GTexture>(5) {
00054       add(g1);
00055       add(g2);
00056       add(g3);
00057       add(g4);
00058       add(g5);
00059    }
00060    GTexture_list(GTexture* g1, GTexture* g2, GTexture* g3, GTexture* g4,
00061                  GTexture* g5, GTexture* g6) :
00062       BMD_array<GTexture>(6) {
00063       add(g1);
00064       add(g2);
00065       add(g3);
00066       add(g4);
00067       add(g5);
00068       add(g6);
00069    }
00070    GTexture_list(GTexture* g1, GTexture* g2, GTexture* g3, GTexture* g4,
00071                  GTexture* g5, GTexture* g6, GTexture* g7) :
00072       BMD_array<GTexture>(6) {
00073       add(g1);
00074       add(g2);
00075       add(g3);
00076       add(g4);
00077       add(g5);
00078       add(g6);
00079       add(g7);
00080    }
00081    GTexture_list(GTexture* g1, GTexture* g2, GTexture* g3, GTexture* g4,
00082                  GTexture* g5, GTexture* g6, GTexture* g7, GTexture* g8) :
00083       BMD_array<GTexture>(6) {
00084       add(g1);
00085       add(g2);
00086       add(g3);
00087       add(g4);
00088       add(g5);
00089       add(g6);
00090       add(g7);
00091       add(g8);
00092    }
00093 
00094    //******** CONVENIENCE ********
00095       
00096    void write_stream(ostream& os) const;
00097    void delete_all();
00098 
00099    void set_patch(Patch* p)     const;
00100 
00101    void push_alpha(double a)    const;
00102    void pop_alpha()             const;
00103 };
00104 typedef const GTexture_list CGTexture_list;
00105 
00106 typedef void (*init_fade_func_t)(GTexture*, GTexture*, double, double);
00107 
00108 class PatchData;
00109 typedef const PatchData CPatchData;
00110 
00111 /*!
00112  *  \brief Base class for application-specific, custom data attached to the
00113  *   patch.
00114  *
00115  */
00116 class PatchData {
00117    
00118  public:
00119    
00120    virtual ~PatchData() {}
00121       
00122    //! \name RTTI Methods
00123    //@{
00124       
00125    DEFINE_RTTI_METHODS_BASE("PatchData", CPatchData*);
00126       
00127    //@}
00128 
00129 };
00130 
00131 /*!
00132  *  \brief DynamicSample is used as a sampel point for Dynamic Hatching 
00133  *
00134  */
00135 
00136 class DynamicSample;
00137 typedef const DynamicSample CDynamicSample;
00138 
00139 class DynamicSample {
00140    
00141  public:
00142    DynamicSample() {}
00143    DynamicSample(CBsimplex* s, Wvec bc, PIXEL pix, double weight)
00144       : _s(s),
00145         _bc(bc),
00146         _pix(pix),
00147         _weight(weight)
00148    {}
00149    virtual ~DynamicSample() {}
00150    CBsimplex* get_simplex() const { return _s; }
00151    Wvec      get_bc()      const { return _bc;}
00152    double    get_weight()  const { return _weight; }
00153    PIXEL     get_pix()     const { return _pix; }   
00154    Wpt       get_pos(CWtransf& tr)  const { return tr*_s->bc2pos(_bc); }
00155    //! \name RTTI Methods
00156    //@{      
00157    DEFINE_RTTI_METHODS_BASE("DynamicSample", CDynamicSample*);
00158    //@}
00159  public:
00160     CBsimplex* _s;
00161     Wvec      _bc;
00162     PIXEL     _pix;
00163     double    _weight;
00164 
00165 };
00166 
00167 class Patch;
00168 typedef const Patch CPatch;
00169 
00170 /*!
00171  *  \brief A region of a BMESH that can be textured individually.
00172  *
00173  */
00174 class Patch : public DATA_ITEM, public APPEAR, public BMESHdrawable {
00175    
00176  protected:
00177 
00178    //******** MANAGERS ********
00179    Patch(BMESH* = 0);
00180    friend class BMESH;
00181    
00182  public:
00183    
00184    virtual ~Patch();
00185 
00186    //! \name Accessors
00187    //@{
00188       
00189    BMESH*       mesh ()                 const      { return _mesh; }
00190    void         set_mesh(BMESH* m)                 { _mesh = m; changed(); }
00191    Cstr_ptr&    name ()                 const      { return _name;}
00192    void         set_name(Cstr_ptr &str)            { _name = str;}
00193    Cstr_ptr&    texture_file ()         const      { return _texture_file;}
00194    void         set_texture_file(Cstr_ptr &str)    { _texture_file = str;}
00195    TexCoordGen* tex_coord_gen()         const      { return _tex_coord_gen; }
00196    void         set_tex_coord_gen(TexCoordGen* tg) { _tex_coord_gen = tg; }
00197       
00198    CARRAY<uint>& pixels()               const      { return _pixels; }
00199    void          add_pixel(uint p)                 { _pixels += p; }
00200       
00201    int num_vert_strips() const { return _vert_strips.num(); }
00202    int num_edge_strips() const { return _edge_strips.num(); }
00203    int num_tri_strips()  const { return _tri_strips.num(); }
00204       
00205    virtual void          set_data(PatchData *d)     { _data = d; }
00206    virtual PatchData*    get_data()                 { return _data; }
00207       
00208    int stencil_id() {
00209       if (!_stencil_id)
00210          _stencil_id = ++_next_stencil_id;
00211       return _stencil_id;
00212    }
00213       
00214    // List of Gtextures:
00215    const GTexture_list& gtextures() const { return _textures; }
00216       
00217    //@}
00218 
00219    //! \name Accessing Patch Geometry
00220    //@{
00221    
00222    //! \brief Lightweight: returns reference to existing face list:
00223    CBface_list& faces() const   { return _faces; }
00224    
00225    //! \brief Heavyweight: builds the lists and returns by copying
00226    //! (returns vertices and edges of this patch).
00227    Bvert_list   verts() const;
00228    //! \copydoc Patch::verts()
00229    Bedge_list   edges() const;
00230       
00231    //@}
00232 
00233    //! \name Silhouettes, Creases, Etc.
00234    //@{
00235    
00236    //! \brief Generates (if needed) and returns the requested silhouettes,
00237    //! creases, etc.  Operates on the CURRENT subdivision Patch.
00238    EdgeStrip&   cur_sils()
00239       { return cur_patch()->build_sils(); }
00240    //! \copydoc Patch::cur_sils()
00241    ZcrossPath&  cur_zx_sils()
00242       { return cur_patch()->build_zx_sils(); }
00243 
00244    EdgeStrip*   cur_creases()
00245       { return cur_patch()->build_creases(); }
00246    //! \copydoc Patch::cur_sils()
00247    EdgeStrip*   cur_borders()
00248       { return cur_patch()->build_borders(); }
00249       
00250  protected:
00251    
00252    //! \brief Generates (if needed) and returns the requested silhouettes,
00253    //! creases, etc. Operates on *this* Patch as opposed to the current
00254    //! subdivision Patch.
00255    EdgeStrip&   build_sils();
00256    //! \copydoc Patch::build_sils()
00257    ZcrossPath&  build_zx_sils();
00258    //! \copydoc Patch::build_sils()
00259    EdgeStrip*   build_creases();
00260    //! \copydoc Patch::build_sils()
00261    EdgeStrip*   build_borders();
00262 
00263  public:
00264 
00265  protected:
00266    
00267    //! \brief Simple accessor -- no checks for updating.
00268    //! \note May be phased out because it appears to be unused.
00269    EdgeStrip&   sils()          { return _sils; }
00270    //! \copydoc Patch::sils()
00271    ZcrossPath&  zx_sils()       { return _zx_sils; }
00272    //! \copydoc Patch::sils()
00273    EdgeStrip*   creases()       { return _creases; }
00274    //! \copydoc Patch::sils()
00275    EdgeStrip*   borders()       { return _borders; }
00276       
00277    //@}
00278    
00279  public:
00280 
00281    //! \name Subdivision
00282    //! Redefined by Lpatch (subdivision patches).
00283    //@{
00284       
00285    //! \brief Returns the corresponding patch at the "current"
00286    //! subdivision level.
00287    virtual Patch* cur_patch() { return this; }
00288       
00289    //! \brief Convenience: the mesh of the current subdivision patch.
00290    BMESH* cur_mesh() { return cur_patch()->mesh(); }
00291       
00292    //! \brief The level of this Patch in the subdivision hierarchy
00293    //! (control mesh is 0, next level is 1, etc.).
00294    int subdiv_level() const { return _mesh ? _mesh->subdiv_level() : 0; }
00295       
00296    //! \brief The level of this Patch relative to its control Patch
00297    //! (filled in by Lpatch).
00298    virtual int rel_subdiv_level() { return 0; }
00299       
00300    //! \brief The mesh edit level, relative to this patch
00301    //! (filled in by Lpatch).
00302    virtual int rel_edit_level()
00303       { return _mesh ? (_mesh->edit_level() - subdiv_level()) : 0; }
00304       
00305    //! \brief Returns mesh faces at current subdivision level.
00306    virtual CBface_list& cur_faces()     const   { return _faces; }
00307    //! \brief Returns mesh vertices at current subdivision level.
00308    virtual Bvert_list   cur_verts()     const   { return verts(); }
00309    //! \brief Returns mesh edges at current subdivision level.
00310    virtual Bedge_list   cur_edges()     const   { return edges(); }
00311       
00312    //! For BMESH patch: returns number of faces in patch.
00313    //! For LMESH patch: returns number of faces at current subdiv level.
00314    //! \remark Popular with Gtextures to report on how many faces they rendered.
00315    virtual int          num_faces()     const    { return _faces.num();}
00316       
00317    //! \brief Used by Lpatch to produce a child patch
00318    //! at the next subdivision level.
00319    virtual Patch* get_child() { return 0; }
00320       
00321    //! \brief Returns the highest-level parent Patch of this one.
00322    //!
00323    //! \note NB. the control patch may not belong to the control mesh,
00324    //! in the case that a patch has been added at a level > 0.
00325    virtual Patch* ctrl_patch() const { return (Patch*)this; }
00326       
00327    //@}
00328 
00329    //! \name Convenience - Mesh Accessors
00330    //@{
00331    
00332    CWtransf& xform()      const   { return _mesh->xform(); }
00333    CWtransf& inv_xform()  const   { return _mesh->inv_xform(); }
00334    CWtransf& obj_to_ndc() const   { return _mesh->obj_to_ndc(); }
00335    CWpt&     eye_local()  const   { return _mesh->eye_local(); }
00336    double    pix_size()   const   { return _mesh->pix_size(); }
00337       
00338    //@}
00339 
00340    //! \name Building
00341    //@{
00342       
00343    void add(Bface* f);
00344    void remove(Bface* f);
00345    
00346    void add(VertStrip*);
00347    void remove(VertStrip*);
00348    
00349    void add(EdgeStrip*);
00350    void remove(EdgeStrip*);
00351    
00352    void build_tri_strips();
00353    virtual double tris_per_strip() const {
00354       return _tri_strips.empty() ? 0.0 :
00355          double(_faces.num())/_tri_strips.num();
00356    }
00357       
00358    //@}
00359 
00360    //! \name Versioning/Caching
00361    //! used by textures to tell if they are up-to-date
00362    //! (e.g., display lists may be out of date).
00363    //@{
00364       
00365    virtual void changed() { _stamp++; }
00366       
00367    virtual uint stamp() {
00368       if (_mesh && _mesh->version() != _mesh_version) {
00369          _mesh_version = _mesh->version();
00370          changed();
00371       }
00372       return _stamp;
00373    }
00374       
00375    //@}
00376 
00377    //! \name Notification
00378    //@{
00379    
00380    virtual void triangulation_changed();
00381    
00382    void creases_changed();
00383    void borders_changed();
00384       
00385    //@}
00386 
00387    //! \name BMESHdrawable Methods
00388    //@{
00389       
00390    virtual int draw(CVIEWptr&);
00391       
00392    //@}
00393 
00394    //! \name Drawing
00395    //@{
00396    
00397    // XXX - in transition.
00398    virtual int  draw_tri_strips(StripCB *);
00399    virtual int  draw_sil_strips(StripCB *);
00400    
00401    int          draw_crease_strips(StripCB *);
00402    int          draw_border_strips(StripCB *);
00403    int          draw_edge_strips(StripCB *);
00404    int          draw_vert_strips(StripCB *);
00405       
00406    //@}
00407    
00408    //! \name Procedural Textures
00409    //@{
00410       
00411    void      set_texture(GTexture* gtex);
00412    void      set_texture(Cstr_ptr& style);
00413    void      next_texture();
00414    
00415    //! \brief Returns an existing texture of the given type, or nil.
00416    GTexture* find_tex(Cstr_ptr& tex_name) const;
00417    
00418    //! \brief Same as find_tex() but makes a new GTexture if needed.
00419    GTexture* get_tex(Cstr_ptr& tex_name);
00420    
00421    //! \brief Returns an index for a texture.
00422    int get_tex_index(Cstr_ptr& tex_name) {
00423       return _textures.get_index(get_tex(tex_name));
00424    }
00425    
00426    //! \brief Return "current" GTexture, based on the mesh's render style
00427    //! if it has one, or based on the view's render style.
00428    virtual GTexture* cur_tex(CVIEWptr& v);
00429    
00430    //! \brief Texture to use according to the "current texture index".
00431    GTexture* cur_tex() const {
00432       return _textures.valid_index(_cur_tex_i) ? _textures[_cur_tex_i] : 0;
00433    }
00434       
00435    //@}
00436    
00437    //! \name I/O Functions
00438    //@{
00439       
00440    virtual int write_stream     (ostream &os);
00441    virtual int read_stream      (istream &is, str_list &leftover);
00442    virtual int read_texture     (istream &is, str_list &leftover);
00443    virtual int read_color       (istream &is, str_list &leftover);
00444    virtual int read_texture_map (istream &is, str_list &leftover);
00445    virtual int read_patchname   (istream &is, str_list &leftover);
00446       
00447    //@}
00448 
00449    //! \name RefImageClient Methods
00450    //@{
00451       
00452    virtual ref_img_t    use_ref_image();
00453       
00454    virtual int draw_vis_ref();
00455    virtual int draw_ref_img(ref_img_t);
00456    virtual int draw_final(CVIEWptr &v);
00457       
00458    //@}
00459       
00460    //! \name RTTI Methods
00461    //@{
00462       
00463    DEFINE_RTTI_METHODS3("Patch", Patch*, DATA_ITEM, Patch *);
00464       
00465    //@}
00466       
00467    //! \name DATA_ITEM Methods
00468    //@{
00469       
00470    virtual CTAGlist    &tags()  const;
00471    virtual DATA_ITEM  *dup  ()  const;
00472       
00473    //@}
00474       
00475    //! \name Appear Methods
00476    //@{
00477       
00478    virtual CCOLOR&   color         ()                const;
00479    virtual bool      has_color     ()                const;
00480    virtual void      set_color     (CCOLOR& c);
00481    virtual void      unset_color   ();
00482       
00483    virtual double    transp        ()                const;
00484    virtual bool      has_transp    ()                const;
00485    virtual void      set_transp(double t);
00486    virtual void      unset_transp();
00487       
00488    //! \brief Set normal texture map.
00489    virtual void      set_texture   (CTEXTUREptr& t);
00490    //! \brief Unset normal texture map.
00491    virtual void      unset_texture ();
00492       
00493    //! \brief convenience
00494    void apply_texture() {
00495       if (has_texture()) {
00496          _texture->apply_texture(&_tex_xform);
00497       }
00498    }
00499       
00500    //! \brief Function to use for initializing a fade from one GTexture
00501    //! to another.
00502    static init_fade_func_t _init_fade;
00503    
00504    //! \name Dynamic Samples
00505    //@{
00506    //! \brief center of the samples from last frame
00507    PIXEL    get_old_sample_center()  { return _old_center; }
00508    //! \brief center of the samples
00509    PIXEL    get_sample_center()  { return _new_center; }
00510    //! \brief Non-accumulated z
00511    VEXEL    get_z()              { return _z; }
00512 
00513    PIXEL    get_patch_center()  { return _patch_center; }
00514 
00515 
00516    bool     get_do_dynamic_stuff() const { return _do_dynamic_stuff; }
00517    void     do_dynamic_stuff(bool d)     { _do_dynamic_stuff = d; }
00518    void     set_do_lod(bool d)           { _do_lod = d; }
00519    bool     get_do_lod()                 { return _do_lod; }
00520   
00521    PIXEL    sample_origin()     const   { return _o; }
00522    VEXEL    sample_u_vec()      const   { return (_u_o - _o); }
00523    VEXEL    sample_v_vec()      const   { return (_v_o - _o); }
00524    double   sample_scale()      const   { return _scale; }
00525    const vector<DynamicSample>&  get_samples() const{ return _old_samples; }
00526 
00527    double lod_t() const { return _lod_t; }
00528    VEXEL  lod_u() const { return _lod_u; }
00529    VEXEL  lod_v() const { return _lod_v; }
00530 
00531    void update_dynamic_samples();  
00532    void reset_dynamic_samples();  
00533 
00534  private:
00535    void     create_dynamic_samples();  
00536    //@}
00537 
00538  protected:
00539    
00540    BMESH*            _mesh;             //!< owner
00541    
00542    Bface_list        _faces;            //!< unordered faces
00543    ARRAY<TriStrip*>  _tri_strips;       //!< faces organized into tri strips
00544    
00545    EdgeStrip         _sils;             //!< silhouette edges (as strip)
00546    ZcrossPath        _zx_sils;          //!< zero_crossing sils
00547    EdgeStrip*        _creases;          //!< crease edges (maybe derived type)
00548    EdgeStrip*        _borders;          //!< border edges (maybe derived type)
00549    ARRAY<EdgeStrip*> _edge_strips;      //!< edges to be rendered as line strips
00550    ARRAY<VertStrip*> _vert_strips;      //!< vertices to be rendered as points
00551       
00552    GTexture_list     _textures;         //!< list of textures
00553    int               _cur_tex_i;        //!< index of current texture
00554    int               _non_tex_i;
00555    
00556    GTexture*         _prev_tex;         //!< last GTexture used
00557    
00558    ARRAY<uint>       _pixels;           //!< pixels on patch
00559    uint              _stamp;            //!< version number
00560    uint              _mesh_version;     //!< last recorded mesh version
00561    bool              _tri_strips_dirty; //!< used to rebuild _tri_strips
00562    
00563    str_ptr           _name;             //!< name
00564    str_ptr           _texture_file;     //!< name of texture map image file
00565    
00566    TexCoordGen*      _tex_coord_gen;    //!< for generating texture coordinates
00567    PatchData*        _data;             //!< optional custom data
00568    
00569    int          _stencil_id;
00570    static int   _next_stencil_id;
00571    
00572    //! \name Dynamic Samples Variables
00573    //@{
00574    vector<DynamicSample>  _old_samples;     //!< old sample positions (in pixel space)  
00575    
00576    PIXEL                  _old_center;   //!< sample's center in the last frame
00577    PIXEL                  _new_center;   //!< sample's center in the current frame
00578    VEXEL                  _z;            //!< non-accumulated z
00579    double                 _scale;        //!< total accumulated scale...
00580    PIXEL                  _patch_center; //!< XXX testing...
00581    
00582    //! These are used when growing new faces, chaced values of the first quad, so that 
00583    //! given a new UV point can figure out new location of the points
00584    PIXEL                  _o;
00585    PIXEL                  _u_o;        
00586    PIXEL                  _v_o;
00587    uint                   _dynamic_stamp;
00588    bool                   _do_dynamic_stuff;
00589    bool                   _do_lod;
00590    double                 _lod_t; // interpolation parameter between 2 LOD scales
00591    VEXEL                  _lod_u; // u vector to use when doing LOD
00592    VEXEL                  _lod_v; // v vector to use when doing LOD
00593    //@}
00594 
00595    //! \name Serialization Methods
00596    //@{
00597       
00598    static TAGlist      *_patch_tags;
00599    COLOR   &color_    () { return _color;}
00600    str_ptr &name_     () { return _name;}
00601    int     &cur_tex_i_() { return _cur_tex_i;}
00602    virtual void get_faces(TAGformat &d);
00603    virtual void put_faces(TAGformat &d) const;
00604    virtual void get_color  (TAGformat &d)       { COLOR c; *d >> c; set_color(c); }
00605    virtual void put_color  (TAGformat &d) const {
00606       if (has_color())
00607          d.id() << color();
00608    }
00609    virtual void get_texture (TAGformat &d);
00610    virtual void put_textures(TAGformat &d) const;
00611    virtual void recompute();
00612       
00613    //@}
00614    
00615    //! \brief Fill the given edge strip with edges of a given type that
00616    //! belong to this patch.
00617    EdgeStrip* build_edge_strip(EdgeStrip* strip, CSimplexFilter& filter);
00618 
00619 };
00620 
00621 /*****************************************************************
00622  * inline convenience methods
00623  *****************************************************************/
00624 
00625 //! \brief Returns the Patch of a Bface.
00626 //! \relates Patch
00627 //! \relatesalso Bface
00628 inline Patch* 
00629 get_patch(CBface* f) 
00630 {
00631    return f ? f->patch() : 0; 
00632 }
00633 
00634 //! \brief Returns the Patch of a Bsimplex.
00635 //! \note If you know it's actually a Bface, get_patch(CBface*) is faster.
00636 //! \relates Patch
00637 //! \relatesalso Bsimplex
00638 inline Patch*
00639 get_patch(CBsimplex* s)
00640 {
00641    // For an edge, prefer the patch of the front-facing Bface.
00642    // For a face return its own patch.
00643    // For a vertex just return any adjacent patch.
00644 
00645    return is_edge(s) ? ((CBedge*)s)->patch() : get_patch(get_bface(s));
00646 }
00647 
00648 //! \brief Similar to get_patch(CBface*), but returns the control Patch.
00649 //! \relates Patch
00650 //! \relatesalso Bface
00651 inline Patch*
00652 get_ctrl_patch(CBface* f)
00653 {
00654    Patch* p = get_patch(f);
00655    return p ? p->ctrl_patch() : 0;
00656 }
00657 
00658 //! \brief Similar to get_patch(CBsimplex*), but returns the control Patch.
00659 //! \relates Patch
00660 //! \relatesalso Bsimplex
00661 inline Patch*
00662 get_ctrl_patch(CBsimplex* s)
00663 {
00664    Patch* p = get_patch(s);
00665    return p ? p->ctrl_patch() : 0;
00666 }
00667 
00668 /*****************************************************************
00669  * PatchEdgeFilter:
00670  *****************************************************************/
00671 class PatchEdgeFilter : public SimplexFilter {
00672  public:
00673    PatchEdgeFilter(Patch* p) : _patch(p) {}
00674 
00675    virtual bool accept(CBsimplex* s) const {
00676       if (!is_edge(s))
00677          return false;
00678       Bedge* e = (Bedge*)s;
00679       return (
00680          !_patch                      ||
00681          get_patch(e->f1()) == _patch ||
00682          get_patch(e->f2()) == _patch
00683          );
00684    }
00685 
00686  protected:
00687    Patch*  _patch;
00688 };
00689 
00690 /*****************************************************************
00691  * PatchFaceFilter:
00692  *****************************************************************/
00693 class PatchFaceFilter : public SimplexFilter {
00694  public:
00695    PatchFaceFilter(Patch* p) : _patch(p) {}
00696 
00697    virtual bool accept(CBsimplex* s) const {
00698       if (!is_face(s))
00699          return false;
00700       return ((Bface*)s)->patch() == _patch;
00701    }
00702 
00703  protected:
00704    Patch*  _patch;
00705 };
00706 
00707 /*****************************************************************
00708  * Patch_list
00709  *
00710  *   Defined in bmesh.H, inlined convenience methods defined here.
00711  *****************************************************************/
00712 inline void
00713 Patch_list::creases_changed() const
00714 {
00715    for (int k=0; k<_num; k++)
00716       _array[k]->creases_changed();
00717 }
00718 
00719 inline void
00720 Patch_list::triangulation_changed() const
00721 {
00722    for (int k=0; k<_num; k++)
00723       _array[k]->triangulation_changed();
00724 }
00725 
00726 inline void
00727 Patch_list::write_stream(ostream& os) const
00728 {
00729    for (int k=0; k<_num; k++)
00730       _array[k]->write_stream(os);
00731 }
00732 
00733 inline void
00734 Patch_list::delete_all()
00735 {
00736    while (!empty())
00737       delete pop();
00738 }
00739 
00740 inline double 
00741 Patch_list::min_alpha() const
00742 {
00743    double ret=1;
00744    for (int k=0; k<_num; k++)
00745       ret = min(ret, _array[k]->transp());
00746    return ret;
00747 }
00748 
00749 #endif // PATCH_H_IS_INCLUDED
00750 
00751 // end of file patch.H

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