Skip to content

Commit 8d48abf

Browse files
authored
rename trimesh_xt -> trimesh (#184)
And remove type alias. To be consitent with other grid classes in C++ API.
1 parent e0f7b25 commit 8d48abf

File tree

4 files changed

+39
-56
lines changed

4 files changed

+39
-56
lines changed

doc/source/api_cpp/grid.rst

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,22 +156,19 @@ Triangular mesh
156156

157157
Defined in ``fastscapelib/grid/trimesh.hpp``.
158158

159-
- :cpp:class:`~template\<class S, unsigned int N> fastscapelib::grid_inner_types\<trimesh_xt\<S, N>>`
160-
- :cpp:class:`~template\<class S, unsigned int N = 30> fastscapelib::trimesh_xt`
161-
- :cpp:type:`~fastscapelib::trimesh`
159+
- :cpp:class:`~template\<class S, unsigned int N> fastscapelib::grid_inner_types\<trimesh\<S, N>>`
160+
- :cpp:class:`~template\<class S, unsigned int N = 30> fastscapelib::trimesh`
162161

163162
|
164163
165-
.. doxygenstruct:: fastscapelib::grid_inner_types< trimesh_xt< S, N > >
164+
.. doxygenstruct:: fastscapelib::grid_inner_types< trimesh< S, N > >
166165
:members:
167166
:undoc-members:
168167

169-
.. doxygenclass:: fastscapelib::trimesh_xt
168+
.. doxygenclass:: fastscapelib::trimesh
170169
:members:
171170
:undoc-members:
172171

173-
.. doxygentypedef:: fastscapelib::trimesh
174-
175172
|
176173
177174
Healpix grid

include/fastscapelib/grid/trimesh.hpp

Lines changed: 29 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,13 @@ namespace fastscapelib
7878

7979

8080
template <class S, unsigned int N>
81-
class trimesh_xt;
81+
class trimesh;
8282

8383
/**
8484
* 2-d triangular mesh specialized types.
8585
*/
8686
template <class S, unsigned int N>
87-
struct grid_inner_types<trimesh_xt<S, N>>
87+
struct grid_inner_types<trimesh<S, N>>
8888
{
8989
static constexpr bool is_structured = false;
9090
static constexpr bool is_uniform = false;
@@ -107,11 +107,11 @@ namespace fastscapelib
107107
* @tparam S The xtensor container selector for data array members.
108108
* @tparam N The maximum number of node neighbors.
109109
*/
110-
template <class S, unsigned int N = 20>
111-
class trimesh_xt : public grid<trimesh_xt<S, N>>
110+
template <class S = xt_selector, unsigned int N = 20>
111+
class trimesh : public grid<trimesh<S, N>>
112112
{
113113
public:
114-
using self_type = trimesh_xt<S, N>;
114+
using self_type = trimesh<S, N>;
115115
using base_type = grid<self_type>;
116116

117117
using grid_data_type = typename base_type::grid_data_type;
@@ -133,13 +133,13 @@ namespace fastscapelib
133133
using nodes_status_map_type = typename std::map<size_type, node_status>;
134134
using nodes_status_array_type = fixed_shape_container_t<container_selector, node_status, 1>;
135135

136-
trimesh_xt(const points_type& points,
137-
const triangles_type& triangles,
138-
const nodes_status_map_type& nodes_status = {});
136+
trimesh(const points_type& points,
137+
const triangles_type& triangles,
138+
const nodes_status_map_type& nodes_status = {});
139139

140-
trimesh_xt(const points_type& points,
141-
const triangles_type& triangles,
142-
const nodes_status_array_type& nodes_status);
140+
trimesh(const points_type& points,
141+
const triangles_type& triangles,
142+
const nodes_status_array_type& nodes_status);
143143

144144
protected:
145145
using neighbors_distances_impl_type = typename base_type::neighbors_distances_impl_type;
@@ -195,9 +195,9 @@ namespace fastscapelib
195195
* by more than one triangle).
196196
*/
197197
template <class S, unsigned int N>
198-
trimesh_xt<S, N>::trimesh_xt(const points_type& points,
199-
const triangles_type& triangles,
200-
const nodes_status_map_type& nodes_status)
198+
trimesh<S, N>::trimesh(const points_type& points,
199+
const triangles_type& triangles,
200+
const nodes_status_map_type& nodes_status)
201201
: base_type(0)
202202
, m_nodes_points(points)
203203
{
@@ -215,9 +215,9 @@ namespace fastscapelib
215215
* @param nodes_status The status of all nodes on the mesh (array of shape [N]).
216216
*/
217217
template <class S, unsigned int N>
218-
trimesh_xt<S, N>::trimesh_xt(const points_type& points,
219-
const triangles_type& triangles,
220-
const nodes_status_array_type& nodes_status)
218+
trimesh<S, N>::trimesh(const points_type& points,
219+
const triangles_type& triangles,
220+
const nodes_status_array_type& nodes_status)
221221
: base_type(0)
222222
, m_nodes_points(points)
223223
{
@@ -229,8 +229,7 @@ namespace fastscapelib
229229
//@}
230230

231231
template <class S, unsigned int N>
232-
void trimesh_xt<S, N>::set_size_shape(const points_type& points,
233-
const triangles_type& triangles)
232+
void trimesh<S, N>::set_size_shape(const points_type& points, const triangles_type& triangles)
234233
{
235234
if (points.shape()[1] != 2)
236235
{
@@ -246,7 +245,7 @@ namespace fastscapelib
246245
}
247246

248247
template <class S, unsigned int N>
249-
void trimesh_xt<S, N>::set_neighbors(const points_type& points, const triangles_type& triangles)
248+
void trimesh<S, N>::set_neighbors(const points_type& points, const triangles_type& triangles)
250249
{
251250
// extract and count triangle edges
252251

@@ -306,8 +305,7 @@ namespace fastscapelib
306305
}
307306

308307
template <class S, unsigned int N>
309-
void trimesh_xt<S, N>::set_nodes_areas(const points_type& points,
310-
const triangles_type& triangles)
308+
void trimesh<S, N>::set_nodes_areas(const points_type& points, const triangles_type& triangles)
311309
{
312310
size_type n_points = points.shape()[0];
313311
size_type n_triangles = triangles.shape()[0];
@@ -378,7 +376,7 @@ namespace fastscapelib
378376
}
379377

380378
template <class S, unsigned int N>
381-
void trimesh_xt<S, N>::set_nodes_status(const nodes_status_map_type& nodes_status)
379+
void trimesh<S, N>::set_nodes_status(const nodes_status_map_type& nodes_status)
382380
{
383381
nodes_status_type temp_nodes_status(m_shape, node_status::core);
384382

@@ -408,7 +406,7 @@ namespace fastscapelib
408406
}
409407

410408
template <class S, unsigned int N>
411-
void trimesh_xt<S, N>::set_nodes_status(const nodes_status_array_type& nodes_status)
409+
void trimesh<S, N>::set_nodes_status(const nodes_status_array_type& nodes_status)
412410
{
413411
if (!xt::same_shape(nodes_status.shape(), m_shape))
414412
{
@@ -419,27 +417,27 @@ namespace fastscapelib
419417
}
420418

421419
template <class S, unsigned int N>
422-
inline auto trimesh_xt<S, N>::neighbors_count_impl(const size_type& idx) const -> size_type
420+
inline auto trimesh<S, N>::neighbors_count_impl(const size_type& idx) const -> size_type
423421
{
424422
return m_neighbors_indices[idx].size();
425423
}
426424

427425
template <class S, unsigned int N>
428-
inline auto trimesh_xt<S, N>::nodes_areas_impl() const -> areas_type
426+
inline auto trimesh<S, N>::nodes_areas_impl() const -> areas_type
429427
{
430428
return m_nodes_areas;
431429
}
432430

433431
template <class S, unsigned int N>
434-
inline auto trimesh_xt<S, N>::nodes_areas_impl(const size_type& idx) const noexcept
432+
inline auto trimesh<S, N>::nodes_areas_impl(const size_type& idx) const noexcept
435433
-> grid_data_type
436434
{
437435
return m_nodes_areas(idx);
438436
}
439437

440438
template <class S, unsigned int N>
441-
void trimesh_xt<S, N>::neighbors_indices_impl(neighbors_indices_impl_type& neighbors,
442-
const size_type& idx) const
439+
void trimesh<S, N>::neighbors_indices_impl(neighbors_indices_impl_type& neighbors,
440+
const size_type& idx) const
443441
{
444442
const auto& size = m_neighbors_indices[idx].size();
445443
neighbors.resize(size);
@@ -451,30 +449,18 @@ namespace fastscapelib
451449
}
452450

453451
template <class S, unsigned int N>
454-
auto trimesh_xt<S, N>::neighbors_distances_impl(const size_type& idx) const
452+
auto trimesh<S, N>::neighbors_distances_impl(const size_type& idx) const
455453
-> const neighbors_distances_impl_type&
456454
{
457455
return m_neighbors_distances[idx];
458456
}
459457

460458

461459
template <class S, unsigned int N>
462-
constexpr std::size_t trimesh_xt<S, N>::dimension_impl() noexcept
460+
constexpr std::size_t trimesh<S, N>::dimension_impl() noexcept
463461
{
464462
return 2;
465463
}
466-
467-
/**
468-
* @typedef trimesh
469-
*
470-
* \rst
471-
* Alias template on ``trimesh_xt`` with :cpp:type:`xt::xtensor`
472-
* used as array container type for data members.
473-
*
474-
* This is mainly for convenience when using in C++ applications.
475-
* \endrst
476-
*/
477-
using trimesh = trimesh_xt<xt_selector>;
478464
}
479465

480466
#endif // FASTSCAPELIB_GRID_TRIMESH_H

python/src/grid.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ namespace fastscapelib
3131

3232
using py_profile_grid = fs::profile_grid<fs::xt_python_selector>;
3333
using py_raster_grid = fs::raster_grid<fs::xt_python_selector, fs::raster_connect::queen>;
34-
using py_trimesh = fs::trimesh_xt<fs::xt_python_selector>;
34+
using py_trimesh = fs::trimesh<fs::xt_python_selector>;
3535
#ifdef WITH_HEALPIX
3636
using py_healpix_grid = fs::healpix_grid<fs::xt_python_selector>;
3737
#endif

test/test_trimesh.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace fastscapelib
2323
node_s fixed = node_s::fixed_value;
2424
node_s core = node_s::core;
2525

26-
using grid_type = fs::trimesh_xt<fs::xt_selector>;
26+
using grid_type = fs::trimesh<fs::xt_selector>;
2727
using size_type = typename grid_type::size_type;
2828
using shape_type = typename grid_type::shape_type;
2929

@@ -40,10 +40,10 @@ namespace fastscapelib
4040

4141
TEST_F(trimesh, static_expr)
4242
{
43-
EXPECT_EQ(fs::trimesh::is_structured(), false);
44-
EXPECT_EQ(fs::trimesh::is_uniform(), false);
45-
EXPECT_EQ(fs::trimesh::n_neighbors_max(), 20u);
46-
EXPECT_EQ(fs::trimesh::container_ndims(), 1);
43+
EXPECT_EQ(fs::trimesh<>::is_structured(), false);
44+
EXPECT_EQ(fs::trimesh<>::is_uniform(), false);
45+
EXPECT_EQ(fs::trimesh<>::n_neighbors_max(), 20u);
46+
EXPECT_EQ(fs::trimesh<>::container_ndims(), 1);
4747
}
4848

4949

0 commit comments

Comments
 (0)