gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] gzz/gfx/libcoords Coords.cxx Coords.hxx


From: Tuomas J. Lukka
Subject: [Gzz-commits] gzz/gfx/libcoords Coords.cxx Coords.hxx
Date: Wed, 25 Sep 2002 12:16:46 -0400

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Tuomas J. Lukka <address@hidden>        02/09/25 12:16:46

Modified files:
        gfx/libcoords  : Coords.cxx Coords.hxx 

Log message:
        No *need* to have all that stuff in the headers...

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libcoords/Coords.cxx.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libcoords/Coords.hxx.diff?tr1=1.3&tr2=1.4&r1=text&r2=text

Patches:
Index: gzz/gfx/libcoords/Coords.cxx
diff -c gzz/gfx/libcoords/Coords.cxx:1.3 gzz/gfx/libcoords/Coords.cxx:1.4
*** gzz/gfx/libcoords/Coords.cxx:1.3    Wed Sep 25 12:04:44 2002
--- gzz/gfx/libcoords/Coords.cxx        Wed Sep 25 12:16:46 2002
***************
*** 4,9 ****
--- 4,127 ----
  namespace Coords {
      DBGVAR(dbg, "Coords.general");
  
+     class RootCoords : public CoordSys {
+     public:
+       virtual ZPt transform(const ZPt &p) const {
+           return p;
+       }
+       virtual void vertex(const ZPt &p) const {
+           glVertex3f(p.x, p.y, p.z);
+       }
+     };
+ 
+     /** Affine coordinate system (in xy), offset in z.
+      * Parameter layout: x, y, depth, xx, xy, yx, yy
+      */
+     class AffineXYCoords : public CoordSys {
+     public:
+       enum { NParams = 7 };
+       /** Perform the internal transformation of this 
+        * coordsys.
+        */
+       void tr(const ZPt &from, ZPt &to) const {
+           to.x = params[0] + from.x * params[3] + from.y * params[4];
+           to.y = params[1] + from.x * params[5] + from.y * params[6];
+           to.z = params[2] + from.z;
+       }
+       virtual ZPt transform(const ZPt &p) const {
+           ZPt mp;
+           tr(p, mp);
+           return super->transform(mp);
+       }
+       virtual void vertex(const ZPt &p) const {
+           ZPt mp;
+           tr(p, mp);
+           super->vertex(mp);
+       }
+     };
+ 
+     /** Rotation clockwise. 
+      * Parameter layout: angle (degrees)
+      */
+     class RotateXYCoords : public CoordSys {
+       float s, c;
+     public:
+       enum { NParams = 1 };
+       virtual void setParams(float *params) {
+           CoordSys::setParams(params);
+           s = sin(params[0]);
+           c = cos(params[0]);
+       }
+       /** Perform the internal transformation of this 
+        * coordsys.
+        */
+       void tr(const ZPt &from, ZPt &to) const {
+           to.x = c * from.x + s * from.y; 
+           to.y = -s * from.x + c * from.y; 
+           to.z = from.z;
+       }
+       virtual ZPt transform(const ZPt &p) const {
+           ZPt mp;
+           tr(p, mp);
+           return super->transform(mp);
+       }
+       virtual void vertex(const ZPt &p) const {
+           ZPt mp;
+           tr(p, mp);
+           super->vertex(mp);
+       }
+     };
+ 
+     ;
+     ;
+ 
+     /** Distorted coordinate system.
+      * Parameter layout: x, y (of center), log(mag), log(min), w, h.
+      * W and h give the width and height in the inside coordinate system
+      * of the zoomed area.
+      */
+     class DistortCoords : public CoordSys {
+       float mmin;
+       float mmax;
+       Fisheye::vector_mag_isotropic<Fisheye::scalar_mag_atan> distort;
+     public:
+       enum { NParams = 6 };
+       virtual void setParams(float *params) {
+           CoordSys::setParams(params);
+           mmax = exp(params[2]);
+           mmin = exp(params[3]);
+           distort.f = Fisheye::scalar_mag_atan(mmax / mmin);
+       }
+       virtual ZPt transform(const ZPt &p) const {
+           ZPt mp;
+           tr(p, mp);
+           return super->transform(mp);
+       }
+       virtual void vertex(const ZPt &p) const {
+           ZPt mp;
+           tr(p, mp);
+           super->vertex(mp);
+       }
+       void tr(const ZPt &from, ZPt &to) const {
+           to = distort(from);
+           to.x *= mmin;
+           to.y *= mmin;
+       }
+     };
+ 
+     struct SomeFactory {
+       virtual int nparams() = 0;
+       virtual CoordSys *create() = 0;
+     };
+     template<class C> class Factory : public SomeFactory {
+     public:
+       virtual int nparams() { return C::NParams; }
+       virtual CoordSys *create() { return new C(); }
+     };
+ 
+     extern SomeFactory* facs[];
+ 
+ 
      /* This mustn't change without changing GLVobCoorder2 as well.
       */
      SomeFactory* facs[] = {
***************
*** 13,18 ****
--- 131,143 ----
        new Factory<DistortCoords>()
      };
  
+     int CoordSet::nparams(int typecode) { 
+       return facs[typecode]->nparams();
+     }
+     CoordSys *CoordSet::create(int typecode) {
+       return facs[typecode]->create();
+     }
+ 
      void CoordSet::setPoints( int ninds, 
                                 int *inds1, float *points1, 
                                 int *interpinds, 
***************
*** 32,39 ****
        DBG(dbg)  << "Reserved\n";
        cs.resize(ninds/3);
        DBG(dbg)  << "Resized2\n";
!       root = new RootCoords();
!       cs[0] = root;
        DBG(dbg)  << "setroot\n";
        for(int i=3; i+3<ninds; i+=3) {
            DBG(dbg)  << "loop "<<i<<"\n";
--- 157,163 ----
        DBG(dbg)  << "Reserved\n";
        cs.resize(ninds/3);
        DBG(dbg)  << "Resized2\n";
!       cs[0] = new RootCoords();
        DBG(dbg)  << "setroot\n";
        for(int i=3; i+3<ninds; i+=3) {
            DBG(dbg)  << "loop "<<i<<"\n";
Index: gzz/gfx/libcoords/Coords.hxx
diff -c gzz/gfx/libcoords/Coords.hxx:1.3 gzz/gfx/libcoords/Coords.hxx:1.4
*** gzz/gfx/libcoords/Coords.hxx:1.3    Wed Sep 25 11:58:44 2002
--- gzz/gfx/libcoords/Coords.hxx        Wed Sep 25 12:16:46 2002
***************
*** 61,200 ****
            cout << "Unknown coordsys\n";
        }
      };
- 
-     class RootCoords : public CoordSys {
-     public:
-       virtual ZPt transform(const ZPt &p) const {
-           return p;
-       }
-       virtual void vertex(const ZPt &p) const {
-           glVertex3f(p.x, p.y, p.z);
-       }
-     };
- 
-     /** Affine coordinate system (in xy), offset in z.
-      * Parameter layout: x, y, depth, xx, xy, yx, yy
-      */
-     class AffineXYCoords : public CoordSys {
-     public:
-       enum { NParams = 7 };
-       /** Perform the internal transformation of this 
-        * coordsys.
-        */
-       void tr(const ZPt &from, ZPt &to) const {
-           to.x = params[0] + from.x * params[3] + from.y * params[4];
-           to.y = params[1] + from.x * params[5] + from.y * params[6];
-           to.z = params[2] + from.z;
-       }
-       virtual ZPt transform(const ZPt &p) const {
-           ZPt mp;
-           tr(p, mp);
-           return super->transform(mp);
-       }
-       virtual void vertex(const ZPt &p) const {
-           ZPt mp;
-           tr(p, mp);
-           super->vertex(mp);
-       }
-     };
- 
-     /** Rotation clockwise. 
-      * Parameter layout: angle (degrees)
-      */
-     class RotateXYCoords : public CoordSys {
-       float s, c;
-     public:
-       enum { NParams = 1 };
-       virtual void setParams(float *params) {
-           CoordSys::setParams(params);
-           s = sin(params[0]);
-           c = cos(params[0]);
-       }
-       /** Perform the internal transformation of this 
-        * coordsys.
-        */
-       void tr(const ZPt &from, ZPt &to) const {
-           to.x = c * from.x + s * from.y; 
-           to.y = -s * from.x + c * from.y; 
-           to.z = from.z;
-       }
-       virtual ZPt transform(const ZPt &p) const {
-           ZPt mp;
-           tr(p, mp);
-           return super->transform(mp);
-       }
-       virtual void vertex(const ZPt &p) const {
-           ZPt mp;
-           tr(p, mp);
-           super->vertex(mp);
-       }
-     };
- 
-     ;
-     ;
- 
-     /** Distorted coordinate system.
-      * Parameter layout: x, y (of center), log(mag), log(min), w, h.
-      * W and h give the width and height in the inside coordinate system
-      * of the zoomed area.
-      */
-     class DistortCoords : public CoordSys {
-       float mmin;
-       float mmax;
-       Fisheye::vector_mag_isotropic<Fisheye::scalar_mag_atan> distort;
-     public:
-       enum { NParams = 6 };
-       virtual void setParams(float *params) {
-           CoordSys::setParams(params);
-           mmax = exp(params[2]);
-           mmin = exp(params[3]);
-           distort.f = Fisheye::scalar_mag_atan(mmax / mmin);
-       }
-       virtual ZPt transform(const ZPt &p) const {
-           ZPt mp;
-           tr(p, mp);
-           return super->transform(mp);
-       }
-       virtual void vertex(const ZPt &p) const {
-           ZPt mp;
-           tr(p, mp);
-           super->vertex(mp);
-       }
-       void tr(const ZPt &from, ZPt &to) const {
-           to = distort(from);
-           to.x *= mmin;
-           to.y *= mmin;
-       }
-     };
- 
-     struct SomeFactory {
-       virtual int nparams() = 0;
-       virtual CoordSys *create() = 0;
-     };
-     template<class C> class Factory : public SomeFactory {
-     public:
-       virtual int nparams() { return C::NParams; }
-       virtual CoordSys *create() { return new C(); }
-     };
- 
-     extern SomeFactory* facs[];
- 
      /** A class that manages a set of coordinate systems.
       */
      class CoordSet {
        vector<CoordSys *> cs;
        vector<float> params;
-       RootCoords *root;
  
!       int nparams(int typecode) { 
!           return facs[typecode]->nparams();
!       }
!       CoordSys *create(int typecode) {
!           return facs[typecode]->create();
!       }
      public:
        ~CoordSet() {
-           delete root;
        }
        void clean() {
            for(unsigned i=0; i<cs.size(); i++) {
--- 61,76 ----
            cout << "Unknown coordsys\n";
        }
      };
      /** A class that manages a set of coordinate systems.
       */
      class CoordSet {
        vector<CoordSys *> cs;
        vector<float> params;
  
!       int nparams(int typecode) ;
!       CoordSys *create(int typecode) ;
      public:
        ~CoordSet() {
        }
        void clean() {
            for(unsigned i=0; i<cs.size(); i++) {




reply via email to

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