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

Method BuildRepresentation

Interaction/Widgets/vtkPolyLineRepresentation.cxx:44–83  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

42
43//------------------------------------------------------------------------------
44void vtkPolyLineRepresentation::BuildRepresentation()
45{
46 this->ValidPick = 1;
47 // TODO: Avoid unnecessary rebuilds.
48 // Handles have changed position, re-compute the points
49 vtkPoints* points = this->PolyLineSource->GetPoints();
50 if (points->GetNumberOfPoints() != this->NumberOfHandles)
51 {
52 points->SetNumberOfPoints(this->NumberOfHandles);
53 }
54
55 vtkBoundingBox bbox;
56 for (int i = 0; i < this->NumberOfHandles; ++i)
57 {
58 double pt[3];
59 this->PointHandles[i]->GetPosition(pt);
60 points->SetPoint(i, pt);
61 bbox.AddPoint(pt);
62 }
63 this->PolyLineSource->SetClosed(this->Closed);
64 this->PolyLineSource->Modified();
65 points->Modified();
66
67 // Update end arrow direction
68 if (this->Directional && this->NumberOfHandles >= 2)
69 {
70 vtkVector3d pt1, pt2;
71 this->PointHandles[this->NumberOfHandles - 1]->GetPosition(pt1.GetData());
72 this->PointHandles[this->NumberOfHandles - 2]->GetPosition(pt2.GetData());
73 pt1 = pt1 - pt2;
74 this->PointHandles[this->NumberOfHandles - 1]->SetDirection(pt1.GetData());
75 }
76
77 double bounds[6];
78 bbox.GetBounds(bounds);
79 this->InitialLength = sqrt((bounds[1] - bounds[0]) * (bounds[1] - bounds[0]) +
80 (bounds[3] - bounds[2]) * (bounds[3] - bounds[2]) +
81 (bounds[5] - bounds[4]) * (bounds[5] - bounds[4]));
82 this->SizeHandles();
83}
84
85//------------------------------------------------------------------------------
86void vtkPolyLineRepresentation::SetNumberOfHandles(int npts)

Callers 1

SetNumberOfHandlesMethod · 0.95

Calls 13

sqrtFunction · 0.50
GetPointsMethod · 0.45
GetNumberOfPointsMethod · 0.45
SetNumberOfPointsMethod · 0.45
GetPositionMethod · 0.45
SetPointMethod · 0.45
AddPointMethod · 0.45
SetClosedMethod · 0.45
ModifiedMethod · 0.45
GetDataMethod · 0.45
SetDirectionMethod · 0.45
GetBoundsMethod · 0.45

Tested by

no test coverage detected