RayZaler 0.1
The free opto-mechanical simulation framework
Scatter.h
1//
2// Copyright (c) 2024 Gonzalo José Carracedo Carballal
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU Lesser General Public License as
6// published by the Free Software Foundation, either version 3 of the
7// License, or (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful, but
10// WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU Lesser General Public License for more details.
13//
14// You should have received a copy of the GNU Lesser General Public
15// License along with this program. If not, see
16// <http://www.gnu.org/licenses/>
17//
18
19#ifndef _DATA_PRODUCTS_SCATTER_H
20#define _DATA_PRODUCTS_SCATTER_H
21
22#include <DataProduct.h>
23#include <pthread.h>
24#include <list>
25#include <Vector.h>
26#include <vector>
27#include <cstdint>
28
29namespace RZ {
30 class ScatterTree;
31 class ScatterTreeRenderer;
32 struct OpticalSurface;
33
34 class ScatterSet {
35 std::string m_label = "No name";
36 ScatterTree *m_tree = nullptr; // Owned
37 uint32_t m_id = 0;
38 size_t m_size;
39 bool m_built = false;
40
41 public:
42 ScatterSet(uint32_t id, OpticalSurface const *, std::string const &label = "");
43 ScatterSet(uint32_t id, std::vector<Real> const &, std::string const &label = "", unsigned stride = 2);
44 ScatterSet(uint32_t id, std::vector<Real> &, std::string const &label = "", unsigned stride = 2, bool transfer = false);
45
47
48 void rebuild();
49 void render(ScatterTreeRenderer *) const;
50 std::string const &label() const;
51
52 size_t size() const;
53 uint32_t id() const;
54 };
55
57 std::list<ScatterSet *> m_setList;
58 unsigned int m_idCount = 0;
59 size_t m_points = 0;
60 mutable pthread_mutex_t m_lock;
61 bool m_haveLock = false;
62
63 public:
64 ScatterDataProduct(std::string const &);
65 virtual ~ScatterDataProduct() override;
66
67 virtual void clear() override;
68 virtual void build() override;
69 virtual std::string productType() const override;
70 virtual bool saveToFile(std::string const &path) const override;
71
72 size_t points() const;
73 void render(ScatterTreeRenderer *) const;
74 size_t size() const;
75 void addSurface(OpticalSurface const *, std::string const &label = "");
76 void addSurface(uint32_t id, OpticalSurface const *, std::string const &label = "");
77 void addSet(ScatterSet *);
78
79 std::list<ScatterSet *> const &dataSets() const;
80 };
81};
82
83#endif // _DATA_PRODUCTS_SCATTER_H
Definition: DataProduct.h:25
Definition: Scatter.h:56
Definition: Scatter.h:34
Definition: ScatterTree.h:86
Definition: ScatterTree.h:74
Definition: OpticalElement.h:33