gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] libvob ./rules.mk include/vob/geom/Fillets2.hxx...


From: Tuomas J. Lukka
Subject: [Gzz-commits] libvob ./rules.mk include/vob/geom/Fillets2.hxx...
Date: Thu, 05 Jun 2003 00:56:13 -0400

CVSROOT:        /cvsroot/libvob
Module name:    libvob
Changes by:     Tuomas J. Lukka <address@hidden>        03/06/05 00:56:12

Modified files:
        .              : rules.mk 
        include/vob/geom: Fillets2.hxx 
        include/vob/vobs: Fillet.hxx 
        vob/demo/multifil: multifil.py 

Log message:
        Better edges

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/rules.mk.diff?tr1=1.22&tr2=1.23&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/geom/Fillets2.hxx.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/vobs/Fillet.hxx.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/vob/demo/multifil/multifil.py.diff?tr1=1.6&tr2=1.7&r1=text&r2=text

Patches:
Index: libvob/include/vob/geom/Fillets2.hxx
diff -u libvob/include/vob/geom/Fillets2.hxx:1.4 
libvob/include/vob/geom/Fillets2.hxx:1.5
--- libvob/include/vob/geom/Fillets2.hxx:1.4    Wed Jun  4 01:00:14 2003
+++ libvob/include/vob/geom/Fillets2.hxx        Thu Jun  5 00:56:12 2003
@@ -112,11 +112,12 @@
         * Useful for generating internal points.
         */
        ZVec projectToConnLine(ZVec v) const {
+           float l = (v - node.ctr).xylength();
            v = v - norm.dot(v-node.ctr) * norm;
            if(dir.dot(v-node.ctr) <= node.r) {
                v = v - dir.dot(v-node.ctr) * dir;
            }
-           v.z = lerp(node.ctr.z, z, (dir.dot(v-node.ctr) - node.r) / (d - 
node.r));
+           v.z = lerp(node.ctr.z, z, (l - node.r) / (d - node.r));
            return v;
        }
 
Index: libvob/include/vob/vobs/Fillet.hxx
diff -u libvob/include/vob/vobs/Fillet.hxx:1.8 
libvob/include/vob/vobs/Fillet.hxx:1.9
--- libvob/include/vob/vobs/Fillet.hxx:1.8      Wed Jun  4 01:00:14 2003
+++ libvob/include/vob/vobs/Fillet.hxx  Thu Jun  5 00:56:12 2003
@@ -262,9 +262,14 @@
 struct FilletSpan2 {
     enum { NTrans = 3 };
 
+    float border;
     int ndice;
     int flags;
 
+    template<class F> void params(F &f) {
+       f(border, ndice, flags);
+    }
+
     template<class T> float crad(const T &t) const {
        return t.getSqSize().x;
     }
@@ -277,10 +282,6 @@
        float dr = (d - (rmax-rmin)) / (r0 + r1);
        return .96 * rmin *  1 / (1 + dr);
     }
-    
-    template<class F> void params(F &f) {
-       f(ndice, flags);
-    }
 
     void v(ZVec p) const {
        if(flags & 4) {
@@ -318,13 +319,63 @@
        glEnd();
     }
 
-    template<class G> void renderSpan(const G &g) const {
-       if(flags & 1) 
-           renderSpanSolid(g);
-       if(flags & 2) 
-           renderSpanLine(g);
+    void pointInternNormal(ZVec p, ZVec intern, ZVec normal) const {
+       if(flags & 1) {
+           // solid 
+           v(p - border/2 * normal);
+           v(intern);
+       } else {
+           // Line
+           vl(p + border/2 * normal);
+           vl(p - border/2 * normal);
+       }
     }
 
+    template<class G> void renderSpanPolyedged(const G &g, int sign) const {
+       glBegin(GL_QUAD_STRIP); 
+       ZVec intern0;
+       ZVec p0 = g.point(0, &intern0);
+
+       ZVec intern1;
+       ZVec p1 = g.point(1 / (ndice-1.0), &intern1);
+
+       ZVec normal0 = sign * Vec(p1-p0).cw90().normalized();
+
+       pointInternNormal(p0, intern0, normal0);
+
+       ZVec prevpt = p0;
+       ZVec curpt = p1; ZVec curintern = intern1;
+       ZVec nextpt, nextintern;
+
+       for(int i=1; i<ndice-1; i++) {
+           float fract = (i+1) / (ndice-1.0);
+           nextpt = g.point(fract, &nextintern);
+
+           ZVec normal = sign * Vec(nextpt - prevpt).cw90().normalized();
+           pointInternNormal(curpt, curintern, normal);
+           prevpt = curpt;
+           curpt = nextpt;
+           curintern = nextintern;
+       }
+
+       ZVec normalLast = sign * Vec(curpt - prevpt).cw90().normalized();
+       pointInternNormal(curpt, curintern, normalLast);
+       
+       glEnd();
+    }
+
+    template<class G> void renderSpan(const G &g, int sign) const {
+       if(flags & 8) {
+           renderSpanPolyedged(g, -sign);
+       } else {
+           if(flags & 1) 
+               renderSpanSolid(g);
+           if(flags & 2) 
+               renderSpanLine(g);
+       }
+    }
+
+
 
     float normAngle(float a) const {
        while(a < 0) a += 2*M_PI;
@@ -399,25 +450,25 @@
                    makeLerpFilletSpan(
                        FilletBlend(f1, vf2),
                        f1,
-                       fract)
+                       fract), 1
                    );
 
            renderSpan(
                    makeLerpFilletSpan(
                        FilletBlend(f2, vf1),
                        f2,
-                       fract)
+                       fract), -1
                    );
        } else if(f1.overlaps(f2)) {
-           renderSpan(FilletBlend(f1, f2));
-           renderSpan(FilletBlend(f2, f1));
+           renderSpan(FilletBlend(f1, f2), 1);
+           renderSpan(FilletBlend(f2, f1), -1);
        } else {
-           renderSpan(f1);
+           renderSpan(f1, 1);
            float ta1 = f1.dirtang.atan();
            float ta2 = f2.dirtang.atan();
            if(ta2 < ta1) ta2 += 2*M_PI;
-           renderSpan(CircularNodeSpan(node, ta1, ta2));
-           renderSpan(f2);
+           renderSpan(CircularNodeSpan(node, ta1, ta2), 1);
+           renderSpan(f2, -1);
        }
 
     }
Index: libvob/rules.mk
diff -u libvob/rules.mk:1.22 libvob/rules.mk:1.23
--- libvob/rules.mk:1.22        Wed Jun  4 01:00:14 2003
+++ libvob/rules.mk     Thu Jun  5 00:56:12 2003
@@ -1,4 +1,4 @@
-GCCVER=3.3
+GCCVER=3.2
 
 .SUFFIXES: $(SUFFIXES) .dep .cxx .vobgenobj .transgenobj .vobdep .transdep 
.vobjniobj .transjniobj .vobgenjni .transgenjni .vobjnidep .transjnidep
 
Index: libvob/vob/demo/multifil/multifil.py
diff -u libvob/vob/demo/multifil/multifil.py:1.6 
libvob/vob/demo/multifil/multifil.py:1.7
--- libvob/vob/demo/multifil/multifil.py:1.6    Wed Jun  4 01:00:14 2003
+++ libvob/vob/demo/multifil/multifil.py        Thu Jun  5 00:56:12 2003
@@ -38,10 +38,11 @@
            vs.put(getDListNocoords("PolygonMode FRONT_AND_BACK LINE"))
 
        dice = 20
+       border = 2
        conns = GLRen.createSortedConnections(
-           GLRen.createFilletSpan2(dice, 1 + 4*self.depthColor + 
8*(1-self.fillets)))
+           GLRen.createFilletSpan2(border, dice, 1 + 4*self.depthColor + 
8*(1-self.fillets)))
        conns_l = GLRen.createSortedConnections(
-           GLRen.createFilletSpan2(dice, 2 + 4*self.depthColor + 
8*(1-self.fillets)))
+           GLRen.createFilletSpan2(border, dice, 2 + 4*self.depthColor + 
8*(1-self.fillets)))
 
        size = 50
        




reply via email to

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