Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
iwr
amdis
Commits
8618030b
Commit
8618030b
authored
Aug 02, 2012
by
Praetorius, Simon
Browse files
backgroundmesh and kdtree updated
parent
7e87c6ed
Changes
2
Hide whitespace changes
Inline
Side-by-side
extensions/BackgroundMesh.cc
View file @
8618030b
...
...
@@ -217,7 +217,7 @@ namespace experimental {
void
Box
::
init
()
{
int
maxNr
=
1
.0
;
int
maxNr
=
1
;
for
(
size_t
i
=
0
;
i
<
DOW
;
i
++
)
maxNr
*=
N
[
i
];
boxData
.
resize
(
maxNr
);
...
...
@@ -370,4 +370,4 @@ namespace experimental {
boxData
[
nr
].
push_back
(
data
);
}
}
\ No newline at end of file
}
extensions/kdtree_nanoflann_mesh.h
View file @
8618030b
...
...
@@ -36,6 +36,7 @@
#include
<iostream>
#include
"AMDiS.h"
#include
"ElementFunction.h"
using
namespace
nanoflann
;
using
namespace
AMDiS
;
...
...
@@ -66,10 +67,12 @@ typedef std::vector<DataType> VectorOfDataType;
typename
index_type
=
DegreeOfFreedom
>
struct
KDTreeMeshAdaptor
{
typedef
KDTreeMeshAdaptor
<
VectorOfPointsType_
,
typedef
KDTreeMeshAdaptor
<
VectorOfPointsType_
,
VectorOfDataType_
,
value_type
,
DIM
,
Distance
>
self_t
;
Distance
,
index_type
>
self_t
;
typedef
typename
Distance
::
template
traits
<
value_type
,
self_t
>
::
distance_t
metric_t
;
typedef
KDTreeSingleIndexAdaptor
<
metric_t
,
self_t
,
...
...
@@ -77,11 +80,12 @@ typedef std::vector<DataType> VectorOfDataType;
index_type
>
index_t
;
index_t
*
index
;
//! The kd-tree index for the user to call its methods as usual with any other FLANN index.
Mesh
*
mesh
;
/// Constructor: takes a const ref to the vector of vectors object with the data points
KDTree
VectorOfWorldVectors
Adaptor
(
const
int
dimensionality
,
Mesh
*
mesh_
,
const
int
leaf_max_size
=
10
)
KDTree
Mesh
Adaptor
(
const
int
dimensionality
,
Mesh
*
mesh_
,
const
int
leaf_max_size
=
10
)
:
mesh
(
mesh_
)
{
const
size_t
dims
=
Global
::
getGeo
(
WORLD
);
...
...
@@ -98,7 +102,7 @@ typedef std::vector<DataType> VectorOfDataType;
index
->
buildIndex
();
}
~
KDTree
VectorOfWorldVectors
Adaptor
()
{
~
KDTree
Mesh
Adaptor
()
{
delete
index
;
}
...
...
@@ -138,8 +142,8 @@ typedef std::vector<DataType> VectorOfDataType;
index
->
buildIndex
();
}
VectorOfPointsType_
&
m_points
;
VectorOfDataType_
&
m_data
;
VectorOfPointsType_
m_points
;
VectorOfDataType_
m_data
;
/** Query for the \a num_closest closest points to a given point (entered as query_point[0:dim-1]).
* Note that this is a short-cut method for index->findNeighbors().
...
...
@@ -169,7 +173,7 @@ typedef std::vector<DataType> VectorOfDataType;
// Must return the number of data points
inline
size_t
kdtree_get_point_count
()
const
{
return
m_points
.
getUsedS
ize
();
return
m_points
.
s
ize
();
}
// Returns the distance between the vector "p1[0:size-1]" and the data point with index "idx_p2" stored in the class:
...
...
@@ -249,24 +253,24 @@ typedef std::vector<DataType> VectorOfDataType;
};
// end of KDTreeMeshAdaptor
typedef
KDTreeMeshAdaptor
<
VectorOfPointsType
,
VectorOfDataType
,
double
>
KD_Tree
;
static
std
::
map
<
const
FiniteElemSpace
*
,
std
::
pair
<
int
,
KD_Tree
*>
>
kdtreeMap
;
typedef
KDTreeMeshAdaptor
<
VectorOfPointsType
,
VectorOfDataType
,
double
>
KD_Tree
_M
;
static
std
::
map
<
const
FiniteElemSpace
*
,
std
::
pair
<
int
,
KD_Tree
_M
*>
>
kdtreeMap
_M
;
inline
KD_Tree
*
provideKDTree
(
const
FiniteElemSpace
*
feSpace
)
inline
KD_Tree
_M
*
provideKDTree
(
const
FiniteElemSpace
*
feSpace
)
{
if
(
kdtreeMap
.
find
(
feSpace
)
!=
kdtreeMap
.
end
())
{
if
(
kdtreeMap
[
feSpace
].
first
!=
feSpace
->
getMesh
()
->
getChangeIndex
())
{
kdtreeMap
[
feSpace
].
second
->
reinit
();
kdtreeMap
[
feSpace
].
first
=
feSpace
->
getMesh
()
->
getChangeIndex
();
if
(
kdtreeMap
_M
.
find
(
feSpace
)
!=
kdtreeMap
_M
.
end
())
{
if
(
kdtreeMap
_M
[
feSpace
].
first
!=
feSpace
->
getMesh
()
->
getChangeIndex
())
{
kdtreeMap
_M
[
feSpace
].
second
->
reinit
();
kdtreeMap
_M
[
feSpace
].
first
=
feSpace
->
getMesh
()
->
getChangeIndex
();
}
}
else
{
KD_Tree
*
kdtree
=
new
KD_Tree
(
Global
::
getGeo
(
WORLD
),
feSpace
->
getMesh
());
kdtreeMap
[
feSpace
]
=
std
::
make_pair
(
feSpace
->
getMesh
()
->
getChangeIndex
(),
kdtree
);
KD_Tree
_M
*
kdtree
=
new
KD_Tree
_M
(
Global
::
getGeo
(
WORLD
),
feSpace
->
getMesh
());
kdtreeMap
_M
[
feSpace
]
=
std
::
make_pair
(
feSpace
->
getMesh
()
->
getChangeIndex
(),
kdtree
);
}
return
kdtreeMap
[
feSpace
].
second
;
return
kdtreeMap
_M
[
feSpace
].
second
;
}
}
// end namespace
}
// end namespace
experimental
#endif
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