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
4ee3b8b9
Commit
4ee3b8b9
authored
Apr 27, 2012
by
Sebastian Eichelbaum
Browse files
[CHANGE
#162
] - improved sphere creator to support several clamping possibilities
parent
edc0a5b6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
7 deletions
+49
-7
src/modules/dataCreator/WDataCreatorRandom.h
src/modules/dataCreator/WDataCreatorRandom.h
+1
-1
src/modules/dataCreator/WDataCreatorSphere.cpp
src/modules/dataCreator/WDataCreatorSphere.cpp
+26
-4
src/modules/dataCreator/WDataCreatorSphere.h
src/modules/dataCreator/WDataCreatorSphere.h
+21
-1
src/modules/dataCreator/WDataSetSingleCreatorInterface.h
src/modules/dataCreator/WDataSetSingleCreatorInterface.h
+1
-1
No files found.
src/modules/dataCreator/WDataCreatorRandom.h
View file @
4ee3b8b9
...
...
@@ -49,7 +49,7 @@ public:
/**
* Create the dataset. This needs to be implemented by all the creators you write. This method is designed to be applicable to all kinds of
* WDataSetSingle that use WValueSetBase. Your implementation does not need to support all types. If you do not support any order/dimension
* combination, throw an exception (like by using
\ref
WAssert).
* combination, throw an exception (like by using WAssert).
*
* \param order the tensor order of the values stored in this WValueSet
* \param dimension the tensor dimension of the values stored in this WValueSet
...
...
src/modules/dataCreator/WDataCreatorSphere.cpp
View file @
4ee3b8b9
...
...
@@ -25,6 +25,7 @@
#include <vector>
#include "core/common/WAssert.h"
#include "core/common/WLimits.h"
#include "WDataCreatorSphere.h"
...
...
@@ -38,6 +39,18 @@ WDataCreatorSphere::WDataCreatorSphere():
m_radius
=
m_properties
->
addProperty
(
"Radius"
,
"The radius in relative coordinates, where 0.5 creates a sphere in the size of the grid."
,
0.5
);
m_radius
->
setMin
(
0.0
);
m_lowerClamp
=
m_properties
->
addProperty
(
"Lower Clamp Threshold"
,
"Defines a threshold which allows all values below this value to be set to 0."
"This can be handy to create spheres which are 0 in the inside."
,
0.0
);
m_lowerClamp
->
setMin
(
0.0
);
m_upperClamp
=
m_properties
->
addProperty
(
"Upper Clamp Threshold"
,
"Defines a threshold which allows all values above this value to be set to 0."
"This can be handy to create an empty field around the sphere"
,
wlimits
::
MAX_DOUBLE
);
m_upperClamp
->
setMin
(
0.0
);
m_lowerClampValue
=
m_properties
->
addProperty
(
"Lower Clamp Value"
,
"Value to use when below lower clamp threshold."
,
0.0
);
m_upperClampValue
=
m_properties
->
addProperty
(
"Upper Clamp Value"
,
"Value to use when above upper clamp threshold."
,
0.0
);
}
WDataCreatorSphere
::~
WDataCreatorSphere
()
...
...
@@ -67,6 +80,12 @@ WValueSetBase::SPtr WDataCreatorSphere::operator()( WProgress::SPtr progress,
// the formular below calculates the stuff in -1,1 interval. The radius is meant to be used in -0.5 to 0.5 -> so scale up
double
radius
=
2.0
*
m_radius
->
get
();
// clamp info
double
lowClamp
=
m_lowerClamp
->
get
();
double
upClamp
=
m_upperClamp
->
get
();
double
upClampValue
=
m_upperClampValue
->
get
();
double
lowClampValue
=
m_lowerClampValue
->
get
();
// iterate the data and fill in some values
double
xRel
=
0.0
;
double
yRel
=
0.0
;
...
...
@@ -89,10 +108,13 @@ WValueSetBase::SPtr WDataCreatorSphere::operator()( WProgress::SPtr progress,
zRel
-=
originZ
;
zRel
*=
2.0
;
data
->
operator
[](
grid
->
getVoxelNum
(
x
,
y
,
z
)
)
=
static_cast
<
ValueType
>
(
(
1.0
/
(
radius
*
radius
)
)
*
(
(
xRel
*
xRel
)
+
(
yRel
*
yRel
)
+
(
zRel
*
zRel
)
)
);
ValueType
val
=
static_cast
<
ValueType
>
(
(
1.0
/
(
radius
*
radius
)
)
*
(
(
xRel
*
xRel
)
+
(
yRel
*
yRel
)
+
(
zRel
*
zRel
)
)
);
// set value
data
->
operator
[](
grid
->
getVoxelNum
(
x
,
y
,
z
)
)
=
val
<
lowClamp
?
lowClampValue
:
(
val
>
upClamp
?
upClampValue
:
val
);
}
// updating progress for each voxel is not needed. It is enough to update each slice
...
...
src/modules/dataCreator/WDataCreatorSphere.h
View file @
4ee3b8b9
...
...
@@ -48,7 +48,7 @@ public:
/**
* Create the dataset. This needs to be implemented by all the creators you write. This method is designed to be applicable to all kinds of
* WDataSetSingle that use WValueSetBase. Your implementation does not need to support all types. If you do not support any order/dimension
* combination, throw an exception (like by using
\ref
WAssert).
* combination, throw an exception (like by using WAssert).
*
* \param order the tensor order of the values stored in this WValueSet
* \param dimension the tensor dimension of the values stored in this WValueSet
...
...
@@ -73,6 +73,26 @@ private:
* The radius of the sphere in relative coordinates.
*/
WPropDouble
m_radius
;
/**
* Clamp to 0 for all values below this one
*/
WPropDouble
m_lowerClamp
;
/**
* Clamp to 0 for all values above
*/
WPropDouble
m_upperClamp
;
/**
* To which value should be clamped?
*/
WPropDouble
m_lowerClampValue
;
/**
* To which value should be clamped?
*/
WPropDouble
m_upperClampValue
;
};
#endif // WDATACREATORSPHERE_H
...
...
src/modules/dataCreator/WDataSetSingleCreatorInterface.h
View file @
4ee3b8b9
...
...
@@ -44,7 +44,7 @@ public:
/**
* Create the dataset. This needs to be implemented by all the creators you write. This method is designed to be applicable to all kinds of
* WDataSetSingle that use WValueSetBase. Your implementation does not need to support all types. If you do not support any order/dimension
* combination, throw an exception (like by using
\ref
WAssert).
* combination, throw an exception (like by using WAssert).
*
* \param order the tensor order of the values stored in this WValueSet
* \param dimension the tensor dimension of the values stored in this WValueSet
...
...
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