Changeset 4515 for branches


Ignore:
Timestamp:
Jul 16, 2014 4:40:32 PM (10 years ago)
Author:
gah
Message:

add new utilities (squeezer, tweener), update RpDxToVtk?.c, experimental RpDicomToVtk?.c not used yet

Location:
branches/1.3/gui/src
Files:
3 added
3 edited

Legend:

Unmodified
Added
Removed
  • branches/1.3/gui/src/Makefile.in

    r3658 r4515  
    2727CFLAGS          = @CFLAGS@ -fPIC
    2828TCL_VERSION     = @TCL_VERSION@
     29TCLTK_SRCS      = -I../../../runtime/tcl8.4.19/generic -I../../../runtime/tk8.4.19/generic -I../../../runtime/tk8.4.19/unix
    2930TCL_LIB_SPEC    = @TCL_LIB_SPEC@
    3031TK_LIB_SPEC     = @TK_LIB_SPEC@
    3132TK_XLIBSW       = @TK_XLIBSW@
     33VTK_VERSION     = @VTK_VERSION@
     34VTK_TCL_DIR     = @VTK_TCL_DIR@
     35ENABLE_VTK      = @ENABLE_VTK@
     36ENABLE_VTK_DICOM= @ENABLE_VTK_DICOM@
     37VTK_LIB_SPEC    =
    3238
    3339CC_SWITCHES     = $(SHLIB_CFLAGS) $(CFLAGS) $(CFLAGS_DEBUG) $(INCLUDES) $(DEFINES)
     
    3743                  -I$(includedir)
    3844version         = @PACKAGE_VERSION@
    39 DEFINES         = -DPACKAGE_VERSION=\"$(version)\"     
     45DEFINES         = -DPACKAGE_VERSION=\"$(version)\"
    4046
    4147RANLIB          = @RANLIB@
     
    4753
    4854LIBS            = \
    49                 -L$(libdir) $(TCL_LIB_SPEC) $(TK_LIB_SPEC) $(TK_XLIBSW) -lm
     55                -L$(libdir) $(VTK_LIB_SPEC) $(TCL_LIB_SPEC) $(TK_LIB_SPEC) $(TK_XLIBSW) -lm
    5056
    5157OBJS            = \
     
    5460                RpCanvPlacard.o \
    5561                RpDiffview.o \
     62                RpDxToVtk.o \
     63                RpPdbToVtk.o \
    5664                RpReadPoints.o \
    57                 RpDxToVtk.o \
    58                 RpPdbToVtk.o
     65                RpListbox.o \
     66                RpSqueezer.o
     67
     68ifeq ($(ENABLE_VTK),yes)
     69  INCLUDES += -I$(includedir)/vtk-$(VTK_VERSION)
     70  OBJS += RpDicomToVtk.o
     71  VTK_LIB_SPEC += -lvtkIOCore-$(VTK_VERSION) -lvtkIOLegacy-$(VTK_VERSION) -lvtkIOImage-$(VTK_VERSION) -lvtkCommonCore-$(VTK_VERSION)
     72  DEFINES      += -DENABLE_VTK
     73
     74  ifeq ($(ENABLE_VTK_DICOM),yes)
     75    VTK_LIB_SPEC += -lvtkDICOM
     76    DEFINES      += -DENABLE_VTK_DICOM -DUSE_VTK_DICOM_PACKAGE
     77  endif
     78endif
     79
    5980
    6081name            = RapptureGUI$(version)
     
    7394        $(INSTALL) -m 555 $(lib) $(destdir)
    7495
     96RpListbox.o: RpListbox.c
     97        $(CC) $(CC_SWITCHES) $(TCLTK_SRCS) -c $?
    7598.cc.o:
    7699        $(CXX) $(CXX_SWITCHES) -c $?
    77100.c.o:
    78         $(CC) $(CC_SWITCHES)-c $?
     101        $(CC) $(CC_SWITCHES) -c $?
    79102
    80103clean:
  • branches/1.3/gui/src/RapptureGUI_Init.c

    r3658 r4515  
    2525extern Tcl_AppInitProc RpCanvHotspot_Init;
    2626extern Tcl_AppInitProc RpCanvPlacard_Init;
     27extern Tcl_AppInitProc RpDiffview_Init;
     28extern Tcl_AppInitProc RpListbox_Init;
     29extern Tcl_AppInitProc RpReadPoints_Init;
     30extern Tcl_AppInitProc RpSqueezer_Init;
     31
    2732extern Tcl_AppInitProc RpDxToVtk_Init;
    2833extern Tcl_AppInitProc RpPdbToVtk_Init;
    29 extern Tcl_AppInitProc RpDiffview_Init;
    30 extern Tcl_AppInitProc RpReadPoints_Init;
     34#ifdef ENABLE_VTK
     35extern Tcl_AppInitProc RpDicomToVtk_Init;
     36#endif
    3137
    3238#ifdef BUILD_Rappture
     
    4955        return TCL_ERROR;
    5056    }
     57    if (RpListbox_Init(interp) != TCL_OK) {
     58        return TCL_ERROR;
     59    }
     60    if (RpReadPoints_Init(interp) != TCL_OK) {
     61        return TCL_ERROR;
     62    }
     63    if (RpSqueezer_Init(interp) != TCL_OK) {
     64        return TCL_ERROR;
     65    }
     66    if (RpCanvHotspot_Init(interp) != TCL_OK) {
     67        return TCL_ERROR;
     68    }
    5169    if (RpDxToVtk_Init(interp) != TCL_OK) {
    5270        return TCL_ERROR;
     
    5573        return TCL_ERROR;
    5674    }
    57     if (RpReadPoints_Init(interp) != TCL_OK) {
     75#ifdef ENABLE_VTK
     76    if (RpDicomToVtk_Init(interp) != TCL_OK) {
    5877        return TCL_ERROR;
    5978    }
    60     if (RpCanvHotspot_Init(interp) != TCL_OK) {
    61         return TCL_ERROR;
    62     }
     79#endif
    6380    return TCL_OK;
    6481}
  • branches/1.3/gui/src/RpDxToVtk.c

    r3895 r4515  
    7373
    7474        if (p >= endPtr) {
    75             Tcl_AppendResult(interp, "unexpected EOF in reading points",
    76                              (char *)NULL);
     75            Tcl_AppendResult(interp, "unexpected EOF in reading field values",
     76                             (char *)NULL);
     77            free(array);
    7778            return TCL_ERROR;
    7879        }
    7980        value = strtod(p, &nextPtr);
    8081        if (nextPtr == p) {
    81             Tcl_AppendResult(interp, "bad value found in reading points",
    82                              (char *)NULL);
     82            Tcl_AppendResult(interp, "bad value found in reading field values",
     83                             (char *)NULL);
     84            free(array);
    8385            return TCL_ERROR;
    8486        }
     
    122124
    123125        if (p >= endPtr) {
    124             Tcl_AppendResult(interp, "unexpected EOF in reading points",
    125                              (char *)NULL);
     126            Tcl_AppendResult(interp, "unexpected EOF in reading field values",
     127                             (char *)NULL);
     128            free(array);
    126129            return TCL_ERROR;
    127130        }
    128131        value = strtod(p, &nextPtr);
    129132        if (nextPtr == p) {
    130             Tcl_AppendResult(interp, "bad value found in reading points",
    131                              (char *)NULL);
     133            Tcl_AppendResult(interp, "bad value found in reading field values",
     134                             (char *)NULL);
     135            free(array);
    132136            return TCL_ERROR;
    133137        }
     
    169173
    170174        if (p >= endPtr) {
    171             Tcl_AppendResult(interp, "unexpected EOF in reading points",
    172                              (char *)NULL);
     175            Tcl_AppendResult(interp, "unexpected EOF in reading field values",
     176                             (char *)NULL);
     177            free(array);
    173178            return TCL_ERROR;
    174179        }
    175180        value = strtod(p, &nextPtr);
    176181        if (nextPtr == p) {
    177             Tcl_AppendResult(interp, "bad value found in reading points",
    178                              (char *)NULL);
     182            Tcl_AppendResult(interp, "bad value found in reading field values",
     183                             (char *)NULL);
     184            free(array);
    179185            return TCL_ERROR;
    180186        }
     
    246252    return TCL_OK;
    247253}
     254
     255static int
     256GetUniformFieldVectors(Tcl_Interp *interp, int nPoints, int *counts,
     257                       char **stringPtr, const char *endPtr, Tcl_Obj *objPtr)
     258{
     259    int i;
     260    const char *p;
     261    char mesg[2000];
     262    double *array;
     263    int iX, iY, iZ;
     264
     265    p = *stringPtr;
     266    array = malloc(sizeof(double) * nPoints * 3);
     267    if (array == NULL) {
     268        return TCL_ERROR;
     269    }
     270    iX = iY = iZ = 0;
     271    for (i = 0; i < nPoints; i++) {
     272        double x, y, z;
     273        char *nextPtr;
     274        int loc;
     275
     276        if (p >= endPtr) {
     277            Tcl_AppendResult(interp, "unexpected EOF in reading vectors",
     278                             (char *)NULL);
     279            free(array);
     280            return TCL_ERROR;
     281        }
     282        x = strtod(p, &nextPtr);
     283        if (nextPtr == p) {
     284            Tcl_AppendResult(interp, "bad value found in reading vectors",
     285                             (char *)NULL);
     286            free(array);
     287            return TCL_ERROR;
     288        }
     289        p = nextPtr;
     290        y = strtod(p, &nextPtr);
     291        if (nextPtr == p) {
     292            Tcl_AppendResult(interp, "bad value found in reading vectors",
     293                             (char *)NULL);
     294            free(array);
     295            return TCL_ERROR;
     296        }
     297        p = nextPtr;
     298        z = strtod(p, &nextPtr);
     299        if (nextPtr == p) {
     300            Tcl_AppendResult(interp, "bad value found in reading vectors",
     301                             (char *)NULL);
     302            free(array);
     303            return TCL_ERROR;
     304        }
     305        p = nextPtr;
     306        loc = iZ*counts[0]*counts[1] + iY*counts[0] + iX;
     307        if (++iZ >= counts[2]) {
     308            iZ = 0;
     309            if (++iY >= counts[1]) {
     310                iY = 0;
     311                ++iX;
     312            }
     313        }
     314        array[loc*3  ] = x;
     315        array[loc*3+1] = y;
     316        array[loc*3+2] = z;
     317    }
     318    for (i = 0; i < nPoints; i++) {
     319        sprintf(mesg, "%g %g %g\n", array[i*3], array[i*3+1], array[i*3+2]);
     320        Tcl_AppendToObj(objPtr, mesg, -1);
     321    }
     322    free(array);
     323    *stringPtr = (char *)p;
     324    return TCL_OK;
     325}
     326
    248327#if defined(DO_WEDGES) && defined(CHECK_WINDINGS)
    249328static void
     
    301380    int isUniform;
    302381    int isStructuredGrid;
     382    int hasVectors;
    303383    int i, ix, iy, iz;
    304384
     
    312392    dv2[0] = dv2[1] = dv2[2] = 0.0;
    313393    count[0] = count[1] = count[2] = 0; /* Suppress compiler warning. */
    314     isUniform = 1; /* Default to expecting uniform grid */
     394    isUniform = 0;
    315395    isStructuredGrid = 0;
     396    hasVectors = 0;
    316397
    317398    if (objc != 2) {
     
    324405        string += 5;
    325406        length -= 5;
     407    } else if (strncmp("<DX>", string, 4) == 0) {
     408        string += 4;
     409        length -= 4;
    326410    }
    327411    pointsObjPtr = Tcl_NewStringObj("", -1);
     
    414498                          &count[2]) == 1) {
    415499            // Z grid
     500            isUniform = 0;
     501        } else if (sscanf(line, "object %*d class array type %*s shape 3 rank 1"
     502                          " items %d data follows", &nPoints) == 1) {
     503#ifdef notdef
     504                fprintf(stderr, "found class array type shape 3 nPoints=%d\n",
     505                        nPoints);
     506#endif
     507            if (isUniform) {
     508                hasVectors = 1;
     509                if (GetUniformFieldVectors(interp, nPoints, count, &p, pend, fieldObjPtr)
     510                    != TCL_OK) {
     511                    return TCL_ERROR;
     512                }
     513            } else {
     514                // This is a 2D point cloud in xy with a uniform zgrid
     515                isUniform = 0;
     516                nXYPoints = nPoints;
     517                if (nXYPoints < 0) {
     518                    sprintf(mesg, "bad # points %d", nXYPoints);
     519                    Tcl_AppendResult(interp, mesg, (char *)NULL);
     520                    return TCL_ERROR;
     521                }
     522                points = malloc(sizeof(double) * nXYPoints * 2);
     523                if (GetPoints(interp, points, nXYPoints, &p, pend) != TCL_OK) {
     524                    return TCL_ERROR;
     525                }
     526            }
    416527        } else if (sscanf(line, "object %*d class array type %*s rank 1 shape 3"
    417                           " items %d data follows", &nXYPoints) == 1) {
    418             // This is a 2D point cloud in xy with a uniform zgrid
    419             isUniform = 0;
     528                          " items %d data follows", &nPoints) == 1) {
    420529#ifdef notdef
    421             fprintf(stderr, "found class array type shape 3 nPoints=%d\n",
    422                     nPoints);
    423 #endif
    424             if (nXYPoints < 0) {
    425                 sprintf(mesg, "bad # points %d", nXYPoints);
    426                 Tcl_AppendResult(interp, mesg, (char *)NULL);
    427                 return TCL_ERROR;
    428             }
    429             points = malloc(sizeof(double) * nXYPoints * 2);
    430             if (GetPoints(interp, points, nXYPoints, &p, pend) != TCL_OK) {
    431                 return TCL_ERROR;
     530                fprintf(stderr, "found class array type shape 3 nPoints=%d\n",
     531                        nPoints);
     532#endif
     533            if (isUniform) {
     534                hasVectors = 1;
     535                if (GetUniformFieldVectors(interp, nPoints, count, &p, pend, fieldObjPtr)
     536                    != TCL_OK) {
     537                    return TCL_ERROR;
     538                }
     539            } else {
     540                // This is a 2D point cloud in xy with a uniform zgrid
     541                isUniform = 0;
     542                nXYPoints = nPoints;
     543                if (nXYPoints < 0) {
     544                    sprintf(mesg, "bad # points %d", nXYPoints);
     545                    Tcl_AppendResult(interp, mesg, (char *)NULL);
     546                    return TCL_ERROR;
     547                }
     548                points = malloc(sizeof(double) * nXYPoints * 2);
     549                if (GetPoints(interp, points, nXYPoints, &p, pend) != TCL_OK) {
     550                    return TCL_ERROR;
     551                }
    432552            }
    433553        } else if (sscanf(line, "object %*d class array type %*s rank 0"
     
    488608        sprintf(mesg, "POINT_DATA %d\n", nPoints);
    489609        Tcl_AppendToObj(objPtr, mesg, -1);
    490         sprintf(mesg, "SCALARS %s double 1\n", name);
    491         Tcl_AppendToObj(objPtr, mesg, -1);
    492         sprintf(mesg, "LOOKUP_TABLE default\n");
    493         Tcl_AppendToObj(objPtr, mesg, -1);
     610        if (hasVectors) {
     611            sprintf(mesg, "VECTORS %s double\n", name);
     612            Tcl_AppendToObj(objPtr, mesg, -1);
     613        } else {
     614            sprintf(mesg, "SCALARS %s double 1\n", name);
     615            Tcl_AppendToObj(objPtr, mesg, -1);
     616            sprintf(mesg, "LOOKUP_TABLE default\n");
     617            Tcl_AppendToObj(objPtr, mesg, -1);
     618        }
    494619        Tcl_AppendObjToObj(objPtr, fieldObjPtr);
    495620    } else if (isStructuredGrid) {
Note: See TracChangeset for help on using the changeset viewer.