1 // This is core/vcsl/vcsl_scale.h
2 #ifndef vcsl_scale_h_
3 #define vcsl_scale_h_
4 //:
5 // \file
6 // \brief Scale transformation
7 // \author Francois BERTEL
8 //
9 // \verbatim
10 //  Modifications
11 //   2000/07/19 Francois BERTEL Creation.
12 //   2001/04/10 Ian Scott (Manchester) Converted perceps header to doxygen
13 //   2002/01/22 Peter Vanroose - return type of execute() and inverse() changed to non-ptr
14 //   2002/01/28 Peter Vanroose - std::vector member scale_ changed to non-ptr
15 //   2004/09/17 Peter Vanroose - made scale() non-virtual - it just returns a member and should not be overloaded
16 // \endverbatim
17 
18 #include "vcsl_spatial_transformation.h"
19 #include "vcsl_scale_sptr.h"
20 
21 //: Scale transformation
22 class vcsl_scale
23   : public vcsl_spatial_transformation
24 {
25  public:
26   //***************************************************************************
27   // Constructors/Destructor
28   //***************************************************************************
29 
30   // Default constructor
31   vcsl_scale() = default;
32 
33   // Destructor
34   ~vcsl_scale() override = default;
35 
36   //***************************************************************************
37   // Status report
38   //***************************************************************************
39 
40   //: Is `this' invertible at time `time'?
41   //  REQUIRE: valid_time(time)
42   // Pure virtual function of vcsl_spatial_transformation
43   bool is_invertible(double time) const override;
44 
45   //: Is `this' correctly set ?
46   // Virtual function of vcsl_spatial_transformation
is_valid()47   bool is_valid() const override
48   { return vcsl_spatial_transformation::is_valid() &&
49            ((this->duration()==0&&scale_.size()==1) ||
50              this->duration()==scale_.size()); }
51 
52   //***************************************************************************
53   // Transformation parameters
54   //***************************************************************************
55 
56   //: Set the scale value of a static scale
57   void set_static(double new_scale);
58 
59   //: Set the scale variation along the time
set_scale(std::vector<double> const & new_scale)60   void set_scale(std::vector<double> const& new_scale) { scale_=new_scale; }
61 
62   //: Return the scale variation along the time
scale()63   std::vector<double> scale() const { return scale_; }
64 
65   //***************************************************************************
66   // Basic operations
67   //***************************************************************************
68 
69   //: Image of `v' by `this'
70   //  REQUIRE: is_valid()
71   // Pure virtual function of vcsl_spatial_transformation
72   vnl_vector<double> execute(const vnl_vector<double> &v,
73                                      double time) const override;
74 
75   //: Image of `v' by the inverse of `this'
76   //  REQUIRE: is_valid()
77   //  REQUIRE: is_invertible(time)
78   // Pure virtual function of vcsl_spatial_transformation
79   vnl_vector<double> inverse(const vnl_vector<double> &v,
80                                      double time) const override;
81 
82  protected:
83 
84   //: Compute the value of the parameter at time `time'
85   double scale_value(double time) const;
86 
87   //: Scale variation along the time
88   std::vector<double> scale_;
89 };
90 
91 #endif // vcsl_scale_h_
92