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
ca1333ed
There was an error fetching the commit references. Please try again later.
Commit
ca1333ed
authored
8 years ago
by
Vladimír Ulman
Browse files
Options
Downloads
Patches
Plain Diff
Added testing of surface fitting on a sphere. Seems to work well.
parent
40c7a794
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
cmath3d/TriangleMesh.cpp
+1
-0
1 addition, 0 deletions
cmath3d/TriangleMesh.cpp
cmath3d/TriangleMesh.h
+17
-0
17 additions, 0 deletions
cmath3d/TriangleMesh.h
src/graphics.cpp
+26
-7
26 additions, 7 deletions
src/graphics.cpp
src/main.cpp
+2
-1
2 additions, 1 deletion
src/main.cpp
with
46 additions
and
8 deletions
cmath3d/TriangleMesh.cpp
+
1
−
0
View file @
ca1333ed
...
@@ -526,6 +526,7 @@ bool ActiveMesh::GetPointOnQuadricSurface(const float x,const float y,
...
@@ -526,6 +526,7 @@ bool ActiveMesh::GetPointOnQuadricSurface(const float x,const float y,
const
float
sqArg
=
b
*
b
-
4
*
a
*
c
;
const
float
sqArg
=
b
*
b
-
4
*
a
*
c
;
if
(
sqArg
<
0.
f
)
return
false
;
if
(
sqArg
<
0.
f
)
return
false
;
if
(
a
==
0.
f
)
return
false
;
z1
=
(
-
b
+
sqrtf
(
sqArg
))
/
(
2.
f
*
a
);
z1
=
(
-
b
+
sqrtf
(
sqArg
))
/
(
2.
f
*
a
);
z2
=
(
-
b
-
sqrtf
(
sqArg
))
/
(
2.
f
*
a
);
z2
=
(
-
b
-
sqrtf
(
sqArg
))
/
(
2.
f
*
a
);
...
...
This diff is collapsed.
Click to expand it.
cmath3d/TriangleMesh.h
+
17
−
0
View file @
ca1333ed
...
@@ -46,6 +46,23 @@ class ActiveMesh
...
@@ -46,6 +46,23 @@ class ActiveMesh
*/
*/
int
CalcQuadricSurface_Taubin
(
const
int
vertexID
,
int
CalcQuadricSurface_Taubin
(
const
int
vertexID
,
float
(
&
coeffs
)[
10
]);
float
(
&
coeffs
)[
10
]);
int
CalcQuadricSurface_sphere
(
const
float
radius
,
const
Vector3F
&
centre
,
float
(
&
coeffs
)[
10
])
{
const
float
R
=
radius
*
radius
;
coeffs
[
0
]
=-
1.
f
+
(
centre
.
x
*
centre
.
x
+
centre
.
y
*
centre
.
y
+
centre
.
z
*
centre
.
z
)
/
R
;
coeffs
[
1
]
=-
2.
f
*
centre
.
x
/
R
;
coeffs
[
2
]
=-
2.
f
*
centre
.
y
/
R
;
coeffs
[
3
]
=-
2.
f
*
centre
.
z
/
R
;
coeffs
[
4
]
=
0.
f
;
coeffs
[
5
]
=
0.
f
;
coeffs
[
6
]
=
0.
f
;
coeffs
[
7
]
=
1.
f
/
R
;
coeffs
[
8
]
=
1.
f
/
R
;
coeffs
[
9
]
=
1.
f
/
R
;
return
(
0
);
}
/**
/**
* Calculate the 3rd coordinate (e.g., z) to complete a 3D point
* Calculate the 3rd coordinate (e.g., z) to complete a 3D point
...
...
This diff is collapsed.
Click to expand it.
src/graphics.cpp
+
26
−
7
View file @
ca1333ed
...
@@ -149,7 +149,18 @@ void ActiveMesh::displayQuadricSurface(void)
...
@@ -149,7 +149,18 @@ void ActiveMesh::displayQuadricSurface(void)
{
{
//get surface params
//get surface params
float
surf_coeff
[
10
];
float
surf_coeff
[
10
];
CalcQuadricSurface_Taubin
(
VertexID
,
surf_coeff
);
//CalcQuadricSurface_Taubin(VertexID,surf_coeff);
CalcQuadricSurface_sphere
(
5.0
f
,
params
.
sceneCentre
,
surf_coeff
);
std
::
cout
<<
"
\n
surface: "
<<
surf_coeff
[
0
]
<<
" + "
<<
surf_coeff
[
1
]
<<
"*x + "
<<
surf_coeff
[
2
]
<<
"*y + "
<<
surf_coeff
[
3
]
<<
"*z + "
<<
surf_coeff
[
4
]
<<
"*xy + "
<<
surf_coeff
[
5
]
<<
"*xz + "
<<
surf_coeff
[
6
]
<<
"*yz + "
<<
surf_coeff
[
7
]
<<
"*x*x + "
<<
surf_coeff
[
8
]
<<
"*y*y + "
<<
surf_coeff
[
9
]
<<
"*z*z = 0
\n
"
;
glPointSize
(
2.0
f
);
glPointSize
(
2.0
f
);
glBegin
(
GL_POINTS
);
glBegin
(
GL_POINTS
);
...
@@ -165,12 +176,16 @@ void ActiveMesh::displayQuadricSurface(void)
...
@@ -165,12 +176,16 @@ void ActiveMesh::displayQuadricSurface(void)
//FOR CYCLE BEGIN
//FOR CYCLE BEGIN
//over all triangles
//over all triangles
for
(
unsigned
int
t
=
0
;
t
<
neigsT
.
size
();
++
t
)
//for (unsigned int t=0; t < neigsT.size(); ++t)
for
(
unsigned
int
t
=
0
;
t
<
2
;
++
t
)
{
{
//determine triangle vertices
//determine triangle vertices
const
Vector3FC
&
v1
=
Pos
[
ID
[
3
*
neigsT
[
t
]
+
0
]];
const
Vector3FC
&
v1
=
Pos
[
ID
[
3
*
neigsT
[
t
]
+
0
]];
const
Vector3FC
&
v2
=
Pos
[
ID
[
3
*
neigsT
[
t
]
+
1
]];
const
Vector3FC
&
v2
=
Pos
[
ID
[
3
*
neigsT
[
t
]
+
1
]];
const
Vector3FC
&
v3
=
Pos
[
ID
[
3
*
neigsT
[
t
]
+
2
]];
const
Vector3FC
&
v3
=
Pos
[
ID
[
3
*
neigsT
[
t
]
+
2
]];
std
::
cout
<<
"v1: ("
<<
v1
.
x
<<
","
<<
v1
.
y
<<
","
<<
v1
.
z
<<
")
\n
"
;
std
::
cout
<<
"v2: ("
<<
v2
.
x
<<
","
<<
v2
.
y
<<
","
<<
v2
.
z
<<
")
\n
"
;
std
::
cout
<<
"v3: ("
<<
v3
.
x
<<
","
<<
v3
.
y
<<
","
<<
v3
.
z
<<
")
\n
"
;
//sweep (coarsely!) across current triangle
//sweep (coarsely!) across current triangle
for
(
float
c
=
0.1
f
;
c
<=
0.9
f
;
c
+=
0.1
f
)
for
(
float
c
=
0.1
f
;
c
<=
0.9
f
;
c
+=
0.1
f
)
...
@@ -190,10 +205,14 @@ void ActiveMesh::displayQuadricSurface(void)
...
@@ -190,10 +205,14 @@ void ActiveMesh::displayQuadricSurface(void)
GetClosestPointOnQuadricSurface
(
point
,
surf_coeff
);
GetClosestPointOnQuadricSurface
(
point
,
surf_coeff
);
//display the point
//display the point
glColor3f
(
0.0
f
,
1.0
f
,
0.0
f
);
glVertex3f
(
point
.
x
,
point
.
y
,
point
.
z
);
glVertex3f
(
point
.
x
,
point
.
y
,
point
.
z
);
std
::
cout
<<
"("
<<
origPoint
.
x
<<
","
<<
origPoint
.
y
<<
","
<<
origPoint
.
z
std
::
cout
<<
"
("
<<
origPoint
.
x
<<
","
<<
origPoint
.
y
<<
","
<<
origPoint
.
z
<<
") -> ("
<<
") -> ("
<<
point
.
x
<<
","
<<
point
.
y
<<
","
<<
point
.
z
<<
")
\n
"
;
<<
point
.
x
<<
","
<<
point
.
y
<<
","
<<
point
.
z
<<
")
\n
"
;
glColor3f
(
0.0
f
,
1.0
f
,
1.0
f
);
glVertex3f
(
origPoint
.
x
,
origPoint
.
y
,
origPoint
.
z
);
}
}
}
}
//FOR CYCLE END
//FOR CYCLE END
...
@@ -203,7 +222,7 @@ void ActiveMesh::displayQuadricSurface(void)
...
@@ -203,7 +222,7 @@ void ActiveMesh::displayQuadricSurface(void)
void
ActiveMesh
::
displayMesh
(
void
)
void
ActiveMesh
::
displayMesh
(
void
)
{
{
glColor3f
(
0.
8
f
,
0.
8
f
,
0.
8
f
);
glColor3f
(
0.
6
f
,
0.
6
f
,
0.
6
f
);
long
unsigned
int
*
id
=
ID
.
data
();
long
unsigned
int
*
id
=
ID
.
data
();
for
(
unsigned
int
i
=
0
;
i
<
ID
.
size
();
i
+=
3
)
for
(
unsigned
int
i
=
0
;
i
<
ID
.
size
();
i
+=
3
)
...
@@ -503,15 +522,15 @@ void reshape(int w, int h)
...
@@ -503,15 +522,15 @@ void reshape(int w, int h)
void
initializeGL
(
void
)
void
initializeGL
(
void
)
{
{
int
Argc
=
1
;
int
Argc
=
1
;
char
msg
[]
=
"
TRAgen: A Tool for Generation of Synthetic Time-Lapse Image Sequences of Living Cells
"
;
char
msg
[]
=
"
meshSurface GUI
"
;
char
*
Argv
[
10
];
char
*
Argv
[
10
];
Argv
[
0
]
=
msg
;
Argv
[
0
]
=
msg
;
glutInit
(
&
Argc
,
Argv
);
glutInit
(
&
Argc
,
Argv
);
glutInitDisplayMode
(
GLUT_DOUBLE
|
GLUT_RGBA
);
glutInitDisplayMode
(
GLUT_DOUBLE
|
GLUT_RGBA
);
glutInitWindowSize
(
6
00
,
6
00
);
glutInitWindowSize
(
8
00
,
8
00
);
glutInitWindowPosition
(
1
00
,
100
);
glutInitWindowPosition
(
6
00
,
100
);
glutCreateWindow
(
Argv
[
0
]);
glutCreateWindow
(
Argv
[
0
]);
glutKeyboardFunc
(
keyboard
);
glutKeyboardFunc
(
keyboard
);
...
...
This diff is collapsed.
Click to expand it.
src/main.cpp
+
2
−
1
View file @
ca1333ed
...
@@ -17,7 +17,8 @@ int main(void)
...
@@ -17,7 +17,8 @@ int main(void)
//load mesh
//load mesh
//char filename[]="../sample_input/samplecell.stl";
//char filename[]="../sample_input/samplecell.stl";
char
filename
[]
=
"../sample_input/torus_100_30.stl"
;
//char filename[]="../sample_input/torus_100_30.stl";
char
filename
[]
=
"../sample_input/sphere.stl"
;
int
retval
=
mesh
.
ImportSTL
(
filename
);
int
retval
=
mesh
.
ImportSTL
(
filename
);
if
(
retval
)
if
(
retval
)
...
...
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