/usr/include/OTB-5.8/otbGlImageActor.h 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 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 | /*=========================================================================
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 otb_GlImageActor_h
#define otb_GlImageActor_h
#include <vcl_algorithm.h>
#include "itkCenteredRigid2DTransform.h"
#include "otbFragmentShader.h"
#include "otbGenericRSTransform.h"
#include "otbGeoInterface.h"
#include "otbGlActor.h"
#include "otbImageFileReader.h"
#include "otbImageSettings.h"
#include "otbMultiChannelExtractROI.h"
#include "otbVectorRescaleIntensityImageFilter.h"
#include "otbVectorImage.h"
namespace otb
{
class OTBIce_EXPORT GlImageActor
: public GlActor, public GeoInterface
{
public:
typedef GlImageActor Self;
typedef GlActor Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
itkNewMacro(Self);
typedef VectorImage<float> VectorImageType;
typedef VectorImage<unsigned char> UCharVectorImageType;
typedef VectorImageType::PixelType PixelType;
typedef VectorImageType::ImageKeywordlistType ImageKeywordlistType;
typedef itk::MetaDataDictionary MetaDataDictionaryType;
typedef VectorImageType::SizeType SizeType;
typedef VectorImageType::IndexType IndexType;
typedef VectorImageType::RegionType RegionType;
typedef VectorImageType::SpacingType SpacingType;
typedef VectorImageType::PointType PointType;
typedef VectorRescaleIntensityImageFilter<VectorImageType,UCharVectorImageType> RescaleFilterType;
struct ResolutionAlgorithm
{
enum type
{
Invalid,
Nearest, ///<Use the nearest resolution (lower or upper)
Nearest_Lower, ///<Use the nearest lower resolution (better for
///performances, poorer quality
Nearest_Upper,///<Use the nearest upper resolution (lower
///performances, better quality)
MAX__};
};
// Initialize with a new image
void Initialize(const std::string & filename);
// Retrieve the full extent of the actor
void GetExtent(double & ulx, double & uly, double & lrx, double & lry) const ITK_OVERRIDE;
// Update internal actor state with respect to ViewSettings
void ProcessViewSettings() ITK_OVERRIDE;
// Heavy load/unload operations of data
void UpdateData() ITK_OVERRIDE;
// Gl rendering of current state
void Render() ITK_OVERRIDE;
// Automatic color adjustment
void AutoColorAdjustment( double & minRed, double & maxRed,
double & minGreen, double & maxGreen,
double & minBlue, double & maxBlue,
bool full = true,
unsigned int refSize = 500,
double lcp = 0.02, double hcp = 0.02 );
const PointType & GetOrigin() const;
const GeoInterface::Spacing2 & GetSpacing() const ITK_OVERRIDE;
std::string GetWkt() const ITK_OVERRIDE;
ImageKeywordlistType GetKwl() const;
bool HasKwl() const ITK_OVERRIDE;
bool GetKwl( ImageKeywordlist & ) const ITK_OVERRIDE;
MetaDataDictionaryType & GetMetaDataDictionary() const;
itkGetMacro(RedIdx,unsigned int);
itkGetMacro(GreenIdx,unsigned int);
itkGetMacro(BlueIdx,unsigned int);
itkGetMacro(NumberOfComponents,unsigned int);
itkGetMacro(CurrentResolution,unsigned int);
itkGetMacro(LargestRegion,RegionType);
itkSetMacro(TileSize,unsigned int);
itkGetMacro(TileSize,unsigned int);
itkBooleanMacro(SoftwareRendering );
itkSetMacro(SoftwareRendering, bool );
itkGetMacro(SoftwareRendering, bool );
void CreateShader();
void SetResolutionAlgorithm(ResolutionAlgorithm::type alg)
{
m_ResolutionAlgorithm = alg;
}
ResolutionAlgorithm::type GetResolutionAlgorithm() const
{
return m_ResolutionAlgorithm;
}
virtual void SetRedIdx(const unsigned int idx)
{
if ( this->m_RedIdx != idx )
{
this->m_RedIdx = vcl_min(this->GetNumberOfComponents(),idx);
this->Modified();
}
}
virtual void SetGreenIdx(const unsigned int idx)
{
if ( this->m_GreenIdx != idx )
{
this->m_GreenIdx = vcl_min(this->GetNumberOfComponents(),idx);
this->Modified();
}
}
virtual void SetBlueIdx(const unsigned int idx)
{
if ( this->m_BlueIdx != idx )
{
this->m_BlueIdx = vcl_min(this->GetNumberOfComponents(),idx);
this->Modified();
}
}
PointType ViewportToImageTransform(const PointType & in, bool physical = true) const;
PointType ImageToViewportTransform(const PointType & in, bool physical = true) const;
bool GetPixelFromViewport( const PointType & in, PixelType & pixel ) const;
bool GetPixelFromViewport( const PointType & view,
PixelType & pixel,
PointType & physical,
IndexType & index ) const;
bool GetPixel( const PointType & physical, PixelType & pixel, IndexType & index ) const;
itkGetObjectMacro(Shader,FragmentShader);
itkSetObjectMacro(Shader,FragmentShader);
itkGetObjectMacro( ImageSettings, ImageSettings );
//
// otb::GlActor overloads.
//
bool TransformFromViewport( Point2d & out,
const Point2d & in,
bool isPhysical = true ) const ITK_OVERRIDE;
bool TransformToViewport( Point2d & out,
const Point2d & in,
bool isPhysical = true ) const ITK_OVERRIDE;
void UpdateTransforms();
protected:
GlImageActor();
~GlImageActor() ITK_OVERRIDE;
typedef ImageFileReader<VectorImageType> ReaderType;
typedef MultiChannelExtractROI<float,float> ExtractROIFilterType;
typedef otb::GenericRSTransform<> RSTransformType;
typedef itk::CenteredRigid2DTransform<> RigidTransformType;
typedef std::vector<unsigned int> ResolutionVectorType;
// Internal class to hold tiles
class Tile
{
public:
Tile()
: m_Loaded(false),
m_TextureId(0),
m_ImageRegion(),
m_TileSize(0),
m_Image(),
m_UL(),
m_UR(),
m_LL(),
m_LR(),
m_Resolution(1),
m_RedIdx(1),
m_GreenIdx(2),
m_BlueIdx(3),
m_RescaleFilter(ITK_NULLPTR)
{
m_UL.Fill(0);
m_UR.Fill(0);
m_LL.Fill(0);
m_LR.Fill(0);
}
bool m_Loaded;
unsigned int m_TextureId;
RegionType m_ImageRegion;
unsigned int m_TileSize;
VectorImageType::Pointer m_Image;
PointType m_UL;
PointType m_UR;
PointType m_LL;
PointType m_LR;
unsigned int m_Resolution;
unsigned int m_RedIdx;
unsigned int m_GreenIdx;
unsigned int m_BlueIdx;
RescaleFilterType::Pointer m_RescaleFilter;
};
typedef std::vector<Tile> TileVectorType;
private:
// prevent implementation
GlImageActor(const Self&);
void operator=(const Self&);
// Load tile to GPU
void LoadTile(Tile& tile);
// Unload tile from GPU
void UnloadTile(Tile& tile);
// Clean the loaded tiles, getting rid of unnecessary ones
void CleanLoadedTiles();
// Clear all loaded tiles
void ClearLoadedTiles();
// Is tile loaded ?
bool TileAlreadyLoaded(const Tile& tile);
void ImageRegionToViewportExtent(const RegionType& region, double & ulx, double & uly, double & lrx, double& lry) const;
void ImageRegionToViewportQuad(const RegionType & region, PointType & ul, PointType & ur, PointType & ll, PointType & lr, bool rotate = true) const;
void ViewportExtentToImageRegion(const double& ulx, const double & uly, const double & lrx, const double & lry, RegionType & region) const;
void UpdateResolution();
unsigned int m_TileSize;
std::string m_FileName;
ReaderType::Pointer m_FileReader;
TileVectorType m_LoadedTiles;
unsigned int m_RedIdx;
unsigned int m_GreenIdx;
unsigned int m_BlueIdx;
unsigned int m_CurrentResolution;
ResolutionVectorType m_AvailableResolutions;
PointType m_Origin;
SpacingType m_Spacing;
RegionType m_LargestRegion;
unsigned int m_NumberOfComponents;
ImageSettings::Pointer m_ImageSettings;
FragmentShader::Pointer m_Shader;
RSTransformType::Pointer m_ViewportToImageTransform;
RSTransformType::Pointer m_ImageToViewportTransform;
RigidTransformType::Pointer m_ViewportForwardRotationTransform;
RigidTransformType::Pointer m_ViewportBackwardRotationTransform;
ResolutionAlgorithm::type m_ResolutionAlgorithm;
bool m_SoftwareRendering;
}; // End class GlImageActor
} // End namespace otb
#endif
|