23#ifndef VCL_MESH_COMPONENTS_TANGENT_H
24#define VCL_MESH_COMPONENTS_TANGENT_H
26#include "base/component.h"
27#include "base/predicates.h"
29#include <vclib/mesh/elements/base/base.h>
30#include <vclib/mesh/exceptions.h>
32#include <vclib/base.h>
33#include <vclib/space/core.h>
62template<Po
intConcept P,
typename ParentElemType =
void,
bool OPT = false>
65 Tangent<P, ParentElemType, OPT>,
69 !std::is_same_v<ParentElemType, void>,
72 using Base = Component<
77 !std::is_same_v<ParentElemType, void>,
93 if constexpr (!Base::IS_VERTICAL) {
108 void init() { Base::data().second =
true; }
116 const P&
tangent()
const {
return Base::data().first; }
167 " Normal Component is not enabled.");
174 template<
typename Element>
175 void importFrom(
const Element& e,
bool =
true);
177 void serialize(std::ostream&
os)
const
183 void deserialize(std::istream& is)
210concept HasTangent = TTB::IsDerivedFromSpecializationOfV<T, Tangent>;
228template<Po
intConcept P,
typename ParentElemType,
bool OPT>
229template<
typename Element>
230void Tangent<P, ParentElemType, OPT>::importFrom(
const Element& e,
bool)
232 using ScalarType = TangentType::ScalarType;
234 if (isTangentAvailableOn(e)) {
235 tangent() = e.tangent().template cast<ScalarType>();
236 tangentRightHanded() = e.tangentRightHanded();
254bool isTangentAvailableOn(
const auto& element)
274template<
typename Scalar,
typename ElementType =
void,
bool OPT = false>
289template<
typename ElementType =
void,
bool OPT = false>
304template<
typename ElementType =
void,
bool OPT = false>
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
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
Exception thrown when a mesh/element component is missing (not enabled).
Definition exceptions.h:108
The Tangent class represents a N-Dimensional tangent vector that will be part of an Element (e....
Definition tangent.h:71
const P & tangent() const
Returns a const reference of the tangent of the element.
Definition tangent.h:116
P & tangent()
Returns a reference of the tangent of the element.
Definition tangent.h:122
void init()
Initializes the tangent to (0, 0, 0) right handed.
Definition tangent.h:108
bool & tangentRightHanded()
Returns a reference to the boolean that indicates if the tangent is right handed.
Definition tangent.h:136
P TangentType
Expose the type of the Tangent.
Definition tangent.h:84
bool tangentRightHanded() const
Returns true if the tangent is right handed, false otherwise.
Definition tangent.h:128
Tangent()
Initilizes the Tangent to (0, 0, 0) right handed.
Definition tangent.h:91
P bitangent() const
Computes and returns the bitangent vector using the tangent and normal vectors.
Definition tangent.h:151
A concept that checks whether a type T (that should be a Element) has the Tangent component (inherits...
Definition tangent.h:223
A concept that checks whether a type T (that should be a Element) has the Tangent component (inherits...
Definition tangent.h:210
Evaluates to true if the type T is a component that is stored vertically in its element container,...
Definition component.h:74