[an error occurred while processing this directive]
Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

hugin_base/algorithms/basic/CalculateOptimalScale.h

Go to the documentation of this file.
00001 // -*- c-basic-offset: 4 -*-
00027 #ifndef _BASICALGORITHMS_CALCULATEOPTIMALSCALE_H
00028 #define _BASICALGORITHMS_CALCULATEOPTIMALSCALE_H
00029 
00030 #include <hugin_shared.h>
00031 #include <algorithm/PanoramaAlgorithm.h>
00032 
00033 #include <panodata/PanoramaData.h>
00034 
00035 
00036 
00037 namespace HuginBase {
00038 
00039 
00040 class IMPEX CalculateOptimalScale : public PanoramaAlgorithm
00041 {
00042 
00043     public:
00045         CalculateOptimalScale(PanoramaData& panorama)
00046          : PanoramaAlgorithm(panorama)
00047         {}
00048         
00050         virtual ~CalculateOptimalScale()
00051         {}
00052         
00053         
00054     public:
00056         virtual bool modifiesPanoramaData() const
00057             { return false; }
00058             
00060         virtual bool runAlgorithm()
00061         {
00062             o_optimalScale =  calcOptimalScale(o_panorama);
00063             return true; // let's hope so.
00064         }
00065         
00066     public:
00068         static double calcOptimalScale(PanoramaData& panorama);
00069         
00073         static double calcOptimalPanoScale(const SrcPanoImage & src,
00074                                            const PanoramaOptions & dest);
00075         
00077         virtual double getResultOptimalScale()
00078         {
00079             // [TODO] if(!hasRunSuccessfully()) DEBUG;
00080             return o_optimalScale;
00081         }
00082         
00084         virtual unsigned getResultOptimalWidth()
00085         {
00086             // [TODO] if(!hasRunSuccessfully()) DEBUG;
00087             return hugin_utils::roundi(getResultOptimalScale() * o_panorama.getOptions().getWidth());
00088         }
00089         
00090     protected:
00091         double o_optimalScale;
00092         
00093 };
00094 
00095 
00096 class SetWidthOptimal : public CalculateOptimalScale
00097 {
00098     public:
00100         SetWidthOptimal(PanoramaData& panorama)
00101          : CalculateOptimalScale(panorama)
00102         {}
00103 
00105         virtual ~SetWidthOptimal()
00106         {}
00107     
00108     
00109     public:
00111         virtual bool modifiesPanoramaData() const
00112             { return true; }
00113         
00115         virtual bool runAlgorithm()
00116         {
00117             bool success = CalculateOptimalScale::runAlgorithm();
00118             if(success)
00119             {
00120                 PanoramaOptions opts = o_panorama.getOptions();
00121                 opts.setWidth(getResultOptimalWidth());
00122                 o_panorama.setOptions(opts);
00123             }
00124             return success;
00125         }
00126 };
00127 
00128 
00129 } //namespace
00130 #endif

Generated on Mon Sep 20 01:01:26 2010 for Hugintrunk by doxygen 1.3.9.1