Skip to content

Commit 84d3ec6

Browse files
author
deseilligny
committed
Merge branch 'mpd'
2 parents 9c01e52 + 4029b01 commit 84d3ec6

19 files changed

+750
-110
lines changed

MMVII/include/MMVII_Bench.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ void BenchMapping(cParamExeBench & aParam);
125125
void BenchInvertMapping(cParamExeBench & aParam);
126126
void BenchSymDerMap(cParamExeBench & aParam);
127127
void BenchLeastSqMap(cParamExeBench & aParam);
128+
void BenchManifold(cParamExeBench & aParam);
129+
128130

129131
void BenchDelaunay(cParamExeBench & aParam);
130132
void BenchTri2D(cParamExeBench & aParam);

MMVII/include/MMVII_Geom3D.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
namespace MMVII
88
{
99

10-
typedef cSegment<tREAL8,3> tSeg3dr;
10+
typedef cSegment<tREAL8,3> tSeg3dr;
11+
typedef cSegmentCompiled<tREAL8,3> tSegComp3dr;
1112

1213
template<class T> cPtxd<T,3> PFromNumAxe(int aNum); ///< return I,J or K according to 0,1 or 2
1314
/// use the 3 "colum vector" to compute the matrix

MMVII/include/MMVII_Images.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,16 @@ template <> inline bool cPixBox<3>::InsideBL(const cPtxd<double,3> & aP) const
122122
&& (aP.z() >= tBox::mP0.z()) && ((aP.z()+1) < tBox::mP1.z())
123123
;
124124
}
125+
template <> inline bool cPixBox<4>::InsideBL(const cPtxd<double,4> & aP) const
126+
{
127+
return (aP.x() >= tBox::mP0.x()) && ((aP.x()+1) < tBox::mP1.x())
128+
&& (aP.y() >= tBox::mP0.y()) && ((aP.y()+1) < tBox::mP1.y())
129+
&& (aP.z() >= tBox::mP0.z()) && ((aP.z()+1) < tBox::mP1.z())
130+
&& (aP.t() >= tBox::mP0.t()) && ((aP.t()+1) < tBox::mP1.t())
131+
;
132+
}
133+
134+
125135

126136
#if ! defined(_MSC_VER)
127137
template<> const cPixBox<2> cPixBox<2>::TheEmptyBox; // Pb Clang, requires explicit declaration of specialization

MMVII/include/MMVII_Manifolds.h

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
#ifndef __MMVII_MANIFOLDS_H_
2+
#define __MMVII_MANIFOLDS_H_
3+
4+
#include "MMVII_Mappings.h"
5+
#include "MMVII_Geom2D.h"
6+
7+
8+
namespace MMVII
9+
{
10+
11+
/**
12+
DimM = Dim of Manifold, for ex 1 for curve
13+
DimE = Dim of embedding space, for ex 2 for a curve in plane
14+
*/
15+
template <const int DimM,const int DimE> class cManifold
16+
{
17+
public :
18+
static const int DimC = DimE - DimM;
19+
20+
typedef cPtxd<tREAL8,DimM> tPtM;
21+
typedef cPtxd<tREAL8,DimE> tPtE;
22+
typedef std::vector<tPtE> tTgSp;
23+
typedef std::pair<int,tPtM> tResPOP; // Type result Param of Pt
24+
25+
cManifold(int aNbMap=1,const tREAL8 aEpsDeriv = 1e-4);
26+
int NbMap() const; //< Accessor
27+
28+
/// return the num map of a point, defaults assume mNbMap==1
29+
virtual int GetNumMap(const tPtE &) const ;
30+
/// Retun a point of manifold in embedding space kowning a parameter, default error
31+
virtual tPtE PtOfParam(const tResPOP &) const ;
32+
/// "Inverse" of PtOfParam, Assuming tPtE is on manifold
33+
virtual tResPOP ParamOfPt(const tPtE &) const ;
34+
35+
/// return TgSpace, assume aPtE is on the manifold
36+
virtual tTgSp TgSpace(const tPtE & aPtE) const ;
37+
/// Given any point, gives an approximate value of the projection
38+
virtual tPtE ApproxProj(const tPtE &) const = 0 ;
39+
/// Return the projection on the manifold, default iterative method
40+
virtual tPtE Proj(const tPtE &) const ;
41+
/// Return the projection on the tangent space to a Manifolfd
42+
private :
43+
tPtE OneIterProjByTgt(const tPtE & aP0,const tPtE & aP2Proj) const ;
44+
45+
int mNbMap;
46+
tREAL8 mEpsDeriv;
47+
};
48+
49+
template<int DimE> class cLineManifold : public cManifold<1,DimE>
50+
{
51+
public :
52+
// virtual tPtE PtOfParam(const tPtM &,int aNumMap) const ;
53+
static const int DimM = 1;
54+
static const int DimC = DimE - DimM;
55+
56+
typedef cPtxd<tREAL8,DimM> tPtM;
57+
typedef cPtxd<tREAL8,DimE> tPtE;
58+
typedef cSegmentCompiled<tREAL8,DimE> tSeg;
59+
typedef std::pair<int,tPtM> tResPOP; // Type result Param of Pt
60+
61+
tPtE PtOfParam(const tResPOP &) const override;
62+
tResPOP ParamOfPt(const tPtE &) const override;
63+
tPtE ApproxProj(const tPtE &) const override ;
64+
65+
private :
66+
tSeg mSeg;
67+
};
68+
69+
70+
template <const int DimM,const int DimE> class cManifoldFromMapping : public cManifold<DimM,DimE>
71+
{
72+
public :
73+
typedef cDataInvertibleMapping<tREAL8,DimE> tMap;
74+
typedef cManifold<DimM,DimE> tMan;
75+
// virtual tPtE PtOfParam(const tPtM &,int aNumMap) const ;
76+
static const int DimC = DimE - DimM;
77+
78+
typedef cPtxd<tREAL8,DimM> tPtM;
79+
typedef cPtxd<tREAL8,DimE> tPtE;
80+
typedef cSegmentCompiled<tREAL8,DimE> tSeg;
81+
typedef std::pair<int,tPtM> tResPOP; // Type result Param of Pt
82+
83+
cManifoldFromMapping(tMan*,tMap*);
84+
85+
tPtE PtOfParam(const tResPOP&) const override;
86+
tResPOP ParamOfPt(const tPtE &) const override;
87+
tPtE ApproxProj(const tPtE &) const override ;
88+
89+
90+
91+
private :
92+
tMan *mMan;
93+
tMap *mMap;
94+
95+
};
96+
97+
};
98+
99+
#endif // __MMVII_MANIFOLDS_H_

MMVII/include/MMVII_Mappings.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -829,6 +829,8 @@ template <class cMapElem> class cInvertMappingFromElem : public
829829

830830
/** Specialization when cMapElem is linear => constant jacobian */
831831

832+
/*
833+
* No longer see utilty
832834
template <class cMapElem> class cIMElemLinear : public
833835
cInvertMappingFromElem<cMapElem>
834836
{
@@ -851,6 +853,7 @@ template <class cMapElem> class cIMElemLinear : public
851853
private :
852854
tMat mMat;
853855
};
856+
*/
854857

855858
/**
856859
We have a set of function F1, .. Fp R^k => R ^n, we want to estimate F as a linear combination:
@@ -923,7 +926,7 @@ template <class Type,const int DimIn,const int DimOut>
923926

924927
/** Bijective Affine Mapping Elementary */
925928

926-
template <class Type,const int Dim> class cBijAffMapElem
929+
template <class Type,const int Dim> class cBijAffMapElem // : public cDataInvertibleMapping<Type,Dim>
927930
{
928931
public :
929932
typedef Type tTypeElem;
@@ -935,8 +938,8 @@ template <class Type,const int Dim> class cBijAffMapElem
935938
typedef cPtxd<Type,Dim> tPt;
936939
cBijAffMapElem(const tMat & aMat ,const tPt& aTr) ;
937940

938-
tPt Value(const tPt & aP) const;
939-
tPt Inverse(const tPt & aP) const;
941+
tPt Value(const tPt & aP) const ;
942+
tPt Inverse(const tPt & aP) const ;
940943

941944
cBijAffMapElem<Type,Dim> MapInverse() const;
942945

MMVII/include/MMVII_PhgrDist.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,13 @@ NS_SymbolicDerivative::cCalculator<double> * EqColinearityCamGen(int aDeg,bool
136136
NS_SymbolicDerivative::cCalculator<double> * RPC_Proj(bool WithDerive,int aSzBuf,bool ReUse); // PUSHB
137137

138138
// ............. Equation colinearity , imply external parameter, Projectiion, distorsion, foc+PP .............
139-
NS_SymbolicDerivative::cCalculator<double> * EqColinearityCamPPC(eProjPC aType,const cPt3di & aDeg,bool WithDerive,int aSzBuf,bool ReUse,bool isFraserMode);
139+
enum class eTypeEqCol
140+
{
141+
ePt,
142+
eLine
143+
};
144+
145+
NS_SymbolicDerivative::cCalculator<double> * EqColinearityCamPPC(eProjPC aType,const cPt3di & aDeg,bool WithDerive,int aSzBuf,bool ReUse,bool isFraserMode,eTypeEqCol);
140146

141147

142148

MMVII/include/MMVII_Ptxd.h

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,8 @@ template <class Type,const int DimOut,const int DimIn> cPtxd<Type,DimOut> CastDi
246246

247247
template <class Type> inline bool IsNull (const cPtxd<Type,2> & aP) { return (aP.x() ==0) && (aP.y()==0);}
248248
template <class Type> inline bool IsNull (const cPtxd<Type,3> & aP) { return (aP.x() ==0) && (aP.y()==0) && (aP.z()==0);}
249+
template <class Type> inline bool IsNull (const cPtxd<Type,4> & aP) { return (aP.x() ==0) && (aP.y()==0) && (aP.z()==0) &&(aP.t()==0);}
250+
249251
template <class Type> inline bool IsNotNull (const cPtxd<Type,2> & aP) { return ! IsNull(aP);}
250252
//template <class Type> inline bool IsNotNull (const cPtxd<Type,2> & aP) { return (aP.x() !=0) || (aP.y()!=0);}
251253

@@ -316,6 +318,8 @@ template <class Type> inline cPtxd<Type,2> MulCByC (const cPtxd<Type,2> & aP1,c
316318
{ return cPtxd<Type,2>(aP1.x() * aP2.x(),aP1.y() * aP2.y()); }
317319
template <class Type> inline cPtxd<Type,3> MulCByC (const cPtxd<Type,3> & aP1,const cPtxd<Type,3> & aP2)
318320
{ return cPtxd<Type,3>(aP1.x() * aP2.x(),aP1.y() * aP2.y(),aP1.z()*aP2.z()); }
321+
template <class Type> inline cPtxd<Type,4> MulCByC (const cPtxd<Type,4> & aP1,const cPtxd<Type,4> & aP2)
322+
{ return cPtxd<Type,4>(aP1.x() * aP2.x(),aP1.y() * aP2.y(),aP1.z()*aP2.z(),aP1.t()*aP2.t()); }
319323

320324
/// DivCByC division coordinates by coordinates !! => INT Division; see also RDivCByC
321325
template <class Type> inline cPtxd<Type,1> DivCByC (const cPtxd<Type,1> & aP1,const cPtxd<Type,1> & aP2)
@@ -324,6 +328,8 @@ template <class Type> inline cPtxd<Type,2> DivCByC (const cPtxd<Type,2> & aP1,c
324328
{ return cPtxd<Type,2>(aP1.x() / aP2.x(),aP1.y() / aP2.y()); }
325329
template <class Type> inline cPtxd<Type,3> DivCByC (const cPtxd<Type,3> & aP1,const cPtxd<Type,3> & aP2)
326330
{ return cPtxd<Type,3>(aP1.x() / aP2.x(),aP1.y() / aP2.y(),aP1.z()/aP2.z()); }
331+
template <class Type> inline cPtxd<Type,4> DivCByC (const cPtxd<Type,4> & aP1,const cPtxd<Type,4> & aP2)
332+
{ return cPtxd<Type,4>(aP1.x() / aP2.x(),aP1.y() / aP2.y(),aP1.z()/aP2.z(),aP1.t()/aP2.t()); }
327333

328334

329335
/// Some time int division is not what is wanted !!
@@ -336,6 +342,7 @@ template <class T,const int Dim> inline cPtxd<double,Dim> RDivCByC(const cPtxd<T
336342
template <class Type> inline cPtxd<Type,1> operator - (const cPtxd<Type,1> & aP) {return cPtxd<Type,1>(-aP.x());}
337343
template <class Type> inline cPtxd<Type,2> operator - (const cPtxd<Type,2> & aP) {return cPtxd<Type,2>(-aP.x(),-aP.y());}
338344
template <class Type> inline cPtxd<Type,3> operator - (const cPtxd<Type,3> & aP) {return cPtxd<Type,3>(-aP.x(),-aP.y(),-aP.z());}
345+
template <class Type> inline cPtxd<Type,4> operator - (const cPtxd<Type,4> & aP) {return cPtxd<Type,4>(-aP.x(),-aP.y(),-aP.z(),-aP.t());}
339346

340347

341348
/// operator * scalar - points
@@ -396,7 +403,26 @@ template <class T,const int Dim> typename tNumTrait<T>::tFloatAssoc Norm2(const
396403
}
397404
// template <class T,const int Dim> double Norm2(const cPtxd<T,Dim> & aP);
398405

399-
template <class T,const int Dim> typename tNumTrait<T>::tBig Scal(const cPtxd<T,Dim> &,const cPtxd<T,Dim> &);
406+
//template <class T,const int Dim> typename tNumTrait<T>::tBig Scal(const cPtxd<T,Dim> &,const cPtxd<T,Dim> &);
407+
template <class T> typename tNumTrait<T>::tBig Scal(const cPtxd<T,1> &aP1,const cPtxd<T,1> & aP2)
408+
{ return aP1.x() * aP2.x();}
409+
template <class T> typename tNumTrait<T>::tBig Scal(const cPtxd<T,2> &aP1,const cPtxd<T,2> & aP2)
410+
{ return aP1.x() * aP2.x() + aP1.y() * aP2.y();}
411+
template <class T> typename tNumTrait<T>::tBig Scal(const cPtxd<T,3> &aP1,const cPtxd<T,3> & aP2)
412+
{ return aP1.x() * aP2.x() + aP1.y() * aP2.y() + aP1.z() * aP2.z();}
413+
template <class T> typename tNumTrait<T>::tBig Scal(const cPtxd<T,4> &aP1,const cPtxd<T,4> & aP2)
414+
{ return aP1.x() * aP2.x() + aP1.y() * aP2.y() + aP1.z() * aP2.z() +aP1.t() * aP2.t();}
415+
/*
416+
template <class T,const int Dim>
417+
typename tNumTrait<T>::tBig Scal(const cPtxd<T,Dim> &aP1,const cPtxd<T,Dim> & aP2)
418+
{
419+
typename tNumTrait<T>::tBig aRes = aP1[0]*aP2[0];
420+
for (int aD=1 ; aD<Dim; aD++)
421+
aRes += aP1[aD]*aP2[aD];
422+
return aRes;
423+
}
424+
*/
425+
400426
template <class T,const int Dim> typename tNumTrait<T>::tBig MulCoord(const cPtxd<T,Dim> & aP);
401427

402428
template <class T,const int Dim> T Cos(const cPtxd<T,Dim> &,const cPtxd<T,Dim> &);
@@ -470,6 +496,8 @@ template <class Type> inline bool SupEq (const cPtxd<Type,2> & aP1,const cPtxd<
470496
{return (aP1.x()>=aP2.x()) && (aP1.y()>=aP2.y());}
471497
template <class Type> inline bool SupEq (const cPtxd<Type,3> & aP1,const cPtxd<Type,3> & aP2)
472498
{return (aP1.x()>=aP2.x()) && (aP1.y()>=aP2.y()) && (aP1.z()>=aP2.z());}
499+
template <class Type> inline bool SupEq (const cPtxd<Type,4> & aP1,const cPtxd<Type,4> & aP2)
500+
{return (aP1.x()>=aP2.x()) && (aP1.y()>=aP2.y()) && (aP1.z()>=aP2.z()) && (aP1.t()>=aP2.t());}
473501

474502

475503
/// PtSupEq : smallest point being SupEq to
@@ -479,6 +507,8 @@ template <class Type> inline cPtxd<Type,2> PtSupEq (const cPtxd<Type,2> & aP1,c
479507
{ return cPtxd<Type,2> (std::max(aP1.x(),aP2.x()),std::max(aP1.y(),aP2.y())); }
480508
template <class Type> inline cPtxd<Type,3> PtSupEq (const cPtxd<Type,3> & aP1,const cPtxd<Type,3> & aP2)
481509
{ return cPtxd<Type,3> (std::max(aP1.x(),aP2.x()),std::max(aP1.y(),aP2.y()),std::max(aP1.z(),aP2.z())); }
510+
template <class Type> inline cPtxd<Type,4> PtSupEq (const cPtxd<Type,4> & aP1,const cPtxd<Type,4> & aP2)
511+
{ return cPtxd<Type,4> (std::max(aP1.x(),aP2.x()),std::max(aP1.y(),aP2.y()),std::max(aP1.z(),aP2.z()),std::max(aP1.t(),aP2.t()) ); }
482512

483513
template <class TypePt> void SetSupEq(TypePt & aP1,const TypePt & aP2) {aP1 = PtSupEq(aP1,aP2);}
484514

@@ -489,6 +519,8 @@ template <class Type> inline cPtxd<Type,2> PtInfEq (const cPtxd<Type,2> & aP1,c
489519
{ return cPtxd<Type,2> (std::min(aP1.x(),aP2.x()),std::min(aP1.y(),aP2.y())); }
490520
template <class Type> inline cPtxd<Type,3> PtInfEq (const cPtxd<Type,3> & aP1,const cPtxd<Type,3> & aP2)
491521
{ return cPtxd<Type,3> (std::min(aP1.x(),aP2.x()),std::min(aP1.y(),aP2.y()),std::min(aP1.z(),aP2.z())); }
522+
template <class Type> inline cPtxd<Type,4> PtInfEq (const cPtxd<Type,4> & aP1,const cPtxd<Type,4> & aP2)
523+
{ return cPtxd<Type,4> (std::min(aP1.x(),aP2.x()),std::min(aP1.y(),aP2.y()),std::min(aP1.z(),aP2.z()),std::min(aP1.t(),aP2.t())); }
492524

493525
template <class TypePt> void SetInfEq(TypePt & aP1,const TypePt & aP2) {aP1 = PtInfEq(aP1,aP2);}
494526

@@ -501,6 +533,8 @@ template <class Type> inline bool InfStr (const cPtxd<Type,2> & aP1,const cPtxd
501533
{return (aP1.x()<aP2.x()) && (aP1.y()<aP2.y());}
502534
template <class Type> inline bool InfStr (const cPtxd<Type,3> & aP1,const cPtxd<Type,3> & aP2)
503535
{return (aP1.x()<aP2.x()) && (aP1.y()<aP2.y()) && (aP1.z()<aP2.z());}
536+
template <class Type> inline bool InfStr (const cPtxd<Type,4> & aP1,const cPtxd<Type,4> & aP2)
537+
{return (aP1.x()<aP2.x()) && (aP1.y()<aP2.y()) && (aP1.z()<aP2.z()) && (aP1.t()<aP2.t());}
504538

505539
/** PtInfSTr : bigets point beg=ing InfStr (definition valide for integer types)
506540
Warn non symetric function; strictness is relative to P2, not P1 ;
@@ -519,6 +553,8 @@ template <class Type> inline cPtxd<Type,2> PtInfStr (const cPtxd<Type,2> & aP1,
519553
// { return cPtxd<Type,2> (std::min(aP1.x(),aP2.x()-1),std::min(aP1.y(),aP2.y()-1)); }
520554
template <class Type> inline cPtxd<Type,3> PtInfStr (const cPtxd<Type,3> & aP1,const cPtxd<Type,3> & aP2)
521555
{ return cPtxd<Type,3> (std::min(aP1.x(),aP2.x()-1),std::min(aP1.y(),aP2.y()-1),std::min(aP1.z(),aP2.z()-1)); }
556+
template <class Type> inline cPtxd<Type,4> PtInfStr (const cPtxd<Type,4> & aP1,const cPtxd<Type,4> & aP2)
557+
{ return cPtxd<Type,4> (std::min(aP1.x(),aP2.x()-1),std::min(aP1.y(),aP2.y()-1),std::min(aP1.z(),aP2.z()-1),std::min(aP1.t(),aP2.t()-1)); }
522558

523559

524560
/// InfEq : P1.k() <= P2.k() for all coordinates
@@ -528,6 +564,8 @@ template <class Type> inline bool InfEq (const cPtxd<Type,2> & aP1,const cPtxd<
528564
{return (aP1.x()<=aP2.x()) && (aP1.y()<=aP2.y());}
529565
template <class Type> inline bool InfEq (const cPtxd<Type,3> & aP1,const cPtxd<Type,3> & aP2)
530566
{return (aP1.x()<=aP2.x()) && (aP1.y()<=aP2.y()) && (aP1.z()<=aP2.z());}
567+
template <class Type> inline bool InfEq (const cPtxd<Type,4> & aP1,const cPtxd<Type,4> & aP2)
568+
{return (aP1.x()<=aP2.x()) && (aP1.y()<=aP2.y()) && (aP1.z()<=aP2.z()) && (aP1.t()<=aP2.t());}
531569

532570

533571
template<class T,const int Dim> cPtxd<T,Dim> VUnit(const cPtxd<T,Dim> & aP);

MMVII/src/Bench/BenchGlob.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,8 @@ int cAppli_MMVII_Bench::ExecuteBench(cParamExeBench & aParam)
561561

562562
// Test mapping Buf/NotBuf Jacob Inverse ...
563563
BenchMapping(aParam);
564+
BenchManifold(aParam);
565+
564566

565567
// Apparently this bench do not succeed; to see later ?
566568
if (mDoBUSD)

0 commit comments

Comments
 (0)