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

lstrip.C

Go to the documentation of this file.
00001 /**********************************************************************
00002  * lstrip.C:
00003  **********************************************************************/
00004 
00005 #include "mesh/lstrip.H"
00006 #include "mesh/lmesh.H"
00007 
00008 void
00009 Lstrip::delete_substrips()
00010 {
00011    delete _right_substrip;
00012    delete _left_substrip;
00013    _right_substrip = _left_substrip = 0;
00014 }
00015 
00016 void
00017 Lstrip::reset()
00018 {
00019    delete_substrips();
00020    TriStrip::reset();
00021 }
00022 
00023 int
00024 Lstrip::cur_level() const
00025 {
00026    return _verts.empty() ? 0 : ((Lvert*)_verts[0])->lmesh()->cur_level();
00027 }
00028 
00029 void
00030 Lstrip::draw(int level, StripCB* cb)
00031 {
00032    if (level < 1)
00033       TriStrip::draw(cb);
00034    else {
00035       generate_substrips();
00036       _right_substrip->draw(level-1, cb);
00037       _left_substrip-> draw(level-1, cb);
00038    }
00039 }
00040 
00041 void
00042 Lstrip::add(Bvert* v)
00043 {
00044    // this is a protected method of Lstrip.
00045    // it exists as a convenience, used in
00046    // Lstrip::build_substrip1() and
00047    // Lstrip::build_substrip2() (see below).
00048    // assumes the whole strip is built from
00049    // the sequence of verts -- corresponding
00050    // faces need to be looked up.
00051 
00052    if (v == 0) {
00053       err_msg("Lstrip::add: error: vertex is null");
00054       return;
00055    }
00056 
00057    _verts += v;
00058 
00059    int n = _verts.num();
00060 
00061    if (n < 3)
00062       return;   // just starting -- no face lookup yet
00063 
00064    // add face 3 times if this is the 3rd vert.
00065    // once otherwise
00066    Bface* f = lookup_face(_verts[n-3], _verts[n-2], v);
00067    if (n == 3) {
00068       _faces += f;
00069       _faces += f;
00070    }
00071    _faces += f;
00072 }
00073 
00074 
00075 void
00076 Lstrip::build_substrip1(Lstrip* substrip)
00077 {
00078    substrip->add(subvert(0));
00079    substrip->add(subvert(0,1));
00080 
00081    for (int k=2; k<_verts.num(); k++) {
00082       if (k%2) {
00083          substrip->add(subvert(k,k-1));
00084       } else {
00085          substrip->add(subvert(k,k-2));
00086          substrip->add(subvert(k,k-1));
00087          substrip->add(subvert(k));
00088       }
00089    }
00090 }
00091 
00092 void
00093 Lstrip::build_substrip2(Lstrip* substrip)
00094 {
00095    substrip->add(subvert(1,0));
00096    substrip->add(subvert(1));
00097 
00098    for (int k=2; k<_verts.num(); k++) {
00099       if (k%2) {
00100          substrip->add(subvert(k,k-2));
00101          substrip->add(subvert(k,k-1));
00102          substrip->add(subvert(k));
00103       } else {
00104          substrip->add(subvert(k,k-1));
00105       }
00106    }
00107 }
00108 
00109 void
00110 Lstrip::generate_substrips()
00111 {
00112    if (!_left_substrip) {
00113       _left_substrip  = new Lstrip(_orientation);
00114       _right_substrip = new Lstrip(_orientation);
00115 
00116       if (_orientation == 0) {
00117          build_substrip1(_left_substrip);
00118          build_substrip2(_right_substrip);
00119       } else {
00120          build_substrip2(_left_substrip);
00121          build_substrip1(_right_substrip);
00122       } 
00123    }
00124 }
00125 
00126 /* end of file lstrip.C */

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