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

refactoring

parent ca594b45
No related branches found
No related tags found
No related merge requests found
...@@ -21,6 +21,7 @@ project(intersection) ...@@ -21,6 +21,7 @@ project(intersection)
add_executable( add_executable(
tests tests
tests/unit_tests/simple_triangle_tests.cpp tests/unit_tests/simple_triangle_tests.cpp
tests/unit_tests/contourize_tests.cpp
src/intersections/intersections.cpp src/intersections/intersections.cpp
src/shapes/triangle.cpp src/shapes/triangle.cpp
src/shapes/triangle_edges.cpp src/shapes/triangle_edges.cpp
...@@ -29,6 +30,7 @@ add_executable( ...@@ -29,6 +30,7 @@ add_executable(
src/orientation/orientation.cpp src/orientation/orientation.cpp
src/shapes/point.cpp src/shapes/point.cpp
src/union.cpp src/union.cpp
src/triangulation/triangulation.cpp
) )
include_directories(src) include_directories(src)
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#include "triangle_edges.h" #include "triangle_edges.h"
#include "edge.h" #include "edge.h"
bool Triangle::neighbours(Triangle &other) { bool Triangle::neighbours(const Triangle &other) const {
return false; return false;
} }
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
struct Triangle { struct Triangle {
Point points[3]; Point points[3];
int depth; int depth;
bool neighbours(Triangle &other); bool neighbours(const Triangle &other) const;
Triangle(Point p1, Point p2, Point p3, int depth); Triangle(Point p1, Point p2, Point p3, int depth);
bool pointInTriangle(const Point &p) const; bool pointInTriangle(const Point &p) const;
}; };
#include "triangulation.h" #include "triangulation.h"
std::vector<Triangle> triangulate(std::vector<Point> &points) { std::vector<Triangle> monotoneTriangulate(std::vector<Point> &points) {
} }
\ No newline at end of file
...@@ -4,4 +4,4 @@ ...@@ -4,4 +4,4 @@
struct Triangle; struct Triangle;
struct Point; struct Point;
std::vector<Triangle> triangulate(std::vector<Point> &points); std::vector<Triangle> monotoneTriangulate(std::vector<Point> &points);
\ No newline at end of file \ No newline at end of file
...@@ -4,8 +4,9 @@ ...@@ -4,8 +4,9 @@
#include <intersections/intersections.h> #include <intersections/intersections.h>
#include <contourize/contourize.h> #include <contourize/contourize.h>
#include <triangulation/triangulation.h> #include <triangulation/triangulation.h>
#include <union.h>
std::vector<Triangle> unionize(Triangle t1, Triangle t2) { std::vector<Triangle> unionize(const Triangle &t1, const Triangle &t2) {
// if neighbours, do nothing // if neighbours, do nothing
if (t1.neighbours(t2)) { if (t1.neighbours(t2)) {
...@@ -22,7 +23,7 @@ std::vector<Triangle> unionize(Triangle t1, Triangle t2) { ...@@ -22,7 +23,7 @@ std::vector<Triangle> unionize(Triangle t1, Triangle t2) {
std::vector<Point> contour = contourize(t1, t2, newIntersections); std::vector<Point> contour = contourize(t1, t2, newIntersections);
return triangulate(contour); return monotoneTriangulate(contour);
} }
void unionize(Triangle soup) { void unionize(Triangle soup) {
......
#pragma once
#include <vector>
std::vector<Triangle> unionize(const Triangle &t1, const Triangle &t2);
\ No newline at end of file
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include <union.h>
TEST (UnionTrivialTests, NotTouching) {
}
\ No newline at end of file
...@@ -3,13 +3,13 @@ ...@@ -3,13 +3,13 @@
#include <intersections/intersections.h> #include <intersections/intersections.h>
TEST(ContourizeTest, TwoTriangles) { TEST(ContourizeTest, TwoTriangles) {
auto t1 = Triangle(Point(0,0), Point(2,3), Point(5,0), 0); auto t1 = Triangle(Point(0,0), Point(5,0), Point(2,3), 0);
auto t2 = Triangle(Point(3,1), Point(4,3), Point(6,1), 0); auto t2 = Triangle(Point(3,1), Point(6,1), Point(4,3), 0);
auto newIntersections = intersections(t1, t2); auto newIntersections = intersections(t1, t2);
auto contour = contourize(t1, t2, newIntersections); auto contour = contourize(t1, t2, newIntersections);
//EXPECT_EQ(); EXPECT_TRUE(contour.size() > 0);
} }
\ No newline at end of file
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