42 fprintf (
stderr,
"input_stl(): ASCII STL not implemented yet "
43 "(use binary instead)\n");
53 "stdin: incomplete header\n");
58 "stdin: missing number of facets\n");
63 float x = 0,
y = 0,
z = 0;
68 if (
fread (&
x,
sizeof (
float), 1,
fp) != 1) {
70 "stdin: missing normal x-coordinate\n");
73 if (
fread (&
y,
sizeof (
float), 1,
fp) != 1) {
75 "stdin: missing normal y-coordinate\n");
78 if (
fread (&
z,
sizeof (
float), 1,
fp) != 1) {
80 "stdin: missing normal z-coordinate\n");
84 for (
j = 0;
j < 3;
j++) {
85 if (
fread (&
x,
sizeof (
float), 1,
fp) != 1) {
87 "stdin: missing vertex x-coordinate\n");
90 if (
fread (&
y,
sizeof (
float), 1,
fp) != 1) {
92 "stdin: missing vertex y-coordinate\n");
95 if (
fread (&
z,
sizeof (
float), 1,
fp) != 1) {
97 "stdin: missing vertex z-coordinate\n");
106 "stdin: missing attribute byte count\n");
137 if (
fscanf (
fp,
"%lf %lf", &
p.x, &
p.y) == 2) {
142 last =
p,
la = &last;
165 if ((*p).x < (*min).x)
167 if ((*p).x > (*max).x)
184#define double_to_pointer(d) (*((void **) &(d)))
229 for (
int i = 0;
i <
ND;
i++)
233 bool first = (
level == 0);
243 for (
int i = 0;
i <
ND;
i++)
245 for (
int j =
ND - 1;
j >
i;
j--)
247 q[
i].d2 = d2,
q[
i].v =
p;
261 if (
s == 0. &&
t == 0.)
263 else if (
s == 1. &&
t == 0.)
265 else if (
s == 0. &&
t == 1.)
267 else if (
s == 0. ||
t == 0. ||
s +
t == 1.)
283 if (d2 < r2 || first)
293 memcpy (&surface[], &
p,
sizeof(
void *));
309 for (
int i = 0;
i < 2;
i++) {
334 for (
int i = 1;
i < nd &&
q[
i].type < 3;
i++)
351 fprintf (
stderr,
"vertex %g %g %g %g %g %g %d %g %g %g %g %g %g %d\n",
357 else if (
q[0].
type == 3) {
359 if (nd == 1 ||
q[1].
type != 3)
372 fprintf (
stderr,
"edge %g %g %g %g %g %g %d %g %g %g %g %g %g\n",
410 for (
int _c = 0;
_c < 4;
_c++) {
417 for (
int _c = 0;
_c < 4;
_c++) {
431 for (
int _c = 0;
_c < 4;
_c++)
444 for (
int _c = 0;
_c < 4;
_c++)
450 for (
int _l = 0;
_l < 0;
_l++)
double PointSegmentDistance(const coord *p, const coord *p0, const coord *p1, coord *segmentClosest, double *segmentParameter)
Returns the squared distance between p and [p0:p1].
double PointTriangleDistance(const coord *P, const coord *P0, const coord *P1, const coord *P2, double *s, double *t)
Returns the squared distance between point P and triangle P0, P1, P2.
#define vecdotproduct(a, b)
int PointSegmentOrientation(const coord *P, const coord *P0, const coord *P1)
int PointTriangleOrientation(const coord *P, const coord *P0, const coord *P1, const coord *P2)
vector q[]
The primitive variables are the momentum , pressure , density , (face) specific volume ,...
void * array_shrink(Array *a)
void * array_append(Array *a, void *elem, size_t size)
void(* boundary_level)(scalar *, int l)
static number sq(number x)
static int sign(number x)
define sysmalloc malloc define syscalloc calloc define sysrealloc realloc define sysfree free define systrdup strdup define line line line line type
trace coord * input_stl(FILE *fp)
The 3D triangulated surfaces are defined using the (binary) STL format which can be exported from mos...
static void coarsen_distance(Point point, scalar d)
trace void distance(scalar d, coord *p)
static void restriction_distance(Point point, scalar d)
static void delete_distance(scalar d)
attribute
An extra field, holding a pointer to the elements (segments or triangles) intersecting the neighborho...
static void refine_distance(Point point, scalar d)
#define double_to_pointer(d)
void bounding_box(coord *p, coord *min, coord *max)
This function computes the coordinates of the bounding box of a set of segments or triangles.
static void update_distance(Point point, coord **i, scalar d)
trace coord * input_xy(FILE *fp)
In 2D dimensions, the file format is that used by gnuplot i.e.
vector ab
After the advection and diffusion terms have been added to , we recover the update by adding the new ...
*cs[i, 0, 0] a *[i -1, 0, 0] j
static void refine_bilinear(Point point, scalar s)
void set_prolongation(scalar s, void(*prolongation)(Point, scalar))
static void no_restriction(Point point, scalar s)
static double bilinear(Point point, scalar s)
To compute the minimal distance and its sign, we need to store information on the closest (2 in 2D,...