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

Merge branch 'cleanup/constraints' into 'master'

Cleanup/constraints

See merge request DennisGlaeser/frackit!36
parents 1cf19ba4 84aa7eb2
......@@ -190,6 +190,29 @@ ctype computeDistanceToBoundary(const TopoDS_Shape& shape,
extAlgo);
}
/*!
* \brief Compute the distance of a shape
* to the bounding wire of a quadrilateral.
* \param shape The shape
* \param quad The quadrilateral
* \param deflection The epsilon used in the BrepExtrema command
* \param extFlag The flag passed to the BrepExtrema command (MIN/MAX/MINMAX)
* \param extAlgo The algorithm passed to the BrepExtrema command (TREE/GRAD)
*/
template<class ctype>
ctype computeDistanceToBoundary(const TopoDS_Shape& shape,
const Quadrilateral<ctype, 3>& quad,
ctype deflection = Precision<ctype>::confusion(),
Extrema_ExtFlag extFlag = Extrema_ExtFlag_MINMAX,
Extrema_ExtAlgo extAlgo = Extrema_ExtAlgo_Grad)
{
return computeDistance(shape,
OCCUtilities::getShape(quad),
deflection,
extFlag,
extAlgo);
}
/*!
* \brief Compute the distance of a geometry
* to the boundary of a TopoDS_Face.
......
......@@ -26,12 +26,9 @@
#include <variant>
#include <vector>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Solid.hxx>
#include <frackit/magnitude/magnitude.hh>
#include <frackit/intersection/emptyintersection.hh>
#include <frackit/common/extractdimension.hh>
namespace Frackit {
namespace ConstraintImpl {
......@@ -43,41 +40,13 @@ namespace ConstraintImpl {
bool isAdmissibleMagnitude(const Geo& isGeometry, ctype threshold)
{
// zero dimensional (point) intersections fulfill any magnitude constraint
if (Geo::myDimension() == 0) return true;
if (getDimension(isGeometry) == 0) return true;
// empty intersections fulfill any magnitude constraint
if (IsEmptyIntersection<Geo>::value) return true;
// any other intersection geometry
return computeMagnitude(isGeometry) >= threshold;
}
/*!
* \brief Evaluates if the magnitude of a vertex shape is above a given threshold.
*/
template<class ctype>
bool isAdmissibleMagnitude(const TopoDS_Vertex& isVertex, ctype threshold)
{ return true; }
/*!
* \brief Evaluates if the magnitude of an edge is above a given threshold.
*/
template<class ctype>
bool isAdmissibleMagnitude(const TopoDS_Edge& isEdge, ctype threshold)
{ return computeMagnitude(isEdge) >= threshold; }
/*!
* \brief Evaluates if the magnitude of a face is above a given threshold.
*/
template<class ctype>
bool isAdmissibleMagnitude(const TopoDS_Face& isFace, ctype threshold)
{ return computeMagnitude(isFace) >= threshold; }
/*!
* \brief Evaluates if the magnitude of a solid is above a given threshold.
*/
template<class ctype>
bool isAdmissibleMagnitude(const TopoDS_Solid& isSolid, ctype threshold)
{ return computeMagnitude(isSolid) >= threshold; }
/*!
* \brief Overload for an std::variant
*/
......
......@@ -139,33 +139,9 @@ namespace ConstraintImpl {
/*!
* \brief Overload for edge intersections on disks.
*/
template<class ctype, class ctype2>
template<class Entity, class ctype>
bool isAdmissibleDistanceToBoundary(const TopoDS_Edge& edge,
const Disk<ctype>& entity,
ctype2 threshold)
{
const auto p1 = OCCUtilities::point( TopExp::FirstVertex(edge) );
const auto p2 = OCCUtilities::point( TopExp::LastVertex(edge) );
if (!isAdmissibleDistanceToBoundary(p1, entity, threshold))
return false;
return isAdmissibleDistanceToBoundary(p2, entity, threshold);
}
/*!
* \brief Overload for face intersections on disks.
*/
template<class ctype, class ctype2>
bool isAdmissibleDistanceToBoundary(const TopoDS_Face& face,
const Disk<ctype>& entity,
ctype2 threshold)
{ throw std::runtime_error("NotImplemented: face-entity boundary distance"); }
/*!
* \brief Overload for edge intersections on faces.
*/
template<class ctype>
bool isAdmissibleDistanceToBoundary(const TopoDS_Edge& edge,
const TopoDS_Face& entity,
const Entity& entity,
ctype threshold)
{
const auto p1 = OCCUtilities::point( TopExp::FirstVertex(edge) );
......@@ -176,11 +152,11 @@ namespace ConstraintImpl {
}
/*!
* \brief Overload for face intersections on faces.
* \brief Overload for face intersections on disks.
*/
template<class ctype>
template<class Entity, class ctype>
bool isAdmissibleDistanceToBoundary(const TopoDS_Face& face,
const TopoDS_Face& entity,
const Entity& entity,
ctype threshold)
{ throw std::runtime_error("NotImplemented: face-entity boundary distance"); }
......
......@@ -316,13 +316,14 @@ public:
{ return (*this)(geo, cylSurface, isEllipse); }
/*!
* \brief Returns the angle in which a disk
* \brief Returns the angle in which a planar 2d geometry
* and a face shape touch in a point.
* \param disk The disk
* \param geo The planar geometry
* \param face The face shape
* \param isPoint The touching point
*/
ctype operator() (const Disk<ctype>& disk,
template<class Geo, std::enable_if_t<IsPlanarGeometry<Geo>::value, int> = 0>
ctype operator() (const Geo& geo,
const TopoDS_Face& face,
const Point<ctype, 3>& isPoint)
{
......@@ -345,29 +346,31 @@ public:
const auto base2 = OCCUtilities::vector(baseVec2);
const Direction<ctype, 3> normal(crossProduct(base1, base2));
const Plane<ctype, 3> tangentPlane(isPoint, normal);
return (*this)(disk.supportingPlane(), tangentPlane);
return (*this)(geo.supportingPlane(), tangentPlane);
}
/*!
* \brief Returns the angle in which a face shape
* and a disk intersect in a point.
* and a planar 2d geometry intersect in a point.
* \param face The face shape
* \param disk The disk
* \param geo The planar geometry
* \param isPoint The touching point
*/
template<class Geo, std::enable_if_t<IsPlanarGeometry<Geo>::value, int> = 0>
ctype operator() (const TopoDS_Face& face,
const Disk<ctype>& disk,
const Geo& geo,
const Point<ctype, 3>& isPoint)
{ return (*this)(disk, face, isPoint); }
{ return (*this)(geo, face, isPoint); }
/*!
* \brief Returns the angle in which a disk
* \brief Returns the angle in which a planar 2d geometry
* and a face shape intersect in an edge.
* \param disk The disk
* \param geo The planar geometry
* \param face The face shape
* \param isEdge The intersection edge
*/
ctype operator() (const Disk<ctype>& disk,
template<class Geo, std::enable_if_t<IsPlanarGeometry<Geo>::value, int> = 0>
ctype operator() (const Geo& geo,
const TopoDS_Face& face,
const TopoDS_Edge& isEdge)
{
......@@ -383,7 +386,7 @@ public:
{
const auto param = edgeHandle->FirstParameter() + f*deltaParam;
const auto isPoint = OCCUtilities::point(edgeHandle->Value(param));
resultAngle = min(resultAngle, (*this)(disk, face, isPoint));
resultAngle = min(resultAngle, (*this)(geo, face, isPoint));
}
return resultAngle;
......@@ -391,39 +394,42 @@ public:
/*!
* \brief Returns the angle in which a face shape
* and a disk intersect in an edge.
* and a planar 2d geometry intersect in an edge.
* \param face The face shape
* \param disk The disk
* \param geo The planar geometry
* \param isEdge The intersection edge
*/
template<class Geo, std::enable_if_t<IsPlanarGeometry<Geo>::value, int> = 0>
ctype operator() (const TopoDS_Face& face,
const Disk<ctype>& disk,
const Geo& geo,
const TopoDS_Edge& isEdge)
{ return (*this)(disk, face, isEdge); }
{ return (*this)(geo, face, isEdge); }
/*!
* \brief Returns the angle in which a disk intersects
* a face shape in a face.
* \param disk The disk
* \brief Returns the angle in which a planar 2d geometry
* intersects a face shape in a face.
* \param geo The planar geometry
* \param face The face shape
* \param isFace The intersection face
*/
ctype operator() (const Disk<ctype>& disk,
template<class Geo, std::enable_if_t<IsPlanarGeometry<Geo>::value, int> = 0>
ctype operator() (const Geo& geo,
const TopoDS_Face& face,
const TopoDS_Face& isFace)
{ return 0.0; }
/*!
* \brief Returns the angle in which a face shape
* intersects a disk in a face.
* intersects a planar 2d geometry in a face.
* \param face The face shape
* \param disk The disk
* \param geo The planar geometry
* \param isFace The intersection face
*/
template<class Geo, std::enable_if_t<IsPlanarGeometry<Geo>::value, int> = 0>
ctype operator() (const TopoDS_Face& face,
const Disk<ctype>& disk,
const Geo& geo,
const TopoDS_Face& isFace)
{ return (*this)(disk, face, isFace); }
{ return (*this)(geo, face, isFace); }
/*!
* \brief Overload for an intersection variant
......
......@@ -5,6 +5,7 @@
#include <frackit/geometry/quadrilateral.hh>
#include <frackit/geometry/cylinder.hh>
#include <frackit/entitynetwork/constraints.hh>
#include <frackit/occ/breputilities.hh>
//! test the constraints for entity networks of quadrilaterals
int main()
......@@ -105,6 +106,17 @@ int main()
throw std::runtime_error("False positive intersection distance violation");
std::cout << "Test 8 passed" << std::endl;
// test the two above also with a shape representation of the main quad
{
if (constraints.evaluate(mainQuad, Frackit::OCCUtilities::getShape(quad7)))
throw std::runtime_error("Did not detect intersection distance violation");
std::cout << "Test 7 (with shape) passed" << std::endl;
if (!constraints.evaluate(mainQuad, Frackit::OCCUtilities::getShape(quad8)))
throw std::runtime_error("False positive intersection distance violation");
std::cout << "Test 8 (with shape) passed" << std::endl;
}
// intersection angle just ok
Quad quad9(Point(-0.5, -0.5, -0.5 - 1e-3),
Point( 0.5, -0.5, -0.5 - 1e-3),
......
Markdown is supported
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