SDC C-Project CF Review 프로그램
LYW
2021-05-26 5e3a8e2508c719bb48273d873b17b636c7cef4d7
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#pragma once
 
 
 
template<typename T>
class CakRectT
{
public:
    T left;
    T top;
    T right;
    T bottom;
 
public:    
    CakRectT(void);
    //CakRectT(T l, T t, T r, T b);
    CakRectT(const T l, const T t, const T r, const T b):left(l),top(t),right(r),bottom(b) {};
    virtual ~CakRectT(void);
    
 
     //Attirbute
     // retrieves the width
     T Width() const throw();
     // returns the height
     T Height() const throw();
     
    //{
    //    // reference to the top-left point
    //    CPoint& TopLeft() throw();
    //    // reference to the bottom-right point
    //    CPoint& BottomRight() throw();
    //    // const reference to the top-left point
    //    const CPoint& TopLeft() const throw();
    //    // const reference to the bottom-right point
    //    const CPoint& BottomRight() const throw();
    //    // the geometric center point of the rectangle
    //    CPoint CenterPoint() const throw();
    //
    //    bool PtInRect(POINT point) const throw();
    //}
 
     // swap the left and right
    void SwapLeftRight() throw();
     void SwapTopBottom() throw();
 
 
 
     // returns TRUE if rectangle has no area
     bool IsRectEmpty() const throw();
     // returns TRUE if rectangle is at (0,0) and has no area
     bool IsRectNull() const throw();
     // returns TRUE if point is within rectangle
     
    bool PtInRect(T x, T y) const throw();
 
     // Operations
 
     // set rectangle from left, top, right, and bottom
     void SetRect(T x1, T y1, T x2, T y2) throw();
     //void SetRect(POINT topLeft, POINT bottomRight) throw();
     // empty the rectangle
     void SetRectEmpty() throw();
     // copy from another rectangle
     void CopyRect(const CakRectT<T>* lpSrcRect) throw();
     // TRUE if exactly the same as another rectangle
     bool EqualRect(const CakRectT<T>* lpRect) const throw();
 
    // Inflate rectangle's width and height by
    // x units to the left and right ends of the rectangle
    // and y units to the top and bottom.
    void InflateRect(T x, T y) throw();
    void InflateRect(T l, T t, T r, T b) throw();
    void InflateRect(CakRectT<T>* lpRect) throw();
 
    // deflate the rectangle's width and height without
    // moving its top or left
    void DeflateRect(T x, T y) throw();
    void DeflateRect(T l, T t, T r, T b) throw();
    //void DeflateRect(SIZE size) throw();
    void DeflateRect(CakRectT<T>* lpRect) throw();
 
    // translate the rectangle by moving its top and left
    void OffsetRect(T x, T y) throw();
    //void OffsetRect(SIZE size) throw();
    //void OffsetRect(POINT point) throw();
    void NormalizeRect() throw();
 
    // absolute position of rectangle
    void MoveToY(T y) throw();
    void MoveToX(T x) throw();
    void MoveToXY(T x, T y) throw();
    //void MoveToXY(POINT point) throw();
 
     // µÎ»ç°¢ÇüÀÌ °ãÄ¡´Â ºÎºÐ¸¸ °ËÃâ ¾øÀ»½Ã 0À¸·Î ¼ÂÆÃ(ReturnÀº °ãÄ¡´Â ºÎºÐÀÌ ÀÖÀ¸¸é True)
     bool IntersectRect(CakRectT<T>* lpRect1, CakRectT<T>* lpRect2) throw();
 
     // µÎ »ç°¢ÇüÀÇ Å׵θ® ºÎºÐ °ËÃâ(ReturnÀº °ãÄ¡´Â ºÎºÐÀÌ ÀÖÀ¸¸é True)
     bool UnionRect(CakRectT<T>* lpRect1, CakRectT<T>* lpRect2) throw();
    
     // set this rectangle to minimum of two others
     //bool SubtractRect(CakRectT<T>* lpRectSrc1, CakRectT<T>* lpRectSrc2) throw();
 
    // Additional Operations
    void operator=(const CakRectT<T>& srcRect) throw();
    bool operator==(const CakRectT<T>& rect) const throw();
    bool operator!=(const CakRectT<T>& rect) const throw();
    void operator+=(CakRectT<T>* lpRect) throw();
    void operator-=(CakRectT<T>* lpRect) throw();
    //void operator&=(const CakRectT<T>& rect) throw();
    //void operator|=(const CakRectT<T>& rect) throw();
 
      // Operators returning CakRectT<T> values
      //CakRectT<T> operator+(POINT point) const throw();
      //CakRectT<T> operator-(POINT point) const throw();
      CakRectT<T> operator+(CakRectT<T>* lpRect) const throw();
      //CakRectT<T> operator+(SIZE size) const throw();
      //CakRectT<T> operator-(SIZE size) const throw();
      CakRectT<T> operator-(CakRectT<T>* lpRect) const throw();
      //CakRectT<T> operator&(const CakRectT<T>& rect2) const throw();
      //CakRectT<T> operator|(const CakRectT<T>& rect2) const throw();
 
     CakRectT<T> MulDiv(T nMultiplier, T nDivisor) const throw();
 
    //¿¹Àü¿¡ ¾²´ø ÇÔ¼öµé
public:
    inline void set(T l, T t, T r, T b)
    {
        left = l;
        top = t;
        right = r;
        bottom = b;    
    };
    inline T getWidth(){return right-left;};
    inline T getHeight(){return bottom-top;};
    inline T getCenter(){return T(left+(right-left)/2.0);};
    inline T getVCenter(){return T(top+(bottom-top)/2.0);};
    void setAlign(){NormalizeRect();}; //ÀÛÀº°ªÀÌ ¿ÞÂÊ, À§, Å«°ªÀÌ ¿À¸¥ÂÊ ¾Æ·¡·Î °¡°Ô ÇÑ´Ù.
    bool getCheckAreaIn(double x, double y); //»ç°¢Çü ¿µ¿ª¿¡ x,yÆ÷ÀÎÆ®°¡ ÀÖ´ÂÁö °Ë»ç
    bool getCheckWidthIn(double p1); //xÆ÷ÀÎÆ® °¡¿îµ¥ Á¡ÀÌ ÀÖ´ÂÁö °Ë»ç
    bool getCheckHeightIn(double p1); //yÆ÷ÀÎÆ® °¡¿îµ¥ Á¡ÀÌ ÀÖ´ÂÁö °Ë»ç
 
 
 
};
 
 
template<typename T>
bool CakRectT<T>::IntersectRect( CakRectT<T>* lpRect1, CakRectT<T>* lpRect2 ) throw()
{
    
    if ( lpRect1->left    <    lpRect2->right    &&
        lpRect1->top    <    lpRect2->bottom    &&
        lpRect1->right    >    lpRect2->left    &&
        lpRect1->bottom    >    lpRect2->top        )
    {
        //*this = *lpRect2;
 
        lpRect1->left    > lpRect2->left   ? left     = lpRect1->left    : left  = lpRect2->left        ;    
        lpRect1->top    > lpRect2->top      ? top         = lpRect1->top        : top    = lpRect2->top        ;
        lpRect1->right    < lpRect2->right  ? right     = lpRect1->right    : right    = lpRect2->right    ;
        lpRect1->bottom < lpRect2->bottom ? bottom     = lpRect1->bottom    : bottom= lpRect2->bottom    ;
 
        return true;
    }
 
    set(0,0,0,0);
 
    return false;
}
 
template<typename T>
bool CakRectT<T>::UnionRect( CakRectT<T>* lpRect1, CakRectT<T>* lpRect2 ) throw()
{
 
    lpRect1->left    < lpRect2->left   ? left     = lpRect1->left    : left  = lpRect2->left    ;    
    lpRect1->top    < lpRect2->top      ? top         = lpRect1->top        : top    = lpRect2->top        ;
    lpRect1->right    > lpRect2->right  ? right     = lpRect1->right    : right    = lpRect2->right    ;
    lpRect1->bottom > lpRect2->bottom ? bottom     = lpRect1->bottom    : bottom= lpRect2->bottom    ;
    
    if ( lpRect1->left    <    lpRect2->right    &&
        lpRect1->top    <    lpRect2->bottom    &&
        lpRect1->right    >    lpRect2->left    &&
        lpRect1->bottom    >    lpRect2->top        )
    {
        return true;
    }
 
    return false;
}
 
 
 
 
 
 
#include "inl/akRectT.inl"