gzz-commits
[Top][All Lists]
Advanced

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

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


From: Tuomas J. Lukka
Subject: [Gzz-commits] libvob include/vob/geom/Fillets2.hxx include/vo...
Date: Tue, 03 Jun 2003 08:52:42 -0400

CVSROOT:        /cvsroot/libvob
Module name:    libvob
Changes by:     Tuomas J. Lukka <address@hidden>        03/06/03 08:52:41

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

Log message:
        Fillet 2 nearly there

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

Patches:
Index: libvob/include/vob/geom/Fillets2.hxx
diff -u libvob/include/vob/geom/Fillets2.hxx:1.2 
libvob/include/vob/geom/Fillets2.hxx:1.3
--- libvob/include/vob/geom/Fillets2.hxx:1.2    Mon Jun  2 14:18:41 2003
+++ libvob/include/vob/geom/Fillets2.hxx        Tue Jun  3 08:52:40 2003
@@ -164,7 +164,7 @@
            bool success;
            ZVec in = project2circle(node.ctr + dir, node.ctr, fcenter,
                        frad, -1, &success);
-           if(success) return;
+           if(!success) return;
            this->aend = Vec(in-fcenter).atan();
            while(aend - astart >= M_PI) aend -= 2 * M_PI;
            while(astart - aend >= M_PI) aend += 2 * M_PI;
@@ -195,6 +195,9 @@
            return dirtang.cross(conn.dir) * dirtang.cross(dir) >= 0 &&
                conn.dir.cross(dirtang) * conn.dir.cross(dir) >= 0;
        }
+       /** Returns true if either of the directions where the circles
+        * are tangent is inside the other fillet area.
+        */
        bool overlaps(const CircleCircleFillet &other) const {
            return infillet(other.dirtang) || other.infillet(dirtang);
        }
@@ -232,6 +235,24 @@
        }
     };
 
+    template<class S1, class S2> struct LerpFilletSpan {
+       const S1 &s1;
+       const S2 &s2;
+       float fract;
+       LerpFilletSpan(const S1 &s1, const S2 &s2, float fract) : s1(s1), 
s2(s2), fract(fract) { }
+
+       ZVec point(float fract, ZVec *intern = 0) const {
+           ZVec i1, i2;
+           ZVec res = lerp(s1.point(fract, &i1), s2.point(fract, &i2), fract);
+           if(intern)
+               *intern = lerp(i1, i2, fract);
+           return res;
+       }
+    };
+    template<class S1, class S2> LerpFilletSpan<S1, S2> makeLerpFilletSpan(
+               const S1 &s1, const S2 &s2, float fract) {
+       return LerpFilletSpan<S1,S2>(s1, s2, fract);
+    }
 
     struct CircularNodeSpan {
        const CircularNode &node;
Index: libvob/include/vob/vobs/Fillet.hxx
diff -u libvob/include/vob/vobs/Fillet.hxx:1.6 
libvob/include/vob/vobs/Fillet.hxx:1.7
--- libvob/include/vob/vobs/Fillet.hxx:1.6      Mon Jun  2 14:18:42 2003
+++ libvob/include/vob/vobs/Fillet.hxx  Tue Jun  3 08:52:41 2003
@@ -326,6 +326,11 @@
     }
 
 
+    float normAngle(float a) const {
+       while(a < 0) a += 2*M_PI;
+       while(a >= 2*M_PI) a -= 2*M_PI;
+       return a;
+    }
 
     template<class T> void render(const T &t0, const T &t1, const T &t2) 
            const {
@@ -364,11 +369,43 @@
        CircleCircleFillet f2(node, c2);
 
        // Find out how close they are.
-/*     if(a2-a1 < M_PI &&
-               (f1.containsConnection(f2) ||
-                f2.containsConnection(f1))) {
+       if(a2-a1 < M_PI &&
+               (f1.infillet(f2.conn.dir) ||
+                f2.infillet(f1.conn.dir))) {
            // Cleaved case
-       } else */ if(f1.overlaps(f2)) {
+           // Need to construct virtual second connection, with only angle 
changed
+
+           // Width of fillet in radians
+           float w1 = normAngle(f1.dirtang.atan() - a1);
+           float w2 = normAngle(a2 - f2.dirtang.atan());
+           float maxw = w1 >? w2;
+           // Angle between connections
+           float ab = a2 - a1;
+
+           float fract = (maxw - ab) / maxw;
+           float va1 = a2 - maxw;
+           float va2 = a1 + maxw;
+
+           LinearConnectionHalf vc2(node, va2, d2, th2, -1, lerp(p0.z, p2.z, 
.5));
+           CircleCircleFillet vf2(node, vc2);
+
+           LinearConnectionHalf vc1(node, va1, d1, th1, -1, lerp(p0.z, p1.z, 
.5));
+           CircleCircleFillet vf1(node, vc1);
+
+           renderSpan(
+                   makeLerpFilletSpan(
+                       FilletBlend(f1, vf2),
+                       f1,
+                       fract)
+                   );
+
+           renderSpan(
+                   makeLerpFilletSpan(
+                       FilletBlend(f2, vf1),
+                       f2,
+                       fract)
+                   );
+       } else if(f1.overlaps(f2)) {
            renderSpan(FilletBlend(f1, f2));
            renderSpan(FilletBlend(f2, f1));
        } else {
Index: libvob/vob/demo/multifil/multifil.py
diff -u libvob/vob/demo/multifil/multifil.py:1.4 
libvob/vob/demo/multifil/multifil.py:1.5
--- libvob/vob/demo/multifil/multifil.py:1.4    Mon Jun  2 14:18:42 2003
+++ libvob/vob/demo/multifil/multifil.py        Tue Jun  3 08:52:41 2003
@@ -37,7 +37,7 @@
        if self.lines:
            vs.put(getDListNocoords("PolygonMode FRONT_AND_BACK LINE"))
 
-       dice = 200
+       dice = 20
        conns = GLRen.createSortedConnections(
            GLRen.createFilletSpan2(dice, 1 + 4*self.depthColor + 
8*(1-self.fillets)))
        conns_l = GLRen.createSortedConnections(




reply via email to

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