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
b8de9191
Commit
b8de9191
authored
Dec 17, 2009
by
Alexander Wiebel
Browse files
[CHANGE
#161
] can change the siovalue and update the surface from the gui
now
parent
fd7d233b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
40 deletions
+52
-40
src/modules/marchingCubes/WMMarchingCubes.cpp
src/modules/marchingCubes/WMMarchingCubes.cpp
+48
-40
src/modules/marchingCubes/WMMarchingCubes.h
src/modules/marchingCubes/WMMarchingCubes.h
+4
-0
No files found.
src/modules/marchingCubes/WMMarchingCubes.cpp
View file @
b8de9191
...
...
@@ -116,43 +116,11 @@ void WMMarchingCubes::moduleMain()
boost
::
shared_ptr
<
WDataHandler
>
dh
=
WKernel
::
getRunningKernel
()
->
getDataHandler
();
boost
::
shared_ptr
<
WSubject
>
subject
=
(
*
dh
)[
0
];
boost
::
shared_ptr
<
const
WDataSetSingle
>
dataSet
;
dataSet
=
boost
::
shared_dynamic_cast
<
const
WDataSetSingle
>
(
(
*
subject
)[
0
]
);
m_dataSet
=
boost
::
shared_dynamic_cast
<
const
WDataSetSingle
>
(
(
*
subject
)[
0
]
);
debugLog
()
<<
"Computing surface ..."
;
// TODO(wiebel): MC set correct isoValue here
const
float
testIsoValue
=
80
;
switch
(
(
*
dataSet
).
getValueSet
()
->
getDataType
()
)
{
case
W_DT_UNSIGNED_CHAR
:
{
boost
::
shared_ptr
<
WValueSet
<
unsigned
char
>
>
vals
;
vals
=
boost
::
shared_dynamic_cast
<
WValueSet
<
unsigned
char
>
>
(
(
*
dataSet
).
getValueSet
()
);
assert
(
vals
);
generateSurface
(
(
*
dataSet
).
getGrid
(),
vals
,
testIsoValue
);
break
;
}
case
W_DT_INT16
:
{
boost
::
shared_ptr
<
WValueSet
<
int16_t
>
>
vals
;
vals
=
boost
::
shared_dynamic_cast
<
WValueSet
<
int16_t
>
>
(
(
*
dataSet
).
getValueSet
()
);
assert
(
vals
);
generateSurface
(
(
*
dataSet
).
getGrid
(),
vals
,
testIsoValue
);
break
;
}
case
W_DT_FLOAT
:
{
boost
::
shared_ptr
<
WValueSet
<
float
>
>
vals
;
vals
=
boost
::
shared_dynamic_cast
<
WValueSet
<
float
>
>
(
(
*
dataSet
).
getValueSet
()
);
assert
(
vals
);
generateSurface
(
(
*
dataSet
).
getGrid
(),
vals
,
testIsoValue
);
break
;
}
default:
assert
(
false
&&
"Unknow data type in MarchingCubes module"
);
}
generateSurfacePre
(
m_properties
->
getValue
<
int
>
(
"Iso Value"
)
);
// TODO(wiebel): MC remove this from here
// renderMesh( load( "/tmp/isosurfaceTestMesh.vtk" ) );
...
...
@@ -185,31 +153,71 @@ void WMMarchingCubes::connectors()
void
WMMarchingCubes
::
properties
()
{
// TODO(wiebel): MC this is not the recommended way!
//
m_properties->add
Bool( "texture
Changed
"
,
false
);
m_properties
->
addBool
(
"textureChanged"
,
false
,
true
);
m_properties
->
add
Int
(
"Iso Value"
,
100
)
->
connect
(
boost
::
bind
(
&
WMMarchingCubes
::
slotProperty
Changed
,
this
,
_1
)
);
}
void
WMMarchingCubes
::
slotPropertyChanged
(
std
::
string
propertyName
)
{
// TODO(wiebel): MC improve this method when corresponding infrastructure is ready
if
(
propertyName
==
"
i
soValue"
)
if
(
propertyName
==
"
I
so
Value"
)
{
WKernel
::
getRunningKernel
()
->
getGraphicsEngine
()
->
getScene
()
->
removeChild
(
m_geode
);
generateSurfacePre
(
m_properties
->
getValue
<
int
>
(
"Iso Value"
)
);
renderSurface
();
// updateTextures();
}
else
{
assert
(
0
&&
"This property name is not s
o
pp
u
rted by this function yet."
);
assert
(
0
&&
"This property name is not s
u
pp
o
rted by this function yet."
);
}
}
void
WMMarchingCubes
::
generateSurfacePre
(
double
isoValue
)
{
infoLog
()
<<
"Isovalue: "
<<
isoValue
<<
std
::
endl
;
switch
(
(
*
m_dataSet
).
getValueSet
()
->
getDataType
()
)
{
case
W_DT_UNSIGNED_CHAR
:
{
boost
::
shared_ptr
<
WValueSet
<
unsigned
char
>
>
vals
;
vals
=
boost
::
shared_dynamic_cast
<
WValueSet
<
unsigned
char
>
>
(
(
*
m_dataSet
).
getValueSet
()
);
assert
(
vals
);
generateSurface
(
(
*
m_dataSet
).
getGrid
(),
vals
,
isoValue
);
break
;
}
case
W_DT_INT16
:
{
boost
::
shared_ptr
<
WValueSet
<
int16_t
>
>
vals
;
vals
=
boost
::
shared_dynamic_cast
<
WValueSet
<
int16_t
>
>
(
(
*
m_dataSet
).
getValueSet
()
);
assert
(
vals
);
generateSurface
(
(
*
m_dataSet
).
getGrid
(),
vals
,
isoValue
);
break
;
}
case
W_DT_FLOAT
:
{
boost
::
shared_ptr
<
WValueSet
<
float
>
>
vals
;
vals
=
boost
::
shared_dynamic_cast
<
WValueSet
<
float
>
>
(
(
*
m_dataSet
).
getValueSet
()
);
assert
(
vals
);
generateSurface
(
(
*
m_dataSet
).
getGrid
(),
vals
,
isoValue
);
break
;
}
default:
assert
(
false
&&
"Unknow data type in MarchingCubes module"
);
}
}
template
<
typename
T
>
void
WMMarchingCubes
::
generateSurface
(
boost
::
shared_ptr
<
WGrid
>
inGrid
,
boost
::
shared_ptr
<
WValueSet
<
T
>
>
vals
,
double
isoValue
)
{
// TODO(wiebel): MC have to move this
m_properties
->
addBool
(
"textureChanged"
,
false
);
assert
(
vals
);
m_idToVertices
.
clear
();
m_trivecTriangles
.
clear
();
boost
::
shared_ptr
<
WGridRegular3D
>
grid
=
boost
::
shared_dynamic_cast
<
WGridRegular3D
>
(
inGrid
);
m_grid
=
grid
;
assert
(
grid
);
...
...
src/modules/marchingCubes/WMMarchingCubes.h
View file @
b8de9191
...
...
@@ -250,8 +250,12 @@ private:
*/
WTriangleMesh
load
(
std
::
string
fileName
);
// TODO(wiebel): MC need to document and rename this
void
generateSurfacePre
(
double
isoValue
);
boost
::
shared_ptr
<
const
WDataSetSingle
>
m_dataSet
;
boost
::
shared_ptr
<
WGridRegular3D
>
m_grid
;
//!< pointer to grid, because we need to access the grid for the dimensions of the texture.
bool
m_shaderUseTexture
;
//!< shall the shader use texturing?
bool
m_shaderUseLighting
;
//!< shall the shader use lighting?
...
...
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