#define PROG_NAME "TestCurvature" #define PROG_DESC "???" #define PROG_VERS "1.0" #define TestCurvature_C_COPYRIGHT \ "" #define PROG_INFO \ "" \ " " /* This module generates two symetric random variations of a given ".st" file, for submit to the TestEnergy procedure. */ #include #include #include #include #define _GNU_SOURCE #include #include // #include TYPE typedef struct Options_t { char *inFileTp; /* Input file name (topology) */ char *inFileSt; /* Input file name (state) */ char *output; /* Output file name prefix */ char *magnitude; /* for indicate how constructs the random conf. */ REAL jitter; /* Magnitude of random perturbation */ bool_t normalize; /* TRUE to normalize the node coordinates */ } Options_t *GetOptions(int argc, char **argv); int main(int argc, char **argv) { Options_t *o = GetOptions(argc, argv); char *topo_cmt = jsprintf("Created by %s on %s", PROG_NAME, Today()); /* Random_t coins = MakeRandomSource(4615); */ ??? coins = NEW(Random.Default).init(TRUE); ??? tc = Triangulation.ReadToMa(o->inFileTp); ??? top = tc.top; ??? rc = Triangulation.ReadState(o->inFileSt); ??? cOld = rc^; ??? cNew = NEW(REF Coords_t; with ( top->node.nel)^, double cmt = " Random variation : " & o->magnitude & "\n" \ " Randomizing from: " & o->inFileSt & ".st\n" & " Created by TestCurvature: " & o->output & ".st\n" ){ if (o->normalize) { Triangulation.NormalizeNodeDistance(top, cOld) } cNew = cOld; PerturbCoords(top, cNew, coins, ((double)o->jitter), o->magnitude); if (o->normalize) { Triangulation.NormalizeNodeDistance(top, cNew) } WriteState(o->output, top, cNew,cmt); return 0; } PROCEDURE PerturbCoords(ElemTableRec_t *top, Coords_t *c, rand_t *coins; double jitter; char *magnitude; ) { for (i = 0 TO (c.nel-1)){ if ((OrgV(top->node.el[i])->exists) && (NOT top->node[i].fixed)) { ??? ci = c[i]; with ( double p = (r4_t) { jitter * coins.longreal(-1.0, +1.0), jitter * coins.longreal(-1.0, +1.0), jitter * coins.longreal(-1.0, +1.0), jitter * coins.longreal(-1.0, +1.0) } ){ if (0 == strcmp(magnitude,"+"))) { ci = r4_Add(ci, p); } else { ci = r4_Sub(ci, p); } } } } } /* END PerturbCoords */ Options_t *GetOptions(int argc, char **argv) { Options_t *o = (Options_t *)malloc(sizeof(Options_t)); argparser_t *pp = argparser_new(stderr, argc, argv); argparser_set_help(pp, PROG_NAME " version " PROG_VERS ", usage:\n" PROG_HELP); argparser_set_info(pp, PROG_INFO); argparser_process_help_info_options(pp); { ¦TRY argparser_get_keyword(pp, "-inFileTp"); o->inFileTp = argparser_get_next(pp); argparser_get_keyword(pp, "-inFileSt"); o->inFileSt = argparser_get_next(pp); argparser_get_keyword(pp, "-output"); o->output = argparser_get_next(pp); argparser_get_keyword(pp, "-magnitude"); o->magnitude = argparser_get_next(pp); o->normalize = argparser_keyword_present(pp, "-normalize"); if ((argparser_keyword_present(pp, "-jitter"))) { o->jitter = pp.getNextReal(0.0); } else { o->jitter = 1.0 } argparser_finish(pp); ----------------------------------- #define _HELP \ fprintf(stderr, "Usage: TestCurvature \\\n" \ " -inFileTp -inFileSt \\\n" \ " -output -magnitude < + | - > \\\n" \ " [ -normalize ] [ -jitter ]\n"); END¦ } } return o; } /* END GetOptions */ { DoIt() } TestCurvature. /* Copyright © 2000 Universidade Estadual de Campinas (UNICAMP) */