Skip to content

Commit

Permalink
Throw an exception instead of assert(false) for repeat points
Browse files Browse the repository at this point in the history
  • Loading branch information
jhasse committed Feb 28, 2018
1 parent 76b3b53 commit f0a1641
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
4 changes: 3 additions & 1 deletion poly2tri/common/shapes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "shapes.h"

#include <cassert>
#include <iostream>

namespace p2t {
Expand Down Expand Up @@ -362,4 +364,4 @@ void Triangle::DebugPrint()
cout << points_[2]->x << "," << points_[2]->y << endl;
}

}
}
10 changes: 5 additions & 5 deletions poly2tri/common/shapes.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
#ifndef SHAPES_H
#define SHAPES_H

#include <vector>
#include <cstddef>
#include <assert.h>
#include <cmath>
#include <cstddef>
#include <stdexcept>
#include <vector>

namespace p2t {

Expand Down Expand Up @@ -136,7 +136,7 @@ struct Edge {
p = &p2;
} else if (p1.x == p2.x) {
// Repeat points
assert(false);
throw std::runtime_error("Edge::Edge: p1 == p2");
}
}

Expand Down Expand Up @@ -320,4 +320,4 @@ inline void Triangle::IsInterior(bool b)

}

#endif
#endif
4 changes: 3 additions & 1 deletion poly2tri/sweep/advancing_front.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
*/
#include "advancing_front.h"

#include <cassert>

namespace p2t {

AdvancingFront::AdvancingFront(Node& head, Node& tail)
Expand Down Expand Up @@ -105,4 +107,4 @@ AdvancingFront::~AdvancingFront()
{
}

}
}
4 changes: 3 additions & 1 deletion poly2tri/sweep/sweep.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdexcept>
#include "sweep.h"
#include "sweep_context.h"
#include "advancing_front.h"
#include "../common/utils.h"

#include <cassert>
#include <stdexcept>

namespace p2t {

// Triangulate simple polygon with holes
Expand Down

0 comments on commit f0a1641

Please sign in to comment.