31#if defined(DECHelpers_RECURSES)
32#error Recursive header files inclusion detected in DECHelpers.h
35#define DECHelpers_RECURSES
37#if !defined DECHelpers_h
44#include "DGtal/base/Common.h"
45#include "DGtal/dec/Duality.h"
46#include "DGtal/dec/DiscreteExteriorCalculus.h"
58 template <
typename Calculus, DGtal::Dimension dim, DGtal::Duality duality>
63 typedef typename Calculus::LinearAlgebraBackend::Triplet Triplet;
64 typedef typename Calculus::Index
Index;
65 typedef std::vector<Triplet> Triplets;
69 triplets.emplace_back( index, index, kform.
myContainer(index) );
71 ope.myContainer.setFromTriplets(triplets.begin(), triplets.end());
80 template <
typename Calculus>
84 auto M01 = calculus.template derivative<0,DGtal::PRIMAL>();
85 M01.myContainer = 0.5 * M01.myContainer.cwiseAbs();
93 template <
typename Calculus>
97 auto M12 = calculus.template derivative<1,DGtal::PRIMAL>();
98 M12.myContainer = 0.25 * M12.myContainer.cwiseAbs();
106 template <
typename Calculus>
110 BOOST_STATIC_ASSERT( Calculus::dimensionEmbedded == 2 );
111 BOOST_STATIC_ASSERT( Calculus::dimensionAmbient == 3 );
115 typedef typename Calculus::LinearAlgebraBackend::SparseMatrix
SparseMatrix;
116 typedef typename Calculus::LinearAlgebraBackend::Triplet Triplet;
117 typedef typename Calculus::KSpace
KSpace;
118 typedef typename Calculus::Index
Index;
119 typedef typename Calculus::Cell
Cell;
120 typedef typename Calculus::Scalar Scalar;
121 typedef typename Calculus::Point
Point;
125 const KSpace& kspace = calculus.myKSpace;
127 const std::vector<Point> deltas = {
128 Point(0,1,1),
Point(0,-1,1),
Point(0,-1,-1),
Point(0,1,-1),
129 Point(1,0,1),
Point(-1,0,1),
Point(-1,0,-1),
Point(1,0,-1),
130 Point(1,1,0),
Point(-1,1,0),
Point(-1,-1,0),
Point(1,-1,0)
133 std::vector<Triplet> triplets;
134 for (
Index index_point=0; index_point<calculus.kFormLength(0,
PRIMAL); index_point++)
137 ASSERT( kspace.
uDim(point) == 0 );
139 std::vector<Index> indexes_surfel;
140 for (
const Point delta : deltas)
143 ASSERT( kspace.
uDim(surfel) == 2 );
144 if (calculus.containsCell(surfel))
145 indexes_surfel.push_back(calculus.getCellIndex(surfel));
147 ASSERT( indexes_surfel.size() > 2 );
149 const double weight = 1/
static_cast<Scalar
>(indexes_surfel.size());
150 for (
const Index index_surfel : indexes_surfel)
151 triplets.emplace_back( index_point, index_surfel, weight );
156 matrix.setFromTriplets(triplets.begin(), triplets.end());
158 return Operator(calculus, matrix);
171#undef DECHelpers_RECURSES
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
Cell unsigns(const SCell &p) const
Creates an unsigned cell from a signed one.
const Point & uKCoords(const Cell &c) const
Return its Khalimsky coordinates.
Cell uCell(const PreCell &c) const
From an unsigned cell, returns an unsigned cell lying into this Khalismky space.
Dimension uDim(const Cell &p) const
Return the dimension of the cell [p].
Aim: LinearOperator represents discrete linear operator between discrete kforms in the DEC package.
DGtal::LinearOperator< Calculus, dim, duality, dim, duality > diagonal(const DGtal::KForm< Calculus, dim, duality > &kform)
DGtal::LinearOperator< Calculus, 0, DGtal::PRIMAL, 1, DGtal::PRIMAL > averageOperator01(const Calculus &calculus)
DGtal::LinearOperator< Calculus, 2, DGtal::PRIMAL, 0, DGtal::PRIMAL > averageOperator20(const Calculus &calculus)
DGtal is the top-level namespace which contains all DGtal functions and types.
EigenLinearAlgebraBackend::SparseMatrix SparseMatrix