23#ifndef VCL_MESH_COMPONENTS_TEXTURE_IMAGES_H
24#define VCL_MESH_COMPONENTS_TEXTURE_IMAGES_H
26#include "base/component.h"
27#include "concepts/textures.h"
29#include <vclib/space/core.h>
30#include <vclib/base.h>
41 std::vector<Texture> textures;
46 return textures | std::views::transform([](Texture& t) -> std::string& {
53 return textures | std::views::transform(
54 [](
const Texture& t) ->
const std::string& {
59 auto pathBegin() {
return std::begin(paths()); }
61 auto pathBegin()
const {
return std::begin(paths()); }
63 auto pathEnd() {
return std::end(paths()); }
65 auto pathEnd()
const {
return std::end(paths()); }
97 CompId::TEXTURE_IMAGES,
103 using Base = Component<
105 CompId::TEXTURE_IMAGES,
118 using TextureIterator = std::vector<Texture>::iterator;
119 using ConstTextureIterator = std::vector<Texture>::const_iterator;
121 using TexFileNamesIterator =
122 decltype(std::declval<detail::TData>().pathBegin());
123 using ConstTexFileNamesIterator =
124 decltype(std::declval<const detail::TData>().pathBegin());
182 const std::string&
meshBasePath()
const {
return Base::data().meshPath; }
198 std::find(Base::data().pathBegin(), Base::data().pathEnd(), path);
199 if (
it != Base::data().pathEnd()) {
200 return static_cast<uint>(
201 std::distance(Base::data().pathBegin(),
it));
265 ConstTextureIterator
textureEnd()
const {
return texs().end(); }
302 return Base::data().pathBegin();
317 return Base::data().pathEnd();
405 template<
typename Element>
406 void importFrom(
const Element& e,
bool =
true)
421 void serialize(std::ostream& os)
const
423 vcl::serialize(os, texs());
427 void deserialize(std::istream& is)
429 vcl::deserialize(is, texs());
435 std::vector<Texture>& texs() {
return Base::data().textures; }
437 const std::vector<Texture>& texs()
const {
return Base::data().textures; }
A class representing a box in N-dimensional space.
Definition box.h:46
The Element class.
Definition element.h:75
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:102
auto texturePaths()
Returns a lightweigth view object that stores the begin and end iterators of the vector of texture pa...
Definition texture_images.h:380
ConstTextureIterator textureBegin() const
Returns a const iterator to the beginning of the vector of textures.
Definition texture_images.h:259
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:177
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:236
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:165
std::string & meshBasePath()
Returns a reference to the mesh base path.
Definition texture_images.h:187
void clearTextures()
Clears the vector of textures.
Definition texture_images.h:209
TextureImages()=default
Initializes the component with an empty vector of textures and an empty string as mesh base path.
uint indexOfTexturePath(const std::string &path) const
Returns the index of the texture with the given path, or UINT_NULL if the texture is not found.
Definition texture_images.h:195
void clearTexturePaths()
Clears the vector of textures.
Definition texture_images.h:218
TexFileNamesIterator texturePathBegin()
Returns an iterator to the beginning of the vector of texture paths.
Definition texture_images.h:277
View< TextureIterator > textures()
Returns a lightweigth view object that stores the begin and end iterators of the vector of textures....
Definition texture_images.h:335
TexFileNamesIterator texturePathEnd()
Returns an iterator to the end of the vector of texture paths.
Definition texture_images.h:288
TextureIterator textureBegin()
Returns an iterator to the beginning of the vector of textures.
Definition texture_images.h:246
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:146
TextureIterator textureEnd()
Returns an iterator to the end of the vector of textures.
Definition texture_images.h:252
ConstTexFileNamesIterator texturePathBegin() const
Returns a const iterator to the beginning of the vector of texture paths.
Definition texture_images.h:300
void pushTexture(const Texture &texture)
Adds a texture to the vector of textures.
Definition texture_images.h:224
ConstTextureIterator textureEnd() const
Returns a const iterator to the end of the vector of textures.
Definition texture_images.h:265
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:401
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:355
ConstTexFileNamesIterator texturePathEnd() const
Returns a const iterator to the end of the vector of texture paths.
Definition texture_images.h:315
const std::string & meshBasePath() const
Returns the mesh base path.
Definition texture_images.h:182
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:153
uint textureNumber() const
Returns the number of texture of the mesh.
Definition texture_images.h:139
Concept that checks if a Mesh has the TexturePaths component.
Definition mesh_requirements.h:105
A concept that checks whether a type T (that should be a Mesh) has the TextureImages component (inher...
Definition textures.h:45
constexpr uint UINT_NULL
The UINT_NULL value represent a null value of uint that is the maximum value that can be represented ...
Definition base.h:48