23#ifndef VCL_MESH_COMPONENTS_TEXTURE_IMAGES_H
24#define VCL_MESH_COMPONENTS_TEXTURE_IMAGES_H
26#include "bases/component.h"
28#include <vclib/concepts/mesh/components/texture_images.h>
29#include <vclib/concepts/mesh/components/texture_paths.h>
30#include <vclib/space/core/texture.h>
31#include <vclib/types/view.h>
42 std::vector<Texture> textures;
47 return textures | std::views::transform([](Texture& t) -> std::string& {
54 return textures | std::views::transform(
55 [](
const Texture& t) ->
const std::string& {
60 auto pathBegin() {
return std::begin(paths()); }
62 auto pathBegin()
const {
return std::begin(paths()); }
64 auto pathEnd() {
return std::end(paths()); }
66 auto pathEnd()
const {
return std::end(paths()); }
98 CompId::TEXTURE_IMAGES,
104 using Base = Component<
106 CompId::TEXTURE_IMAGES,
119 using TextureIterator = std::vector<Texture>::iterator;
120 using ConstTextureIterator = std::vector<Texture>::const_iterator;
122 using TexFileNamesIterator =
123 decltype(std::declval<detail::TData>().pathBegin());
124 using ConstTexFileNamesIterator =
125 decltype(std::declval<const detail::TData>().pathBegin());
183 const std::string&
meshBasePath()
const {
return Base::data().meshPath; }
249 ConstTextureIterator
textureEnd()
const {
return texs().end(); }
286 return Base::data().pathBegin();
301 return Base::data().pathEnd();
389 template<
typename Element>
390 void importFrom(
const Element& e,
bool =
true)
405 void serialize(std::ostream& os)
const
407 vcl::serialize(os, texs());
411 void deserialize(std::istream& is)
413 vcl::deserialize(is, texs());
419 std::vector<Texture>& texs() {
return Base::data().textures; }
421 const std::vector<Texture>& texs()
const {
return Base::data().textures; }
The Element class.
Definition element.h:57
A class representing a line segment in n-dimensional space. The class is parameterized by a PointConc...
Definition segment.h:43
The View class is a simple class that stores and exposes two iterators begin and end.
Definition view.h:67
The TextureImages class represents a component that stores the textures used by a mesh....
Definition texture_images.h:103
auto texturePaths()
Returns a lightweigth view object that stores the begin and end iterators of the vector of texture pa...
Definition texture_images.h:364
ConstTextureIterator textureBegin() const
Returns a const iterator to the beginning of the vector of textures.
Definition texture_images.h:243
std::string & texturePath(uint i)
Returns a reference to the path of the i-th texture of the mesh. The path is relative to the mesh bas...
Definition texture_images.h:178
void pushTexturePath(const std::string &textPath)
Adds a texture to the vector of textures. The image of the texture is left empty.
Definition texture_images.h:220
const std::string & texturePath(uint i) const
Returns the path of the i-th texture of the mesh. The path is relative to the mesh base path.
Definition texture_images.h:166
std::string & meshBasePath()
Returns a reference to the mesh base path.
Definition texture_images.h:188
void clearTextures()
Clears the vector of textures.
Definition texture_images.h:193
TextureImages()=default
Initializes the component with an empty vector of textures and an empty string as mesh base path.
void clearTexturePaths()
Clears the vector of textures.
Definition texture_images.h:202
TexFileNamesIterator texturePathBegin()
Returns an iterator to the beginning of the vector of texture paths.
Definition texture_images.h:261
View< TextureIterator > textures()
Returns a lightweigth view object that stores the begin and end iterators of the vector of textures....
Definition texture_images.h:319
TexFileNamesIterator texturePathEnd()
Returns an iterator to the end of the vector of texture paths.
Definition texture_images.h:272
TextureIterator textureBegin()
Returns an iterator to the beginning of the vector of textures.
Definition texture_images.h:230
const Texture & texture(uint i) const
Returns the i-th texture of the mesh. The path of the texture is relative to the mesh base path.
Definition texture_images.h:147
TextureIterator textureEnd()
Returns an iterator to the end of the vector of textures.
Definition texture_images.h:236
ConstTexFileNamesIterator texturePathBegin() const
Returns a const iterator to the beginning of the vector of texture paths.
Definition texture_images.h:284
void pushTexture(const Texture &texture)
Adds a texture to the vector of textures.
Definition texture_images.h:208
ConstTextureIterator textureEnd() const
Returns a const iterator to the end of the vector of textures.
Definition texture_images.h:249
auto texturePaths() const
Returns a lightweigth const view object that stores the begin and end iterators of the vector of text...
Definition texture_images.h:385
View< ConstTextureIterator > textures() const
Returns a lightweigth const view object that stores the begin and end iterators of the vector of text...
Definition texture_images.h:339
ConstTexFileNamesIterator texturePathEnd() const
Returns a const iterator to the end of the vector of texture paths.
Definition texture_images.h:299
const std::string & meshBasePath() const
Returns the mesh base path.
Definition texture_images.h:183
Texture & texture(uint i)
Returns a reference to the i-th texture of the mesh. The path of the texture is relative to the mesh ...
Definition texture_images.h:154
uint textureNumber() const
Returns the number of texture of the mesh.
Definition texture_images.h:140
Concept that checks if a Mesh has the TexturePaths component.
Definition per_mesh.h:112
HasTextureImages concept is satisfied only if a Mesh class provides the member functions specified in...
Definition texture_images.h:43