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
5034705f
There was an error fetching the commit references. Please try again later.
Commit
5034705f
authored
8 years ago
by
Vladimír Ulman
Browse files
Options
Downloads
Patches
Plain Diff
Added proper triangulation of fTrees.
parent
84be467d
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
cmath3d/TriangleMesh.cpp
+105
-14
105 additions, 14 deletions
cmath3d/TriangleMesh.cpp
with
105 additions
and
14 deletions
cmath3d/TriangleMesh.cpp
+
105
−
14
View file @
5034705f
...
...
@@ -400,6 +400,9 @@ int ActiveMesh::ImportVTK_Volumetric(const char *filename)
int
ActiveMesh
::
ImportVTK_Ftree
(
const
char
*
filename
,
bool
resetMesh
)
{
const
int
PointsOnRadiusPeriphery
=
10
;
const
float
radiusCorrection
=
0.2
f
;
if
(
resetMesh
)
{
Pos
.
clear
();
...
...
@@ -413,7 +416,6 @@ int ActiveMesh::ImportVTK_Ftree(const char *filename,bool resetMesh)
segFromPoint
.
clear
();
segToPoint
.
clear
();
segFromRadius
.
clear
();
segToRadius
.
clear
();
//try to open the file
std
::
ifstream
file
(
filename
);
...
...
@@ -486,7 +488,6 @@ int ActiveMesh::ImportVTK_Ftree(const char *filename,bool resetMesh)
segFromPoint
.
reserve
(
itemCount
);
segToPoint
.
reserve
(
itemCount
);
segFromRadius
.
reserve
(
itemCount
);
segToRadius
.
reserve
(
itemCount
);
//read all segments vertices
int
ignore
,
v1
,
v2
;
...
...
@@ -534,33 +535,117 @@ int ActiveMesh::ImportVTK_Ftree(const char *filename,bool resetMesh)
v1
=
0
;
while
(
itemCount
>
0
&&
file
>>
x
)
{
segFromRadius
.
push_back
(
x
);
if
(
v1
>
0
)
segToRadius
.
push_back
(
x
);
segFromRadius
.
push_back
(
x
*
radiusCorrection
);
--
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
size_t
firstRadiusPoint
=
Pos
.
size
();
PointsFirstOffset
=
firstRadiusPoint
;
//for all bending points except the last one (tip)
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
);
//we need to construct rotation matrix that would
//rotate points on a circle which lays in the XZ plane
//(Y axis is normal to it then) such that the points
//would lay in the plane to which this new Y axis
//would be normal
//
//new Y axis
Vector3F
nYaxis
=
fPoints
[
segToPoint
[
i
]];
if
(
i
==
0
)
nYaxis
-=
fPoints
[
segFromPoint
[
i
]];
else
{
nYaxis
-=
fPoints
[
segFromPoint
[
i
-
1
]];
nYaxis
/=
2.
f
;
//unnecessary scaling
}
Vector3F
nZaxis
(
0.
f
,
1.
f
,
0.
f
);
//in fact it is original Yaxis _for now_
Vector3F
nXaxis
;
//new X axis is perpendicular to the original and new Y axis
Mul
(
nYaxis
,
nZaxis
,
nXaxis
);
//new Z axis is perpendicular to the new X and Y axes
Mul
(
nYaxis
,
nXaxis
,
nZaxis
);
//normalize...
nXaxis
/=
nXaxis
.
Len
();
nZaxis
/=
nZaxis
.
Len
();
//now render the points on the circle and project them into the scene
for
(
int
p
=
0
;
p
<
PointsOnRadiusPeriphery
;
++
p
)
{
//the point in its original position
float
x
=
segFromRadius
[
i
]
*
cosf
(
6.28
f
*
float
(
p
)
/
float
(
PointsOnRadiusPeriphery
));
float
z
=
segFromRadius
[
i
]
*
sinf
(
6.28
f
*
float
(
p
)
/
float
(
PointsOnRadiusPeriphery
));
//rotate
Vector3FC
V
(
x
*
nXaxis
);
V
+=
z
*
nZaxis
;
//shift to the centre and save
V
+=
fPoints
[
segFromPoint
[
i
]];
Pos
.
push_back
(
V
);
}
}
//finally, add the tip point
Pos
.
push_back
(
fPoints
[
segToPoint
.
back
()]);
//now create triangles for all segment strips
//except the last one (that leads to the tip)
for
(
unsigned
int
i
=
1
;
i
<
segFromPoint
.
size
();
++
i
)
{
int
p
=
0
;
for
(;
p
<
PointsOnRadiusPeriphery
-
1
;
++
p
)
{
ID
.
push_back
(
firstRadiusPoint
+
p
);
ID
.
push_back
(
firstRadiusPoint
+
p
+
1
);
ID
.
push_back
(
firstRadiusPoint
+
p
+
PointsOnRadiusPeriphery
);
norm
.
push_back
(
fictiveNormal
);
ID
.
push_back
(
firstRadiusPoint
+
p
+
PointsOnRadiusPeriphery
+
1
);
ID
.
push_back
(
firstRadiusPoint
+
p
+
PointsOnRadiusPeriphery
);
ID
.
push_back
(
firstRadiusPoint
+
p
+
1
);
norm
.
push_back
(
fictiveNormal
);
}
ID
.
push_back
(
firstRadiusPoint
+
p
);
ID
.
push_back
(
firstRadiusPoint
);
ID
.
push_back
(
firstRadiusPoint
+
p
+
PointsOnRadiusPeriphery
);
norm
.
push_back
(
fictiveNormal
);
ID
.
push_back
(
firstRadiusPoint
+
PointsOnRadiusPeriphery
);
ID
.
push_back
(
firstRadiusPoint
+
p
+
PointsOnRadiusPeriphery
);
ID
.
push_back
(
firstRadiusPoint
);
norm
.
push_back
(
fictiveNormal
);
firstRadiusPoint
+=
PointsOnRadiusPeriphery
;
}
//the last segment...
int
p
=
0
;
for
(;
p
<
PointsOnRadiusPeriphery
-
1
;
++
p
)
{
ID
.
push_back
(
firstRadiusPoint
+
p
);
ID
.
push_back
(
firstRadiusPoint
+
p
+
1
);
ID
.
push_back
(
firstRadiusPoint
+
PointsOnRadiusPeriphery
);
norm
.
push_back
(
fictiveNormal
);
}
ID
.
push_back
(
firstRadiusPoint
+
p
);
ID
.
push_back
(
firstRadiusPoint
);
ID
.
push_back
(
firstRadiusPoint
+
PointsOnRadiusPeriphery
);
norm
.
push_back
(
fictiveNormal
);
return
(
0
);
}
...
...
@@ -754,6 +839,12 @@ void ActiveMesh::CenterMesh(const Vector3F& newCentre)
Pos
[
i
].
y
-=
float
(
y
);
Pos
[
i
].
z
-=
float
(
z
);
}
for
(
unsigned
int
i
=
0
;
i
<
fPoints
.
size
();
++
i
)
{
fPoints
[
i
].
x
-=
float
(
x
);
fPoints
[
i
].
y
-=
float
(
y
);
fPoints
[
i
].
z
-=
float
(
z
);
}
}
...
...
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