View on GitHub

Vistle

Distributed Data-parallel Scientific Visualization in VR

renderer.h
Go to the documentation of this file.
1#ifndef RENDERER_H
2#define RENDERER_H
3
5#include <vistle/util/enum.h>
6#include "renderobject.h"
7#include "export.h"
8
9namespace vistle {
10
11DEFINE_ENUM_WITH_STRING_CONVERSIONS(RenderMode, (LocalOnly)(MasterOnly)(AllRanks)(LocalShmLeader)(AllShmLeaders))
12
13class V_RENDEREREXPORT Renderer: public Module {
14public:
15 Renderer(const std::string &name, const int moduleID, mpi::communicator comm);
16 virtual ~Renderer();
17
18 bool dispatch(bool block = true, bool *messageReceived = nullptr) override;
19
20 int numTimesteps() const;
21 void getBounds(Vector3 &min, Vector3 &max);
22 void getBounds(Vector3 &min, Vector3 &max, int time);
23
24 struct Variant {
25 friend class boost::serialization::access;
26
27 Variant(const std::string &name = std::string()): name(name) {}
28
29 std::string name;
30 int objectCount = 0;
31 RenderObject::InitialVariantVisibility visible = RenderObject::DontChange;
32 };
33 typedef std::map<std::string, Variant> VariantMap;
34 const VariantMap &variants() const;
35
36 struct ColorMap {
37 int sender = vistle::message::Id::Invalid;
38 std::string senderPort;
40 };
41
42 typedef std::map<std::string, ColorMap> ColorMapMap;
43
44protected:
45 bool handleMessage(const message::Message *message, const MessagePayload &payload) override;
46
47 virtual bool addColorMap(const std::string &species, Texture1D::const_ptr texture);
48 virtual bool removeColorMap(const std::string &species);
49
50 virtual std::shared_ptr<RenderObject> addObject(int senderId, const std::string &senderPort,
52 Object::const_ptr normal, Object::const_ptr texture) = 0;
53 virtual void removeObject(std::shared_ptr<RenderObject> ro);
54
55 bool changeParameter(const Parameter *p) override;
56 bool compute() override; // provide dummy implementation of Module::compute
57 void connectionRemoved(const Port *from, const Port *to) override;
58
59 int m_fastestObjectReceivePolicy;
60 void removeAllObjects();
61
62 bool m_maySleep = true;
63
64private:
65 virtual bool render() = 0;
66
67 bool handleAddObject(const message::AddObject &add);
68
69 bool addInputObject(int sender, const std::string &senderPort, const std::string &portName,
70 vistle::Object::const_ptr object) override;
71 std::shared_ptr<RenderObject> addObjectWrapper(int senderId, const std::string &senderPort,
73 Object::const_ptr normal, Object::const_ptr texture);
74 void removeObjectWrapper(std::shared_ptr<RenderObject> ro);
75
76 void removeAllSentBy(int sender, const std::string &senderPort);
77
78 struct Creator {
79 Creator(int id, const std::string &port, const std::string &basename)
80 : module(id), port(port), age(0), iteration(-1)
81 {
82 std::stringstream s;
83 s << basename << "_" << module;
84 name = s.str();
85 }
86 bool operator<(const Creator &other) const
87 {
88 if (module == other.module)
89 return port < other.port;
90 return module < other.module;
91 }
92 bool operator==(const Creator &other) const
93 {
94 if (module == other.module)
95 return port == other.port;
96 return false;
97 }
98
99 int module;
100 std::string port;
101 mutable int age = 0;
102 mutable int iteration = -1;
103 std::string name;
104 };
105 typedef std::set<Creator> CreatorMap;
106 CreatorMap m_creatorMap;
107
108 std::vector<std::vector<std::shared_ptr<RenderObject>>> m_objectList;
109 IntParameter *m_renderMode = nullptr;
110 IntParameter *m_objectsPerFrame = nullptr;
111 bool needsSync(const message::Message &m) const;
112
113 VariantMap m_variants;
114 ColorMapMap m_colormaps;
115
116 int m_numObjectsPerFrame = 500;
117};
118
119} // namespace vistle
120
121#endif
std::shared_ptr< const Object > const_ptr
std::string module(const std::string &prefix)
Eigen::Matrix< Scalar, 3, 1 > Vector3
ShmVector< char > MessagePayload
bool operator<(const ParameterVector< S > &v1, const ParameterVector< S > &v2)
bool operator==(const ParameterVector< S > &v1, const ParameterVector< S > &v2)
DEFINE_ENUM_WITH_STRING_CONVERSIONS(FieldCompressionMode,(Uncompressed)(ZfpFixedRate)(ZfpAccuracy)(ZfpPrecision)) namespace detail