Commit 3dffee02 authored by Dennis Gläser's avatar Dennis Gläser
Browse files

[intersect] add quadrilateral-disk algorithm

parent 41914d61
......@@ -8,6 +8,7 @@ algo_planargeom_line.hh
algo_planargeom_planargeom.hh
algo_plane_line.hh
algo_plane_plane.hh
algo_quadrilateral_disk.hh
algo_quadrilateral_line.hh
algo_quadrilateral_quadrilateral.hh
algo_segment_segment.hh
......
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*****************************************************************************
* See the file COPYING for full copying permissions. *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*****************************************************************************/
/*!
* \file
* \brief Contains the intersection algorithm
* between a quadrilateral and a disk.
*/
#ifndef FRACKIT_QUADRILATERAL_DISK_INTERSECTION_HH
#define FRACKIT_QUADRILATERAL_DISK_INTERSECTION_HH
#include <cmath>
#include <frackit/precision/precision.hh>
#include <frackit/geometry/quadrilateral.hh>
#include <frackit/geometry/disk.hh>
#include "algo_planargeom_planargeom.hh"
namespace Frackit {
namespace IntersectionAlgorithms {
//! Intersect two disks
//! The result can be:
//! - a surface bounded by segments and/or elliptical arcs
//! - a segment
//! - a point
//! - no intersection
template<class ctype>
Intersection< Quadrilateral<ctype, 3>, Disk<ctype> >
intersect_quadrilateral_disk(const Quadrilateral<ctype, 3>& quad,
const Disk<ctype>& disk,
ctype eps)
{
using std::max;
ctype charLength = disk.majorAxisLength();
for (unsigned int edgeIdx = 0; edgeIdx < quad.numEdges(); ++edgeIdx)
charLength = max(charLength, quad.edge(edgeIdx).length());
return intersect_planargeometry_planargeometry(quad,
disk,
charLength,
eps,
Precision<ctype>::confusion(),
eps);
}
} // end namespace IntersectionAlgorithms
} // end namespace Frackit
#endif // FRACKIT_QUADRILATERAL_DISK_INTERSECTION_HH
......@@ -44,6 +44,7 @@
#include "algo_disk_line.hh"
#include "algo_quadrilateral_line.hh"
#include "algo_quadrilateral_quadrilateral.hh"
#include "algo_quadrilateral_disk.hh"
#include "algo_disk_disk.hh"
#include "algo_cylsurface_disk.hh"
#include "algo_shell_disk.hh"
......@@ -196,6 +197,28 @@ Intersection< Quadrilateral<ctype, 3>, Quadrilateral<ctype, 3> >
intersect(const Quadrilateral<ctype, 3>& quad1, const Quadrilateral<ctype, 3>& quad2, ctype eps)
{ return IntersectionAlgorithms::intersect_quadrilateral_quadrilateral(quad1, quad2, eps); }
/*!
* \brief Intersect a quadrilateral and a disk in 3d space.
* \param quad The quadrilateral
* \param disk The disk
* \param eps Tolerance to be used for floating point comparisons
*/
template<class ctype>
Intersection< Quadrilateral<ctype, 3>, Disk<ctype> >
intersect(const Quadrilateral<ctype, 3>& quad, const Disk<ctype>& disk, ctype eps)
{ return IntersectionAlgorithms::intersect_quadrilateral_disk(quad, disk, eps); }
/*!
* \brief Intersect a disk and a quadrilateral in 3d space.
* \param disk The disk
* \param quad The quadrilateral
* \param eps Tolerance to be used for floating point comparisons
*/
template<class ctype>
Intersection< Disk<ctype>, Quadrilateral<ctype, 3> >
intersect(const Disk<ctype>& disk, const Quadrilateral<ctype, 3>& quad, ctype eps)
{ return intersect(quad, disk, eps); }
/*!
* \brief Intersect a lateral cylinder surface and a disk.
* \param cylSurface The lateral cylinder surface
......
......@@ -150,6 +150,22 @@ struct IntersectionTraits< Quadrilateral<ctype, 3>, Quadrilateral<ctype, 3> >
EmptyIntersection<3> >;
};
//! Result type of the intersection of a quadrilateral and a disk in 3d space
template<class ctype>
struct IntersectionTraits< Quadrilateral<ctype, 3>, Disk<ctype> >
{
using type = std::variant< Point<ctype, 3>,
Segment<ctype, 3>,
TopoDS_Face,
EmptyIntersection<3> >;
};
//! Result type of the intersection of a disk and a quadrilateral in 3d space
template<class ctype>
struct IntersectionTraits< Disk<ctype>, Quadrilateral<ctype, 3> >
: public IntersectionTraits< Quadrilateral<ctype, 3>, Disk<ctype> >
{};
//! Result type of the intersection of a cylinder surface and a disk
template<class ctype>
struct IntersectionTraits< CylinderSurface<ctype>, Disk<ctype> >
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment