[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] gzz ./TODO gfx/demo/xupdf.py gfx/libcoords/Coor...
From: |
Tuomas J. Lukka |
Subject: |
[Gzz-commits] gzz ./TODO gfx/demo/xupdf.py gfx/libcoords/Coor... |
Date: |
Thu, 03 Oct 2002 07:23:36 -0400 |
CVSROOT: /cvsroot/gzz
Module name: gzz
Changes by: Tuomas J. Lukka <address@hidden> 02/10/03 07:23:36
Modified files:
. : TODO
gfx/demo : xupdf.py
gfx/libcoords : Coords.cxx
gzz/gfx/gl : GLVobCoorder.java
Log message:
Two new coord systems: translate and buoy
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/TODO.diff?tr1=1.226&tr2=1.227&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/xupdf.py.diff?tr1=1.44&tr2=1.45&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libcoords/Coords.cxx.diff?tr1=1.27&tr2=1.28&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/gfx/gl/GLVobCoorder.java.diff?tr1=1.34&tr2=1.35&r1=text&r2=text
Patches:
Index: gzz/TODO
diff -c gzz/TODO:1.226 gzz/TODO:1.227
*** gzz/TODO:1.226 Thu Oct 3 04:09:54 2002
--- gzz/TODO Thu Oct 3 07:23:36 2002
***************
*** 134,139 ****
--- 134,141 ----
- clean, rename and document Makefile targets (coordinate with mudyc:
do we want to use something else instead of make?)
tjl:
+ - clipping of coordsys: coordsys may, at setparams time,
+ decide not to be shown.
- fix the way nonlinearity of coordsys is handled.
Needs a slightly better approach, with also
direction of nonlinearity taken into account.
Index: gzz/gfx/demo/xupdf.py
diff -c gzz/gfx/demo/xupdf.py:1.44 gzz/gfx/demo/xupdf.py:1.45
*** gzz/gfx/demo/xupdf.py:1.44 Thu Oct 3 06:12:32 2002
--- gzz/gfx/demo/xupdf.py Thu Oct 3 07:23:36 2002
***************
*** 21,27 ****
from test.tools import tools
space = gzz.impl.ModularSpace(*tools.spaceArgList())
! xuindexer = gzz.index.impl.TransientXuIndexer()
enfoverlap = gzz.index.IndexManager.getEnfiladeOverlap(space)
enfMaker = gzz.media.impl.Enfilade1DImpl.Enfilade1DImplMaker()
--- 21,28 ----
from test.tools import tools
space = gzz.impl.ModularSpace(*tools.spaceArgList())
! # xuindexer = gzz.index.impl.TransientXuIndexer()
! xuindexer = gzz.index.IndexManager.getXuIndexer(space)
enfoverlap = gzz.index.IndexManager.getEnfiladeOverlap(space)
enfMaker = gzz.media.impl.Enfilade1DImpl.Enfilade1DImplMaker()
Index: gzz/gfx/libcoords/Coords.cxx
diff -c gzz/gfx/libcoords/Coords.cxx:1.27 gzz/gfx/libcoords/Coords.cxx:1.28
*** gzz/gfx/libcoords/Coords.cxx:1.27 Wed Oct 2 09:24:15 2002
--- gzz/gfx/libcoords/Coords.cxx Thu Oct 3 07:23:36 2002
***************
*** 27,33 ****
TransformCoordSysBase() : t() { }
TransformCoordSysBase(const Transform &tr) : t(tr) { }
virtual void setParams(float *params) {
! t.setParams(params);
}
bool canPerformGL() {
return t.canPerformGL() && super->canPerformGL();
--- 27,33 ----
TransformCoordSysBase() : t() { }
TransformCoordSysBase(const Transform &tr) : t(tr) { }
virtual void setParams(float *params) {
! t.setParams(params, super);
}
bool canPerformGL() {
return t.canPerformGL() && super->canPerformGL();
***************
*** 125,131 ****
float params[7];
public:
enum { NParams = 7 };
! template<class Ptr> void setParams(Ptr p) {
for(int i=0; i<7; i++)
params[i] = p[i];
}
--- 125,131 ----
float params[7];
public:
enum { NParams = 7 };
! template<class Ptr> void setParams(Ptr p, CoordSys *super) {
for(int i=0; i<7; i++)
params[i] = p[i];
}
***************
*** 185,191 ****
float a, s, c;
public:
enum { NParams = 1 };
! template<class Ptr> void setParams(Ptr p) {
a = p[0];
angleWasSet();
}
--- 185,191 ----
float a, s, c;
public:
enum { NParams = 1 };
! template<class Ptr> void setParams(Ptr p, CoordSys *super) {
a = p[0];
angleWasSet();
}
***************
*** 221,226 ****
--- 221,329 ----
}
};
+ /** Translation.
+ * Parameter layout: x, y, z
+ */
+ class TranslateXYZCoords {
+ protected:
+ ZVec vec;
+ public:
+ TranslateXYZCoords() { }
+ TranslateXYZCoords(ZVec vec) : vec(vec) { }
+ enum { NParams = 3 };
+ template<class Ptr> void setParams(Ptr p, CoordSys *super) {
+ vec.x = p[0];
+ vec.y = p[1];
+ vec.z = p[2];
+ }
+ /** Perform the internal transformation of this
+ * coordsys.
+ */
+ void tr(const ZPt &from, ZPt &to) const {
+ to = from + vec;
+ }
+ float tr_radius(const ZPt &from, float radius) const {
+ return radius;
+ }
+ bool canPerformGL() { return true; }
+ bool performGL() {
+ glTranslatef(vec.x, vec.y, vec.z);
+ return true;
+ }
+ typedef TranslateXYZCoords InverseType;
+ TranslateXYZCoords inverseTransform() {
+ TranslateXYZCoords inv(-vec);
+ return inv;
+ }
+ float nonlinearity(const ZPt &p, float radius) {
+ return 0;
+ }
+ };
+
+ /** Buoy coordinates.
+ * This is an interesting cs: it is essentially a translation,
+ * but it reads its coordinates differently.
+ * This means that
+ * interpolation happens differently.
+ * <p>
+ * This is very different from other CS since it also
+ * uses its upper-level coordinate system at setParams
+ * time. Also, it doesn't hierarchically transform by
+ * the upper coordinate system. This means that it
+ * can't be implemented as a TransformCoordSys.
+ * <p>
+ * Parameter layout:
+ * x_circle, y_circle, radius, x_projpoint, y_projpoint
+ */
+ class BuoyOnCircleCoords : public CoordSys {
+ ZVec tr;
+ public:
+ BuoyOnCircleCoords() : tr() { }
+ BuoyOnCircleCoords(ZVec tr) : tr(tr) { }
+ enum { NParams = 5 };
+ virtual void setParams(float *params) {
+ ZVec ctr(params[0], params[1], 0);
+ ZVec proj(params[3], params[4], 0);
+ float radius = params[2];
+
+ // Get the anchor of the buoy
+ ZPt anchor = super->transform(ZPt(0,0,0));
+ // Now that we have the anchor, project
+ // from it to the circle.
+ ZVec amc = proj - ctr; amc.z = 0;
+ ZVec v = anchor - proj; v.z = 0;
+ // coeffs of 2nd degree eq
+ float a = v.dot(v);
+ float b = 2*v.dot(amc);
+ float c = amc.dot(amc) - radius*radius;
+
+ float det = b*b - 4*a*c;
+ if(det <= 0) {
+ tr = ZVec(0,0,0);
+ return;
+ }
+ float ans = (-b + sqrt(det)) / (2*a);
+ ZPt pt = proj + ans * v;
+
+ tr = pt;
+ }
+ virtual CoordSys *createInverse() {
+ return new BuoyOnCircleCoords(-tr);
+ }
+ virtual void vertex(const ZPt &p) const {
+ ZPt n = p + tr;
+ glVertex3f(n.x, n.y, n.z);
+ }
+ virtual ZPt transform(const ZPt &p) const {
+ return p + tr;
+ }
+ virtual bool canPerformGL() { return true; }
+ virtual bool performGL() {
+ glTranslatef(tr.x, tr.y, tr.z);
+ return true;
+ }
+ };
+
/** Rotation around 3D vector.
* Params: x, y, z, angle
*/
***************
*** 228,234 ****
ZVec vec; float a, s, c;
public:
enum { NParams = 4 };
! template<class Ptr> void setParams(Ptr p) {
vec.x = p[0];
vec.y = p[1];
vec.z = p[2];
--- 331,337 ----
ZVec vec; float a, s, c;
public:
enum { NParams = 4 };
! template<class Ptr> void setParams(Ptr p, CoordSys *super) {
vec.x = p[0];
vec.y = p[1];
vec.z = p[2];
***************
*** 282,288 ****
ZVec vec;
public:
enum { NParams = 3 };
! template<class Ptr> void setParams(Ptr p) {
vec.x = p[0];
vec.y = p[1];
vec.z = p[2];
--- 385,391 ----
ZVec vec;
public:
enum { NParams = 3 };
! template<class Ptr> void setParams(Ptr p, CoordSys *super) {
vec.x = p[0];
vec.y = p[1];
vec.z = p[2];
***************
*** 333,339 ****
F distort;
public:
enum { NParams = 6 };
! template<class Ptr> void setParams(Ptr p) {
x = p[0];
y = p[1];
mmax = exp(p[2]);
--- 436,442 ----
F distort;
public:
enum { NParams = 6 };
! template<class Ptr> void setParams(Ptr p, CoordSys *super) {
x = p[0];
y = p[1];
mmax = exp(p[2]);
***************
*** 397,402 ****
--- 500,510 ----
virtual int nparams() { return C::NParams; }
virtual CoordSys *create() { return new TransformCoordSys<C>(); }
};
+ template<class C> class NoTransFactory : public SomeFactory {
+ public:
+ virtual int nparams() { return C::NParams; }
+ virtual CoordSys *create() { return new C(); }
+ };
extern SomeFactory* facs[];
***************
*** 410,415 ****
--- 518,525 ----
new
Factory<DistortCoords<Fisheye::vector_mag_isotropic<Fisheye::scalar_mag_atan> >
>(),
new Factory<RotateXYZCoords>(),
new Factory<ScaleXYZCoords>(),
+ new Factory<TranslateXYZCoords>(),
+ new NoTransFactory<BuoyOnCircleCoords>(),
0
};
Index: gzz/gzz/gfx/gl/GLVobCoorder.java
diff -c gzz/gzz/gfx/gl/GLVobCoorder.java:1.34
gzz/gzz/gfx/gl/GLVobCoorder.java:1.35
*** gzz/gzz/gfx/gl/GLVobCoorder.java:1.34 Wed Oct 2 09:24:16 2002
--- gzz/gzz/gfx/gl/GLVobCoorder.java Thu Oct 3 07:23:36 2002
***************
*** 29,35 ****
import gzz.client.gl.*;
public class GLVobCoorder extends AffineVobCoorder {
! public static final String rcsid = "$Id: GLVobCoorder.java,v 1.34 2002/10/02
13:24:16 tjl Exp $";
public static boolean dbg = false;
private static void pa(String s) { System.err.println(s); }
--- 29,35 ----
import gzz.client.gl.*;
public class GLVobCoorder extends AffineVobCoorder {
! public static final String rcsid = "$Id: GLVobCoorder.java,v 1.35 2002/10/03
11:23:36 tjl Exp $";
public static boolean dbg = false;
private static void pa(String s) { System.err.println(s); }
***************
*** 108,113 ****
--- 108,150 ----
return was;
}
+
+ public int translateXYZ(int into, float sx, float sy, float sz) {
+ floats[nfloats + 0] = sx;
+ floats[nfloats + 1] = sy;
+ floats[nfloats + 2] = sz;
+ int paramInd = nfloats;
+ nfloats += 3;
+
+ inds[ninds + 0] = 6; // translation xyz
+ inds[ninds + 1] = into;
+ inds[ninds + 2] = paramInd;
+ int was = ninds / 3;
+ ninds += 3;
+
+ return was;
+ }
+
+ public int buoyOnCircle(int into, float cx, float cy,
+ float rad, float px, float py) {
+ floats[nfloats + 0] = cx;
+ floats[nfloats + 1] = cy;
+ floats[nfloats + 2] = rad;
+ floats[nfloats + 3] = px;
+ floats[nfloats + 4] = py;
+ int paramInd = nfloats;
+ nfloats += 5;
+
+ inds[ninds + 0] = 7; // buoy xyz
+ inds[ninds + 1] = into;
+ inds[ninds + 2] = paramInd;
+ int was = ninds / 3;
+ ninds += 3;
+
+ return was;
+ }
+
+
public int scaleXYZ(int into, float sx, float sy, float sz) {
floats[nfloats + 0] = sx;
- [Gzz-commits] gzz ./TODO gfx/demo/xupdf.py gfx/libcoords/Coor...,
Tuomas J. Lukka <=