Visual Computing Library  devel
Loading...
Searching...
No Matches
principal_curvature.h
1/*****************************************************************************
2 * VCLib *
3 * Visual Computing Library *
4 * *
5 * Copyright(C) 2021-2025 *
6 * Visual Computing Lab *
7 * ISTI - Italian National Research Council *
8 * *
9 * All rights reserved. *
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the Mozilla Public License Version 2.0 as published *
13 * by the Mozilla Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 * This program is distributed in the hope that it will be useful, *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19 * Mozilla Public License Version 2.0 *
20 * (https://www.mozilla.org/en-US/MPL/2.0/) for more details. *
21 ****************************************************************************/
22
23#ifndef VCL_MESH_COMPONENTS_PRINCIPAL_CURVATURE_H
24#define VCL_MESH_COMPONENTS_PRINCIPAL_CURVATURE_H
25
26#include "base/component.h"
27#include "base/predicates.h"
28
29#include <vclib/space/core.h>
30
31namespace vcl::comp {
32
62template<typename Scalar, typename ParentElemType = void, bool OPT = false>
64 public Component<
65 PrincipalCurvature<Scalar, ParentElemType, OPT>,
66 CompId::PRINCIPAL_CURVATURE,
67 vcl::PrincipalCurvature<Scalar>,
68 ParentElemType,
69 !std::is_same_v<ParentElemType, void>,
70 OPT>
71{
72 using Base = Component<
74 CompId::PRINCIPAL_CURVATURE,
77 !std::is_same_v<ParentElemType, void>,
78 OPT>;
79
80public:
85
86 /* Constructors */
87
91 PrincipalCurvature() = default;
92
93 /* Member functions */
94
101 {
102 return Base::data();
103 }
104
109 PrincipalCurvatureType& principalCurvature() { return Base::data(); }
110
111protected:
112 // Component interface functions
113 template<typename Element>
114 void importFrom(const Element& e, bool = true);
115
116 void serialize(std::ostream& os) const
117 {
119 }
120
121 void deserialize(std::istream& is) { principalCurvature().deserialize(is); }
122};
123
124/* concepts */
125
144template<typename T>
146 TTB::IsDerivedFromSpecializationOfV<T, PrincipalCurvature>;
147
158template<typename T>
162
163/* importFrom function */
164
165template<typename Scalar, typename ParentElemType, bool OPT>
166template<typename Element>
167void PrincipalCurvature<Scalar, ParentElemType, OPT>::importFrom(
168 const Element& e,
169 bool)
170{
171 if constexpr (HasPrincipalCurvature<Element>) {
172 if (isPrincipalCurvatureAvailableOn(e)) {
173 principalCurvature() =
174 e.principalCurvature().template cast<Scalar>();
175 }
176 }
177}
178
179/* Detector function to check if a class has PrincipalCurvature available */
180
193bool isPrincipalCurvatureAvailableOn(const auto& element)
194{
196}
197
198/* Specialization Aliases */
199
212template<typename ElementType = void, bool OPT = false>
214
227template<typename ElementType = void, bool OPT = false>
229
230} // namespace vcl::comp
231
232#endif // VCL_MESH_COMPONENTS_PRINCIPAL_CURVATURE_H
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
The PrincipalCurvature class represents a component that stores the principal curvature directions an...
Definition principal_curvature.h:71
const PrincipalCurvatureType & principalCurvature() const
Returns a const reference of the principal curvature of the element.
Definition principal_curvature.h:100
PrincipalCurvature()=default
Initilizes the PrincipalCurvature values to 0.
PrincipalCurvatureType & principalCurvature()
Returns a reference of the principal curvature of the element.
Definition principal_curvature.h:109
A concept that checks whether a type T (that should be a Element) has the PrincipalCurvature componen...
Definition principal_curvature.h:159
A concept that checks whether a type T (that should be a Element) has the PrincipalCurvature componen...
Definition principal_curvature.h:145
Evaluates to true if the type T is a component that is stored vertically in its element container,...
Definition component.h:74