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/base.h>
30#include <vclib/space/core.h>
76 typename ParentElemType = void,
79 public ContainerComponent<
80 WedgeTexCoords<Scalar, N, ParentElemType, OPT>,
81 CompId::WEDGE_TEX_COORDS,
82 vcl::TexCoord<Scalar>,
86 !std::is_same_v<ParentElemType, void>,
90 using Base = ContainerComponent<
92 CompId::WEDGE_TEX_COORDS,
97 !std::is_same_v<ParentElemType, void>,
110 using ConstWedgeTexCoordsIterator =
113 static const int WEDGE_TEX_COORD_NUMBER = N;
153 return texCoords().at(
i);
174 return texCoords().atMod(
i);
185 return texCoords().atMod(
i);
197 texCoords().set(
i, t);
243 return texCoords().begin();
254 return texCoords().end();
301 void __wedgeTexCoords()
const {}
304 using WedgeTexCoordScalarType = Scalar;
307 template<
typename Element>
308 void importFrom(
const Element& e,
bool =
true);
310 void serialize(std::ostream&
os)
const { texCoords().
serialize(
os); }
312 void deserialize(std::istream& is) { texCoords().
deserialize(is); }
315 void resize(uint n)
requires (N < 0) { texCoords().resize(n); }
320 texCoords().pushBack(t);
328 texCoords().insert(i, t);
331 void erase(uint i)
requires (N < 0) { texCoords().erase(i); }
333 void clear()
requires (N < 0) { texCoords().clear(); }
336 template<
typename Element>
337 void importWedgeTexCoordsFrom(
const Element& e)
339 for (uint i = 0; i < e.vertexNumber(); ++i) {
340 wedgeTexCoord(i) = e.wedgeTexCoord(i).template cast<Scalar>();
344 Vector<vcl::TexCoord<Scalar>, N>& texCoords() {
return Base::container(); }
346 const Vector<vcl::TexCoord<Scalar>, N>& texCoords()
const
373 TITB::IsDerivedFromSpecializationOfV<T, WedgeTexCoords>;
402 RemoveRef<T>::VERTEX_NUMBER == RemoveRef<T>::WEDGE_TEX_COORD_NUMBER;
422template<
typename Scalar,
int N,
typename ParentElemType,
bool OPT>
423template<
typename Element>
424void WedgeTexCoords<Scalar, N, ParentElemType, OPT>::importFrom(
429 if (isWedgeTexCoordsAvailableOn(e)) {
430 if constexpr (N > 0) {
432 if constexpr (N == Element::WEDGE_TEX_COORD_NUMBER) {
433 importWedgeTexCoordsFrom(e);
436 else if constexpr (Element::WEDGE_TEX_COORD_NUMBER < 0) {
437 if (e.vertexNumber() == N) {
438 importWedgeTexCoordsFrom(e);
449 resize(e.vertexNumber());
450 importWedgeTexCoordsFrom(e);
469bool 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:89
WedgeTexCoordsIterator wedgeTexCoordEnd()
Returns an iterator to the end of the container of this component.
Definition wedge_tex_coords.h:233
vcl::TexCoord< Scalar > & wedgeTexCoord(uint i)
Returns a reference to the i-th wedge texcoord of the element.
Definition wedge_tex_coords.h:141
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:172
WedgeTexCoords()=default
Empty constructor.
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:294
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:273
WedgeTexCoordsIterator wedgeTexCoordBegin()
Returns an iterator to the first wedge texcoord in the container of this component.
Definition wedge_tex_coords.h:226
ConstWedgeTexCoordsIterator wedgeTexCoordEnd() const
Returns a const iterator to the end of the container of this component.
Definition wedge_tex_coords.h:252
void setWedgeTexCoords(Rng &&r)
Sets all the wedge texcoords of the element.
Definition wedge_tex_coords.h:212
ConstWedgeTexCoordsIterator wedgeTexCoordBegin() const
Returns a const iterator to the first wedge texcoord in the container of this component.
Definition wedge_tex_coords.h:241
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:151
const vcl::TexCoord< Scalar > & wedgeTexCoordMod(int i) const
Same of wedgeTexCoordMod(int) but returns a const reference.
Definition wedge_tex_coords.h:183
void setWedgeTexCoord(uint i, const vcl::TexCoord< Scalar > &t)
Sets the i-th wedge texcoord of the element.
Definition wedge_tex_coords.h:195
A concept that checks whether a type T (that should be a Element) has the WedgeTexCoords component (i...
Definition wedge_tex_coords.h:386
HasRightNumberOfWedgeTexCoords concept.
Definition wedge_tex_coords.h:401
A concept that checks whether a type T (that should be a Element) has the WedgeTexCoords component (i...
Definition wedge_tex_coords.h:372
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:417