Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
Dmitri Naumov
ogs
Commits
c75feee1
Commit
c75feee1
authored
9 years ago
by
Tom Fischer
Browse files
Options
Downloads
Patches
Plain Diff
[GL] QuadTree: Renamed _childs -> _children.
parent
e0236229
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
GeoLib/QuadTree.h
+32
-32
32 additions, 32 deletions
GeoLib/QuadTree.h
with
32 additions
and
32 deletions
GeoLib/QuadTree.h
+
32
−
32
View file @
c75feee1
...
...
@@ -54,9 +54,9 @@ public:
{
assert
(
_max_points_per_node
>
0
);
// init child
s
// init child
ren
for
(
std
::
size_t
k
(
0
);
k
<
4
;
k
++
)
_child
s
[
k
]
=
nullptr
;
_child
ren
[
k
]
=
nullptr
;
if
((
_ur
[
0
]
-
_ll
[
0
])
>
(
_ur
[
1
]
-
_ll
[
1
]))
_ur
[
1
]
=
_ll
[
1
]
+
_ur
[
0
]
-
_ll
[
0
];
...
...
@@ -72,7 +72,7 @@ public:
~
QuadTree
()
{
for
(
std
::
size_t
k
(
0
);
k
<
4
;
k
++
)
{
delete
_child
s
[
k
];
delete
_child
ren
[
k
];
}
}
...
...
@@ -91,7 +91,7 @@ public:
if
(
!
_is_leaf
)
{
for
(
std
::
size_t
k
(
0
);
k
<
4
;
k
++
)
{
if
(
_child
s
[
k
]
->
addPoint
(
pnt
))
if
(
_child
ren
[
k
]
->
addPoint
(
pnt
))
return
true
;
}
return
false
;
...
...
@@ -184,7 +184,7 @@ public:
leaf_list
.
push_back
(
this
);
else
for
(
std
::
size_t
k
(
0
);
k
<
4
;
k
++
)
_child
s
[
k
]
->
getLeafs
(
leaf_list
);
_child
ren
[
k
]
->
getLeafs
(
leaf_list
);
}
...
...
@@ -208,16 +208,16 @@ public:
if
(
pnt
[
0
]
<=
0.5
*
(
_ur
[
0
]
+
_ll
[
0
]))
// WEST
{
if
(
pnt
[
1
]
<=
0.5
*
(
_ur
[
1
]
+
_ll
[
1
]))
// SOUTH
_child
s
[
static_cast
<
int
>
(
Quadrant
::
SW
)]
->
getLeaf
(
pnt
,
ll
,
ur
);
_child
ren
[
static_cast
<
int
>
(
Quadrant
::
SW
)]
->
getLeaf
(
pnt
,
ll
,
ur
);
else
// NORTH
_child
s
[
static_cast
<
int
>
(
Quadrant
::
NW
)]
->
getLeaf
(
pnt
,
ll
,
ur
);
_child
ren
[
static_cast
<
int
>
(
Quadrant
::
NW
)]
->
getLeaf
(
pnt
,
ll
,
ur
);
}
else
// EAST
{
if
(
pnt
[
1
]
<=
0.5
*
(
_ur
[
1
]
+
_ll
[
1
]))
// SOUTH
_child
s
[
static_cast
<
int
>
(
Quadrant
::
SE
)]
->
getLeaf
(
pnt
,
ll
,
ur
);
_child
ren
[
static_cast
<
int
>
(
Quadrant
::
SE
)]
->
getLeaf
(
pnt
,
ll
,
ur
);
else
// NORTH
_child
s
[
static_cast
<
int
>
(
Quadrant
::
NE
)]
->
getLeaf
(
pnt
,
ll
,
ur
);
_child
ren
[
static_cast
<
int
>
(
Quadrant
::
NE
)]
->
getLeaf
(
pnt
,
ll
,
ur
);
}
}
}
...
...
@@ -229,7 +229,7 @@ public:
QuadTree
<
POINT
>
const
*
getChild
(
Quadrant
quadrant
)
const
{
return
_child
s
[
quadrant
];
return
_child
ren
[
quadrant
];
}
/**
...
...
@@ -243,8 +243,8 @@ public:
max_depth
=
_depth
;
for
(
std
::
size_t
k
(
0
);
k
<
4
;
k
++
)
{
if
(
_child
s
[
k
])
{
_child
s
[
k
]
->
getMaxDepth
(
max_depth
);
if
(
_child
ren
[
k
])
{
_child
ren
[
k
]
->
getMaxDepth
(
max_depth
);
}
}
}
...
...
@@ -258,14 +258,14 @@ public:
private
:
QuadTree
<
POINT
>*
getChild
(
Quadrant
quadrant
)
{
return
_child
s
[
static_cast
<
int
>
(
quadrant
)];
return
_child
ren
[
static_cast
<
int
>
(
quadrant
)];
}
bool
isLeaf
()
const
{
return
_is_leaf
;
}
bool
isChild
(
QuadTree
<
POINT
>
const
*
const
tree
,
Quadrant
quadrant
)
const
{
if
(
_child
s
[
static_cast
<
int
>
(
quadrant
)]
==
tree
)
return
true
;
if
(
_child
ren
[
static_cast
<
int
>
(
quadrant
)]
==
tree
)
return
true
;
return
false
;
}
...
...
@@ -373,38 +373,38 @@ private:
_father
(
father
),
_ll
(
ll
),
_ur
(
ur
),
_depth
(
depth
),
_is_leaf
(
true
),
_max_points_per_node
(
max_points_per_node
)
{
// init child
s
// init child
ren
for
(
std
::
size_t
k
(
0
);
k
<
4
;
k
++
)
_child
s
[
k
]
=
nullptr
;
_child
ren
[
k
]
=
nullptr
;
}
void
splitNode
()
{
// create child
s
// create child
ren
POINT
mid_point
(
_ll
);
mid_point
[
0
]
+=
(
_ur
[
0
]
-
_ll
[
0
])
/
2.0
;
mid_point
[
1
]
+=
(
_ur
[
1
]
-
_ll
[
1
])
/
2.0
;
assert
(
_child
s
[
0
]
==
nullptr
);
_child
s
[
0
]
=
new
QuadTree
<
POINT
>
(
mid_point
,
_ur
,
this
,
_depth
+
1
,
_max_points_per_node
);
// north east
assert
(
_child
ren
[
0
]
==
nullptr
);
_child
ren
[
0
]
=
new
QuadTree
<
POINT
>
(
mid_point
,
_ur
,
this
,
_depth
+
1
,
_max_points_per_node
);
// north east
POINT
h_ll
(
mid_point
),
h_ur
(
mid_point
);
h_ll
[
0
]
=
_ll
[
0
];
h_ur
[
1
]
=
_ur
[
1
];
assert
(
_child
s
[
1
]
==
nullptr
);
_child
s
[
1
]
=
new
QuadTree
<
POINT
>
(
h_ll
,
h_ur
,
this
,
_depth
+
1
,
_max_points_per_node
);
// north west
assert
(
_child
s
[
2
]
==
nullptr
);
_child
s
[
2
]
=
new
QuadTree
<
POINT
>
(
_ll
,
mid_point
,
this
,
_depth
+
1
,
_max_points_per_node
);
// south west
assert
(
_child
ren
[
1
]
==
nullptr
);
_child
ren
[
1
]
=
new
QuadTree
<
POINT
>
(
h_ll
,
h_ur
,
this
,
_depth
+
1
,
_max_points_per_node
);
// north west
assert
(
_child
ren
[
2
]
==
nullptr
);
_child
ren
[
2
]
=
new
QuadTree
<
POINT
>
(
_ll
,
mid_point
,
this
,
_depth
+
1
,
_max_points_per_node
);
// south west
h_ll
=
_ll
;
h_ll
[
0
]
=
mid_point
[
0
];
h_ur
=
_ur
;
h_ur
[
1
]
=
mid_point
[
1
];
assert
(
_child
s
[
3
]
==
nullptr
);
_child
s
[
3
]
=
new
QuadTree
<
POINT
>
(
h_ll
,
h_ur
,
this
,
_depth
+
1
,
_max_points_per_node
);
// south east
assert
(
_child
ren
[
3
]
==
nullptr
);
_child
ren
[
3
]
=
new
QuadTree
<
POINT
>
(
h_ll
,
h_ur
,
this
,
_depth
+
1
,
_max_points_per_node
);
// south east
// distribute points to sub quadtrees
for
(
std
::
size_t
j
(
0
);
j
<
_pnts
.
size
();
j
++
)
{
bool
nfound
(
true
);
for
(
std
::
size_t
k
(
0
);
k
<
4
&&
nfound
;
k
++
)
if
(
_child
s
[
k
]
->
addPoint
(
_pnts
[
j
]))
nfound
=
false
;
if
(
_child
ren
[
k
]
->
addPoint
(
_pnts
[
j
]))
nfound
=
false
;
}
_pnts
.
clear
();
...
...
@@ -469,13 +469,13 @@ private:
QuadTree
<
POINT
>*
_father
;
/**
* child
s
are sorted:
* _child
s
[0] is north east child
* _child
s
[1] is north west child
* _child
s
[2] is south west child
* _child
s
[3] is south east child
* child
ren
are sorted:
* _child
ren
[0] is north east child
* _child
ren
[1] is north west child
* _child
ren
[2] is south west child
* _child
ren
[3] is south east child
*/
QuadTree
<
POINT
>*
_child
s
[
4
];
QuadTree
<
POINT
>*
_child
ren
[
4
];
/**
* lower left point of the square
*/
...
...
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