All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SegmenterDummyStrategy.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2001-2009 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/rp/SegmenterDummyStrategy.cpp
22  \briefRaster dummy strategy.
23 */
24 
25 #include "SegmenterDummyStrategy.h"
26 #include "../common/progress/TaskProgress.h"
27 
28 namespace
29 {
31  segmenterDummyStrategyFactoryInstance;
32 }
33 
34 namespace te
35 {
36  namespace rp
37  {
38 
40  {
41  }
42 
44  {
45  }
46 
48  SegmenterStrategyParameters const* const strategyParams )
49  throw( te::rp::Exception )
50  {
51  return true;
52  }
53 
55  {
56  }
57 
59  SegmenterIdsManager& segmenterIdsManager,
60  const te::rst::Raster&,
61  const std::vector< unsigned int >& inputRasterBands,
62  const std::vector< double >&,
63  const std::vector< double >&,
64  te::rst::Raster& outputRaster,
65  const unsigned int outputRasterBand,
66  const bool enableProgressInterface )
67  throw( te::rp::Exception )
68  {
70  segmenterIdsManager.getNewID();
71 
72  const unsigned int nLines = outputRaster.getNumberOfRows();
73  const unsigned int nCols = outputRaster.getNumberOfColumns();
74 
75  // Progress interface
76 
77  std::auto_ptr< te::common::TaskProgress > progressPtr;
78  if( enableProgressInterface )
79  {
80  progressPtr.reset( new te::common::TaskProgress );
81  progressPtr->setTotalSteps( nLines );
82  progressPtr->setMessage( "Segmentation" );
83  }
84 
85  unsigned int col = 0;
86 
87  for( unsigned int line = 0 ; line < nLines ; ++line )
88  {
89  for( col = 0 ; col < nCols ; ++col )
90  {
91  outputRaster.setValue( col, line, segmentId, outputRasterBand );
92  }
93 
94  if( enableProgressInterface )
95  {
96  if( ! progressPtr->isActive() )
97  {
98  return false;
99  }
100 
101  progressPtr->pulse();
102  }
103  }
104 
105  return true;
106  }
107 
109  const unsigned int bandsToProcess, const unsigned int pixelsNumber ) const
110  {
111  return (double)( sizeof(double) * bandsToProcess * pixelsNumber );
112  }
113 
115  {
116  return 10;
117  }
118 
120  : te::rp::SegmenterStrategyFactory( "Dummy" )
121  {
122  }
123 
125  {
126  }
127 
129  {
130  return new te::rp::SegmenterDummyStrategy();
131  }
132 
133  } // end namespace rp
134 } // end namespace te
135 
Segmenter segments IDs manager.
Dummy strategy (just for testing purposes).
bool initialize(SegmenterStrategyParameters const *const strategyParams)
Initialize the segmentation strategy.
This class can be used to inform the progress of a task.
Definition: TaskProgress.h:53
unsigned int getOptimalBlocksOverlapSize() const
Returns a optimal blocks overlap size (number of border pixels overlapped between blocks...
double getMemUsageEstimation(const unsigned int bandsToProcess, const unsigned int pixelsNumber) const
Returns a memory estimation (bytes).
Raster dummy segmenter strategy factory.
void reset()
Clear all internal allocated resources and go back to the initial not-initialized state...
Raster segmenter strategy factory base class.
An abstract class for raster data strucutures.
Definition: Raster.h:71
Raster segmenter strategy base class.
te::rp::SegmenterStrategy * build()
Concrete factories (derived from this one) must implement this method in order to create objects...
bool execute(SegmenterIdsManager &segmenterIdsManager, const te::rst::Raster &inputRaster, const std::vector< unsigned int > &inputRasterBands, const std::vector< double > &inputRasterGains, const std::vector< double > &inputRasterOffsets, te::rst::Raster &outputRaster, const unsigned int outputRasterBand, const bool enableProgressInterface)
Executes the segmentation strategy.
Dummy strategy (just for testing purposes).