25 #include "DECExamplesCommon.h"
29 #include "DGtal/math/linalg/EigenSupport.h"
30 #include "DGtal/dec/DiscreteExteriorCalculus.h"
31 #include "DGtal/dec/DiscreteExteriorCalculusSolver.h"
32 #include "DGtal/dec/DiscreteExteriorCalculusFactory.h"
35 #include "DGtal/io/boards/Board2D.h"
36 #include "DGtal/io/readers/GenericReader.h"
39 using namespace DGtal;
55 Calculus
calculus = CalculusFactory::createFromDigitalSet(generateRingSet(
domain),
false);
67 board.
saveSVG(
"usage_calculus_without_border.svg");
72 Calculus
calculus = CalculusFactory::createFromDigitalSet(generateRingSet(
domain),
true);
86 board.
saveSVG(
"usage_calculus_with_border.svg");
97 Calculus::PrimalForm0 primal_zero_form(
calculus);
101 const Calculus::Scalar& value = Z2i::l2Metric(
calculus.myKSpace.sKCoords(cell), center)/2;
102 primal_zero_form.myContainer(index) = value;
107 const Calculus::PrimalForm0 foo = 2 * primal_zero_form + primal_zero_form;
114 board << primal_zero_form;
115 board.
saveSVG(
"usage_primal_zero_form.svg");
120 const Calculus::PrimalDerivative0 primal_zero_derivative =
calculus.derivative<0,
PRIMAL>();
121 const Calculus::PrimalForm1 primal_one_form = primal_zero_derivative * primal_zero_form;
122 const Calculus::PrimalVectorField primal_vector_field =
calculus.
sharp(primal_one_form);
129 board << primal_one_form;
130 board << primal_vector_field;
131 board.
saveSVG(
"usage_primal_one_form.svg");
136 const Calculus::PrimalForm1 flat_sharp_primal_one_form =
calculus.
flat(primal_vector_field);
137 const Calculus::PrimalVectorField sharp_flat_primal_vector_field =
calculus.
sharp(flat_sharp_primal_one_form);
144 board << flat_sharp_primal_one_form;
145 board << sharp_flat_primal_vector_field;
146 board.
saveSVG(
"usage_primal_one_form_sharp_flat.svg");
151 const Calculus::PrimalHodge1 primal_one_hodge =
calculus.hodge<1,
PRIMAL>();
152 const Calculus::DualForm1 dual_one_form = primal_one_hodge * primal_zero_derivative * primal_zero_form;
153 const Calculus::DualVectorField dual_vector_field =
calculus.
sharp(dual_one_form);
160 board << dual_one_form;
161 board << dual_vector_field;
162 board << primal_vector_field;
163 board.
saveSVG(
"usage_primal_one_form_hodge.svg");
172 Calculus::DualForm0 dual_zero_form(
calculus);
176 const Calculus::Scalar& value = Z2i::l2Metric(
calculus.myKSpace.sKCoords(cell), center)/2;
177 dual_zero_form.myContainer(index) = value;
184 board << dual_zero_form;
185 board.
saveSVG(
"usage_dual_zero_form.svg");
189 const Calculus::DualDerivative0 dual_zero_derivative =
calculus.derivative<0,
DUAL>();
190 const Calculus::DualForm1 dual_one_form = dual_zero_derivative * dual_zero_form;
191 const Calculus::DualVectorField dual_vector_field =
calculus.
sharp(dual_one_form);
197 board << dual_one_form;
198 board << dual_vector_field;
199 board.
saveSVG(
"usage_dual_one_form.svg");
203 const Calculus::DualForm1 flat_sharp_dual_one_form =
calculus.
flat(dual_vector_field);
204 const Calculus::DualVectorField sharp_flat_dual_vector_field = -
calculus.
sharp(flat_sharp_dual_one_form);
210 board << flat_sharp_dual_one_form;
211 board << -sharp_flat_dual_vector_field;
212 board.
saveSVG(
"usage_dual_one_form_sharp_flat.svg");
216 const Calculus::DualHodge1 dual_one_hodge =
calculus.hodge<1,
DUAL>();
217 const Calculus::PrimalForm1 primal_one_form = dual_one_hodge * dual_zero_derivative * dual_zero_form;
218 const Calculus::PrimalVectorField primal_vector_field =
calculus.
sharp(primal_one_form);
224 board << primal_one_form;
225 board << primal_vector_field;
226 board << dual_vector_field;
227 board.
saveSVG(
"usage_dual_one_form_hodge.svg");
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Aim: This class provides static members to create DEC structures from various other DGtal structures.
Aim: DiscreteExteriorCalculus represents a calculus in the dec package. This is the main structure in...
DenseMatrix sharp(const Face f) const
DenseMatrix flat(const Face f) const
void beginBlock(const std::string &keyword="")
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Point center(const std::vector< Point > &points)
DGtal is the top-level namespace which contains all DGtal functions and types.
int main(int argc, char **argv)