2023-06-15 13:09:04 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2000 `Bruno Levy <levy@loria.fr>`
|
2023-08-16 00:20:26 +10:00
|
|
|
* SPDX-FileCopyrightText: 2023 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
2023-06-15 13:09:04 +10:00
|
|
|
*
|
2012-12-22 18:25:01 +00:00
|
|
|
* The Original Code is:
|
2023-06-15 13:09:04 +10:00
|
|
|
* - OGF/Graphite: Geometry and Graphics Programming Library + Utilities.
|
|
|
|
|
*/
|
2008-04-30 15:41:54 +00:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup freestyle
|
2012-12-22 18:25:01 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "Geom.h"
|
|
|
|
|
|
|
|
|
|
#include "../system/FreestyleConfig.h"
|
|
|
|
|
|
2024-11-13 13:39:49 +01:00
|
|
|
#include "MEM_guardedalloc.h"
|
2013-05-13 22:58:27 +00:00
|
|
|
|
2013-04-09 00:46:49 +00:00
|
|
|
namespace Freestyle {
|
|
|
|
|
|
2008-04-30 15:41:54 +00:00
|
|
|
using namespace Geometry;
|
2012-12-22 18:25:01 +00:00
|
|
|
|
2008-04-30 15:41:54 +00:00
|
|
|
namespace OGF {
|
|
|
|
|
|
2012-12-22 18:25:01 +00:00
|
|
|
template<class T> inline void ogf_swap(T &x, T &y)
|
|
|
|
|
{
|
|
|
|
|
T z = x;
|
|
|
|
|
x = y;
|
|
|
|
|
y = z;
|
|
|
|
|
}
|
2008-04-30 15:41:54 +00:00
|
|
|
|
|
|
|
|
//_________________________________________________________
|
|
|
|
|
|
2012-12-22 18:25:01 +00:00
|
|
|
/**
|
2016-07-02 10:02:04 +10:00
|
|
|
* NormalCycle evaluates the curvature tensor in function
|
|
|
|
|
* of a set of dihedral angles and associated vectors.
|
|
|
|
|
* Reference:
|
|
|
|
|
* Restricted Delaunay Triangulation and Normal Cycle,
|
|
|
|
|
* D. Cohen-Steiner and J.M. Morvan,
|
|
|
|
|
* SOCG 2003
|
|
|
|
|
*/
|
2014-04-17 14:19:10 +09:00
|
|
|
class NormalCycle {
|
2012-12-22 18:25:01 +00:00
|
|
|
public:
|
|
|
|
|
void begin();
|
|
|
|
|
void end();
|
|
|
|
|
/**
|
2021-07-03 23:08:40 +10:00
|
|
|
* NOTE: the specified edge vector needs to be pre-clipped by the neighborhood.
|
2012-12-22 18:25:01 +00:00
|
|
|
*/
|
|
|
|
|
void accumulate_dihedral_angle(const Vec3r &edge, real angle, real neigh_area = 1.0);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-12-22 18:25:01 +00:00
|
|
|
const Vec3r &eigen_vector(int i) const
|
|
|
|
|
{
|
|
|
|
|
return axis_[i_[i]];
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-12-22 18:25:01 +00:00
|
|
|
real eigen_value(int i) const
|
|
|
|
|
{
|
|
|
|
|
return eigen_value_[i_[i]];
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-12-22 18:25:01 +00:00
|
|
|
const Vec3r &N() const
|
|
|
|
|
{
|
|
|
|
|
return eigen_vector(2);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-12-22 18:25:01 +00:00
|
|
|
const Vec3r &Kmax() const
|
|
|
|
|
{
|
|
|
|
|
return eigen_vector(1);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-12-22 18:25:01 +00:00
|
|
|
const Vec3r &Kmin() const
|
|
|
|
|
{
|
|
|
|
|
return eigen_vector(0);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-12-22 18:25:01 +00:00
|
|
|
real n() const
|
|
|
|
|
{
|
|
|
|
|
return eigen_value(2);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-12-22 18:25:01 +00:00
|
|
|
real kmax() const
|
|
|
|
|
{
|
|
|
|
|
return eigen_value(1);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-12-22 18:25:01 +00:00
|
|
|
real kmin() const
|
|
|
|
|
{
|
|
|
|
|
return eigen_value(0);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-12-22 18:25:01 +00:00
|
|
|
private:
|
2013-04-10 22:49:50 +00:00
|
|
|
/* UNUSED */
|
|
|
|
|
// real center_[3];
|
2012-12-22 18:25:01 +00:00
|
|
|
Vec3r axis_[3];
|
|
|
|
|
real eigen_value_[3];
|
|
|
|
|
real M_[6];
|
|
|
|
|
int i_[3];
|
2013-05-13 22:58:27 +00:00
|
|
|
|
|
|
|
|
MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:OGF:NormalCycle")
|
2012-12-22 18:25:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
inline void NormalCycle::accumulate_dihedral_angle(const Vec3r &edge,
|
|
|
|
|
const double beta,
|
|
|
|
|
double neigh_area)
|
|
|
|
|
{
|
|
|
|
|
double s = beta * neigh_area / edge.norm();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-12-22 18:25:01 +00:00
|
|
|
M_[0] += s * edge.x() * edge.x();
|
|
|
|
|
M_[1] += s * edge.x() * edge.y();
|
|
|
|
|
M_[2] += s * edge.y() * edge.y();
|
|
|
|
|
M_[3] += s * edge.x() * edge.z();
|
|
|
|
|
M_[4] += s * edge.y() * edge.z();
|
|
|
|
|
M_[5] += s * edge.z() * edge.z();
|
2008-04-30 15:41:54 +00:00
|
|
|
}
|
|
|
|
|
|
2012-12-22 18:25:01 +00:00
|
|
|
//_________________________________________________________
|
|
|
|
|
|
|
|
|
|
} // namespace OGF
|
|
|
|
|
|
2013-04-09 00:46:49 +00:00
|
|
|
} /* namespace Freestyle */
|