1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
// Copyright (c) 1997 Philip A. Hardin (pahardin@cs.utexas.edu)
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License v2 or later.
#ifndef VIEW_h
#define VIEW_h
#include "xform.h"
#include "xregion3d.h"
/*=========================================================================*/
/* This is a 3d view of a region3d. The view contains two types of data:
1. the 3d points of the region3d, which are kept in VIEW coordinates, and
can be projected directly to the screen
2. angular/cartesian position tracking data, which allow the 3d points
mentioned above to be updated, with the LEAST amount of computation
possible
This class could be templatized with little trouble to work with
both 2d & 3d objects. It would need to be parameterized by point, region,
and transformation matrix types.
*/
struct view {
pt3d *pts; // object's pts in view coords.
int numPts; // number of valid points in 'pts'.
tmtrx modelToView; // transforms points from the
// object's shape definition
// (region3d) into the view coord
// system.
private:
int maxPts; // size of array to which 'pts'
// points.
// -- WARNING: --
// NOT all elements of the 'pts' array
// are necessarily valid! 'maxPts' is
// simply the size of the array, used
// to determine when a larger array
// must be allocated. The number of
// VALID points in 'pts' is 'numPts'
// The next four fields are used
// to determine when 'pts' need to be
// recomputed:
xregion3d *shape; // ptr to the shape definition of
// this object which was used the
// last time 'pts' were computed
public:
view() {numPts= maxPts= 0; shape= NULL;}
view(const view& v) {Copy(v);}
~view() {if (maxPts >0) delete [] pts;};
view& operator=(const view& v) {return Copy(v);}; // if &v != this... -PAH
pt3d *ViewPts() {return pts;};
int NumPts() const {return numPts;};
void Update(xregion3d*, const tmtrx& newMtv);
private:
view& Copy(const view&);
};
#endif
|