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
3afc6ef7
Commit
3afc6ef7
authored
Aug 01, 2013
by
Andreas Schwarzkopf
Browse files
[FIX
#294
] fixed problem producing spikes
parent
cfea9cbf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
28 deletions
+36
-28
src/modules/butterfly/ButterflyFactory.cpp
src/modules/butterfly/ButterflyFactory.cpp
+7
-17
src/modules/butterfly/WMButterfly.cpp
src/modules/butterfly/WMButterfly.cpp
+27
-9
src/modules/butterfly/WMButterfly.h
src/modules/butterfly/WMButterfly.h
+2
-2
No files found.
src/modules/butterfly/ButterflyFactory.cpp
View file @
3afc6ef7
...
...
@@ -36,7 +36,7 @@ namespace butterfly
{
float
ButterflyFactory
::
w
=
0.0
f
,
ButterflyFactory
::
factor
[
4
][
7
]
=
{{
0.75
f
,
5.0
f
/
12.0
f
,
-
1.0
f
/
12.0
f
,
-
1.0
f
/
12.0
f
,
0.0
f
,
0.0
f
,
0.0
f
},
//NOLINT
{
0.75
f
,
3.0
f
/
8.0
f
,
-
1.0
f
/
8.0
f
,
0.0
f
,
-
1.0
f
/
8.0
f
,
0.0
f
,
0.0
f
},
//NOLINT
{
0.
8
75
f
,
3.0
f
/
8.0
f
,
-
1.0
f
/
8.0
f
,
0.0
f
,
-
1.0
f
/
8.0
f
,
0.0
f
,
0.0
f
},
//NOLINT
{
0.0
f
,
0.0
f
,
0.0
f
,
0.0
f
,
0.0
f
,
0.0
f
,
0.0
f
},
//NOLINT
{
0.5
f
-
w
,
0.0
f
,
0.125
f
+
2
*
w
,
-
0.0625
f
-
w
,
w
,
-
0.0625
f
-
w
,
0.125
f
+
2
*
w
}},
//NOLINT
ButterflyFactory
::
s1
=
9.0
f
/
16.0
f
,
...
...
@@ -155,19 +155,8 @@ namespace butterfly
final
=
add
(
Vec3
(
0.0
f
,
0.0
f
,
0.0
f
),
getKNeighbourValueBoundary
(
vertID1
,
vertID2
,
false
,
false
),
1.0
f
);
final
=
add
(
final
,
getKNeighbourValueBoundary
(
vertID2
,
vertID1
,
true
,
false
),
1.0
f
);
}
else
if
(
false
/*(k1==6) != (k2==6)*/
)
{
//Case 2: one vertex of valence=6 and onother has valence!=6
if
(
k1
!=
6
)
{
final
=
getKNeighbourValueBoundary
(
vertID1
,
vertID2
,
false
,
false
);
}
else
{
final
=
getKNeighbourValueBoundary
(
vertID2
,
vertID1
,
false
,
false
);
}
}
else
if
(
k1
!=
6
||
k2
!=
6
)
{
//Case 3:
two
vert
ices
of valence!=6
{
//Case
2/
3:
at least one
vert
ex
of valence!=6
final
=
add
(
Vec3
(
0.0
f
,
0.0
f
,
0.0
f
),
getKNeighbourValueBoundary
(
vertID1
,
vertID2
,
false
,
true
),
0.5
f
);
final
=
add
(
final
,
getKNeighbourValueBoundary
(
vertID2
,
vertID1
,
false
,
true
),
0.5
f
);
}
...
...
@@ -213,9 +202,10 @@ namespace butterfly
if
(
bounds
==
1
)
k
+=
k
-
2
;
int
k_row
=
static_cast
<
int
>
(
k
+
0.3
f
)
-
3
;
bool
isDefaultButterfly
=
(
k
==
3
||
k
==
4
||
(
k
==
6
&&
!
treatK6AsKn
)
);
bool
hasCustomWeight
=
(
k
==
3
||
k
==
4
||
(
k
==
6
&&
!
treatK6AsKn
)
);
Vec3
final
=
add
(
Vec3
(
0.0
f
,
0.0
f
,
0.0
f
),
mesh
->
getVertex
(
stencilCenterVertID
),
isDefaultButterfly
?
factor
[
k_row
][
0
]
:
factor
[
0
][
0
]
);
hasCustomWeight
?
factor
[
k_row
][
0
]
:
factor
[
0
][
0
]
);
for
(
int
i
=
0
;
i
<
k
;
i
++
)
{
float
j
=
i
-
start
;
...
...
@@ -225,7 +215,7 @@ namespace butterfly
int
i_mirrored
=
isBehindBound
?
i
-
k
/
2
:
i
,
k_col
=
1
+
static_cast
<
int
>
(
j
+
0.3
f
);
int
neighbourID
=
verts
->
getVertexProperty
(
stencilCenterVertID
)
->
getNeighbourVertices
()[
i_mirrored
];
float
s_j
=
isDefaultButterfly
?
factor
[
k_row
][
k_col
]
float
s_j
=
hasCustomWeight
?
factor
[
k_row
][
k_col
]
:
(
0.25
f
+
cos
(
2.0
f
*
M_PI
*
j
/
k
)
+
0.5
f
*
cos
(
4.0
f
*
M_PI
*
j
/
k
)
)
/
k
;
Vec3
value
=
mesh
->
getVertex
(
neighbourID
);
if
(
isBehindBound
)
...
...
@@ -233,7 +223,7 @@ namespace butterfly
value
=
add
(
mesh
->
getVertex
(
stencilCenterVertID
),
value
,
-
1.0
f
);
value
=
add
(
mesh
->
getVertex
(
stencilCenterVertID
),
value
,
1.0
f
);
}
if
(
!
isSecondK6
||
(
j
!=
1
&&
j
!=
5
)
)
if
(
!
isSecondK6
||
treatK6AsKn
||
(
j
!=
1
&&
j
!=
5
)
)
final
=
add
(
final
,
value
,
s_j
);
}
return
final
;
...
...
src/modules/butterfly/WMButterfly.cpp
View file @
3afc6ef7
...
...
@@ -45,14 +45,6 @@ const double M_PI = 3.14159265358979323846;
// This line is needed by the module loader to actually find your module.
W_LOADABLE_MODULE
(
WMButterfly
)
float
WMButterfly
::
w
=
0.0
f
,
WMButterfly
::
factor
[
4
][
7
]
=
{{
0.75
f
,
5.0
f
/
12.0
f
,
-
1.0
f
/
12.0
f
,
-
1.0
f
/
12.0
f
,
0.0
f
,
0.0
f
,
0.0
f
},
//NOLINT
{
0.75
f
,
3.0
f
/
8.0
f
,
-
1.0
f
/
8.0
f
,
0.0
f
,
-
1.0
f
/
8.0
f
,
0.0
f
,
0.0
f
},
//NOLINT
{
0.0
f
,
0.0
f
,
0.0
f
,
0.0
f
,
0.0
f
,
0.0
f
,
0.0
f
},
//NOLINT
{
0.5
f
-
w
,
0.0
f
,
0.125
f
+
2
*
w
,
-
0.0625
f
-
w
,
w
,
-
0.0625
f
-
w
,
0.125
f
+
2
*
w
}},
//NOLINT
WMButterfly
::
s1
=
9.0
f
/
16.0
f
,
WMButterfly
::
s2
=
-
1.0
f
/
16.0
f
;
WMButterfly
::
WMButterfly
()
:
WModule
(),
m_propCondition
(
new
WCondition
()
)
{
...
...
@@ -76,7 +68,7 @@ const char** WMButterfly::getXPMIcon() const
const
std
::
string
WMButterfly
::
getName
()
const
{
return
"
[Proj.]
Butterfly"
;
return
"Butterfly
subdivision
"
;
}
const
std
::
string
WMButterfly
::
getDescription
()
const
...
...
@@ -172,5 +164,31 @@ void WMButterfly::moduleMain()
// ---> Insert code doing the real stuff here
}
WKernel
::
getRunningKernel
()
->
getGraphicsEngine
()
->
getScene
()
->
remove
(
m_rootNode
);
}
boost
::
shared_ptr
<
WTriangleMesh
>
WMButterfly
::
popUnusedVertices
(
boost
::
shared_ptr
<
WTriangleMesh
>
inputMesh
)
{
boost
::
shared_ptr
<
WTriangleMesh
>
outputMesh
(
new
WTriangleMesh
(
0
,
0
)
);
size_t
triCount
=
0
;
boost
::
shared_ptr
<
WTriangleMesh
>
tmpMesh
(
new
WTriangleMesh
(
0
,
0
)
);
try
{
while
(
true
)
{
Vec3
point0
=
inputMesh
->
getVertex
(
mesh
->
getTriVertId0
(
triCount
)
);
Vec3
point1
=
inputMesh
->
getVertex
(
mesh
->
getTriVertId1
(
triCount
)
);
Vec3
point2
=
inputMesh
->
getVertex
(
mesh
->
getTriVertId2
(
triCount
)
);
outputMesh
->
addTriangle
(
point0
,
point1
,
point2
);
triCount
++
;
}
}
catch
(
...
)
{
}
return
inputMesh
;
}
src/modules/butterfly/WMButterfly.h
View file @
3afc6ef7
...
...
@@ -69,6 +69,8 @@ protected:
/**Entry point after loading the module. Runs in separate thread.*/
virtual
void
moduleMain
();
virtual
boost
::
shared_ptr
<
WTriangleMesh
>
popUnusedVertices
(
boost
::
shared_ptr
<
WTriangleMesh
>
inputMesh
);
/**Initialize the connectors this module is using.*/
virtual
void
connectors
();
...
...
@@ -96,8 +98,6 @@ private:
boost
::
shared_ptr
<
WTriangleMesh
>
mesh
;
butterfly
::
VertexFactory
*
verts
;
static
float
w
,
factor
[
4
][
7
],
s1
,
s2
;
butterfly
::
ButterflyFactory
*
butterfly
;
};
...
...
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