Ignore:
Timestamp:
May 18, 2009, 11:44:11 AM (15 years ago)
Author:
gah
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/vizservers/nanovis/Unirect.cpp

    r1434 r1447  
    144144        } else if ((c == 'u') && (strcmp(string, "units") == 0)) {
    145145            _vUnits = strdup(Tcl_GetString(objv[i+1]));
    146         } else if ((c == 'o') && (strcmp(string, "order") == 0)) {
     146        } else if ((c == 'c') && (strcmp(string, "components") == 0)) {
     147            int n;
     148
     149            if (Tcl_GetIntFromObj(interp, objv[i+1], &n) != TCL_OK) {
     150                return TCL_ERROR;
     151            }
     152            if (n <= 0) {
     153                Tcl_AppendResult(interp, "bad extents value: must be > 0",
     154                                 (char *)NULL);
     155                return TCL_ERROR;
     156            }
     157            _nComponents = n;
     158        } else if ((c == 'a') && (strcmp(string, "axisorder") == 0)) {
    147159            Tcl_Obj **axes;
    148160            int n;
     
    337349        } else if ((c == 'u') && (strcmp(string, "units") == 0)) {
    338350            _vUnits = strdup(Tcl_GetString(objv[i+1]));
    339         } else if ((c == 'e') && (strcmp(string, "extents") == 0)) {
     351        } else if ((c == 'c') && (strcmp(string, "components") == 0)) {
    340352            int n;
    341353
     
    379391    if (_nValues != (_xNum * _yNum * _nComponents)) {
    380392        Tcl_AppendResult(interp,
    381                 "wrong number of values: must be xnum*ynum*extents",
     393                "wrong number of values: must be xnum*ynum*components",
    382394                         (char *)NULL);
     395        fprintf(stderr, "x=%d y=%d c=%d, nv=%d\n",
     396                _xNum, _yNum, _nComponents, _nValues);
    383397        return TCL_ERROR;
    384398    }
     
    642656    }
    643657}
     658
     659bool
     660Rappture::Unirect3d::Convert(Rappture::Unirect2d *dataPtr)
     661{
     662    _initialized = false;
     663
     664    _xValueMin = dataPtr->xValueMin();
     665    _yValueMin = dataPtr->yValueMin();
     666    _zValueMin = 0.0;
     667    _xMin = dataPtr->xMin();
     668    _yMin = dataPtr->yMin();
     669    _zMin = 0.0;
     670    _xMax = dataPtr->xMax();
     671    _yMax = dataPtr->yMax();
     672    _zMax = 0.0;
     673    _xNum = dataPtr->xNum();
     674    _yNum = dataPtr->yNum();
     675    _zNum = 1;
     676    switch (dataPtr->nComponents()) {
     677    case 1:
     678    case 3:
     679        if (_values != NULL) {
     680            delete [] _values;
     681        }
     682        _values = new float[dataPtr->nValues()];
     683        memcpy(_values, dataPtr->values(), dataPtr->nValues());
     684        _nValues = dataPtr->nValues();
     685        _nComponents = dataPtr->nComponents();
     686        break;
     687    case 2:
     688        float *values;
     689        _nValues = 3 * _xNum * _yNum * _zNum;
     690        if (_values != NULL) {
     691            delete [] _values;
     692        }
     693        _values = new float[_nValues];
     694        if (_values == NULL) {
     695            return false;
     696        }
     697        values = dataPtr->values();
     698        size_t i, j;
     699        for(j = i = 0; i < dataPtr->nValues(); i += 2, j+= 3) {
     700            _values[j] = values[i];
     701            _values[j+1] = values[i+1];
     702            _values[j+2] = 0.0f;
     703        }           
     704        _nComponents = 3;
     705        break;
     706    }
     707    return true;
     708}
Note: See TracChangeset for help on using the changeset viewer.