23#ifndef VCL_MESH_COMPONENTS_WEDGE_COLORS_H
24#define VCL_MESH_COMPONENTS_WEDGE_COLORS_H
26#include "base/container_component.h"
27#include "base/predicates.h"
29#include <vclib/space/core.h>
30#include <vclib/base.h>
71template<
int N,
typename ParentElemType =
void,
bool OPT = false>
73 public ContainerComponent<
74 WedgeColors<N, ParentElemType, OPT>,
80 !std::is_same_v<ParentElemType, void>,
84 using Base = ContainerComponent<
91 !std::is_same_v<ParentElemType, void>,
103 using WedgeColorsIterator = Base::Iterator;
104 using ConstWedgeColorsIterator = Base::ConstIterator;
106 static const int WEDGE_COLOR_NUMBER = Base::SIZE;
221 return colors().begin();
275 void __wedgeColors()
const {}
279 template<
typename Element>
280 void importFrom(
const Element& e,
bool =
true);
282 void serialize(std::ostream&
os)
const { colors().
serialize(
os); }
284 void deserialize(std::istream& is) { colors().
deserialize(is); }
287 void resize(uint n)
requires (N < 0) { colors().resize(n); }
291 colors().pushBack(c);
296 colors().insert(i, c);
299 void erase(uint i)
requires (N < 0) { colors().erase(i); }
301 void clear()
requires (N < 0) { colors().clear(); }
304 template<
typename Element>
305 void importWedgeColorsFrom(
const Element& e)
307 for (uint i = 0; i < e.vertexNumber(); ++i) {
314 const Vector<vcl::Color, N>& colors()
const {
return Base::container(); }
385template<
int N,
typename ParentElemType,
bool OPT>
386template<
typename Element>
387void WedgeColors<N, ParentElemType, OPT>::importFrom(
const Element& e,
bool)
390 if (isWedgeColorsAvailableOn(e)) {
391 if constexpr (N > 0) {
393 if constexpr (N == Element::WEDGE_COLOR_NUMBER) {
394 importWedgeColorsFrom(e);
397 else if constexpr (Element::WEDGE_COLOR_NUMBER < 0) {
398 if (e.vertexNumber() == N) {
399 importWedgeColorsFrom(e);
410 resize(e.vertexNumber());
411 importWedgeColorsFrom(e);
429bool isWedgeColorsAvailableOn(
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 Color class represents a 32 bit color.
Definition color.h:48
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 WedgeColors class is a container of colors associated to the wedges of a Face element.
Definition wedge_colors.h:83
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:269
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:161
vcl::Color & wedgeColor(uint i)
Returns a reference to the i-th wedge color of the element.
Definition wedge_colors.h:134
WedgeColors()=default
Empty constructor.
WedgeColorsIterator wedgeColorBegin()
Returns an iterator to the first wedge color in the container of this component.
Definition wedge_colors.h:204
ConstWedgeColorsIterator wedgeColorEnd() const
Returns a const iterator to the end of the container of this component.
Definition wedge_colors.h:230
WedgeColorsIterator wedgeColorEnd()
Returns an iterator to the end of the container of this component.
Definition wedge_colors.h:211
void setWedgeColors(Rng &&r)
Sets all the wedge colors of the element.
Definition wedge_colors.h:191
ConstWedgeColorsIterator wedgeColorBegin() const
Returns a const iterator to the first wedge color in the container of this component.
Definition wedge_colors.h:219
const vcl::Color & wedgeColor(uint i) const
Returns a const reference to the i-th wedge color of the element.
Definition wedge_colors.h:143
const vcl::Color & wedgeColorMod(int i) const
Same of wedgeColorMod(int) but returns a const reference.
Definition wedge_colors.h:169
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:248
void setWedgeColor(uint i, const vcl::Color &c)
Sets the i-th wedge color of the element.
Definition wedge_colors.h:177
A concept that checks whether a type T (that should be a Element) has the WedgeColors component (inhe...
Definition wedge_colors.h:350
HasRightNumberOfWedgeColors concept.
Definition wedge_colors.h:365
A concept that checks whether a type T (that should be a Element) has the WedgeColors component (inhe...
Definition wedge_colors.h:337
Evaluates to true if the type T is a component that is stored vertically in its element container,...
Definition component.h:74
SanityCheckWedgeColors concept.
Definition wedge_colors.h:380