@@ -56,8 +56,10 @@ class SpaceMapBase {
5656
5757} // namespace internal
5858
59+ // ! \brief The PointMap class provides an interface for accessing a raw pointer
60+ // ! as a Point, allowing easy access to its coordinates.
5961template <typename Scalar_, int Dim_>
60- class PointMap final : public internal::PointMapBase<Scalar_, Dim_> {
62+ class PointMap : public internal ::PointMapBase<Scalar_, Dim_> {
6163 public:
6264 using typename internal::PointMapBase<Scalar_, Dim_>::ScalarType;
6365 using internal::PointMapBase<Scalar_, Dim_>::Dim;
@@ -73,8 +75,10 @@ class PointMap final : public internal::PointMapBase<Scalar_, Dim_> {
7375 }
7476};
7577
78+ // ! \brief The PointMap class provides an interface for accessing a raw pointer
79+ // ! as a Point, allowing easy access to its coordinates.
7680template <typename Scalar_>
77- class PointMap <Scalar_, kDynamicDim > final
81+ class PointMap <Scalar_, kDynamicDim >
7882 : public internal::PointMapBase<Scalar_, kDynamicDim > {
7983 public:
8084 using typename internal::PointMapBase<Scalar_, kDynamicDim >::ScalarType;
@@ -89,8 +93,10 @@ class PointMap<Scalar_, kDynamicDim> final
8993 std::size_t sdim_;
9094};
9195
96+ // ! \brief The SpaceMap class provides an interface for accessing a raw pointer
97+ // ! as a Space, allowing easy access to its points via a PointMap interface.
9298template <typename Scalar_, int Dim_>
93- class SpaceMap final : public internal::SpaceMapBase<Scalar_, Dim_> {
99+ class SpaceMap : public internal ::SpaceMapBase<Scalar_, Dim_> {
94100 public:
95101 using typename internal::SpaceMapBase<Scalar_, Dim_>::ScalarType;
96102 using internal::SpaceMapBase<Scalar_, Dim_>::Dim;
@@ -114,8 +120,10 @@ class SpaceMap final : public internal::SpaceMapBase<Scalar_, Dim_> {
114120 }
115121};
116122
123+ // ! \brief The SpaceMap class provides an interface for accessing a raw pointer
124+ // ! as a Space, allowing easy access to its points via a PointMap interface.
117125template <typename Scalar_>
118- class SpaceMap <Scalar_, kDynamicDim > final
126+ class SpaceMap <Scalar_, kDynamicDim >
119127 : public internal::SpaceMapBase<Scalar_, kDynamicDim > {
120128 public:
121129 using typename internal::SpaceMapBase<Scalar_, kDynamicDim >::ScalarType;
@@ -152,4 +160,38 @@ struct StdPointTraits<PointMap<Scalar_, Dim_>> {
152160 }
153161};
154162
163+ // ! \brief MapTraits provides an interface for SpaceMap and points supported by
164+ // ! StdPointTraits.
165+ // ! \tparam Index_ Type used for indexing. Defaults to int.
166+ template <typename Scalar_, int Dim_, typename Index_ = int >
167+ struct MapTraits {
168+ using SpaceType = SpaceMap<Scalar_, Dim_>;
169+ using PointType = PointMap<Scalar_ const , Dim_>;
170+ using ScalarType = Scalar_;
171+ static constexpr int Dim = Dim_;
172+ using IndexType = Index_;
173+
174+ inline static int SpaceSdim (SpaceType const & space) {
175+ return static_cast <IndexType>(space.sdim ());
176+ }
177+
178+ inline static IndexType SpaceNpts (SpaceType const & space) {
179+ return static_cast <IndexType>(space.npts ());
180+ }
181+
182+ inline static PointType PointAt (SpaceType const & space, IndexType const idx) {
183+ return space (idx);
184+ }
185+
186+ template <typename OtherPoint>
187+ inline static int PointSdim (OtherPoint const & point) {
188+ return StdPointTraits<OtherPoint>::Sdim (point);
189+ }
190+
191+ template <typename OtherPoint>
192+ inline static ScalarType const * PointCoords (OtherPoint const & point) {
193+ return StdPointTraits<OtherPoint>::Coords (point);
194+ }
195+ };
196+
155197} // namespace pico_tree
0 commit comments