summaryrefslogtreecommitdiff
path: root/header.h
diff options
context:
space:
mode:
Diffstat (limited to 'header.h')
-rw-r--r--header.h229
1 files changed, 134 insertions, 95 deletions
diff --git a/header.h b/header.h
index 3988abb..1391b5b 100644
--- a/header.h
+++ b/header.h
@@ -43,6 +43,27 @@ int multiresolution_meshing(int argc, char** argv);
* ----------------------------------------------------------------------
*/
+int sign(double x)
+{
+ int flag = (x > 0) ? 1 : -1;
+ if (x == 0) {
+ flag = 0;
+ }
+ return flag;
+}
+
+double max(double a, double b)
+{
+ double results = (a > b) ? a : b;
+ return results;
+}
+
+double min(double a, double b)
+{
+ double results = (a < b) ? a : b;
+ return results;
+}
+
int ipow(int base, int exponent)
{
int result = 1;
@@ -116,101 +137,6 @@ int transpose(double* matrix, int nrow, int ncol) {
return 0;
}
-void report(io, markers, reporttriangles, reportneighbors, reportsegments,
- reportedges, reportnorms)
-struct triangulateio *io;
-int markers;
-int reporttriangles;
-int reportneighbors;
-int reportsegments;
-int reportedges;
-int reportnorms;
-{
- int i, j;
-
- for (i = 0; i < io->numberofpoints; i++) {
- printf("Point %4d:", i);
- for (j = 0; j < 2; j++) {
- printf(" %.6g", io->pointlist[i * 2 + j]);
- }
- if (io->numberofpointattributes > 0) {
- printf(" attributes");
- }
- for (j = 0; j < io->numberofpointattributes; j++) {
- printf(" %.6g",
- io->pointattributelist[i * io->numberofpointattributes + j]);
- }
- if (markers) {
- printf(" marker %d\n", io->pointmarkerlist[i]);
- } else {
- printf("\n");
- }
- }
- printf("\n");
-
- if (reporttriangles || reportneighbors) {
- for (i = 0; i < io->numberoftriangles; i++) {
- if (reporttriangles) {
- printf("Triangle %4d points:", i);
- for (j = 0; j < io->numberofcorners; j++) {
- printf(" %4d", io->trianglelist[i * io->numberofcorners + j]);
- }
- if (io->numberoftriangleattributes > 0) {
- printf(" attributes");
- }
- for (j = 0; j < io->numberoftriangleattributes; j++) {
- printf(" %.6g", io->triangleattributelist[i *
- io->numberoftriangleattributes + j]);
- }
- printf("\n");
- }
- if (reportneighbors) {
- printf("Triangle %4d neighbors:", i);
- for (j = 0; j < 3; j++) {
- printf(" %4d", io->neighborlist[i * 3 + j]);
- }
- printf("\n");
- }
- }
- printf("\n");
- }
-
- if (reportsegments) {
- for (i = 0; i < io->numberofsegments; i++) {
- printf("Segment %4d points:", i);
- for (j = 0; j < 2; j++) {
- printf(" %4d", io->segmentlist[i * 2 + j]);
- }
- if (markers) {
- printf(" marker %d\n", io->segmentmarkerlist[i]);
- } else {
- printf("\n");
- }
- }
- printf("\n");
- }
-
- if (reportedges) {
- for (i = 0; i < io->numberofedges; i++) {
- printf("Edge %4d points:", i);
- for (j = 0; j < 2; j++) {
- printf(" %4d", io->edgelist[i * 2 + j]);
- }
- if (reportnorms && (io->edgelist[i * 2 + 1] == -1)) {
- for (j = 0; j < 2; j++) {
- printf(" %.6g", io->normlist[i * 2 + j]);
- }
- }
- if (markers) {
- printf(" marker %d\n", io->edgemarkerlist[i]);
- } else {
- printf("\n");
- }
- }
- printf("\n");
- }
-}
-
/*
* ----------------------------------------------------------------------
* meshing functions
@@ -300,3 +226,116 @@ int get_border(double *data, double nodata, int nrow, int ncol)
return 0;
}
+
+void write_avs(struct triangulateio *io, int counter)
+{
+
+ char fname[1024];
+ sprintf(fname, "output/mesh%d.inp", counter);
+
+ FILE *fp;
+ fp = fopen(fname, "w");
+
+ fprintf(fp, "%d %d %d %d %d\n", io->numberofpoints, io->numberoftriangles, 0, 1, 0);
+
+ for (int i = 0; i < io->numberofpoints; ++ i) {
+ fprintf(fp, "%d %f %f %f\n", i+1, io->pointlist[2*i], io->pointlist[2*i+1], 0.0);
+ }
+
+ for (int i = 0; i < io->numberoftriangles; ++ i) {
+ fprintf(fp, "%d %d tri %d %d %d\n", i+1, 1, io->trianglelist[3*i], io->trianglelist[3*i+1], io->trianglelist[3*i+2]);
+ }
+
+ fclose(fp);
+
+}
+
+void report(struct triangulateio *io, int markers, int reporttriangles,
+ int reportneighbors, int reportsegments, int reportedges,
+ int reportnorms)
+{
+
+ int i, j;
+
+ for (i = 0; i < io->numberofpoints; i++) {
+ printf("Point %4d:", i);
+ for (j = 0; j < 2; j++) {
+ printf(" %.6g", io->pointlist[i * 2 + j]);
+ }
+ if (io->numberofpointattributes > 0) {
+ printf(" attributes");
+ }
+ for (j = 0; j < io->numberofpointattributes; j++) {
+ printf(" %.6g",
+ io->pointattributelist[i * io->numberofpointattributes + j]);
+ }
+ if (markers) {
+ printf(" marker %d\n", io->pointmarkerlist[i]);
+ } else {
+ printf("\n");
+ }
+ }
+ printf("\n");
+
+ if (reporttriangles || reportneighbors) {
+ for (i = 0; i < io->numberoftriangles; i++) {
+ if (reporttriangles) {
+ printf("Triangle %4d points:", i);
+ for (j = 0; j < io->numberofcorners; j++) {
+ printf(" %4d", io->trianglelist[i * io->numberofcorners + j]);
+ }
+ if (io->numberoftriangleattributes > 0) {
+ printf(" attributes");
+ }
+ for (j = 0; j < io->numberoftriangleattributes; j++) {
+ printf(" %.6g", io->triangleattributelist[i *
+ io->numberoftriangleattributes + j]);
+ }
+ printf("\n");
+ }
+ if (reportneighbors) {
+ printf("Triangle %4d neighbors:", i);
+ for (j = 0; j < 3; j++) {
+ printf(" %4d", io->neighborlist[i * 3 + j]);
+ }
+ printf("\n");
+ }
+ }
+ printf("\n");
+ }
+
+ if (reportsegments) {
+ for (i = 0; i < io->numberofsegments; i++) {
+ printf("Segment %4d points:", i);
+ for (j = 0; j < 2; j++) {
+ printf(" %4d", io->segmentlist[i * 2 + j]);
+ }
+ if (markers) {
+ printf(" marker %d\n", io->segmentmarkerlist[i]);
+ } else {
+ printf("\n");
+ }
+ }
+ printf("\n");
+ }
+
+ if (reportedges) {
+ for (i = 0; i < io->numberofedges; i++) {
+ printf("Edge %4d points:", i);
+ for (j = 0; j < 2; j++) {
+ printf(" %4d", io->edgelist[i * 2 + j]);
+ }
+ if (reportnorms && (io->edgelist[i * 2 + 1] == -1)) {
+ for (j = 0; j < 2; j++) {
+ printf(" %.6g", io->normlist[i * 2 + j]);
+ }
+ }
+ if (markers) {
+ printf(" marker %d\n", io->edgemarkerlist[i]);
+ } else {
+ printf("\n");
+ }
+ }
+ printf("\n");
+ }
+}