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
ee4c22e9
Commit
ee4c22e9
authored
Aug 04, 2010
by
Sebastian Eichelbaum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[CHANGE] - now multiple histograms can be cached in WDataSetSingle once they have been requested.
parent
7e47022c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
13 deletions
+16
-13
src/dataHandler/WDataSetScalar.cpp
src/dataHandler/WDataSetScalar.cpp
+8
-9
src/dataHandler/WDataSetScalar.h
src/dataHandler/WDataSetScalar.h
+8
-4
No files found.
src/dataHandler/WDataSetScalar.cpp
View file @
ee4c22e9
...
...
@@ -43,9 +43,6 @@ WDataSetScalar::WDataSetScalar( boost::shared_ptr< WValueSetBase > newValueSet,
WAssert
(
newGrid
,
"No grid given."
);
WAssert
(
newValueSet
->
size
()
==
newGrid
->
size
(),
"Number of values unequal number of positions in grid."
);
WAssert
(
newValueSet
->
order
()
==
0
,
"The value set does not contain scalars."
);
// the histogram gets calculated on demand
m_histogram
=
boost
::
shared_ptr
<
WValueSetHistogram
>
();
}
WDataSetScalar
::
WDataSetScalar
()
...
...
@@ -138,16 +135,18 @@ double WDataSetScalar::getValueAt( int x, int y, int z ) const
return
WDataSetSingle
::
getValueAt
(
id
);
}
boost
::
shared_ptr
<
const
WValueSetHistogram
>
WDataSetScalar
::
getHistogram
()
boost
::
shared_ptr
<
const
WValueSetHistogram
>
WDataSetScalar
::
getHistogram
(
size_t
buckets
)
{
if
(
m_histogram
)
boost
::
lock_guard
<
boost
::
mutex
>
lock
(
m_histogramLock
);
if
(
m_histograms
.
count
(
buckets
)
!=
0
)
{
return
m_histogram
;
return
m_histogram
s
[
buckets
]
;
}
boost
::
lock_guard
<
boost
::
mutex
>
lock
(
m_histogramLock
);
m_histogram
=
boost
::
shared_ptr
<
WValueSetHistogram
>
(
new
WValueSetHistogram
(
m_valueSet
)
);
// create if not yet existing
m_histogram
s
[
buckets
]
=
boost
::
shared_ptr
<
WValueSetHistogram
>
(
new
WValueSetHistogram
(
m_valueSet
,
buckets
)
);
return
m_histogram
;
return
m_histogram
s
[
buckets
]
;
}
src/dataHandler/WDataSetScalar.h
View file @
ee4c22e9
...
...
@@ -70,11 +70,15 @@ public:
double
getMin
()
const
;
/**
* Returns the histogram of this dataset's valueset. If it does not exist yet, it will be created.
* Returns the histogram of this dataset's valueset. If it does not exist yet, it will be created and cached. It does NOT make use of the
* WValueSetHistogram down scaling feature even though the number of buckets might be lower than the default as the down scaling might
* introduce errors. To use down-scaling, grab the default histogram and call WValueSetHistogram( getHistogram(), buckets ) manually.
*
* \param buckets the number of buckets inside the histogram.
*
* \return the histogram.
*/
boost
::
shared_ptr
<
const
WValueSetHistogram
>
getHistogram
();
boost
::
shared_ptr
<
const
WValueSetHistogram
>
getHistogram
(
size_t
buckets
=
1000
);
/**
* Interpolate the value fo the valueset at the given position.
...
...
@@ -124,9 +128,9 @@ protected:
private:
/**
* The histogram
for later use
.
* The histogram
s for later use. Each histogram for a requested bucket count gets cached
.
**/
boost
::
shared_ptr
<
WValueSetHistogram
>
m_histogram
;
std
::
map
<
size_t
,
boost
::
shared_ptr
<
WValueSetHistogram
>
>
m_histograms
;
/**
* The lock used for securely creating m_histogram on demand.
...
...
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