31 #if defined(DECHelpers_RECURSES)
32 #error Recursive header files inclusion detected in DECHelpers.h
33 #else // defined(DECHelpers_RECURSES)
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;
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 );
116 typedef typename Calculus::LinearAlgebraBackend::Triplet Triplet;
120 typedef typename Calculus::Scalar Scalar;
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);
169 #endif // !defined DECHelpers_h
171 #undef DECHelpers_RECURSES
172 #endif // else defined(DECHelpers_RECURSES)