f3e15b8c8d
- aggiunti file della libreria e progetto visual studio.
275 lines
8.7 KiB
C++
275 lines
8.7 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 */
|
|
/* */
|
|
/*****************************************************************************/
|
|
/* */
|
|
/* provide support for debug output. */
|
|
/* */
|
|
/*****************************************************************************/
|
|
|
|
/* */
|
|
/* get standard libraries */
|
|
/* */
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <assert.h>
|
|
#include <math.h>
|
|
|
|
/* */
|
|
/* get my header files */
|
|
/* */
|
|
#include "fpkernel.h"
|
|
#include "vronivector.h"
|
|
#include "vroni_object.h"
|
|
#include "defs.h"
|
|
#include "numerics.h"
|
|
|
|
/*
|
|
* please turn those define's only on if you know what you do! (they are
|
|
* here only for my debugging purposes!!
|
|
*
|
|
#define INIT_FORCED
|
|
#define TRACE_INPUT
|
|
*
|
|
*/
|
|
|
|
|
|
|
|
void vroniObject::WriteSites(const char *output_file)
|
|
{
|
|
int i, number;
|
|
FILE *output;
|
|
|
|
output = OpenFileVD(output_file, "w");
|
|
for (i = 2; i < num_pnts-2; ++i) {
|
|
FP_fprintf(output, "2\n%20.16f %20.16f\n", FP_PRNTARG(pnts[i].p.x), FP_PRNTARG(pnts[i].p.y));
|
|
}
|
|
for (i = 0; i < num_segs; ++i) {
|
|
if ((pnts[segs[i].i1].p.x != pnts[segs[i].i2].p.x) ||
|
|
(pnts[segs[i].i1].p.y != pnts[segs[i].i2].p.y))
|
|
FP_fprintf(output, "0\n%20.16f %20.16f %20.16f %20.16f\n",
|
|
FP_PRNTARG(pnts[segs[i].i1].p.x),
|
|
FP_PRNTARG(pnts[segs[i].i1].p.y),
|
|
FP_PRNTARG(pnts[segs[i].i2].p.x),
|
|
FP_PRNTARG(pnts[segs[i].i2].p.y));
|
|
}
|
|
|
|
number = num_arcs;
|
|
for (i = 0; i < number; ++i) {
|
|
if ((pnts[arcs[i].i1].p.x != pnts[arcs[i].i2].p.x) ||
|
|
(pnts[arcs[i].i1].p.y != pnts[arcs[i].i2].p.y))
|
|
FP_fprintf(output, "1\n%20.16f %20.16f %20.16f %20.16f %20.16f %20.16f\n",
|
|
FP_PRNTARG(pnts[arcs[i].i1].p.x),
|
|
FP_PRNTARG(pnts[arcs[i].i1].p.y),
|
|
FP_PRNTARG(pnts[arcs[i].i2].p.x),
|
|
FP_PRNTARG(pnts[arcs[i].i2].p.y),
|
|
FP_PRNTARG(arcs[i].c.x), FP_PRNTARG(arcs[i].c.y));
|
|
}
|
|
|
|
fclose(output);
|
|
|
|
return;
|
|
}
|
|
|
|
|
|
#ifdef TRACE
|
|
void vroniObject::WriteSiteData(int j, t_site type, const char* qual_string)
|
|
{
|
|
printf("%s", qual_string);
|
|
|
|
if (type == PNT) {
|
|
assert(InPntsList(j));
|
|
printf("pnt %d: (%21.17f, %21.17f)\n",
|
|
j, pnts[j].p.x, pnts[j].p.y);
|
|
}
|
|
else if (type == SEG) {
|
|
assert(InSegsList(j));
|
|
printf("seg %d: (%21.17f, %21.17f), (%21.17f, %21.17f)\n",
|
|
j, pnts[segs[j].i1].p.x, pnts[segs[j].i1].p.y,
|
|
pnts[segs[j].i2].p.x, pnts[segs[j].i2].p.y);
|
|
}
|
|
else if (type == ARC) {
|
|
assert(InArcsList(j));
|
|
printf("arc %d: (%21.17f, %21.17f), (%21.17f, %21.17f)\n",
|
|
j, pnts[arcs[j].i1].p.x, pnts[arcs[j].i1].p.y,
|
|
pnts[arcs[j].i2].p.x, pnts[arcs[j].i2].p.y);
|
|
printf("center: (%21.17f, %21.17f)\n",
|
|
arcs[j].c.x, arcs[j].c.y);
|
|
}
|
|
else {
|
|
assert(0 == 1);
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
|
|
|
|
void vroniObject::WriteProcessedSites(const char *output_file)
|
|
{
|
|
#ifdef GRAPHICS
|
|
FILE *output;
|
|
|
|
int i;
|
|
coord q;
|
|
q.x = 0.18;
|
|
q.y = 0.38;
|
|
|
|
output = OpenFileVD(output_file, "w");
|
|
|
|
for (i = 2; i < num_pnts-2; ++i) {
|
|
if(PntPntDist(q, pnts[i].p) < 0.03)
|
|
if (pnts[i].draw)
|
|
fprintf(output, "2\n%24.20f %24.20f\n", pnts[i].p.x, pnts[i].p.y);
|
|
}
|
|
for (i = 0; i < num_segs; ++i) {
|
|
if((PntPntDist(q, pnts[segs[i].i1].p) < 0.03) ||
|
|
(PntPntDist(q, pnts[segs[i].i2].p) < 0.03))
|
|
if (segs[i].draw)
|
|
fprintf(output, "0\n%24.20f %24.20f %24.20f %24.20f\n",
|
|
pnts[segs[i].i1].p.x, pnts[segs[i].i1].p.y,
|
|
pnts[segs[i].i2].p.x, pnts[segs[i].i2].p.y);
|
|
}
|
|
|
|
for (i = 0; i < num_arcs; ++i) {
|
|
if (arcs[i].draw)
|
|
fprintf(output, "1\n%24.20f %24.20f %24.20f %24.20f %24.20f %24.20f\n",
|
|
pnts[arcs[i].i1].p.x, pnts[arcs[i].i1].p.y,
|
|
pnts[arcs[i].i2].p.x, pnts[arcs[i].i2].p.y,
|
|
arcs[i].c.x, arcs[i].c.y);
|
|
}
|
|
|
|
fclose(output);
|
|
#endif
|
|
|
|
return;
|
|
}
|
|
|
|
|
|
#define ClipPnt(x1, y1) \
|
|
((x1 >= clip_min.x) && (x1 <= clip_max.x) && \
|
|
(y1 >= clip_min.y) && (y1 <= clip_max.y))
|
|
|
|
|
|
#define ClipSeg(x1, y1, x2, y2) \
|
|
((Min(x1, x2) <= clip_max.x) && (Max(x1, x2) >= clip_min.x) && \
|
|
(Min(y1, y2) <= clip_max.y) && (Max(y1, y2) >= clip_min.y))
|
|
|
|
|
|
|
|
|
|
void vroniObject::WriteDisplayedSites(double_arg xmin, double_arg ymin, double_arg xmax, double_arg ymax,
|
|
const char *output_file)
|
|
{
|
|
#ifdef GRAPHICS
|
|
int i;
|
|
FILE *output;
|
|
double x1, y1, x2, y2;
|
|
|
|
output = OpenFileVD(output_file, "w");
|
|
ExportClipWindow(xmin, ymin, xmax, ymax);
|
|
|
|
for (i = 2; i < num_pnts-2; ++i) {
|
|
if (pnts[i].draw) {
|
|
x1 = pnts[i].p.x;
|
|
y1 = pnts[i].p.y;
|
|
if (ClipPnt(x1, y1)) {
|
|
fprintf(output, "2\n%24.20f %24.20f\n", x1, y1);
|
|
printf("pnt %d:\n%24.20f %24.20f\n", i, x1, y1);
|
|
}
|
|
}
|
|
}
|
|
|
|
for (i = 0; i < num_segs; ++i) {
|
|
if (segs[i].draw) {
|
|
x1 = pnts[segs[i].i1].p.x;
|
|
y1 = pnts[segs[i].i1].p.y;
|
|
x2 = pnts[segs[i].i2].p.x;
|
|
y2 = pnts[segs[i].i2].p.y;
|
|
if (ClipSeg(x1, y1, x2, y2)) {
|
|
fprintf(output, "0\n%24.20f %24.20f %24.20f %24.20f\n",
|
|
x1, y1, x2, y2);
|
|
printf("seg %d:\n%24.20f %24.20f %24.20f %24.20f\n",
|
|
i, x1, y1, x2, y2);
|
|
}
|
|
}
|
|
}
|
|
|
|
fclose(output);
|
|
#endif
|
|
|
|
return;
|
|
}
|
|
|
|
|
|
|
|
void vroniObject::ExportClipWindow(double_arg xmin, double_arg ymin, double_arg xmax, double_arg ymax)
|
|
{
|
|
clip_min.x = xmin;
|
|
clip_max.x = xmax;
|
|
clip_min.y = ymin;
|
|
clip_max.y = ymax;
|
|
|
|
return;
|
|
}
|
|
|
|
|
|
#endif
|
|
|
|
#ifdef TRACE_INPUT
|
|
|
|
void vroniObject::ClipWriteSiteData(int j, t_site type, const char *output_file)
|
|
{
|
|
FILE *output;
|
|
|
|
output = OpenFileVD(output_file, "a+");
|
|
|
|
if (type == PNT) {
|
|
assert(InPntsList(j));
|
|
fprintf(output, "2\n%24.20f %24.20f\n", pnts[j].p.x, pnts[j].p.y);
|
|
}
|
|
else if (type == SEG) {
|
|
assert(InSegsList(j));
|
|
fprintf(output, "0\n%24.20f %24.20f %24.20f %24.20f\n",
|
|
pnts[segs[j].i1].p.x, pnts[segs[j].i1].p.y,
|
|
pnts[segs[j].i2].p.x, pnts[segs[j].i2].p.y);
|
|
}
|
|
else if (type == ARC) {
|
|
assert(InArcsList(j));
|
|
fprintf(output, "1\n %24.20f %24.20f %24.20f %24.20f ",
|
|
pnts[arcs[j].i1].p.x, pnts[arcs[j].i1].p.y,
|
|
pnts[arcs[j].i2].p.x, pnts[arcs[j].i2].p.y);
|
|
fprintf(output, "%24.20f %24.20f\n",
|
|
arcs[j].c.x, arcs[j].c.y);
|
|
}
|
|
else if (type == UNKNOWN) {
|
|
fprintf(output, "restart!\n");
|
|
}
|
|
else {
|
|
assert(0 == 1);
|
|
}
|
|
|
|
fclose(output);
|
|
|
|
return;
|
|
}
|
|
|
|
#endif
|