23#ifndef VCL_MESH_COMPONENTS_WEDGE_TEX_COORDS_H
24#define VCL_MESH_COMPONENTS_WEDGE_TEX_COORDS_H
26#include "bases/container_component.h"
28#include <vclib/concepts/mesh/components/tex_coord.h>
29#include <vclib/concepts/mesh/components/wedge_tex_coords.h>
30#include <vclib/space/core/tex_coord.h>
31#include <vclib/space/core/vector.h>
32#include <vclib/types/view.h>
80 typename ParentElemType = void,
84 WedgeTexCoords<Scalar, N, ParentElemType, OPT>,
85 CompId::WEDGE_TEX_COORDS,
86 vcl::TexCoord<Scalar>,
90 !std::is_same_v<ParentElemType, void>,
96 CompId::WEDGE_TEX_COORDS,
101 !std::is_same_v<ParentElemType, void>,
114 using ConstWedgeTexCoordsIterator =
117 static const int WEDGE_TEX_COORD_NUMBER = N;
157 return texCoords().at(
i);
178 return texCoords().atMod(
i);
189 return texCoords().atMod(
i);
201 texCoords().set(
i, t);
263 return texCoords().begin();
274 return texCoords().end();
321 void __wedgeTexCoords()
const {}
324 using WedgeTexCoordScalarType = Scalar;
327 template<
typename Element>
328 void importFrom(
const Element& e,
bool =
true)
331 if (isWedgeTexCoordsAvailableOn(e)) {
332 if constexpr (N > 0) {
334 if constexpr (N == Element::WEDGE_TEX_COORD_NUMBER) {
335 importWedgeTexCoordsFrom(e);
338 else if constexpr (Element::WEDGE_TEX_COORD_NUMBER < 0) {
339 if (e.vertexNumber() == N) {
340 importWedgeTexCoordsFrom(e);
351 resize(e.vertexNumber());
352 importWedgeTexCoordsFrom(e);
358 void serialize(std::ostream& os)
const
360 texCoords().serialize(os);
364 void deserialize(std::istream& is)
366 texCoords().deserialize(is);
371 void resize(uint n)
requires (N < 0) { texCoords().resize(n); }
376 texCoords().pushBack(t);
384 texCoords().insert(i, t);
387 void erase(uint i)
requires (N < 0) { texCoords().erase(i); }
389 void clear()
requires (N < 0) { texCoords().clear(); }
392 template<
typename Element>
393 void importWedgeTexCoordsFrom(
const Element& e)
395 for (uint i = 0; i < e.vertexNumber(); ++i) {
396 wedgeTexCoord(i) = e.wedgeTexCoord(i).template cast<Scalar>();
401 Vector<vcl::TexCoord<Scalar>, N>& texCoords() {
return Base::container(); }
403 const Vector<vcl::TexCoord<Scalar>, N>& texCoords()
const
405 return Base::container();
423bool isWedgeTexCoordsAvailableOn(
const ElementConcept
auto& element)
425 return isComponentAvailableOn<CompId::WEDGE_TEX_COORDS>(element);
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 ContainerComponent class is the base class for all the components of VCLib that store a container...
Definition container_component.h:130
The WedgeTexCoords class is a container of texture coordinates associated to the wedges of a Face ele...
Definition wedge_tex_coords.h:93
WedgeTexCoordsIterator wedgeTexCoordEnd()
Returns an iterator to the end of the container of this component.
Definition wedge_tex_coords.h:253
vcl::TexCoord< Scalar > & wedgeTexCoord(uint i)
Returns a reference to the i-th wedge texcoord of the element.
Definition wedge_tex_coords.h:145
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:176
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:228
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:236
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:314
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:293
WedgeTexCoordsIterator wedgeTexCoordBegin()
Returns an iterator to the first wedge texcoord in the container of this component.
Definition wedge_tex_coords.h:246
ConstWedgeTexCoordsIterator wedgeTexCoordEnd() const
Returns a const iterator to the end of the container of this component.
Definition wedge_tex_coords.h:272
void setWedgeTexCoords(Rng &&r)
Sets all the wedge texcoords of the element.
Definition wedge_tex_coords.h:216
ConstWedgeTexCoordsIterator wedgeTexCoordBegin() const
Returns a const iterator to the first wedge texcoord in the container of this component.
Definition wedge_tex_coords.h:261
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:155
const vcl::TexCoord< Scalar > & wedgeTexCoordMod(int i) const
Same of wedgeTexCoordMod(int) but returns a const reference.
Definition wedge_tex_coords.h:187
void setWedgeTexCoord(uint i, const vcl::TexCoord< Scalar > &t)
Sets the i-th wedge texcoord of the element.
Definition wedge_tex_coords.h:199