Loading...
Searching...
No Matches
levelSetBooleanObject.hpp
1/*---------------------------------------------------------------------------*\
2 *
3 * bitpit
4 *
5 * Copyright (C) 2015-2021 OPTIMAD engineering Srl
6 *
7 * -------------------------------------------------------------------------
8 * License
9 * This file is part of bitpit.
10 *
11 * bitpit is free software: you can redistribute it and/or modify it
12 * under the terms of the GNU Lesser General Public License v3 (LGPL)
13 * as published by the Free Software Foundation.
14 *
15 * bitpit is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18 * License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with bitpit. If not, see <http://www.gnu.org/licenses/>.
22 *
23\*---------------------------------------------------------------------------*/
24
25# ifndef __BITPIT_LEVELSET_BOOLEAN_OBJECT_HPP__
26# define __BITPIT_LEVELSET_BOOLEAN_OBJECT_HPP__
27
28// Standard Template Library
29# include <array>
30# include <vector>
31
32# include "levelSetCommon.hpp"
33# include "levelSetProxyObject.hpp"
34
35namespace bitpit{
36
37class LevelSetObject ;
38
39namespace adaption{
40 struct Info;
41}
42
43template<typename SourceLevelSetObject>
45
46 private:
47 LevelSetBooleanOperation m_operation;
49 const SourceLevelSetObject *m_object;
50 int m_objectSign;
52 double m_value;
54 public:
56 LevelSetBooleanResult(LevelSetBooleanOperation operation, const SourceLevelSetObject *object, double value) ;
57
58 void update(const SourceLevelSetObject *object, double value) ;
59
60 const SourceLevelSetObject * getObject() const ;
61 int getObjectSign () const ;
62
63 double getValue() const ;
64
65};
66
67template<typename SourceLevelSetObject>
68class LevelSetBooleanBaseObject : public LevelSetProxyObject<SourceLevelSetObject, SourceLevelSetObject> {
69
70 private:
71 LevelSetBooleanOperation m_operation;
72 std::vector<const SourceLevelSetObject *> m_sourceObjects;
74 LevelSetBooleanOperation getBooleanOperation() const;
75
76 LevelSetBooleanResult<SourceLevelSetObject> computeBooleanResult( long, bool signedLevelSet ) const ;
77 LevelSetBooleanResult<SourceLevelSetObject> computeBooleanResult( const std::array<double,3> &coords, bool signedLevelSet ) const ;
78
79 protected:
80 LevelSetBooleanBaseObject(int, LevelSetBooleanOperation, const SourceLevelSetObject *, const SourceLevelSetObject *);
81 LevelSetBooleanBaseObject(int, LevelSetBooleanOperation, const std::vector<const SourceLevelSetObject *> &);
82
83 void replaceSourceObject(const SourceLevelSetObject *current, const SourceLevelSetObject *updated) override ;
84
85 void fillCellPropagatedSignCache() override;
86
87 short _evalCellSign(long id) const override;
88 double _evalCellValue(long id, bool signedLevelSet) const override;
89 std::array<double,3> _evalCellGradient(long id, bool signedLevelSet) const override;
90
91 double _evalValue(const std::array<double,3> &point, bool signedLevelSet) const override;
92 std::array<double,3> _evalGradient(const std::array<double,3> &point, bool signedLevelSet) const override;
93
94 public:
95 bool empty() const override;
96
97 const SourceLevelSetObject * getCellReferenceObject(long id) const override;
98
99 const SourceLevelSetObject * getReferenceObject(const std::array<double,3> &point) const override;
100
101 std::vector<const SourceLevelSetObject *> getSourceObjects() const override;
102
103protected:
104 template<typename data_t, typename function_t>
105 data_t _evalCellFunction(long id, bool signedLevelSet, const function_t &function) const;
106
107 template<typename data_t, typename function_t>
108 data_t _evalFunction(const std::array<double,3> &point, bool signedLevelSet, const function_t &function) const;
109
110};
111
112template<typename SourceLevelSetObject>
113class LevelSetBooleanObject : public LevelSetBooleanBaseObject<SourceLevelSetObject> {
114
115};
116
117template<>
119
120public:
122 LevelSetBooleanObject(int, LevelSetBooleanOperation, const std::vector<const LevelSetObject *> &);
123
124 LevelSetBooleanObject<LevelSetObject> * clone() const override;
125
126};
127
128// Typdefs for compatibility with older versions
130
131}
132
133#endif
Base class which deals with boolean operation between two LevelSetObjects.
std::vector< const SourceLevelSetObject * > getSourceObjects() const override
std::array< double, 3 > _evalGradient(const std::array< double, 3 > &point, bool signedLevelSet) const override
const SourceLevelSetObject * getCellReferenceObject(long id) const override
double _evalValue(const std::array< double, 3 > &point, bool signedLevelSet) const override
std::array< double, 3 > _evalCellGradient(long id, bool signedLevelSet) const override
LevelSetBooleanBaseObject(int, LevelSetBooleanOperation, const SourceLevelSetObject *, const SourceLevelSetObject *)
const SourceLevelSetObject * getReferenceObject(const std::array< double, 3 > &point) const override
data_t _evalCellFunction(long id, bool signedLevelSet, const function_t &function) const
short _evalCellSign(long id) const override
double _evalCellValue(long id, bool signedLevelSet) const override
data_t _evalFunction(const std::array< double, 3 > &point, bool signedLevelSet, const function_t &function) const
void replaceSourceObject(const SourceLevelSetObject *current, const SourceLevelSetObject *updated) override
Class which deals with boolean operation between two LevelSetObjects.
Allow to evaluate the result of a boolean operation between two LevelSetObjects.
void update(const SourceLevelSetObject *object, double value)
LevelSetBooleanResult(LevelSetBooleanOperation operation)
const SourceLevelSetObject * getObject() const
Interface class for all objects with respect to whom the levelset function may be computed.
Interface class for all objects, which depend on other LevelSetObjects.
--- layout: doxygen_footer ---