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 |
|
---|
18 | #include "CodePatterns/Observer/Observer.hpp"
|
---|
19 | #include "CodePatterns/Range.hpp"
|
---|
20 | #include "LinkedCell/LinkedCell_View.hpp"
|
---|
21 |
|
---|
22 | class LinkedCell_ControllerTest;
|
---|
23 | class IPointCloud;
|
---|
24 |
|
---|
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 | *
|
---|
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
|
---|
40 | * to a present LinkedCell instance.
|
---|
41 | *
|
---|
42 | */
|
---|
43 | class LinkedCell_Controller : public Observer
|
---|
44 | {
|
---|
45 | //!> grant unit tests access to internal parts
|
---|
46 | friend class ::LinkedCell_ControllerTest;
|
---|
47 | public:
|
---|
48 | LinkedCell_Controller(const Box &_domain);
|
---|
49 | ~LinkedCell_Controller();
|
---|
50 |
|
---|
51 | LinkedCell_View getView(const double distance, IPointCloud &set);
|
---|
52 |
|
---|
53 | void update(Observable *publisher);
|
---|
54 | void recieveNotification(Observable *publisher, Notification_ptr notification);
|
---|
55 | void subjectKilled(Observable *publisher);
|
---|
56 |
|
---|
57 | private:
|
---|
58 | const LinkedCell_Model * getBestModel(const double distance) const;
|
---|
59 | const range<double> getHeuristicRange(const double distance) const;
|
---|
60 | void insertNewModel(const double edgelength, const LinkedCell_Model* instance);
|
---|
61 | void updateModels();
|
---|
62 |
|
---|
63 | double getMinimumSensibleLength(double distance) const;
|
---|
64 |
|
---|
65 | private:
|
---|
66 | //!> typedef for the (edge length, model) map
|
---|
67 | typedef std::map<double, const LinkedCell_Model* > MapEdgelengthModel;
|
---|
68 |
|
---|
69 | //!> internal map of present LinkedCell_Model instances by their egde length
|
---|
70 | MapEdgelengthModel ModelsMap;
|
---|
71 |
|
---|
72 | //!> lower threshold below which no new instances are generated.
|
---|
73 | static double lower_threshold;
|
---|
74 |
|
---|
75 | //!> upper threshold above which no new instances are generated.
|
---|
76 | static double upper_threshold;
|
---|
77 |
|
---|
78 | //!> internal reference to domain required for constructing LinkedCell_Model instances.
|
---|
79 | const Box &domain;
|
---|
80 | };
|
---|
81 |
|
---|
82 | }
|
---|
83 |
|
---|
84 | #endif /* LINKEDCELL_CONTROLLER_HPP_ */
|
---|