Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
ISBI2016-filaSimu-TM
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Vladimír Ulman
ISBI2016-filaSimu-TM
Commits
692d418e
There was an error fetching the commit references. Please try again later.
Commit
692d418e
authored
8 years ago
by
Vladimír Ulman
Browse files
Options
Downloads
Patches
Plain Diff
Added initial importing of f-tree VTK files.
parent
ea664931
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
cmath3d/TriangleMesh.cpp
+167
-0
167 additions, 0 deletions
cmath3d/TriangleMesh.cpp
cmath3d/TriangleMesh.h
+7
-0
7 additions, 0 deletions
cmath3d/TriangleMesh.h
src/main.cpp
+8
-0
8 additions, 0 deletions
src/main.cpp
with
182 additions
and
0 deletions
cmath3d/TriangleMesh.cpp
+
167
−
0
View file @
692d418e
...
...
@@ -397,6 +397,173 @@ int ActiveMesh::ImportVTK_Volumetric(const char *filename)
}
int
ActiveMesh
::
ImportVTK_Ftree
(
const
char
*
filename
,
bool
resetMesh
)
{
if
(
resetMesh
)
{
Pos
.
clear
();
ID
.
clear
();
norm
.
clear
();
}
//local/temporary list of vertices of segments that make up the f-tree
//later, we convert these to triangles and save these guys instead
fPoints
.
clear
();
segFromPoint
.
clear
();
segToPoint
.
clear
();
segFromRadius
.
clear
();
segToRadius
.
clear
();
//try to open the file
std
::
ifstream
file
(
filename
);
if
(
!
file
.
is_open
())
return
1
;
//read the "header" line
char
tmp
[
1024
];
file
>>
tmp
>>
tmp
;
//dangerous...
//check tmp for "vtk" or complain
if
(
tmp
[
0
]
!=
'v'
||
tmp
[
1
]
!=
't'
||
tmp
[
2
]
!=
'k'
)
{
file
.
close
();
return
(
2
);
}
//read (and skip) the rest of the header line
file
.
ignore
(
10240
,
'\n'
);
//ignore "vtk output"
file
.
ignore
(
10240
,
'\n'
);
//read "ASCII"
file
>>
tmp
;
if
(
tmp
[
0
]
!=
'A'
||
tmp
[
1
]
!=
'S'
||
tmp
[
2
]
!=
'C'
||
tmp
[
3
]
!=
'I'
||
tmp
[
4
]
!=
'I'
)
{
file
.
close
();
return
(
3
);
}
file
.
ignore
(
10240
,
'\n'
);
//ignore "DATASET UNSTRUCTURED GRID"
file
.
ignore
(
10240
,
'\n'
);
//read points header
int
itemCount
;
file
>>
tmp
>>
itemCount
;;
if
(
tmp
[
0
]
!=
'P'
||
tmp
[
1
]
!=
'O'
||
tmp
[
2
]
!=
'I'
||
tmp
[
3
]
!=
'N'
||
tmp
[
4
]
!=
'T'
||
tmp
[
5
]
!=
'S'
)
{
file
.
close
();
return
(
4
);
}
file
.
ignore
(
10240
,
'\n'
);
std
::
cout
<<
"reading "
<<
itemCount
<<
" point coordinates
\n
"
;
fPoints
.
reserve
(
itemCount
);
//read all points...
float
x
,
y
,
z
;
while
(
itemCount
>
0
&&
file
>>
x
)
{
file
>>
y
>>
z
;
//... and save them
Vector3FC
v1
(
x
,
y
,
z
);
v1
*=
100.
f
;
fPoints
.
push_back
(
v1
);
--
itemCount
;
}
std
::
cout
<<
"last coordinate was: "
<<
x
<<
","
<<
y
<<
","
<<
z
<<
"
\n
"
;
//read segments header
file
>>
tmp
>>
itemCount
;
if
(
tmp
[
0
]
!=
'C'
||
tmp
[
1
]
!=
'E'
||
tmp
[
2
]
!=
'L'
||
tmp
[
3
]
!=
'L'
||
tmp
[
4
]
!=
'S'
)
{
file
.
close
();
return
(
5
);
}
file
.
ignore
(
10240
,
'\n'
);
std
::
cout
<<
"reading "
<<
itemCount
<<
" segments
\n
"
;
segFromPoint
.
reserve
(
itemCount
);
segToPoint
.
reserve
(
itemCount
);
segFromRadius
.
reserve
(
itemCount
);
segToRadius
.
reserve
(
itemCount
);
//read all segments vertices
int
ignore
,
v1
,
v2
;
while
(
itemCount
>
0
&&
file
>>
ignore
&&
ignore
==
2
)
{
file
>>
v1
>>
v2
;
segFromPoint
.
push_back
(
v1
);
segToPoint
.
push_back
(
v2
);
--
itemCount
;
}
std
::
cout
<<
"last segment was: "
<<
v1
<<
","
<<
v2
<<
"
\n
"
;
//"ignore" cell types header, body
file
>>
tmp
>>
itemCount
;
if
(
tmp
[
0
]
!=
'C'
||
tmp
[
1
]
!=
'E'
||
tmp
[
2
]
!=
'L'
||
tmp
[
3
]
!=
'L'
||
tmp
[
4
]
!=
'_'
||
tmp
[
5
]
!=
'T'
||
tmp
[
6
]
!=
'Y'
)
{
file
.
close
();
return
(
6
);
}
file
.
ignore
(
10240
,
'\n'
);
while
(
itemCount
>
0
)
{
file
.
ignore
(
10240
,
'\n'
);
--
itemCount
;
}
//read radii, i.e. CELL_DATA header
file
>>
tmp
>>
itemCount
;
if
(
tmp
[
0
]
!=
'C'
||
tmp
[
1
]
!=
'E'
||
tmp
[
2
]
!=
'L'
||
tmp
[
3
]
!=
'L'
||
tmp
[
4
]
!=
'_'
||
tmp
[
5
]
!=
'D'
||
tmp
[
6
]
!=
'A'
)
{
file
.
close
();
return
(
7
);
}
file
.
ignore
(
10240
,
'\n'
);
file
.
ignore
(
10240
,
'\n'
);
//ignore SCALARS..
file
.
ignore
(
10240
,
'\n'
);
//ignore LOOKUP_TABLE
//read the radii
v1
=
0
;
while
(
itemCount
>
0
&&
file
>>
x
)
{
segFromRadius
.
push_back
(
x
);
if
(
v1
>
0
)
segToRadius
.
push_back
(
x
);
--
itemCount
;
++
v1
;
}
//the tip has width 0
segToRadius
.
push_back
(
0.
f
);
file
.
close
();
//now widen segments and save triangles...
//prepare "information about faces normals"
Vector3F
fictiveNormal
(
1.
f
,
0.
f
,
0.
f
);
//temporary view of segments themselves
for
(
unsigned
int
i
=
0
;
i
<
segFromPoint
.
size
();
++
i
)
{
Pos
.
push_back
(
fPoints
[
segFromPoint
[
i
]]);
Pos
.
push_back
(
fPoints
[
segFromPoint
[
i
]]
+
Vector3FC
(
0.01
f
,
0.01
f
,
0.01
f
));
Pos
.
push_back
(
fPoints
[
segToPoint
[
i
]]);
ID
.
push_back
(
Pos
.
size
()
-
3
);
ID
.
push_back
(
Pos
.
size
()
-
2
);
ID
.
push_back
(
Pos
.
size
()
-
1
);
norm
.
push_back
(
fictiveNormal
);
}
return
(
0
);
}
void
ActiveMesh
::
RenderMask
(
i3d
::
Image3d
<
i3d
::
GRAY16
>&
mask
)
{
//time savers: resolution
...
...
This diff is collapsed.
Click to expand it.
cmath3d/TriangleMesh.h
+
7
−
0
View file @
692d418e
...
...
@@ -99,6 +99,13 @@ class ActiveMesh
int
ImportVTK
(
const
char
*
filename
);
int
ImportVTK_Volumetric
(
const
char
*
filename
);
int
ImportVTK_Ftree
(
const
char
*
filename
,
bool
resetMesh
=
false
);
std
::
vector
<
Vector3FC
>
fPoints
;
std
::
vector
<
int
>
segFromPoint
;
//segment description, quite ugly solution for now
std
::
vector
<
int
>
segToPoint
;
std
::
vector
<
float
>
segFromRadius
;
std
::
vector
<
float
>
segToRadius
;
void
RenderMask
(
i3d
::
Image3d
<
i3d
::
GRAY16
>&
mask
);
void
RenderMaskB
(
i3d
::
Image3d
<
i3d
::
GRAY16
>&
mask
);
...
...
This diff is collapsed.
Click to expand it.
src/main.cpp
+
8
−
0
View file @
692d418e
...
...
@@ -32,6 +32,14 @@ int main(void)
return
(
1
);
}
retval
=
mesh
.
ImportVTK_Ftree
(
"../sample_input/ID1_t001_fTree01.vtk"
);
retval
=
mesh
.
ImportVTK_Ftree
(
"../sample_input/ID1_t001_fTree02.vtk"
);
if
(
retval
)
{
std
::
cout
<<
"some error reading f-tree: "
<<
retval
<<
"
\n
"
;
return
(
2
);
}
std
::
cout
<<
"mesh: "
<<
filename
<<
"
\n
"
;
std
::
cout
<<
"vertices #: "
<<
mesh
.
Pos
.
size
()
<<
"
\n
"
;
std
::
cout
<<
"triangles #: "
<<
mesh
.
ID
.
size
()
/
3
<<
"
\n
"
;
...
...
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