Branch data Line data Source code
1 : : /*
2 : : * AF2FreeZone.hpp
3 : : *
4 : : * A region of 2-dimensional space, supposed to be convex, defined by
5 : : * the points of which the region is supposed to be the convex hull,
6 : : * listed in a counter-clockwise order around the region. This region
7 : : * can be checked (1) to verify that the points defining it are, indeed,
8 : : * all on the convex hull of the region, (2) to see whether it contains
9 : : * other points, and (3) to see whether it intersects an edge defined
10 : : * by its two endpoints.
11 : : *
12 : : * Within an advancing front algorithm, a free zone may be used to
13 : : * determine whether insertion of vertices and edges can be accomplished
14 : : * without forcing inverted or poor quality elements to appear in the mesh.
15 : : */
16 : : #ifndef AF2FREEZONE_HPP
17 : : #define AF2FREEZONE_HPP
18 : :
19 : : // C++
20 : : #include <list>
21 : :
22 : : // MeshKit
23 : : #include "meshkit/AF2Point2D.hpp"
24 : :
25 : 44756 : class AF2FreeZone
26 : : {
27 : : private:
28 : :
29 : : // the vertices on the convex hull of the free zone,
30 : : // in counterclockwise order
31 : : std::list<AF2Point2D> vertices;
32 : :
33 : : // the bounding box of the free zone
34 : : double minX;
35 : : double maxX;
36 : : double minY;
37 : : double maxY;
38 : :
39 : : // approximate scale of the coordinates that define the free zone
40 : : double scale;
41 : :
42 : : /**
43 : : * \brief Check whether two points are equal or nearly equal
44 : : *
45 : : * Near equality is measured relative to the scale of the free zone.
46 : : *
47 : : * \param pointAlpha one of the two points to test
48 : : * \param pointBravo the other of the two points to test
49 : : * \return true if the points are equal or nearly equal, false otherwise
50 : : */
51 : : bool nearEqual(AF2Point2D const & pointAlpha,
52 : : AF2Point2D const & pointBravo) const;
53 : :
54 : : public:
55 : :
56 : : /**
57 : : * \brief Constructor
58 : : */
59 : : AF2FreeZone(std::list<AF2Point2D> const& bndryPoints);
60 : :
61 : : /**
62 : : * \brief Check whether the free zone contains (or nearly contains)
63 : : * a specified point
64 : : *
65 : : * \param point the point to check
66 : : * \param containsBndry if false, the method treats query points that
67 : : * are nearly equal to a free zone boundary point as not contained,
68 : : * even if they are actually mathematically on or in the free zone
69 : : * \return true if the free zone contains the point or nearly
70 : : * contains the point, false otherwise
71 : : */
72 : : bool nearContains(AF2Point2D const & testPnt,
73 : : bool const & containsBndry = false) const;
74 : :
75 : : /**
76 : : * \brief Check whether the free zone intersects (or nearly intersects)
77 : : * a line segment given the two endpoints of the line segment
78 : : *
79 : : * \param startPoint one endpoint of the line segment
80 : : * \param endPoint the other endpoint of the line segment
81 : : * \param containsBndry if false, the method treats query line segments
82 : : * that are nearly equal to free zone boundary line segments as not
83 : : * intersecting, even if they actually mathematically do intersect
84 : : * the free zone or lie on its boundary. This applies only if the
85 : : * query line segment is nearly equal to the full boundary line
86 : : * segment, i.e., if each endpoint of the query line segment
87 : : * is nearly equal to one of a pair of consective free zone
88 : : * boundary points. Also, if false, a query line segment
89 : : * that has one endpoint that is nearly equal to a free
90 : : * zone boundary point will be treated as nonintersecting if
91 : : * the only intersection or near intersection is in the
92 : : * neighborhood of that free zone boundary point.
93 : : * \return true if the free zone intersects or nearly intersects the
94 : : * line segment, false otherwise
95 : : */
96 : : bool nearIntersects(AF2Point2D const & startPoint,
97 : : AF2Point2D const & endPoint, bool const & containsBndry = false) const;
98 : :
99 : : /**
100 : : * \brief Verify that the free zone is convex, and that the
101 : : * boundary points are given in a counter-clockwise ordering.
102 : : *
103 : : * If the free zone is not actually convex or the boundary points
104 : : * were not given in a counter-clockwise ordering, the behavior
105 : : * of other methods in this class is not defined.
106 : : *
107 : : * \return true if the free zone is convex, false otherwise
108 : : */
109 : : bool isConvex() const;
110 : : };
111 : :
112 : : #endif
|