[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Getfem-commits] (no subject)
From: |
Markus Bürg |
Subject: |
[Getfem-commits] (no subject) |
Date: |
Thu, 23 May 2019 10:24:00 -0400 (EDT) |
branch: mb-Use_rtree_in_poly_composite
commit 8117af56c55093921bcfcbd2b09b4bd5d4bac778
Author: mb <address@hidden>
Date: Thu May 23 16:19:11 2019 +0200
Store pointers instead of copies.
---
src/bgeot_rtree.cc | 24 ++++++++++++------------
src/getfem/bgeot_rtree.h | 2 +-
src/getfem_generic_assembly_interpolation.cc | 6 +++---
src/getfem_interpolation_on_deformed_domains.cc | 4 ++--
4 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/src/bgeot_rtree.cc b/src/bgeot_rtree.cc
index 25182bc..8d57e30 100644
--- a/src/bgeot_rtree.cc
+++ b/src/bgeot_rtree.cc
@@ -183,7 +183,7 @@ namespace bgeot {
const rtree_leaf *rl = static_cast<rtree_leaf*>(n);
for (rtree::pbox_cont::const_iterator it = rl->lst.begin();
it != rl->lst.end(); ++it) {
- if (p((*it)->min, (*it)->max)) { boxlst.insert(*it); }
+ if (p(*(*it)->min, *(*it)->max)) { boxlst.insert(*it); }
}
} else {
const rtree_node *rn = static_cast<rtree_node*>(n);
@@ -247,9 +247,9 @@ namespace bgeot {
scalar_type v = bmin[dir] + (bmax[dir] - bmin[dir])/2; split_v = v;
size_type cnt = 0;
for (rtree::pbox_cont::const_iterator it = b.begin(); it!=b.end(); ++it) {
- if ((*it)->max[dir] < v) {
- if (cnt == 0) split_v = (*it)->max[dir];
- else split_v = std::max((*it)->max[dir],split_v);
+ if ((*it)->max->at(dir) < v) {
+ if (cnt == 0) split_v = (*it)->max->at(dir);
+ else split_v = std::max((*it)->max->at(dir),split_v);
cnt++;
}
}
@@ -281,8 +281,8 @@ namespace bgeot {
size_type cnt1=0,cnt2=0;
for (rtree::pbox_cont::const_iterator it = b.begin();
it != b.end(); ++it) {
- if ((*it)->min[split_dir] < split_v) cnt1++;
- if ((*it)->max[split_dir] > split_v) cnt2++;
+ if ((*it)->min->at(split_dir) < split_v) cnt1++;
+ if ((*it)->max->at(split_dir) > split_v) cnt2++;
}
assert(cnt1); assert(cnt2);
GMM_ASSERT1(cnt1+cnt2 >= b.size(), "internal error");
@@ -292,13 +292,13 @@ namespace bgeot {
cnt1 = cnt2 = 0;
for (rtree::pbox_cont::const_iterator it = b.begin();
it != b.end(); ++it) {
- if ((*it)->min[split_dir] < split_v) {
+ if ((*it)->min->at(split_dir) < split_v) {
v1[cnt1++] = *it;
- update_box(bmin1,bmax1,(*it)->min,(*it)->max);
+ update_box(bmin1,bmax1,*(*it)->min,*(*it)->max);
}
- if ((*it)->max[split_dir] > split_v) {
+ if ((*it)->max->at(split_dir) > split_v) {
v2[cnt2++] = *it;
- update_box(bmin2,bmax2,(*it)->min,(*it)->max);
+ update_box(bmin2,bmax2,*(*it)->min,*(*it)->max);
}
}
for (size_type k=0; k < N; ++k) {
@@ -325,9 +325,9 @@ namespace bgeot {
assert(root == 0);
pbox_cont b(boxes.size());
pbox_cont::iterator b_it = b.begin();
- base_node bmin(boxes.front().min), bmax(boxes.front().max);
+ base_node bmin(*boxes.begin()->min), bmax(*boxes.begin()->max);
for (box_cont::const_iterator it=boxes.begin(); it != boxes.end(); ++it) {
- update_box(bmin,bmax,(*it).min,(*it).max);
+ update_box(bmin,bmax,*(*it).min,*(*it).max);
*b_it++ = &(*it);
}
root = build_tree_(b, bmin, bmax, 0);
diff --git a/src/getfem/bgeot_rtree.h b/src/getfem/bgeot_rtree.h
index dd7a496..48a5b5e 100644
--- a/src/getfem/bgeot_rtree.h
+++ b/src/getfem/bgeot_rtree.h
@@ -45,7 +45,7 @@ namespace bgeot {
struct box_index {
size_type id;
- base_node min, max;
+ const base_node *min, *max;
};
struct box_index_compare {
diff --git a/src/getfem_generic_assembly_interpolation.cc
b/src/getfem_generic_assembly_interpolation.cc
index 9fdddf7..3a4ce15 100644
--- a/src/getfem_generic_assembly_interpolation.cc
+++ b/src/getfem_generic_assembly_interpolation.cc
@@ -671,10 +671,10 @@ namespace getfem {
for (const auto &box : bset) {
scalar_type rating = scalar_type(1);
for (size_type i = 0; i < m.dim(); ++i) {
- scalar_type h = box->max[i] - box->min[i];
+ scalar_type h = box->max->at(i) - box->min->at(i);
if (h > scalar_type(0)) {
- scalar_type r = std::min(box->max[i] - P[i],
- P[i] - box->min[i]) / h;
+ scalar_type r = std::min(box->max->at(i) - P[i],
+ P[i] - box->min->at(i)) / h;
rating = std::min(r, rating);
}
}
diff --git a/src/getfem_interpolation_on_deformed_domains.cc
b/src/getfem_interpolation_on_deformed_domains.cc
index 04473a2..2224184 100644
--- a/src/getfem_interpolation_on_deformed_domains.cc
+++ b/src/getfem_interpolation_on_deformed_domains.cc
@@ -60,9 +60,9 @@ auto most_central_box(const bgeot::rtree::pbox_set &bset,
for (; it != end(bset); ++it) {
auto rate_box = scalar_type{1};
for (size_type i = 0; i < pt.size(); ++i) {
- auto h = (*it)->max[i] - (*it)->min[i];
+ auto h = (*it)->max->at(i) - (*it)->min->at(i);
if (h > 0.) {
- auto rate = min((*it)->max[i] - pt[i], pt[i] - (*it)->min[i]) / h;
+ auto rate = min((*it)->max->at(i) - pt[i], pt[i] -
(*it)->min->at(i)) / h;
rate_box = min(rate, rate_box);
}
}
- [Getfem-commits] [getfem-commits] branch mb-Use_rtree_in_poly_composite created (now 22cd69d), Markus Bürg, 2019/05/23
- [Getfem-commits] (no subject), Markus Bürg, 2019/05/23
- [Getfem-commits] (no subject), Markus Bürg, 2019/05/23
- [Getfem-commits] (no subject), Markus Bürg, 2019/05/23
- [Getfem-commits] (no subject), Markus Bürg, 2019/05/23
- [Getfem-commits] (no subject), Markus Bürg, 2019/05/23
- [Getfem-commits] (no subject), Markus Bürg, 2019/05/23
- [Getfem-commits] (no subject),
Markus Bürg <=
- [Getfem-commits] (no subject), Markus Bürg, 2019/05/23
- [Getfem-commits] (no subject), Markus Bürg, 2019/05/23
- [Getfem-commits] (no subject), Markus Bürg, 2019/05/23