[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] libvob/include/vob geom/Fillets2.hxx vobs/Fille...
From: |
Janne V. Kujala |
Subject: |
[Gzz-commits] libvob/include/vob geom/Fillets2.hxx vobs/Fille... |
Date: |
Fri, 13 Jun 2003 08:13:36 -0400 |
CVSROOT: /cvsroot/libvob
Module name: libvob
Branch:
Changes by: Janne V. Kujala <address@hidden> 03/06/13 08:13:36
Modified files:
include/vob/geom: Fillets2.hxx
include/vob/vobs: Fillet.hxx
Log message:
Implement blending for StretchedCircle (uses a numeric solution for the
6th degree equation)
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/geom/Fillets2.hxx.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/vobs/Fillet.hxx.diff?tr1=1.13&tr2=1.14&r1=text&r2=text
Patches:
Index: libvob/include/vob/geom/Fillets2.hxx
diff -u libvob/include/vob/geom/Fillets2.hxx:1.11
libvob/include/vob/geom/Fillets2.hxx:1.12
--- libvob/include/vob/geom/Fillets2.hxx:1.11 Thu Jun 12 09:28:53 2003
+++ libvob/include/vob/geom/Fillets2.hxx Fri Jun 13 08:13:36 2003
@@ -160,6 +160,7 @@
float tangentAngle;
Vec dirTang;
+ float dtSign;
float r1;
@@ -168,6 +169,8 @@
float x0;
float x1;
+ float cutangle;
+
StretchedCircleFillet(
const CircularNode &node,
const LinearConnectionHalf &conn,
@@ -184,10 +187,12 @@
x1 = (node.r+r1) * cos(ta);
dirTang = dirVec(conn.a - conn.sign * tangentAngle);
+ dtSign = conn.sign;
+ cutangle = M_PI/2 - tangentAngle;
}
ZVec point(float fract, ZVec *intern = 0) const {
- float angle = lerp(0, M_PI/2 - tangentAngle, fract);
+ float angle = lerp(0, cutangle, fract);
float y = (1-cos(angle)) * r1 + conn.t / 2;
@@ -207,6 +212,84 @@
}
return pt;
+ }
+
+ ZVec point(Vec dir, bool &success, float *ptfract = NULL) const {
+ if (!infillet(dir)) {
+ success = false;
+ return ZVec();
+ }
+
+
+
+ float f0 = 0;
+ float f1 = 1;
+ float f;
+
+ ZVec p0 = point(f0) - node.ctr;
+ ZVec p1 = point(f1) - node.ctr;
+ ZVec p;
+
+ const float eps = 1E-3;
+ float coseps = cos(eps);
+
+ while (1) {
+ f = 0.5 * (f0 + f1);
+ p = point(f) - node.ctr;
+
+ float t = dir.dot(p);
+ /*
+ cout << f << Vec(p.x,p.y).normalized()
+ << f0 << Vec(p0.x,p0.y).normalized()
+ << f1 << Vec(p1.x,p1.y).normalized()
+ << dir << t * t / p.dot(p) << std::endl;
+ */
+ if (t * t > coseps * (p.x * p.x + p.y * p.y)) break;
+
+ if (f < eps || f > (1 - eps)) {
+ success = false;
+ return p + node.ctr;
+ }
+
+ if (dir.cross(p) * dtSign > 0) {
+ p0 = p;
+ f0 = f;
+ } else {
+ p1 = p;
+ f1 = f;
+ }
+ }
+
+ success = true;
+ if (ptfract) *ptfract = f;
+ return p + node.ctr;
+ }
+ void cutEnd(Vec dir) {
+ bool success;
+ float ptfract;
+ cutangle = M_PI/2 - tangentAngle;
+ point(dir, success, &ptfract);
+ if (success)
+ cutangle = lerp(0, M_PI/2 - tangentAngle, ptfract);
+ }
+
+ /** Whether the given direction vector from the center of the node is
inside
+ * the fillet. This does *not* guarantee that point(dir) will be a
success:
+ * this function includes vectors inside the connection to the fillet
but point()
+ * naturally does not.
+ */
+ bool infillet(Vec dir) const {
+ 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.
+ * This is not *quite* the same as the trivial definition
+ * of overlapping: it returns false if the tangent points are
+ * past the connections.
+ */
+ bool overlaps(const StretchedCircleFillet &other) const {
+ return infillet(other.dirTang) || other.infillet(dirTang);
}
};
Index: libvob/include/vob/vobs/Fillet.hxx
diff -u libvob/include/vob/vobs/Fillet.hxx:1.13
libvob/include/vob/vobs/Fillet.hxx:1.14
--- libvob/include/vob/vobs/Fillet.hxx:1.13 Thu Jun 12 09:28:53 2003
+++ libvob/include/vob/vobs/Fillet.hxx Fri Jun 13 08:13:36 2003
@@ -305,13 +305,55 @@
StretchedCircleFillet f1(node, c1, conn1.a);
StretchedCircleFillet f2(node, c2, conn2.a);
- 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), 1);
- renderSpan(f2, -1);
+ //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), 1);
+ //renderSpan(f2, -1);
+ // Find out how close they are.
+ if(a2-a1 < M_PI &&
+ (f1.infillet(f2.conn.dir) ||
+ f2.infillet(f1.conn.dir))) {
+ // Cleaved case
+ // 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));
+ StretchedCircleFillet vf2(node, vc2, conn2.a);
+
+ LinearConnectionHalf vc1(node, va1, d1, th1, -1, lerp(p0.z,
p1.z, .5));
+ StretchedCircleFillet vf1(node, vc1, conn1.a);
+
+ DBG(dbg_vfillets) << "P cleave: "<< w1<<" "<<w2<<" "
+ << ab<<" "<<fract<<" "<<va1<<" "<<va2<<
+ "\n";
+ renderSpan(
+ makeLerpFilletSpan(
+ makeFilletBlend(f1, vf2),
+ f1,
+ fract), 1
+ );
+
+ renderSpan(
+ makeLerpFilletSpan(
+ makeFilletBlend(f2, vf1),
+ f2,
+ fract), -1
+ );
+ } else
+ renderNormalOrBlend(node, f1, f2);
} else if(flags & 16) { // Ellipses
// For now, fix angle of attachment to the given angle
EllipseCircleFillet f1(node, c1, conn1.a);
- [Gzz-commits] libvob/include/vob geom/Fillets2.hxx vobs/Fille...,
Janne V. Kujala <=
- [Gzz-commits] libvob/include/vob geom/Fillets2.hxx vobs/Fille..., Janne V. Kujala, 2003/06/24
- [Gzz-commits] libvob/include/vob geom/Fillets2.hxx vobs/Fille..., Janne V. Kujala, 2003/06/24
- [Gzz-commits] libvob/include/vob geom/Fillets2.hxx vobs/Fille..., Janne V. Kujala, 2003/06/25
- [Gzz-commits] libvob/include/vob geom/Fillets2.hxx vobs/Fille..., Janne V. Kujala, 2003/06/25
- [Gzz-commits] libvob/include/vob geom/Fillets2.hxx vobs/Fille..., Janne V. Kujala, 2003/06/25