LCOV - code coverage report
Current view: top level - ugbase/common/math/misc - shapes.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 5 0
Test Date: 2025-09-21 23:31:46 Functions: 0.0 % 3 0

            Line data    Source code
       1              : /*
       2              :  * Copyright (c) 2012-2015:  G-CSC, Goethe University Frankfurt
       3              :  * Author: Sebastian Reiter
       4              :  * 
       5              :  * This file is part of UG4.
       6              :  * 
       7              :  * UG4 is free software: you can redistribute it and/or modify it under the
       8              :  * terms of the GNU Lesser General Public License version 3 (as published by the
       9              :  * Free Software Foundation) with the following additional attribution
      10              :  * requirements (according to LGPL/GPL v3 §7):
      11              :  * 
      12              :  * (1) The following notice must be displayed in the Appropriate Legal Notices
      13              :  * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
      14              :  * 
      15              :  * (2) The following notice must be displayed at a prominent place in the
      16              :  * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
      17              :  * 
      18              :  * (3) The following bibliography is recommended for citation and must be
      19              :  * preserved in all covered files:
      20              :  * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
      21              :  *   parallel geometric multigrid solver on hierarchically distributed grids.
      22              :  *   Computing and visualization in science 16, 4 (2013), 151-164"
      23              :  * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
      24              :  *   flexible software system for simulating pde based models on high performance
      25              :  *   computers. Computing and visualization in science 16, 4 (2013), 165-179"
      26              :  * 
      27              :  * This program is distributed in the hope that it will be useful,
      28              :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      29              :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
      30              :  * GNU Lesser General Public License for more details.
      31              :  */
      32              : 
      33              : #ifndef __H__UG_shapes__
      34              : #define __H__UG_shapes__
      35              : 
      36              : #include "math_util.h"
      37              : #include <iostream>
      38              :  
      39              : namespace ug{
      40              : 
      41              : template <class vector_t>
      42              : class Sphere{
      43              :         public:
      44              :                 Sphere()        {}
      45              :                 Sphere(const vector_t& nCenter, number nRadius) :
      46              :                         center(nCenter), radius(nRadius)        {}
      47              : 
      48              :         ///     returns true if the point lies inside or on the bounds of the rectangle
      49              :                 bool contains_point(const vector_t& point) const;
      50              : 
      51              :         ///     returns true if the specified sphere touches or intersects this sphere.
      52              :                 bool intersects(const Sphere& sphere) const;
      53              : 
      54              :                 vector_t        center;
      55              :                 number          radius;
      56              : };
      57              : 
      58              : 
      59              : template <class vector_t>
      60            0 : struct AABox{
      61            0 :         AABox() {}
      62              :         AABox(const vector_t& nMin, const vector_t& nMax) : min(nMin), max(nMax)        {}
      63              : 
      64              : ///     calculates the bounding box to the given set of points.
      65              :         AABox(const vector_t* points, size_t numPoints);
      66              : 
      67              : ///     calculates the bounding box of two given bounding boxes
      68              :         AABox(const AABox& b1, const AABox& b2);
      69              : 
      70              : ///     calculates the bounding box of the given sphere
      71              :         AABox(const Sphere<vector_t>& s);
      72              : 
      73              : ///     calculates the bounding box of a given box and an additional point
      74              :         AABox(const AABox& b, const vector_t& v);
      75              : 
      76              : ///     returns the center of the box
      77              :         vector_t center() const;
      78              : 
      79              : ///     returns the extension (width/height/depth) of the box
      80              :         vector_t extension() const;
      81              : 
      82              : ///     returns true if the given point lies in the box or on its boundary
      83              :         bool contains_point(const vector_t& point) const;
      84              : 
      85              : /// return true if the given line (segment) and the box overlap
      86              :         bool overlaps_line(const vector_t& point1, const vector_t& point2) const;
      87              : 
      88              :         vector_t min;
      89              :         vector_t max;
      90              : };
      91              : 
      92              : 
      93              : template <class vector_t>
      94            0 : std::ostream& operator << (std::ostream& out, const AABox<vector_t>& box) {
      95            0 :         out << box.min << "-" << box.max;
      96            0 :         return out;
      97              : }
      98              : 
      99              : }//     end of namespace
     100              : 
     101              : 
     102              : #include "shapes_impl.h"
     103              : 
     104              : #endif
        

Generated by: LCOV version 2.0-1