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

[constraints] allow for exchangeable angle computation engine

parent b5ad445c
......@@ -42,6 +42,21 @@
namespace Frackit {
/*!
* \brief Forward declaration of the constraints class.
*/
template<class ST = double,
class AE = IntersectionAngle<ST> >
class EntityNetworkConstraints;
/*!
* \brief Convenience function to construct an instance
* of the constraints class using the default engines
*/
template<class ST = double>
EntityNetworkConstraints<ST> makeDefaultConstraints()
{ return EntityNetworkConstraints<ST>(IntersectionAngle<ST>()); }
/*!
* \brief Class which defines and checks constraints on
* the geometric relationships between entities of
......@@ -57,10 +72,12 @@ namespace Frackit {
* zero distance. However, this case is admissible, only small features
* related to the non-intersecting boundaries are of interest here.
* \tparam ST The type used for the scalar constraint values
* \tparam AE The engine used for angle computations between intersecting geometries
* \tparam AE The engine used for angle computations between intersecting geometries.
* This engine is required to return the angle between geometries when
* the operator() is called with the two geometries and the intersection
* result as arguments.
*/
template<class ST = double,
class AE = IntersectionAngle<ST> >
template<class ST, class AE>
class EntityNetworkConstraints
{
......@@ -72,10 +89,12 @@ public:
using AngleComputationEngine = AE;
/*!
* \brief Default constructor, deactivates all constraints.
* \brief The constructor.
* \param angleEngine An instance of the engine used for angle computations.
*/
EntityNetworkConstraints()
: minDistance_(), minIsAngle_()
EntityNetworkConstraints(const AngleComputationEngine& angleEngine)
: angleEngine_(angleEngine)
, minDistance_(), minIsAngle_()
, minIsMagnitude_(), minIsDistance_()
, useMinDistance_(false), useMinIsAngle_(false)
, useMinIsMagnitude_(false), useMinIsDistance_(false)
......@@ -85,28 +104,6 @@ public:
allowEquiDimIS_ = false;
}
/*!
* \brief The constructor defining all constraints
* \param minDistance Minimum distance allowed between two (non-intersecting) entities
* \param minIsAngle Minimum angle in which two entities are allowed to intersect
* \param minIsMagnitude Minimum magnitude of intersection allowed
* \param minIsDistance Minimum distance of an intersection to intersecting entity boundaries
* \note The default epsilon is set to be used for intersection computations
*/
EntityNetworkConstraints(Scalar minDistance,
Scalar minIsAngle,
Scalar minIsMagnitude,
Scalar minIsDistance)
: minDistance_(minDistance), minIsAngle_(minIsAngle)
, minIsMagnitude_(minIsMagnitude), minIsDistance_(minIsDistance)
, useMinDistance_(false), useMinIsAngle_(false)
, useMinIsMagnitude_(false), useMinIsDistance_(false)
, intersectionEps_(), useIntersectionEps_(false)
{
// per default, we do not allow equi-dimensional intersections
allowEquiDimIS_ = false;
}
//! Set the constraint for the minimum distance between entities
void setMinDistance(Scalar minDistance)
{
......@@ -164,6 +161,13 @@ public:
void allowEquiDimensionalIntersections(bool value)
{ allowEquiDimIS_ = value; }
/*!
* \brief Set the engine used for angle computations
* \param angleEngine An instance of the engine
*/
void setAngleComputationEngine(const AngleComputationEngine& angleEngine)
{ angleEngine_ = angleEngine; }
/*!
* \brief Check if a pair of geometries fulfills the constraints
* \param geo1 The first geometry
......@@ -233,6 +237,8 @@ public:
}
private:
AngleComputationEngine angleEngine_; //! Algorithms to compute angles between intersecting geometries
Scalar minDistance_; //!< Minimum distance allowed between two entities
Scalar minIsAngle_; //!< Minimum angle in which two entities are allowed to intersect
Scalar minIsMagnitude_; //!< Minimum magnitude of the intersection geometry
......@@ -248,7 +254,6 @@ private:
Scalar intersectionEps_; //! Tolerance value to be used for intersections
bool useIntersectionEps_; //! Stores wether or not a user-defined epsilon value was set
AngleComputationEngine angleEngine_; //! Algorithms to compute angles between intersecting geometries
};
} // end namespace Frackit
......
......@@ -23,7 +23,7 @@ int main()
const Vector e3(0.0, 0.0, 1.0);
// Define constraints
Frackit::EntityNetworkConstraints<ctype> constraints;
auto constraints = Frackit::makeDefaultConstraints<ctype>();
constraints.setMinDistance(0.1);
constraints.setMinIntersectingAngle(M_PI/4.0);
constraints.setMinIntersectionMagnitude(0.05);
......
......@@ -22,7 +22,7 @@ int main()
const Vector e3(0.0, 0.0, 1.0);
// Define constraints
Frackit::EntityNetworkConstraints<ctype> constraints;
auto constraints = Frackit::makeDefaultConstraints<ctype>();
constraints.setMinDistance(0.1);
constraints.setMinIntersectingAngle(M_PI/4.0);
constraints.setMinIntersectionMagnitude(0.05);
......
......@@ -54,9 +54,9 @@ int main()
std::vector<Disk> diskSet2;
//! enforce some constraints on the network
Frackit::EntityNetworkConstraints<ctype> constraintsOnSelf;
Frackit::EntityNetworkConstraints<ctype> constraintsOnOther;
Frackit::EntityNetworkConstraints<ctype> constraintsOnDomain;
auto constraintsOnSelf = makeDefaultConstraints<ctype>();
auto constraintsOnOther = makeDefaultConstraints<ctype>();
auto constraintsOnDomain = makeDefaultConstraints<ctype>();
// constraints among disks of the same set
constraintsOnSelf.setMinDistance(0.1);
......
......@@ -76,9 +76,9 @@ int main(int argc, char** argv)
std::vector<Disk> diskSet2;
//! enforce some constraints on the network
Frackit::EntityNetworkConstraints<ctype> constraintsOnSelf;
Frackit::EntityNetworkConstraints<ctype> constraintsOnOther;
Frackit::EntityNetworkConstraints<ctype> constraintsOnDomain;
auto constraintsOnSelf = makeDefaultConstraints<ctype>();
auto constraintsOnOther = makeDefaultConstraints<ctype>();
auto constraintsOnDomain = makeDefaultConstraints<ctype>();
// constraints among disks of the same set
constraintsOnSelf.setMinDistance(10.0);
......
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