00001
00002
00003
00004 #ifndef ZCROSS_PATH_H_IS_INCLUDED
00005 #define ZCROSS_PATH_H_IS_INCLUDED
00006
00007 #include "bvert.H"
00008 #include "bsimplex.H"
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 class ZXseg {
00028
00029 protected:
00030
00031
00032
00033
00034
00035
00036 Wpt _p;
00037
00038
00039
00040
00041
00042
00043 Bsimplex* _s;
00044
00045
00046
00047
00048
00049
00050 Bvert* _v;
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060 double _g;
00061
00062
00063
00064
00065 Wvec _bc;
00066
00067
00068
00069
00070
00071
00072 int _type;
00073
00074
00075
00076
00077 bool _end;
00078
00079 public:
00080
00081
00082
00083
00084 ZXseg(Bsimplex* s, CWpt &pt, Bvert * v, bool grad, mlib::CWvec& bc,
00085 int type = 0, bool end = 0)
00086 : _p(pt),
00087 _s(s),
00088 _v(v),
00089 _g(grad ? 1.0 : 0.0),
00090 _bc(bc),
00091 _type(type),
00092 _end(end)
00093 {}
00094
00095 ZXseg(Bsimplex* s, CWpt &pt, Bvert * v, double conf, mlib::CWvec& bc,
00096 int type = 0, bool end = 0)
00097 : _p(pt),
00098 _s(s),
00099 _v(v),
00100 _g(conf),
00101 _bc(bc),
00102 _type(type),
00103 _end(end)
00104 {}
00105
00106
00107 ZXseg(Bsimplex* s, CWpt &pt, Bvert * v, bool grad, Bsimplex* bary_s,
00108 int type = 0, bool end = 0)
00109 : _p(pt),
00110 _s(s),
00111 _v(v),
00112 _g(grad ? 1.0 : 0.0),
00113 _type(type),
00114 _end(end)
00115 {
00116
00117
00118
00119
00120
00121
00122 if (bary_s)
00123 bary_s->project_barycentric ( _p, _bc );
00124 }
00125
00126 ZXseg ()
00127 {
00128 _s = NULL;
00129 _v = NULL;
00130 _g = false;
00131
00132 }
00133
00134
00135
00136
00137
00138
00139 bool end() const { return _end; }
00140 Wpt& p() { return _p; }
00141 Bsimplex* s() const { return _s; }
00142
00143
00144 Bface* f() const { return get_bface(_s); }
00145 Bvert* v() const { return _v; }
00146 bool g() const { return _g > 0.0; }
00147 double conf() const { return _g; }
00148 int type() const { return _type; }
00149 CWvec& bc() const { return _bc; }
00150
00151
00152 void set_end() { _end = true; }
00153 void setf(Bsimplex* s) { _s = s; }
00154 void setv(Bvert* v) { _v = v; }
00155 void setg(bool g) { _g = g ? 1.0 : 0.0; }
00156 void setg(double g) { _g = g; }
00157 void settype(int t) { _type = t;}
00158 void set_bary( Bsimplex* s )
00159 { if(s) s->project_barycentric ( _p, _bc); }
00160
00161
00162
00163
00164
00165
00166 bool operator ==( const ZXseg& z) const
00167 {return _p==z._p && _s==z._s && _v==z._v && _g==z._g;}
00168
00169
00170
00171 };
00172
00173 #define CZXseg const ZXseg
00174
00175 class ZcrossCB;
00176
00177
00178
00179 #define CZcrossPath const ZcrossPath
00180 class ZcrossPath
00181 {
00182 public:
00183
00184
00185
00186 ZcrossPath() : _patch(0), _index(-1) {}
00187
00188
00189
00190 ZcrossPath(CBface_list& list) :
00191 _patch(0),
00192 _index(-1)
00193 {
00194
00195 build(list);
00196 }
00197
00198 virtual ~ZcrossPath() {}
00199
00200
00201
00202 void build(CBface_list& list);
00203
00204 bool has_sil(Bface* f);
00205
00206 void start_sil(Bface * f);
00207 void get_g(Bface*f , double g[3], int& ex1, int& ex2);
00208
00209 Bface* sil_walk_search ( Bface * f , Bvert* vert[3], double g[3] );
00210 Bface* sil_search (Bface * last , Bface *f);
00211 Bface* sil_finish (Bface * last , Bface *f);
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225 void add_seg ( Bface* f , CWpt& pt, Bvert* v, bool grad, mlib::CWvec& bc)
00226 {
00227 bool end = (f) ? false : true;
00228 _segs += ZXseg ( f, pt, v, grad, bc, 0, end );
00229 }
00230 void add_seg ( const ZXseg& seg) { _segs += seg; }
00231
00232 void add_seg ( Bface* f , CWpt& pt, Bvert* v, bool grad, Bface * bary_f)
00233 {
00234 bool end = (f) ? false : true;
00235 _segs += ZXseg ( f, pt, v, grad, bary_f, 0 ,end);
00236 }
00237
00238
00239 virtual void reset() { _segs.clear(); }
00240
00241
00242 Patch* patch() const { return _patch; }
00243 CARRAY<ZXseg>& segs() const { return _segs; }
00244 ARRAY<ZXseg>& segs() { return _segs; }
00245
00246
00247
00248 Bface* face(int i) const { return _segs[i].f(); }
00249 CWpt& point(int i) const { return _segs[i].p(); }
00250 Bvert* vert(int i ) const { return _segs[i].v(); }
00251 bool grad(int i) const { return _segs[i].g(); }
00252 CWvec& bc(int i) const { return _segs[i].bc();}
00253 int type(int i) const { return _segs[i].type();}
00254
00255 ZXseg& seg(int i ) { return _segs[i]; }
00256 void set_eye(CWpt& eye ) { _eye = eye; }
00257 CWpt& eye() const { return _eye; }
00258 CWpt& first() const { return _segs[0].p(); }
00259 CWpt& last() const { return _segs[num()-1].p(); }
00260
00261
00262 bool empty() const { return _segs.empty(); }
00263
00264 int num() const { return _segs.num(); }
00265
00266 BMESH* mesh() const
00267 {
00268 return empty() ? (BMESH*)0 : _segs[0].f()->mesh();
00269 }
00270
00271
00272
00273
00274 protected:
00275 friend class Patch;
00276
00277 ARRAY <ZXseg> _segs;
00278 Patch* _patch;
00279 int _index;
00280 Wpt _eye;
00281
00282
00283
00284
00285
00286
00287
00288 void set_patch(Patch* p) { _patch = p; }
00289 void set_patch_index(int k) { _index = k; }
00290 int patch_index() const { return _index; }
00291 };
00292
00293
00294
00295 enum { STYPE_SIL=0, STYPE_BF_SIL, STYPE_BORDER, STYPE_CREASE, STYPE_SUGLINE, STYPE_WPATH, STYPE_POLYLINE, STYPE_NUM } ;
00296
00297 #endif // ZCROSS_PATH_H_IS_INCLUDED
00298
00299