gzz-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gzz-commits] libvob ./TODO include/vob/Primitives.hxx includ...


From: Tuomas J. Lukka
Subject: [Gzz-commits] libvob ./TODO include/vob/Primitives.hxx includ...
Date: Mon, 10 Mar 2003 09:26:18 -0500

CVSROOT:        /cvsroot/libvob
Module name:    libvob
Changes by:     Tuomas J. Lukka <address@hidden>        03/03/10 09:26:18

Modified files:
        .              : TODO 
        include/vob    : Primitives.hxx 
        include/vob/jni: Generate.hxx 
        org/nongnu/libvob/impl/gl: GLVobCoorder.java 
        src/jni        : Gen.cxx Makefile 
        src/trans      : Makefile 
Added files:
        include/vob    : Coorder.hxx 
        src/jni        : GLVobCoorder_Gen.template.java 
        src/trans      : Coorder.cxx 

Log message:
        Starting to integrate - doesn't work yet

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/TODO.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/Coorder.hxx?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/Primitives.hxx.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/jni/Generate.hxx.diff?tr1=1.12&tr2=1.13&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/impl/gl/GLVobCoorder.java.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/src/jni/GLVobCoorder_Gen.template.java?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/src/jni/Gen.cxx.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/src/jni/Makefile.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/src/trans/Coorder.cxx?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/src/trans/Makefile.diff?tr1=1.1&tr2=1.2&r1=text&r2=text

Patches:
Index: libvob/TODO
diff -u libvob/TODO:1.7 libvob/TODO:1.8
--- libvob/TODO:1.7     Mon Mar 10 08:29:30 2003
+++ libvob/TODO Mon Mar 10 09:26:17 2003
@@ -4,18 +4,25 @@
     tjl:
        - make tests and make them work
        - bring back fonts
+       - implement vital coordsyses
+       - implement "set*Params" calls
     vegai:
        - .cvsignores
+       - make sure libvob works right with kaffe
 
 0.1alpha2: Vital fixes for packages depending on this
     tjl:
        - go through " grep cout gfx/*/*.[ch]* "
          and deal with them.
     anybody:
+       - reimplement getCoordSystemStr using src/jni
+         generator
        - revamp DisplayList objects from storing Ids to storing
          the CallGL displaylist objects.
          The point is that then we can print out the code that
          was compiled into the list when an error occurs.
+       - fix the generator to pass on the parameter names
+         defined in the "vob_defined" call somehow!
 
 0.1alpha3: Pending fixes
     tjl:
Index: libvob/include/vob/Primitives.hxx
diff -u libvob/include/vob/Primitives.hxx:1.10 
libvob/include/vob/Primitives.hxx:1.11
--- libvob/include/vob/Primitives.hxx:1.10      Mon Mar 10 06:15:13 2003
+++ libvob/include/vob/Primitives.hxx   Mon Mar 10 09:26:18 2003
@@ -213,12 +213,19 @@
 
     };
 
+    class HierarchicalTransform {
+       virtual int getNParams() = 0;
+       virtual int getNDepends() = 0;
+       virtual void setParams(const Transform *super, 
+                   const Transform **depends, float *p) = 0;
+    }
+
     /** A hierarchical transformation, which applies the 
      * template argument primitive transformation to the result
      * of the parent transform.
      */
-    template<class Primitive> class HierarchicalTransform : 
-           public Transform 
+    template<class Primitive> class PrimitiveHierarchicalTransform : 
+           public Transform , public HierarchicalTransform
     {
        const Transform *super;
        Transform *inverse;
@@ -311,10 +318,10 @@
        }
 
 
-       int getNParams() {
+       virtual int getNParams() {
            return getNParams(&t);
        }
-       int getNDepends() {
+       virtual int getNDepends() {
            return getNDepends(t);
        }
 
Index: libvob/include/vob/jni/Generate.hxx
diff -u libvob/include/vob/jni/Generate.hxx:1.12 
libvob/include/vob/jni/Generate.hxx:1.13
--- libvob/include/vob/jni/Generate.hxx:1.12    Mon Mar 10 06:15:13 2003
+++ libvob/include/vob/jni/Generate.hxx Mon Mar 10 09:26:18 2003
@@ -175,34 +175,43 @@
 
     template<class Primitive> struct TransJNIGenerator {
        int ind;
-       Primitive typer;
-
-       int nParents(Primitives::DependentPrimitiveTransform &t) {
-           return Primitive::NDepends;
-       }
-       template<class T> int nParents(T &t) { return 1; }
-
-       int nParams(Primitives::ParametrizedPrimitiveTransform &t) {
-           return Primitive::NParams;
-       }
-       template<class T> int nParams(T &t) { return 0; }
+       Primitives::HierarchicalTransform<Primitive> hier;
 
        TransJNIGenerator(std::string className, std::string methodName) {
            ind = index++;
            VOB_TRANSJAVASTREAM << "public int "<<methodName
                        <<"(int d0 ";
-           for(int i=1; i<nParents(typer); i++) {
+           for(int i=1; i<hier.getNDepends(); i++) {
                VOB_TRANSJAVASTREAM << ", int d"<<i<<" ";
            }
-           for(int i=0; i<nParams(typer); i++) {
+           for(int i=0; i<hier.getNParams(); i++) {
                VOB_TRANSJAVASTREAM << ", float p"<<i<<" ";
            }
-           std::string passignCode = "";
-           for(int i=0; i<nParams(typer); i++) {
-               passignCode += "floats[i+";
+           std::ostringstream  passignCode;
+           for(int i=0; i<hier.getNParams(); i++) {
+               passignCode << "floats[i+"<<i
+                       <<"] = p"<<i<<";\n";
            }
            VOB_TRANSJAVASTREAM << ") {\n"
-                   "int i = nfloats;";
+                   "int i = nfloats; \n" <<
+                   "nfloats +="<<hier.getNParams()<<";\n";
+
+           VOB_TRANSJAVASTREAM << passignCode.str();
+
+           VOB_TRANSJAVASTREAM <<
+                   "int j = ninds; ninds += "<<
+                       (hier.getNDepends()+2)
+                       <<"; inds[j+0] = "<<ind<<";\n";
+
+           for(int i=0; i<hier.getNDepends(); i++) {
+               VOB_TRANSJAVASTREAM << 
+                   "inds[j+"<<(i+1)<<"] = d"<<i<<";\n";
+           }
+           VOB_TRANSJAVASTREAM <<
+                   "inds[j+"<<(hier.getNDepends()+1)<<
+                       "] = i;\n return j;";
+
+           VOB_TRANSJAVASTREAM << "}\n";
 
            VOB_TRANSCSTREAM << " case "<<ind<<": \n"
                    << "\t\tTRANSTYPE("<<className<<");break;\n";
Index: libvob/org/nongnu/libvob/impl/gl/GLVobCoorder.java
diff -u libvob/org/nongnu/libvob/impl/gl/GLVobCoorder.java:1.1 
libvob/org/nongnu/libvob/impl/gl/GLVobCoorder.java:1.2
--- libvob/org/nongnu/libvob/impl/gl/GLVobCoorder.java:1.1      Sat Mar  8 
08:26:10 2003
+++ libvob/org/nongnu/libvob/impl/gl/GLVobCoorder.java  Mon Mar 10 09:26:18 2003
@@ -31,8 +31,8 @@
 import org.nongnu.libvob.gl.*;
 import java.util.HashMap;
 
-public final class GLVobCoorder extends AffineVobCoorder {
-public static final String rcsid = "$Id: GLVobCoorder.java,v 1.1 2003/03/08 
13:26:10 tjl Exp $";
+public class GLVobCoorder extends AffineVobCoorder {
+public static final String rcsid = "$Id: GLVobCoorder.java,v 1.2 2003/03/10 
14:26:18 tjl Exp $";
     public static boolean dbg = false;
     private static void pa(String s) { System.err.println(s); }
 
@@ -97,405 +97,6 @@
        if(cs == 0) return -1;
        return inds[cs+1];
     }
-
-    // For at least debugging purposes.
-    public String getCoordSystemStr(int cs) {
-       if (cs < 0 || cs >= 5000) return "Out of index!";
-       String cs_str = null;
-
-       switch(inds[cs]) {
-       case 1: cs_str = "Affine"; break;
-       case 2: cs_str = "Rotation"; break;
-       case 3: cs_str = "Distort"; break;
-       case 4: cs_str = "Rotation xyz"; break;
-       case 5: cs_str = "Rotation xyz"; break;
-       case 6: cs_str = "Translation xyz"; break;
-       case 7: cs_str = "BuoyOnCircle"; break;
-       case 8: cs_str = "Concat"; break;
-       case 9: cs_str = "Nadir"; break;
-       case 10: cs_str = "Culling"; break;
-       case 11: cs_str = "Box"; break;
-       case 12: cs_str = "unitSq"; break;
-       case 14: cs_str = "OrthoBox"; break;
-       case 15: cs_str = "Invert"; break;
-       }
-       if (cs_str == null) return "CoordSystem: "+cs+" not defined.";
-       else return cs_str;
-    }
-
-
-    public int affineCoordsys(
-           int into, float depth,
-           float cx, float cy,
-                   float x_x, float x_y,
-                   float y_x, float y_y
-                   ) {
-       if(dbg) pa("AffineCoordSys "+ninds+": "+into+" '"+depth+" --- "+
-                   cx+" "+cy+" "+x_x+" "+x_y+" "+y_x+" "+y_y);
-
-       int paramInd = nfloats;
-       nfloats += 7;
-
-       inds[ninds + 0] = 1; // affine = 1
-       inds[ninds + 1] = into;
-       inds[ninds + 2] = paramInd;
-
-       int was = ninds;
-       ninds += 3;
-
-       setAffineParams(was, depth, cx, cy, x_x, x_y, y_x, y_y);
-
-       return was;
-    }
-
-    public void setAffineParams(
-           int cs, float depth, float cx, float cy, 
-           float x_x, float x_y, float y_x, float y_y) {
-       int ind = inds[cs + 2];
-       floats[ind + 0] = cx;
-       floats[ind + 1] = cy;
-       floats[ind + 2] = depth;
-       floats[ind + 3] = x_x;
-       floats[ind + 4] = x_y;
-       floats[ind + 5] = y_x;
-       floats[ind + 6] = y_y;
-    }
-
-    public int rotate(int into, float degrees) {
-       int paramInd = nfloats;
-       nfloats += 1;
-
-       inds[ninds + 0] = 2; // rotation = 2
-       inds[ninds + 1] = into;
-       inds[ninds + 2] = paramInd;
-       int was = ninds;
-       ninds += 3;
-
-       setRotateParams(was, degrees);
-
-       return was;
-    }
-
-    public void setRotateParams(int cs, float degrees) {
-       int ind = inds[cs + 2];
-       floats[ind + 0] = degrees;
-    }
-
-
-    public int rotateCentered(int into, float degrees, float x, float y) {
-       int paramInd = nfloats;
-       nfloats += 3;
-
-       inds[ninds + 0] = 16; // rotationCentered = 16
-       inds[ninds + 1] = into;
-       inds[ninds + 2] = paramInd;
-       int was = ninds;
-       ninds += 3;
-
-       setRotateCenteredParams(was, degrees, x, y);
-
-       return was;
-    }
-
-    public void setRotateCenteredParams(int cs, float degrees, 
-                                           float x, float y) {
-       int ind = inds[cs + 2];
-       floats[ind + 0] = degrees;
-       floats[ind + 1] = x;
-       floats[ind + 2] = y;
-    }
-
-
-    public int rotateXYZ(int into, float degrees, float x, float y, float z) {
-       floats[nfloats + 0] = x;
-       floats[nfloats + 1] = y;
-       floats[nfloats + 2] = z;
-       floats[nfloats + 3] = degrees;
-       int paramInd = nfloats;
-       nfloats += 4;
-
-       inds[ninds + 0] = 4; // rotation xyz
-       inds[ninds + 1] = into;
-       inds[ninds + 2] = paramInd;
-       int was = ninds;
-       ninds += 3;
-
-       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;
-       ninds += 3;
-
-       return was;
-    }
-
-    public int buoyOnCircle(int into, int anchor, float cx, float cy, 
-                       float rad, float px, float py, 
-                       float shiftamount) {
-       floats[nfloats + 0] = cx;
-       floats[nfloats + 1] = cy;
-       floats[nfloats + 2] = rad;
-       floats[nfloats + 3] = px;
-       floats[nfloats + 4] = py;
-       floats[nfloats + 5] = shiftamount;
-       int paramInd = nfloats;
-       nfloats += 6;
-
-       inds[ninds + 0] = 7; // buoy xyz
-       inds[ninds + 1] = into;
-       inds[ninds + 2] = anchor;
-       inds[ninds + 3] = paramInd;
-       int was = ninds;
-       ninds += 4;
-
-       return was;
-    }
-
-    public int getBuoyOnCircleAnchor(int cs) {
-       if(inds[cs] != 7) throw new Error("GetBuoyOnCircle: not buoyOnCircle 
"+cs);
-       return inds[cs + 2];
-    }
-
-    /** Make a nadir rotation of into towards nadir.
-     * That is, at each moment of time, nadirOrigin(a, b)
-     * is equivalent to rotate(a, X) for some angle.
-     * The angle is determined so that the
-     * positive y direction from (0,0) of the rotated
-     * coordinate system points towards the origin of the
-     * nadir coordinate system.
-     * @param into The coordinate system for which a rotated
-     *                         child is to be constructed.
-     * @param nadir The coordinate system towards whose origin
-     *                 the positive y coordinate axis of the rotated CS
-     *                 should point.
-     */
-    public int nadirOrigin(int into, int nadir) {
-       int paramInd = nfloats;
-       nfloats += 0;
-
-       inds[ninds + 0] = 9; // nadir
-       inds[ninds + 1] = into;
-       inds[ninds + 2] = nadir;
-       inds[ninds + 3] = paramInd;
-       int was = ninds;
-       ninds += 4;
-
-       return was;
-    }
-
-    /** Make a nadir rotation around unitsq center towards nadir.
-     */
-    public int nadirUnitSq(int into, int nadir) {
-       int paramInd = nfloats;
-       nfloats += 0;
-
-       inds[ninds + 0] = 17; // nadirUnitSq
-       inds[ninds + 1] = into;
-       inds[ninds + 2] = nadir;
-       inds[ninds + 3] = paramInd;
-       int was = ninds;
-       ninds += 4;
-
-       return was;
-    }
-
-
-
-
-
-    public int scale(int into, float sx, float sy, float sz) {
-       int paramInd = nfloats;
-       nfloats += 3;
-
-       inds[ninds + 0] = 5; // rotation xyz
-       inds[ninds + 1] = into;
-       inds[ninds + 2] = paramInd;
-       int was = ninds;
-       ninds += 3;
-
-       setScaleParams(was, sx, sy, sz);
-
-       return was;
-    }
-
-    public void setScaleParams(int cs, float sx, float sy, float sz) {
-       int ind = inds[cs + 2];
-       floats[ind + 0] = sx;
-       floats[ind + 1] = sy;
-       floats[ind + 2] = sz;
-    }
-
-    public int box(int into, float w, float h) {
-       int paramInd = nfloats;
-       nfloats += 2;
-
-       inds[ninds + 0] = 11; // box
-       inds[ninds + 1] = into;
-       inds[ninds + 2] = paramInd;
-       int was = ninds;
-       ninds += 3;
-
-       setBoxParams(was, w, h);
-
-       return was;
-    }
-
-    public void setBoxParams(int cs, float w, float h) {
-       int ind = inds[cs + 2];
-       floats[ind + 0] = w;
-       floats[ind + 1] = h;
-    }
-
-    public int unitSq(int into) {
-       inds[ninds + 0] = 12; // unitsq 
-       inds[ninds + 1] = into;
-       inds[ninds + 2] = -42; // not used
-       int was = ninds;
-       ninds += 3;
-       return was;
-    }
-
-
-    public int orthoBox(int into, float z, float x, float y, float sx, float 
sy, float w, float h) {
-       int paramInd = nfloats;
-       nfloats += 7;
-
-       inds[ninds + 0] = 14; // orthobox
-       inds[ninds + 1] = into;
-       inds[ninds + 2] = paramInd;
-       int was = ninds;
-       ninds += 3;
-
-       setOrthoBoxParams(was, z, x, y, sx, sy, w, h);
-
-       return was;
-    }
-
-    public void setOrthoBoxParams(int cs, float z, float x, float y, float sx, 
float sy, float w, float h) {
-       int ind = inds[cs + 2];
-       floats[ind + 0] = x;
-       floats[ind + 1] = y;
-       floats[ind + 2] = z;
-       floats[ind + 3] = sx;
-       floats[ind + 4] = sy;
-       floats[ind + 5] = w;
-       floats[ind + 6] = h;
-    }
-
-    public void getSqSize(int cs, float[] into) {
-       // XXX Dangerous: this needs to be updated whenever new non-unit box 
-       // coordsys are added.
-       int type = inds[cs] & ~GL.CSFLAGS;
-       int ind=-42;
-       switch(type) {
-           case 10: // culling
-               getSqSize(inds[cs + 1], into); // forwards to cs' parent
-               break;
-           case 11: // box
-               ind = inds[cs+2];
-               into[0] = floats[ind + 0];
-               into[1] = floats[ind + 1];
-               break;
-           case 14: // orthobox
-               ind = inds[cs+2];
-               into[0] = floats[ind + 5];
-               into[1] = floats[ind + 6];
-               break;
-           case 9: case 17: // nadir -- recurse
-               ind = inds[cs + 1];
-               getSqSize(ind, into);
-               break;
-           default:
-               into[0] = into[1] = 1;
-               break;
-       }
-    }
-
-
-    /** A fisheye coordinate system: non-linear magnification.
-     * @param into The parent coordinate system, inside which this cs is
-     * @param x,y,w,h The location and size of the center of magnification
-     * @param mag The magnification at its largest, i.e. in the center of the 
rectangle
-     *            defined by x, y, w, h
-     * @param min The magnification at its smallest, i.e. far away from the 
origin.
-     */
-    public int distort(int into, float x, float y, float w, float h, float 
mag, float min) {
-
-       int paramInd = nfloats;
-       nfloats += 6;
-
-       inds[ninds + 0] = 3; // distort 
-       inds[ninds + 1] = into;
-       inds[ninds + 2] = paramInd;
-
-       int was = ninds;
-       ninds += 3;
-
-       setDistortParams(was, x, y, w, h, mag, min);
-       return was;
-    }
-
-    public void setDistortParams(int cs, float x, float y, float w, float h, 
float mag, float min) {
-
-       int ind = inds[cs + 2];
-       floats[ind + 0] = x;
-       floats[ind + 1] = y;
-       floats[ind + 2] = (float)Math.log(mag);
-       floats[ind + 3] = (float)Math.log(min);
-       floats[ind + 4] = w;
-       floats[ind + 5] = h;
-    }
-
-
-    public int concat(int parent, int child) {
-       int paramInd = nfloats;
-       inds[ninds+0] = 8; // concat
-       inds[ninds+1] = parent;
-       inds[ninds+2] = child;
-       inds[ninds+3] = paramInd;
-
-       int was = ninds;
-       ninds += 4; 
-       return was;
-    }
-
-    public int invert(int parent) {
-       inds[ninds+0] = 15; // invert
-       inds[ninds+1] = parent;
-       inds[ninds+2] = 42;
-
-       int was = ninds;
-       ninds += 3; 
-       return was;
-    }
-
-    public int cull(int parent, int clip) {
-       return cull(parent, parent, clip);
-    }
-
-    public int cull(int parent, int test, int clip) {
-       int paramInd = nfloats;
-       inds[ninds+0] = 10; // culling
-       inds[ninds+1] = parent;
-       inds[ninds+2] = test;
-       inds[ninds+3] = clip;
-       inds[ninds+4] = paramInd;
-
-       int was = ninds;
-       ninds += 5; 
-       return was;
-    }
-
     public void dump() {
        pa("GLVobCoorder: ");
        for(int i=0; i<ninds; i++) {
Index: libvob/src/jni/Gen.cxx
diff -u libvob/src/jni/Gen.cxx:1.7 libvob/src/jni/Gen.cxx:1.8
--- libvob/src/jni/Gen.cxx:1.7  Mon Mar 10 06:15:13 2003
+++ libvob/src/jni/Gen.cxx      Mon Mar 10 09:26:18 2003
@@ -41,8 +41,11 @@
 
 int main() {
     std::ifstream templ("src/jni/GLRen.template.java");
+    std::ifstream templtrans("src/jni/GLVobCoorder_Gen.template.java");
 
     std::ofstream java("org/nongnu/libvob/gl/GLRen.java");
+    std::ofstream javatrans(
+           "org/nongnu/libvob/impl/gl/GLVobCoorder_Gen.java");
     std::ofstream jni("src/jni/GLRen.gen.cxx");
     java << "//COMPUTER GENERATED DO NOT EDIT\n";
 
@@ -51,8 +54,17 @@
     std::ostreambuf_iterator<char> out(java);
     std::copy(in, eos, out);
 
+    std::istreambuf_iterator<char> tin(templtrans);
+    std::ostreambuf_iterator<char> tout(javatrans);
+    std::copy(tin, eos, tout);
+
     java << VOB_JAVASTREAM.str()<<"\n\n";
     java << "}\n";
+
+    javatrans << VOB_TRANSJAVASTREAM.str()<<"\n\n";
+    javatrans << "}\n";
+
+
 
     jni << "//COMPUTER GENERATED DO NOT EDIT\n";
     jni << "#include <vob/jni/Types.hxx>\n";
Index: libvob/src/jni/Makefile
diff -u libvob/src/jni/Makefile:1.5 libvob/src/jni/Makefile:1.6
--- libvob/src/jni/Makefile:1.5 Sat Mar  8 14:45:47 2003
+++ libvob/src/jni/Makefile     Mon Mar 10 09:26:18 2003
@@ -11,7 +11,7 @@
 all: $(sources:.cxx=.o) Gen libvobjni.so
 
 Gen: Gen.o
-       $(CXX) -o Gen Gen.o
+       $(CXX) -o Gen Gen.o $(LIBS)
 
 GLRen.gen.cxx: Gen GLRen.template.java
        (cd ../..; src/jni/Gen)
Index: libvob/src/trans/Makefile
diff -u libvob/src/trans/Makefile:1.1 libvob/src/trans/Makefile:1.2
--- libvob/src/trans/Makefile:1.1       Tue Feb 25 15:08:45 2003
+++ libvob/src/trans/Makefile   Mon Mar 10 09:26:18 2003
@@ -1,6 +1,6 @@
 include ../../rules.mk
 
-sources = Transform.cxx
+sources = Transform.cxx Coorder.cxx
 
 all: $(sources:.cxx=.o)
 




reply via email to

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