$extrastylesheet
00001 // The libMesh Finite Element Library. 00002 // Copyright (C) 2002-2014 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner 00003 00004 // This library is free software; you can redistribute it and/or 00005 // modify it under the terms of the GNU Lesser General Public 00006 // License as published by the Free Software Foundation; either 00007 // version 2.1 of the License, or (at your option) any later version. 00008 00009 // This library is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 // Lesser General Public License for more details. 00013 00014 // You should have received a copy of the GNU Lesser General Public 00015 // License along with this library; if not, write to the Free Software 00016 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 00018 00019 #include "libmesh/libmesh_config.h" 00020 00021 #ifdef LIBMESH_HAVE_TRIANGLE 00022 00023 // Local includes 00024 #include "libmesh/mesh_triangle_holes.h" 00025 00026 namespace libMesh 00027 { 00028 00029 // 00030 // PolygonHole member functions 00031 // 00032 TriangleInterface::PolygonHole::PolygonHole 00033 (const Point& center, Real radius, unsigned int n_points_in) 00034 : _center(center), 00035 _radius(radius), 00036 _n_points(n_points_in) 00037 {} 00038 00039 00040 unsigned int TriangleInterface::PolygonHole::n_points() const 00041 { 00042 return _n_points; 00043 } 00044 00045 Point TriangleInterface::PolygonHole::point(const unsigned int n) const 00046 { 00047 // The nth point lies at the angle theta = 2 * pi * n / _n_points 00048 const Real theta = static_cast<Real>(n) * 2.0 * libMesh::pi / static_cast<Real>(_n_points); 00049 00050 return Point(_center(0) + _radius*std::cos(theta), // x=r*cos(theta) 00051 _center(1) + _radius*std::sin(theta), // y=r*sin(theta) 00052 0.); 00053 } 00054 00055 00056 00057 Point TriangleInterface::PolygonHole::inside() const 00058 { 00059 // The center of the hole is definitely inside. 00060 return _center; 00061 } 00062 00063 00064 00065 // 00066 // ArbitraryHole member functions 00067 // 00068 TriangleInterface::ArbitraryHole::ArbitraryHole(const Point& center, 00069 const std::vector<Point>& points) 00070 : _center(center), 00071 _points(points) 00072 {} 00073 00074 00075 unsigned int TriangleInterface::ArbitraryHole::n_points() const 00076 { 00077 return _points.size(); 00078 } 00079 00080 00081 Point TriangleInterface::ArbitraryHole::point(const unsigned int n) const 00082 { 00083 libmesh_assert_less (n, _points.size()); 00084 return _points[n]; 00085 } 00086 00087 00088 Point TriangleInterface::ArbitraryHole::inside() const 00089 { 00090 return _center; 00091 } 00092 00093 00094 } // namespace libMesh 00095 00096 00097 #endif // LIBMESH_HAVE_TRIANGLE