/[libvob]/libvob/include/vob/vobs/Fillet.hxx
ViewVC logotype

Diff of /libvob/include/vob/vobs/Fillet.hxx

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.44 by jvk, Fri Jul 4 12:49:53 2003 UTC revision 1.45 by jvk, Fri Jul 4 13:57:30 2003 UTC
# Line 671  struct Fillet3DBlend { Line 671  struct Fillet3DBlend {
671      int ndice;      int ndice;
672      float dicelen;      float dicelen;
673      int tblsize;      int tblsize;
674        int mode;
675    
676      template<class F> void params(F &f) {      template<class F> void params(F &f) {
677          f(ndice, dicelen, tblsize);          f(ndice, dicelen, tblsize, mode);
678      }      }
679    
680      template<class T> float crad(const T &t) const {      template<class T> float crad(const T &t) const {
# Line 772  struct Fillet3DBlend { Line 773  struct Fillet3DBlend {
773              float l1 = (v[j] - v[k]).length() * !(v[j].id && v[j].id == v[k].id);              float l1 = (v[j] - v[k]).length() * !(v[j].id && v[j].id == v[k].id);
774              float l2 = (v[k] - v[i]).length() * !(v[k].id && v[k].id == v[i].id);              float l2 = (v[k] - v[i]).length() * !(v[k].id && v[k].id == v[i].id);
775    
776                if (!(l0 < 1000 && l1 < 1000 && l2 < 1000))
777                    return -1;
778    
779              if (l0 < dicelen && l1 < dicelen && l2 < dicelen)              if (l0 < dicelen && l1 < dicelen && l2 < dicelen)
780                  return -1;                  return -1;
781    
# Line 898  struct Fillet3DBlend { Line 902  struct Fillet3DBlend {
902              dirs.push_back((p1 - p0).normalized());              dirs.push_back((p1 - p0).normalized());
903          }          }
904    
905  #if 1          if (mode == 0 || mode == 1) {
906    
907          for (int k = 0; k < N; k++) {          for (int k = 0; k < N; k++) {
908              std::vector<ZVec> pt((ndice + 1) * ndice);              std::vector<ZVec> pt((ndice + 1) * ndice);
# Line 935  struct Fillet3DBlend { Line 939  struct Fillet3DBlend {
939                            
940              renderCylinder2(pt, clip, ndice + 1, ndice);              renderCylinder2(pt, clip, ndice + 1, ndice);
941    
942              if (k == 0) {              if (k == 0 && mode == 0) {
943                  for (i = 0; i <= ndice; i++) {                  for (i = 0; i <= ndice; i++) {
944                      float f = (float)i / ndice;                      float f = (float)i / ndice;
945                                    
# Line 956  struct Fillet3DBlend { Line 960  struct Fillet3DBlend {
960              }              }
961          }          }
962    
963  #elif 1 // Old  version without Dicer          } else if (mode == 2) {
964    
965          std::vector<ZVec> pt((ndice + 1) * (ndice * 2));              std::vector<ZVec> pt((ndice + 1) * (ndice * 2));
966    
967          for (i = 0; i <= ndice; i++) {              for (i = 0; i <= ndice; i++) {
968              float a = i * M_PI / ndice;                  float a = i * M_PI / ndice;
969              float x = cos(a);                  float x = cos(a);
970              float R = sin(a);                  float R = sin(a);
971    
972              for (j = 0; j < ndice*2; j++) {                  for (j = 0; j < ndice*2; j++) {
973                  float b = j * M_PI * 2 / (ndice*2);                      float b = j * M_PI * 2 / (ndice*2);
974    
975                  float y = cos(b) * R;                      float y = cos(b) * R;
976                  float z = sin(b) * R;                      float z = sin(b) * R;
977    
978                  pt[i * (ndice * 2) + j] = r * ZVec(x, y, z);                      pt[i * (ndice * 2) + j] = r * ZVec(x, y, z);
979                    }
980              }              }
         }  
981    
         for (i = 0; i < (ndice + 1) * (ndice * 2); i++)  
             pt[i] = blend(conns, N, r, pt[i]) + p0;  
982    
983          renderCylinder(pt, ndice + 1, ndice * 2);  
984                for (i = 0; i < (ndice + 1) * (ndice * 2); i++)
985                    pt[i] = blend(conns, N, r, pt[i]) + p0;
986    
987                renderCylinder(pt, ndice + 1, ndice * 2);
988            } else {
989                                    
990    
991  #else // use Dicer          // use Dicer
992    
993          Verts verts(*this, conns, N, r);          Verts verts(*this, conns, N, r);
994          ::Vob::Dicer::Triangles<Verts> triangler(verts);          ::Vob::Dicer::Triangles<Verts> triangler(verts);
995    
996  #if 0 // use Delaunay triangulation based topology          if (mode == 3) {
997    
998            // use Delaunay triangulation based topology
999    
1000          if (dirs.size() == 2) {          if (dirs.size() == 2) {
1001              ZVec sum = dirs[0] + dirs[1];              ZVec sum = dirs[0] + dirs[1];
# Line 1083  struct Fillet3DBlend { Line 1092  struct Fillet3DBlend {
1092                  triangler.add(nvert, poly[j], poly[(j+1) % poly.size()]);                  triangler.add(nvert, poly[j], poly[(j+1) % poly.size()]);
1093          }          }
1094    
1095  #else // Icosahedron topology          } else if (mode == 4) {
1096    
1097          // icosahedron code adapted from sphere.c found in          // icosahedron code adapted from sphere.c found in
1098          // http://www.sgi.com/Technology/openGL/advanced/programs.html          // http://www.sgi.com/Technology/openGL/advanced/programs.html
# Line 1141  struct Fillet3DBlend { Line 1150  struct Fillet3DBlend {
1150          triangler.add(Im1, Im0, Im5);          triangler.add(Im1, Im0, Im5);
1151          triangler.add(Im2, Im1, Im5);          triangler.add(Im2, Im1, Im5);
1152    
1153  #endif          }
1154                    
1155    
1156          triangler.dice(DiceCrit(verts, verts.noblend ? .01 * dicelen : dicelen));          triangler.dice(DiceCrit(verts, verts.noblend ? .01 * dicelen : dicelen));
# Line 1181  struct Fillet3DBlend { Line 1190  struct Fillet3DBlend {
1190          }          }
1191          glEnd();          glEnd();
1192    
1193  #endif // use Dicer          }
1194    
1195          for (i = 0; i < N; i++) {          for (i = 0; i < N; i++) {
1196              delete conns[i];              delete conns[i];

Legend:
Removed from v.1.44  
changed lines
  Added in v.1.45

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26