f3e15b8c8d
- aggiunti file della libreria e progetto visual studio.
331 lines
15 KiB
C++
331 lines
15 KiB
C++
/*****************************************************************************/
|
|
/* */
|
|
/* Copyright (C) 2002-2023 M. Held */
|
|
/* */
|
|
/* This code is not in the public domain. All rights reserved! Please make */
|
|
/* sure to read the full copyright statement contained in "README.txt" or in */
|
|
/* the "main" file of this code, such as "main.cc". */
|
|
/* */
|
|
/*****************************************************************************/
|
|
/* */
|
|
/* Written by: Martin Held */
|
|
/* */
|
|
/* E-Mail: held@cs.sbg.ac.at */
|
|
/* Fax Mail: (+43 662) 8044-611 */
|
|
/* Voice Mail: (+43 662) 8044-6304 */
|
|
/* Snail Mail: Martin Held */
|
|
/* FB Informatik */
|
|
/* Universitaet Salzburg */
|
|
/* A-5020 Salzburg, Austria */
|
|
/* */
|
|
/*****************************************************************************/
|
|
/* */
|
|
/* routines for printing the help information and the copyright notice. */
|
|
/* */
|
|
/*****************************************************************************/
|
|
/* */
|
|
/* get standard libraries */
|
|
/* */
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <assert.h>
|
|
|
|
/* */
|
|
/* get my header files */
|
|
/* */
|
|
#include "fpkernel.h"
|
|
#include "vronivector.h"
|
|
#include "vroni_object.h"
|
|
#include "defs.h"
|
|
|
|
|
|
|
|
void vroniObject::Copyright(void)
|
|
{
|
|
printf("\n");
|
|
printf("(***********************************************************");
|
|
printf("******************)\n");
|
|
printf("(* ");
|
|
printf(" *)\n");
|
|
printf("(* Copyright (C) %9s M. Held", PROG_YEAR);
|
|
printf(" *)\n");
|
|
printf("(* ");
|
|
printf(" *)\n");
|
|
printf("(* ");
|
|
printf(" *)\n");
|
|
printf("(* %9s %5s ",
|
|
PROG_NAME, PROG_VERSION);
|
|
|
|
printf(" *)\n");
|
|
printf("(* ");
|
|
printf(" *)\n");
|
|
printf("(* ");
|
|
printf(" *)\n");
|
|
printf("(* Start this program as `vroni --help' in order to get a sh");
|
|
printf("ort summary of *)\n");
|
|
printf("(* how to use it. ");
|
|
printf(" *)\n");
|
|
printf("(* ");
|
|
printf(" *)\n");
|
|
printf("(* Please report bugs to held@cs.sbg.ac.at. ");
|
|
printf(" *)\n");
|
|
printf("(* ");
|
|
printf(" *)\n");
|
|
printf("(* ");
|
|
printf(" *)\n");
|
|
printf("(* ");
|
|
printf(" *)\n");
|
|
printf("(* C O P Y R I G H T ");
|
|
printf(" *)\n");
|
|
printf("(* ");
|
|
printf(" *)\n");
|
|
printf("(* This code is provided at no charge to you for purely non-profit purposes *)\n");
|
|
printf("(* and only for use internal to your institution. You may use this code for *)\n");
|
|
printf("(* academic applications, following standard rules of academic conduct *)\n");
|
|
printf("(* including crediting the author(s) and the copyright holder in any *)\n");
|
|
printf("(* publication. This code is not in the public domain, and no parts of it *)\n");
|
|
printf("(* may be duplicated, altered, sold, re-distributed (in either source-code *)\n");
|
|
printf("(* or binary format), or used as a blueprint for somebody else's own *)\n");
|
|
printf("(* implementation without obtaining the prior written consent of the *)\n");
|
|
printf("(* copyright holder. All rights reserved! *)\n");
|
|
printf("(* *)\n");
|
|
printf("(* Free use of this code is restricted to purely non-profit purposes within *)\n");
|
|
printf("(* academic research institutions. Absolutely all other forms of use require *)\n");
|
|
printf("(* the signing of a non-disclosure agreement or of a commercial license. *)\n");
|
|
printf("(* Please contact me, Martin Held (held@cs.sbg.ac.at), for commercial *)\n");
|
|
printf("(* evaluation and licensing terms. *)\n");
|
|
printf("(* *)\n");
|
|
printf("(* D I S C L A I M E R *)\n");
|
|
printf("(* *)\n");
|
|
printf("(* In any case, this code is provided `as is', and you use it at your own *)\n");
|
|
printf("(* risk. The author does not accept any responsibility, to the extent *)\n");
|
|
printf("(* permitted by applicable law, for the consequences of using it or for its *)\n");
|
|
printf("(* usefulness for any particular application. *)\n");
|
|
printf("(* ");
|
|
printf(" *)\n");
|
|
printf("(***********************************************************");
|
|
printf("******************)\n");
|
|
printf("\n");
|
|
|
|
return;
|
|
}
|
|
|
|
|
|
|
|
void vroniObject::Help(void)
|
|
{
|
|
printf("\n\n");
|
|
printf("(***********************************************************");
|
|
printf("******************)\n");
|
|
printf("(* ");
|
|
printf(" *)\n");
|
|
printf("(* Start this program as `vroni --help' in order to get a sh");
|
|
printf("ort summary of *)\n");
|
|
printf("(* how to use it. ");
|
|
printf(" *)\n");
|
|
printf("(* ");
|
|
printf(" *)\n");
|
|
printf("(* Please make sure to read the files README and README.data");
|
|
printf(". *)\n");
|
|
printf("(* ");
|
|
printf(" *)\n");
|
|
printf("(***********************************************************");
|
|
printf("******************)\n");
|
|
printf("\n\nSummary of keyboard short-cuts used in the GUI:\n\n");
|
|
|
|
printf("`h' ... hit the `h'-key while the cursor is within the drawing\n");
|
|
printf(" canvas in order to reproduce this message.\n");
|
|
printf("`p' ... tells my code that you will now enter a new polygon.\n");
|
|
printf(" the vertices of the polygon are entered via mouse");
|
|
printf("-clicks\n");
|
|
printf("`c' ... to close the polygonal chain which you have entered.\n");
|
|
printf("`v' ... to compute the Voronoi diagram. It is also used for\n");
|
|
printf(" advancing the graphics display if `--step' was selected\n");
|
|
printf(" as a command-line option.\n");
|
|
printf("`u' ... to redraw the entities displayed in the drawing canvas;\n");
|
|
printf(" it also resizes the display such that all entities fit\n");
|
|
printf(" nicely within the graphics window.\n");
|
|
printf("`i' ... to zoom in.\n");
|
|
printf("`o' ... to zoom out.\n");
|
|
printf("`z' ... to zoom into a rectangular region; this region is ");
|
|
printf("specified\n");
|
|
printf(" by clicking first at its lower-left and then at its\n");
|
|
printf(" upper-right corner.\n");
|
|
printf("`d' ... to erase the drawing canvas and delete all data.\n");
|
|
printf("`m' ... toggle; draw or not draw the vertex markers.\n");
|
|
printf("`n' ... toggle; draw or not draw the Voronoi nodes.\n");
|
|
printf("`e' ... toggle; draw or not draw the Voronoi edges.\n");
|
|
printf("`a' ... toggle; draw or not draw the arcs.\n");
|
|
printf("`s' ... toggle; draw or not draw the segments.\n");
|
|
printf("`t' ... multiple toggle; draw or not draw VD, DT or WMAT.\n");
|
|
printf("`f' ... toggle; draw or not draw offset curves.\n");
|
|
printf("`x' ... toggle; draw or not draw the maximum inscribed circle.\n");
|
|
printf("`q' ... to terminate the program.\n");
|
|
printf("\nPlease note that the interface does not recognize upper-case ");
|
|
printf("letters.\n");
|
|
printf("\nA listing of the command-line options is produced by using the ");
|
|
printf("option `--help'.\n\n");
|
|
printf("Color codes used in the GUI:\n");
|
|
printf("green ....... input sites (points and line segments).\n");
|
|
printf("white ....... Delaunay triangulation, offsets\n");
|
|
printf("red ......... Voronoi diagram.\n");
|
|
printf("yellow ...... Delaunay circles, current site (if step mode is activated),\n");
|
|
printf(" maximum inscribed circle.\n");
|
|
printf("magenta ..... current Voronoi cell (if step mode is activated).\n");
|
|
printf("cyan ........ input sites (circular arcs), weighted medial axis.\n");
|
|
printf("blue ........ alert color.\n");
|
|
printf("orange ...... current node (if step mode is activated).\n\n");
|
|
|
|
return;
|
|
}
|
|
|
|
|
|
/* */
|
|
/* prints value of a variable. typical usage: */
|
|
/* int i = 0; */
|
|
/* PrintVarValue(stdout, (void*) &new_input, "new_input", vroniBOOLEAN); */
|
|
/* PrintVarValue(stdout, (void*) &bound, "bound", vroniINTEGER); */
|
|
/* PrintVarValue(stdout, (void*) output_file, "output_file", vroniCHARS); */
|
|
/* PrintVarValue(stdout, (void*) &apx_absolute,"apx_absolute",vroniDOUBLE);*/
|
|
/* PrintVarValue(stdout, (void*) &(pnts[0].p), "p", vroniCOORD); */
|
|
/* PrintVarValue(stdout, (void*) &i, "pnts", vroniPNTS); */
|
|
/* */
|
|
void vroniObject::PrintVarValue(FILE *output, void *v, char const *var_name, my_types t)
|
|
{
|
|
char my_string[100], number[100], tmp[100];
|
|
|
|
switch(t) {
|
|
case(vroniCHARS):
|
|
fprintf(output, "%40s = %s\n", var_name, (char*)v);
|
|
break;
|
|
case(vroniINTEGER):
|
|
fprintf(output, "%40s = %12d\n", var_name, *(int*)v);
|
|
break;
|
|
case(vroniDOUBLE):
|
|
FP_fprintf(output, "%40s = %30.17f\n", var_name, FP_PRNTARG(*(double*)v));
|
|
break;
|
|
case(vroniBOOLEAN):
|
|
if (*(vr_bool*)v)
|
|
fprintf(output, "%40s = TRUE\n", var_name);
|
|
else
|
|
fprintf(output, "%40s = FALSE\n", var_name);
|
|
break;
|
|
case(vroniCOORD):
|
|
my_string[0] = '\0';
|
|
strcat(my_string, var_name);
|
|
strcat(my_string, ".x");
|
|
FP_fprintf(output, "%40s = %30.17f\n", my_string, FP_PRNTARG((*(coord*)v).x));
|
|
my_string[0] = '\0';
|
|
strcat(my_string, var_name);
|
|
strcat(my_string, ".y");
|
|
FP_fprintf(output, "%40s = %30.17f\n", my_string, FP_PRNTARG((*(coord*)v).y));
|
|
break;
|
|
case(vroniN_STATUS):
|
|
my_string[0] = '\0';
|
|
switch(*(t_site*)v) {
|
|
case(UNCHECKED):
|
|
strcat(my_string, "UNCHECKED");
|
|
break;
|
|
case(CHECKED):
|
|
strcat(my_string, "CHECKED");
|
|
break;
|
|
case(DELETED):
|
|
strcat(my_string, "DELETED");
|
|
break;
|
|
case(VISITED):
|
|
strcat(my_string, "VISITED");
|
|
break;
|
|
case(DUMMY):
|
|
strcat(my_string, "DUMMY");
|
|
break;
|
|
case(MISC):
|
|
strcat(my_string, "MISC");
|
|
break;
|
|
default:
|
|
strcat(my_string, "***** type not known *****");
|
|
break;
|
|
}
|
|
fprintf(output, "%40s = %s\n", var_name, my_string);
|
|
break;
|
|
case(vroniT_SITE):
|
|
my_string[0] = '\0';
|
|
switch(*(t_site*)v) {
|
|
case(SEG):
|
|
strcat(my_string, "SEG");
|
|
break;
|
|
case(ARC):
|
|
strcat(my_string, "ARC");
|
|
break;
|
|
case(PNT):
|
|
strcat(my_string, "PNT");
|
|
break;
|
|
case(VDN):
|
|
strcat(my_string, "VDN");
|
|
break;
|
|
case(VDE):
|
|
strcat(my_string, "VDE");
|
|
break;
|
|
case(DTE):
|
|
strcat(my_string, "DTE");
|
|
break;
|
|
case(CCW):
|
|
strcat(my_string, "CCW");
|
|
break;
|
|
case(CW):
|
|
strcat(my_string, "CW");
|
|
break;
|
|
case(UNKNOWN):
|
|
strcat(my_string, "UNKNOWN");
|
|
break;
|
|
default:
|
|
strcat(my_string, "***** type not known *****");
|
|
break;
|
|
}
|
|
fprintf(output, "%40s = %s\n", var_name, my_string);
|
|
break;
|
|
case(vroniPNTS):
|
|
my_string[0] = '\0';
|
|
strcat(my_string, var_name);
|
|
strcat(my_string, "[");
|
|
number[0] = '\0';
|
|
sprintf(number, "%d", *(int*)v);
|
|
strcat(my_string, number);
|
|
strcat(my_string, "]");
|
|
if (InPntsList(*(int*)v)) {
|
|
strcpy(tmp, my_string);
|
|
strcat(my_string, ".p ");
|
|
PrintVarValue(output, &(pnts[*(int*)v].p), my_string, vroniCOORD);
|
|
strcpy(my_string, tmp);
|
|
strcat(my_string, ".vd ");
|
|
PrintVarValue(output, &(pnts[*(int*)v].vd), my_string,
|
|
vroniINTEGER);
|
|
strcpy(my_string, tmp);
|
|
strcat(my_string, ".node");
|
|
PrintVarValue(output, &(pnts[*(int*)v].node), my_string,
|
|
vroniINTEGER);
|
|
strcpy(my_string, tmp);
|
|
strcat(my_string, ".vis ");
|
|
PrintVarValue(output, &(pnts[*(int*)v].vis), my_string, vroniBOOLEAN);
|
|
strcpy(my_string, tmp);
|
|
strcat(my_string, ".s ");
|
|
PrintVarValue(output, &(pnts[*(int*)v].s), my_string, vroniBOOLEAN);
|
|
strcpy(my_string, tmp);
|
|
strcat(my_string, ".del ");
|
|
PrintVarValue(output, &(pnts[*(int*)v].del), my_string, vroniBOOLEAN);
|
|
}
|
|
else {
|
|
number[0] = '\0';
|
|
strcat(number, "***** index out of range! *****");
|
|
PrintVarValue(output, &(number), my_string, vroniCHARS);
|
|
}
|
|
break;
|
|
default:
|
|
my_string[0] = '\0';
|
|
strcat(my_string, "***** type not known *****");
|
|
PrintVarValue(output, &(var_name), my_string, vroniCHARS);
|
|
break;
|
|
}
|
|
|
|
return;
|
|
}
|