Merge with latest master

This commit is contained in:
GPayne
2020-02-19 09:25:33 -07:00
parent 79a3b42d06
commit addfa65fa6
230 changed files with 1151 additions and 2270 deletions

View File

@@ -70,7 +70,8 @@ BrickSelection BrickSelection::splitTemporally(bool t, unsigned int childBrickIn
if (t) {
child.lowT = centerT();
child.highT = highT;
} else {
}
else {
child.lowT = lowT;
child.highT = centerT();
}

View File

@@ -117,7 +117,8 @@ bool ErrorHistogramManager::buildFromLeaf(unsigned int bstOffset,
_histograms[innerNodeIndex] = Histogram(_minBin, _maxBin, _numBins);
ancestorVoxels = readValues(ancestorBrickIndex);
_voxelCache[innerNodeIndex] = ancestorVoxels;
} else {
}
else {
ancestorVoxels = it->second;
}
@@ -289,7 +290,8 @@ const Histogram* ErrorHistogramManager::histogram(unsigned int brickIndex) const
const unsigned int innerNodeIndex = brickToInnerNodeIndex(brickIndex);
if (innerNodeIndex < _numInnerNodes) {
return &(_histograms[innerNodeIndex]);
} else {
}
else {
return nullptr;
}
}

View File

@@ -64,7 +64,8 @@ bool HistogramManager::buildHistogram(TSP* tsp, unsigned int brickIndex) {
for (size_t v = 0; v < numVoxels; ++v) {
histogram.add(voxelValues[v], 1.0);
}
} else {
}
else {
// Has children
std::vector<unsigned int> children;
@@ -89,7 +90,8 @@ bool HistogramManager::buildHistogram(TSP* tsp, unsigned int brickIndex) {
// If node has both BST and Octree children, only add BST ones
histogram.add(_histograms[childIndex]);
}
} else {
}
else {
return false;
}
}

View File

@@ -129,12 +129,14 @@ bool LocalErrorHistogramManager::buildFromOctreeChild(unsigned int bstOffset,
if (isOctreeLeaf) {
childValues = readValues(childIndex);
} else {
}
else {
const unsigned int childInnerNodeIndex = brickToInnerNodeIndex(childIndex);
auto it = _voxelCache.find(childInnerNodeIndex);
if (it != _voxelCache.end()) {
childValues = it->second;
} else {
}
else {
LERROR(fmt::format(
"Child {} visited without cache, {}, {}",
childIndex,
@@ -149,11 +151,13 @@ bool LocalErrorHistogramManager::buildFromOctreeChild(unsigned int bstOffset,
if (octreeChildIndex == 0) {
parentValues = readValues(parentIndex);
_voxelCache[parentInnerNodeIndex] = parentValues;
} else {
}
else {
auto it = _voxelCache.find(parentInnerNodeIndex);
if (it != _voxelCache.end()) {
parentValues = it->second;
} else {
}
else {
LERROR(fmt::format("Parent {} visited without cache", parentIndex));
return false;
}
@@ -231,12 +235,14 @@ bool LocalErrorHistogramManager::buildFromBstChild(unsigned int bstOffset,
if (isBstLeaf) {
childValues = readValues(childIndex);
} else {
}
else {
unsigned int childInnerNodeIndex = brickToInnerNodeIndex(childIndex);
auto it = _voxelCache.find(childInnerNodeIndex);
if (it != _voxelCache.end()) {
childValues = it->second;
} else {
}
else {
LERROR(fmt::format("Child {} visited without cache", childIndex));
return false;
}
@@ -246,11 +252,13 @@ bool LocalErrorHistogramManager::buildFromBstChild(unsigned int bstOffset,
if (bstChildIndex == 1) {
parentValues = readValues(parentIndex);
_voxelCache[parentInnerNodeIndex] = parentValues;
} else {
}
else {
auto it = _voxelCache.find(parentInnerNodeIndex);
if (it != _voxelCache.end()) {
parentValues = it->second;
} else {
}
else {
LERROR(fmt::format("Parent {} visited without cache", parentIndex));
return false;
}
@@ -433,7 +441,8 @@ const Histogram* LocalErrorHistogramManager::spatialHistogram(
const unsigned int innerNodeIndex = brickToInnerNodeIndex(brickIndex);
if (innerNodeIndex < _numInnerNodes) {
return &(_spatialHistograms[innerNodeIndex]);
} else {
}
else {
return nullptr;
}
}
@@ -444,7 +453,8 @@ const Histogram* LocalErrorHistogramManager::temporalHistogram(
const unsigned int innerNodeIndex = brickToInnerNodeIndex(brickIndex);
if (innerNodeIndex < _numInnerNodes) {
return &(_temporalHistograms[innerNodeIndex]);
} else {
}
else {
return nullptr;
}
}

View File

@@ -82,7 +82,8 @@ void LocalTfBrickSelector::selectBricks(int timestep, std::vector<int>& bricks)
if (splitType != BrickSelection::SplitType::None) {
priorityQueue.push_back(brickSelection);
} else {
}
else {
leafSelections.push_back(brickSelection);
}
@@ -135,10 +136,12 @@ void LocalTfBrickSelector::selectBricks(int timestep, std::vector<int>& bricks)
priorityQueue.end(),
compareSplitPoints
);
} else {
}
else {
leafSelections.push_back(childSelection);
}
} else if (bs.splitType == BrickSelection::SplitType::Spatial) {
}
else if (bs.splitType == BrickSelection::SplitType::Spatial) {
nBricksInMemory += 7; // Remove one and add eight.
const unsigned int firstChild = _tsp->firstOctreeChild(brickIndex);
@@ -156,7 +159,8 @@ void LocalTfBrickSelector::selectBricks(int timestep, std::vector<int>& bricks)
}
if (bs.splitPoints > -1) {
temporalSplitQueue.push_back(bs);
} else {
}
else {
deadEnds.push_back(bs);
}
break;
@@ -187,7 +191,8 @@ void LocalTfBrickSelector::selectBricks(int timestep, std::vector<int>& bricks)
priorityQueue.end(),
compareSplitPoints
);
} else {
}
else {
leafSelections.push_back(childSelection);
}
}
@@ -210,7 +215,8 @@ void LocalTfBrickSelector::selectBricks(int timestep, std::vector<int>& bricks)
temporalSplitQueue.end(),
compareSplitPoints
);
} else {
}
else {
deadEnds.push_back(bs);
}
}
@@ -241,7 +247,8 @@ void LocalTfBrickSelector::selectBricks(int timestep, std::vector<int>& bricks)
if (pickRightTimeChild) {
childBrickIndex = _tsp->bstRight(brickIndex);
} else {
}
else {
childBrickIndex = _tsp->bstLeft(brickIndex);
}
@@ -260,7 +267,8 @@ void LocalTfBrickSelector::selectBricks(int timestep, std::vector<int>& bricks)
temporalSplitQueue.end(),
compareSplitPoints
);
} else {
}
else {
BrickSelection childSelection = bs.splitTemporally(
pickRightTimeChild,
childBrickIndex,
@@ -270,7 +278,8 @@ void LocalTfBrickSelector::selectBricks(int timestep, std::vector<int>& bricks)
deadEnds.push_back(childSelection);
}
}
} else {
}
else {
// Write selected inner nodes to brickSelection vector
for (const BrickSelection& bs : priorityQueue) {
writeSelection(bs, bricks);
@@ -316,10 +325,12 @@ float LocalTfBrickSelector::splitPoints(unsigned int brickIndex,
if (spatialPoints > 0 && spatialPoints > temporalPoints) {
splitPoints = spatialPoints;
splitType = BrickSelection::SplitType::Spatial;
} else if (temporalPoints > 0) {
}
else if (temporalPoints > 0) {
splitPoints = temporalPoints;
splitType = BrickSelection::SplitType::Temporal;
} else {
}
else {
splitPoints = -1;
splitType = BrickSelection::SplitType::None;
}
@@ -354,7 +365,8 @@ bool LocalTfBrickSelector::calculateBrickErrors() {
for (unsigned int brickIndex = 0; brickIndex < nHistograms; brickIndex++) {
if (_tsp->isOctreeLeaf(brickIndex)) {
_brickErrors[brickIndex].spatial = 0.0;
} else {
}
else {
const Histogram* histogram = _histogramManager->spatialHistogram(
brickIndex
);
@@ -371,7 +383,8 @@ bool LocalTfBrickSelector::calculateBrickErrors() {
if (_tsp->isBstLeaf(brickIndex)) {
_brickErrors[brickIndex].temporal = 0.0;
} else {
}
else {
const Histogram* histogram = _histogramManager->temporalHistogram(
brickIndex
);

View File

@@ -221,7 +221,8 @@ RenderableMultiresVolume::RenderableMultiresVolume(const ghoul::Dictionary& dict
_startTime = SpiceManager::ref().ephemerisTimeFromDate(startTimeString);
_endTime = SpiceManager::ref().ephemerisTimeFromDate(endTimeString);
_loop = false;
} else {
}
else {
_loop = true;
LWARNING("Node does not provide time information. Viewing one image / frame");
}
@@ -268,9 +269,11 @@ RenderableMultiresVolume::RenderableMultiresVolume(const ghoul::Dictionary& dict
std::string selectorName = _selectorName;
if (selectorName == "simple") {
_selector = Selector::SIMPLE;
} else if (selectorName == "local") {
}
else if (selectorName == "local") {
_selector = Selector::LOCAL;
} else {
}
else {
_selector = Selector::TF;
}
@@ -280,11 +283,14 @@ RenderableMultiresVolume::RenderableMultiresVolume(const ghoul::Dictionary& dict
std::string newSelectorName = _selectorName;
if (newSelectorName == "simple") {
s = Selector::SIMPLE;
} else if (newSelectorName == "local") {
}
else if (newSelectorName == "local") {
s = Selector::LOCAL;
} else if (newSelectorName == "tf") {
}
else if (newSelectorName == "tf") {
s = Selector::TF;
} else {
}
else {
return;
}
setSelectorType(s);
@@ -474,13 +480,15 @@ bool RenderableMultiresVolume::initializeSelector() {
fmt::format("Loading histograms from cache: {}", cacheFilename)
);
success &= _errorHistogramManager->loadFromFile(cacheFilename);
} else if (_errorHistogramsPath != "") {
}
else if (_errorHistogramsPath != "") {
// Read histograms from scene data.
LINFO(fmt::format(
"Loading histograms from scene data: {}", _errorHistogramsPath
));
success &= _errorHistogramManager->loadFromFile(_errorHistogramsPath);
} else {
}
else {
// Build histograms from tsp file.
LWARNING(fmt::format("Failed to open {}", cacheFilename));
success &= _errorHistogramManager->buildHistograms(nHistograms);
@@ -510,7 +518,8 @@ bool RenderableMultiresVolume::initializeSelector() {
cacheFile.close();
LINFO(fmt::format("Loading histograms from {}", cacheFilename));
success &= _histogramManager->loadFromFile(cacheFilename);
} else {
}
else {
// Build histograms from tsp file.
LWARNING(fmt::format("Failed to open '{}'", cacheFilename));
success &= _histogramManager->buildHistograms(
@@ -541,7 +550,8 @@ bool RenderableMultiresVolume::initializeSelector() {
cacheFile.close();
LINFO(fmt::format("Loading histograms from {}", cacheFilename));
success &= _localErrorHistogramManager->loadFromFile(cacheFilename);
} else {
}
else {
// Build histograms from tsp file.
LWARNING(fmt::format("Failed to open {}", cacheFilename));
success &= _localErrorHistogramManager->buildHistograms(nHistograms);

View File

@@ -74,7 +74,8 @@ void ShenBrickSelector::traverseBST(int timestep, unsigned int brickIndex,
if (timestep <= timeSpanCenter) {
bstChild = _tsp->bstLeft(brickIndex);
timeSpanEnd = timeSpanCenter;
} else {
}
else {
bstChild = _tsp->bstRight(brickIndex);
timeSpanStart = timeSpanCenter;
}
@@ -97,11 +98,14 @@ void ShenBrickSelector::selectBricks(int timestep, unsigned int brickIndex,
if (_tsp->temporalError(brickIndex) <= _temporalTolerance) {
if (_tsp->isOctreeLeaf(bstRootBrickIndex)) {
selectCover(coveredBricks, brickIndex, bricks);
} else if (_tsp->spatialError(brickIndex) <= _spatialTolerance) {
}
else if (_tsp->spatialError(brickIndex) <= _spatialTolerance) {
selectCover(coveredBricks, brickIndex, bricks);
} else if (_tsp->isBstLeaf(brickIndex)) {
}
else if (_tsp->isBstLeaf(brickIndex)) {
traverseOT(timestep, bstRootBrickIndex, coveredBricks, bricks);
} else {
}
else {
traverseBST(
timestep,
brickIndex,
@@ -112,13 +116,16 @@ void ShenBrickSelector::selectBricks(int timestep, unsigned int brickIndex,
bricks
);
}
} else if (_tsp->isBstLeaf(brickIndex)) {
}
else if (_tsp->isBstLeaf(brickIndex)) {
if (_tsp->isOctreeLeaf(bstRootBrickIndex)) {
selectCover(coveredBricks, brickIndex, bricks);
} else {
}
else {
traverseOT(timestep, bstRootBrickIndex, coveredBricks, bricks);
}
} else {
}
else {
traverseBST(
timestep,
brickIndex,

View File

@@ -83,7 +83,8 @@ void SimpleTfBrickSelector::selectBricks(int timestep, std::vector<int>& bricks)
if (splitType != BrickSelection::SplitType::None) {
priorityQueue.push_back(brickSelection);
} else {
}
else {
leafSelections.push_back(brickSelection);
}
@@ -137,10 +138,12 @@ void SimpleTfBrickSelector::selectBricks(int timestep, std::vector<int>& bricks)
priorityQueue.end(),
compareSplitPoints
);
} else {
}
else {
leafSelections.push_back(childSelection);
}
} else if (bs.splitType == BrickSelection::SplitType::Spatial) {
}
else if (bs.splitType == BrickSelection::SplitType::Spatial) {
nBricksInMemory += 7; // Remove one and add eight.
unsigned int firstChild = _tsp->firstOctreeChild(brickIndex);
@@ -158,7 +161,8 @@ void SimpleTfBrickSelector::selectBricks(int timestep, std::vector<int>& bricks)
}
if (bs.splitPoints > -1) {
temporalSplitQueue.push_back(bs);
} else {
}
else {
deadEnds.push_back(bs);
}
break;
@@ -186,7 +190,8 @@ void SimpleTfBrickSelector::selectBricks(int timestep, std::vector<int>& bricks)
priorityQueue.end(),
compareSplitPoints
);
} else {
}
else {
leafSelections.push_back(childSelection);
}
}
@@ -208,7 +213,8 @@ void SimpleTfBrickSelector::selectBricks(int timestep, std::vector<int>& bricks)
temporalSplitQueue.end(),
compareSplitPoints
);
} else {
}
else {
deadEnds.push_back(bs);
}
}
@@ -256,7 +262,8 @@ void SimpleTfBrickSelector::selectBricks(int timestep, std::vector<int>& bricks)
temporalSplitQueue.end(),
compareSplitPoints
);
} else {
}
else {
BrickSelection childSelection = bs.splitTemporally(
pickRightTimeChild,
childBrickIndex,
@@ -265,7 +272,8 @@ void SimpleTfBrickSelector::selectBricks(int timestep, std::vector<int>& bricks)
deadEnds.push_back(childSelection);
}
}
} else {
}
else {
// Write selected inner nodes to brickSelection vector
for (const BrickSelection& bs : priorityQueue) {
writeSelection(bs, bricks);
@@ -309,10 +317,12 @@ float SimpleTfBrickSelector::splitPoints(unsigned int brickIndex,
if (spatialPoints > 0 && spatialPoints > temporalPoints) {
splitPoints = spatialPoints;
splitType = BrickSelection::SplitType::Spatial;
} else if (temporalPoints > 0) {
}
else if (temporalPoints > 0) {
splitPoints = temporalPoints;
splitType = BrickSelection::SplitType::Temporal;
} else {
}
else {
splitPoints = -1;
splitType = BrickSelection::SplitType::None;
}

View File

@@ -84,7 +84,8 @@ void TfBrickSelector::selectBricks(int timestep, std::vector<int>& bricks) {
if (splitType != BrickSelection::SplitType::None) {
priorityQueue.push_back(brickSelection);
} else {
}
else {
leafSelections.push_back(brickSelection);
}
@@ -126,7 +127,8 @@ void TfBrickSelector::selectBricks(int timestep, std::vector<int>& bricks) {
if (pickRightTimeChild) {
childBrickIndex = _tsp->bstRight(brickIndex);
} else {
}
else {
childBrickIndex = _tsp->bstLeft(brickIndex);
}
@@ -145,10 +147,12 @@ void TfBrickSelector::selectBricks(int timestep, std::vector<int>& bricks) {
priorityQueue.end(),
compareSplitPoints
);
} else {
}
else {
leafSelections.push_back(childSelection);
}
} else if (bs.splitType == BrickSelection::SplitType::Spatial) {
}
else if (bs.splitType == BrickSelection::SplitType::Spatial) {
nBricksInMemory += 7; // Remove one and add eight.
unsigned int firstChild = _tsp->firstOctreeChild(brickIndex);
@@ -167,7 +171,8 @@ void TfBrickSelector::selectBricks(int timestep, std::vector<int>& bricks) {
}
if (bs.splitPoints > -1) {
temporalSplitQueue.push_back(bs);
} else {
}
else {
deadEnds.push_back(bs);
}
break;
@@ -196,7 +201,8 @@ void TfBrickSelector::selectBricks(int timestep, std::vector<int>& bricks) {
priorityQueue.end(),
compareSplitPoints
);
} else {
}
else {
leafSelections.push_back(childSelection);
}
}
@@ -224,7 +230,8 @@ void TfBrickSelector::selectBricks(int timestep, std::vector<int>& bricks) {
temporalSplitQueue.end(),
compareSplitPoints
);
} else {
}
else {
deadEnds.push_back(bs);
}
}
@@ -273,7 +280,8 @@ void TfBrickSelector::selectBricks(int timestep, std::vector<int>& bricks) {
temporalSplitQueue.end(),
compareSplitPoints
);
} else {
}
else {
BrickSelection childSelection = bs.splitTemporally(
pickRightTimeChild,
childBrickIndex,
@@ -283,7 +291,8 @@ void TfBrickSelector::selectBricks(int timestep, std::vector<int>& bricks) {
deadEnds.push_back(childSelection);
}
}
} else {
}
else {
// Write selected inner nodes to brickSelection vector
//std::cout << "priority queue: " << priorityQueue.size() << std::endl;
for (const BrickSelection& bs : priorityQueue) {
@@ -357,10 +366,12 @@ float TfBrickSelector::splitPoints(unsigned int brickIndex,
if (spatialPoints > 0 && spatialPoints > temporalPoints) {
splitPoints = spatialPoints;
splitType = BrickSelection::SplitType::Spatial;
} else if (temporalPoints > 0) {
}
else if (temporalPoints > 0) {
splitPoints = temporalPoints;
splitType = BrickSelection::SplitType::Temporal;
} else {
}
else {
splitPoints = -1;
splitType = BrickSelection::SplitType::None;
}
@@ -396,7 +407,8 @@ bool TfBrickSelector::calculateBrickErrors() {
for (unsigned int brickIndex = 0; brickIndex < nHistograms; brickIndex++) {
if (_tsp->isBstLeaf(brickIndex) && _tsp->isOctreeLeaf(brickIndex)) {
_brickErrors[brickIndex] = 0;
} else {
}
else {
const Histogram* histogram = _histogramManager->histogram(brickIndex);
float error = 0;
for (size_t i = 0; i < gradients.size(); i++) {

View File

@@ -436,7 +436,8 @@ bool TSP::calculateTemporalError() {
// 0.0 higher up in the tree
if (coveredBricks.size() == 1) {
errors[brick] = -0.1f;
} else {
}
else {
// Calculate standard deviation per voxel, average over brick
float avgStdDev = 0.f;
for (unsigned int voxel = 0; voxel<numBrickVals; ++voxel) {