Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
iMSTK
iMSTK
Commits
84caab04
Commit
84caab04
authored
Apr 27, 2021
by
Sreekanth Arikatla
Committed by
Andrew Wilson
May 17, 2021
Browse files
TEST: Add sdf tests for closed-form geometry
parent
daed2750
Changes
3
Hide whitespace changes
Inline
Side-by-side
Source/Geometry/Testing/imstkCubeTest.cpp
View file @
84caab04
...
...
@@ -63,11 +63,25 @@ TEST_F(imstkCubeTest, GetVolume)
m_cube
.
setWidth
(
0.003
);
EXPECT_EQ
(
m_cube
.
getVolume
(),
0.003
*
0.003
*
0.003
);
double
w
=
400000000
;
const
double
w
=
400000000
;
m_cube
.
setWidth
(
400000000
);
EXPECT_EQ
(
m_cube
.
getVolume
(),
w
*
w
*
w
);
}
///
/// \brief test the cube SDF evaluator
///
TEST_F
(
imstkCubeTest
,
GetFunctionValue
)
{
m_cube
.
setWidth
(
2.
);
m_cube
.
updatePostTransformData
();
EXPECT_EQ
(
m_cube
.
getFunctionValue
(
Vec3d
(
0.
,
0.
,
0.
)),
-
1.
);
EXPECT_EQ
(
m_cube
.
getFunctionValue
(
Vec3d
(
0.5
,
0.
,
0.
)),
-
0.5
);
EXPECT_EQ
(
m_cube
.
getFunctionValue
(
Vec3d
(
1.
,
1.
,
1.
)),
0.
);
EXPECT_EQ
(
m_cube
.
getFunctionValue
(
Vec3d
(
0.
,
-
10.
,
0.
)),
9.
);
}
///
/// \brief TODO
///
...
...
Source/Geometry/Testing/imstkPlaneTest.cpp
View file @
84caab04
...
...
@@ -85,6 +85,29 @@ TEST_F(imstkPlaneTest, GetVolume)
EXPECT_EQ
(
m_plane
.
getVolume
(),
0
);
}
///
/// \brief test the plane SDF evaluator
///
TEST_F
(
imstkPlaneTest
,
GetFunctionValue
)
{
m_plane
.
setNormal
(
Vec3d
(
0.
,
1.
,
0.
));
m_plane
.
updatePostTransformData
();
EXPECT_EQ
(
m_plane
.
getFunctionValue
(
Vec3d
(
0.
,
0.
,
0.
)),
0.
);
EXPECT_EQ
(
m_plane
.
getFunctionValue
(
Vec3d
(
0.5
,
0.
,
0.
)),
0.
);
EXPECT_EQ
(
m_plane
.
getFunctionValue
(
Vec3d
(
1.
,
1.
,
1.
)),
1.
);
EXPECT_EQ
(
m_plane
.
getFunctionValue
(
Vec3d
(
0.
,
-
10.
,
0.
)),
-
10.
);
m_plane
.
setPosition
(
Vec3d
(
1.
,
1.
,
1.
));
m_plane
.
setNormal
(
Vec3d
(
1.
,
1.
,
1.
));
m_plane
.
updatePostTransformData
();
EXPECT_FLOAT_EQ
(
m_plane
.
getFunctionValue
(
Vec3d
(
0.
,
0.
,
0.
)),
-
std
::
sqrt
(
3.0
));
EXPECT_EQ
(
m_plane
.
getFunctionValue
(
Vec3d
(
1.
,
1.
,
1.
)),
0.0
);
EXPECT_FLOAT_EQ
(
m_plane
.
getFunctionValue
(
Vec3d
(
1.
,
0.
,
0.
)),
-
2.0
/
std
::
sqrt
(
3.0
));
EXPECT_FLOAT_EQ
(
m_plane
.
getFunctionValue
(
Vec3d
(
0.
,
-
10.
,
0.
)),
-
13.0
/
std
::
sqrt
(
3.0
));
}
///
/// \brief TODO
///
...
...
Source/Geometry/Testing/imstkSphereTest.cpp
View file @
84caab04
...
...
@@ -68,6 +68,21 @@ TEST_F(imstkSphereTest, GetVolume)
EXPECT_EQ
(
m_sphere
.
getVolume
(),
4.0
/
3.0
*
PI
*
r
*
r
*
r
);
}
///
/// \brief test the sphere SDF evaluator
///
TEST_F
(
imstkSphereTest
,
GetFunctionValue
)
{
m_sphere
.
setRadius
(
20.
);
m_sphere
.
updatePostTransformData
();
EXPECT_EQ
(
m_sphere
.
getFunctionValue
(
Vec3d
(
0.
,
0.
,
0.
)),
-
20.
);
EXPECT_EQ
(
m_sphere
.
getFunctionValue
(
Vec3d
(
5.
,
0.
,
0.
)),
-
15
);
EXPECT_EQ
(
m_sphere
.
getFunctionValue
(
Vec3d
(
1.
,
1.
,
1.
)),
-
20.0
+
std
::
sqrt
(
3
));
EXPECT_EQ
(
m_sphere
.
getFunctionValue
(
Vec3d
(
0.
,
20.
,
0.
)),
0.
);
EXPECT_EQ
(
m_sphere
.
getFunctionValue
(
Vec3d
(
0.
,
0.
,
50.
)),
30.
);
}
///
/// \brief TODO
///
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment