From 7e7ec0e12cf4fe89cf36ba5f9b42bbb67628955f Mon Sep 17 00:00:00 2001 From: AZEN-SGG Date: Sun, 15 Dec 2024 16:38:50 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=B1=D1=80=D0=B0=D0=BB=20=D1=83=D1=82?= =?UTF-8?q?=D0=B5=D1=87=D0=BA=D1=83=20=D0=BF=D0=B0=D0=BC=D1=8F=D1=82=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ComputationalGeometry/10Ex/polygon.c | 15 ++------------- ComputationalGeometry/10Ex/polygon.h | 11 +++++++++++ ComputationalGeometry/10Ex/types.h | 9 --------- 3 files changed, 13 insertions(+), 22 deletions(-) diff --git a/ComputationalGeometry/10Ex/polygon.c b/ComputationalGeometry/10Ex/polygon.c index 8490e1e..5854315 100644 --- a/ComputationalGeometry/10Ex/polygon.c +++ b/ComputationalGeometry/10Ex/polygon.c @@ -64,6 +64,8 @@ void repairPolygon(polygon * plgn) { delLine(&lns, i--); } } + + free(lns.arr); } bool isNull(point vector) { @@ -82,19 +84,6 @@ DELFUNC(Vector, points) DELFUNC(Line, lines) -//void delVector(points * vectors, int index) { -// DEL(vectors -> arr, index, vectors -> len) -// vectors -> len--; -//} -// -//void delLine(lines * lns, int index) { -// for (int i = index + 1; i < lns -> len; ++i) { -// lns -> arr[i] = lns -> arr[i - 1]; -// } -// -// lns -> len--; -//} - polygon getPolygon(polygon * plgn, double shift) { points vectors = getVectors(plgn -> pts); int secind, len = plgn -> pts.len; diff --git a/ComputationalGeometry/10Ex/polygon.h b/ComputationalGeometry/10Ex/polygon.h index 0e494cc..88ff7b6 100644 --- a/ComputationalGeometry/10Ex/polygon.h +++ b/ComputationalGeometry/10Ex/polygon.h @@ -8,6 +8,17 @@ #include #include "types.h" +#define DELFUNC(NAME, TYPE) \ + void del##NAME(TYPE * array, int index) { \ + DEL(array->arr, index, array->len) \ + array -> len--; \ + } + +#define DEL(DATA, INDEX, LEN) \ + for (int i = INDEX; i < (LEN) - 1; ++i) { \ + (DATA)[i] = (DATA)[i + 1]; \ + } + line getLine(point pt1, point pt2); lines getLines(points pts); points getVectors(points pts); diff --git a/ComputationalGeometry/10Ex/types.h b/ComputationalGeometry/10Ex/types.h index 0a8eb57..281d1ad 100644 --- a/ComputationalGeometry/10Ex/types.h +++ b/ComputationalGeometry/10Ex/types.h @@ -9,16 +9,7 @@ int len;\ } NAME -#define DELFUNC(NAME, TYPE) \ - void del##NAME(TYPE * array, int index) { \ - DEL(array->arr, index, array->len) \ - array -> len--; \ - } -#define DEL(DATA, INDEX, LEN) \ - for (int i = INDEX; i < (LEN) - 1; ++i) { \ - (DATA)[i] = (DATA)[i + 1]; \ - } typedef struct { double x;