Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs-feliks
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
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Feliks Kiszkurno
ogs-feliks
Commits
b29f936a
Commit
b29f936a
authored
12 years ago
by
Tom Fischer
Browse files
Options
Downloads
Patches
Plain Diff
Fixed a bug in algorithm for determining neighbour cells.
parent
4c8b020a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
GeoLib/Grid.h
+68
-49
68 additions, 49 deletions
GeoLib/Grid.h
with
68 additions
and
49 deletions
GeoLib/Grid.h
+
68
−
49
View file @
b29f936a
...
@@ -207,53 +207,72 @@ public:
...
@@ -207,53 +207,72 @@ public:
}
}
}
else
{
}
else
{
// search in all border cells for at least one neighbor
// search in all border cells for at least one neighbor
double
sqr_min_dist_tmp
;
double
sqr_min_dist_tmp
;
POINT
*
nearest_pnt_tmp
(
NULL
);
POINT
*
nearest_pnt_tmp
(
NULL
);
std
::
size_t
offset
(
1
);
std
::
size_t
offset
(
1
);
while
(
nearest_pnt
==
NULL
)
{
while
(
nearest_pnt
==
NULL
)
{
std
::
size_t
tmp_coords
[
3
];
std
::
size_t
tmp_coords
[
3
];
for
(
tmp_coords
[
0
]
=
coords
[
0
]
-
offset
;
tmp_coords
[
0
]
<
coords
[
0
]
+
offset
;
tmp_coords
[
0
]
++
)
{
if
(
coords
[
0
]
<
offset
)
{
for
(
tmp_coords
[
1
]
=
coords
[
1
]
-
offset
;
tmp_coords
[
1
]
<
coords
[
1
]
+
offset
;
tmp_coords
[
1
]
++
)
{
tmp_coords
[
0
]
=
0
;
for
(
tmp_coords
[
2
]
=
coords
[
2
]
-
offset
;
tmp_coords
[
2
]
<
coords
[
2
]
+
offset
;
tmp_coords
[
2
]
++
)
{
}
else
{
// do not check the origin grid cell twice
tmp_coords
[
0
]
=
coords
[
0
]
-
offset
;
if
(
!
(
tmp_coords
[
0
]
==
coords
[
0
]
&&
tmp_coords
[
1
]
==
coords
[
1
]
&&
tmp_coords
[
2
]
==
coords
[
2
]))
{
}
// check if temporary grid cell coordinates are valid
for
(;
tmp_coords
[
0
]
<
coords
[
0
]
+
offset
;
tmp_coords
[
0
]
++
)
{
if
(
tmp_coords
[
0
]
<
_n_steps
[
0
]
&&
tmp_coords
[
1
]
<
_n_steps
[
1
]
&&
tmp_coords
[
2
]
<
_n_steps
[
2
])
{
if
(
coords
[
1
]
<
offset
)
{
if
(
calcNearestPointInGridCell
(
pnt
,
tmp_coords
,
sqr_min_dist_tmp
,
nearest_pnt_tmp
))
{
tmp_coords
[
1
]
=
0
;
if
(
sqr_min_dist_tmp
<
sqr_min_dist
)
{
}
else
{
sqr_min_dist
=
sqr_min_dist_tmp
;
tmp_coords
[
1
]
=
coords
[
1
]
-
offset
;
nearest_pnt
=
nearest_pnt_tmp
;
}
}
}
// valid grid cell coordinates
}
// same element
}
// end k
}
// end j
}
// end i
offset
++
;
}
// end while
}
// end else
double
len
(
sqrt
(
MathLib
::
sqrDist
(
pnt
,
nearest_pnt
->
getCoords
())));
// search all other grid cells within the cube with the edge nodes
std
::
vector
<
std
::
vector
<
POINT
*>
const
*>
vecs_of_pnts
;
getPntVecsOfGridCellsIntersectingCube
(
pnt
,
len
,
vecs_of_pnts
);
const
std
::
size_t
n_vecs
(
vecs_of_pnts
.
size
());
for
(
std
::
size_t
j
(
0
);
j
<
n_vecs
;
j
++
)
{
std
::
vector
<
POINT
*>
const
&
pnts
(
*
(
vecs_of_pnts
[
j
]));
const
std
::
size_t
n_pnts
(
pnts
.
size
());
for
(
std
::
size_t
k
(
0
);
k
<
n_pnts
;
k
++
)
{
const
double
sqr_dist
(
MathLib
::
sqrDist
(
pnt
,
pnts
[
k
]
->
getCoords
()));
if
(
sqr_dist
<
sqr_min_dist
)
{
sqr_min_dist
=
sqr_dist
;
nearest_pnt
=
pnts
[
k
];
}
}
for
(;
tmp_coords
[
1
]
<
coords
[
1
]
+
offset
;
tmp_coords
[
1
]
++
)
{
if
(
coords
[
2
]
<
offset
)
{
tmp_coords
[
2
]
=
0
;
}
else
{
tmp_coords
[
2
]
=
coords
[
2
]
-
offset
;
}
for
(;
tmp_coords
[
2
]
<
coords
[
2
]
+
offset
;
tmp_coords
[
2
]
++
)
{
// do not check the origin grid cell twice
if
(
!
(
tmp_coords
[
0
]
==
coords
[
0
]
&&
tmp_coords
[
1
]
==
coords
[
1
]
&&
tmp_coords
[
2
]
==
coords
[
2
]))
{
// check if temporary grid cell coordinates are valid
if
(
tmp_coords
[
0
]
<
_n_steps
[
0
]
&&
tmp_coords
[
1
]
<
_n_steps
[
1
]
&&
tmp_coords
[
2
]
<
_n_steps
[
2
])
{
if
(
calcNearestPointInGridCell
(
pnt
,
tmp_coords
,
sqr_min_dist_tmp
,
nearest_pnt_tmp
))
{
if
(
sqr_min_dist_tmp
<
sqr_min_dist
)
{
sqr_min_dist
=
sqr_min_dist_tmp
;
nearest_pnt
=
nearest_pnt_tmp
;
}
}
}
// valid grid cell coordinates
}
// same element
}
// end k
}
// end j
}
// end i
offset
++
;
}
// end while
}
// end else
double
len
(
sqrt
(
MathLib
::
sqrDist
(
pnt
,
nearest_pnt
->
getCoords
())));
// search all other grid cells within the cube with the edge nodes
std
::
vector
<
std
::
vector
<
POINT
*>
const
*>
vecs_of_pnts
;
getPntVecsOfGridCellsIntersectingCube
(
pnt
,
len
,
vecs_of_pnts
);
const
std
::
size_t
n_vecs
(
vecs_of_pnts
.
size
());
for
(
std
::
size_t
j
(
0
);
j
<
n_vecs
;
j
++
)
{
std
::
vector
<
POINT
*>
const
&
pnts
(
*
(
vecs_of_pnts
[
j
]));
const
std
::
size_t
n_pnts
(
pnts
.
size
());
for
(
std
::
size_t
k
(
0
);
k
<
n_pnts
;
k
++
)
{
const
double
sqr_dist
(
MathLib
::
sqrDist
(
pnt
,
pnts
[
k
]
->
getCoords
()));
if
(
sqr_dist
<
sqr_min_dist
)
{
sqr_min_dist
=
sqr_dist
;
nearest_pnt
=
pnts
[
k
];
}
}
}
}
}
return
nearest_pnt
;
return
nearest_pnt
;
}
}
/**
/**
...
@@ -511,14 +530,14 @@ void Grid<POINT>::getPointCellBorderDistances(double const* const pnt,
...
@@ -511,14 +530,14 @@ void Grid<POINT>::getPointCellBorderDistances(double const* const pnt,
double
dists
[
6
],
double
dists
[
6
],
std
::
size_t
const
*
const
coords
)
const
std
::
size_t
const
*
const
coords
)
const
{
{
dists
[
0
]
=
(
pnt
[
2
]
-
this
->
_min_pnt
[
2
]
+
coords
[
2
]
*
_step_sizes
[
2
]);
// bottom
dists
[
0
]
=
fabs
(
pnt
[
2
]
-
this
->
_min_pnt
[
2
]
+
coords
[
2
]
*
_step_sizes
[
2
]);
// bottom
dists
[
5
]
=
(
_step_sizes
[
2
]
-
dist
s
[
0
]);
// top
dists
[
5
]
=
fabs
(
pnt
[
2
]
-
this
->
_min_pnt
[
2
]
+
(
coords
[
2
]
+
1
)
*
_step_size
s
[
2
]);
// top
dists
[
1
]
=
(
pnt
[
1
]
-
this
->
_min_pnt
[
1
]
+
coords
[
1
]
*
_step_sizes
[
1
]);
// front
dists
[
1
]
=
fabs
(
pnt
[
1
]
-
this
->
_min_pnt
[
1
]
+
coords
[
1
]
*
_step_sizes
[
1
]);
// front
dists
[
3
]
=
(
_step_sizes
[
1
]
-
dist
s
[
1
]);
// back
dists
[
3
]
=
fabs
(
pnt
[
1
]
-
this
->
_min_pnt
[
1
]
+
(
coords
[
1
]
+
1
)
*
_step_size
s
[
1
]);
// back
dists
[
4
]
=
(
pnt
[
0
]
-
this
->
_min_pnt
[
0
]
+
coords
[
0
]
*
_step_sizes
[
0
]);
// left
dists
[
4
]
=
fabs
(
pnt
[
0
]
-
this
->
_min_pnt
[
0
]
+
coords
[
0
]
*
_step_sizes
[
0
]);
// left
dists
[
2
]
=
(
_step_sizes
[
0
]
-
dist
s
[
4
]);
// right
dists
[
2
]
=
fabs
(
pnt
[
0
]
-
this
->
_min_pnt
[
0
]
+
(
coords
[
0
]
+
1
)
*
_step_size
s
[
0
]);
// right
}
}
}
// end namespace GeoLib
}
// end namespace GeoLib
...
...
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