/[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.46 by jvk, Fri Jul 4 17:29:12 2003 UTC revision 1.47 by jvk, Sat Jul 5 11:55:57 2003 UTC
# Line 684  struct Fillet3DBlend { Line 684  struct Fillet3DBlend {
684      typedef Filletoid<StretchedCircleFillet> Conn;      typedef Filletoid<StretchedCircleFillet> Conn;
685    
686      ZVec blend(Conn *conns[], int N, float r, ZVec pt,      ZVec blend(Conn *conns[], int N, float r, ZVec pt,
687                 int *maxi = NULL) const {                 int *maxip = NULL) const {
688          int i, num = 0;          int i, num = 0;
689          double sum = 0;          double sum = 0;
690          float x[N];          float x[N];
691          float maxt = 0;          float maxt = -1;
692            int maxi = -1;
693    
694          pt = pt.normalized();          pt = pt.normalized();
695    
# Line 697  struct Fillet3DBlend { Line 698  struct Fillet3DBlend {
698          for (i = 0; i < N; i++) {          for (i = 0; i < N; i++) {
699              bool success;              bool success;
700              float t = conns[i]->rad(pt, success);              float t = conns[i]->rad(pt, success);
701              if (t < r) t = r;              if (success && t > r) {
702              if (success) {                  if (t > maxt) maxt = t, maxi = i;
703                    x[num++] = (t - r) / r;
704    
705                    // Approximate the slope of the fillet surface
706                    float t0 = sqrt(conns[i]->c.d * conns[i]->c.d +
707                                    conns[i]->c.t * conns[i]->c.t);
708                    t = (t - r) / (t0 - r);
709                    t = (t >? 0) <? 1;
710                    t = sqrt(t * (2 - t)) / (1 - t);
711    
712                    sum += t;
713    
714                  //cout << t << " ";                  //cout << t << " ";
                 sum += x[num++] = (t - r) / r;  
                 if (maxi) {  
                     if (t > maxt) maxt = t, *maxi = i;  
                 }  
715              }              }
716          }          }
717            if (maxip) *maxip = maxi;
718    
719          // Compute p for an l^p norm to be used as the blending function          // Compute p for an l^p norm to be used as the blending function
720          // p == 1: sum of distances,          // p == 1: sum of distances,
721          // p == \infty: maximum of distances          // p == \infty: maximum of distances
722          float p = 1.0 + sum;          float p = 1.0 + sum;
         if (p > 100) p = 100;  
723    
724          //cout << "p=" << p << " ";          //cout << "p=" << p << " ";
725    
# Line 719  struct Fillet3DBlend { Line 727  struct Fillet3DBlend {
727          for (i = 0; i < num; i++) {          for (i = 0; i < num; i++) {
728              sum += pow(x[i], p);              sum += pow(x[i], p);
729          }          }
730    
731            if (!finite(sum) || !finite(p))
732                return pt * maxt;
733                    
734          //cout << "->" << pow(sum, 1 / p) << std::endl;          //cout << "->" << pow(sum, 1 / p) << std::endl;
735    
# Line 879  struct Fillet3DBlend { Line 890  struct Fillet3DBlend {
890                  glNormal(norm[i * m + (j + 1) % m]);                  glNormal(norm[i * m + (j + 1) % m]);
891                  glVertex(pt[i * m + (j + 1) % m]);                  glVertex(pt[i * m + (j + 1) % m]);
892    
893                  if (clip[i * m + j] &&                  int k;
894                      clip[i * m + (j + 1)]) break;                  for (k = i; k < n; k++)
895                        if (!clip[k * m + j] ||
896                            !clip[i * m + (j + 1)])
897                            break;
898                    if (k > i) {
899                        if (k == n) break;
900                        if (k >= i + 2) {
901                            glEnd();
902                            i = k - 2;
903                            glBegin(GL_QUAD_STRIP);
904                        }
905                    }
906              }              }
907              glEnd();              glEnd();
908          }          }

Legend:
Removed from v.1.46  
changed lines
  Added in v.1.47

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