Visual Computing Library
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 "bases/component.h"
27
28#include <vclib/concepts/mesh/components/principal_curvature.h>
29#include <vclib/space/core/principal_curvature.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 if constexpr (HasPrincipalCurvature<Element>) {
117 if (isPrincipalCurvatureAvailableOn(e)) {
119 e.principalCurvature().template cast<Scalar>();
120 }
121 }
122 }
123
124 void serialize(std::ostream& os) const
125 {
126 principalCurvature().serialize(os);
127 }
128
129 void deserialize(std::istream& is) { principalCurvature().deserialize(is); }
130};
131
132/* Detector function to check if a class has PrincipalCurvature available */
133
147bool isPrincipalCurvatureAvailableOn(const ElementConcept auto& element)
148{
149 return isComponentAvailableOn<CompId::PRINCIPAL_CURVATURE>(element);
150}
151
152/* Specialization Aliases */
153
166template<typename ElementType = void, bool OPT = false>
168
181template<typename ElementType = void, bool OPT = false>
183
184} // namespace vcl::comp
185
186#endif // VCL_MESH_COMPONENTS_PRINCIPAL_CURVATURE_H
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 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
HasPrincipalCurvature concept is satisfied only if a Element class provides the types and member func...
Definition principal_curvature.h:48