Commit 99b9845b authored by Dennis Gläser's avatar Dennis Gläser
Browse files

[intersect] add quad-quad algorithm

parent ec9e407b
......@@ -9,6 +9,7 @@ algo_planargeom_planargeom.hh
algo_plane_line.hh
algo_plane_plane.hh
algo_quadrilateral_line.hh
algo_quadrilateral_quadrilateral.hh
algo_segment_segment.hh
algo_shell_disk.hh
emptyintersection.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 two quadrilaterals.
*/
#ifndef FRACKIT_QUADRILATERAL_QUADRILATERAL_INTERSECTION_HH
#define FRACKIT_QUADRILATERAL_QUADRILATERAL_INTERSECTION_HH
#include <cmath>
#include <frackit/precision/precision.hh>
#include <frackit/geometry/quadrilateral.hh>
#include "algo_planargeom_planargeom.hh"
namespace Frackit {
namespace IntersectionAlgorithms {
//! Intersect two quadrilaterals in 3d space
//! The result can be:
//! - a polygon bounded by segments
//! - a segment
//! - a point
//! - no intersection
template<class ctype>
Intersection< Quadrilateral<ctype, 3>, Quadrilateral<ctype, 3> >
intersect_quadrilateral_quadrilateral(const Quadrilateral<ctype, 3>& quad1,
const Quadrilateral<ctype, 3>& quad2,
ctype eps)
{
using std::max;
ctype charLength = 0.0;
for (unsigned int edgeIdx = 0; edgeIdx < quad1.numEdges(); ++edgeIdx)
charLength = max(charLength, quad1.edge(edgeIdx).length());
for (unsigned int edgeIdx = 0; edgeIdx < quad2.numEdges(); ++edgeIdx)
charLength = max(charLength, quad2.edge(edgeIdx).length());
return intersect_planargeometry_planargeometry(quad1,
quad2,
charLength,
eps,
eps,
eps);
}
} // end namespace IntersectionAlgorithms
} // end namespace Frackit
#endif // FRACKIT_QUADRILATERAL_QUADRILATERAL_INTERSECTION_HH
......@@ -43,6 +43,7 @@
#include "algo_plane_line.hh"
#include "algo_disk_line.hh"
#include "algo_quadrilateral_line.hh"
#include "algo_quadrilateral_quadrilateral.hh"
#include "algo_disk_disk.hh"
#include "algo_cylsurface_disk.hh"
#include "algo_shell_disk.hh"
......@@ -172,6 +173,7 @@ template<class ctype>
Intersection< Line<ctype, 3>, Quadrilateral<ctype, 3>>
intersect(const Line<ctype, 3>& line, const Quadrilateral<ctype, 3>& quad, ctype eps)
{ return intersect(quad, line, eps); }
/*!
* \brief Intersect two disks.
* \param disk1 The first disk
......@@ -180,11 +182,20 @@ intersect(const Line<ctype, 3>& line, const Quadrilateral<ctype, 3>& quad, ctype
*/
template<class ctype>
Intersection< Disk<ctype>, Disk<ctype> >
intersect(const Disk<ctype>& disk1,
const Disk<ctype>& disk2,
ctype eps)
intersect(const Disk<ctype>& disk1, const Disk<ctype>& disk2, ctype eps)
{ return IntersectionAlgorithms::intersect_disk_disk(disk1, disk2, eps); }
/*!
* \brief Intersect two quadrilaterals in 3d space.
* \param quad1 The first quadrilateral
* \param quad2 The second quadrilateral
* \param eps Tolerance to be used for floating point comparisons
*/
template<class ctype>
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 lateral cylinder surface and a disk.
* \param cylSurface The lateral cylinder surface
......
......@@ -136,10 +136,20 @@ struct IntersectionTraits< Disk<ctype>, Disk<ctype> >
using type = std::variant< Point<ctype, wd>,
Segment<ctype, wd>,
Disk<ctype>,
Disk<ctype>, // TODO: Substitute by TopoDS_Face or polygon when supported?
EmptyIntersection<wd> >;
};
//! Result type of the intersection of two quadrilaterals in 3d space
template<class ctype>
struct IntersectionTraits< Quadrilateral<ctype, 3>, Quadrilateral<ctype, 3> >
{
using type = std::variant< Point<ctype, 3>,
Segment<ctype, 3>,
Quadrilateral<ctype, 3>, // TODO: Substitute by TopoDS_Face or polygon when supported?
EmptyIntersection<3> >;
};
//! 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