[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Getfem-commits] (no subject)
From: |
Konstantinos Poulios |
Subject: |
[Getfem-commits] (no subject) |
Date: |
Sat, 24 Jun 2017 17:28:15 -0400 (EDT) |
branch: devel-logari81
commit 2d7e2b0d7bc1e77e6f2b6f3c407cb15b36895401
Author: Konstantinos Poulios <address@hidden>
Date: Sat Jun 24 23:27:20 2017 +0200
add new function getfem::mesh::select_convexes_in_box
---
src/getfem/getfem_mesh.h | 19 +++++++++++++++----
src/getfem_mesh.cc | 22 ++++++++++++++++++++++
2 files changed, 37 insertions(+), 4 deletions(-)
diff --git a/src/getfem/getfem_mesh.h b/src/getfem/getfem_mesh.h
index ba1342c..cf67b83 100644
--- a/src/getfem/getfem_mesh.h
+++ b/src/getfem/getfem_mesh.h
@@ -656,10 +656,21 @@ namespace getfem {
/** Select in the region mr the faces of the mesh m lying entirely in the
box delimated by pt1 and pt2.
*/
- mesh_region APIDECL select_faces_in_box(const mesh &m, const mesh_region &mr,
- const base_node &pt1,
- const base_node &pt2);
-
+ mesh_region APIDECL
+ select_faces_in_box(const mesh &m, const mesh_region &mr,
+ const base_node &pt1,
+ const base_node &pt2);
+
+ mesh_region APIDECL
+ select_convexes_in_box(const mesh &m, const mesh_region &mr,
+ const base_node &pt1,
+ const base_node &pt2);
+
+ inline mesh_region APIDECL
+ select_convexes_in_box(const mesh &m,
+ const base_node &pt1,
+ const base_node &pt2)
+ { return select_convexes_in_box(m, m.region(-1), pt1, pt2); }
///@}
} /* end of namespace getfem. */
diff --git a/src/getfem_mesh.cc b/src/getfem_mesh.cc
index 03082a1..caeb31d 100644
--- a/src/getfem_mesh.cc
+++ b/src/getfem_mesh.cc
@@ -881,6 +881,28 @@ namespace getfem {
return mrr;
}
+ mesh_region select_convexes_in_box(const mesh &m, const mesh_region &mr,
+ const base_node &pt1, const base_node
&pt2) {
+ mesh_region mrr;
+ size_type N = m.dim();
+ GMM_ASSERT1(pt1.size() == N && pt2.size() == N, "Wrong dimensions");
+ for (getfem::mr_visitor i(mr, m); !i.finished(); ++i)
+ if (i.f() == short_type(-1)) {
+ bgeot::mesh_structure::ind_cv_ct pt = m.ind_points_of_convex(i.cv());
+
+ bool is_in = true;
+ for (bgeot::mesh_structure::ind_cv_ct::iterator it = pt.begin();
+ it != pt.end(); ++it) {
+ for (size_type j = 0; j < N; ++j)
+ if (m.points()[*it][j] < pt1[j] || m.points()[*it][j] > pt2[j])
+ { is_in = false; break; }
+ if (!is_in) break;
+ }
+ if (is_in) mrr.add(i.cv());
+ }
+ return mrr;
+ }
+
void extrude(const mesh& in, mesh& out, size_type nb_layers, short_type
degree) {
dim_type dim = in.dim();
base_node pt(dim+1);