FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
mesh_atlas.hpp
1// FEAT3: Finite Element Analysis Toolbox, Version 3
2// Copyright (C) 2010 by Stefan Turek & the FEAT group
3// FEAT3 is released under the GNU General Public License version 3,
4// see the file 'copyright.txt' in the top level directory for details.
5
6#pragma once
7
8// includes, FEAT
9#include <kernel/geometry/conformal_mesh.hpp>
10#include <kernel/geometry/mesh_part.hpp>
11#include <kernel/geometry/atlas/chart.hpp>
12
13// includes, system
14#include <map>
15#include <deque>
16#include <memory>
17
18namespace FEAT
19{
20 namespace Geometry
21 {
30 template<typename Mesh_>
32 {
33 public:
35 typedef Mesh_ MeshType;
39 typedef typename MeshType::VertexType VertexType;
40
41 protected:
43 typedef std::map<String, std::unique_ptr<MeshChartType>> MeshChartMap;
44
47
48 public:
51 {
52 }
53
56
59
61 MeshAtlas(const MeshAtlas&) = delete;
62
64 MeshAtlas& operator=(const MeshAtlas&) = delete;
65
67 virtual ~MeshAtlas()
68 {
69 // map and unique_ptr take care of cleanup
70 }
71
78 static std::unique_ptr<MeshAtlas> make_unique()
79 {
80 return std::unique_ptr<MeshAtlas>(new MeshAtlas());
81 }
82
84 std::size_t bytes() const
85 {
86 std::size_t s(0);
87 for(auto it = _chart_map.begin(); it != _chart_map.end(); ++it)
88 s += it->second->bytes();
89 return s;
90 }
91
109 bool add_mesh_chart(const String& name, std::unique_ptr<MeshChartType> chart, bool replace = false)
110 {
111 // try to insert
112 // note: unique_ptr needs to be moved here, otherwise emplace tries to copy instead
113 auto it = _chart_map.emplace(name, std::move(chart));
114
115 // insertion successful?
116 if(it.second)
117 return true;
118
119 // a chart with that name already exists. replace?
120 if(!replace)
121 return false;
122
123 // assign new chart
124 it.first->second = std::move(chart);
125 return true;
126 }
127
131 std::deque<String> get_chart_names() const
132 {
133 std::deque<String> names;
134 for(auto it = _chart_map.begin(); it != _chart_map.end(); ++it)
135 {
136 names.push_back((*it).first);
137 }
138 return names;
139 }
140
147 {
148 return _chart_map;
149 }
150
163 {
164 auto it = _chart_map.find(name);
165 if(it == _chart_map.end())
166 return nullptr;
167 return (*it).second.get();
168 }
169
171 const MeshChartType* find_mesh_chart(const String& name) const
172 {
173 auto it = _chart_map.find(name);
174 if(it == _chart_map.end())
175 return nullptr;
176 return (*it).second.get();
177 }
178
205 void transform(const VertexType& origin, const VertexType& angles, const VertexType& offset)
206 {
207 // transform all charts
208 for(auto it = _chart_map.begin(); it != _chart_map.end(); ++it)
209 it->second->transform(origin, angles, offset);
210 }
211 }; // class MeshAltas<...>
212 } // namespace Geometry
213} // namespace FEAT
Mesh Atlas class template.
Definition: mesh_atlas.hpp:32
MeshAtlas & operator=(const MeshAtlas &)=delete
deleted copy-assignment operator
MeshAtlas(MeshAtlas &&other)=default
move CTOR
const MeshChartType * find_mesh_chart(const String &name) const
Searches for a mesh chart.
Definition: mesh_atlas.hpp:171
MeshChartType * find_mesh_chart(const String &name)
Searches for a mesh chart.
Definition: mesh_atlas.hpp:162
MeshChartMap _chart_map
our chart map
Definition: mesh_atlas.hpp:46
Atlas::ChartBase< MeshType > MeshChartType
our chart base-class type
Definition: mesh_atlas.hpp:37
std::deque< String > get_chart_names() const
Returns the names of all charts of this atlas.
Definition: mesh_atlas.hpp:131
bool add_mesh_chart(const String &name, std::unique_ptr< MeshChartType > chart, bool replace=false)
Inserts a new chart into the map.
Definition: mesh_atlas.hpp:109
MeshAtlas & operator=(MeshAtlas &&other)=default
move-assignment operator
void transform(const VertexType &origin, const VertexType &angles, const VertexType &offset)
Applies a "proper rigid" transformation onto the atlas.
Definition: mesh_atlas.hpp:205
MeshType::VertexType VertexType
our vertex type (aka world point type)
Definition: mesh_atlas.hpp:39
Mesh_ MeshType
our mesh type
Definition: mesh_atlas.hpp:35
const MeshChartMap & get_mesh_chart_map() const
Returns a const reference to the chart map.
Definition: mesh_atlas.hpp:146
static std::unique_ptr< MeshAtlas > make_unique()
Creates a new MeshAtlas on the heap and returns a unique pointer to it.
Definition: mesh_atlas.hpp:78
MeshAtlas(const MeshAtlas &)=delete
deleted copy CTOR
std::map< String, std::unique_ptr< MeshChartType > > MeshChartMap
our chart map type
Definition: mesh_atlas.hpp:43
std::size_t bytes() const
Definition: mesh_atlas.hpp:84
virtual ~MeshAtlas()
virtual DTOR
Definition: mesh_atlas.hpp:67
String class implementation.
Definition: string.hpp:46
@ other
generic/other permutation strategy
FEAT namespace.
Definition: adjactor.hpp:12