/[gzz]/gzz/gfx/libcoords/Coords.cxx
ViewVC logotype

Diff of /gzz/gfx/libcoords/Coords.cxx

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.31 by tjl, Fri Oct 4 06:54:11 2002 UTC revision 1.32 by tjl, Mon Oct 7 07:40:03 2002 UTC
# Line 519  namespace Coords { Line 519  namespace Coords {
519    
520      struct SomeFactory {      struct SomeFactory {
521          virtual int nparams() = 0;          virtual int nparams() = 0;
522            virtual int nprevious() = 0;
523          virtual CoordSys *create() = 0;          virtual CoordSys *create() = 0;
524      };      };
525    
526      template<class C> class Factory : public SomeFactory {      template<class C> class Factory : public SomeFactory {
527      public:      public:
528          virtual int nparams() { return C::NParams; }          virtual int nparams() { return C::NParams; }
529            virtual int nprevious() { return 1; }
530          virtual CoordSys *create() { return new TransformCoordSys<C>(); }          virtual CoordSys *create() { return new TransformCoordSys<C>(); }
531      };      };
532      template<class C> class NoTransFactory : public SomeFactory {      template<class C> class NoTransFactory : public SomeFactory {
533      public:      public:
534          virtual int nparams() { return C::NParams; }          virtual int nparams() { return C::NParams; }
535            virtual int nprevious() { return 1; }
536          virtual CoordSys *create() { return new C(); }          virtual CoordSys *create() { return new C(); }
537      };      };
538    
# Line 549  namespace Coords { Line 553  namespace Coords {
553          0          0
554      };      };
555    
556        int CoordSet::nprevious(int typecode) {
557            return facs[typecode]->nprevious();
558        }
559      int CoordSet::nparams(int typecode) {      int CoordSet::nparams(int typecode) {
560          return facs[typecode]->nparams();          return facs[typecode]->nparams();
561      }      }
# Line 571  namespace Coords { Line 578  namespace Coords {
578                      << show1 << "\n" ;                      << show1 << "\n" ;
579          params.resize(0);          params.resize(0);
580          DBG(dbg)  << "Resized\n";          DBG(dbg)  << "Resized\n";
581          params.reserve(7*ninds);          params.reserve(3*ninds);
582          DBG(dbg)  << "Reserved\n";          DBG(dbg)  << "Reserved\n";
583          cs.resize(ninds/3);          cs.resize(ninds);
584          DBG(dbg)  << "Resized2\n";          DBG(dbg)  << "Resized2\n";
585          cs[0] = new RootCoords();          cs[0] = new RootCoords();
586          DBG(dbg)  << "setroot\n";          DBG(dbg)  << "setroot\n";
587          for(int i=3; i+3<=ninds; i+=3) {          int lastIndSize = 1;
588            for(int i=1; i<ninds; i+=lastIndSize) {
589              DBG(dbg)  << "loop "<<i<<"\n";              DBG(dbg)  << "loop "<<i<<"\n";
590              int parind = params.size();              int parind = params.size();
591              int tp = inds1[i];              int tp = inds1[i];
592              int npars = nparams(tp);              int npars = nparams(tp);
593              int parent = inds1[i+1];              int nprev = nprevious(tp);
594              CoordSys *parentcs = cs[parent];              int ind1;
595              if(parentcs == 0) {              int csind2;
596                  DBG(dbg) << "Parent not interp\n";  
597                  continue; // If parent's not interpolating, neither are we.              lastIndSize = nprev + 2; // typecode, prevs and paramind
598    
599                CoordSys *prev[nprev];
600                
601                for(int j=0; j<nprev; j++) {
602                    int parent = inds1[i+1+j];
603                    CoordSys *parentcs = cs[parent];
604                    if(parentcs == 0) {
605                        DBG(dbg) << "Parent "<<j<<" not interp\n";
606                        goto nextInd; // If parent's not interpolating, neither are we.
607                    }
608                    prev[j] = parentcs;
609              }              }
610              int ind1 = inds1[i+2];  
611              int csind2 = ((interpinds && i/3 < interpinds[0]) ? interpinds[i/3] : -1);              ind1 = inds1[i+1+nprev];
612                csind2 = ((interpinds && i < interpinds[0]) ? interpinds[i] : -1);
613              DBG(dbg) << "inds: "<<parind<<" typ:"<<tp<<" npars:"<<npars<<              DBG(dbg) << "inds: "<<parind<<" typ:"<<tp<<" npars:"<<npars<<
614                              " parent:"<<parent<<" "<<parentcs<<                              " parent:"<<prev[0]<<" "<<
615                              " ind1:"<<ind1<<" "<<csind2<<"\n";                              " ind1:"<<ind1<<" "<<csind2<<"\n";
616              if(csind2 <= 0) {              if(csind2 <= 0) {
617                  if(show1) {                  if(show1) {
# Line 602  namespace Coords { Line 622  namespace Coords {
622                      continue;                      continue;
623                  }                  }
624              } else {              } else {
625                  int ind2 = inds2[3*csind2 + 2];                  int ind2 = inds2[csind2 + 2];
626                  for(int j = 0; j<npars; j++) {                  for(int j = 0; j<npars; j++) {
627                      DBG(dbg) << "Interpolating "<<(ind1+j)<<" "<<(ind2+j)<<"  = "<<                      DBG(dbg) << "Interpolating "<<(ind1+j)<<" "<<(ind2+j)<<"  = "<<
628                                  points1[ind1+j]<<" "<< points2[ind2+j]<<"\n";                                  points1[ind1+j]<<" "<< points2[ind2+j]<<"\n";
629                      params.push_back(lerp(points1[ind1 + j], points2[ind2 + j], fract));                      params.push_back(lerp(points1[ind1 + j], points2[ind2 + j], fract));
630                  }                  }
631              }              }
632              CoordSys *c = create(tp);              {
633              cs[i/3] = c;                  CoordSys *c = create(tp);
634              c->setSuper(parentcs);                  cs[i] = c;
635              c->setParams(&(params[0]) + parind);                  c->setSuper(prev);
636                    c->setParams(&(params[0]) + parind);
637                }
638            nextInd:;
639          }          }
640          DBG(dbg)  << "end\n";          DBG(dbg)  << "end\n";
641      }      }

Legend:
Removed from v.1.31  
changed lines
  Added in v.1.32

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26