[37] | 1 | /* |
---|
| 2 | |
---|
| 3 | Brian Curless |
---|
| 4 | |
---|
| 5 | Computer Graphics Laboratory |
---|
| 6 | Stanford University |
---|
| 7 | |
---|
| 8 | --------------------------------------------------------------------- |
---|
| 9 | |
---|
| 10 | Copyright (1997) The Board of Trustees of the Leland Stanford Junior |
---|
| 11 | University. Except for commercial resale, lease, license or other |
---|
| 12 | commercial transactions, permission is hereby given to use, copy, |
---|
| 13 | modify this software for academic purposes only. No part of this |
---|
| 14 | software or any derivatives thereof may be used in the production of |
---|
| 15 | computer models for resale or for use in a commercial |
---|
| 16 | product. STANFORD MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND |
---|
| 17 | CONCERNING THIS SOFTWARE. No support is implied or provided. |
---|
| 18 | |
---|
| 19 | */ |
---|
| 20 | |
---|
| 21 | |
---|
| 22 | #include "vripAux.h" |
---|
| 23 | #include "vripGlobals.h" |
---|
| 24 | |
---|
| 25 | |
---|
| 26 | void |
---|
| 27 | expandVaryingFromConstant(OccGridRLE *inGrid, OccGridRLE *outGrid) |
---|
| 28 | { |
---|
| 29 | int i; |
---|
| 30 | RunLength length, len; |
---|
| 31 | int runType; |
---|
| 32 | OccElement *element; |
---|
| 33 | |
---|
| 34 | outGrid->copyParams(inGrid); |
---|
| 35 | outGrid->reset(); |
---|
| 36 | for (int zz = 0; zz < inGrid->zdim; zz++) { |
---|
| 37 | for (int yy = 0; yy < inGrid->ydim; yy++) { |
---|
| 38 | inGrid->setScanline(yy,zz); |
---|
| 39 | outGrid->allocNewRun(yy,zz); |
---|
| 40 | |
---|
| 41 | while (TRUE) { |
---|
| 42 | length = inGrid->getNextLength(); |
---|
| 43 | runType = inGrid->getRunType(&length); |
---|
| 44 | |
---|
| 45 | if (runType == OccGridRLE::END_OF_RUN) { |
---|
| 46 | inGrid->setRunType(&length, OccGridRLE::END_OF_RUN); |
---|
| 47 | outGrid->putNextLength(length); |
---|
| 48 | break; |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | if (runType == OccGridRLE::CONSTANT_DATA) { |
---|
| 52 | element = inGrid->getNextElement(); |
---|
| 53 | len = 1; |
---|
| 54 | inGrid->setRunType(&len, OccGridRLE::VARYING_DATA); |
---|
| 55 | outGrid->putNextLength(len); |
---|
| 56 | outGrid->putNextElement(element); |
---|
| 57 | |
---|
| 58 | if (length > 2) { |
---|
| 59 | len = length - 2; |
---|
| 60 | inGrid->setRunType(&len, OccGridRLE::CONSTANT_DATA); |
---|
| 61 | outGrid->putNextLength(len); |
---|
| 62 | outGrid->putNextElement(element); |
---|
| 63 | } |
---|
| 64 | |
---|
| 65 | if (length >= 2) { |
---|
| 66 | len = 1; |
---|
| 67 | inGrid->setRunType(&len, OccGridRLE::VARYING_DATA); |
---|
| 68 | outGrid->putNextLength(len); |
---|
| 69 | outGrid->putNextElement(element); |
---|
| 70 | } |
---|
| 71 | } |
---|
| 72 | else { |
---|
| 73 | len = length; |
---|
| 74 | inGrid->setRunType(&len, OccGridRLE::VARYING_DATA); |
---|
| 75 | outGrid->putNextLength(len); |
---|
| 76 | for (i=0; i<length; i++) { |
---|
| 77 | element = inGrid->getNextElement(); |
---|
| 78 | outGrid->putNextElement(element); |
---|
| 79 | } |
---|
| 80 | } |
---|
| 81 | } |
---|
| 82 | } |
---|
| 83 | } |
---|
| 84 | } |
---|
| 85 | |
---|
| 86 | |
---|
| 87 | void |
---|
| 88 | swapgrids() |
---|
| 89 | { |
---|
| 90 | OccGridRLE *tempRLE; |
---|
| 91 | tempRLE = backRLEGrid; |
---|
| 92 | backRLEGrid = frontRLEGrid; |
---|
| 93 | frontRLEGrid = tempRLE; |
---|
| 94 | |
---|
| 95 | OccGridNormRLE *tempNormRLE; |
---|
| 96 | tempNormRLE = backRLEGridNorm; |
---|
| 97 | backRLEGridNorm = frontRLEGridNorm; |
---|
| 98 | frontRLEGridNorm = tempNormRLE; |
---|
| 99 | } |
---|
| 100 | |
---|