MCPcopy Create free account
hub / github.com/Kitware/VTK / PlaceLabels

Method PlaceLabels

Rendering/Context2D/vtkLabeledContourPolyDataItem.cxx:544–593  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

542
543//------------------------------------------------------------------------------
544bool 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//------------------------------------------------------------------------------
596bool vtkLabeledContourPolyDataItem::ResolveLabels()

Callers 1

PaintMethod · 0.95

Calls 15

backMethod · 0.80
assertFunction · 0.50
GetPointsMethod · 0.45
GetLinesMethod · 0.45
push_backMethod · 0.45
beginMethod · 0.45
reserveMethod · 0.45
sizeMethod · 0.45
InitTraversalMethod · 0.45
GetNextCellMethod · 0.45
endMethod · 0.45
emplace_backMethod · 0.45

Tested by

no test coverage detected