Skip to content
GitLab
Menu
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
89c4588e
Commit
89c4588e
authored
Apr 12, 2016
by
Sreekanth Arikatla
Browse files
ENH: Adds tet-tri map
Adds tet-tri map and all the support functionality that it needs
parent
6b79f2a3
Changes
11
Hide whitespace changes
Inline
Side-by-side
Base/Geometry/imstkGeometryMap.cpp
View file @
89c4588e
...
...
@@ -47,6 +47,25 @@ GeometryMap::setMaster(std::shared_ptr<Geometry> master)
m_master
=
master
;
}
const
std
::
string
&
GeometryMap
::
getTypeName
()
const
{
switch
(
getType
())
{
case
GeometryMapType
::
Isometric
:
return
"Isometric map"
;
case
GeometryMapType
::
Identity
:
return
"Identity map"
;
case
GeometryMapType
::
TetraTriangle
:
return
"Tetra-Triangle map"
;
case
GeometryMapType
::
HexaTriangle
:
return
"Hexa-Triangle map"
;
case
GeometryMapType
::
TetraTetra
:
return
"Tetra-Tetra map"
;
default:
return
"Map type not determined!"
;
}
}
std
::
shared_ptr
<
Geometry
>
GeometryMap
::
getMaster
()
const
{
...
...
Base/Geometry/imstkGeometryMap.h
View file @
89c4588e
...
...
@@ -23,6 +23,7 @@
#define imstkGeometryMap_h
#include <memory>
#include <iostream>
#include "imstkGeometry.h"
#include "g3log/g3log.hpp"
...
...
@@ -68,6 +69,7 @@ public:
const
GeometryMapType
&
getType
()
const
;
virtual
void
setMaster
(
std
::
shared_ptr
<
Geometry
>
master
);
const
std
::
string
&
getTypeName
()
const
;
virtual
std
::
shared_ptr
<
Geometry
>
getMaster
()
const
;
virtual
void
setSlave
(
std
::
shared_ptr
<
Geometry
>
slave
);
...
...
@@ -78,6 +80,11 @@ public:
///
bool
isActive
()
const
;
///
/// \brief Print the map
///
virtual
void
printMap
()
const
=
0
;
protected:
GeometryMap
(
GeometryMapType
type
)
:
m_isActive
(
true
)
{}
...
...
Base/Geometry/imstkIdentityMap.cpp
View file @
89c4588e
...
...
@@ -29,6 +29,11 @@ IdentityMap::getTransform() const
return
imstk
::
RigidTransform3d
::
Identity
();
}
void
IdentityMap
::
printMap
()
const
{
std
::
cout
<<
this
->
getTypeName
()
<<
std
::
endl
;
}
void
IdentityMap
::
applyMap
()
{
...
...
Base/Geometry/imstkIdentityMap.h
View file @
89c4588e
...
...
@@ -38,6 +38,8 @@ public:
void
computeMap
(){};
void
printMap
()
const
;
// Accessors
void
setTransform
(
const
RigidTransform3d
&
affineTransform
);
...
...
Base/Geometry/imstkIsometricMap.cpp
View file @
89c4588e
...
...
@@ -34,6 +34,11 @@ IsometricMap::getTransform() const
return
m_rigidTransform
;
}
void
IsometricMap
::
printMap
()
const
{
std
::
cout
<<
this
->
getTypeName
()
<<
std
::
endl
;
}
void
IsometricMap
::
applyMap
()
{
...
...
Base/Geometry/imstkIsometricMap.h
View file @
89c4588e
...
...
@@ -42,6 +42,8 @@ public:
void
setTransform
(
const
RigidTransform3d
&
affineTransform
);
const
RigidTransform3d
&
getTransform
()
const
;
void
printMap
()
const
;
protected:
RigidTransform3d
m_rigidTransform
;
};
...
...
Base/Geometry/imstkTetraTriangleMap.cpp
View file @
89c4588e
...
...
@@ -37,7 +37,6 @@ TetraTriangleMap::computeMap()
auto
tetMesh
=
std
::
dynamic_pointer_cast
<
imstk
::
TetrahedralMesh
>
(
m_master
);
auto
triMesh
=
std
::
dynamic_pointer_cast
<
imstk
::
SurfaceMesh
>
(
m_slave
);
weightsArray
weights
;
int
numSurfaceVertices
=
triMesh
->
getNumVertices
();
int
numTetrahedra
=
tetMesh
->
getNumTetrahedra
();
...
...
@@ -56,6 +55,7 @@ TetraTriangleMap::computeMap()
}
// compute the weights
weightsArray
weights
=
{
0.0
,
0.0
,
0.0
,
0.0
};
tetMesh
->
computeBarycentricWeights
(
closestEle
,
surfVertPos
,
weights
);
m_enclosingTetra
.
push_back
(
closestEle
);
// store nearest tetrahedra
...
...
@@ -111,7 +111,7 @@ TetraTriangleMap::findEclosingTetrahedra(const std::shared_ptr<imstk::Tetrahedra
// Check which probable tetrahedra the point belongs to
int
elclosingTetra
=
-
1
;
weightsArray
weights
;
weightsArray
weights
=
{
0.0
,
0.0
,
0.0
,
0.0
}
;
for
(
auto
it
=
probables
.
begin
();
it
!=
probables
.
end
();
++
it
)
{
tetraMesh
->
computeBarycentricWeights
(
*
it
,
p
,
weights
);
...
...
@@ -152,6 +152,21 @@ TetraTriangleMap::setSlave(std::shared_ptr<Geometry> slave)
}
void
TetraTriangleMap
::
printMap
()
const
{
std
::
cout
<<
this
->
getTypeName
()
<<
std
::
endl
;
std
::
cout
<<
"Vertex (<vertNum>): Tetrahedra: <TetNum> - Weights: (w1, w2, w3, w4)
\n\n
"
;
for
(
size_t
i
=
0
;
i
<
this
->
m_enclosingTetra
.
size
();
i
++
)
{
std
::
cout
<<
"
\t
Vertex ("
<<
i
<<
"):"
<<
"
\t
Tetrahedra: "
<<
m_enclosingTetra
[
i
];
std
::
cout
<<
" - Weights: "
<<
"("
<<
m_weights
.
at
(
i
)[
0
]
<<
", "
<<
m_weights
.
at
(
i
)[
1
]
<<
", "
<<
m_weights
.
at
(
i
)[
2
]
<<
", "
<<
m_weights
.
at
(
i
)[
3
]
<<
")
\n
"
;
}
}
void
TetraTriangleMap
::
applyMap
()
{
...
...
Base/Geometry/imstkTetraTriangleMap.h
View file @
89c4588e
...
...
@@ -80,6 +80,11 @@ public:
///
void
setSlave
(
std
::
shared_ptr
<
Geometry
>
slave
)
override
;
///
/// \brief Print the map
///
void
printMap
()
const
;
protected:
std
::
vector
<
weightsArray
>
m_weights
;
///> weights
std
::
vector
<
int
>
m_enclosingTetra
;
///> Enclosing tetrahedra to interpolate the weights upon
...
...
Base/Geometry/imstkTetrahedralMesh.cpp
View file @
89c4588e
...
...
@@ -40,7 +40,7 @@ TetrahedralMesh::setTetrahedronVertices(const std::vector<TetraArray>& tetrahedr
}
void
TetrahedralMesh
::
computeBarycentricWeights
(
const
int
closestEle
,
const
imstk
::
Vec3d
&
p
,
std
::
array
<
double
,
4
>
weights
)
const
TetrahedralMesh
::
computeBarycentricWeights
(
const
int
closestEle
,
const
imstk
::
Vec3d
&
p
,
std
::
array
<
double
,
4
>
&
weights
)
const
{
TetraArray
vertIndices
=
getTetrahedronVertices
(
closestEle
);
imstk
::
Vec3d
v
[
4
];
...
...
Base/Geometry/imstkTetrahedralMesh.h
View file @
89c4588e
...
...
@@ -49,7 +49,7 @@ public:
///
/// \brief compute the barycentric weights of a given point in 3D space for a given the tetrahedra
///
void
computeBarycentricWeights
(
const
int
closestEle
,
const
imstk
::
Vec3d
&
p
,
std
::
array
<
double
,
4
>
weights
)
const
;
void
computeBarycentricWeights
(
const
int
closestEle
,
const
imstk
::
Vec3d
&
p
,
std
::
array
<
double
,
4
>
&
weights
)
const
;
///
/// \brief get the indices vertices of a given tetrahedra in an array
...
...
Examples/Sandbox/main.cpp
View file @
89c4588e
...
...
@@ -12,6 +12,13 @@
#include "imstkCube.h"
#include "imstkLight.h"
#include "imstkCamera.h"
// Geometry
#include "imstkTetrahedralMesh.h"
#include "imstkSurfaceMesh.h"
// Map
#include "imstkTetraTriangleMap.h"
#include "imstkIsometricMap.h"
#include "g3log/g3log.hpp"
...
...
@@ -20,6 +27,7 @@ void testViewer();
void
testAnalyticalGeometry
();
void
testScenesManagement
();
void
testGeometryMaps
();
void
testTetraTriangleMap
();
int
main
()
{
...
...
@@ -27,10 +35,11 @@ int main()
<<
"Starting Sandbox
\n
"
<<
"****************
\n
"
;
testViewer
();
//
testViewer();
//testAnalyticalGeometry();
//testScenesManagement();
//testIsometricMaps();
testTetraTriangleMap
();
return
0
;
}
...
...
@@ -178,14 +187,6 @@ void testScenesManagement()
while
(
sdk
->
getStatus
()
!=
imstk
::
SimulationStatus
::
INACTIVE
)
{}
}
void
testTetraTriangleMap
()
{
// SDK and Scene
auto
sdk
=
std
::
make_shared
<
imstk
::
SimulationManager
>
();
auto
geometryMapTest
=
sdk
->
createNewScene
(
"geometryMapTest"
);
geometryMapTest
->
setLoopDelay
(
1000
);
}
void
testIsometricMaps
()
{
// SDK and Scene
...
...
@@ -213,6 +214,7 @@ void testIsometricMaps()
auto
transform
=
imstk
::
RigidTransform3d
::
Identity
();
transform
.
translate
(
imstk
::
Vec3d
(
0.0
,
1.0
,
0.0
));
transform
.
rotate
(
Eigen
::
AngleAxisd
(
imstk
::
PI_4
,
imstk
::
Vec3d
(
0
,
1.0
,
0
)));
auto
rigidMap
=
std
::
make_shared
<
imstk
::
IsometricMap
>
();
rigidMap
->
setMaster
(
sphereObj
->
getVisualGeometry
());
rigidMap
->
setSlave
(
cubeObj
->
getVisualGeometry
());
...
...
@@ -232,3 +234,40 @@ void testIsometricMaps()
sdk
->
setCurrentScene
(
"geometryMapTest"
);
sdk
->
startSimulation
(
imstk
::
Renderer
::
Mode
::
DEBUG
);
}
void
testTetraTriangleMap
()
{
// Tetrahedral mesh
auto
tetMesh
=
std
::
make_shared
<
imstk
::
TetrahedralMesh
>
();
std
::
vector
<
imstk
::
Vec3d
>
vertList
;
vertList
.
push_back
(
imstk
::
Vec3d
(
0
,
0
,
0
));
vertList
.
push_back
(
imstk
::
Vec3d
(
1.0
,
0
,
0
));
vertList
.
push_back
(
imstk
::
Vec3d
(
0
,
1.0
,
0
));
vertList
.
push_back
(
imstk
::
Vec3d
(
0
,
0
,
1.0
));
tetMesh
->
setInitialVertexPositions
(
vertList
);
tetMesh
->
setVertexPositions
(
vertList
);
std
::
vector
<
std
::
array
<
size_t
,
4
>>
tetConnectivity
;
std
::
array
<
size_t
,
4
>
tet1
=
{
0
,
1
,
2
,
3
};
tetConnectivity
.
push_back
(
tet1
);
tetMesh
->
setTetrahedronVertices
(
tetConnectivity
);
// Triangular mesh
auto
triMesh
=
std
::
make_shared
<
imstk
::
SurfaceMesh
>
();
std
::
vector
<
imstk
::
Vec3d
>
SurfVertList
;
SurfVertList
.
push_back
(
imstk
::
Vec3d
(
0
,
0
,
1
));
// coincides with one vertex
SurfVertList
.
push_back
(
imstk
::
Vec3d
(
0.25
,
0.25
,
0.25
));
// centroid
SurfVertList
.
push_back
(
imstk
::
Vec3d
(
1.05
,
0
,
0
));
triMesh
->
setInitialVertexPositions
(
SurfVertList
);
triMesh
->
setVertexPositions
(
SurfVertList
);
// Construct a map
auto
tetTriMap
=
std
::
make_shared
<
imstk
::
TetraTriangleMap
>
();
tetTriMap
->
setMaster
(
tetMesh
);
tetTriMap
->
setSlave
(
triMesh
);
tetTriMap
->
computeMap
();
tetTriMap
->
printMap
();
getchar
();
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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