------------------------------------------------------------------------------
| 542 | |
| 543 | //------------------------------------------------------------------------------ |
| 544 | bool vtkLabeledContourPolyDataItem::PlaceLabels() |
| 545 | { |
| 546 | vtkPolyData* input = this->PolyData; |
| 547 | vtkPoints* points = input->GetPoints(); |
| 548 | vtkCellArray* lines = input->GetLines(); |
| 549 | |
| 550 | // Progression of smoothness tolerances to use. |
| 551 | std::vector<double> tols; |
| 552 | tols.push_back(0.010); |
| 553 | tols.push_back(0.025); |
| 554 | tols.push_back(0.050); |
| 555 | tols.push_back(0.100); |
| 556 | tols.push_back(0.200); |
| 557 | tols.push_back(0.300); |
| 558 | |
| 559 | typedef std::vector<PDILabelMetric>::const_iterator MetricsIterator; |
| 560 | MetricsIterator metric = this->Internal->LabelMetrics.begin(); |
| 561 | |
| 562 | // Identify smooth parts of the isoline for labeling |
| 563 | vtkIdType numIds; |
| 564 | const vtkIdType* origIds; |
| 565 | this->Internal->LabelInfos.reserve(this->Internal->LabelMetrics.size()); |
| 566 | for (lines->InitTraversal(); lines->GetNextCell(numIds, origIds); ++metric) |
| 567 | { |
| 568 | assert(metric != this->Internal->LabelMetrics.end()); |
| 569 | |
| 570 | this->Internal->LabelInfos.emplace_back(); |
| 571 | |
| 572 | // Test if it is possible to place a label (e.g. the line is big enough |
| 573 | // to not be completely obscured) |
| 574 | if (this->Internal->LineCanBeLabeled(points, numIds, origIds, *metric)) |
| 575 | { |
| 576 | std::vector<PDILabelInfo>& infos = this->Internal->LabelInfos.back(); |
| 577 | PDILabelInfo info; |
| 578 | // If no labels are found, increase the tolerance: |
| 579 | for (std::vector<double>::const_iterator it = tols.begin(), itEnd = tols.end(); |
| 580 | it != itEnd && infos.empty(); ++it) |
| 581 | { |
| 582 | vtkIdType nIds = numIds; |
| 583 | const vtkIdType* ids = origIds; |
| 584 | while (this->Internal->NextLabel(points, nIds, ids, *metric, info, *it, this->SkipDistance)) |
| 585 | { |
| 586 | infos.push_back(info); |
| 587 | } |
| 588 | } |
| 589 | } |
| 590 | } |
| 591 | |
| 592 | return true; |
| 593 | } |
| 594 | |
| 595 | //------------------------------------------------------------------------------ |
| 596 | bool vtkLabeledContourPolyDataItem::ResolveLabels() |
no test coverage detected