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_SPACE_CORE_PRINCIPAL_CURVATURE_H
24#define VCL_SPACE_CORE_PRINCIPAL_CURVATURE_H
25
26#include "point.h"
27
28namespace vcl {
29
42template<typename Scalar>
44{
45 Point3<Scalar> mDir1, mDir2;
46 Scalar mK1 = 0, mK2 = 0;
47
48public:
52 using ScalarType = Scalar;
53
58
70 template<typename S>
71 auto cast() const
72 {
73 if constexpr (std::is_same<Scalar, S>::value) {
74 return *this;
75 }
76 else {
78 tmp.maxDir() = mDir1.template cast<S>();
79 tmp.minDir() = mDir2.template cast<S>();
80 tmp.maxValue() = mK1;
81 tmp.minValue() = mK2;
82 return tmp;
83 }
84 }
85
90 const Point3<Scalar>& maxDir() const { return mDir1; }
91
96 Point3<Scalar>& maxDir() { return mDir1; }
97
102 const Point3<Scalar>& minDir() const { return mDir2; }
103
108 Point3<Scalar>& minDir() { return mDir2; }
109
114 const Scalar& maxValue() const { return mK1; }
115
120 Scalar& maxValue() { return mK1; }
121
126 const Scalar& minValue() const { return mK2; }
127
132 Scalar& minValue() { return mK2; }
133
134 void serialize(std::ostream& os) const
135 {
136 mDir1.serialize(os);
137 mDir1.serialize(os);
138 vcl::serialize(os, mK1);
139 vcl::serialize(os, mK2);
140 }
141
142 void deserialize(std::istream& is)
143 {
144 mDir1.deserialize(is);
145 mDir2.deserialize(is);
146 vcl::deserialize(is, mK1);
147 vcl::deserialize(is, mK2);
148 }
149};
150
151/* Specialization Aliases */
152
156using PrincipalCurvaturef = PrincipalCurvature<float>;
157
161using PrincipalCurvatured = PrincipalCurvature<double>;
162
163} // namespace vcl
164
165#endif // VCL_SPACE_CORE_PRINCIPAL_CURVATURE_H
The PrincipalCurvature class stores the principal curvature directions and values at a point on a 3D ...
Definition principal_curvature.h:44
const Point3< Scalar > & minDir() const
Returns a const reference to the minimum curvature direction.
Definition principal_curvature.h:102
Scalar & maxValue()
Returns a reference to the maximum curvature value.
Definition principal_curvature.h:120
const Point3< Scalar > & maxDir() const
Returns a const reference to the maximum curvature direction.
Definition principal_curvature.h:90
Scalar ScalarType
The scalar type of the curvature values.
Definition principal_curvature.h:52
Point3< Scalar > & minDir()
Returns a reference to the minimum curvature direction.
Definition principal_curvature.h:108
auto cast() const
Casts the PrincipalCurvature object to a different scalar type.
Definition principal_curvature.h:71
const Scalar & minValue() const
Returns a const reference to the minimum curvature value.
Definition principal_curvature.h:126
Scalar & minValue()
Returns a reference to the minimum curvature value.
Definition principal_curvature.h:132
const Scalar & maxValue() const
Returns a const reference to the maximum curvature value.
Definition principal_curvature.h:114
Point3< Scalar > & maxDir()
Returns a reference to the maximum curvature direction.
Definition principal_curvature.h:96
PrincipalCurvature()
Empty constructor. Directions and values are set to 0.
Definition principal_curvature.h:57
A class representing a line segment in n-dimensional space. The class is parameterized by a PointConc...
Definition segment.h:43
PrincipalCurvature< float, ElementType, OPT > PrincipalCurvaturef
Definition principal_curvature.h:167
PrincipalCurvature< double, ElementType, OPT > PrincipalCurvatured
Definition principal_curvature.h:182