| 269 | } |
| 270 | |
| 271 | void SampleTriangle(const vtkIdType* pts) override |
| 272 | { |
| 273 | double x0[3], x1[3], x2[3]; |
| 274 | this->InPts->GetPoint(pts[0], x0); |
| 275 | this->InPts->GetPoint(pts[1], x1); |
| 276 | this->InPts->GetPoint(pts[2], x2); |
| 277 | |
| 278 | double l1 = vtkMath::Distance2BetweenPoints(x0, x1); |
| 279 | double l2 = vtkMath::Distance2BetweenPoints(x0, x2); |
| 280 | if (l1 > this->Distance2 || l2 > this->Distance2) |
| 281 | { |
| 282 | vtkIdType pId; |
| 283 | double s, t, x[3]; |
| 284 | if (this->InPD) |
| 285 | { |
| 286 | this->TriIds->SetId(0, pts[0]); |
| 287 | this->TriIds->SetId(1, pts[1]); |
| 288 | this->TriIds->SetId(2, pts[2]); |
| 289 | } |
| 290 | |
| 291 | l1 = sqrt(l1); |
| 292 | l2 = sqrt(l2); |
| 293 | int n1 = static_cast<int>(l1 / this->Distance) + 2; |
| 294 | int n2 = static_cast<int>(l2 / this->Distance) + 2; |
| 295 | n1 = (n1 < 3 ? 3 : n1); // make sure there is at least one point |
| 296 | n2 = (n2 < 3 ? 3 : n2); |
| 297 | for (vtkIdType j = 1; j < (n2 - 1); j++) |
| 298 | { |
| 299 | t = static_cast<double>(j) / (n2 - 1); |
| 300 | for (vtkIdType i = 1; i < (n1 - 1); i++) |
| 301 | { |
| 302 | s = static_cast<double>(i) / (n1 - 1); |
| 303 | if ((1.0 - s - t) > 0.0) |
| 304 | { |
| 305 | x[0] = x0[0] + s * (x1[0] - x0[0]) + t * (x2[0] - x0[0]); |
| 306 | x[1] = x0[1] + s * (x1[1] - x0[1]) + t * (x2[1] - x0[1]); |
| 307 | x[2] = x0[2] + s * (x1[2] - x0[2]) + t * (x2[2] - x0[2]); |
| 308 | pId = this->OutPts->InsertNextPoint(x); |
| 309 | if (this->InPD) |
| 310 | { |
| 311 | this->TriWeights[0] = 1.0 - s - t; |
| 312 | this->TriWeights[1] = s; |
| 313 | this->TriWeights[2] = t; |
| 314 | this->OutPD->InterpolatePoint(this->InPD, pId, this->TriIds, this->TriWeights); |
| 315 | } |
| 316 | } |
| 317 | } |
| 318 | } |
| 319 | } |
| 320 | } |
| 321 | |
| 322 | void SamplePolygon(vtkIdType npts, const vtkIdType* pts) override |
| 323 | { |
no test coverage detected