/usr/include/OTB-5.8/otbPolyLineParametricPathWithValue.txx is in libotb-dev 5.8.0+dfsg-3.
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 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | /*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt 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 notices for more information.
=========================================================================*/
#ifndef otbPolyLineParametricPathWithValue_txx
#define otbPolyLineParametricPathWithValue_txx
#include "otbPolyLineParametricPathWithValue.h"
#include "itkNumericTraits.h"
namespace otb
{
/**
* Constructor
*/
template <class TValue, unsigned int VDimension>
PolyLineParametricPathWithValue<TValue, VDimension>
::PolyLineParametricPathWithValue() :
m_Key("Value"), m_Length(-1.0), m_LengthIsValid(false),
m_BoundingRegion(), m_BoundingRegionIsValid(false)
{
itk::MetaDataDictionary& dict = this->GetMetaDataDictionary();
ValueType v;
itk::EncapsulateMetaData<ValueType>(dict, m_Key, itk::NumericTraits<ValueType>::ZeroValue(v));
}
template <class TValue, unsigned int VDimension>
void PolyLineParametricPathWithValue<TValue, VDimension>
::AddVertex(const ContinuousIndexType& vertex)
{
Superclass::AddVertex(vertex);
this->Modified();
}
template <class TValue, unsigned int VDimension>
double PolyLineParametricPathWithValue<TValue, VDimension>
::GetLength() const
{
if (!m_LengthIsValid)
{
ComputeLength();
}
return m_Length;
}
template <class TValue, unsigned int VDimension>
void
PolyLineParametricPathWithValue<TValue, VDimension>
::ComputeLength() const
{
double length = 0.0;
VertexListConstIteratorType it = this->GetVertexList()->Begin();
if (this->GetVertexList()->Size() > 1)
{
VertexType pt1 = it.Value(); //just init, won't be used like that
VertexType pt2 = it.Value();
++it;
while (it != this->GetVertexList()->End())
{
pt1 = pt2;
pt2 = it.Value();
double accum = 0.0;
for (unsigned int i = 0; i < VDimension; ++i)
{
accum += (pt1[i] - pt2[i]) * (pt1[i] - pt2[i]);
}
length += vcl_sqrt(accum);
++it;
}
}
else //if there is strictly less than 2 points, length is 0
{
length = 0.0;
}
m_Length = length;
m_LengthIsValid = true;
}
/**
* PrintSelf Method
*/
template <class TValue, unsigned int VDimension>
void
PolyLineParametricPathWithValue<TValue, VDimension>
::PrintSelf(std::ostream& os, itk::Indent indent) const
{
Superclass::PrintSelf(os, indent);
VertexListConstIteratorType it = this->GetVertexList()->Begin();
while (it != this->GetVertexList()->End())
{
os << it.Value() << " - ";
++it;
}
os << std::endl;
}
template <class TValue, unsigned int VDimension>
typename PolyLineParametricPathWithValue<TValue, VDimension>
::RegionType
PolyLineParametricPathWithValue<TValue, VDimension>
::GetBoundingRegion() const
{
if (!m_BoundingRegionIsValid)
{
ComputeBoundingRegion();
}
return m_BoundingRegion;
}
/**
* Bounding Box computation
*/
template <class TValue, unsigned int VDimension>
void
PolyLineParametricPathWithValue<TValue, VDimension>
::ComputeBoundingRegion() const
{
SizeType size;
IndexType index;
size.Fill(0);
index.Fill(0);
IndexType maxId;
maxId.Fill(0);
VertexListConstIteratorType it = this->GetVertexList()->Begin();
double x = 0.0;
double y = 0.0;
if (this->GetVertexList()->Size() > 0)
{
x = static_cast<double>(it.Value()[0]);
y = static_cast<double>(it.Value()[1]);
index[0] = x;
index[1] = y;
maxId[0] = x;
maxId[1] = y;
++it;
while (it != this->GetVertexList()->End())
{
x = static_cast<double>(it.Value()[0]);
y = static_cast<double>(it.Value()[1]);
// Index search
if (x < index[0])
{
index[0] = x;
}
if (y < index[1])
{
index[1] = y;
}
// Max Id search for size computation
if (x > maxId[0])
{
maxId[0] = x;
}
if (y > maxId[1])
{
maxId[1] = y;
}
++it;
}
size[0] = maxId[0] - index[0];
size[1] = maxId[1] - index[1];
}
m_BoundingRegion.SetSize(size);
m_BoundingRegion.SetOrigin(index);
m_BoundingRegionIsValid = true;
}
template <class TValue, unsigned int VDimension>
void
PolyLineParametricPathWithValue<TValue, VDimension>
::Modified() const
{
m_LengthIsValid = false;
m_BoundingRegionIsValid = false;
}
} // end namespace otb
#endif
|