[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] libvob include/vob/geom/Fillets.hxx include/vob...
From: |
Tuomas J. Lukka |
Subject: |
[Gzz-commits] libvob include/vob/geom/Fillets.hxx include/vob... |
Date: |
Thu, 29 May 2003 10:35:40 -0400 |
CVSROOT: /cvsroot/libvob
Module name: libvob
Changes by: Tuomas J. Lukka <address@hidden> 03/05/29 10:35:40
Modified files:
include/vob/geom: Fillets.hxx
include/vob/vobs: Fillet.hxx
vob/demo : multifil.py
Log message:
Filling up some of the fillets
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/geom/Fillets.hxx.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/vobs/Fillet.hxx.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/vob/demo/multifil.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
Patches:
Index: libvob/include/vob/geom/Fillets.hxx
diff -u libvob/include/vob/geom/Fillets.hxx:1.1
libvob/include/vob/geom/Fillets.hxx:1.2
--- libvob/include/vob/geom/Fillets.hxx:1.1 Thu May 29 04:00:20 2003
+++ libvob/include/vob/geom/Fillets.hxx Thu May 29 10:35:40 2003
@@ -76,7 +76,9 @@
struct FilletSpan {
CircleFillet a, b;
float aa, ab;
- Vec ctr;
+ float da, db;
+ float za, zb;
+ ZVec ctr;
float r;
/** The three states of the two fillet edges
* involved here. Separate = no interaction,
@@ -100,17 +102,23 @@
* @param ab Angle of fillet b. Always > aa
*/
FilletSpan(
- Vec ctr,
+ ZVec ctr,
float r,
float aa,
float da,
float ta,
+ float za,
float ab,
float db,
- float tb
+ float tb,
+ float zb
) {
this->aa = aa;
this->ab = ab;
+ this->da = da;
+ this->db = db;
+ this->za = za;
+ this->zb = zb;
this->ctr = ctr;
this->r = r;
this->f = -1;
@@ -151,23 +159,13 @@
}
}
- float rad_separate(Vec dir) {
- float ra = a.rad(dir);
- float rb = b.rad(dir);
- return ra >? rb;
- }
-
- template <class Blender> float rad_blended(Vec dir, const Blender &b) {
- float ra = this->a.rad(dir);
- float rb = this->b.rad(dir);
- return b(ra-r, rb-r) + r;
- }
// If calls to point should be split
bool split() { return type == CLEAVE; }
- template <class Blender> Vec point(float fract, const Blender &b) {
+ template <class Blender> ZVec point(float fract, const Blender &blend,
ZVec *intern = 0) {
if(type == CLEAVE) {
+ if(intern) *intern = ctr;
if(fract < .5) {
// Angle of real current sample
float ang = lerp(aa, aang, 2*fract);
@@ -179,9 +177,9 @@
Vec db = dirVec(ab - fangle + fangle/2 * (2*fract));
float ra = this->a.rad(da);
float rb = this->b.rad(db);
- float curvfra = b(ra-r, rb-r) + r;
+ float curvfra = blend(ra-r, rb-r) + r;
- Vec p = ctr + lerp(
+ ZVec p = ctr + lerp(
da * curvfra,
d * r0,
f);
@@ -201,9 +199,9 @@
Vec da = dirVec(aa + fangle - fangle/2 * (2*fract));
float rb = this->b.rad(db);
float ra = this->a.rad(da);
- float curvfra = b(rb-r, ra-r) + r;
+ float curvfra = blend(rb-r, ra-r) + r;
- Vec p = ctr + lerp(
+ ZVec p = ctr + lerp(
db * curvfra,
d * r0,
f);
@@ -214,11 +212,42 @@
} else {
// Use angle
Vec d = dirVec(lerp(aa, ab, fract));
+ float ra = a.rad(d);
+ float rb = b.rad(d);
+ float z, resr;
if(type == SEPARATE) {
- return ctr + d * rad_separate(d);
+ if(ra > rb) {
+ z = lerp(ctr.z, za, (ra - r) / (da-r)) ;
+ resr = ra;
+ } else {
+ z = lerp(ctr.z, zb, (rb - r) / (db-r)) ;
+ resr = rb;
+ }
} else {
- return ctr + d * rad_blended(d, b);
+ resr = blend(ra-r, rb-r) + r;
+ z = blend(ra-r, rb-r,
+ lerp(ctr.z, za, (ra - r) / (da-r)),
+ lerp(ctr.z, zb, (rb - r) / (db-r))
+ );
}
+ ZVec res = ctr + d * resr;
+ if(intern) {
+ if(ra > rb) {
+ *intern = d*resr;
+ *intern -= intern->dot(a.dirconn.cw90()) * a.dirconn.cw90();
+ intern->z = z;
+ if(intern->length() <= r) *intern = ZVec(0,0,0);
+ *intern += ctr;
+ } else {
+ *intern = d*resr;
+ *intern -= intern->dot(b.dirconn.cw90()) * b.dirconn.cw90();
+ intern->z = z;
+ if(intern->length() <= r) *intern = ZVec(0,0,0);
+ *intern += ctr;
+ }
+ }
+ res.z = z;
+ return res;
}
}
@@ -228,6 +257,9 @@
struct BlendSimply {
float operator()(float a, float b) const {
return a + b;
+ }
+ float operator()(float a, float b, float fa, float fb) const {
+ return (a*fa + b*fb) / (a+b + .0001);
}
};
Index: libvob/include/vob/vobs/Fillet.hxx
diff -u libvob/include/vob/vobs/Fillet.hxx:1.1
libvob/include/vob/vobs/Fillet.hxx:1.2
--- libvob/include/vob/vobs/Fillet.hxx:1.1 Thu May 29 04:00:20 2003
+++ libvob/include/vob/vobs/Fillet.hxx Thu May 29 10:35:40 2003
@@ -109,6 +109,7 @@
enum { NTrans = 3 };
int ndice;
+ int flags;
template<class T> float crad(const T &t) const {
return t.getSqSize().x;
@@ -124,7 +125,7 @@
}
template<class F> void params(F &f) {
- f(ndice);
+ f(ndice, flags);
}
template<class T> void render(const T &t0, const T &t1, const T &t2)
const {
@@ -132,7 +133,7 @@
ZVec p1 = t1.transform(t1.getSqSize()) ;
ZVec p2 = t2.transform(t2.getSqSize()) ;
- Vec ctr = p0;
+ ZVec ctr = p0;
Vec v1 = p1 - ctr;
Vec v2 = p2 - ctr;
@@ -156,8 +157,8 @@
"\n";
FilletSpan sp(ctr, csize,
- a1, d1, th1,
- a2, d2, th2);
+ a1, d1, th1, p1.z,
+ a2, d2, th2, p2.z);
// Render it. XXX -- jvk, you need to make this
// render the solid fillet.
if(sp.split()) {
@@ -176,16 +177,24 @@
}
glEnd();
} else {
- glBegin(GL_LINE_STRIP);
- for(float f = 0; f < 1; f+= 1.0 / ndice) {
- Vec p = sp.point(f, BlendSimply());
- glVertex3f(p.x, p.y,
- (f < .5 ?
- lerp(p1.z, p0.z, 2*f) :
- lerp(p2.z, p0.z, 2*(1-f)) )
- );
+ if(flags & 1) {
+ ZVec intern;
+ glBegin(GL_QUAD_STRIP);
+ for(float f = 0; f < 1; f+= 1.0 / ndice) {
+ ZVec p = sp.point(f, BlendSimply(), &intern);
+ glVertex(p);
+ glVertex(intern);
+ }
+ glEnd();
+ }
+ if(flags & 2) {
+ glBegin(GL_LINE_STRIP);
+ for(float f = 0; f < 1; f+= 1.0 / ndice) {
+ ZVec p = sp.point(f, BlendSimply(), 0);
+ glVertex(p);
+ }
+ glEnd();
}
- glEnd();
}
}
};
Index: libvob/vob/demo/multifil.py
diff -u libvob/vob/demo/multifil.py:1.1 libvob/vob/demo/multifil.py:1.2
--- libvob/vob/demo/multifil.py:1.1 Thu May 29 04:00:20 2003
+++ libvob/vob/demo/multifil.py Thu May 29 10:35:40 2003
@@ -16,29 +16,49 @@
self,
SlideLin("x", 200, 20, "x", "Left", "Right"),
SlideLin("y", 300, 20, "y", "Up", "Down"),
+ Toggle("drawEdge", 1, "Draw edge", "e"),
+ Toggle("drawInside", 1, "Draw inside", "i"),
)
def scene(self, vs):
putnoc(vs, background((.5,1,.2)))
+ vs.put(getDListNocoords("""
+ Enable DEPTH_TEST
+ LineWidth 3
+ PolygonOffset 100 100
+ """))
conns = GLRen.createSortedConnections(
- GLRen.createFilletSpan1(1000))
+ GLRen.createFilletSpan1(1000, 1))
+ conns_l = GLRen.createSortedConnections(
+ GLRen.createFilletSpan1(1000, 2))
size = 50
- a = vs.orthoBoxCS(0, "A", 0, 100, 100, 1, 1, size, size);
- b = vs.orthoBoxCS(0, "B", 0, self.x, self.y, 1, 1, size, size);
- c = vs.orthoBoxCS(0, "C", 0, 200, 500, 1, 1, size, size);
- d = vs.orthoBoxCS(0, "D", 0, 100, 300, 1, 1, size, size);
- e = vs.orthoBoxCS(0, "E", 0, 500, 500, 1, 1, size, size);
-
- vs.put(conns, [a, b, c, d])
- vs.put(conns, [b, a, d, e]);
- vs.put(conns, [c, a]);
- vs.put(conns, [d, a, b]);
-
- vs.put(GLRen.createDebugSwitch("Fillets", 1));
- vs.put(GLRen.createDebugSwitch("VFillets", 1));
- vs.put(conns, [e, b]);
- vs.put(GLRen.createDebugSwitch("Fillets", 0));
- vs.put(GLRen.createDebugSwitch("VFillets", 0));
+ a = vs.orthoBoxCS(0, "A", 10, 100, 100, 1, 1, size, size);
+ b = vs.orthoBoxCS(0, "B", 20, self.x, self.y, 1, 1, size, size);
+ c = vs.orthoBoxCS(0, "C", 30, 200, 500, 1, 1, size, size);
+ d = vs.orthoBoxCS(0, "D", 40, 100, 300, 1, 1, size, size);
+ e = vs.orthoBoxCS(0, "E", 50, 500, 500, 1, 1, size, size);
+
+ def pc(conns):
+ vs.put(conns, [a, b, c, d])
+ vs.put(conns, [b, a, d, e]);
+ vs.put(conns, [c, a]);
+ vs.put(conns, [d, a, b]);
+ #vs.put(GLRen.createDebugSwitch("Fillets", 1));
+ #vs.put(GLRen.createDebugSwitch("VFillets", 1));
+ vs.put(conns, [e, b]);
+ #vs.put(GLRen.createDebugSwitch("Fillets", 0));
+ #vs.put(GLRen.createDebugSwitch("VFillets", 0));
+
+
+
+ vs.put(getDListNocoords("""
+ Color 1 1 1
+ """))
+ if self.drawInside: pc(conns)
+ vs.put(getDListNocoords("""
+ Color 0 0 0
+ """))
+ if self.drawEdge: pc(conns_l)
- [Gzz-commits] libvob include/vob/geom/Fillets.hxx include/vob...,
Tuomas J. Lukka <=