Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
iMSTK
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
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
Ben Boeckel
iMSTK
Commits
29470639
Commit
29470639
authored
3 years ago
by
Harald Scheirich
Committed by
Andrew Wilson
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Remove unused var
parent
979b4345
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Source/GeometryMappers/imstkOneToOneMap.cpp
+58
-72
58 additions, 72 deletions
Source/GeometryMappers/imstkOneToOneMap.cpp
with
58 additions
and
72 deletions
Source/GeometryMappers/imstkOneToOneMap.cpp
+
58
−
72
View file @
29470639
...
...
@@ -20,25 +20,63 @@
namespace
imstk
{
OneToOneMap
::
OneToOneMap
()
{
setRequiredInputType
<
PointSet
>
(
0
);
setRequiredInputType
<
PointSet
>
(
1
);
}
OneToOneMap
::
OneToOneMap
(
std
::
shared_ptr
<
Geometry
>
parent
,
std
::
shared_ptr
<
Geometry
>
child
)
{
setParentGeometry
(
parent
);
setChildGeometry
(
child
);
setRequiredInputType
<
PointSet
>
(
0
);
setRequiredInputType
<
PointSet
>
(
1
);
}
void
OneToOneMap
::
compute
()
{
CHECK
(
m_parentGeom
!=
nullptr
&&
m_childGeom
!=
nullptr
)
<<
"OneToOneMap map is being applied without valid geometries"
;
if
(
!
areInputsValid
())
{
LOG
(
WARNING
)
<<
"OneToOneMap failed to run, inputs not satisfied"
;
return
;
}
m_oneToOneMap
.
clear
();
computeMap
(
m_oneToOneMap
);
// Copy data from map to vector for parallel processing
m_oneToOneMapVector
.
clear
();
for
(
auto
kv
:
m_oneToOneMap
)
{
m_oneToOneMapVector
.
push_back
({
kv
.
first
,
kv
.
second
});
}
}
auto
meshParent
=
std
::
dynamic_pointer_cast
<
PointSet
>
(
m_parentGeom
);
auto
meshChild
=
std
::
dynamic_pointer_cast
<
PointSet
>
(
m_childGeom
);
void
OneToOneMap
::
computeMap
(
std
::
unordered_map
<
int
,
int
>&
tetVertToSurfVertMap
)
{
tetVertToSurfVertMap
.
clear
();
CHECK
(
meshParent
!=
nullptr
&&
meshChild
!=
nullptr
)
<<
"Fail to cast from geometry to pointset"
;
if
(
!
areInputsValid
())
{
LOG
(
WARNING
)
<<
"OneToOneMap failed to run, inputs not satisfied"
;
return
;
}
m_oneToOneMap
.
clear
(
);
ParallelUtils
::
SpinLock
lock
;
auto
meshParent
=
std
::
dynamic_pointer_cast
<
PointSet
>
(
getParentGeometry
()
);
auto
meshChild
=
std
::
dynamic_pointer_cast
<
PointSet
>
(
getChildGeometry
())
;
std
::
shared_ptr
<
VecDataArray
<
double
,
3
>>
parentVerticesPtr
=
meshParent
->
getInitialVertexPositions
();
const
VecDataArray
<
double
,
3
>&
parentVertices
=
*
parentVerticesPtr
;
std
::
shared_ptr
<
VecDataArray
<
double
,
3
>>
childVerticesPtr
=
meshChild
->
getInitialVertexPositions
();
const
VecDataArray
<
double
,
3
>&
childVertices
=
*
childVerticesPtr
;
const
VecDataArray
<
double
,
3
>&
parentVertices
=
*
parentVerticesPtr
;
std
::
shared_ptr
<
VecDataArray
<
double
,
3
>>
childVerticesPtr
=
meshChild
->
getInitialVertexPositions
();
const
VecDataArray
<
double
,
3
>&
childVertices
=
*
childVerticesPtr
;
// For every vertex on the child, find corresponding one on the parent
ParallelUtils
::
SpinLock
lock
;
ParallelUtils
::
parallelFor
(
meshChild
->
getNumVertices
(),
[
&
](
const
int
nodeId
)
{
...
...
@@ -52,35 +90,24 @@ OneToOneMap::compute()
// Add to the map
// Note: This replaces the map if one with <nodeId> already exists
lock
.
lock
();
m_oneToOne
Map
[
nodeId
]
=
matchingNodeId
;
// child index -> parent index
tetVertToSurfVert
Map
[
nodeId
]
=
matchingNodeId
;
// child index -> parent index
lock
.
unlock
();
});
// Copy data from map to vector for parallel processing
m_oneToOneMapVector
.
clear
();
for
(
auto
kv
:
m_oneToOneMap
)
{
m_oneToOneMapVector
.
push_back
({
kv
.
first
,
kv
.
second
});
}
}
int
OneToOneMap
::
findMatchingVertex
(
const
VecDataArray
<
double
,
3
>&
parentVertices
,
const
Vec3d
&
p
)
{
const
double
eps2
=
m_epsilon
*
m_epsilon
;
for
(
int
idx
=
0
;
idx
<
parentVertices
.
size
();
idx
++
)
{
if
(
p
.
isApprox
(
parentVertices
[
idx
],
m_epsilon
))
return
idx
;
if
(
p
.
isApprox
(
parentVertices
[
idx
],
m_epsilon
))
{
return
idx
;
}
}
return
-
1
;
}
bool
OneToOneMap
::
isValid
()
const
{
return
true
;
}
void
OneToOneMap
::
setMap
(
const
std
::
unordered_map
<
int
,
int
>&
sourceMap
)
{
...
...
@@ -95,68 +122,27 @@ OneToOneMap::setMap(const std::unordered_map<int, int>& sourceMap)
}
void
OneToOneMap
::
apply
()
OneToOneMap
::
requestUpdate
()
{
// Check Map active
if
(
!
m_isActive
)
{
LOG
(
WARNING
)
<<
"OneToOneMap map is not active"
;
return
;
}
// Check geometries
CHECK
(
m_parentGeom
!=
nullptr
&&
m_childGeom
!=
nullptr
)
<<
"OneToOneMap map is being applied without valid geometries"
;
auto
meshParent
=
std
::
dynamic_pointer_cast
<
PointSet
>
(
getParentGeometry
());
auto
meshChild
=
std
::
dynamic_pointer_cast
<
PointSet
>
(
getChildGeometry
());
// Check data
CHECK
(
m_oneToOneMap
.
size
()
==
m_oneToOneMapVector
.
size
())
<<
"Internal data is corrupted"
;
auto
meshParent
=
std
::
dynamic_pointer_cast
<
PointSet
>
(
m_parentGeom
);
auto
meshChild
=
std
::
dynamic_pointer_cast
<
PointSet
>
(
m_childGeom
);
CHECK
(
meshParent
!=
nullptr
&&
meshChild
!=
nullptr
)
<<
"Failed to cast from Geometry to PointSet"
;
std
::
shared_ptr
<
VecDataArray
<
double
,
3
>>
childVerticesPtr
=
meshChild
->
getVertexPositions
();
VecDataArray
<
double
,
3
>&
childVertices
=
*
childVerticesPtr
;
std
::
shared_ptr
<
VecDataArray
<
double
,
3
>>
parentVerticesPtr
=
meshParent
->
getVertexPositions
();
const
VecDataArray
<
double
,
3
>&
parentVertices
=
*
parentVerticesPtr
;
ParallelUtils
::
parallelFor
(
m_oneToOneMapVector
.
size
(),
[
&
](
const
size_t
idx
)
{
[
&
](
const
size_t
idx
)
{
const
auto
&
mapValue
=
m_oneToOneMapVector
[
idx
];
childVertices
[
mapValue
.
first
]
=
parentVertices
[
mapValue
.
second
];
});
meshChild
->
postModified
();
}
void
OneToOneMap
::
print
()
const
{
// Print Type
GeometryMap
::
print
();
// Print the one-to-one map
LOG
(
INFO
)
<<
"[childVertId, parentVertexId]
\n
"
;
for
(
auto
const
&
mapValue
:
m_oneToOneMap
)
{
LOG
(
INFO
)
<<
"["
<<
mapValue
.
first
<<
", "
<<
mapValue
.
second
<<
"]
\n
"
;
}
}
void
OneToOneMap
::
setParentGeometry
(
std
::
shared_ptr
<
Geometry
>
parent
)
{
CHECK
(
parent
!=
nullptr
)
<<
"The parent geometry provided is nullptr"
;
CHECK
(
std
::
dynamic_pointer_cast
<
PointSet
>
(
parent
)
!=
nullptr
)
<<
"The parent geometry provided is not PointSet"
;
GeometryMap
::
setParentGeometry
(
parent
);
}
void
OneToOneMap
::
setChildGeometry
(
std
::
shared_ptr
<
Geometry
>
child
)
{
CHECK
(
child
!=
nullptr
)
<<
"The child geometry provided is nullptr"
;
CHECK
(
std
::
dynamic_pointer_cast
<
PointSet
>
(
child
)
!=
nullptr
)
<<
"The child geometry provided is not PointSet"
;
GeometryMap
::
setChildGeometry
(
child
);
setOutput
(
meshChild
);
}
int
...
...
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