Commit 1f1cd85c authored by Dennis Gläser's avatar Dennis Gläser
Browse files

[isection] add quadrilateral-cylindersurface algo

parent beb4804b
install(FILES
algo_cylsurface_disk.hh
algo_cylsurface_planargeom.hh
algo_cylsurface_quadrilateral.hh
algo_disk_disk.hh
algo_disk_line.hh
algo_face_disk.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 lateral cylinder surface and
* a quadrilateral in 3d space.
*/
#ifndef FRACKIT_CYLINDERSURFACE_QUADRILATERAL_INTERSECTION_HH
#define FRACKIT_CYLINDERSURFACE_QUADRILATERAL_INTERSECTION_HH
#include <cmath>
#include <frackit/geometry/quadrilateral.hh>
#include <frackit/geometry/cylindersurface.hh>
#include "intersectiontraits.hh"
#include "algo_cylsurface_planargeom.hh"
namespace Frackit {
namespace IntersectionAlgorithms {
//! Intersect a lateral cylinder surface and a disk
//! The result can be:
//! - an ellipse
//! - ellipse arc(s)
//! - segment(s)
//! - touching points
template<class ctype>
Intersection< CylinderSurface<ctype>, Quadrilateral<ctype, 3> >
intersect_cylinderSurface_quadrilateral(const CylinderSurface<ctype>& cylSurface,
const Quadrilateral<ctype, 3>& quad,
ctype eps)
{
using std::max;
ctype charLength = 0.0;
for (unsigned int edgeIdx = 0; edgeIdx < quad.numEdges(); ++edgeIdx)
charLength = max(charLength, quad.edge(edgeIdx).length());
return intersect_cylinderSurface_planarGeometry(cylSurface, quad, charLength, eps);
}
} // end namespace IntersectionAlgorithms
} // end namespace Frackit
#endif // FRACKIT_CYLINDERSURFACE_QUADRILATERAL_INTERSECTION_HH
......@@ -47,6 +47,7 @@
#include "algo_quadrilateral_disk.hh"
#include "algo_disk_disk.hh"
#include "algo_cylsurface_disk.hh"
#include "algo_cylsurface_quadrilateral.hh"
#include "algo_shell_disk.hh"
#include "algo_face_disk.hh"
......@@ -241,6 +242,28 @@ Intersection< Disk<ctype>, CylinderSurface<ctype> >
intersect(const Disk<ctype>& disk, const CylinderSurface<ctype>& cylSurface, ctype eps)
{ return intersect(cylSurface, disk, eps); }
/*!
* \brief Intersect a lateral cylinder surface and a quadrilateral.
* \param cylSurface The lateral cylinder surface
* \param quad The quadrilateral
* \param eps Tolerance to be used for floating point comparisons
*/
template<class ctype>
Intersection< CylinderSurface<ctype>, Quadrilateral<ctype, 3> >
intersect(const CylinderSurface<ctype>& cylSurface, const Quadrilateral<ctype, 3>& quad, ctype eps)
{ return IntersectionAlgorithms::intersect_cylinderSurface_quadrilateral(cylSurface, quad, eps); }
/*!
* \brief Intersect a quadrilateral and a lateral cylinder surface.
* \param quad The quadrilateral
* \param cylSurface The lateral cylinder surface
* \param eps Tolerance to be used for floating point comparisons
*/
template<class ctype>
Intersection< Quadrilateral<ctype, 3>, CylinderSurface<ctype> >
intersect(const Quadrilateral<ctype, 3>& quad, const CylinderSurface<ctype>& cylSurface, ctype eps)
{ return intersect(cylSurface, quad, eps); }
/*!
* \brief Intersect a disk and the boundary (TopoDS_Shell) of a solid.
* \param disk The disk
......
......@@ -189,6 +189,27 @@ struct IntersectionTraits< Disk<ctype>, CylinderSurface<ctype> >
: public IntersectionTraits< CylinderSurface<ctype>, Disk<ctype> >
{};
//! Result type of the intersection of a cylinder surface and a quadrilateral
template<class ctype>
struct IntersectionTraits< CylinderSurface<ctype>, Quadrilateral<ctype, 3> >
{
static constexpr int wd = CylinderSurface<ctype>::worldDimension();
static_assert(wd == 3, "World dimension of 3 expected");
using BaseType = std::variant< Point<ctype, 3>,
Segment<ctype, 3>,
EllipseArc<ctype, 3>,
Ellipse<ctype, 3>,
EmptyIntersection<3> >;
using type = std::vector<BaseType>;
};
//! Result type of the intersection of a quadrilateral and a cylinder surface
template<class ctype>
struct IntersectionTraits< Quadrilateral<ctype, 3>, CylinderSurface<ctype> >
: public IntersectionTraits< CylinderSurface<ctype>, Quadrilateral<ctype, 3> >
{};
//! Result type of the intersection of a shell and a disk
template<class ctype>
struct IntersectionTraits< TopoDS_Shell, 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