23#ifndef VCL_MESH_COMPONENTS_WEDGE_TEX_COORDS_H
24#define VCL_MESH_COMPONENTS_WEDGE_TEX_COORDS_H
26#include "base/container_component.h"
27#include "base/predicates.h"
29#include <vclib/space/core.h>
30#include <vclib/base.h>
78 typename ParentElemType = void,
81 public ContainerComponent<
82 WedgeTexCoords<Scalar, N, ParentElemType, OPT>,
83 CompId::WEDGE_TEX_COORDS,
84 vcl::TexCoord<Scalar>,
88 !std::is_same_v<ParentElemType, void>,
92 using Base = ContainerComponent<
94 CompId::WEDGE_TEX_COORDS,
99 !std::is_same_v<ParentElemType, void>,
112 using ConstWedgeTexCoordsIterator =
115 static const int WEDGE_TEX_COORD_NUMBER = N;
155 return texCoords().at(
i);
176 return texCoords().atMod(
i);
187 return texCoords().atMod(
i);
199 texCoords().set(
i, t);
261 return texCoords().begin();
272 return texCoords().end();
319 void __wedgeTexCoords()
const {}
322 using WedgeTexCoordScalarType = Scalar;
325 template<
typename Element>
326 void importFrom(
const Element& e,
bool =
true);
328 void serialize(std::ostream&
os)
const
334 void deserialize(std::istream& is)
341 void resize(uint n)
requires (N < 0) { texCoords().resize(n); }
346 texCoords().pushBack(t);
354 texCoords().insert(i, t);
357 void erase(uint i)
requires (N < 0) { texCoords().erase(i); }
359 void clear()
requires (N < 0) { texCoords().clear(); }
362 template<
typename Element>
363 void importWedgeTexCoordsFrom(
const Element& e)
365 for (uint i = 0; i < e.vertexNumber(); ++i) {
366 wedgeTexCoord(i) = e.wedgeTexCoord(i).template cast<Scalar>();
371 Vector<vcl::TexCoord<Scalar>, N>& texCoords() {
return Base::container(); }
373 const Vector<vcl::TexCoord<Scalar>, N>& texCoords()
const
400 TITB::IsDerivedFromSpecializationOfV<T, WedgeTexCoords>;
429 RemoveRef<T>::VERTEX_NUMBER == RemoveRef<T>::WEDGE_TEX_COORD_NUMBER;
449template<
typename Scalar,
int N,
typename ParentElemType,
bool OPT>
450template<
typename Element>
451void WedgeTexCoords<Scalar, N, ParentElemType, OPT>::importFrom(
456 if (isWedgeTexCoordsAvailableOn(e)) {
457 if constexpr (N > 0) {
459 if constexpr (N == Element::WEDGE_TEX_COORD_NUMBER) {
460 importWedgeTexCoordsFrom(e);
463 else if constexpr (Element::WEDGE_TEX_COORD_NUMBER < 0) {
464 if (e.vertexNumber() == N) {
465 importWedgeTexCoordsFrom(e);
476 resize(e.vertexNumber());
477 importWedgeTexCoordsFrom(e);
496bool isWedgeTexCoordsAvailableOn(
const auto& element)
A class representing a box in N-dimensional space.
Definition box.h:46
void deserialize(std::istream &is)
Deserializes the box from the given input stream.
Definition box.h:476
Box()
The Empty constructor of a box, initializes a null box.
Definition box.h:65
void serialize(std::ostream &os) const
Serializes the box to the given output stream.
Definition box.h:466
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 WedgeTexCoords class is a container of texture coordinates associated to the wedges of a Face ele...
Definition wedge_tex_coords.h:91
WedgeTexCoordsIterator wedgeTexCoordEnd()
Returns an iterator to the end of the container of this component.
Definition wedge_tex_coords.h:251
vcl::TexCoord< Scalar > & wedgeTexCoord(uint i)
Returns a reference to the i-th wedge texcoord of the element.
Definition wedge_tex_coords.h:143
vcl::TexCoord< Scalar > & wedgeTexCoordMod(int i)
Returns a reference to the i-th wedge texcoord of the element but using as index the module between i...
Definition wedge_tex_coords.h:174
ushort & textureIndex()
Returns a reference to the texture index used to identify the texture on which the wedge texture coor...
Definition wedge_tex_coords.h:226
WedgeTexCoords()=default
Empty constructor.
ushort textureIndex() const
Returns the texture index used to identify the texture on which the wedge texture coordinates are map...
Definition wedge_tex_coords.h:234
View< ConstWedgeTexCoordsIterator > wedgeTexCoords() const
Returns a lightweight const view object that stores the begin and end iterators of the container of w...
Definition wedge_tex_coords.h:312
View< WedgeTexCoordsIterator > wedgeTexCoords()
Returns a lightweight view object that stores the begin and end iterators of the container of wedge t...
Definition wedge_tex_coords.h:291
WedgeTexCoordsIterator wedgeTexCoordBegin()
Returns an iterator to the first wedge texcoord in the container of this component.
Definition wedge_tex_coords.h:244
ConstWedgeTexCoordsIterator wedgeTexCoordEnd() const
Returns a const iterator to the end of the container of this component.
Definition wedge_tex_coords.h:270
void setWedgeTexCoords(Rng &&r)
Sets all the wedge texcoords of the element.
Definition wedge_tex_coords.h:214
ConstWedgeTexCoordsIterator wedgeTexCoordBegin() const
Returns a const iterator to the first wedge texcoord in the container of this component.
Definition wedge_tex_coords.h:259
const vcl::TexCoord< Scalar > & wedgeTexCoord(uint i) const
Returns a const reference to the i-th wedge texcoord of the element.
Definition wedge_tex_coords.h:153
const vcl::TexCoord< Scalar > & wedgeTexCoordMod(int i) const
Same of wedgeTexCoordMod(int) but returns a const reference.
Definition wedge_tex_coords.h:185
void setWedgeTexCoord(uint i, const vcl::TexCoord< Scalar > &t)
Sets the i-th wedge texcoord of the element.
Definition wedge_tex_coords.h:197
A concept that checks whether a type T (that should be a Element) has the WedgeTexCoords component (i...
Definition wedge_tex_coords.h:413
HasRightNumberOfWedgeTexCoords concept.
Definition wedge_tex_coords.h:428
A concept that checks whether a type T (that should be a Element) has the WedgeTexCoords component (i...
Definition wedge_tex_coords.h:399
Evaluates to true if the type T is a component that is stored vertically in its element container,...
Definition component.h:74
SanityCheckWedgeTexCoords concept.
Definition wedge_tex_coords.h:444