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
5b13f239
Commit
5b13f239
authored
Aug 12, 2010
by
schurade
Browse files
[ADD] additional pencil shapes
parent
0d57b8da
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
327 additions
and
4 deletions
+327
-4
src/dataHandler/WGridRegular3D.cpp
src/dataHandler/WGridRegular3D.cpp
+200
-0
src/dataHandler/WGridRegular3D.h
src/dataHandler/WGridRegular3D.h
+44
-0
src/modules/paintTexture/WMPaintTexture.cpp
src/modules/paintTexture/WMPaintTexture.cpp
+82
-3
src/modules/paintTexture/WMPaintTexture.h
src/modules/paintTexture/WMPaintTexture.h
+1
-1
No files found.
src/dataHandler/WGridRegular3D.cpp
View file @
5b13f239
...
...
@@ -378,6 +378,16 @@ int WGridRegular3D::getVoxelNum( const wmath::WPosition& pos ) const
+
zVoxelCoord
*
(
m_nbPosX
)
*
(
m_nbPosY
);
}
int
WGridRegular3D
::
getVoxelNum
(
const
size_t
x
,
const
size_t
y
,
const
size_t
z
)
const
{
// since we use size_t here only a check for the upper bounds is needed
if
(
x
>
m_nbPosX
||
y
>
m_nbPosY
||
z
>
m_nbPosZ
)
{
return
-
1
;
}
return
x
+
y
*
(
m_nbPosX
)
+
z
*
(
m_nbPosX
)
*
(
m_nbPosY
);
}
int
WGridRegular3D
::
getNVoxelCoord
(
const
wmath
::
WPosition
&
pos
,
size_t
axis
)
const
{
double
result
=
pos
[
axis
]
-
m_origin
[
axis
];
...
...
@@ -673,6 +683,196 @@ std::vector< size_t > WGridRegular3D::getNeighbours27( size_t id ) const
return
neighbours
;
}
std
::
vector
<
size_t
>
WGridRegular3D
::
getNeighbours9XY
(
size_t
id
)
const
{
std
::
vector
<
size_t
>
neighbours
;
size_t
x
=
id
%
m_nbPosX
;
size_t
y
=
(
id
/
m_nbPosX
)
%
m_nbPosY
;
size_t
z
=
id
/
(
m_nbPosX
*
m_nbPosY
);
if
(
x
>=
m_nbPosX
||
y
>=
m_nbPosY
||
z
>=
m_nbPosZ
)
{
std
::
stringstream
ss
;
ss
<<
"This point: "
<<
id
<<
" is not part of this grid: "
;
ss
<<
" nbPosX: "
<<
m_nbPosX
;
ss
<<
" nbPosY: "
<<
m_nbPosY
;
ss
<<
" nbPosZ: "
<<
m_nbPosZ
;
throw
WOutOfBounds
(
ss
.
str
()
);
}
// for every neighbour we must check if its not on the boundary, it will be skipped otherwise
int
vNum
;
size_t
test
=
0
;
vNum
=
getVoxelNum
(
x
-
1
,
y
,
z
);
if
(
vNum
!=
-
1
)
{
neighbours
.
push_back
(
vNum
);
}
vNum
=
getVoxelNum
(
x
-
1
,
y
-
1
,
z
);
if
(
vNum
!=
-
1
)
{
neighbours
.
push_back
(
vNum
);
}
vNum
=
getVoxelNum
(
x
,
y
-
1
,
z
);
if
(
vNum
!=
-
1
)
{
neighbours
.
push_back
(
vNum
);
}
vNum
=
getVoxelNum
(
x
+
1
,
y
-
1
,
z
);
if
(
vNum
!=
-
1
)
{
neighbours
.
push_back
(
vNum
);
}
vNum
=
getVoxelNum
(
x
+
1
,
y
,
z
);
if
(
vNum
!=
-
1
)
{
neighbours
.
push_back
(
vNum
);
}
vNum
=
getVoxelNum
(
x
+
1
,
y
+
1
,
z
);
if
(
vNum
!=
-
1
)
{
neighbours
.
push_back
(
vNum
);
}
vNum
=
getVoxelNum
(
x
,
y
+
1
,
z
);
if
(
vNum
!=
-
1
)
{
neighbours
.
push_back
(
vNum
);
}
vNum
=
getVoxelNum
(
x
-
1
,
y
+
1
,
z
);
if
(
vNum
!=
-
1
)
{
neighbours
.
push_back
(
vNum
);
}
return
neighbours
;
}
std
::
vector
<
size_t
>
WGridRegular3D
::
getNeighbours9YZ
(
size_t
id
)
const
{
std
::
vector
<
size_t
>
neighbours
;
size_t
x
=
id
%
m_nbPosX
;
size_t
y
=
(
id
/
m_nbPosX
)
%
m_nbPosY
;
size_t
z
=
id
/
(
m_nbPosX
*
m_nbPosY
);
if
(
x
>=
m_nbPosX
||
y
>=
m_nbPosY
||
z
>=
m_nbPosZ
)
{
std
::
stringstream
ss
;
ss
<<
"This point: "
<<
id
<<
" is not part of this grid: "
;
ss
<<
" nbPosX: "
<<
m_nbPosX
;
ss
<<
" nbPosY: "
<<
m_nbPosY
;
ss
<<
" nbPosZ: "
<<
m_nbPosZ
;
throw
WOutOfBounds
(
ss
.
str
()
);
}
// for every neighbour we must check if its not on the boundary, it will be skipped otherwise
int
vNum
;
vNum
=
getVoxelNum
(
x
,
y
,
z
-
1
);
if
(
vNum
!=
-
1
)
{
neighbours
.
push_back
(
vNum
);
}
vNum
=
getVoxelNum
(
x
,
y
-
1
,
z
-
1
);
if
(
vNum
!=
-
1
)
{
neighbours
.
push_back
(
vNum
);
}
vNum
=
getVoxelNum
(
x
,
y
-
1
,
z
);
if
(
vNum
!=
-
1
)
{
neighbours
.
push_back
(
vNum
);
}
vNum
=
getVoxelNum
(
x
,
y
-
1
,
z
+
1
);
if
(
vNum
!=
-
1
)
{
neighbours
.
push_back
(
vNum
);
}
vNum
=
getVoxelNum
(
x
,
y
,
z
+
1
);
if
(
vNum
!=
-
1
)
{
neighbours
.
push_back
(
vNum
);
}
vNum
=
getVoxelNum
(
x
,
y
+
1
,
z
+
1
);
if
(
vNum
!=
-
1
)
{
neighbours
.
push_back
(
vNum
);
}
vNum
=
getVoxelNum
(
x
,
y
+
1
,
z
);
if
(
vNum
!=
-
1
)
{
neighbours
.
push_back
(
vNum
);
}
vNum
=
getVoxelNum
(
x
,
y
+
1
,
z
-
1
);
if
(
vNum
!=
-
1
)
{
neighbours
.
push_back
(
vNum
);
}
return
neighbours
;
}
std
::
vector
<
size_t
>
WGridRegular3D
::
getNeighbours9XZ
(
size_t
id
)
const
{
std
::
vector
<
size_t
>
neighbours
;
size_t
x
=
id
%
m_nbPosX
;
size_t
y
=
(
id
/
m_nbPosX
)
%
m_nbPosY
;
size_t
z
=
id
/
(
m_nbPosX
*
m_nbPosY
);
if
(
x
>=
m_nbPosX
||
y
>=
m_nbPosY
||
z
>=
m_nbPosZ
)
{
std
::
stringstream
ss
;
ss
<<
"This point: "
<<
id
<<
" is not part of this grid: "
;
ss
<<
" nbPosX: "
<<
m_nbPosX
;
ss
<<
" nbPosY: "
<<
m_nbPosY
;
ss
<<
" nbPosZ: "
<<
m_nbPosZ
;
throw
WOutOfBounds
(
ss
.
str
()
);
}
// for every neighbour we must check if its not on the boundary, it will be skipped otherwise
int
vNum
;
vNum
=
getVoxelNum
(
x
,
y
,
z
-
1
);
if
(
vNum
!=
-
1
)
{
neighbours
.
push_back
(
vNum
);
}
vNum
=
getVoxelNum
(
x
-
1
,
y
,
z
-
1
);
if
(
vNum
!=
-
1
)
{
neighbours
.
push_back
(
vNum
);
}
vNum
=
getVoxelNum
(
x
-
1
,
y
,
z
);
if
(
vNum
!=
-
1
)
{
neighbours
.
push_back
(
vNum
);
}
vNum
=
getVoxelNum
(
x
-
1
,
y
,
z
+
1
);
if
(
vNum
!=
-
1
)
{
neighbours
.
push_back
(
vNum
);
}
vNum
=
getVoxelNum
(
x
,
y
,
z
+
1
);
if
(
vNum
!=
-
1
)
{
neighbours
.
push_back
(
vNum
);
}
vNum
=
getVoxelNum
(
x
+
1
,
y
,
z
+
1
);
if
(
vNum
!=
-
1
)
{
neighbours
.
push_back
(
vNum
);
}
vNum
=
getVoxelNum
(
x
+
1
,
y
,
z
);
if
(
vNum
!=
-
1
)
{
neighbours
.
push_back
(
vNum
);
}
vNum
=
getVoxelNum
(
x
+
1
,
y
,
z
-
1
);
if
(
vNum
!=
-
1
)
{
neighbours
.
push_back
(
vNum
);
}
return
neighbours
;
}
bool
WGridRegular3D
::
encloses
(
const
wmath
::
WPosition
&
pos
)
const
...
...
src/dataHandler/WGridRegular3D.h
View file @
5b13f239
...
...
@@ -288,6 +288,18 @@ public:
*/
int
getVoxelNum
(
const
wmath
::
WPosition
&
pos
)
const
;
/**
* returns the voxel index for a given discrete position in the grid
*
* \param x Position for which we want to have the voxel number.
* \param y Position for which we want to have the voxel number.
* \param z Position for which we want to have the voxel number.
*
* \return Voxel number or -1 if the position refers to a point outside of
* the grid.
*/
int
getVoxelNum
(
const
size_t
x
,
const
size_t
y
,
const
size_t
z
)
const
;
/**
* Computes the X coordinate of that voxel that contains the
* position pos.
...
...
@@ -417,6 +429,38 @@ public:
*/
std
::
vector
<
size_t
>
getNeighbours27
(
size_t
id
)
const
;
/**
* Return the list of all neighbour voxels.
*
* \throw WOutOfBounds If the voxel id is outside of the grid.
*
* \param id Number of the voxel for which the neighbours should be computed
*
* \return Vector of voxel ids which are all neighboured along the XY plane
*/
std
::
vector
<
size_t
>
getNeighbours9XY
(
size_t
id
)
const
;
/**
* Return the list of all neighbour voxels.
*
* \throw WOutOfBounds If the voxel id is outside of the grid.
*
* \param id Number of the voxel for which the neighbours should be computed
*
* \return Vector of voxel ids which are all neighboured along the YZ plane
*/
std
::
vector
<
size_t
>
getNeighbours9YZ
(
size_t
id
)
const
;
/**
* Return the list of all neighbour voxels.
*
* \throw WOutOfBounds If the voxel id is outside of the grid.
*
* \param id Number of the voxel for which the neighbours should be computed
*
* \return Vector of voxel ids which are all neighboured along the XZ plane
*/
std
::
vector
<
size_t
>
getNeighbours9XZ
(
size_t
id
)
const
;
/**
* Decides whether a certain position is inside this grid or not.
...
...
src/modules/paintTexture/WMPaintTexture.cpp
View file @
5b13f239
...
...
@@ -97,6 +97,8 @@ void WMPaintTexture::properties()
m_pencilSelectionsList
->
addItem
(
"1x1"
,
""
);
m_pencilSelectionsList
->
addItem
(
"3x3"
,
""
);
m_pencilSelectionsList
->
addItem
(
"5x5"
,
""
);
m_pencilSelectionsList
->
addItem
(
"3x1 (only works on orthogonal slices)"
,
""
);
m_pencilSelectionsList
->
addItem
(
"5x1 (only works on orthogonal slices)"
,
""
);
m_pencilSelection
=
m_properties
->
addProperty
(
"Pencil"
,
"Pencil type."
,
m_pencilSelectionsList
->
getSelectorFirst
()
);
WPropertyHelper
::
PC_SELECTONLYONE
::
addTo
(
m_pencilSelection
);
...
...
@@ -254,7 +256,8 @@ void WMPaintTexture::doPaint()
while
(
!
m_paintQueue
.
empty
()
)
{
wmath
::
WPosition
paintPosition
=
m_paintQueue
.
front
();
WPickInfo
pickInfo
=
m_paintQueue
.
front
();
wmath
::
WPosition
paintPosition
=
pickInfo
.
getPickPosition
();
m_paintQueue
.
pop
();
int
voxelNum
=
m_grid
->
getVoxelNum
(
paintPosition
);
...
...
@@ -282,13 +285,89 @@ void WMPaintTexture::doPaint()
for
(
size_t
i
=
0
;
i
<
ids
.
size
();
++
i
)
{
std
::
vector
<
size_t
>
allIds
=
m_grid
->
getNeighbours27
(
ids
[
i
]
);
for
(
size_t
k
=
0
;
k
<
i
ds
.
size
();
++
k
)
for
(
size_t
k
=
0
;
k
<
allI
ds
.
size
();
++
k
)
{
data
[
allIds
[
k
]
]
=
m_paintIndex
->
get
();
}
}
break
;
}
case
3
:
{
if
(
pickInfo
.
getName
()
==
"Axial Slice"
)
{
data
[
voxelNum
]
=
m_paintIndex
->
get
();
std
::
vector
<
size_t
>
ids
=
m_grid
->
getNeighbours9XY
(
voxelNum
);
for
(
size_t
i
=
0
;
i
<
ids
.
size
();
++
i
)
{
data
[
ids
[
i
]
]
=
m_paintIndex
->
get
();
}
}
if
(
pickInfo
.
getName
()
==
"Coronal Slice"
)
{
data
[
voxelNum
]
=
m_paintIndex
->
get
();
std
::
vector
<
size_t
>
ids
=
m_grid
->
getNeighbours9XZ
(
voxelNum
);
for
(
size_t
i
=
0
;
i
<
ids
.
size
();
++
i
)
{
data
[
ids
[
i
]
]
=
m_paintIndex
->
get
();
}
}
if
(
pickInfo
.
getName
()
==
"Sagittal Slice"
)
{
data
[
voxelNum
]
=
m_paintIndex
->
get
();
std
::
vector
<
size_t
>
ids
=
m_grid
->
getNeighbours9YZ
(
voxelNum
);
for
(
size_t
i
=
0
;
i
<
ids
.
size
();
++
i
)
{
data
[
ids
[
i
]
]
=
m_paintIndex
->
get
();
}
}
break
;
}
case
4
:
{
if
(
pickInfo
.
getName
()
==
"Axial Slice"
)
{
data
[
voxelNum
]
=
m_paintIndex
->
get
();
std
::
vector
<
size_t
>
ids
=
m_grid
->
getNeighbours9XY
(
voxelNum
);
for
(
size_t
i
=
0
;
i
<
ids
.
size
();
++
i
)
{
std
::
vector
<
size_t
>
allIds
=
m_grid
->
getNeighbours9XY
(
ids
[
i
]
);
for
(
size_t
k
=
0
;
k
<
allIds
.
size
();
++
k
)
{
data
[
allIds
[
k
]
]
=
m_paintIndex
->
get
();
}
}
}
if
(
pickInfo
.
getName
()
==
"Coronal Slice"
)
{
data
[
voxelNum
]
=
m_paintIndex
->
get
();
std
::
vector
<
size_t
>
ids
=
m_grid
->
getNeighbours9XZ
(
voxelNum
);
for
(
size_t
i
=
0
;
i
<
ids
.
size
();
++
i
)
{
std
::
vector
<
size_t
>
allIds
=
m_grid
->
getNeighbours9XZ
(
ids
[
i
]
);
for
(
size_t
k
=
0
;
k
<
allIds
.
size
();
++
k
)
{
data
[
allIds
[
k
]
]
=
m_paintIndex
->
get
();
}
}
}
if
(
pickInfo
.
getName
()
==
"Sagittal Slice"
)
{
data
[
voxelNum
]
=
m_paintIndex
->
get
();
std
::
vector
<
size_t
>
ids
=
m_grid
->
getNeighbours9YZ
(
voxelNum
);
for
(
size_t
i
=
0
;
i
<
ids
.
size
();
++
i
)
{
std
::
vector
<
size_t
>
allIds
=
m_grid
->
getNeighbours9YZ
(
ids
[
i
]
);
for
(
size_t
k
=
0
;
k
<
allIds
.
size
();
++
k
)
{
data
[
allIds
[
k
]
]
=
m_paintIndex
->
get
();
}
}
}
break
;
}
default:
break
;
}
...
...
@@ -305,7 +384,7 @@ void WMPaintTexture::queuePaint( WPickInfo pickInfo )
{
return
;
}
m_paintQueue
.
push
(
pickInfo
.
getPickPosition
()
);
m_paintQueue
.
push
(
pickInfo
);
m_queueAdded
->
set
(
true
);
}
...
...
src/modules/paintTexture/WMPaintTexture.h
View file @
5b13f239
...
...
@@ -196,7 +196,7 @@ private:
/**
* new paint coordinates get added here
*/
std
::
queue
<
wmath
::
WPosition
>
m_paintQueue
;
std
::
queue
<
WPickInfo
>
m_paintQueue
;
/**
* An input connector that accepts order 1 datasets.
...
...
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