9#include <opencv2/core.hpp>
10#include <opencv2/imgproc.hpp>
58 enum class Origin { TopLeft = 0, TopRight, BottomLeft, BottomRight };
62 double width{1}, height{1}, aspect{1};
73 template <
typename... Args>
76 return std::make_shared<UVMap>(std::forward<Args>(args)...);
82 [[nodiscard]]
auto size() const -> std::
size_t;
85 [[nodiscard]] auto
empty() const ->
bool;
106 void set(std::
size_t id, const cv::Vec2d& uv, const
Origin& o);
113 void set(std::
size_t id, const cv::Vec2d& uv);
120 [[nodiscard]] auto
get(std::
size_t id, const
Origin& o) const -> cv::Vec2d;
127 [[nodiscard]] auto
get(std::
size_t id) const -> cv::Vec2d;
130 [[nodiscard]] auto
contains(std::
size_t id) const ->
bool;
133 [[nodiscard]] auto
as_map() const -> std::map<std::
size_t, cv::Vec2d>;
152 enum class FlipAxis { Vertical = 0, Horizontal, Both };
172 const ITKMesh::Pointer& mesh2D,
175 const Color& color = color::LIGHT_GRAY) -> cv::Mat;
219 UVMap& uv,
double theta,
const cv::Vec2d& center = {0.5, 0.5});
230 const cv::Vec2d& center = {0.5, 0.5});
238 std::map<std::size_t, cv::Vec2d>
map_;
Stores per-vertex UV mappings.
static void Rotate(UVMap &uv, Rotation rotation)
Rotate a UVMap by a multiple of 90 degrees.
static void Rotate(UVMap &uv, double theta, cv::Mat &texture, const cv::Vec2d ¢er={0.5, 0.5})
Rotate a UVMap by a specified angle.
std::shared_ptr< UVMap > Pointer
static void Flip(UVMap &uv, FlipAxis axis)
Flip a UVMap across one or both of its axes.
UVMap(Origin o)
Construct and set origin.
static auto Plot(const UVMap &uv, const ITKMesh::Pointer &mesh2D, int width=-1, int height=-1, const Color &color=color::LIGHT_GRAY) -> cv::Mat
Plot the UV mesh on an image.
static void Rotate(UVMap &uv, double theta, const cv::Vec2d ¢er={0.5, 0.5})
Rotate a UVMap by a specified angle.
std::map< std::size_t, cv::Vec2d > map_
void setOrigin(const Origin &o)
Set the origin of the UVMap.
auto contains(std::size_t id) const -> bool
Check if the vertex index has a UV mapping.
auto get(std::size_t id, const Origin &o) const -> cv::Vec2d
Get the UV value for a point by ID.
UVMap()=default
Default constructor.
void set(std::size_t id, const cv::Vec2d &uv, const Origin &o)
Set the UV value for a point by ID.
auto origin() const -> Origin
Get the current origin of the UVMap.
auto as_map() const -> std::map< std::size_t, cv::Vec2d >
auto empty() const -> bool
Return whether the UVMap is empty.
static void AlignToAxis(UVMap &uv, const ITKMesh::Pointer &mesh, AlignmentAxis axis)
Rotate a UVMap to align a specified volume axis to the -V direction of UV space.
static auto Plot(const UVMap &uv, const Color &color=color::GREEN) -> cv::Mat
Plot the UV points on an image.
static auto New(Args... args) -> Pointer
auto ratio() const -> Ratio
Get the size information (aspect ratio, width, height)
static void Rotate(UVMap &uv, Rotation rotation, cv::Mat &texture)
Rotate a UVMap by a multiple of 90 degrees.
auto size() const -> std::size_t
Return the number of UV elements.
Volume Cartographer library
cv::Vec3b Color
Color type.
static const cv::Vec2d NULL_MAPPING