[0b990d] | 1 | //
|
---|
| 2 | // isotest.cc
|
---|
| 3 | //
|
---|
| 4 | // Copyright (C) 1996 Limit Point Systems, Inc.
|
---|
| 5 | //
|
---|
| 6 | // Author: Curtis Janssen <cljanss@limitpt.com>
|
---|
| 7 | // Maintainer: LPS
|
---|
| 8 | //
|
---|
| 9 | // This file is part of the SC Toolkit.
|
---|
| 10 | //
|
---|
| 11 | // The SC Toolkit is free software; you can redistribute it and/or modify
|
---|
| 12 | // it under the terms of the GNU Library General Public License as published by
|
---|
| 13 | // the Free Software Foundation; either version 2, or (at your option)
|
---|
| 14 | // any later version.
|
---|
| 15 | //
|
---|
| 16 | // The SC Toolkit is distributed in the hope that it will be useful,
|
---|
| 17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 19 | // GNU Library General Public License for more details.
|
---|
| 20 | //
|
---|
| 21 | // You should have received a copy of the GNU Library General Public License
|
---|
| 22 | // along with the SC Toolkit; see the file COPYING.LIB. If not, write to
|
---|
| 23 | // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
| 24 | //
|
---|
| 25 | // The U.S. Government is granted a limited license as per AL 91-7.
|
---|
| 26 | //
|
---|
| 27 |
|
---|
| 28 | extern "C" {
|
---|
| 29 | #include <math.h>
|
---|
| 30 | #ifdef SGI
|
---|
| 31 | #include <sigfpe.h>
|
---|
| 32 | #endif // SGI
|
---|
| 33 | }
|
---|
| 34 |
|
---|
| 35 | #include <util/misc/ieee.h>
|
---|
| 36 | #include <util/misc/formio.h>
|
---|
| 37 |
|
---|
| 38 | #include <util/keyval/keyval.h>
|
---|
| 39 | #include <math/isosurf/volume.h>
|
---|
| 40 | #include <math/isosurf/shape.h>
|
---|
| 41 | #include <math/isosurf/surf.h>
|
---|
| 42 | #include <math/isosurf/isosurf.h>
|
---|
| 43 |
|
---|
| 44 | using namespace std;
|
---|
| 45 | using namespace sc;
|
---|
| 46 |
|
---|
| 47 | // Force linkages:
|
---|
| 48 | #ifndef __PIC__
|
---|
| 49 | static ForceLink<SphereShape> fl0;
|
---|
| 50 | static ForceLink<TriangulatedImplicitSurface> fl1;
|
---|
| 51 | #endif
|
---|
| 52 |
|
---|
| 53 | main(int argc,char** argv)
|
---|
| 54 | {
|
---|
| 55 | ieee_trap_errors();
|
---|
| 56 |
|
---|
| 57 | // The first argument is the input filename. If it doesn't
|
---|
| 58 | // exist or is a '.', then the default ioput file is used.
|
---|
| 59 | const char *defaultinput = SRCDIR "/isotest.in";
|
---|
| 60 | const char *input;
|
---|
| 61 | if (argc == 1 || !strcmp(argv[1], ".")) input = defaultinput;
|
---|
| 62 | else input = argv[1];
|
---|
| 63 |
|
---|
| 64 | const char *keyword = (argc > 2)? argv[2] : "surf";
|
---|
| 65 |
|
---|
| 66 | // open keyval input
|
---|
| 67 | Ref<KeyVal> rpkv(new ParsedKeyVal(input));
|
---|
| 68 |
|
---|
| 69 | Ref<TriangulatedSurface> surf;
|
---|
| 70 | surf << rpkv->describedclassvalue(keyword);
|
---|
| 71 |
|
---|
| 72 | cout << scprintf("surf->flat_area() = %f\n", surf->flat_area());
|
---|
| 73 | cout << scprintf("surf->flat_volume() = %f\n", surf->flat_volume());
|
---|
| 74 |
|
---|
| 75 | cout << scprintf("surf->area() = %f\n", surf->area());
|
---|
| 76 | cout << scprintf("surf->volume() = %f\n", surf->volume());
|
---|
| 77 |
|
---|
| 78 | for (int order=1; order<4; order++) {
|
---|
| 79 | cout << scprintf("order = %d", order) << endl;
|
---|
| 80 | int nir = 4;
|
---|
| 81 | for (int ir=0; ir<nir; ir++) {
|
---|
| 82 | double r = double(ir)/(nir-1);
|
---|
| 83 | double s = 1.0 - r;
|
---|
| 84 | cout << scprintf(" r = %6.4f, s = %6.4f", r, s) << endl;
|
---|
| 85 | TriInterpCoefKey key(order, r, s);
|
---|
| 86 | Ref<TriInterpCoef> coef = new TriInterpCoef(key);
|
---|
| 87 | for (int i=0; i<=order; i++) {
|
---|
| 88 | for (int j=0; j+i<=order; j++) {
|
---|
| 89 | int k = order - i - j;
|
---|
| 90 | cout << scprintf(" coef(%d,%d,%d) = %12.8f",
|
---|
| 91 | i,j,k,coef->coef(i,j,k))
|
---|
| 92 | << endl;
|
---|
| 93 | }
|
---|
| 94 | }
|
---|
| 95 | }
|
---|
| 96 | }
|
---|
| 97 |
|
---|
| 98 | return 0;
|
---|
| 99 | }
|
---|
| 100 |
|
---|
| 101 | /////////////////////////////////////////////////////////////////////////////
|
---|
| 102 |
|
---|
| 103 | // Local Variables:
|
---|
| 104 | // mode: c++
|
---|
| 105 | // c-file-style: "CLJ"
|
---|
| 106 | // End:
|
---|