From 378aab025f6b372447d5cde7e4f425b8515b1c05 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Tue, 12 Jun 2012 15:04:59 -0300 Subject: [PATCH] cameo/path.c: new function path_is_inside which calls p2d_contains_poly --- cameo/path.c | 16 ++++++++++++++++ cameo/path.h | 1 + 2 files changed, 17 insertions(+) diff --git a/cameo/path.c b/cameo/path.c index 7533cc1..f73ead5 100644 --- a/cameo/path.c +++ b/cameo/path.c @@ -18,6 +18,7 @@ #include "util.h" #include "shape.h" +#include "poly2d.h" #include "path.h" @@ -390,6 +391,21 @@ const struct path *path_find_leftmost(const struct path *path) } +int path_is_inside(const struct path *a, const struct path *b) +{ + struct p2d *pa, *pb; + int res; + + pa = path_to_poly(a); + pb = path_to_poly(b); + res = p2d_contains_poly(pb, pa); + p2d_free(pa); + p2d_free(pb); + + return res == 1; /* 0 if they intersect */ +} + + static int attr_eq(const struct path *a, const struct path *b) { return a->r_tool == b->r_tool && a->outside == b->outside && diff --git a/cameo/path.h b/cameo/path.h index de1c585..1344dad 100644 --- a/cameo/path.h +++ b/cameo/path.h @@ -38,6 +38,7 @@ int path_is_closed(const struct path *path); int path_tool_is_left(const struct path *path); struct path *path_offset(const struct path *path, int left, int notch); const struct path *path_find_leftmost(const struct path *path); +int path_is_inside(const struct path *a, const struct path *b); void path_free(struct path *path); struct path *path_connect(struct path *path); void path_stats(const struct path *path);