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
c38ca384
Commit
c38ca384
authored
Oct 26, 2009
by
Mathias Goldau
Browse files
[ADD
#130
] Added basic functionallity for displaying fibers via the WFiberTestModule
parent
0c3aa5c2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
68 additions
and
3 deletions
+68
-3
src/dataHandler/WDataSetFibers.h
src/dataHandler/WDataSetFibers.h
+2
-2
src/math/WLine.h
src/math/WLine.h
+1
-1
src/modules/fiberTest/WFiberTestModule.cpp
src/modules/fiberTest/WFiberTestModule.cpp
+54
-0
src/modules/fiberTest/WFiberTestModule.h
src/modules/fiberTest/WFiberTestModule.h
+11
-0
No files found.
src/dataHandler/WDataSetFibers.h
View file @
c38ca384
...
...
@@ -48,7 +48,7 @@ public:
/**
* Get number of fibers in this data set.
*/
size_t
size
()
inline
size_t
size
()
const
{
return
m_fibers
->
size
();
}
...
...
@@ -56,7 +56,7 @@ public:
/**
* \return The i'th fiber.
*/
const
wmath
::
WFiber
&
operator
[](
const
size_t
index
)
const
inline
const
wmath
::
WFiber
&
operator
[](
const
size_t
index
)
const
{
assert
(
index
<
m_fibers
->
size
()
);
return
(
*
m_fibers
)[
index
];
...
...
src/math/WLine.h
View file @
c38ca384
...
...
@@ -78,7 +78,7 @@ public:
/**
* Get number of points (length) the value consists of.
*/
size_t
size
()
inline
size_t
size
()
const
{
return
m_points
.
size
();
}
...
...
src/modules/fiberTest/WFiberTestModule.cpp
View file @
c38ca384
...
...
@@ -25,11 +25,17 @@
#include <string>
#include <osg/Geode>
#include <osg/Geometry>
#include <osg/Group>
#include "WFiberTestModule.h"
#include "../../math/WFiber.h"
#include "../../common/WLogger.h"
#include "../../dataHandler/WDataHandler.h"
#include "../../dataHandler/WSubject.h"
#include "../../dataHandler/WDataSetFibers.h"
#include "../../dataHandler/WLoaderManager.h"
#include "../../kernel/WKernel.h"
WFiberTestModule
::
WFiberTestModule
()
:
WModule
()
...
...
@@ -50,6 +56,30 @@ const std::string WFiberTestModule::getDescription() const
return
std
::
string
(
"Draws fibers out of a WDataSetFibers"
);
}
void
WFiberTestModule
::
drawFiber
(
const
wmath
::
WFiber
&
fib
,
osg
::
Group
*
group
)
const
{
osg
::
Vec3Array
*
vertices
=
new
osg
::
Vec3Array
(
fib
.
size
()
);
osg
::
Vec3Array
::
iterator
vitr
=
vertices
->
begin
();
for
(
size_t
i
=
0
;
i
<
fib
.
size
();
++
i
)
{
(
vitr
++
)
->
set
(
fib
[
i
][
0
],
fib
[
i
][
1
],
fib
[
i
][
2
]
);
}
osg
::
Geometry
*
geometry
=
new
osg
::
Geometry
();
geometry
->
setVertexArray
(
vertices
);
geometry
->
addPrimitiveSet
(
new
osg
::
DrawArrays
(
osg
::
PrimitiveSet
::
LINE_STRIP
,
0
,
fib
.
size
()
)
);
osg
::
Vec4Array
*
colors
=
new
osg
::
Vec4Array
;
colors
->
push_back
(
osg
::
Vec4
(
1.0
f
,
1.0
f
,
0.0
f
,
1.0
f
)
);
geometry
->
setColorArray
(
colors
);
geometry
->
setColorBinding
(
osg
::
Geometry
::
BIND_OVERALL
);
osg
::
ref_ptr
<
osg
::
Geode
>
geode
=
new
osg
::
Geode
;
geode
->
addDrawable
(
geometry
);
group
->
addChild
(
geode
);
std
::
cout
<<
"drawn fiber.. "
<<
std
::
endl
;
}
void
WFiberTestModule
::
threadMain
()
{
using
boost
::
shared_ptr
;
...
...
@@ -58,4 +88,28 @@ void WFiberTestModule::threadMain()
shared_ptr
<
WDataHandler
>
dataHandler
=
shared_ptr
<
WDataHandler
>
(
new
WDataHandler
()
);
WLoaderManager
testLoaderManager
;
testLoaderManager
.
load
(
fname
,
dataHandler
);
std
::
cout
<<
"Number of DS: "
<<
dataHandler
->
getNumberOfSubjects
()
<<
std
::
endl
;
sleep
(
10
);
// we need this to allow the thread to terminate
std
::
cout
<<
"Number of DS: "
<<
dataHandler
->
getNumberOfSubjects
()
<<
std
::
endl
;
shared_ptr
<
const
WDataSetFibers
>
fiberDS
;
assert
(
fiberDS
=
boost
::
shared_dynamic_cast
<
const
WDataSetFibers
>
(
dataHandler
->
getSubject
(
0
)
->
getDataSet
(
0
)
)
);
const
WDataSetFibers
&
fibers
=
*
fiberDS
;
// just an alias
// osg group node bauen
osg
::
Group
*
group
=
new
osg
::
Group
;
// osg childs an die group hängen
for
(
size_t
i
=
0
;
i
<
fibers
.
size
();
++
i
)
{
drawFiber
(
fibers
[
i
],
group
);
}
WKernel
::
getRunningKernel
()
->
getGraphicsEngine
()
->
getScene
()
->
addChild
(
group
);
// Since the modules run in a separate thread: such loops are possible
while
(
!
m_FinishRequested
)
{
// do fancy stuff
sleep
(
1
);
}
}
src/modules/fiberTest/WFiberTestModule.h
View file @
c38ca384
...
...
@@ -27,7 +27,10 @@
#include <string>
#include <osg/Group>
#include "../../kernel/WModule.h"
#include "../../math/WFiber.h"
/**
* Test module for drawing fibers
...
...
@@ -63,6 +66,14 @@ protected:
*/
virtual
void
threadMain
();
/**
* Draws the given fiber into the given osg::Groupe node.
*
* \param fib reference to a WFiber instance
* \param group OSG group node, where all fibers are drawn into
*/
void
drawFiber
(
const
wmath
::
WFiber
&
fib
,
osg
::
Group
*
group
)
const
;
private:
};
...
...
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