00001 #ifndef LFACE_H_HAS_BEEN_INCLUDED
00002 #define LFACE_H_HAS_BEEN_INCLUDED
00003
00004 #include "lvert.H"
00005 class LMESH;
00006
00007
00008
00009
00010 class Lface : public Bface {
00011 public:
00012
00013 enum {
00014 SUBDIV_ALLOCATED_BIT = Bface::NEXT_AVAILABLE_BIT,
00015 NEXT_AVAILABLE_BIT
00016 };
00017
00018
00019
00020 Lface(Lvert* u, Lvert* v, Lvert* w, Ledge* e, Ledge* f, Ledge* g) :
00021 Bface(u,v,w,e,f,g), _parent(0) {}
00022
00023 virtual ~Lface() { delete_subdiv_elements(); }
00024
00025
00026 LMESH* lmesh() const { return (LMESH*)mesh(); }
00027 Lvert* lv(int k) const { return (Lvert*) v(k); }
00028 Ledge* le(int k) const { return (Ledge*) e(k); }
00029
00030
00031
00032 Lface* parent() const { return _parent; }
00033
00034 void set_parent(Lface* f) { _parent = f; }
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 Lface* parent(int rel_level);
00046
00047 Lface* control_face() const {
00048 return _parent ? _parent->control_face() : (Lface*)this;
00049 }
00050
00051
00052
00053
00054 Lface* parent_bc(CWvec& bc, mlib::Wvec& ret) const;
00055 Lface* parent_bc(Wvec& bc) const { return parent_bc(bc,bc); }
00056
00057 Lface* child_bc (CWvec& bc, mlib::Wvec& ret) const;
00058 Lface* child_bc (Wvec& bc) const { return child_bc(bc,bc); }
00059
00060
00061
00062
00063
00064
00065
00066
00067 Lface* bc_to_level(int level, CWvec& bc, mlib::Wvec& ret) const;
00068 Lface* bc_to_level(int level, Wvec& bc) const {
00069 return bc_to_level(level, bc, bc);
00070 }
00071
00072
00073 Lface* bc_to_edit_level(Wvec& bc) const {
00074 return bc_to_level(_mesh->edit_level(), bc);
00075 }
00076
00077
00078 bool subdiv_dirty() const { return is_clear(SUBDIV_ALLOCATED_BIT); }
00079 void allocate_subdiv_elements();
00080 void set_subdiv_elements();
00081 void delete_subdiv_elements();
00082
00083
00084 Ledge *subdiv_edge1() const {
00085 return (Ledge*)lookup_edge(le(1)->subdiv_vertex(),
00086 le(2)->subdiv_vertex());
00087 }
00088 Ledge *subdiv_edge2() const {
00089 return (Ledge*)lookup_edge(le(2)->subdiv_vertex(),
00090 le(3)->subdiv_vertex());
00091 }
00092 Ledge *subdiv_edge3() const {
00093 return (Ledge*)lookup_edge(le(3)->subdiv_vertex(),
00094 le(1)->subdiv_vertex());
00095 }
00096
00097
00098 Lface *subdiv_face_center() const {
00099 return (Lface*) lookup_face(subdiv_edge1(), subdiv_edge2());
00100 }
00101 Lface *subdiv_face1() const {
00102 return (Lface*) lookup_face(subdiv_edge3(),lv(1)->subdiv_vertex());
00103 }
00104 Lface *subdiv_face2() const {
00105 return (Lface*) lookup_face(subdiv_edge1(),lv(2)->subdiv_vertex());
00106 }
00107 Lface *subdiv_face3() const {
00108 return (Lface*) lookup_face(subdiv_edge2(),lv(3)->subdiv_vertex());
00109 }
00110
00111 void append_subdiv_faces(int lev, ARRAY<Bface *> &faces);
00112
00113 virtual void color_changed();
00114
00115
00116
00117
00118
00119
00120 virtual void make_primary();
00121 virtual void make_secondary();
00122
00123
00124 virtual void set_layer(ushort l);
00125
00126
00127
00128 virtual int detach();
00129 virtual void reverse();
00130
00131 protected:
00132 Lface* _parent;
00133
00134
00135 virtual void set_patch(Patch* p);
00136
00137
00138 void set_child_patch(Lface* subface, Patch*& child);
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151 void claim_child(Lface* child, bool center_face=false);
00152
00153
00154
00155
00156 Lface* gen_child_face(Bvert* v1, Bvert* v2, Bvert* v3,
00157 Patch* p, LMESH* m, bool center_face=false);
00158 };
00159
00160
00161
00162
00163 inline Lface*
00164 get_child(Lface* f, int level)
00165 {
00166
00167
00168
00169
00170
00171 while (f && level > 0) {
00172 f->allocate_subdiv_elements();
00173 f = f->subdiv_face_center();
00174 level--;
00175 }
00176 return f;
00177 }
00178
00179 inline Lface*
00180 get_parent(Lface* f, int level)
00181 {
00182
00183
00184
00185 return f ? f->parent(level) : 0;
00186 }
00187
00188 inline Lface*
00189 remap(Lface* f, int level)
00190 {
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202 if (!f)
00203 return 0;
00204 if (level == 0)
00205 return f;
00206 if (level > 0)
00207 return get_child(f, level);
00208
00209 return get_parent(f, -level);
00210 }
00211
00212 inline Lface*
00213 Ledge::ctrl_face() const
00214 {
00215 Bsimplex* sim = ctrl_element();
00216 return is_face(sim) ? (Lface*)sim : (Lface*)0;
00217 }
00218
00219 #endif // LFACE_H_HAS_BEEN_INCLUDED
00220
00221