All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
IdlBand.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/idl/IdlBand.cpp
22 
23  \brief A adaptor to an external existent raster in a idl array form.
24 */
25 
26 // TerraLib
27 #include "IdlBand.h"
28 #include "Exception.h"
29 #include "../raster/BandProperty.h"
30 #include "../raster/Utils.h"
31 
32 #include <cstring>
33 
35  const void* allBandsDataPtr, std::size_t idx, int dataType,
36  const unsigned int nBands, const unsigned int nLines, const unsigned int nCols )
37 : te::rst::Band( new te::rst::BandProperty( idx, dataType, "" ), idx )
38 {
39  m_property->m_blkh = nLines;
40  m_property->m_blkw = nCols;
44 
45  m_allBandsDataPtr = (void*)allBandsDataPtr;
46  m_nLines = nLines;
47  m_nCols = nCols;
48  m_nBands = nBands;
49 
51  dataType );
52 }
53 
55 : te::rst::Band( new te::rst::BandProperty( 0, 0 ), 0 )
56 {
57  throw te::idl::Exception( "Not implemented" );
58 }
59 
61 : te::rst::Band( new te::rst::BandProperty( 0, 0 ), 0 )
62 {
63  throw te::idl::Exception( "Not implemented" );
64 }
65 
67 {
68 }
69 
70 void te::idl::IdlBand::getValue(unsigned int c, unsigned int r, double& value) const
71 {
72  m_bufferOffset = m_nBands * ( ( m_nCols * r ) + c ) + m_idx;
73  m_getBuff(m_bufferOffset, m_allBandsDataPtr, &value );
74 }
75 
76 void te::idl::IdlBand::setValue(unsigned int c, unsigned int r, const double value)
77 {
78  m_bufferOffset = m_nBands * ( ( m_nCols * r ) + c ) + m_idx;
79  m_setBuff(m_bufferOffset, m_allBandsDataPtr, &value );
80 }
81 
82 void te::idl::IdlBand::getIValue(unsigned int c, unsigned int r, double& value) const
83 {
84  m_bufferOffset = m_nBands * ( ( m_nCols * r ) + c ) + m_idx;
85  m_getBuffI(m_bufferOffset, m_allBandsDataPtr, &value );
86 }
87 
88 void te::idl::IdlBand::setIValue(unsigned int c, unsigned int r, const double value)
89 {
90  m_bufferOffset = m_nBands * ( ( m_nCols * r ) + c ) + m_idx;
91  m_setBuffI(m_bufferOffset, m_allBandsDataPtr, &value );
92 }
93 
94 void te::idl::IdlBand::read(int x, int y, void* buffer) const
95 {
96  assert( x == 0 );
97  assert( y == 0 );
98  memcpy( buffer, m_allBandsDataPtr, te::rst::GetPixelSize( m_property->m_type ) *
99  m_nLines * m_nCols * m_nBands );
100 }
101 
102 void te::idl::IdlBand::write(int x, int y, void* buffer)
103 {
104  assert( x == 0 );
105  assert( y == 0 );
106  memcpy( m_allBandsDataPtr, buffer, te::rst::GetPixelSize( m_property->m_type ) *
107  m_nLines * m_nCols * m_nBands );
108 }
109 
110 
111 
112 
void getValue(unsigned int c, unsigned int r, double &value) const
Returns the cell attribute value.
Definition: IdlBand.cpp:70
A adaptor to an external existent raster in a idl array form.
Index into a lookup table.
Definition: Enums.h:57
te::rst::SetBufferValueFPtr m_setBuffI
A pointer to a function that helps to insert the imaginary part value into a specific buffer data typ...
Definition: IdlBand.h:115
unsigned int m_nLines
The parent raster number of lines.
Definition: IdlBand.h:106
int m_nblocksx
The number of blocks in x.
Definition: BandProperty.h:145
int m_nblocksy
The number of blocks in y.
Definition: BandProperty.h:146
te::rst::GetBufferValueFPtr m_getBuff
A pointer to a function that helps to extract a double or complex value from a specific buffer data t...
Definition: IdlBand.h:112
unsigned int m_nBands
The parent raster number of bands.
Definition: IdlBand.h:110
void write(int x, int y, void *buffer)
It writes a data block from the specified buffer.
Definition: IdlBand.cpp:102
An abstract class for raster data strucutures.
Definition: Raster.h:71
unsigned int m_nCols
The parent raster number of columns.
Definition: IdlBand.h:108
A adaptor to an external existent raster in a idl array form.
Definition: IdlBand.h:51
int m_blkw
Block width (pixels).
Definition: BandProperty.h:143
void setIValue(unsigned int c, unsigned int r, const double value)
Sets the imaginary attribute value in a complex band of a cell.
Definition: IdlBand.cpp:88
void * m_allBandsDataPtr
Data buffer pointer.
Definition: IdlBand.h:104
void read(int x, int y, void *buffer) const
It reads a data block to the specified buffer.
Definition: IdlBand.cpp:94
Exception class.
void setValue(unsigned int c, unsigned int r, const double value)
Sets the cell attribute value.
Definition: IdlBand.cpp:76
TERASTEREXPORT int GetPixelSize(int datatype)
Returns the byte size of a given datatype.
Definition: Utils.cpp:80
te::rst::GetBufferValueFPtr m_getBuffI
A pointer to a function that helps to extract the imaginary part value from a specific buffer data ty...
Definition: IdlBand.h:113
void getIValue(unsigned int c, unsigned int r, double &value) const
Returns the imaginary attribute value in a complex band of a cell.
Definition: IdlBand.cpp:82
int m_blkh
Block height (pixels).
Definition: BandProperty.h:144
ColorInterp m_colorInterp
The color interpretation.
Definition: BandProperty.h:140
TERASTEREXPORT void SetBlockFunctions(GetBufferValueFPtr *gb, GetBufferValueFPtr *gbi, SetBufferValueFPtr *sb, SetBufferValueFPtr *sbi, int type)
Sets the pointers to functions that helps to extract a double or complex value from a specific buffer...
Definition: BlockUtils.cpp:295
BandProperty * m_property
The band information.
Definition: Band.h:474
te::rst::SetBufferValueFPtr m_setBuff
A pointer to a function that helps to insert a double or complex value into a specific buffer data ty...
Definition: IdlBand.h:114