1 /**************************************************************************/
2 /*  Copyright 2012 Tim Day                                                */
3 /*                                                                        */
4 /*  This file is part of Evolvotron                                       */
5 /*                                                                        */
6 /*  Evolvotron is free software: you can redistribute it and/or modify    */
7 /*  it under the terms of the GNU General Public License as published by  */
8 /*  the Free Software Foundation, either version 3 of the License, or     */
9 /*  (at your option) any later version.                                   */
10 /*                                                                        */
11 /*  Evolvotron is distributed in the hope that it will be useful,         */
12 /*  but WITHOUT ANY WARRANTY; without even the implied warranty of        */
13 /*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         */
14 /*  GNU General Public License for more details.                          */
15 /*                                                                        */
16 /*  You should have received a copy of the GNU General Public License     */
17 /*  along with Evolvotron.  If not, see <http://www.gnu.org/licenses/>.   */
18 /**************************************************************************/
19 
20 /*! \file
21   \brief Interfaces for class FunctionTop
22   This class would normally live in functions.h (and is included and registered there),
23   but is split out so it can be efficiently used by MutatableImageDisplay and EvolvotronMain.
24   NB There is no class heirarchy here as all virtualisation and boilerplate services are supplied when the functions are plugged into the FunctionNode template
25 */
26 
27 #ifndef _function_top_h_
28 #define _function_top_h_
29 
30 #include "common.h"
31 
32 #include "function_boilerplate.h"
33 
34 class Transform;
35 
36 //! Function intended primarily to be the top level function node.
37 /*! First 12 parameters are a space transform, second 12 paramters are a colour space transform.
38 */
39 FUNCTION_BEGIN(FunctionTop,24,1,false,0)
40 
41 public:
42   //! This returns a random tree suitable for use as a starting image.
43   static std::unique_ptr<FunctionTop> initial(const MutationParameters& parameters,const FunctionRegistration* specific_fn=0,bool unwrapped=false);
44 
45   virtual const XYZ evaluate(const XYZ& p) const;
46 
is_a_FunctionTop()47   virtual FunctionTop* is_a_FunctionTop()
48   {
49       return this;
50   }
51 
is_a_FunctionTop()52   virtual const FunctionTop* is_a_FunctionTop() const
53   {
54       return this;
55   }
56 
57   //! Overridden so transform and colours don't keep changing
58   virtual void mutate(const MutationParameters& parameters,bool mutate_own_parameters=true);
59 
60   virtual void concatenate_pretransform_on_right(const Transform& transform);
61 
62   virtual void mutate_pretransform_parameters(const MutationParameters& parameters);
63   virtual void reset_pretransform_parameters(const MutationParameters& parameters);
64   virtual void mutate_posttransform_parameters(const MutationParameters& parameters);
65   virtual void reset_posttransform_parameters(const MutationParameters& parameters);
66 
67 private:
68 
69   const Transform interesting_pretransform(const MutationParameters& parameters,const real k);
70 
71 FUNCTION_END(FunctionTop)
72 
73 #endif
74