Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
OpenWalnut Core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
44
Issues
44
List
Boards
Labels
Service Desk
Milestones
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
343d9c0f
Commit
343d9c0f
authored
Apr 07, 2011
by
Stefan Philips
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ADD] Add WGridRegular3D pointer attribute to avoid dynamic cast
[CHANGE] Adapt to spherical harmonics with Eigen vectors
parent
80e58aef
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
12 deletions
+15
-12
src/dataHandler/WDataSetSphericalHarmonics.cpp
src/dataHandler/WDataSetSphericalHarmonics.cpp
+14
-12
src/dataHandler/WDataSetSphericalHarmonics.h
src/dataHandler/WDataSetSphericalHarmonics.h
+1
-0
No files found.
src/dataHandler/WDataSetSphericalHarmonics.cpp
View file @
343d9c0f
...
...
@@ -24,10 +24,13 @@
#include <stdint.h>
#include <cmath>
#include <string>
#include <vector>
#include "../common/WAssert.h"
#include "../common/math/WVector3D.h"
#include "../common/math/WPosition.h"
#include "WDataSetSingle.h"
#include "WDataSetSphericalHarmonics.h"
...
...
@@ -38,6 +41,7 @@ WDataSetSphericalHarmonics::WDataSetSphericalHarmonics( boost::shared_ptr< WValu
boost
::
shared_ptr
<
WGrid
>
newGrid
)
:
WDataSetSingle
(
newValueSet
,
newGrid
),
m_valueSet
(
newValueSet
)
{
m_gridRegular3D
=
boost
::
shared_dynamic_cast
<
WGridRegular3D
>
(
newGrid
);
WAssert
(
newValueSet
,
"No value set given."
);
WAssert
(
newGrid
,
"No grid given."
);
}
...
...
@@ -78,12 +82,10 @@ boost::shared_ptr< WPrototyped > WDataSetSphericalHarmonics::getPrototype()
WSymmetricSphericalHarmonic
WDataSetSphericalHarmonics
::
interpolate
(
const
WPosition
&
pos
,
bool
*
success
)
const
{
boost
::
shared_ptr
<
WGridRegular3D
>
grid
=
boost
::
shared_dynamic_cast
<
WGridRegular3D
>
(
m_grid
);
*
success
=
grid
->
encloses
(
pos
);
*
success
=
m_gridRegular3D
->
encloses
(
pos
);
bool
isInside
=
true
;
size_t
cellId
=
grid
->
getCellId
(
pos
,
&
isInside
);
size_t
cellId
=
m_gridRegular3D
->
getCellId
(
pos
,
&
isInside
);
if
(
!
isInside
)
{
...
...
@@ -92,13 +94,13 @@ WSymmetricSphericalHarmonic WDataSetSphericalHarmonics::interpolate( const WPosi
}
// ids of vertices for interpolation
std
::
vector
<
size_t
>
vertexIds
=
grid
->
getCellVertexIds
(
cellId
);
std
::
vector
<
size_t
>
vertexIds
=
m_gridRegular3D
->
getCellVertexIds
(
cellId
);
WPosition
localPos
=
pos
-
grid
->
getPosition
(
vertexIds
[
0
]
);
WPosition
localPos
=
pos
-
m_gridRegular3D
->
getPosition
(
vertexIds
[
0
]
);
double
lambdaX
=
localPos
[
0
]
/
grid
->
getOffsetX
();
double
lambdaY
=
localPos
[
1
]
/
grid
->
getOffsetY
();
double
lambdaZ
=
localPos
[
2
]
/
grid
->
getOffsetZ
();
double
lambdaX
=
localPos
[
0
]
/
m_gridRegular3D
->
getOffsetX
();
double
lambdaY
=
localPos
[
1
]
/
m_gridRegular3D
->
getOffsetY
();
double
lambdaZ
=
localPos
[
2
]
/
m_gridRegular3D
->
getOffsetZ
();
std
::
vector
<
double
>
h
(
8
);
// lZ lY
// | /
...
...
@@ -119,10 +121,10 @@ WSymmetricSphericalHarmonic WDataSetSphericalHarmonics::interpolate( const WPosi
h
[
7
]
=
(
lambdaX
)
*
(
lambdaY
)
*
(
lambdaZ
);
// take
WV
alue
<
double
>
interpolatedCoefficients
(
m_valueSet
->
dimension
()
);
WV
ector_2
interpolatedCoefficients
(
m_valueSet
->
dimension
()
);
for
(
size_t
i
=
0
;
i
<
8
;
++
i
)
{
interpolatedCoefficients
+=
h
[
i
]
*
m_valueSet
->
getWV
alueDouble
(
vertexIds
[
i
]
);
interpolatedCoefficients
+=
h
[
i
]
*
m_valueSet
->
getWV
ector
(
vertexIds
[
i
]
);
}
*
success
=
true
;
...
...
@@ -132,7 +134,7 @@ WSymmetricSphericalHarmonic WDataSetSphericalHarmonics::interpolate( const WPosi
WSymmetricSphericalHarmonic
WDataSetSphericalHarmonics
::
getSphericalHarmonicAt
(
size_t
index
)
const
{
if
(
index
<
m_valueSet
->
size
()
)
return
WSymmetricSphericalHarmonic
(
m_valueSet
->
getWV
alueDouble
(
index
)
);
if
(
index
<
m_valueSet
->
size
()
)
return
WSymmetricSphericalHarmonic
(
m_valueSet
->
getWV
ector
(
index
)
);
return
WSymmetricSphericalHarmonic
();
}
...
...
src/dataHandler/WDataSetSphericalHarmonics.h
View file @
343d9c0f
...
...
@@ -145,6 +145,7 @@ protected:
static
boost
::
shared_ptr
<
WPrototyped
>
m_prototype
;
private:
boost
::
shared_ptr
<
WGridRegular3D
>
m_gridRegular3D
;
boost
::
shared_ptr
<
WValueSetBase
>
m_valueSet
;
};
...
...
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