1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
|
// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
// SPDX-License-Identifier: BSD-3-Clause
#include "vtkPointHandleSource.h"
#include "vtkConeSource.h"
#include "vtkSphereSource.h"
//------------------------------------------------------------------------------
VTK_ABI_NAMESPACE_BEGIN
vtkStandardNewMacro(vtkPointHandleSource);
//------------------------------------------------------------------------------
void vtkPointHandleSource::SetPosition(double xPos, double yPos, double zPos)
{
if ((this->Position[0] != xPos) || (this->Position[1] != yPos) || (this->Position[2] != zPos))
{
this->Position[0] = xPos;
this->Position[1] = yPos;
this->Position[2] = zPos;
this->Modified();
}
}
//------------------------------------------------------------------------------
double* vtkPointHandleSource::GetPosition()
{
return this->Position;
}
//------------------------------------------------------------------------------
void vtkPointHandleSource::SetDirection(double xDir, double yDir, double zDir)
{
if ((this->Direction[0] != xDir) || (this->Direction[1] != yDir) || (this->Direction[2] != zDir))
{
this->Direction[0] = xDir;
this->Direction[1] = yDir;
this->Direction[2] = zDir;
this->Modified();
}
}
//------------------------------------------------------------------------------
double* vtkPointHandleSource::GetDirection()
{
return this->Direction;
}
//------------------------------------------------------------------------------
int vtkPointHandleSource::RequestData(
vtkInformation*, vtkInformationVector**, vtkInformationVector* outputVector)
{
auto output = vtkPolyData::GetData(outputVector);
if (!this->Directional)
{
this->RecomputeSphere();
output->ShallowCopy(this->PositionSphere->GetOutput(0));
}
else
{
this->RecomputeCone();
output->ShallowCopy(this->PositionCone->GetOutput(0));
}
return 1;
}
//------------------------------------------------------------------------------
void vtkPointHandleSource::RecomputeSphere()
{
this->PositionSphere->SetRadius(this->Size);
this->PositionSphere->SetCenter(this->Position);
this->PositionSphere->SetThetaResolution(16);
this->PositionSphere->SetPhiResolution(8);
this->PositionSphere->Update();
}
//------------------------------------------------------------------------------
void vtkPointHandleSource::RecomputeCone()
{
this->PositionCone->SetRadius(this->Size);
this->PositionCone->SetCenter(this->Position);
this->PositionCone->SetHeight(2.8 * this->Size);
this->PositionCone->SetResolution(16);
this->PositionCone->SetDirection(this->Direction);
this->PositionCone->Update();
}
//------------------------------------------------------------------------------
void vtkPointHandleSource::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
if (this->Directional)
{
os << indent << "PositionCone: (" << this->PositionCone << "\n";
if (this->PositionCone)
{
this->PositionCone->PrintSelf(os, indent.GetNextIndent());
os << indent << ")\n";
}
else
{
os << "none)\n";
}
}
else
{
os << indent << "PositionSphere: (" << this->PositionSphere << "\n";
if (this->PositionSphere)
{
this->PositionSphere->PrintSelf(os, indent.GetNextIndent());
os << indent << ")\n";
}
else
{
os << "none)\n";
}
}
}
VTK_ABI_NAMESPACE_END
|