From 4910996b6386b99c909ec0c0628086eddecc7c57 Mon Sep 17 00:00:00 2001 From: richter Date: Thu, 12 Oct 2000 07:32:16 +0000 Subject: [PATCH] check for point in cell git-svn-id: https://svn.dealii.org/trunk@3414 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/include/grid/tria_accessor.h | 12 +++++++++ deal.II/deal.II/source/grid/tria_accessor.cc | 27 ++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/deal.II/deal.II/include/grid/tria_accessor.h b/deal.II/deal.II/include/grid/tria_accessor.h index 293e1d4b83..017e7f4edb 100644 --- a/deal.II/deal.II/include/grid/tria_accessor.h +++ b/deal.II/deal.II/include/grid/tria_accessor.h @@ -130,6 +130,9 @@ class TriaAccessor bool operator != (const TriaAccessor &) const; public: + + double ind_value; + /** * Data type to be used for passing * parameters from iterators to the @@ -1929,6 +1932,15 @@ class CellAccessor : public TriaObjectAccessor * of a cell). */ bool active () const; + + /** + * Test whether the point p is inside + * this cell. + * Up to now, this function is only + * implemented for 2d + */ + bool point_inside(const Point &p) const; + /** * Exception diff --git a/deal.II/deal.II/source/grid/tria_accessor.cc b/deal.II/deal.II/source/grid/tria_accessor.cc index a6f9354fc3..81c74c4352 100644 --- a/deal.II/deal.II/source/grid/tria_accessor.cc +++ b/deal.II/deal.II/source/grid/tria_accessor.cc @@ -1566,6 +1566,12 @@ void CellAccessor<1>::set_material_id (const unsigned char mat_id) const }; +template <> +bool CellAccessor<1>::point_inside (const Point<1> &) const +{ + Assert (false, ExcNotImplemented() ); +} + #endif @@ -1599,6 +1605,20 @@ void CellAccessor<2>::set_material_id (const unsigned char mat_id) const = mat_id; }; +template <> +bool CellAccessor<2>::point_inside (const Point<2> &p) const +{ + for (unsigned int k=0;k<4;++k) + { + const Point<2> to_p = p-vertex(k); + const Point<2> face = vertex((k+1)%4)-vertex(k); + if (-face(1)*to_p(0)+face(0)*to_p(1)<0) + return false; + } + return true; +} + + #endif @@ -1634,6 +1654,13 @@ void CellAccessor<3>::set_material_id (const unsigned char mat_id) const = mat_id; }; +template <> +bool CellAccessor<3>::point_inside (const Point<3> &) const +{ + Assert (false, ExcNotImplemented() ); +} + + #endif -- 2.39.5