Line | Branch | Exec | Source |
---|---|---|---|
1 | // This file is part of Bembel, the higher order C++ boundary element library. | ||
2 | // | ||
3 | // Copyright (C) 2024 see <http://www.bembel.eu> | ||
4 | // | ||
5 | // It was written as part of a cooperation of J. Doelz, H. Harbrecht, S. Kurz, | ||
6 | // M. Multerer, S. Schoeps, and F. Wolf at Technische Universitaet Darmstadt, | ||
7 | // Universitaet Basel, and Universita della Svizzera italiana, Lugano. This | ||
8 | // source code is subject to the GNU General Public License version 3 and | ||
9 | // provided WITHOUT ANY WARRANTY, see <http://www.bembel.eu> for further | ||
10 | // information. | ||
11 | #ifndef BEMBEL_SRC_GEOMETRY_GEOMETRY_HPP_ | ||
12 | #define BEMBEL_SRC_GEOMETRY_GEOMETRY_HPP_ | ||
13 | |||
14 | namespace Bembel { | ||
15 | /** | ||
16 | * \ingroup Geometry | ||
17 | * \brief this class wraps a GeometryVector and provides some basic | ||
18 | * functionality, like reading Geometry files | ||
19 | */ | ||
20 | class Geometry { | ||
21 | public: | ||
22 | ////////////////////////////////////////////////////////////////////////////// | ||
23 | // Constructors | ||
24 | ////////////////////////////////////////////////////////////////////////////// | ||
25 | /** | ||
26 | * \brief Default constructor. | ||
27 | */ | ||
28 | Geometry() {} | ||
29 | /** | ||
30 | * \brief Constructor. | ||
31 | * | ||
32 | * This constructor initializes a geometry specified in a given file. We can | ||
33 | * handle .dat and .igs at the moment. | ||
34 | * | ||
35 | * \param filename File name of the .dat or .igs file. | ||
36 | */ | ||
37 |
1/2✓ Branch 2 taken 27 times.
✗ Branch 3 not taken.
|
27 | explicit Geometry(const std::string &filename) { init_Geometry(filename); } |
38 | /** | ||
39 | * \brief Move constructor. | ||
40 | */ | ||
41 | Geometry(Geometry &&other) { geometry_ = std::move(other.geometry_); } | ||
42 | /** | ||
43 | * \brief Copy constructor. | ||
44 | * | ||
45 | * Though we are using a shared pointer, we are creating an actual copy here. | ||
46 | * might be useful if we want to modify the geometry object. | ||
47 | */ | ||
48 | Geometry(const Geometry &other) { | ||
49 | geometry_ = std::make_shared<PatchVector>(); | ||
50 | *geometry_ = *(other.geometry_); | ||
51 | } | ||
52 | /** | ||
53 | * \brief Copy constructor. | ||
54 | * | ||
55 | * Though we are using a shared pointer, we are creating an actual copy here. | ||
56 | * might be useful if we want to modify the geometry object. | ||
57 | * | ||
58 | * \param in Geometry provided as PatchVector. | ||
59 | */ | ||
60 | explicit Geometry(const PatchVector &in) { | ||
61 | geometry_ = std::make_shared<PatchVector>(); | ||
62 | *geometry_ = in; | ||
63 | } | ||
64 | /** | ||
65 | * \brief Copy assignment operator for the Geometry class. | ||
66 | * | ||
67 | * This copy assignment operator is explicitly deleted to prevent copying of | ||
68 | * Geometry objects. | ||
69 | * | ||
70 | * \return A reference to the updated Geometry object. | ||
71 | */ | ||
72 | Geometry &operator=(Geometry other) { | ||
73 | std::swap(geometry_, other.geometry_); | ||
74 | return *this; | ||
75 | } | ||
76 | ////////////////////////////////////////////////////////////////////////////// | ||
77 | // init_Geometry | ||
78 | ////////////////////////////////////////////////////////////////////////////// | ||
79 | /** | ||
80 | * \brief Initialize the geometry from a geometry given by a file. | ||
81 | * | ||
82 | * Note that the Shredder is required. The order of ansatz functions allows to | ||
83 | * be chosen higher than the smoothness of the NÙRBS mappings. Thus, we need | ||
84 | * to shredder the geometry mappings to have Bezier patches. You can achieve | ||
85 | * the higher regularity by changing coefficients in the projector. | ||
86 | * | ||
87 | * \param filename Filename of a .dat or .igs file. | ||
88 | */ | ||
89 | 27 | inline void init_Geometry(const std::string &filename) { | |
90 |
1/2✓ Branch 2 taken 27 times.
✗ Branch 3 not taken.
|
27 | std::string file_suffix = filename.substr(filename.find('.') + 1); |
91 | 27 | PatchVector tmp; | |
92 | |||
93 |
2/2✓ Branch 1 taken 26 times.
✓ Branch 2 taken 1 times.
|
27 | if (file_suffix.compare("dat") == 0) |
94 | 26 | tmp = PatchShredder(LoadGeometryFileDAT(filename)); | |
95 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | else if (file_suffix.compare("igs") == 0) |
96 | 1 | tmp = PatchShredder(LoadGeometryFileIGS(filename)); | |
97 | else | ||
98 | ✗ | assert(!"File type unknown!"); | |
99 | |||
100 |
1/2✓ Branch 1 taken 27 times.
✗ Branch 2 not taken.
|
27 | geometry_ = std::make_shared<PatchVector>(); |
101 |
1/2✓ Branch 2 taken 27 times.
✗ Branch 3 not taken.
|
27 | *geometry_ = tmp; |
102 | 27 | } | |
103 | ////////////////////////////////////////////////////////////////////////////// | ||
104 | // getters | ||
105 | ////////////////////////////////////////////////////////////////////////////// | ||
106 | /** | ||
107 | * \brief Return const reference to the geometry. | ||
108 | * | ||
109 | * \return Const reference to the PatchVector. | ||
110 | */ | ||
111 | const PatchVector &get_geometry() const { return *geometry_; } | ||
112 | /** | ||
113 | * \brief Return reference to the geometry. | ||
114 | * | ||
115 | * \return Reference to the PatchVector. | ||
116 | */ | ||
117 | 3280 | PatchVector &get_geometry() { return *geometry_; } | |
118 | /** | ||
119 | * \brief Return const pointer to the geometry. | ||
120 | * | ||
121 | * \return Const shared pointer to the PatchVector. | ||
122 | */ | ||
123 | 168 | const std::shared_ptr<PatchVector> get_geometry_ptr() const { | |
124 | 168 | return geometry_; | |
125 | } | ||
126 | /** | ||
127 | * \brief Return pointer to the geometry. | ||
128 | * | ||
129 | * \return Shared pointer to the PatchVector. | ||
130 | */ | ||
131 | std::shared_ptr<PatchVector> get_geometry_ptr() { return geometry_; } | ||
132 | |||
133 | /** | ||
134 | * \brief Get number of patches. | ||
135 | * | ||
136 | * \return Number of patches. | ||
137 | */ | ||
138 | int get_number_of_patches() const { return geometry_->size(); } | ||
139 | ////////////////////////////////////////////////////////////////////////////// | ||
140 | // private member variables | ||
141 | ////////////////////////////////////////////////////////////////////////////// | ||
142 | private: | ||
143 | std::shared_ptr<PatchVector> geometry_; | ||
144 | }; | ||
145 | } // namespace Bembel | ||
146 | #endif // BEMBEL_SRC_GEOMETRY_GEOMETRY_HPP_ | ||
147 |