@{ * Expand this rect to contain the point passed in. */
| 140 | * Expand this rect to contain the point passed in. |
| 141 | */ |
| 142 | void AddPoint(const T point[2]) |
| 143 | { |
| 144 | // This code is written like this to ensure that adding a point gives |
| 145 | // exactly the same result as AddRect(vtkRect(x,y,0,0) |
| 146 | if (point[0] < this->GetX()) |
| 147 | { |
| 148 | T dx = this->GetX() - point[0]; |
| 149 | this->SetX(point[0]); |
| 150 | this->SetWidth(dx + this->GetWidth()); |
| 151 | } |
| 152 | else if (point[0] > this->GetX()) |
| 153 | { |
| 154 | // this->GetX() is already correct |
| 155 | T dx = point[0] - this->GetX(); |
| 156 | this->SetWidth(vtkMath::Max(dx, this->GetWidth())); |
| 157 | } |
| 158 | ///@} |
| 159 | |
| 160 | if (point[1] < this->GetY()) |
| 161 | { |
| 162 | T dy = this->GetY() - point[1]; |
| 163 | this->SetY(point[1]); |
| 164 | this->SetHeight(dy + this->GetHeight()); |
| 165 | } |
| 166 | else if (point[1] > this->GetY()) |
| 167 | { |
| 168 | // this->GetY() is already correct |
| 169 | T dy = point[1] - this->GetY(); |
| 170 | this->SetHeight(vtkMath::Max(dy, this->GetHeight())); |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | ///@{ |
| 175 | /** |