23#ifndef VCL_MESH_COMPONENTS_WEDGE_COLORS_H
24#define VCL_MESH_COMPONENTS_WEDGE_COLORS_H
26#include "bases/container_component.h"
28#include <vclib/concepts/mesh/components/color.h>
29#include <vclib/concepts/mesh/components/wedge_colors.h>
30#include <vclib/space/core/color.h>
31#include <vclib/space/core/vector.h>
32#include <vclib/types/view.h>
73template<
int N,
typename ParentElemType =
void,
bool OPT = false>
76 WedgeColors<N, ParentElemType, OPT>,
82 !std::is_same_v<ParentElemType, void>,
93 !std::is_same_v<ParentElemType, void>,
105 using WedgeColorsIterator = Base::Iterator;
106 using ConstWedgeColorsIterator = Base::ConstIterator;
108 static const int WEDGE_COLOR_NUMBER = Base::SIZE;
223 return colors().begin();
277 void __wedgeColors()
const {}
281 template<
typename Element>
282 void importFrom(
const Element& e,
bool =
true)
285 if (isWedgeColorsAvailableOn(e)) {
286 if constexpr (N > 0) {
288 if constexpr (N == Element::WEDGE_COLOR_NUMBER) {
289 importWedgeColorsFrom(e);
292 else if constexpr (Element::WEDGE_COLOR_NUMBER < 0) {
293 if (e.vertexNumber() == N) {
294 importWedgeColorsFrom(e);
305 resize(e.vertexNumber());
306 importWedgeColorsFrom(e);
312 void serialize(std::ostream& os)
const { colors().serialize(os); }
314 void deserialize(std::istream& is) { colors().deserialize(is); }
317 void resize(uint n)
requires (N < 0) { colors().resize(n); }
321 colors().pushBack(c);
326 colors().insert(i, c);
329 void erase(uint i)
requires (N < 0) { colors().erase(i); }
331 void clear()
requires (N < 0) { colors().clear(); }
334 template<
typename Element>
335 void importWedgeColorsFrom(
const Element& e)
337 for (uint i = 0; i < e.vertexNumber(); ++i) {
342 Vector<vcl::Color, N>& colors() {
return Base::container(); }
344 const Vector<vcl::Color, N>& colors()
const {
return Base::container(); }
360bool isWedgeColorsAvailableOn(
const ElementConcept
auto& element)
362 return isComponentAvailableOn<CompId::WEDGE_COLORS>(element);
The Color class represents a 32 bit color.
Definition color.h:48
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 WedgeColors class is a container of colors associated to the wedges of a Face element.
Definition wedge_colors.h:85
View< ConstWedgeColorsIterator > wedgeColors() const
Returns a lightweight const view object that stores the begin and end iterators of the container of w...
Definition wedge_colors.h:271
vcl::Color & wedgeColorMod(int i)
Returns a reference to the i-th wedge color of the element but using as index the module between i an...
Definition wedge_colors.h:163
vcl::Color & wedgeColor(uint i)
Returns a reference to the i-th wedge color of the element.
Definition wedge_colors.h:136
WedgeColors()=default
Empty constructor.
WedgeColorsIterator wedgeColorBegin()
Returns an iterator to the first wedge color in the container of this component.
Definition wedge_colors.h:206
ConstWedgeColorsIterator wedgeColorEnd() const
Returns a const iterator to the end of the container of this component.
Definition wedge_colors.h:232
WedgeColorsIterator wedgeColorEnd()
Returns an iterator to the end of the container of this component.
Definition wedge_colors.h:213
void setWedgeColors(Rng &&r)
Sets all the wedge colors of the element.
Definition wedge_colors.h:193
ConstWedgeColorsIterator wedgeColorBegin() const
Returns a const iterator to the first wedge color in the container of this component.
Definition wedge_colors.h:221
const vcl::Color & wedgeColor(uint i) const
Returns a const reference to the i-th wedge color of the element.
Definition wedge_colors.h:145
const vcl::Color & wedgeColorMod(int i) const
Same of wedgeColorMod(int) but returns a const reference.
Definition wedge_colors.h:171
View< WedgeColorsIterator > wedgeColors()
Returns a lightweight view object that stores the begin and end iterators of the container of wedge c...
Definition wedge_colors.h:250
void setWedgeColor(uint i, const vcl::Color &c)
Sets the i-th wedge color of the element.
Definition wedge_colors.h:179