Skip to content

Commit

Permalink
Changed RedeclareTypes and RedeclareConstants macros
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Marie Mirebeau authored and Jean-Marie Mirebeau committed Sep 6, 2018
1 parent c573b4a commit d2a387e
Show file tree
Hide file tree
Showing 199 changed files with 22,827 additions and 95 deletions.
6 changes: 3 additions & 3 deletions Headers/Base/GeodesicDiscreteSolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
template<typename TTraits> struct GeodesicDiscreteSolver
: HamiltonFastMarching<TTraits>::GeodesicSolverInterface {
typedef TTraits Traits; typedef HamiltonFastMarching<Traits> HFM;
Redeclare7Types(FromTraits,DiscreteType,ScalarType,ShortType,IndexType,OffsetType,VectorType,PointType)
Redeclare6Types(FromHFM,DiscreteFlowType,MultiplierType,IndexCRef,DifferenceType,HFMI,GeodesicSolverInterface);
Redeclare7Types(Traits,DiscreteType,ScalarType,ShortType,IndexType,OffsetType,VectorType,PointType)
Redeclare6Types(HFM,DiscreteFlowType,MultiplierType,IndexCRef,DifferenceType,HFMI,GeodesicSolverInterface);
template<typename E, size_t n> using Array = typename Traits::template Array<E,n>;
Redeclare1Constant(FromTraits,Dimension);
Redeclare1Constant(Traits,Dimension);

ScalarType geodesicStep = 0.25;
ScalarType weightThreshold = 0.0001; // smaller contributions eliminated
Expand Down
8 changes: 4 additions & 4 deletions Headers/Base/GeodesicODESolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
template <typename TTraits> struct GeodesicODESolver
: HamiltonFastMarching<TTraits>::GeodesicSolverInterface {
typedef TTraits Traits; typedef HamiltonFastMarching<Traits> HFM;
Redeclare7Types(FromTraits,DiscreteType,ScalarType,ShortType,IndexType,OffsetType,VectorType,PointType)
Redeclare2Types(FromHFM,HFMI,GeodesicSolverInterface);
Redeclare7Types(Traits,DiscreteType,ScalarType,ShortType,IndexType,OffsetType,VectorType,PointType)
Redeclare2Types(HFM,HFMI,GeodesicSolverInterface);

Redeclare1Type(FromHFM, FlowDataType);
Redeclare1Type(HFM, FlowDataType);
template<typename E, size_t n> using Array = typename Traits::template Array<E,n>;
Redeclare1Constant(FromTraits,Dimension);
Redeclare1Constant(Traits,Dimension);

ScalarType geodesicStep = 0.25;
DiscreteType targetTolerance = 6;
Expand Down
6 changes: 3 additions & 3 deletions Headers/Base/HFMInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
template<typename TTraits> struct HFMInterface {
typedef TTraits Traits;
typedef HamiltonFastMarching<Traits> HFM;
Redeclare4Types(FromHFM,ActiveNeighFlagType,StencilDataType,ExtraAlgorithmInterface,GeodesicSolverInterface);
Redeclare5Types(FromTraits,DiscreteType,ScalarType,PointType,VectorType,IndexType);
Redeclare2Constants(FromTraits,Dimension,mathPi)
Redeclare4Types(HFM,ActiveNeighFlagType,StencilDataType,ExtraAlgorithmInterface,GeodesicSolverInterface);
Redeclare5Types(Traits,DiscreteType,ScalarType,PointType,VectorType,IndexType);
Redeclare2Constants(Traits,Dimension,mathPi)

template<typename E, size_t n> using Array = typename Traits::template Array<E,n>;
template<typename E> using DataSource = typename Traits::template DataSource<E>;
Expand Down
16 changes: 8 additions & 8 deletions Headers/Base/HFMInterface.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ template<typename T> template<typename Dummy> struct
HFMInterface<T>::SpecializationsDefault<true,Dummy> {
typedef HFMInterface<T> HFMI;
typedef typename HFMI::HFM HFM;
Redeclare6Types(FromHFM,ScalarType,Traits,MultiplierType,PointType,IndexType,DiscreteType)
Redeclare2Constants(FromTraits,mathPi,Dimension)
Redeclare6Types(HFM,ScalarType,Traits,MultiplierType,PointType,IndexType,DiscreteType)
Redeclare2Constants(Traits,mathPi,Dimension)

static const int DimDep =Traits::nStencilDependencies, DimIndep = Dimension-DimDep;
template<typename E> using DataSource = typename HFM::template DataSource<E>;
Expand Down Expand Up @@ -95,8 +95,8 @@ template<typename T> template<typename Dummy> struct
HFMInterface<T>::SpecializationsDefault<false,Dummy> {
typedef HFMInterface<T> HFMI;
typedef typename HFMI::HFM HFM;
Redeclare3Types(FromHFM,ScalarType,PointType,IndexType)
Redeclare1Constant(FromHFM,Dimension)
Redeclare3Types(HFM,ScalarType,PointType,IndexType)
Redeclare1Constant(HFM,Dimension)

template<typename E> using DataSource = typename HFM::template DataSource<E>;
template<typename E> using DataSource_Value = typename HFMI::template DataSource_Value<E>;
Expand Down Expand Up @@ -172,8 +172,8 @@ template<typename T> template<typename E> struct
HFMInterface<T>::DataSource_Indep<E,true> : DataSource<E> {
typedef typename HFMInterface<T>::HFM HFM;
typedef typename HFM::template DataSource<E>::ReturnType ReturnType;
Redeclare2Types(FromHFM,Traits,IndexType)
Redeclare1Constant(FromHFM,Dimension)
Redeclare2Types(HFM,Traits,IndexType)
Redeclare1Constant(HFM,Dimension)
typedef HFMInterface<T>::Array<E, Dimension-Traits::nStencilDependencies> ArrayType;
ArrayType values;
DataSource_Indep(ArrayType && _values):values(std::move(_values)){};
Expand All @@ -198,8 +198,8 @@ template<typename T> template<typename E> struct
HFMInterface<T>::DataSource_Dep<E,true> : DataSource<E> {
typedef typename HFMInterface<T>::HFM HFM;
typedef typename HFM::template DataSource<E>::ReturnType ReturnType;
Redeclare2Types(FromHFM,Traits,IndexType)
Redeclare1Constant(FromHFM,Dimension)
Redeclare2Types(HFM,Traits,IndexType)
Redeclare1Constant(HFM,Dimension)
typedef HFMInterface<T>::Array<E, Traits::nStencilDependencies> ArrayType;
ArrayType values;
DataSource_Dep(ArrayType && _values):values(std::move(_values)){};
Expand Down
10 changes: 5 additions & 5 deletions Headers/Base/HFM_ParamDefault.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
template<typename TTraits> template<typename Dummy> struct
HamiltonFastMarching<TTraits>::_ParamDefault<1,Dummy> : HFM::ParamInterface {
typedef HamiltonFastMarching<TTraits> HFM;
Redeclare6Types(FromHFM,PointType,VectorType,ScalarType,DiscreteType,HFMI,Traits);
Redeclare1Constant(FromHFM,Dimension)
Redeclare6Types(HFM,PointType,VectorType,ScalarType,DiscreteType,HFMI,Traits);
Redeclare1Constant(HFM,Dimension)
PointType origin = PointType::Constant(0);
// Two distinct scales, for "physical" and "bundle" parts respectively.
ScalarType gridScale=1, dependScale=1;
Expand Down Expand Up @@ -43,7 +43,7 @@ HamiltonFastMarching<TTraits>::_ParamDefault<1,Dummy> : HFM::ParamInterface {
template<typename TTraits> template<typename Dummy> struct
HamiltonFastMarching<TTraits>::_ParamDefault<0,Dummy> : HFM::ParamInterface {
typedef HamiltonFastMarching<TTraits> HFM;
Redeclare5Types(FromHFM,PointType,VectorType,ScalarType,HFMI,Traits);
Redeclare5Types(HFM,PointType,VectorType,ScalarType,HFMI,Traits);
PointType origin = PointType::Constant(0);
ScalarType gridScale=1;
virtual PointType ADim(const PointType & p) const override {
Expand All @@ -61,8 +61,8 @@ HamiltonFastMarching<TTraits>::_ParamDefault<0,Dummy> : HFM::ParamInterface {
template<typename TTraits> template<typename Dummy> struct
HamiltonFastMarching<TTraits>::_ParamDefault<2,Dummy> : HFM::ParamInterface {
typedef HamiltonFastMarching<TTraits> HFM;
Redeclare5Types(FromHFM,PointType,VectorType,ScalarType,HFMI,Traits);
Redeclare1Constant(FromHFM,Dimension)
Redeclare5Types(HFM,PointType,VectorType,ScalarType,HFMI,Traits);
Redeclare1Constant(HFM,Dimension)

PointType origin = PointType::Constant(0);
PointType gridScales = PointType::Constant(1);
Expand Down
24 changes: 11 additions & 13 deletions Headers/Base/HamiltonFastMarching.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
// Note : walls must not be taken into account at initialization with mult based.
*/

#define FromHFM(x) HFM:: x

// Silly replacement for a constexpr log. TODO : hide somewhere.

template<size_t i> struct FloorLog2 {static const size_t value = 1+FloorLog2<i/2>::value;};
Expand All @@ -40,9 +38,9 @@ template<typename T> struct HFMInterface;
template<typename TTraits>
struct HamiltonFastMarching {
typedef TTraits Traits;
Redeclare1Constant(FromTraits,Dimension)
Redeclare3Types(FromTraits,ScalarType,DiscreteType,ShortType)
Redeclare5Types(FromTraits,PointType,VectorType,IndexType,OffsetType,DifferenceType)
Redeclare1Constant(Traits,Dimension)
Redeclare3Types(Traits,ScalarType,DiscreteType,ShortType)
Redeclare5Types(Traits,PointType,VectorType,IndexType,OffsetType,DifferenceType)

typedef const IndexType & IndexCRef;
typedef const OffsetType & OffsetCRef;
Expand Down Expand Up @@ -179,10 +177,10 @@ StencilType {
template<typename T> template<typename Dummy>
struct HamiltonFastMarching<T>::_StencilDataType<true,Dummy>{
typedef HamiltonFastMarching<T> HFM;
Redeclare8Types(FromHFM,IndexCRef,OffsetCRef,StencilType,QuadType,DifferenceType,MultiplierType,Traits,FullIndexCRef)
Redeclare3Types(FromHFM,ParamInterface,HFMI,DomainType)
Redeclare6Types(FromTraits,DiscreteType,ScalarType,PointType,VectorType,IndexType,OffsetType)
Redeclare2Constants(FromTraits,Dimension,mathPi)
Redeclare8Types(HFM,IndexCRef,OffsetCRef,StencilType,QuadType,DifferenceType,MultiplierType,Traits,FullIndexCRef)
Redeclare3Types(HFM,ParamInterface,HFMI,DomainType)
Redeclare6Types(Traits,DiscreteType,ScalarType,PointType,VectorType,IndexType,OffsetType)
Redeclare2Constants(Traits,Dimension,mathPi)

typedef HFM::DataSource<MultiplierType> MultSourceType;
IndexType dims; // Needs value
Expand Down Expand Up @@ -221,10 +219,10 @@ struct HamiltonFastMarching<T>::_StencilDataType<true,Dummy>{
template<typename T> template<typename Dummy>
struct HamiltonFastMarching<T>::_StencilDataType<false,Dummy>{
typedef HamiltonFastMarching<T> HFM;
Redeclare8Types(FromHFM,IndexCRef,OffsetCRef,StencilType,QuadType,DifferenceType,Traits,FullIndexCRef,DomainType)
Redeclare3Types(FromHFM,ParamInterface,HFMI,MultiplierType)
Redeclare6Types(FromTraits,DiscreteType,ScalarType,PointType,VectorType,IndexType,OffsetType)
Redeclare2Constants(FromTraits,Dimension,mathPi)
Redeclare8Types(HFM,IndexCRef,OffsetCRef,StencilType,QuadType,DifferenceType,Traits,FullIndexCRef,DomainType)
Redeclare3Types(HFM,ParamInterface,HFMI,MultiplierType)
Redeclare6Types(Traits,DiscreteType,ScalarType,PointType,VectorType,IndexType,OffsetType)
Redeclare2Constants(Traits,Dimension,mathPi)

IndexType dims; // Needs value
virtual void SetStencil(IndexCRef, StencilType &) = 0; // Needs specialization
Expand Down
4 changes: 2 additions & 2 deletions Headers/Base/PeriodicGrid.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ struct Boundary_AllClosed {

template<typename TTraits> struct PeriodicGrid {
typedef TTraits Traits;
Redeclare4Types(FromTraits,DiscreteType,ScalarType,IndexType,PointType);
Redeclare1Constant(FromTraits,Dimension);
Redeclare4Types(Traits,DiscreteType,ScalarType,IndexType,PointType);
Redeclare1Constant(Traits,Dimension);
typedef const IndexType & IndexCRef;

DiscreteType LinearFromIndex(IndexCRef) const;
Expand Down
2 changes: 1 addition & 1 deletion Headers/DispatchAndRun.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ if(model== #modelName){ \
template<typename TTraits> struct HFMInterface2 {
typedef TTraits Traits;
typedef HamiltonFastMarching<Traits> HFM;
Redeclare4Types(FromHFM,ActiveNeighFlagType,StencilDataType,ExtraAlgorithmInterface,GeodesicSolverInterface);
Redeclare4Types(HFM,ActiveNeighFlagType,StencilDataType,ExtraAlgorithmInterface,GeodesicSolverInterface);

template<typename E, size_t n> using Array = typename Traits::template Array<E,n>;
template<typename E> using DataSource = typename Traits::template DataSource<E>;
Expand Down
10 changes: 5 additions & 5 deletions Headers/Experimental/AsymmetricQuadratic.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ void HalfDisk(ScalarType r, ScalarType delta, SymmetricMatrixType & D, VectorTyp
template<size_t VDimension>
struct TraitsAsymmetricQuadratic : TraitsBase<VDimension> {
typedef TraitsBase<VDimension> Superclass;
Redeclare1Type(FromSuperclass,DiscreteType)
Redeclare1Constant(FromSuperclass,Dimension)
Redeclare1Type(Superclass,DiscreteType)
Redeclare1Constant(Superclass,Dimension)
typedef typename Superclass::template Difference<0> DifferenceType;
static const DiscreteType SymDimension = (Dimension*(Dimension+1))/2;
static const DiscreteType nSymmetric=SymDimension, nForward=SymDimension;
Expand All @@ -114,9 +114,9 @@ template<size_t VDimension>
struct StencilAsymmetricQuadratic : HamiltonFastMarching<TraitsAsymmetricQuadratic<VDimension> >::StencilDataType {
typedef HamiltonFastMarching<TraitsAsymmetricQuadratic<VDimension> > HFM;
typedef typename HFM::StencilDataType Superclass;
Redeclare5Types(FromHFM,ParamDefault,ScalarType,Traits,VectorType,IndexType)
Redeclare4Types(FromHFM,StencilType,ParamInterface,HFMI,IndexCRef)
Redeclare1Constant(FromHFM,Dimension)
Redeclare5Types(HFM,ParamDefault,ScalarType,Traits,VectorType,IndexType)
Redeclare4Types(HFM,StencilType,ParamInterface,HFMI,IndexCRef)
Redeclare1Constant(HFM,Dimension)
ParamDefault param;
ScalarType eps = 0.3, epsRev = 0.2;

Expand Down
10 changes: 5 additions & 5 deletions Headers/Experimental/Differentiable.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
template<size_t VDimension>
struct TraitsIsotropicDiff : TraitsBase<VDimension> {
typedef TraitsBase<VDimension> Superclass;
Redeclare1Type(FromSuperclass,DiscreteType)
Redeclare1Constant(FromSuperclass,Dimension)
Redeclare1Type(Superclass,DiscreteType)
Redeclare1Constant(Superclass,Dimension)

typedef typename Superclass::template Difference<1> DifferenceType;
static const DiscreteType nForward = 2*Dimension;
Expand All @@ -33,8 +33,8 @@ template<size_t VDimension>
struct StencilIsotropicDiff : HamiltonFastMarching<TraitsIsotropicDiff<VDimension> >::StencilDataType {
typedef HamiltonFastMarching<TraitsIsotropicDiff<VDimension> > HFM;
typedef typename HFM::StencilDataType Superclass;
Redeclare5Types(FromHFM,ParamDefault,IndexType,StencilType,ParamInterface,HFMI)
Redeclare1Constant(FromHFM,Dimension)
Redeclare5Types(HFM,ParamDefault,IndexType,StencilType,ParamInterface,HFMI)
Redeclare1Constant(HFM,Dimension)
ParamDefault param;

virtual void SetStencil(const IndexType & index, StencilType & stencil) override {
Expand Down Expand Up @@ -157,7 +157,7 @@ void StencilRiemannDiff2::Setup(HFMI*that){
HFMInterface<TS,TH>::SpecializedStencil<StencilRiemannDiff2,Dummy> {
typedef HFMInterface<TS,TH> HFMI;
typedef TH HFM; typedef TS StencilDataType;
Redeclare5Types(FromHFM,StencilType,ScalarType,PointType,MultiplierType,OffsetType)
Redeclare5Types(HFM,StencilType,ScalarType,PointType,MultiplierType,OffsetType)
typedef HFMI::template DataSource<MultiplierType> MultSourceType;
typedef typename StencilDataType::ReductionType ReductionType;
typedef typename StencilDataType::SymmetricMatrixType SymmetricMatrixType;
Expand Down
4 changes: 2 additions & 2 deletions Headers/Experimental/IsotropicBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ struct StencilIsotropicBox2
: HamiltonFastMarching<TraitsIsotropicBox2<cond> >::StencilDataType {
typedef HamiltonFastMarching<TraitsIsotropicBox2<cond> > HFM;
typedef typename HFM::StencilDataType Superclass;
Redeclare4Types(FromSuperclass,IndexType,StencilType,ParamInterface,HFMI)
Redeclare4Types(Superclass,IndexType,StencilType,ParamInterface,HFMI)
typedef typename HFM::ParamDefault ParamType;
ParamType param;
virtual void SetStencil(const IndexType & index, StencilType & stencil) override {
Expand Down Expand Up @@ -111,7 +111,7 @@ struct StencilIsotropicBox3
: HamiltonFastMarching<TraitsIsotropicBox3<cond> >::StencilDataType {
typedef HamiltonFastMarching<TraitsIsotropicBox3<cond> > HFM;
typedef typename HFM::StencilDataType Superclass;
Redeclare4Types(FromSuperclass,IndexType,StencilType,ParamInterface,HFMI)
Redeclare4Types(Superclass,IndexType,StencilType,ParamInterface,HFMI)
typedef typename HFM::ParamDefault ParamType;
ParamType param;
virtual void SetStencil(const IndexType & index, StencilType & stencil) override {
Expand Down
4 changes: 2 additions & 2 deletions Headers/Experimental/PrescribedCurvature2.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ struct StencilElasticaExt2
: HamiltonFastMarching<TraitsElasticaExt2<nFejer> >::StencilDataType {
typedef HamiltonFastMarching<TraitsElasticaExt2<nFejer> > HFM;
typedef typename HFM::StencilDataType Superclass;
Redeclare7Types(FromSuperclass,Traits,ScalarType,IndexCRef,VectorType,StencilType,ParamInterface,HFMI)
Redeclare1Constant(FromTraits,mathPi)
Redeclare7Types(Superclass,Traits,ScalarType,IndexCRef,VectorType,StencilType,ParamInterface,HFMI)
Redeclare1Constant(Traits,mathPi)
typename HFM::ParamDefault param;
ScalarType eps=0.1;
typedef typename Traits::template DataSource<ScalarType> ScalarFieldType;
Expand Down
2 changes: 1 addition & 1 deletion Headers/Experimental/RiemannLifted.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ template<Boundary cond>
struct StencilRiemannLifted2 : HamiltonFastMarching<TraitsRiemannLifted2<cond> >::StencilDataType {
typedef HamiltonFastMarching<TraitsRiemannLifted2<cond> > HFM;
typedef typename HFM::StencilDataType Superclass;
Redeclare7Types(FromSuperclass,Traits,IndexType,StencilType,ParamInterface,HFMI,ScalarType,DiscreteType);
Redeclare7Types(Superclass,Traits,IndexType,StencilType,ParamInterface,HFMI,ScalarType,DiscreteType);
typedef typename Traits::template BasisReduction<2> ReductionType;
typedef typename ReductionType::SymmetricMatrixType Sym;
typedef LinearAlgebra::VectorPair<Sym,ScalarType> MetricElementType;
Expand Down
4 changes: 2 additions & 2 deletions Headers/ExtraAlgorithms/CommonStoppingCriteria.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ template<typename T> struct CommonStoppingCriteria :
HamiltonFastMarching<T>::ExtraAlgorithmInterface {
typedef HamiltonFastMarching<T> HFM;
typedef typename HFM::ExtraAlgorithmInterface Superclass;
Redeclare7Types(FromHFM,IndexCRef,IndexType,ScalarType,Traits,Decision,HFMI,PointType)
Redeclare1Constant(FromHFM,Dimension)
Redeclare7Types(HFM,IndexCRef,IndexType,ScalarType,Traits,Decision,HFMI,PointType)
Redeclare1Constant(HFM,Dimension)

virtual void Setup(HFMI*) override;
virtual void Finally(HFMI*) override;
Expand Down
6 changes: 3 additions & 3 deletions Headers/ExtraAlgorithms/EuclideanPathLength.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ template<typename T> struct EuclideanPathLength :
HamiltonFastMarching<T>::ExtraAlgorithmInterface {
typedef HamiltonFastMarching<T> HFM;
typedef typename HFM::ExtraAlgorithmInterface Superclass;
Redeclare7Types(FromHFM,IndexCRef,IndexType,ScalarType,Traits,HFMI,PointType,DiscreteType)
Redeclare6Types(FromHFM,OffsetCRef,VectorType,DiscreteFlowType,RecomputeType,DiscreteFlowElement,Decision)
Redeclare1Constant(FromHFM,Dimension)
Redeclare7Types(HFM,IndexCRef,IndexType,ScalarType,Traits,HFMI,PointType,DiscreteType)
Redeclare6Types(HFM,OffsetCRef,VectorType,DiscreteFlowType,RecomputeType,DiscreteFlowElement,Decision)
Redeclare1Constant(HFM,Dimension)

ScalarType stopAtEuclideanLength = Traits::Infinity();
IndexType stoppingIndex = IndexType::Constant(-1); // Output
Expand Down

0 comments on commit d2a387e

Please sign in to comment.