39 using MeshD<2>::LocalCoords;
58 : triangleNodes(triangleNodes), mesh(mesh) {}
67 return triangleNodes[index];
76 return mesh.
nodes[getNodeIndex(index)];
84 return { getNode(0), getNode(1), getNode(2) };
92 return (getNode(0)+getNode(1)+getNode(2)) / 3.0;
104 return abs( (A.c0 - C.c0) * (B.c1 - A.c1)
105 - (A.c0 - B.c0) * (C.c1 - A.c1) ) / 2.0;
121 auto b = barycentric(p);
122 return b.c0 >= 0 &&
b.c1 >= 0 &&
b.c2 >= 0;
129 Box2D getBoundingBox()
const;
174 return Element(*
this, elementNodes[elementIndex]);
178 return Element(*
this, elementNodes[elementIndex]);
186 return elementNodes.size();
211 explicit Builder(
TriangularMesh2D& mesh, std::size_t predicted_number_of_elements, std::size_t predicted_number_of_nodes);
222 :
Builder(mesh, predicted_number_of_elements, predicted_number_of_elements*3) {}
232 Builder&
add(LocalCoords p1, LocalCoords p2, LocalCoords p3);
246 Builder&
add(
const std::array<LocalCoords, 3>& points) {
return add(points[0], points[1], points[2]); }
270 typedef boost::geometry::model::box<Vec<2>>
Box;
272 typedef boost::geometry::index::rtree<
273 std::pair<Box, std::size_t>,
274 boost::geometry::index::quadratic<16>
283 static constexpr std::size_t INDEX_NOT_FOUND = std::numeric_limits<std::size_t>::max();
302 assert(index < nodes.size());
306 std::size_t
size()
const override {
311 return nodes.empty();
359 void writeXML(
XMLElement&
object)
const override;
371 template <
typename Predicate>
377 typedef std::pair<std::size_t, std::size_t>
Segment;
380 typedef std::unordered_map<TriangularMesh2D::Segment, std::size_t, boost::hash<Segment>>
SegmentsCounts;
422 static std::set<std::size_t> allBoundaryNodes(
const SegmentsCounts& segmentsCount);
424 template <
typename T>
425 struct greater:
public std::function<bool(T, T)> {
426 bool operator()(
const T& first,
const T& second)
const {
return second < first; }
437 template<
int SEG_DIR,
template<
class>
class Compare>
438 std::set<std::size_t> dirBoundaryNodes(
const SegmentsCounts& segmentsCount)
const;
440 enum class BoundaryDir { LEFT, RIGHT, BOTTOM, TOP, ALL };
442 template<BoundaryDir boundaryDir,
typename std::enable_if<boundaryDir != BoundaryDir::ALL &&
int(boundaryDir)%2==0,
int>::type = 0>
443 std::set<std::size_t> boundaryNodes(
const SegmentsCounts& segmentsCount)
const {
444 return dirBoundaryNodes<
int(
boundaryDir) / 2, greater>(segmentsCount);
447 template<BoundaryDir boundaryDir,
typename std::enable_if<boundaryDir != BoundaryDir::ALL &&
int(boundaryDir)%2==1,
int>::type = 0>
448 std::set<std::size_t> boundaryNodes(
const SegmentsCounts& segmentsCount)
const {
449 return dirBoundaryNodes<
int(
boundaryDir) / 2, std::less>(segmentsCount);
453 std::set<std::size_t> boundaryNodes(
const SegmentsCounts& segmentsCount)
const {
454 return allBoundaryNodes(segmentsCount);
491 static Boundary getBottomBoundary();
548 static Boundary getRightOfBoundary(
const std::vector<Box2D>&
boxes);
555 static Boundary getLeftOfBoundary(
const std::vector<Box2D>&
boxes);
562 static Boundary getTopOfBoundary(
const std::vector<Box2D>&
boxes);
569 static Boundary getBottomOfBoundary(
const std::vector<Box2D>&
boxes);
630 return path ? getAllBoundaryIn(
object, *path) : getAllBoundaryIn(
object);
648 return path ? getRightOfBoundary(
object, *path) : getRightOfBoundary(
object);
666 return path ? getLeftOfBoundary(
object, *path) : getLeftOfBoundary(
object);
684 return path ? getTopOfBoundary(
object, *path) : getTopOfBoundary(
object);
702 return path ? getBottomOfBoundary(
object, *path) : getBottomOfBoundary(
object);