------------------------------------------------------------------------------
| 42 | |
| 43 | //------------------------------------------------------------------------------ |
| 44 | void 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 | //------------------------------------------------------------------------------ |
| 86 | void vtkPolyLineRepresentation::SetNumberOfHandles(int npts) |
no test coverage detected