/usr/include/vtk-6.3/vtkAngularPeriodicDataArray.txx is in libvtk6-dev 6.3.0+dfsg1-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | /*=========================================================================
Program: Visualization Toolkit
Module: vtkAngularPeriodicDataArray.txx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkMath.h"
#include "vtkMatrix3x3.h"
#include "vtkObjectFactory.h"
#include <algorithm>
//------------------------------------------------------------------------------
// Can't use vtkStandardNewMacro on a templated class.
template <class Scalar> vtkAngularPeriodicDataArray<Scalar>*
vtkAngularPeriodicDataArray<Scalar>::New()
{
VTK_STANDARD_NEW_BODY(vtkAngularPeriodicDataArray<Scalar>);
}
//------------------------------------------------------------------------------
template <class Scalar> void vtkAngularPeriodicDataArray<Scalar>
::PrintSelf(ostream &os, vtkIndent indent)
{
this->vtkAngularPeriodicDataArray<Scalar>::Superclass::PrintSelf(os, indent);
os << indent << "Axis: " << this->Axis << "\n";
os << indent << "Angle: " << this->Angle << "\n";
os << indent << "Center: " <<
this->Center[0] << " " << this->Center[1] << " " << this->Center[2] << "\n";
}
//------------------------------------------------------------------------------
template <class Scalar> void vtkAngularPeriodicDataArray<Scalar>::
SetAngle(double angle)
{
if (this->Angle != angle)
{
this->Angle = angle;
this->AngleInRadians = vtkMath::RadiansFromDegrees(angle);
this->InvalidateRange();
this->UpdateRotationMatrix();
this->Modified();
}
}
//------------------------------------------------------------------------------
template <class Scalar> void vtkAngularPeriodicDataArray<Scalar>::
SetAxis(int axis)
{
if (this->Axis != axis)
{
this->Axis = axis;
this->InvalidateRange();
this->UpdateRotationMatrix();
this->Modified();
}
}
//------------------------------------------------------------------------------
template <class Scalar> void vtkAngularPeriodicDataArray<Scalar>::
SetCenter(double* center)
{
if (center)
{
bool diff = false;
for (int i = 0; i < 3; i++)
{
if (this->Center[i] != center[i])
{
this->Center[i] = center[i];
diff = true;
}
}
if (diff)
{
this->InvalidateRange();
this->Modified();
}
}
}
//------------------------------------------------------------------------------
template <class Scalar> void vtkAngularPeriodicDataArray<Scalar>::
Transform(Scalar* pos)
{
if (this->NumberOfComponents == 3)
{
// Axis rotation
int axis0 = (this->Axis + 1) % this->NumberOfComponents;
int axis1 = (this->Axis + 2) % this->NumberOfComponents;
double posx = static_cast<double>(pos[axis0]) - this->Center[axis0];
double posy = static_cast<double>(pos[axis1]) - this->Center[axis1];
pos[axis0] = this->Center[axis0] +
static_cast<Scalar>(cos(this->AngleInRadians) * posx - sin(this->AngleInRadians) * posy);
pos[axis1] = this->Center[axis1] +
static_cast<Scalar>(sin(this->AngleInRadians) * posx + cos(this->AngleInRadians) * posy);
if (this->Normalize)
{
vtkMath::Normalize(pos);
}
}
else if (this->NumberOfComponents == 9)
{
// Template type force a copy to a double array for tensor
double localPos [9];
double tmpMat [9];
double tmpMat2 [9];
std::copy(pos, pos + 9, localPos);
vtkMatrix3x3::Transpose(this->RotationMatrix->GetData(), tmpMat);
vtkMatrix3x3::Multiply3x3(this->RotationMatrix->GetData(), localPos, tmpMat2);
vtkMatrix3x3::Multiply3x3(tmpMat2, tmpMat, localPos);
std::copy(localPos, localPos + 9, pos);
}
}
//------------------------------------------------------------------------------
template <class Scalar> void vtkAngularPeriodicDataArray<Scalar>::
UpdateRotationMatrix()
{
int axis0 = (this->Axis + 1) % 3;
int axis1 = (this->Axis + 2) % 3;
this->RotationMatrix->Identity();
this->RotationMatrix->SetElement(this->Axis, this->Axis, 1.);
this->RotationMatrix->SetElement(axis0, axis0, cos(this->AngleInRadians));
this->RotationMatrix->SetElement(axis0, axis1, -sin(this->AngleInRadians));
this->RotationMatrix->SetElement(axis1, axis0, sin(this->AngleInRadians));
this->RotationMatrix->SetElement(axis1, axis1, cos(this->AngleInRadians));
}
//------------------------------------------------------------------------------
template <class Scalar> vtkAngularPeriodicDataArray<Scalar>
::vtkAngularPeriodicDataArray()
{
this->Axis = VTK_PERIODIC_ARRAY_AXIS_X;
this->Angle = 0.0;
this->AngleInRadians = 0.0;
this->Center[0] = 0.0;
this->Center[1] = 0.0;
this->Center[2] = 0.0;
this->RotationMatrix = vtkMatrix3x3::New();
this->RotationMatrix->Identity();
}
//------------------------------------------------------------------------------
template <class Scalar> vtkAngularPeriodicDataArray<Scalar>
::~vtkAngularPeriodicDataArray()
{
this->RotationMatrix->Delete();
}
|