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: Janne V. Kujala
Subject: [Gzz-commits] libvob include/vob/geom/Fillets2.hxx include/vo...
Date: Tue, 24 Jun 2003 10:30:04 -0400

CVSROOT:        /cvsroot/libvob
Module name:    libvob
Branch:         
Changes by:     Janne V. Kujala <address@hidden>        03/06/24 10:30:04

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

Log message:
        get rid of the triangle-shaped depth artifact

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/geom/Fillets2.hxx.diff?tr1=1.20&tr2=1.21&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/vobs/Fillet.hxx.diff?tr1=1.21&tr2=1.22&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/vob/demo/multifil/multifil.py.diff?tr1=1.15&tr2=1.16&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/vob/demo/multifil/randgraph.py.diff?tr1=1.14&tr2=1.15&r1=text&r2=text

Patches:
Index: libvob/include/vob/geom/Fillets2.hxx
diff -u libvob/include/vob/geom/Fillets2.hxx:1.20 
libvob/include/vob/geom/Fillets2.hxx:1.21
--- libvob/include/vob/geom/Fillets2.hxx:1.20   Tue Jun 24 09:13:24 2003
+++ libvob/include/vob/geom/Fillets2.hxx        Tue Jun 24 10:30:04 2003
@@ -213,9 +213,9 @@
            ZVec proj = conn.projectToConnLine(pt);
            pt.z = proj.z;
            if(intern) {
-               if(fract > .94)
-                   *intern = node.ctr;
-               else
+               //if(fract > .94)
+               //    *intern = node.ctr;
+               //else
                    *intern = proj;
                intern->z -= 20;
            }
@@ -616,16 +616,24 @@
      */
     struct CircularSliceSpan {
        const CircularNode &node;
-       float astart;
-       float aend;
+       ZVec v0;
+       ZVec v1;
        CircularSliceSpan(const CircularNode &node, 
-                       float astart, float aend)  :
-               node(node), astart(astart), aend(aend) {
+                         float astart, float aend)  :
+           node(node), 
+           v0(node.ctr + node.r * dirVec(astart)), 
+           v1(node.ctr + node.r * dirVec(aend)) {
+       }
+       CircularSliceSpan(const CircularNode &node, 
+                         Vec vstart, Vec vend)  :
+           node(node), 
+           v0(vstart.x, vstart.y, node.ctr.z), 
+           v1(vend.x, vend.y, node.ctr.z) {
        }
 
        ZVec point(float fract, ZVec *intern = 0) const {
            if(intern) *intern = node.ctr - ZVec(0,0,20);
-           return node.ctr + node.r * lerp(dirVec(astart), dirVec(aend), 
fract);
+           return lerp(v0, v1, fract);
        }
 
     };
Index: libvob/include/vob/vobs/Fillet.hxx
diff -u libvob/include/vob/vobs/Fillet.hxx:1.21 
libvob/include/vob/vobs/Fillet.hxx:1.22
--- libvob/include/vob/vobs/Fillet.hxx:1.21     Tue Jun 24 09:26:22 2003
+++ libvob/include/vob/vobs/Fillet.hxx  Tue Jun 24 10:30:04 2003
@@ -363,25 +363,20 @@
                DBG(dbg_vfillets) << "P cleave: "<< w1<<" "<<w2<<" "
                        << ab<<" "<<fract<<" "<<va1<<" "<<va2<<
                            "\n";
-               if (overlap1) 
-                   renderSpan(CircularSliceSpan(node, a1-w1, a1+w1), 0);
-               else
-                   renderSpan(
-                              makeLerpFilletSpan(
-                                                 makeFilletBlend(f1, vf2),
-                                                 f1,
-                                                 fract), 1
-                              );
-
-               if (overlap2) 
-                   renderSpan(CircularSliceSpan(node, a2-w2, a2+w2), 0);
-               else
-                   renderSpan(
-                              makeLerpFilletSpan(
-                                                 makeFilletBlend(f2, vf1),
-                                                 f2,
-                                                 fract), -1
-                              );
+               renderSpan2(node, a1,
+                           makeLerpFilletSpan(
+                                              makeFilletBlend(f1, vf2),
+                                              f1,
+                                              fract), 1,
+                           overlap1);
+
+               renderSpan2(node, a2,
+                           makeLerpFilletSpan(
+                                              makeFilletBlend(f2, vf1),
+                                              f2,
+                                              fract), -1,
+                           overlap2
+                           );
            } else 
                renderNormalOrBlend(node, f1, f2, overlap1, overlap2);
        } else if(flags & 16) { // Ellipses
@@ -483,36 +478,29 @@
     }
 
     template<class F> void renderNormalOrBlend(const CircularNode &node, const 
F &f1, const F &f2, bool overlap1 = false, bool overlap2 = false) const {
-       float a1 = f1.conn.a;
-       float a2 = f2.conn.a;
-       float w1 = normAngle(f1.dirTang.atan() - a1);
-       float w2 = normAngle(a2 - f2.dirTang.atan());
-       
        if(f1.overlaps(f2)) {
-           if (overlap1) 
-               renderSpan(CircularSliceSpan(node, a1-w1, a1+w1), 0);
-           else
-               renderSpan(makeFilletBlend(f1, f2), 1);
-
-           if (overlap2) 
-               renderSpan(CircularSliceSpan(node, a2-w2, a2+w2), 0);
-           else
-               renderSpan(makeFilletBlend(f2, f1), -1);
-           
+           renderSpan2(node, f1.conn.a, makeFilletBlend(f1, f2), 1, overlap1);
+           renderSpan2(node, f2.conn.a, makeFilletBlend(f2, f1), -1, overlap2);
        } else {
-           if (overlap1) 
-               renderSpan(CircularSliceSpan(node, a1-w1, a1+w1), 0);
-           else
-               renderSpan(f1, 1);
+           renderSpan2(node, f1.conn.a, f1, 1, overlap1);
+           
            float ta1 = f1.dirTang.atan();
            float ta2 = f2.dirTang.atan();
            if(ta2 < ta1) ta2 += 2*M_PI;
            renderSpan(CircularNodeSpan(node, ta1, ta2), 1);
-           if (overlap2) 
-               renderSpan(CircularSliceSpan(node, a2-w2, a2+w2), 0);
-           else
-               renderSpan(f2, -1);
+
+           renderSpan2(node, f2.conn.a, f2, -1, overlap2);
        }
+    }
+
+    template<class F> void renderSpan2(const CircularNode &node, float a0, 
const F &f, int sign, bool overlap) const {
+       Vec p1 = f.point(1);
+       Vec n = dirVec(a0).cw90();
+       Vec p2 = p1 - node.ctr;
+       p2 = p2 - n.dot(p2) * n + node.ctr;
+       if (flags & 128)
+           renderSpan(CircularSliceSpan(node, p1, p2), 0);
+       if (!overlap) renderSpan(f, sign);
     }
 
 };
Index: libvob/vob/demo/multifil/multifil.py
diff -u libvob/vob/demo/multifil/multifil.py:1.15 
libvob/vob/demo/multifil/multifil.py:1.16
--- libvob/vob/demo/multifil/multifil.py:1.15   Sat Jun 14 03:53:04 2003
+++ libvob/vob/demo/multifil/multifil.py        Tue Jun 24 10:30:04 2003
@@ -47,6 +47,7 @@
            Toggle("ellipses", 1, "Toggle ellipses", "s"),
            Toggle("stretched", 1, "Toggle stretched", "v"),
            Toggle("curvature", 0, "Show curvature", "c"),
+           Toggle("sectors", 1, "Show sectors", "z"),
            SlideLin("size", 50, 5, "Node size", "K", "k"),
            SlideLin("dice", 20, 1, "Dice factor", "P", "p"),
        )
@@ -77,15 +78,28 @@
        border = 2
        conns = GLRen.createSortedConnections(
            GLRen.createFilletSpan2(border, self.dice, 
-                           1 + 4*self.depthColor + 16 * self.ellipses + 64 * 
self.stretched),
+                                    1 +
+                                    4 * self.depthColor +
+                                    16 * self.ellipses +
+                                    64 * self.stretched +
+                                    128 * self.sectors),
            2)
        conns_l = GLRen.createSortedConnections(
            GLRen.createFilletSpan2(border, self.dice, 
-                           2 + 4*self.depthColor + 16 * self.ellipses + 64 * 
self.stretched),
+                                    2 +
+                                    4 * self.depthColor +
+                                    16 * self.ellipses +
+                                    64 * self.stretched +
+                                    128 * self.sectors),
            2)
        conns_c = GLRen.createSortedConnections(
            GLRen.createFilletSpan2(1000, self.dice, 
-                           2 + 4*self.depthColor + 16 * self.ellipses + 64 * 
self.stretched + 32),
+                                    2 +
+                                    4 * self.depthColor +
+                                    16 * self.ellipses +
+                                    32 +
+                                    64 * self.stretched +
+                                    128 * self.sectors),
            2)
 
        a = vs.orthoBoxCS(0, "A", 0, 100, 100, 1, 1, self.size, self.size);
Index: libvob/vob/demo/multifil/randgraph.py
diff -u libvob/vob/demo/multifil/randgraph.py:1.14 
libvob/vob/demo/multifil/randgraph.py:1.15
--- libvob/vob/demo/multifil/randgraph.py:1.14  Sat Jun 14 03:53:04 2003
+++ libvob/vob/demo/multifil/randgraph.py       Tue Jun 24 10:30:04 2003
@@ -47,6 +47,7 @@
            Toggle("ellipses", 1, "Toggle ellipses", "s"),
            Toggle("stretched", 1, "Toggle stretched", "v"),
            Toggle("curvature", 1, "Show curvature", "c"),
+           Toggle("sectors", 1, "Show sectors", "z"),
            SlideLin("N", 21, 3, "N", "N", "n"),
            SlideLin("ang", 21, 3, "Rotation angle", "Prior", "Next"),
            Toggle("fillets", 1, "Toggle filleting", "f"),
@@ -75,7 +76,8 @@
                                     4 * self.depthColor +
                                     8 * (1-self.fillets) +
                                     16 * self.ellipses +
-                                    64 * self.stretched), 2)
+                                    64 * self.stretched +
+                                    128 * self.sectors), 2)
         
        conns_l = GLRen.createSortedConnections(
            GLRen.createFilletSpan2(border, self.dice,
@@ -83,7 +85,8 @@
                                     4 * self.depthColor +
                                     8 * (1-self.fillets) +
                                     16 * self.ellipses +
-                                    64 * self.stretched), 2)
+                                    64 * self.stretched +
+                                    128 * self.sectors), 2)
 
         rng = Random(self.seed)
         N2 = 2*self.N/3




reply via email to

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