[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 | #ifndef _DEPTH_MAP_ |
---|
| 23 | #define _DEPTH_MAP_ |
---|
| 24 | |
---|
| 25 | #include "vrip.h" |
---|
| 26 | |
---|
| 27 | struct DepthElement { |
---|
| 28 | float z; |
---|
| 29 | float conf; |
---|
| 30 | }; |
---|
| 31 | |
---|
| 32 | |
---|
| 33 | struct DepthTreeElement { |
---|
| 34 | float minZ; |
---|
| 35 | float maxZ; |
---|
| 36 | }; |
---|
| 37 | |
---|
| 38 | |
---|
| 39 | struct DepthMapNorm { |
---|
| 40 | signed char nx; |
---|
| 41 | signed char ny; |
---|
| 42 | signed char nz; |
---|
| 43 | }; |
---|
| 44 | |
---|
| 45 | |
---|
| 46 | class DepthMap { |
---|
| 47 | |
---|
| 48 | public: |
---|
| 49 | enum {TRIANGLE_ONE=0x1, TRIANGLE_TWO=0x2, |
---|
| 50 | TRIANGLE_THREE=0x4, TRIANGLE_FOUR=0x8}; |
---|
| 51 | |
---|
| 52 | int xdim; |
---|
| 53 | int ydim; |
---|
| 54 | float resolution; |
---|
| 55 | vec2f origin; |
---|
| 56 | DepthElement *elems; |
---|
| 57 | uchar *tags; |
---|
| 58 | DepthMapNorm *norms; |
---|
| 59 | signed char *edgeSteps; |
---|
| 60 | DepthTreeElement ***treeElems; |
---|
| 61 | DepthTreeElement ***holeTreeElems; |
---|
| 62 | int *leafIndices; |
---|
| 63 | int *runs; |
---|
| 64 | int treeDepth; |
---|
| 65 | int treeGranularity; |
---|
| 66 | |
---|
| 67 | int origTreeDepth; |
---|
| 68 | int origXdim; |
---|
| 69 | int origYdim; |
---|
| 70 | |
---|
| 71 | int linePersp; |
---|
| 72 | int perspective; |
---|
| 73 | |
---|
| 74 | DepthMap(); |
---|
| 75 | DepthMap(int,int,int); |
---|
| 76 | DepthMap(int,int,int,int); |
---|
| 77 | |
---|
| 78 | ~DepthMap(); |
---|
| 79 | |
---|
| 80 | void tagCellsForResampling(); |
---|
| 81 | int writePly(const char*, float noiseLevel); |
---|
| 82 | void updateNx(); |
---|
| 83 | void updateNy(); |
---|
| 84 | void updateNz(); |
---|
| 85 | void updateEdgeSteps(); |
---|
| 86 | void normalize(); |
---|
| 87 | int reuse(int xd, int yd); |
---|
| 88 | void initTree(int granularity); |
---|
| 89 | void fillTree(int numLines); |
---|
| 90 | void pullUpTree(int y, int level); |
---|
| 91 | int * getDepthRuns(float y, float zmin, float zmax, int *numRuns); |
---|
| 92 | void consolidateRuns(int *leafIndices, int numLeaves, int *numRuns); |
---|
| 93 | void traverseTree(int y, int level, int off, float zmin, float zmax, |
---|
| 94 | int *leafIndices, int *numLeaves); |
---|
| 95 | int *getDepthRunsUpperBound(float y, float zmax, int *numRuns); |
---|
| 96 | void traverseTreeUpperBound(int y, int level, int off, float zmax, |
---|
| 97 | int *leafIndices, int *numLeaves); |
---|
| 98 | int *getDepthRunsEdges(float y, float zmax, int *numRuns); |
---|
| 99 | void traverseTreeEdges(int y, int level, int off, float zmax, |
---|
| 100 | int *leafIndices, int *numLeaves); |
---|
| 101 | }; |
---|
| 102 | |
---|
| 103 | |
---|
| 104 | #endif |
---|