1 | #ifndef SCAN_H |
---|
2 | #define SCAN_H |
---|
3 | |
---|
4 | #include <iostream> |
---|
5 | |
---|
6 | class Scan |
---|
7 | { |
---|
8 | public: |
---|
9 | Scan(){itsY=-1;itsX=-1;itsXLen=0;}; |
---|
10 | Scan(long y, long x, long xl){itsY=y; itsX=x; itsXLen=xl;}; |
---|
11 | Scan(const Scan& s){itsY=s.itsY; itsX=s.itsX; itsXLen=s.itsXLen;}; |
---|
12 | Scan& operator= (const Scan& s){itsY=s.itsY; itsX=s.itsX; itsXLen=s.itsXLen;}; |
---|
13 | virtual ~Scan(){}; |
---|
14 | void define(long y, long x, long xl){itsY=y; itsX=x; itsXLen=xl;}; |
---|
15 | void clear(){itsY=0;itsX=0;itsXLen=0;}; |
---|
16 | long getY(){return itsY;}; |
---|
17 | void setY(long l){itsY=l;}; |
---|
18 | long getX(){return itsX;}; |
---|
19 | void setX(long l){itsX=l;}; |
---|
20 | long getXlen(){return itsXLen;}; |
---|
21 | void setXlen(long l){itsXLen=l;}; |
---|
22 | long getXmax(){return itsX+itsXLen-1;}; |
---|
23 | void setXmax(long l){itsXLen = l-itsX+1;}; |
---|
24 | void growLeft(){itsX--;itsXLen++;}; |
---|
25 | void growRight(){itsXLen++;}; |
---|
26 | |
---|
27 | void addOffsets(long xoff, long yoff){itsY+=yoff; itsX+=xoff;}; |
---|
28 | |
---|
29 | bool isInScan(long x, long y); |
---|
30 | |
---|
31 | friend std::ostream& operator<< ( std::ostream& theStream, Scan& scan); |
---|
32 | friend bool operator< (Scan lhs, Scan rhs); |
---|
33 | friend bool operator== (Scan lhs, Scan rhs); |
---|
34 | friend class Object2D; |
---|
35 | |
---|
36 | private: |
---|
37 | long itsY; |
---|
38 | long itsX; |
---|
39 | long itsXLen; |
---|
40 | |
---|
41 | }; |
---|
42 | |
---|
43 | Scan unite(Scan &s1, Scan &s2); |
---|
44 | Scan intersect(Scan &s1, Scan &s2); |
---|
45 | bool touching(Scan &s1, Scan &s2); |
---|
46 | bool overlap(Scan &s1, Scan &s2); |
---|
47 | bool adjacent(Scan &scan1, Scan &scan2); |
---|
48 | Scan nullScan(); |
---|
49 | |
---|
50 | #endif //SCAN_H |
---|