Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
6a22740f
Commit
6a22740f
authored
Apr 04, 2013
by
Mathias Goldau
Browse files
[MERGE]
parents
b544eae8
d70127d1
Changes
170
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
171 additions
and
72 deletions
+171
-72
src/core/common/WProjectFileIO.cpp
src/core/common/WProjectFileIO.cpp
+38
-0
src/core/common/WProjectFileIO.h
src/core/common/WProjectFileIO.h
+14
-0
src/core/common/WPropertyTypes.h
src/core/common/WPropertyTypes.h
+1
-1
src/core/common/WPropertyVariable.h
src/core/common/WPropertyVariable.h
+0
-2
src/core/common/WThreadedJobs.h
src/core/common/WThreadedJobs.h
+0
-2
src/core/common/WThreadedRunnerSignals.h
src/core/common/WThreadedRunnerSignals.h
+2
-3
src/core/common/datastructures/WFiber.h
src/core/common/datastructures/WFiber.h
+1
-1
src/core/common/datastructures/test/WFiber_test.h
src/core/common/datastructures/test/WFiber_test.h
+1
-1
src/core/common/math/WGeometryFunctions.h
src/core/common/math/WGeometryFunctions.h
+1
-1
src/core/common/math/WLine.cpp
src/core/common/math/WLine.cpp
+2
-1
src/core/common/math/WLine.h
src/core/common/math/WLine.h
+1
-3
src/core/common/math/WLinearAlgebraFunctions.cpp
src/core/common/math/WLinearAlgebraFunctions.cpp
+1
-34
src/core/common/math/WLinearAlgebraFunctions.h
src/core/common/math/WLinearAlgebraFunctions.h
+43
-3
src/core/common/math/WMath.cpp
src/core/common/math/WMath.cpp
+2
-1
src/core/common/math/WMath.h
src/core/common/math/WMath.h
+1
-1
src/core/common/math/WMatrix.h
src/core/common/math/WMatrix.h
+60
-14
src/core/common/math/WOSSIMHelper.h
src/core/common/math/WOSSIMHelper.h
+1
-1
src/core/common/math/WPlane.cpp
src/core/common/math/WPlane.cpp
+1
-1
src/core/common/math/WPlane.h
src/core/common/math/WPlane.h
+1
-1
src/core/common/math/WPolynomialEquationSolvers.h
src/core/common/math/WPolynomialEquationSolvers.h
+0
-1
No files found.
src/core/common/WProjectFileIO.cpp
View file @
6a22740f
...
...
@@ -77,3 +77,41 @@ void WProjectFileIO::addWarning( std::string description )
m_warnings
.
push_back
(
description
);
}
void
WProjectFileIO
::
printProperties
(
std
::
ostream
&
output
,
boost
::
shared_ptr
<
WProperties
>
props
,
std
::
string
indent
,
//NOLINT
std
::
string
prefix
,
unsigned
int
index
,
std
::
string
indexPrefix
)
{
// lock, unlocked if l looses focus
WProperties
::
PropertySharedContainerType
::
ReadTicket
l
=
props
->
getProperties
();
output
<<
indent
<<
"// Property Group: "
<<
props
->
getName
()
<<
std
::
endl
;
// iterate of them and print them to output
for
(
WProperties
::
PropertyConstIterator
iter
=
l
->
get
().
begin
();
iter
!=
l
->
get
().
end
();
++
iter
)
{
// information properties do not get written
if
(
(
*
iter
)
->
getPurpose
()
==
PV_PURPOSE_INFORMATION
)
{
continue
;
}
if
(
(
*
iter
)
->
getType
()
!=
PV_GROUP
)
{
output
<<
indent
+
" "
<<
"PROPERTY:("
<<
indexPrefix
<<
index
<<
","
<<
prefix
+
(
*
iter
)
->
getName
()
<<
")="
<<
(
*
iter
)
->
getAsString
()
<<
std
::
endl
;
}
else
{
// it is a group -> recursively print it
if
(
prefix
.
empty
()
)
{
printProperties
(
output
,
(
*
iter
)
->
toPropGroup
(),
indent
+
" "
,
(
*
iter
)
->
getName
()
+
"/"
,
index
,
indexPrefix
);
}
else
{
printProperties
(
output
,
(
*
iter
)
->
toPropGroup
(),
indent
+
" "
,
prefix
+
(
*
iter
)
->
getName
()
+
"/"
,
index
,
indexPrefix
);
}
}
}
output
<<
indent
<<
"// Property Group END: "
<<
props
->
getName
()
<<
std
::
endl
;
}
src/core/common/WProjectFileIO.h
View file @
6a22740f
...
...
@@ -29,6 +29,8 @@
#include <string>
#include <vector>
#include "WProperties.h"
/**
* A base class for all parts of OpenWalnut which can be serialized to a project file. It is used by WProjectFile to actually parse the file line
* by line. Derive from this class if you write your own parser and use it to fill your internal data structures. But write it in a very
...
...
@@ -117,6 +119,18 @@ protected:
*/
void
addWarning
(
std
::
string
description
);
/**
* Recursively prints the properties and nested properties.
*
* \param output the output stream to print to
* \param props the properties to recursively print
* \param indent the indentation level
* \param prefix the prefix (name prefix of property)
* \param index the ID to use
* \param indexPrefix use this to add a prefix to the index
*/
void
printProperties
(
std
::
ostream
&
output
,
boost
::
shared_ptr
<
WProperties
>
props
,
std
::
string
indent
,
//NOLINT ( non-const ref )
std
::
string
prefix
,
unsigned
int
index
,
std
::
string
indexPrefix
=
""
);
private:
/**
* List of errors if any.
...
...
src/core/common/WPropertyTypes.h
View file @
6a22740f
...
...
@@ -34,8 +34,8 @@
#include <boost/filesystem.hpp>
#include "WStringUtils.h"
#include "math/linearAlgebra/WLinearAlgebra.h"
#include "math/linearAlgebra/WMatrixFixed.h"
#include "math/linearAlgebra/WPosition.h"
#include "math/linearAlgebra/WVectorFixed.h"
#include "math/WInterval.h"
#include "WAssert.h"
...
...
src/core/common/WPropertyVariable.h
View file @
6a22740f
...
...
@@ -27,11 +27,9 @@
#include <stdint.h>
#include <iostream>
#include <list>
#include <set>
#include <string>
#include <vector>
#include <boost/shared_ptr.hpp>
#include <boost/signals2.hpp>
...
...
src/core/common/WThreadedJobs.h
View file @
6a22740f
...
...
@@ -25,14 +25,12 @@
#ifndef WTHREADEDJOBS_H
#define WTHREADEDJOBS_H
#include <iostream>
#include <string>
#include <boost/shared_ptr.hpp>
#include "WException.h"
#include "WFlag.h"
#include "WLogger.h"
/**
* \class WThreadedJobs
...
...
src/core/common/WThreadedRunnerSignals.h
View file @
6a22740f
...
...
@@ -33,11 +33,10 @@ class WException;
/**
* Enum of all possible signals WThreadedRunner instances can emit.
*/
typedef
enum
enum
THREAD_SIGNAL
{
WTHREAD_ERROR
// error during execution
}
THREAD_SIGNAL
;
};
// **************************************************************************************************************************
// Types
...
...
src/core/common/datastructures/WFiber.h
View file @
6a22740f
...
...
@@ -28,7 +28,7 @@
#include <vector>
#include "../math/WLine.h"
#include "../math/linearAlgebra/W
LinearAlgebra
.h"
#include "../math/linearAlgebra/W
Position
.h"
class
WFiberTest
;
...
...
src/core/common/datastructures/test/WFiber_test.h
View file @
6a22740f
...
...
@@ -30,7 +30,7 @@
#include <cxxtest/TestSuite.h>
#include "../../math/linearAlgebra/W
LinearAlgebra
.h"
#include "../../math/linearAlgebra/W
Position
.h"
#include "../WFiber.h"
#include "WFiberTraits.h"
...
...
src/core/common/math/WGeometryFunctions.h
View file @
6a22740f
...
...
@@ -30,7 +30,7 @@
#include <vector>
#include "../WAssert.h"
#include "linearAlgebra/W
LinearAlgebra
.h"
#include "linearAlgebra/W
VectorFixed
.h"
namespace
utility
{
...
...
src/core/common/math/WLine.cpp
View file @
6a22740f
...
...
@@ -37,7 +37,8 @@
#include "../WStringUtils.h"
#include "WLine.h"
#include "WPolynomialEquationSolvers.h"
#include "linearAlgebra/WLinearAlgebra.h"
#include "linearAlgebra/WPosition.h"
#include "linearAlgebra/WVectorFixed.h"
WLine
::
WLine
(
const
std
::
vector
<
WPosition
>
&
points
)
:
WMixinVector
<
WPosition
>
(
points
)
...
...
src/core/common/math/WLine.h
View file @
6a22740f
...
...
@@ -25,14 +25,12 @@
#ifndef WLINE_H
#define WLINE_H
#include <algorithm>
#include <iostream>
#include <vector>
#include "../WBoundingBox.h"
#include "../WMixinVector.h"
#include "linearAlgebra/W
LinearAlgebra
.h"
#include "linearAlgebra/W
Position
.h"
// forward declarations
class
WLineTest
;
...
...
src/core/common/math/WLinearAlgebraFunctions.cpp
View file @
6a22740f
...
...
@@ -24,14 +24,12 @@
#include <vector>
#include <Eigen/SVD>
#include "../WAssert.h"
#include "../WLimits.h"
#include "WLinearAlgebraFunctions.h"
#include "WMatrix.h"
#include "linearAlgebra/W
LinearAlgebra
.h"
#include "linearAlgebra/W
VectorFixed
.h"
WVector3d
multMatrixWithVector3D
(
WMatrix
<
double
>
mat
,
WVector3d
vec
)
{
...
...
@@ -292,34 +290,3 @@ bool linearIndependent( const WVector3d& u, const WVector3d& v )
}
return
true
;
}
void
computeSVD
(
const
WMatrix
<
double
>&
A
,
WMatrix
<
double
>&
U
,
WMatrix
<
double
>&
V
,
WValue
<
double
>&
S
)
{
Eigen
::
MatrixXd
eigenA
(
A
);
Eigen
::
JacobiSVD
<
Eigen
::
MatrixXd
>
svd
(
eigenA
,
Eigen
::
ComputeFullU
|
Eigen
::
ComputeFullV
);
U
=
WMatrix
<
double
>
(
svd
.
matrixU
()
);
V
=
WMatrix
<
double
>
(
svd
.
matrixV
()
);
S
=
WValue
<
double
>
(
svd
.
singularValues
()
);
}
WMatrix
<
double
>
pseudoInverse
(
const
WMatrix
<
double
>&
input
)
{
// calc pseudo inverse
WMatrix
<
double
>
U
(
input
.
getNbRows
(),
input
.
getNbCols
()
);
WMatrix
<
double
>
V
(
input
.
getNbCols
(),
input
.
getNbCols
()
);
WValue
<
double
>
Svec
(
input
.
size
()
);
computeSVD
(
input
,
U
,
V
,
Svec
);
// create diagonal matrix S
WMatrix
<
double
>
S
(
input
.
getNbCols
(),
input
.
getNbCols
()
);
S
.
setZero
();
for
(
size_t
i
=
0
;
i
<
Svec
.
size
()
&&
i
<
S
.
getNbRows
()
&&
i
<
S
.
getNbCols
();
i
++
)
{
S
(
i
,
i
)
=
(
Svec
[
i
]
==
0.0
)
?
0.0
:
1.0
/
Svec
[
i
];
}
return
WMatrix
<
double
>
(
V
*
S
*
U
.
transposed
()
);
}
src/core/common/math/WLinearAlgebraFunctions.h
View file @
6a22740f
...
...
@@ -25,9 +25,11 @@
#ifndef WLINEARALGEBRAFUNCTIONS_H
#define WLINEARALGEBRAFUNCTIONS_H
#include <Eigen/Core>
#include <Eigen/SVD>
#include "WMatrix.h"
#include "linearAlgebra/W
LinearAlgebra
.h"
#include "linearAlgebra/W
Position
.h"
template
<
typename
>
class
WMatrix
;
...
...
@@ -92,22 +94,60 @@ bool linearIndependent( const WVector3d& u, const WVector3d& v );
*
* A=U*S*V^T
*
* \tparam T The data type.
* \param A Input Matrix
* \param U Output Matrix
* \param S Output of the entries in the diagonal matrix
* \param V Output Matrix
*
*/
void
computeSVD
(
const
WMatrix
<
double
>&
A
,
WMatrix
<
double
>&
U
,
WMatrix
<
double
>&
V
,
WValue
<
double
>&
S
);
template
<
typename
T
>
void
computeSVD
(
const
WMatrix
<
T
>&
A
,
WMatrix
<
T
>&
U
,
WMatrix
<
T
>&
V
,
WValue
<
T
>&
S
);
/**
* Calculates for a matrix the pseudo inverse.
*
* \tparam T The data type.
* \param input Matrix to invert
*
* \return Inverted Matrix
*
*/
WMatrix
<
double
>
pseudoInverse
(
const
WMatrix
<
double
>&
input
);
template
<
typename
T
>
WMatrix
<
T
>
pseudoInverse
(
const
WMatrix
<
T
>&
input
);
template
<
typename
T
>
void
computeSVD
(
const
WMatrix
<
T
>&
A
,
WMatrix
<
T
>&
U
,
WMatrix
<
T
>&
V
,
WValue
<
T
>&
S
)
{
Eigen
::
Matrix
<
T
,
Eigen
::
Dynamic
,
Eigen
::
Dynamic
>
eigenA
(
A
);
Eigen
::
JacobiSVD
<
Eigen
::
Matrix
<
T
,
Eigen
::
Dynamic
,
Eigen
::
Dynamic
>
>
svd
(
eigenA
,
Eigen
::
ComputeFullU
|
Eigen
::
ComputeFullV
);
U
=
WMatrix
<
T
>
(
svd
.
matrixU
()
);
V
=
WMatrix
<
T
>
(
svd
.
matrixV
()
);
S
=
WValue
<
T
>
(
svd
.
singularValues
()
);
}
template
<
typename
T
>
WMatrix
<
T
>
pseudoInverse
(
const
WMatrix
<
T
>&
input
)
{
// calc pseudo inverse
WMatrix
<
T
>
U
(
input
.
getNbRows
(),
input
.
getNbCols
()
);
WMatrix
<
T
>
V
(
input
.
getNbCols
(),
input
.
getNbCols
()
);
WValue
<
T
>
Svec
(
input
.
size
()
);
computeSVD
(
input
,
U
,
V
,
Svec
);
// create diagonal matrix S
WMatrix
<
T
>
S
(
input
.
getNbCols
(),
input
.
getNbCols
()
);
S
.
setZero
();
for
(
size_t
i
=
0
;
i
<
Svec
.
size
()
&&
i
<
S
.
getNbRows
()
&&
i
<
S
.
getNbCols
();
i
++
)
{
S
(
i
,
i
)
=
(
Svec
[
i
]
==
0.0
)
?
0.0
:
1.0
/
Svec
[
i
];
}
return
WMatrix
<
T
>
(
V
*
S
*
U
.
transposed
()
);
}
#endif // WLINEARALGEBRAFUNCTIONS_H
src/core/common/math/WMath.cpp
View file @
6a22740f
...
...
@@ -24,7 +24,8 @@
#include "WMath.h"
#include "WPlane.h"
#include "linearAlgebra/WLinearAlgebra.h"
#include "linearAlgebra/WPosition.h"
#include "linearAlgebra/WVectorFixed.h"
#include "../WAssert.h"
#include "../WLimits.h"
...
...
src/core/common/math/WMath.h
View file @
6a22740f
...
...
@@ -31,7 +31,7 @@
#include "WLine.h"
#include "WPlane.h"
#include "linearAlgebra/W
LinearAlgebra
.h"
#include "linearAlgebra/W
Position
.h"
/**
* Classes and functions of math module of OpenWalnut.
...
...
src/core/common/math/WMatrix.h
View file @
6a22740f
...
...
@@ -30,7 +30,8 @@
#include <osg/Matrix>
#include "WValue.h"
#include "linearAlgebra/WLinearAlgebra.h"
#include "linearAlgebra/WMatrixFixed.h"
#include "linearAlgebra/WVectorFixed.h"
#include "../WDefines.h"
...
...
@@ -79,6 +80,20 @@ public:
*/
WMatrix
(
const
Eigen
::
MatrixXd
&
newMatrix
);
// NOLINT
/**
* Copies the specified Eigen::MatrixXf.
*
* \param newMatrix the Eigen::MatrixXf matrix to copy
*/
WMatrix
(
const
Eigen
::
MatrixXf
&
newMatrix
);
// NOLINT
/**
* Copies the specified Eigen::MatrixXi.
*
* \param newMatrix the Eigen::MatrixXi matrix to copy
*/
WMatrix
(
const
Eigen
::
MatrixXi
&
newMatrix
);
// NOLINT
/**
* Makes the matrix contain the identity matrix, i.e. 1 on the diagonal.
* \return Reference to the current matrix which is identity matrix now.
...
...
@@ -130,11 +145,14 @@ public:
operator
osg
::
Matrixd
()
const
;
/**
* Cast this matrix to an Eigen::MatrixXd matrix.
* Cast this matrix to an Eigen::Matrix< EigenDataType, Eigen::Dynamic, Eigen::Dynamic >() matrix.
*
* \tparam EigenDataType Data type of Eigen matrix.
*
* \return casted matrix.
*/
operator
Eigen
::
MatrixXd
()
const
;
template
<
typename
EigenDataType
>
operator
Eigen
::
Matrix
<
EigenDataType
,
Eigen
::
Dynamic
,
Eigen
::
Dynamic
>
()
const
;
/**
* Compares two matrices and returns true if they are equal.
...
...
@@ -210,6 +228,14 @@ public:
protected:
private:
/**
* This function is used by the constructors that have the different Eigen::MatrixX types as parameter.
* \tparam EigenDataType The data type which is used by the Eigen matrix.
* \param newMatrix The source matrix.
*/
template
<
typename
EigenDataType
>
void
copyFromEigenMatrix
(
const
Eigen
::
Matrix
<
EigenDataType
,
Eigen
::
Dynamic
,
Eigen
::
Dynamic
>&
newMatrix
);
size_t
m_nbCols
;
//!< Number of columns of the matrix. The number of rows will be computed by (size/m_nbCols).
};
...
...
@@ -251,16 +277,20 @@ template< typename T > WMatrix< T >::WMatrix( const WMatrix4d& newMatrix )
template
<
typename
T
>
WMatrix
<
T
>::
WMatrix
(
const
Eigen
::
MatrixXd
&
newMatrix
)
:
WValue
<
T
>
(
newMatrix
.
cols
()
*
newMatrix
.
rows
()
)
{
m_nbCols
=
static_cast
<
size_t
>
(
newMatrix
.
cols
()
);
for
(
int
row
=
0
;
row
<
newMatrix
.
rows
();
++
row
)
{
for
(
int
col
=
0
;
col
<
newMatrix
.
cols
();
++
col
)
{
(
*
this
)(
row
,
col
)
=
static_cast
<
T
>
(
newMatrix
(
row
,
col
)
);
}
}
copyFromEigenMatrix
<
double
>
(
newMatrix
);
}
template
<
typename
T
>
WMatrix
<
T
>::
WMatrix
(
const
Eigen
::
MatrixXf
&
newMatrix
)
:
WValue
<
T
>
(
newMatrix
.
cols
()
*
newMatrix
.
rows
()
)
{
copyFromEigenMatrix
<
float
>
(
newMatrix
);
}
template
<
typename
T
>
WMatrix
<
T
>::
WMatrix
(
const
Eigen
::
MatrixXi
&
newMatrix
)
:
WValue
<
T
>
(
newMatrix
.
cols
()
*
newMatrix
.
rows
()
)
{
copyFromEigenMatrix
<
int
>
(
newMatrix
);
}
template
<
typename
T
>
WMatrix
<
T
>::
operator
WMatrix4d
()
const
{
...
...
@@ -301,19 +331,21 @@ template< typename T > WMatrix< T >::operator osg::Matrixd() const
}
}
template
<
typename
T
>
WMatrix
<
T
>::
operator
Eigen
::
MatrixXd
()
const
template
<
typename
T
>
template
<
typename
EigenDataType
>
WMatrix
<
T
>::
operator
Eigen
::
Matrix
<
EigenDataType
,
Eigen
::
Dynamic
,
Eigen
::
Dynamic
>
()
const
{
Eigen
::
Matrix
Xd
matrix
(
this
->
getNbRows
(),
this
->
getNbCols
()
);
Eigen
::
Matrix
<
EigenDataType
,
Eigen
::
Dynamic
,
Eigen
::
Dynamic
>
matrix
(
this
->
getNbRows
(),
this
->
getNbCols
()
);
for
(
int
row
=
0
;
row
<
matrix
.
rows
();
++
row
)
{
for
(
int
col
=
0
;
col
<
matrix
.
cols
();
++
col
)
{
matrix
(
row
,
col
)
=
(
*
this
)(
row
,
col
);
matrix
(
row
,
col
)
=
static_cast
<
EigenDataType
>
(
(
*
this
)(
row
,
col
)
);
}
}
return
matrix
;
}
/**
* Makes the matrix contain the identity matrix, i.e. 1 on the diagonal.
*/
...
...
@@ -494,6 +526,20 @@ template< typename T > bool WMatrix< T >::isIdentity( T delta ) const
return
true
;
}
template
<
typename
T
>
template
<
typename
EigenDataType
>
void
WMatrix
<
T
>::
copyFromEigenMatrix
(
const
Eigen
::
Matrix
<
EigenDataType
,
Eigen
::
Dynamic
,
Eigen
::
Dynamic
>&
newMatrix
)
{
m_nbCols
=
static_cast
<
size_t
>
(
newMatrix
.
cols
()
);
for
(
int
row
=
0
;
row
<
newMatrix
.
rows
();
++
row
)
{
for
(
int
col
=
0
;
col
<
newMatrix
.
cols
();
++
col
)
{
(
*
this
)(
row
,
col
)
=
static_cast
<
T
>
(
newMatrix
(
row
,
col
)
);
}
}
}
template
<
typename
T
>
inline
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
WMatrix
<
T
>&
m
)
{
...
...
src/core/common/math/WOSSIMHelper.h
View file @
6a22740f
...
...
@@ -27,7 +27,7 @@
#ifdef OW_USE_OSSIM
#include <algorithm>
#include <iostream>
//
#include <iostream>
#include <vector>
#include <matrix/newmat.h>
...
...
src/core/common/math/WPlane.cpp
View file @
6a22740f
...
...
@@ -27,7 +27,7 @@
#include <boost/shared_ptr.hpp>
#include "../../common/math/WLinearAlgebraFunctions.h"
#include "../../common/math/linearAlgebra/W
LinearAlgebra
.h"
#include "../../common/math/linearAlgebra/W
VectorFixed
.h"
#include "../../common/WAssert.h"
#include "../../common/WLimits.h"
...
...
src/core/common/math/WPlane.h
View file @
6a22740f
...
...
@@ -31,7 +31,7 @@
#include "../../dataHandler/WGridRegular3D.h"
#include "linearAlgebra/W
LinearAlgebra
.h"
#include "linearAlgebra/W
VectorFixed
.h"
/**
* Represents a plane with a normal vector and a position in space.
...
...
src/core/common/math/WPolynomialEquationSolvers.h
View file @
6a22740f
...
...
@@ -26,7 +26,6 @@
#define WPOLYNOMIALEQUATIONSOLVERS_H
#include <complex>
#include <iostream>
#include <sstream>
#include <utility>
...
...
Prev
1
2
3
4
5
…
9
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment