/usr/include/OTB-5.8/otbVectorDataProperties.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 | /*=========================================================================
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 otbVectorDataProperties_txx
#define otbVectorDataProperties_txx
#include "otbVectorDataProperties.h"
#include <algorithm>
namespace otb
{
template <class TVectorData>
bool VectorDataProperties<TVectorData>
::IsBoundingRegionNull()
{
for (unsigned int i = 0; i < VectorDataDimension; ++i)
{
if ((m_BoundingRegion.GetOrigin(i) != itk::NumericTraits<Type>::ZeroValue()) ||
(m_BoundingRegion.GetSize(i) != itk::NumericTraits<Type>::ZeroValue())) return false;
}
return true;
}
/**
* Add a region
*/
template <class TVectorData>
void
VectorDataProperties<TVectorData>
::AddRegion(const RegionType& region)
{
// std::cout << "add region: " << region << std::endl;
if (this->IsBoundingRegionNull())
{
m_BoundingRegion = region;
}
else
{
Type index;
for (unsigned int i = 0; i < VectorDataDimension; ++i)
{
index = std::min (m_BoundingRegion.GetOrigin(i), region.GetOrigin(i));
m_BoundingRegion.SetSize(i,
std::max (m_BoundingRegion.GetOrigin(i) + m_BoundingRegion.GetSize(i),
region.GetOrigin(i) + region.GetSize(
i)) - index);
m_BoundingRegion.SetOrigin(i, index);
}
}
}
/**
* Compute the complete bounding box of the dataset
*/
template <class TVectorData>
void
VectorDataProperties<TVectorData>
::ComputeBoundingRegion()
{
/** Initialize the bounding region to null*/
IndexType index;
SizeType size;
index.Fill(itk::NumericTraits<Type>::ZeroValue());
size.Fill(itk::NumericTraits<Type>::ZeroValue());
m_BoundingRegion.SetIndex(index);
m_BoundingRegion.SetSize(size);
/** Compute the bounding region*/
InternalTreeNodeType * inputRoot = const_cast<InternalTreeNodeType *>(m_VectorDataObject->GetDataTree()->GetRoot());
ProcessNode(inputRoot);
}
template<class TVectorData>
void
VectorDataProperties<TVectorData>
::ProcessNode(InternalTreeNodeType * source)
{
// Get the children list from the input node
ChildrenListType children = source->GetChildrenList();
// For each child
for (typename ChildrenListType::iterator it = children.begin(); it != children.end(); ++it)
{
// Copy input DataNode info
DataNodePointerType dataNode = (*it)->Get();
switch (dataNode->GetNodeType())
{
case otb::ROOT:
{
ProcessNode((*it));
break;
}
case otb::DOCUMENT:
{
ProcessNode((*it));
break;
}
case otb::FOLDER:
{
ProcessNode((*it));
break;
}
case FEATURE_POINT:
{
// otbGenericMsgDebugMacro(<<"Insert Point from vectorData");
IndexType start;
for (unsigned int i = 0; i < VectorDataDimension; ++i)
{
start[i] = dataNode->GetPoint()[i];
}
SizeType size;
size.Fill(itk::NumericTraits<Type>::ZeroValue());
RegionType region;
region.SetSize(size);
region.SetIndex(start);
this->AddRegion(region);
break;
}
case otb::FEATURE_LINE:
{
this->AddRegion(dataNode->GetLine()->GetBoundingRegion());
break;
}
case FEATURE_POLYGON:
{
//otbGenericMsgDebugMacro(<<"Insert polygons from vectorData");
this->AddRegion(dataNode->GetPolygonExteriorRing()->GetBoundingRegion());
break;
}
case FEATURE_MULTIPOINT:
{
itkExceptionMacro(
<<
"This type (FEATURE_MULTIPOINT) is not handle (yet), please request for it");
break;
}
case FEATURE_MULTILINE:
{
itkExceptionMacro(
<< "This type (FEATURE_MULTILINE) is not handle (yet), please request for it");
break;
}
case FEATURE_MULTIPOLYGON:
{
itkExceptionMacro(
<<
"This type (FEATURE_MULTIPOLYGON) is not handle (yet), please request for it");
break;
}
case FEATURE_COLLECTION:
{
itkExceptionMacro(
<<
"This type (FEATURE_COLLECTION) is not handle (yet), please request for it");
break;
}
}
}
}
template<class TVectorData>
void
VectorDataProperties<TVectorData>
::PrintSelf(std::ostream& os, itk::Indent indent) const
{
Superclass::PrintSelf(os, indent);
os << indent << "Properties VectorData: " << m_VectorDataObject << std::endl;
os << indent << "Properties Bounding Region: " << m_BoundingRegion << std::endl;
}
} // End namespace otb
#endif
|