Get Cell orientation so we know which value to flood fill a region with
| 537 | |
| 538 | // Get Cell orientation so we know which value to flood fill a region with |
| 539 | int vtkLoopBooleanPolyDataFilter::Impl::GetCellOrientation( |
| 540 | vtkPolyData* pd, vtkIdType cellId, vtkIdType p0, vtkIdType p1, int index) |
| 541 | { |
| 542 | vtkDebugWithObjectMacro(this->ParentFilter, << "CellId: " << cellId); |
| 543 | vtkIdType npts; |
| 544 | const vtkIdType* pts; |
| 545 | pd->BuildLinks(); |
| 546 | pd->GetCellPoints(cellId, npts, pts); |
| 547 | // pt0Id and pt1Id are from intersectionLines PolyData and I am trying |
| 548 | // to compare these to the point ids in pd. |
| 549 | vtkIdType cellPtId0 = this->ReversePointMapper[index][p0]; |
| 550 | vtkIdType cellPtId1 = this->ReversePointMapper[index][p1]; |
| 551 | double points[3][3]; |
| 552 | vtkIdType cellPtId2 = 0; |
| 553 | for (int j = 0; j < npts; j++) |
| 554 | { |
| 555 | pd->GetPoint(pts[j], points[j]); |
| 556 | if (cellPtId0 != pts[j] && cellPtId1 != pts[j]) |
| 557 | { |
| 558 | cellPtId2 = pts[j]; |
| 559 | } |
| 560 | } |
| 561 | vtkSmartPointer<vtkPoints> cellPts = vtkSmartPointer<vtkPoints>::New(); |
| 562 | cellPts->InsertNextPoint(pd->GetPoint(cellPtId0)); |
| 563 | cellPts->InsertNextPoint(pd->GetPoint(cellPtId1)); |
| 564 | cellPts->InsertNextPoint(pd->GetPoint(cellPtId2)); |
| 565 | |
| 566 | vtkSmartPointer<vtkPolyData> cellPD = vtkSmartPointer<vtkPolyData>::New(); |
| 567 | cellPD->SetPoints(cellPts); |
| 568 | |
| 569 | vtkSmartPointer<vtkCellArray> cellLines = vtkSmartPointer<vtkCellArray>::New(); |
| 570 | for (int j = 0; j < npts; j++) |
| 571 | { |
| 572 | int spot1 = j; |
| 573 | int spot2 = (j + 1) % 3; |
| 574 | cellLines->InsertNextCell(2); |
| 575 | cellLines->InsertCellPoint(spot1); |
| 576 | cellLines->InsertCellPoint(spot2); |
| 577 | } |
| 578 | cellPD->SetLines(cellLines); |
| 579 | |
| 580 | // Set up a transform that will rotate the points to the |
| 581 | // XY-plane (normal aligned with z-axis). |
| 582 | vtkSmartPointer<vtkTransform> transform = vtkSmartPointer<vtkTransform>::New(); |
| 583 | double zaxis[3] = { 0.0, 0.0, 1.0 }; |
| 584 | double rotationAxis[3], normal[3], center[3], rotationAngle; |
| 585 | |
| 586 | vtkTriangle::ComputeNormal(points[0], points[1], points[2], normal); |
| 587 | |
| 588 | double dotZAxis = vtkMath::Dot(normal, zaxis); |
| 589 | if (fabs(1.0 - dotZAxis) < 1e-6) |
| 590 | { |
| 591 | // Aligned with z-axis |
| 592 | rotationAxis[0] = 1.0; |
| 593 | rotationAxis[1] = 0.0; |
| 594 | rotationAxis[2] = 0.0; |
| 595 | rotationAngle = 0.0; |
| 596 | } |
no test coverage detected