1
0
mirror of git://projects.qi-hardware.com/cae-tools.git synced 2024-12-23 13:52:25 +02:00

poly2d/: store actual values in struct f2d, not pointers

... since the data structures they point to have internal use only.
This commit is contained in:
Werner Almesberger 2013-10-14 11:11:27 -03:00
parent 8b6e4168d3
commit 626dbe52e1
2 changed files with 19 additions and 8 deletions

View File

@ -186,31 +186,40 @@ static struct f2d *make_face(CDT::Finite_faces_iterator fit,
const struct p2d *p, const struct p2d *holes) const struct p2d *p, const struct p2d *holes)
{ {
struct f2d *f; struct f2d *f;
const struct v2d *v[3];
const struct p2d *h; const struct p2d *h;
int i; int i, j;
f = alloc_type(struct f2d);
for (i = 0; i != 3; i++) { for (i = 0; i != 3; i++) {
Point point = fit->vertex(i)->point(); Point point = fit->vertex(i)->point();
const struct v2d *m; const struct v2d *m;
m = find_point(p, point.x(), point.y()); m = find_point(p, point.x(), point.y());
if (m) { if (m) {
f->v[i] = m; v[i] = m;
f->p[i] = p;
continue; continue;
} }
for (h = holes; h; h = h->next) { for (h = holes; h; h = h->next) {
m = find_point(h, point.x(), point.y()); m = find_point(h, point.x(), point.y());
if (!m) if (!m)
continue; continue;
f->v[i] = m; v[i] = m;
f->p[i] = h;
break; break;
} }
assert(m); assert(m);
} }
f = alloc_type(struct f2d);
for (i = 0; i != 3; i++) {
f->x[i] = v[i]->x;
f->y[i] = v[i]->y;
j = i+1;
if (j == 3)
j = 0;
f->side[i] = v[i]->next == v[j] || v[j]->next == v[i];
}
f->next = NULL; f->next = NULL;
return f; return f;
} }

View File

@ -14,6 +14,7 @@
#ifndef POLY2D_H #ifndef POLY2D_H
#define POLY2D_H #define POLY2D_H
#include <stdbool.h>
#include <stdio.h> #include <stdio.h>
@ -30,8 +31,9 @@ struct p2d {
}; };
struct f2d { struct f2d {
const struct v2d *v[3]; /* vertices forming the face */ double x[3]; /* vertices forming the face */
const struct p2d *p[3]; /* polygons vertices belong to */ double y[3];
bool side[3]; /* side[i] if v[i] and v[(i+1) mod 3] are on polygon */
struct f2d *next; struct f2d *next;
}; };