23#ifndef VCL_MESH_COMPONENTS_TEXTURE_PATHS_H
24#define VCL_MESH_COMPONENTS_TEXTURE_PATHS_H
26#include "base/component.h"
27#include "concepts/textures.h"
29#include <vclib/base.h>
40 std::vector<std::string> texPaths;
74 CompId::TEXTURE_PATHS,
80 using Base = Component<
82 CompId::TEXTURE_PATHS,
90 using TexFileNamesIterator = std::vector<std::string>::iterator;
91 using ConstTexFileNamesIterator = std::vector<std::string>::const_iterator;
125 const std::string&
meshBasePath()
const {
return Base::data().meshPath; }
140 auto it = std::find(texPaths().begin(), texPaths().end(), path);
141 if (
it != texPaths().end()) {
142 return static_cast<uint>(std::distance(texPaths().begin(),
it));
181 return texPaths().begin();
191 return texPaths().end();
237 template<
typename Element>
238 void importFrom(
const Element& e,
bool =
true)
242 for (
const auto&
tex : e.textures()) {
243 texPaths().push_back(
tex.path());
249 void serialize(std::ostream& os)
const
251 vcl::serialize(os, texPaths());
255 void deserialize(std::istream& is)
257 vcl::deserialize(is, texPaths());
263 std::vector<std::string>& texPaths() {
return Base::data().texPaths; }
265 const std::vector<std::string>& texPaths()
const
267 return Base::data().texPaths;
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 TexturePaths class represents a component that stores the paths of the textures used by a mesh....
Definition texture_paths.h:79
uint textureNumber() const
Returns the number of texture paths of the mesh.
Definition texture_paths.h:106
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_paths.h:138
TexFileNamesIterator texturePathBegin()
Returns an iterator to the beginning of the vector of texture paths.
Definition texture_paths.h:166
void clearTexturePaths()
Clears the vector of texture paths.
Definition texture_paths.h:150
TexFileNamesIterator texturePathEnd()
Returns an iterator to the end of the vector of texture paths.
Definition texture_paths.h:172
TexturePaths()=default
Initializes the component with an empty vector of texture paths, and an empty string as mesh base pat...
std::string & meshBasePath()
Returns a reference to the mesh base path.
Definition texture_paths.h:130
View< ConstTexFileNamesIterator > texturePaths() const
Returns a lightweigth const view object that stores the begin and end iterators of the vector of text...
Definition texture_paths.h:230
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_paths.h:120
ConstTexFileNamesIterator texturePathEnd() const
Returns a const iterator to the end of the vector of texture paths.
Definition texture_paths.h:189
const std::string & meshBasePath() const
Returns the mesh base path.
Definition texture_paths.h:125
View< TexFileNamesIterator > texturePaths()
Returns a lightweigth view object that stores the begin and end iterators of the vector of texture pa...
Definition texture_paths.h:210
ConstTexFileNamesIterator texturePathBegin() const
Returns a const iterator to the beginning of the vector of texture paths.
Definition texture_paths.h:179
void pushTexturePath(const std::string &textName)
Adds a texture path to the vector of texture paths.
Definition texture_paths.h:156
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_paths.h:113
A concept that checks whether a type T (that should be a Mesh) has the TexturePaths or TextureImages ...
Definition textures.h:61
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