Skip to content
Snippets Groups Projects
Commit eec91116 authored by Brandon Lai-Cheong's avatar Brandon Lai-Cheong
Browse files

sync

parent 80b87784
No related branches found
No related tags found
No related merge requests found
#include <vector>
#include <union.h>
#include <contourize.h>
#include <triangle.h>
#include <constants.h>
#include <list>
#include <triangle_edges.h>
#include <intersections.h>
#include <contourize.h>
#include <convex_triangulation.h>
std::vector<Point> getPointsOnSide(const Edge &e, const std::vector<Point> intr, const Triangle &bottom)
{
std::vector<Point> result;
for (int i = 0; i < NB_TRIANGLE_SIDES; i++)
{
if (e.positiveSide(bottom.points[i]))
{
result.push_back(bottom.points[i]);
}
}
for (const auto &p : intr)
{
if (e.positiveSide(p))
{
result.push_back(p);
}
}
return result;
}
std::vector<Triangle> unionizeTopAndBottom(const Triangle &top, const Triangle &bot) {
std::vector<Triangle> result;
std::vector<Triangle> unionizeTopAndBottom(const Triangle &top, const Triangle &bottom)
{
std::list<Point> intr;
TriangleEdges topEdges = TriangleEdges(top);
std::vector<Triangle> result;
TriangleEdges topEdges = TriangleEdges(top);
TriangleEdges botEdges = TriangleEdges(bottom);
// keep track of relevant triangles
for (int i = 0; i < NB_TRIANGLE_SIDES; i++) {
const Edge &e = topEdges.edges[i];
auto newIntr = intersections(e, bot);
// split triangle if exists
// currently relevant triangles
// add these to result
// future relevant triangles
// use to
std::vector<Point> intrPoints;
// filter using previous edges
for (int i = 0; i < NB_TRIANGLE_SIDES; i++)
{
for (int j = 0; j < NB_TRIANGLE_SIDES; j++)
{
auto cand = intersectionWithinEdgeDirection(topEdges.edges[i], botEdges.edges[j]);
if (cand.has_value())
{
intrPoints.push_back(cand.value());
}
}
}
for (int i = 0; i < NB_TRIANGLE_SIDES; i++)
{
std::vector<Point> currentShape = getPointsOnSide(topEdges.edges[i], intrPoints, bottom);
if (currentShape.empty()) {
continue;
// create shape if points exists
contourize();
}
std::vector<Point> orderedPoints = contourize(currentShape);
std::vector<Triangle> newTriangles = convexTriangulation(orderedPoints, bottom.depth, bottom.id);
result.insert(result.begin(), newTriangles.begin(), newTriangles.end());
}
// add top triangle
result.push_back(top);
return result;
}
return result;
std::vector<Triangle> unionize(const Triangle &t1, const Triangle &t2)
{
if (intersections(t1, t2).empty())
{
return {t1, t2};
}
if (t1.depth < t2.depth)
{
return unionizeTopAndBottom(t1, t2);
}
return unionizeTopAndBottom(t2, t1);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment