Throw an exception instead of assert(false) for repeat points

This commit is contained in:
Jan Niklas Hasse 2018-02-28 17:34:54 +01:00
parent 76b3b53bc6
commit f0a16419c5
4 changed files with 14 additions and 8 deletions

View File

@ -29,6 +29,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "shapes.h"
#include <cassert>
#include <iostream>
namespace p2t {
@ -362,4 +364,4 @@ void Triangle::DebugPrint()
cout << points_[2]->x << "," << points_[2]->y << endl;
}
}
}

View File

@ -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 {
@ -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");
}
}
@ -320,4 +320,4 @@ inline void Triangle::IsInterior(bool b)
}
#endif
#endif

View File

@ -30,6 +30,8 @@
*/
#include "advancing_front.h"
#include <cassert>
namespace p2t {
AdvancingFront::AdvancingFront(Node& head, Node& tail)
@ -105,4 +107,4 @@ AdvancingFront::~AdvancingFront()
{
}
}
}

View File

@ -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