| [fea945] | 1 | /* | 
|---|
|  | 2 | * LinkedCell_Controller.hpp | 
|---|
|  | 3 | * | 
|---|
|  | 4 | *  Created on: Nov 15, 2011 | 
|---|
|  | 5 | *      Author: heber | 
|---|
|  | 6 | */ | 
|---|
|  | 7 |  | 
|---|
|  | 8 | #ifndef LINKEDCELL_CONTROLLER_HPP_ | 
|---|
|  | 9 | #define LINKEDCELL_CONTROLLER_HPP_ | 
|---|
|  | 10 |  | 
|---|
|  | 11 | // include config.h | 
|---|
|  | 12 | #ifdef HAVE_CONFIG_H | 
|---|
|  | 13 | #include <config.h> | 
|---|
|  | 14 | #endif | 
|---|
|  | 15 |  | 
|---|
|  | 16 | #include <map> | 
|---|
|  | 17 |  | 
|---|
| [4a8169] | 18 | #include "CodePatterns/Observer/Observer.hpp" | 
|---|
| [fe8253] | 19 | #include "CodePatterns/Range.hpp" | 
|---|
| [fea945] | 20 | #include "LinkedCell/LinkedCell_View.hpp" | 
|---|
|  | 21 |  | 
|---|
| [fe8253] | 22 | class LinkedCell_ControllerTest; | 
|---|
| [c80643] | 23 | class IPointCloud; | 
|---|
| [fe8253] | 24 |  | 
|---|
| [fea945] | 25 | namespace LinkedCell { | 
|---|
|  | 26 |  | 
|---|
|  | 27 | class LinkedCell_Model; | 
|---|
|  | 28 |  | 
|---|
|  | 29 | /** This is the controller in the MVC ansatz for the LinkedCell structure. | 
|---|
|  | 30 | * | 
|---|
|  | 31 | * \sa linkedcell | 
|---|
|  | 32 | * | 
|---|
|  | 33 | * The Controller contains multiple models (i.e. LinkedCell instances) and he | 
|---|
|  | 34 | * takes care that the view (the interface) can give its functionality with | 
|---|
|  | 35 | * low computational complexity. | 
|---|
|  | 36 | * | 
|---|
| [fe8253] | 37 | * Here, it contains multiple LinkedCell models, each with different edge | 
|---|
|  | 38 | * lengths of the inherent mesh. You request a LinkedCell instance from the | 
|---|
|  | 39 | * controller, but you basically just receive a const interface reference | 
|---|
| [fea945] | 40 | * to a present LinkedCell instance. | 
|---|
|  | 41 | * | 
|---|
|  | 42 | */ | 
|---|
| [4a8169] | 43 | class LinkedCell_Controller : public Observer | 
|---|
| [fea945] | 44 | { | 
|---|
| [fe8253] | 45 | //!> grant unit tests access to internal parts | 
|---|
|  | 46 | friend class ::LinkedCell_ControllerTest; | 
|---|
| [fea945] | 47 | public: | 
|---|
|  | 48 | LinkedCell_Controller(const Box &_domain); | 
|---|
|  | 49 | ~LinkedCell_Controller(); | 
|---|
|  | 50 |  | 
|---|
| [c80643] | 51 | LinkedCell_View getView(const double distance, IPointCloud &set); | 
|---|
| [fea945] | 52 |  | 
|---|
| [4a8169] | 53 | void update(Observable *publisher); | 
|---|
|  | 54 | void recieveNotification(Observable *publisher, Notification_ptr notification); | 
|---|
|  | 55 | void subjectKilled(Observable *publisher); | 
|---|
|  | 56 |  | 
|---|
| [fea945] | 57 | private: | 
|---|
|  | 58 | const LinkedCell_Model * getBestModel(const double distance) const; | 
|---|
| [fe8253] | 59 | const range<double> getHeuristicRange(const double distance) const; | 
|---|
| [455043] | 60 | void insertNewModel(const double edgelength, const LinkedCell_Model* instance); | 
|---|
| [ce81e76] | 61 | void updateModels(); | 
|---|
| [fea945] | 62 |  | 
|---|
|  | 63 | private: | 
|---|
|  | 64 | //!> typedef for the (edge length, model) map | 
|---|
| [455043] | 65 | typedef std::map<double, const LinkedCell_Model* > MapEdgelengthModel; | 
|---|
| [fea945] | 66 |  | 
|---|
|  | 67 | //!> internal map of present LinkedCell_Model instances by their egde length | 
|---|
|  | 68 | MapEdgelengthModel ModelsMap; | 
|---|
|  | 69 |  | 
|---|
| [fe8253] | 70 | //!> lower threshold below which no new instances are generated. | 
|---|
|  | 71 | static double lower_threshold; | 
|---|
|  | 72 |  | 
|---|
|  | 73 | //!> upper threshold above which no new instances are generated. | 
|---|
|  | 74 | static double upper_threshold; | 
|---|
|  | 75 |  | 
|---|
| [fea945] | 76 | //!> internal reference to domain required for constructing LinkedCell_Model instances. | 
|---|
|  | 77 | const Box &domain; | 
|---|
|  | 78 | }; | 
|---|
|  | 79 |  | 
|---|
|  | 80 | } | 
|---|
|  | 81 |  | 
|---|
|  | 82 | #endif /* LINKEDCELL_CONTROLLER_HPP_ */ | 
|---|