1
0
mirror of git://projects.qi-hardware.com/cae-tools.git synced 2024-12-22 23:51:08 +02:00

poly2d (p2d_is_cw, p2d_is_closed, p2d_no_intersect, p2d_vertices): use better types

There's more to the world than just "int" ...
This commit is contained in:
Werner Almesberger 2015-01-10 21:16:47 -03:00
parent b2d6ef5f3c
commit cba417fc37
3 changed files with 17 additions and 14 deletions

View File

@ -1,8 +1,8 @@
/*
* cgal_helper.h - Conversions between poly2d and CGAL
*
* Written 2012 by Werner Almesberger
* Copyright 2012 by Werner Almesberger
* Written 2012, 2015 by Werner Almesberger
* Copyright 2012, 2015 by Werner Almesberger
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -21,6 +21,8 @@
*/
extern "C" {
#include <stdbool.h>
#include "poly2d.h"
}
@ -35,7 +37,7 @@ typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Polygon_2<K> Polygon_2;
static inline Polygon_2 p2d_to_P2(const struct p2d *p, int ccw)
static inline Polygon_2 p2d_to_P2(const struct p2d *p, bool ccw)
{
const struct v2d *v;
Polygon_2 np;

View File

@ -1,8 +1,8 @@
/*
* p2d_attrib.c - Determine various polygon attributes
*
* Written 2012 by Werner Almesberger
* Copyright 2012 Werner Almesberger
* Written 2012, 2015 by Werner Almesberger
* Copyright 2012, 2015 Werner Almesberger
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -11,6 +11,7 @@
*/
#include <stdbool.h>
#include <math.h>
#include <assert.h>
@ -46,7 +47,7 @@ static double angle_3(const struct v2d *a, const struct v2d *b,
* If we predominantly turn to the right, then the path must be clockwise.
*/
int p2d_is_cw(const struct p2d *p)
bool p2d_is_cw(const struct p2d *p)
{
const struct v2d *v;
double a = 0;
@ -65,7 +66,7 @@ int p2d_is_cw(const struct p2d *p)
}
int p2d_is_closed(const struct p2d *p)
bool p2d_is_closed(const struct p2d *p)
{
return p->v == p->last || p->last->next;
}
@ -76,7 +77,7 @@ int p2d_is_closed(const struct p2d *p)
* go unnoticed.
*/
int p2d_no_intersect(const struct p2d *p)
bool p2d_no_intersect(const struct p2d *p)
{
const struct v2d *v, *u;
@ -106,10 +107,10 @@ int p2d_no_intersect(const struct p2d *p)
}
int p2d_vertices(const struct p2d *p)
unsigned p2d_vertices(const struct p2d *p)
{
const struct v2d *v;
int n = 0;
unsigned n = 0;
v = p->v;
while (v) {

View File

@ -121,10 +121,10 @@ struct p2d *p2d_reverse(const struct p2d *p);
* p2d_vertices counts the number of vertices in a polygon.
*/
int p2d_is_cw(const struct p2d *p);
int p2d_is_closed(const struct p2d *p);
int p2d_no_intersect(const struct p2d *p);
int p2d_vertices(const struct p2d *p);
bool p2d_is_cw(const struct p2d *p);
bool p2d_is_closed(const struct p2d *p);
bool p2d_no_intersect(const struct p2d *p);
unsigned p2d_vertices(const struct p2d *p);
/*
* Convert a possibly self-intersecting polygon into one or more simple