Blender V4.3
edge_lengths.cpp
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2013 Alec Jacobson
2 * 2023 Blender Authors
3 *
4 * SPDX-License-Identifier: MPL-2.0 */
5
10#include "BLI_task.hh"
11
12#include "edge_lengths.h"
13
14namespace slim {
15
16template<typename DerivedV, typename DerivedF, typename DerivedL>
17inline void edge_lengths(const Eigen::PlainObjectBase<DerivedV> &V,
18 const Eigen::PlainObjectBase<DerivedF> &F,
19 Eigen::PlainObjectBase<DerivedL> &L)
20{
22 L = L.array().sqrt().eval();
23}
24
25template<typename DerivedV, typename DerivedF, typename DerivedL>
26inline void squared_edge_lengths(const Eigen::PlainObjectBase<DerivedV> &V,
27 const Eigen::PlainObjectBase<DerivedF> &F,
28 Eigen::PlainObjectBase<DerivedL> &L)
29{
30 using namespace std;
31 const int m = F.rows();
32 assert(F.cols() == 3);
33
34 L.resize(m, 3);
35
36 /* Loop over faces. */
37 using namespace blender;
38 threading::parallel_for(IndexRange(m), 1000, [&V, &F, &L](const IndexRange range) {
39 for (const int i : range) {
40 L(i, 0) = (V.row(F(i, 1)) - V.row(F(i, 2))).squaredNorm();
41 L(i, 1) = (V.row(F(i, 2)) - V.row(F(i, 0))).squaredNorm();
42 L(i, 2) = (V.row(F(i, 0)) - V.row(F(i, 1))).squaredNorm();
43 }
44 });
45}
46
47} // namespace slim
IndexRange range
#define F
#define L
void edge_lengths(const Eigen::PlainObjectBase< DerivedV > &V, const Eigen::PlainObjectBase< DerivedF > &F, Eigen::PlainObjectBase< DerivedL > &L)
void squared_edge_lengths(const Eigen::PlainObjectBase< DerivedV > &V, const Eigen::PlainObjectBase< DerivedF > &F, Eigen::PlainObjectBase< DerivedL > &L)
CCL_NAMESPACE_BEGIN struct Window V