PLaSK library

Loading...
Searching...
No Matches
utils.hpp
Go to the documentation of this file.
1/*
2 * This file is part of PLaSK (https://plask.app) by Photonics Group at TUL
3 * Copyright (c) 2022 Lodz University of Technology
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 3.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14#ifndef PLASK__GEOMETRY_UTILS_H
15#define PLASK__GEOMETRY_UTILS_H
16
17#include "object.hpp"
18
23 namespace plask {
24
25//TODO at the moment, this template is not used, consider to remove it
29 template <int dims>
30 struct PLASK_API BoundingBoxCache {
31
32 typedef typename Primitive<dims>::Box BoundingBoxT;
33
34 private:
35
37 boost::signals2::connection connection_with_object;
38
40 BoundingBoxT boundingBox;
41
42 GeometryObjectD<dims>* object;
43
44 bool isFresh;
45
46 void connect();
47
48 public:
49
55 const BoundingBoxT& operator()();
56
61 void onObjectChanged(const GeometryObject::Event& evt);
62
67 void setObject(GeometryObjectD<dims>* object);
68
73 void setObject(GeometryObjectD<dims>& object) {
74 setObject(&object);
75 }
76
81 void setObject(shared_ptr<GeometryObjectD<dims> > object) {
82 setObject(*object);
83 }
84
89 GeometryObjectD<dims>* getObject() const {
90 return object;
91 }
92
97 BoundingBoxCache(GeometryObjectD<dims>* object = 0): object(object), isFresh(false) {
98 connect();
99 }
100
105 BoundingBoxCache(GeometryObjectD<dims>& object): object(&object), isFresh(false) {
106 connect();
107 }
108
113 BoundingBoxCache(shared_ptr< GeometryObjectD<dims> > object): object(object.get()), isFresh(false) {
114 connect();
115 }
116
117 ~BoundingBoxCache() {
118 connection_with_object.disconnect();
119 }
120
121};
122
123 PLASK_API_EXTERN_TEMPLATE_STRUCT(BoundingBoxCache<2>)
124 PLASK_API_EXTERN_TEMPLATE_STRUCT(BoundingBoxCache<3>)
125
126} // namespace plask
127
128#endif // PLASK__GEOMETRY_UTILS_H