[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: |
Thu, 03 Jul 2003 16:21:04 -0400 |
CVSROOT: /cvsroot/libvob
Module name: libvob
Branch:
Changes by: Janne V. Kujala <address@hidden> 03/07/03 16:21:04
Modified files:
include/vob/geom: Fillets2.hxx
include/vob/vobs: Fillet.hxx
Log message:
abstract
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/geom/Fillets2.hxx.diff?tr1=1.26&tr2=1.27&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/vobs/Fillet.hxx.diff?tr1=1.42&tr2=1.43&r1=text&r2=text
Patches:
Index: libvob/include/vob/geom/Fillets2.hxx
diff -u libvob/include/vob/geom/Fillets2.hxx:1.26
libvob/include/vob/geom/Fillets2.hxx:1.27
--- libvob/include/vob/geom/Fillets2.hxx:1.26 Thu Jul 3 09:18:58 2003
+++ libvob/include/vob/geom/Fillets2.hxx Thu Jul 3 16:21:04 2003
@@ -715,6 +715,77 @@
}
+ template <class Fillet>
+ struct Filletoid {
+ const CircularNode &node;
+ LinearConnectionHalf c;
+ Fillet f;
+ ZVec dir;
+
+ float da;
+ vector<float> rtbl;
+
+ Filletoid(const CircularNode &node,
+ float d,
+ float th,
+ float a,
+ ZVec dir) :
+ node(node),
+ c(node, 0, d, th, -1, 0),
+ f(node, c, a), dir(dir) {
+ compute_rtbl(100);
+ }
+
+ Vec trans(ZVec v) const {
+ float x = dir.dot(v);
+ float y = (v - x * dir).length();
+ return Vec(x, y);
+ }
+
+ float rad(ZVec v, bool &success) const {
+ Vec t = trans(v);
+ if (rtbl.size()) {
+ success = true;
+ return rad_rtbl(t);
+ }
+ ZVec pt = f.point(t, success);
+ if (success) return pt.length();
+ if (f.infillet(t)) {
+ success = true;
+ // return distance to the middle of the connection
+ return c.d / v.normalized().dot(dir);
+ }
+ return node.r;
+ }
+
+ void compute_rtbl(int n) {
+ rtbl.resize(n + 1);
+ for (int i = 0; i < n; i++) {
+ float t = i * (1.0 / n);
+ float a = (t * t) * f.tangentAngle;
+ bool success;
+ float fract;
+ ZVec pt = f.point(dirVec(a), success, &fract, .001);
+ if (success)
+ rtbl[i] = pt.length();
+ else
+ rtbl[i] = c.d / cos(a);
+ //cout << i << ": " << rtbl[i] << pt << fract << std::endl;
+ }
+ rtbl[n] = node.r;
+ }
+
+ float rad_rtbl(Vec v) const {
+ int n = rtbl.size() - 1;
+ float a = v.atan();
+ float t = sqrt(a / f.tangentAngle);
+ 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];
+ }
+ };
+
}
}
Index: libvob/include/vob/vobs/Fillet.hxx
diff -u libvob/include/vob/vobs/Fillet.hxx:1.42
libvob/include/vob/vobs/Fillet.hxx:1.43
--- libvob/include/vob/vobs/Fillet.hxx:1.42 Thu Jul 3 15:13:15 2003
+++ libvob/include/vob/vobs/Fillet.hxx Thu Jul 3 16:21:04 2003
@@ -679,75 +679,7 @@
return 0.5 * t.getSqSize().x;
}
- struct Conn {
- const CircularNode *node;
- LinearConnectionHalf c;
- StretchedCircleFillet f;
- ZVec dir;
-
- float da;
- vector<float> rtbl;
-
- Conn(const CircularNode &node,
- float d,
- float th,
- float a,
- ZVec dir) :
- node(&node),
- c(node, 0, d, th, -1, 0),
- f(node, c, a), dir(dir) {
- compute_rtbl(100);
- }
-
- Vec trans(ZVec v) const {
- float x = dir.dot(v);
- float y = (v - x * dir).length();
- return Vec(x, y);
- }
-
- float rad(ZVec v, bool &success) const {
- Vec t = trans(v);
- if (rtbl.size()) {
- success = true;
- return rad_rtbl(t);
- }
- ZVec pt = f.point(t, success);
- if (success) return pt.length();
- if (f.infillet(t)) {
- success = true;
- // return distance to the middle of the connection
- return c.d / v.normalized().dot(dir);
- }
- return node->r;
- }
-
- void compute_rtbl(int n) {
- rtbl.resize(n + 1);
- for (int i = 0; i < n; i++) {
- float t = i * (1.0 / n);
- float a = (t * t) * f.tangentAngle;
- bool success;
- float fract;
- ZVec pt = f.point(dirVec(a), success, &fract, .001);
- if (success)
- rtbl[i] = pt.length();
- else
- rtbl[i] = c.d / cos(a);
- //cout << i << ": " << rtbl[i] << pt << fract << std::endl;
- }
- rtbl[n] = node->r;
- }
-
- float rad_rtbl(Vec v) const {
- int n = rtbl.size() - 1;
- float a = v.atan();
- float t = sqrt(a / f.tangentAngle);
- 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];
- }
- };
+ typedef Filletoid<StretchedCircleFillet> Conn;
ZVec blend(Conn *conns[], int N, float r, ZVec pt) const {
int i, num = 0;
@@ -910,14 +842,44 @@
float d = (p1 - p0).length() / 2;
FilletSpan2::Conn conn(thick_t, angle_t, t0, t1, d);
-
+
conns[i] = new Conn(node, d, conn.th, conn.a,
(p1 - p0).normalized());
dirs.push_back((p1 - p0).normalized());
}
-#if 1 // Old version without Dicer
+#if 0
+
+ for (int k = 0; k < N; k++) {
+ std::vector<ZVec> pt((ndice + 1) * ndice);
+
+ for (i = 0; i <= ndice; i++) {
+ float f = (float)i / ndice;
+
+ Vec v = conns[k]->f.point(f);
+
+ ZVec e0 = conns[k]->dir;
+ ZVec e1 = e0.crossp(ref).normalized();
+ ZVec e2 = e0.crossp(e1);
+
+ for (j = 0; j < ndice; j++) {
+ float a = j * 2 * M_PI / ndice;
+
+ pt[i * ndice + j] =
+ v.x * e0
+ + v.y * cos(a) * e1
+ + v.y * sin(a) * e2;
+ }
+ }
+
+ for (i = 0; i < (ndice + 1) * ndice; i++)
+ pt[i] = blend(conns, N, r, pt[i]) + p0;
+
+ renderGrid(pt, ndice + 1, ndice);
+ }
+
+#elif 1 // Old version without Dicer
std::vector<ZVec> pt((ndice + 1) * (ndice * 2));