Blender V5.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
9
10#include "BLI_task.hh"
11
12#include "edge_lengths.h"
13
14#include <cassert>
15
16namespace slim {
17
18template<typename DerivedV, typename DerivedF, typename DerivedL>
19inline void edge_lengths(const Eigen::PlainObjectBase<DerivedV> &V,
20 const Eigen::PlainObjectBase<DerivedF> &F,
21 Eigen::PlainObjectBase<DerivedL> &L)
22{
24 L = L.array().sqrt().eval();
25}
26
27template<typename DerivedV, typename DerivedF, typename DerivedL>
28inline void squared_edge_lengths(const Eigen::PlainObjectBase<DerivedV> &V,
29 const Eigen::PlainObjectBase<DerivedF> &F,
30 Eigen::PlainObjectBase<DerivedL> &L)
31{
32 using namespace std;
33 const int m = F.rows();
34 assert(F.cols() == 3);
35
36 L.resize(m, 3);
37
38 /* Loop over faces. */
39 using namespace blender;
40 threading::parallel_for(IndexRange(m), 1000, [&V, &F, &L](const IndexRange range) {
41 for (const int i : range) {
42 L(i, 0) = (V.row(F(i, 1)) - V.row(F(i, 2))).squaredNorm();
43 L(i, 1) = (V.row(F(i, 2)) - V.row(F(i, 0))).squaredNorm();
44 L(i, 2) = (V.row(F(i, 0)) - V.row(F(i, 1))).squaredNorm();
45 }
46 });
47}
48
49} // namespace slim
#define assert(assertion)
#define F
#define L
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
Definition BLI_task.hh:69
BMesh Iterators.
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