gzz-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gzz-commits] libvob/include/vob/vobs Fillet.hxx


From: Janne V. Kujala
Subject: [Gzz-commits] libvob/include/vob/vobs Fillet.hxx
Date: Thu, 03 Jul 2003 15:13:15 -0400

CVSROOT:        /cvsroot/libvob
Module name:    libvob
Branch:         
Changes by:     Janne V. Kujala <address@hidden>        03/07/03 15:13:15

Modified files:
        include/vob/vobs: Fillet.hxx 

Log message:
        cleanup

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/vobs/Fillet.hxx.diff?tr1=1.41&tr2=1.42&r1=text&r2=text

Patches:
Index: libvob/include/vob/vobs/Fillet.hxx
diff -u libvob/include/vob/vobs/Fillet.hxx:1.41 
libvob/include/vob/vobs/Fillet.hxx:1.42
--- libvob/include/vob/vobs/Fillet.hxx:1.41     Thu Jul  3 11:06:45 2003
+++ libvob/include/vob/vobs/Fillet.hxx  Thu Jul  3 15:13:15 2003
@@ -742,7 +742,7 @@
            int n = rtbl.size() - 1;
            float a = v.atan();
            float t = sqrt(a / f.tangentAngle);
-           unsigned i = (unsigned)(t * n);
+           int i = (int)(t * n);
            float fract = t * n - i;
            if (i >= n) return rtbl[n];
            return (1 - fract) * rtbl[i] + fract * rtbl[i + 1];
@@ -855,6 +855,39 @@
        
     }
 
+    void renderGrid(const std::vector<ZVec> &pt, int n, int m) const {
+       std::vector<ZVec> norm(n * m);
+       int i, j;
+
+       for (i = 0; i < n; i++) {
+           for (j = 0; j < m; j++) {
+               ZVec px0 = pt[(i==  0 ?   0 : i-1) * m + j];
+               ZVec px1 = pt[(i==n-1 ? n-1 : i+1) * m + j];
+               ZVec py0 = pt[i * m + (j==  0 ?   0 : j-1)];
+               ZVec py1 = pt[i * m + (j==m-1 ? m-1 : j+1)];
+
+               norm[i * m + j] = (px1 - px0).crossp(py1 - py0).normalized();
+           }
+       }
+
+       for (i = 0; i < n - 1; i++) {
+           glBegin(GL_QUAD_STRIP);
+           for (j = 0; j < m; j++) {
+               glNormal(norm[i * m + j]);
+               glVertex(pt[i * m + j]);
+
+               glNormal(norm[(i+1) * m + j]);
+               glVertex(pt[(i+1) * m + j]);
+           }
+           glNormal(norm[i * m + 0]);
+           glVertex(pt[i * m + 0]);
+
+           glNormal(norm[(i+1) * m + 0]);
+           glVertex(pt[(i+1) * m + 0]);
+           glEnd();
+       }
+    }
+
     void render(const Transform **t, int n) const {
        const Transform &thick_t = *t[0];
        const Transform &angle_t = *t[1];
@@ -886,8 +919,7 @@
 
 #if 1 // Old  version without Dicer
 
-       ZVec pt[ndice + 1][ndice*2];
-       ZVec norm[ndice + 1][ndice*2];
+       std::vector<ZVec> pt((ndice + 1) * (ndice * 2));
 
        for (i = 0; i <= ndice; i++) {
            float a = i * M_PI / ndice;
@@ -900,43 +932,15 @@
                float y = cos(b) * R;
                float z = sin(b) * R;
 
-               pt[i][j] = r * ZVec(x, y, z);
+               pt[i * (ndice * 2) + j] = r * ZVec(x, y, z);
            }
        }
 
+       for (i = 0; i < (ndice + 1) * (ndice * 2); i++)
+           pt[i] = blend(conns, N, r, pt[i]) + p0;
 
-       for (i = 0; i <= ndice; i++)
-           for (j = 0; j < ndice*2; j++)
-               pt[i][j] = blend(conns, N, r, pt[i][j]) + p0;
-
+       renderGrid(pt, ndice + 1, ndice * 2);
                
-       for (i = 0; i <= ndice; i++) {
-           for (j = 0; j < ndice*2; j++) {
-               ZVec px0 = pt[i==0 ? 0 : i-1][j];
-               ZVec px1 = pt[i==ndice ? ndice : i+1][j];
-               ZVec py0 = pt[i][j==0 ? 0 : j-1];
-               ZVec py1 = pt[i][j==ndice*2-1 ? ndice*2-1 : j+1];
-
-               norm[i][j] = (px1 - px0).crossp(py1 - py0).normalized();
-           }
-       }
-
-       for (i = 0; i < ndice; i++) {
-           glBegin(GL_QUAD_STRIP);
-           for (j = 0; j < ndice*2-1; j++) {
-               glNormal(norm[i][j]);
-               glVertex(pt[i][j]);
-
-               glNormal(norm[i+1][j]);
-               glVertex(pt[i+1][j]);
-           }
-           glNormal(norm[i][0]);
-           glVertex(pt[i][0]);
-
-           glNormal(norm[i+1][0]);
-           glVertex(pt[i+1][0]);
-           glEnd();
-       }
 
 #else // use Dicer
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]