Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nt1100 analyser
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pascal Engeler
nt1100 analyser
Commits
3ec81ae4
Commit
3ec81ae4
authored
2 years ago
by
Pascal Engeler
Browse files
Options
Downloads
Patches
Plain Diff
Fixed formatting, fixed bug in line data extraction, plotting works now
parent
07858f66
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/heightmap.cpp
+89
-75
89 additions, 75 deletions
src/heightmap.cpp
with
89 additions
and
75 deletions
src/heightmap.cpp
+
89
−
75
View file @
3ec81ae4
...
...
@@ -156,15 +156,15 @@ Heightmap::Heightmap(std::string filename): _filename(filename) {
/*Setup Framebuffer*/
_framebuffer_ptr
=
std
::
make_shared
<
Framebuffer
>
();
/*Setup plotting vectors*/
_plotAlongX_y
=
_min
X
+
(
_maxY
-
_minY
)
/
2.
f
;
_plotAlongY_x
=
_minX
+
(
_maxX
-
_minX
)
/
2.
f
;
_last_plotAlongX_y
=
-
99999.
f
;
_last_plotAlongY_x
=
-
99999.
f
;
_plotAlongX_data_x
.
resize
(
_Nx
);
_plotAlongX_data_h
.
resize
(
_Nx
);
_plotAlongY_data_y
.
resize
(
_Ny
);
_plotAlongY_data_h
.
resize
(
_Ny
);
/*Setup plotting vectors*/
_plotAlongX_y
=
_min
Y
+
(
_maxY
-
_minY
)
/
2.
f
;
_plotAlongY_x
=
_minX
+
(
_maxX
-
_minX
)
/
2.
f
;
_last_plotAlongX_y
=
-
99999.
f
;
_last_plotAlongY_x
=
-
99999.
f
;
_plotAlongX_data_x
.
resize
(
_Nx
);
_plotAlongX_data_h
.
resize
(
_Nx
);
_plotAlongY_data_y
.
resize
(
_Ny
);
_plotAlongY_data_h
.
resize
(
_Ny
);
}
else
{
throw
Nt1100_exception
(
"Heightmap::Heightmap(std::string): File "
+
filename
+
" contents are empty."
);
...
...
@@ -222,76 +222,90 @@ float Heightmap::getSurfaceHeight(unsigned x, unsigned y, glm::mat4 projection,
}
void
Heightmap
::
updatePlotWindow
(){
ImGui
::
Begin
(
"Height Profiles"
,
nullptr
,
ImGuiWindowFlags_AlwaysAutoResize
);
ImGui
::
SliderFloat
(
"
x
"
,
&
_plotAlong
Y_x
,
_min
X
,
_max
X
,
"%.3f mm"
);
ImGui
::
SliderFloat
(
"
y
"
,
&
_plotAlong
X_y
,
_min
Y
,
_max
Y
,
"%.3f mm"
);
_plotHeightLineAlongX
(
_plotAlongX_y
);
_plotHeightLineAlongY
(
_plotAlongY_x
);
ImGui
::
End
();
ImGui
::
Begin
(
"Height Profiles"
,
nullptr
);
ImGui
::
SliderFloat
(
"
Offset y
"
,
&
_plotAlong
X_y
,
_min
Y
,
_max
Y
,
"%.3f mm"
);
ImGui
::
SliderFloat
(
"
Offset x
"
,
&
_plotAlong
Y_x
,
_min
X
,
_max
X
,
"%.3f mm"
);
_plotHeightLineAlongX
(
_plotAlongX_y
);
_plotHeightLineAlongY
(
_plotAlongY_x
);
ImGui
::
End
();
}
void
Heightmap
::
_plotHeightLineAlongX
(
const
float
y
){
if
(
y
!=
_last_plotAlongX_y
){
_last_plotAlongX_y
=
y
;
if
(
y
>
_maxY
||
y
<
_minY
){
return
;
}
//find correct i (row)
//TODO: This has to change when _data changes
size_t
stride
=
3
;
size_t
i
=
0
;
for
(;
i
<
_Ny
;
++
i
){
if
(
_data
[
stride
*
i
+
1
]
>=
y
){
break
;
}
}
if
(
i
>=
_Ny
){
return
;
}
//traverse the row, push xs and zs to the plotting vectors
for
(
size_t
j
=
0
;
j
<
_Nx
;
++
j
){
_plotAlongX_data_x
[
j
]
=
_data
[
stride
*
j
*
_Ny
+
i
];
_plotAlongX_data_h
[
j
]
=
_data
[
stride
*
j
*
_Ny
+
i
+
2
];
}
}
//plot data
if
(
ImPlot
::
BeginPlot
(
"Heightplot along x"
)){
ImPlot
::
SetupAxes
(
"Position [mm]"
,
"Height [um]"
);
ImPlot
::
SetNextLineStyle
(
ImVec4
(
0.
f
,
0.5
f
,
1.
f
,
1.
f
));
ImPlot
::
PlotLine
(
"Height along x"
,
_plotAlongX_data_x
.
data
(),
_plotAlongX_data_h
.
data
(),
_Nx
);
ImPlot
::
EndPlot
()
}
if
(
y
!=
_last_plotAlongX_y
){
_last_plotAlongX_y
=
y
;
if
(
y
>
_maxY
||
y
<
_minY
){
return
;
}
//find correct i (row)
//TODO: This has to change when _data changes
size_t
stride
=
3
;
size_t
i
=
0
;
for
(;
i
<
_Ny
;
++
i
){
if
(
_data
[
stride
*
i
+
1
]
>=
y
){
break
;
}
}
if
(
i
>=
_Ny
){
std
::
cout
<<
"_plotHeightLineAlongX: Data not found."
<<
std
::
endl
;
return
;
}
std
::
cout
<<
"_plotHeightLineAlongX: Found element "
<<
i
<<
", y = "
<<
_data
[
stride
*
i
+
1
]
<<
std
::
endl
;
//traverse the row, push xs and zs to the plotting vectors
for
(
size_t
j
=
0
;
j
<
_Nx
;
++
j
){
_plotAlongX_data_x
[
j
]
=
_data
[
stride
*
j
*
_Ny
+
stride
*
i
];
if
(
_data
[
stride
*
j
*
_Ny
+
stride
*
i
+
2
]
!=
BAD_Z_VALUE
)
{
_plotAlongX_data_h
[
j
]
=
_minZ
+
_zRangeUm
*
_data
[
stride
*
j
*
_Ny
+
stride
*
i
+
2
];
}
else
{
_plotAlongX_data_h
[
j
]
=
NAN
;
}
}
}
//plot data
if
(
ImPlot
::
BeginPlot
(
"Heightplot along x"
)){
ImPlot
::
SetupAxes
(
"Position [mm]"
,
"Height [um]"
);
ImPlot
::
SetNextLineStyle
(
ImVec4
(
1.
f
,
0.
f
,
1.
f
,
1.
f
));
ImPlot
::
PlotLine
(
"Height along x"
,
_plotAlongX_data_x
.
data
(),
_plotAlongX_data_h
.
data
(),
_Nx
);
ImPlot
::
EndPlot
();
}
}
void
Heightmap
::
_plotHeightLineAlongY
(
const
float
x
){
if
(
x
!=
_last_plotAlongY_x
){
_last_plotAlongY_x
=
x
;
if
(
x
>
_maxX
||
x
<
_minX
){
return
;
}
//find correct i (column)
//TODO: This has to change when _data changes
size_t
stride
=
3
;
size_t
i
=
0
;
for
(;
i
<
_Nx
;
++
i
){
if
(
_data
[
stride
*
_Ny
*
i
]
>=
x
){
break
;
}
}
if
(
i
>=
_Nx
){
return
;
}
//traverse the column, push ys and zs to the plotting vectors
for
(
size_t
j
=
0
;
j
<
_Ny
;
++
j
){
_plotAlongY_data_y
[
j
]
=
_data
[
i
+
stride
*
j
+
1
];
_plotAlongY_data_h
[
j
]
=
_data
[
i
+
stride
*
j
+
2
];
}
}
//plot data
if
(
ImPlot
::
BeginPlot
(
"Heightplot along y"
)){
ImPlot
::
SetupAxes
(
"Position [mm]"
,
"Height [um]"
);
ImPlot
::
SetNextLineStyle
(
ImVec4
(
0.
f
,
0.5
f
,
1.
f
,
1.
f
));
ImPlot
::
PlotLine
(
"Height along y"
,
_plotAlongY_data_y
.
data
(),
_plotAlongY_data_h
.
data
(),
_Nx
);
ImPlot
::
EndPlot
()
}
if
(
x
!=
_last_plotAlongY_x
){
_last_plotAlongY_x
=
x
;
if
(
x
>
_maxX
||
x
<
_minX
){
return
;
}
//find correct i (column)
//TODO: This has to change when _data changes
size_t
stride
=
3
;
size_t
i
=
0
;
for
(;
i
<
_Nx
;
++
i
){
if
(
_data
[
stride
*
_Ny
*
i
]
>=
x
){
break
;
}
}
if
(
i
>=
_Nx
){
std
::
cout
<<
"_plotHeightLineAlongY: Data not found."
<<
std
::
endl
;
return
;
}
std
::
cout
<<
"_plotHeightLineAlongY: Found element "
<<
i
<<
", x = "
<<
_data
[
stride
*
_Ny
*
i
]
<<
std
::
endl
;
//traverse the column, push ys and zs to the plotting vectors
for
(
size_t
j
=
0
;
j
<
_Ny
;
++
j
){
_plotAlongY_data_y
[
j
]
=
_data
[
stride
*
_Ny
*
i
+
stride
*
j
+
1
];
if
(
_data
[
stride
*
_Ny
*
i
+
stride
*
j
+
2
]
!=
BAD_Z_VALUE
)
{
_plotAlongY_data_h
[
j
]
=
_minZ
+
_zRangeUm
*
_data
[
stride
*
_Ny
*
i
+
stride
*
j
+
2
];
}
else
{
_plotAlongY_data_h
[
j
]
=
NAN
;
}
}
}
//plot data
if
(
ImPlot
::
BeginPlot
(
"Heightplot along y"
)){
ImPlot
::
SetupAxes
(
"Position [mm]"
,
"Height [um]"
);
ImPlot
::
SetNextLineStyle
(
ImVec4
(
1.
f
,
0.
f
,
0.
f
,
1.
f
));
ImPlot
::
PlotLine
(
"Height along y"
,
_plotAlongY_data_y
.
data
(),
_plotAlongY_data_h
.
data
(),
_Ny
);
ImPlot
::
EndPlot
();
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment