From 5ef294af545dfaf879856fae949e0222a57b127f Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Thu, 12 Dec 2024 14:08:57 -0500 Subject: [PATCH] Experimenting with different code algorithms. NONE ARE WORKING. THIS COMMIT IS JUNK The issue is that the outer virtual boundary Face Labels and the underlying FeatureIds do not agree. I think we may need to store the actual index offset into the FeatureIds array and then also store a reference to the FeatureIds array so that we can get the data consistently. Signed-off-by: Michael Jackson --- .../Filters/Algorithms/SurfaceNets.cpp | 185 ++++++++++++++++-- .../Filters/Algorithms/SurfaceNets.hpp | 9 + .../Filters/Algorithms/TupleTransfer.hpp | 32 +-- .../SimplnxCore/Filters/SurfaceNetsFilter.cpp | 6 +- .../SimplnxCore/SurfaceNets/MMCellFlag.cpp | 15 ++ .../src/SimplnxCore/SurfaceNets/MMCellFlag.h | 18 +- .../src/SimplnxCore/SurfaceNets/MMCellMap.cpp | 41 ++-- .../src/SimplnxCore/SurfaceNets/MMCellMap.h | 6 +- .../SimplnxCore/SurfaceNets/MMGeometryGL.cpp | 8 +- .../SimplnxCore/SurfaceNets/MMGeometryOBJ.cpp | 8 +- .../SimplnxCore/SurfaceNets/MMSurfaceNet.cpp | 13 +- .../SimplnxCore/SurfaceNets/MMSurfaceNet.h | 11 +- .../SimplnxCore/test/SurfaceNetsTest.cpp | 47 ++--- .../simplnx/UnitTest/UnitTestCommon.hpp | 12 +- 14 files changed, 305 insertions(+), 106 deletions(-) diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/SurfaceNets.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/SurfaceNets.cpp index 9fbe7ade59..6ad6a5db86 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/SurfaceNets.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/SurfaceNets.cpp @@ -103,11 +103,13 @@ Result<> SurfaceNets::operator()() auto voxelSize = imageGeom.getSpacing(); auto origin = imageGeom.getOrigin(); + // X Y Z Ordering IntVec3 arraySize(static_cast(gridDimensions[0]), static_cast(gridDimensions[1]), static_cast(gridDimensions[2])); auto& featureIds = m_DataStructure.getDataAs(m_InputValues->FeatureIdsArrayPath)->getDataStoreRef(); - using LabelType = int32; + // THIS IS MAKING A COPY OF THE IMAGE GEOMETRY CELL "FEATURE IDS" array + using LabelType = int32_t; std::vector labels(featureIds.getNumberOfTuples()); for(size_t idx = 0; idx < featureIds.getNumberOfTuples(); idx++) { @@ -115,6 +117,7 @@ Result<> SurfaceNets::operator()() } MMSurfaceNet surfaceNet(labels.data(), arraySize.data(), voxelSize.data()); + labels.resize(0); // Free that copy... because there is another copy in the surfaceNet object. // Use current parameters to relax the SurfaceNet if(m_InputValues->ApplySmoothing) @@ -155,12 +158,15 @@ Result<> SurfaceNets::operator()() nodeTypes[static_cast(vertIndex)] = static_cast(currentCellPtr->flag.numJunctions()); } usize triangleCount = 0; + std::array cellDataIndex = {0, 0}; // First Pass through to just count the number of triangles: for(int idxVtx = 0; idxVtx < nodeCount; idxVtx++) { std::array vertexIndices = {0, 0, 0, 0}; std::array quadLabels = {0, 0}; - if(cellMapPtr->getEdgeQuad(idxVtx, MMCellFlag::Edge::BackBottomEdge, vertexIndices.data(), quadLabels.data())) + std::array cellIndices = {0, 0, 0}; + + if(cellMapPtr->getEdgeQuad(idxVtx, MMCellFlag::Edge::BackBottomEdge, vertexIndices.data(), quadLabels.data(), cellIndices)) { if(quadLabels[0] == MMSurfaceNet::Padding || quadLabels[1] == MMSurfaceNet::Padding) { @@ -178,7 +184,7 @@ Result<> SurfaceNets::operator()() } triangleCount += 2; } - if(cellMapPtr->getEdgeQuad(idxVtx, MMCellFlag::Edge::LeftBottomEdge, vertexIndices.data(), quadLabels.data())) + if(cellMapPtr->getEdgeQuad(idxVtx, MMCellFlag::Edge::LeftBottomEdge, vertexIndices.data(), quadLabels.data(), cellIndices)) { if(quadLabels[0] == MMSurfaceNet::Padding || quadLabels[1] == MMSurfaceNet::Padding) { @@ -196,7 +202,7 @@ Result<> SurfaceNets::operator()() } triangleCount += 2; } - if(cellMapPtr->getEdgeQuad(idxVtx, MMCellFlag::Edge::LeftBackEdge, vertexIndices.data(), quadLabels.data())) + if(cellMapPtr->getEdgeQuad(idxVtx, MMCellFlag::Edge::LeftBackEdge, vertexIndices.data(), quadLabels.data(), cellIndices)) { if(quadLabels[0] == MMSurfaceNet::Padding || quadLabels[1] == MMSurfaceNet::Padding) { @@ -221,6 +227,7 @@ Result<> SurfaceNets::operator()() // Resize the face labels Int32Array auto& faceLabels = m_DataStructure.getDataAs(m_InputValues->FaceLabelsDataPath)->getDataStoreRef(); faceLabels.resizeTuples({triangleCount}); + faceLabels.fill(-1000); // Create a vector of TupleTransferFunctions for each of the Triangle Face to VertexType Data Arrays std::vector> tupleTransferFunctions; @@ -240,12 +247,29 @@ Result<> SurfaceNets::operator()() std::array vertexIndices = {0, 0, 0, 0}; std::array quadLabels = {0, 0}; std::array vData{}; + std::array cellIndices = {0, 0, 0}; + + constexpr size_t x_idx = 0; + constexpr size_t y_idx = 1; + constexpr size_t z_idx = 2; + for(int idxVtx = 0; idxVtx < nodeCount; idxVtx++) { - // Back-bottom edge - if(cellMapPtr->getEdgeQuad(idxVtx, MMCellFlag::Edge::BackBottomEdge, vertexIndices.data(), quadLabels.data())) + // std::array cellIndex; + // cellMapPtr->getVertexCellIndex(idxVtx, cellIndex.data()); + // std::cout << cellIndex[0] << ", " << cellIndex[1] << ", " << cellIndex[2] << std::endl; + + GenerateTriangles(idxVtx, MMCellFlag::Edge::BackBottomEdge, cellMapPtr, imageGeom, triangleGeom, faceIndex, faceLabels, featureIds, tupleTransferFunctions); + GenerateTriangles(idxVtx, MMCellFlag::Edge::LeftBottomEdge, cellMapPtr, imageGeom, triangleGeom, faceIndex, faceLabels, featureIds, tupleTransferFunctions); + GenerateTriangles(idxVtx, MMCellFlag::Edge::LeftBackEdge, cellMapPtr, imageGeom, triangleGeom, faceIndex, faceLabels, featureIds, tupleTransferFunctions); + +#if 0 + if(cellMapPtr->getEdgeQuad(idxVtx, MMCellFlag::Edge::BackBottomEdge, vertexIndices.data(), quadLabels.data(), cellIndices)) { + size_t cellIndex1 = cellIndices[z_idx] * gridDimensions[y_idx] * gridDimensions[x_idx] + cellIndices[y_idx] * gridDimensions[x_idx] + cellIndices[x_idx]; + size_t cellIndex2 = (cellIndices[z_idx] - 1) * gridDimensions[y_idx] * gridDimensions[x_idx] + cellIndices[y_idx] * gridDimensions[x_idx] + cellIndices[x_idx]; + vData[0] = {vertexIndices[0], 00.0f, 0.0f, 0.0f}; vData[1] = {vertexIndices[1], 00.0f, 0.0f, 0.0f}; vData[2] = {vertexIndices[2], 00.0f, 0.0f, 0.0f}; @@ -271,7 +295,7 @@ Result<> SurfaceNets::operator()() // Copy any Cell Data to the Triangle Mesh for(size_t dataVectorIndex = 0; dataVectorIndex < m_InputValues->SelectedDataArrayPaths.size(); dataVectorIndex++) { - tupleTransferFunctions[dataVectorIndex]->transfer(faceIndex, quadLabels[0], quadLabels[1], faceLabels); + tupleTransferFunctions[dataVectorIndex]->transfer(faceIndex, cellIndex1, cellIndex2); } faceIndex++; @@ -290,14 +314,17 @@ Result<> SurfaceNets::operator()() // Copy any Cell Data to the Triangle Mesh for(size_t dataVectorIndex = 0; dataVectorIndex < m_InputValues->SelectedDataArrayPaths.size(); dataVectorIndex++) { - tupleTransferFunctions[dataVectorIndex]->transfer(faceIndex, quadLabels[0], quadLabels[1], faceLabels); + tupleTransferFunctions[dataVectorIndex]->transfer(faceIndex, cellIndex1, cellIndex2); } faceIndex++; } - // Left-bottom edge - if(cellMapPtr->getEdgeQuad(idxVtx, MMCellFlag::Edge::LeftBottomEdge, vertexIndices.data(), quadLabels.data())) + // Left-bottom edge Y + if(cellMapPtr->getEdgeQuad(idxVtx, MMCellFlag::Edge::LeftBottomEdge, vertexIndices.data(), quadLabels.data(), cellIndices)) { + size_t cellIndex1 = cellIndices[z_idx] * gridDimensions[y_idx] * gridDimensions[x_idx] + cellIndices[y_idx] * gridDimensions[x_idx] + cellIndices[x_idx]; + size_t cellIndex2 = cellIndices[z_idx] * (gridDimensions[y_idx] - 1) * gridDimensions[x_idx] + (cellIndices[y_idx] - 1) * gridDimensions[x_idx] + cellIndices[x_idx]; + vData[0] = {vertexIndices[0], 00.0f, 0.0f, 0.0f}; vData[1] = {vertexIndices[1], 00.0f, 0.0f, 0.0f}; vData[2] = {vertexIndices[2], 00.0f, 0.0f, 0.0f}; @@ -323,7 +350,7 @@ Result<> SurfaceNets::operator()() // Copy any Cell Data to the Triangle Mesh for(size_t dataVectorIndex = 0; dataVectorIndex < m_InputValues->SelectedDataArrayPaths.size(); dataVectorIndex++) { - tupleTransferFunctions[dataVectorIndex]->transfer(faceIndex, quadLabels[0], quadLabels[1], faceLabels); + tupleTransferFunctions[dataVectorIndex]->transfer(faceIndex, cellIndex1, cellIndex2); } faceIndex++; @@ -341,14 +368,17 @@ Result<> SurfaceNets::operator()() // Copy any Cell Data to the Triangle Mesh for(size_t dataVectorIndex = 0; dataVectorIndex < m_InputValues->SelectedDataArrayPaths.size(); dataVectorIndex++) { - tupleTransferFunctions[dataVectorIndex]->transfer(faceIndex, quadLabels[0], quadLabels[1], faceLabels); + tupleTransferFunctions[dataVectorIndex]->transfer(faceIndex, cellIndex1, cellIndex2); } faceIndex++; } - // Left-back edge - if(cellMapPtr->getEdgeQuad(idxVtx, MMCellFlag::Edge::LeftBackEdge, vertexIndices.data(), quadLabels.data())) + // Left-back edge X + if(cellMapPtr->getEdgeQuad(idxVtx, MMCellFlag::Edge::LeftBackEdge, vertexIndices.data(), quadLabels.data(), cellIndices)) { + size_t cellIndex1 = cellIndices[z_idx] * gridDimensions[y_idx] * gridDimensions[x_idx] + cellIndices[y_idx] * gridDimensions[x_idx] + cellIndices[x_idx]; + size_t cellIndex2 = cellIndices[z_idx] * gridDimensions[y_idx] * gridDimensions[x_idx] + cellIndices[y_idx] * gridDimensions[x_idx] + (cellIndices[x_idx] - 1); + vData[0] = {vertexIndices[0], 00.0f, 0.0f, 0.0f}; vData[1] = {vertexIndices[1], 00.0f, 0.0f, 0.0f}; vData[2] = {vertexIndices[2], 00.0f, 0.0f, 0.0f}; @@ -374,7 +404,7 @@ Result<> SurfaceNets::operator()() // Copy any Cell Data to the Triangle Mesh for(size_t dataVectorIndex = 0; dataVectorIndex < m_InputValues->SelectedDataArrayPaths.size(); dataVectorIndex++) { - tupleTransferFunctions[dataVectorIndex]->transfer(faceIndex, quadLabels[0], quadLabels[1], faceLabels); + tupleTransferFunctions[dataVectorIndex]->transfer(faceIndex, cellIndex1, cellIndex2); } faceIndex++; @@ -392,11 +422,134 @@ Result<> SurfaceNets::operator()() // Copy any Cell Data to the Triangle Mesh for(size_t dataVectorIndex = 0; dataVectorIndex < m_InputValues->SelectedDataArrayPaths.size(); dataVectorIndex++) { - tupleTransferFunctions[dataVectorIndex]->transfer(faceIndex, quadLabels[0], quadLabels[1], faceLabels); + tupleTransferFunctions[dataVectorIndex]->transfer(faceIndex, cellIndex1, cellIndex2); } faceIndex++; } +#endif } return {}; } + +using LabelType = int32; + +/** + * + * @param idxVtx + * @param edgeType + * @param cellMapPtr + * @param imageGeom + * @param triangleGeom + * @param faceIndex + * @param faceLabels + * @param tupleTransferFunctions + */ +void SurfaceNets::GenerateTriangles(int idxVtx, MMCellFlag::Edge edgeType, MMCellMap* cellMapPtr, const ImageGeom& imageGeom, TriangleGeom& triangleGeom, usize& faceIndex, + AbstractDataStore& faceLabels, AbstractDataStore& featureIds, std::vector>& tupleTransferFunctions) +{ + auto gridDimensions = imageGeom.getDimensions(); + + std::array vertexIndices = {0, 0, 0, 0}; + std::array quadLabels = {0, 0}; + std::array cellIndex = {0, 0, 0}; + if(!cellMapPtr->getEdgeQuad(idxVtx, edgeType, vertexIndices.data(), quadLabels.data(), cellIndex)) + { + return; + } + constexpr size_t x_idx = 0; + constexpr size_t y_idx = 1; + constexpr size_t z_idx = 2; + + // cellIndex[x_idx] = (cellIndex[x_idx] > 0 ? cellIndex[x_idx] - 1 : cellIndex[x_idx]); + // cellIndex[y_idx] = (cellIndex[y_idx] > 0 ? cellIndex[y_idx] - 1 : cellIndex[y_idx]); + // cellIndex[z_idx] = (cellIndex[z_idx] > 0 ? cellIndex[z_idx] - 1 : cellIndex[z_idx]); + + std::array cellOffset = {(cellIndex[z_idx] * gridDimensions[y_idx] * gridDimensions[x_idx]) + (cellIndex[y_idx] * gridDimensions[x_idx]) + cellIndex[x_idx], 0}; + + if(edgeType == MMCellFlag::Edge::LeftBottomEdge) + { + cellOffset[1] = cellOffset[0] + gridDimensions[x_idx]; + } + else if(edgeType == MMCellFlag::Edge::BackBottomEdge) + { + cellOffset[1] = cellOffset[0] + 1; + } + else if(edgeType == MMCellFlag::Edge::LeftBackEdge) + { + cellOffset[1] = cellOffset[0] + gridDimensions[x_idx] * gridDimensions[y_idx]; + } + else + { + throw std::runtime_error("SurfaceNets: GenerateTriangles used unknown enumeration for edge type"); + } + + std::array vData = {VertexData{vertexIndices[0], 00.0f, 0.0f, 0.0f}, VertexData{vertexIndices[1], 00.0f, 0.0f, 0.0f}, VertexData{vertexIndices[2], 00.0f, 0.0f, 0.0f}, + VertexData{vertexIndices[3], 00.0f, 0.0f, 0.0f}}; + + const bool isQuadFrontFacing = (quadLabels[0] < quadLabels[1]); + + std::array triangleVtxIDs = {0, 0, 0, 0, 0, 0}; + getQuadTriangleIDs(vData, isQuadFrontFacing, triangleVtxIDs); + std::array t1 = {static_cast(triangleVtxIDs[0]), static_cast(triangleVtxIDs[1]), static_cast(triangleVtxIDs[2])}; + triangleGeom.setFacePointIds(faceIndex, t1); + std::array t2 = {static_cast(triangleVtxIDs[3]), static_cast(triangleVtxIDs[4]), static_cast(triangleVtxIDs[5])}; + triangleGeom.setFacePointIds(faceIndex + 1, t2); + + if(quadLabels[0] != -1 && quadLabels[1] != -1) + { + size_t firstIdx = 0; + size_t secIdx = 1; + if(quadLabels[1] < quadLabels[0]) + { + firstIdx = 1; + secIdx = 0; + } + + std::cout << quadLabels[firstIdx] << "\t" << quadLabels[secIdx] << "\t" << featureIds[cellOffset[firstIdx]] << '\t' << featureIds[cellOffset[secIdx]] << "\n"; + + faceLabels[faceIndex * 2] = (quadLabels[firstIdx] == -1 ? -1 : faceLabels[cellOffset[firstIdx]]); // quadLabels[firstIdx]; + faceLabels[faceIndex * 2 + 1] = (quadLabels[secIdx] == -1 ? -1 : faceLabels[cellOffset[secIdx]]); // quadLabels[firstIdx]; + + faceLabels[(faceIndex + 1) * 2] = (quadLabels[firstIdx] == -1 ? -1 : faceLabels[cellOffset[firstIdx]]); // quadLabels[firstIdx]; + faceLabels[(faceIndex + 1) * 2 + 1] = (quadLabels[secIdx] == -1 ? -1 : faceLabels[cellOffset[secIdx]]); // quadLabels[firstIdx]; + } + else // One of the Quad Labels is -1, which means we are on the virtual border + { + // Assume the first Quad Label = -1 + size_t firstIdx = 0; + size_t secIdx = 1; + if(quadLabels[1] == -1) + { + firstIdx = 1; + secIdx = 0; + } + + std::cout << quadLabels[firstIdx] << "\t" << quadLabels[secIdx] << "\t" << featureIds[cellOffset[firstIdx]] << '\t' << featureIds[cellOffset[secIdx]] << "\n"; + + if(quadLabels[secIdx] != -1 && quadLabels[secIdx] != featureIds[cellOffset[secIdx]]) + { + std::cout << " " << cellIndex[0] << "\t" << cellIndex[1] << "\t" << cellIndex[2] << "\n"; + } + + faceLabels[faceIndex * 2] = (quadLabels[firstIdx] == -1 ? -666 : faceLabels[cellOffset[firstIdx]]); // quadLabels[firstIdx]; + faceLabels[faceIndex * 2 + 1] = (quadLabels[secIdx] == -1 ? -1 : faceLabels[cellOffset[secIdx]]); // quadLabels[firstIdx]; + + faceLabels[(faceIndex + 1) * 2] = (quadLabels[firstIdx] == -1 ? -666 : faceLabels[cellOffset[firstIdx]]); // quadLabels[firstIdx]; + faceLabels[(faceIndex + 1) * 2 + 1] = (quadLabels[secIdx] == -1 ? -1 : faceLabels[cellOffset[secIdx]]); // quadLabels[firstIdx]; + + // Copy any Cell Data to the Triangle Mesh for the first triangle + for(size_t dataVectorIndex = 0; dataVectorIndex < m_InputValues->SelectedDataArrayPaths.size(); dataVectorIndex++) + { + tupleTransferFunctions[dataVectorIndex]->transfer(faceIndex, cellOffset[firstIdx], cellOffset[secIdx], faceLabels); + } + // Copy any Cell Data to the Triangle Mesh for the second triangle + for(size_t dataVectorIndex = 0; dataVectorIndex < m_InputValues->SelectedDataArrayPaths.size(); dataVectorIndex++) + { + tupleTransferFunctions[dataVectorIndex]->transfer(faceIndex + 1, cellOffset[firstIdx], cellOffset[secIdx], faceLabels); + } + } + + // Increment the 'faceIndex' index by 2 + faceIndex = faceIndex + 2; +} diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/SurfaceNets.hpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/SurfaceNets.hpp index 7c203e8c49..dc6ef5fdd7 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/SurfaceNets.hpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/SurfaceNets.hpp @@ -1,9 +1,13 @@ #pragma once +#include "SimplnxCore/Filters/Algorithms/TupleTransfer.hpp" #include "SimplnxCore/SimplnxCore_export.hpp" +#include "SimplnxCore/SurfaceNets/MMCellFlag.h" #include "simplnx/DataStructure/DataPath.hpp" #include "simplnx/DataStructure/DataStructure.hpp" +#include "simplnx/DataStructure/Geometry/ImageGeom.hpp" +#include "simplnx/DataStructure/Geometry/TriangleGeom.hpp" #include "simplnx/Filter/IFilter.hpp" #include "simplnx/Parameters/ArrayCreationParameter.hpp" #include "simplnx/Parameters/ArraySelectionParameter.hpp" @@ -11,6 +15,8 @@ #include "simplnx/Parameters/DataGroupCreationParameter.hpp" #include "simplnx/Parameters/MultiArraySelectionParameter.hpp" +class MMCellMap; + namespace nx::core { @@ -55,6 +61,9 @@ class SIMPLNXCORE_EXPORT SurfaceNets const SurfaceNetsInputValues* m_InputValues = nullptr; const std::atomic_bool& m_ShouldCancel; const IFilter::MessageHandler& m_MessageHandler; + + void GenerateTriangles(int idxVtx, MMCellFlag::Edge edgeType, MMCellMap* cellMapPtr, const ImageGeom& imageGeom, TriangleGeom& triangleGeom, usize& faceIndex, AbstractDataStore& featureIds, + AbstractDataStore& faceLabels, std::vector>& tupleTransferFunctions); }; } // namespace nx::core diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/TupleTransfer.hpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/TupleTransfer.hpp index 700be14986..f2258f411d 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/TupleTransfer.hpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/TupleTransfer.hpp @@ -31,7 +31,7 @@ class SIMPLNXCORE_EXPORT AbstractTupleTransfer * @param secondcIndex * @param forceSecondToZero */ - virtual void transfer(size_t faceIndex, size_t firstcIndex, size_t secondcIndex, bool forceSecondToZero = false) = 0; + // virtual void transfer(size_t faceIndex, size_t firstcIndex, size_t secondcIndex, bool forceSecondToZero) = 0; virtual void transfer(size_t faceIndex, size_t firstcIndex) = 0; @@ -82,21 +82,21 @@ class TransferTuple : public AbstractTupleTransfer * @param secondcIndex * @param forceSecondToZero */ - void transfer(size_t faceIndex, size_t firstcIndex, size_t secondcIndex, bool forceSecondToZero = false) override - { - for(size_t i = 0; i < m_NumComps; i++) - { - m_FaceRef[faceIndex * m_NumComps + i] = m_CellRef[firstcIndex * m_NumComps + i]; - } - - if(!forceSecondToZero) - { - for(size_t i = 0; i < m_NumComps; i++) - { - m_FaceRef[faceIndex + i + m_NumComps] = m_CellRef[secondcIndex + i]; - } - } - } + // void transfer(size_t faceIndex, size_t cellIndex1, size_t cellIndex2, bool forceSecondToZero) override + // { + // for(size_t i = 0; i < m_NumComps; i++) + // { + // m_FaceRef[faceIndex * m_NumComps + i] = m_CellRef[cellIndex1 * m_NumComps + i]; + // } + // + // if(!forceSecondToZero) + // { + // for(size_t i = 0; i < m_NumComps; i++) + // { + // m_FaceRef[faceIndex * m_NumComps + i] = m_CellRef[cellIndex2 * m_NumComps + i]; + // } + // } + // } void transfer(size_t faceIndex, size_t firstcIndex) override { diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/SurfaceNetsFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/SurfaceNetsFilter.cpp index 041f54ef75..df504f7092 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/SurfaceNetsFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/SurfaceNetsFilter.cpp @@ -69,9 +69,9 @@ Parameters SurfaceNetsFilter::parameters() const GeometrySelectionParameter::AllowedTypes{IGeometry::Type::Image})); params.insert(std::make_unique(k_CellFeatureIdsArrayPath_Key, "Cell Feature Ids", "The complete path to the Array specifying which Feature each Cell belongs to", DataPath{}, ArraySelectionParameter::AllowedTypes{DataType::int32}, ArraySelectionParameter::AllowedComponentShapes{{1}})); - // params.insert(std::make_unique( - // k_SelectedDataArrayPaths_Key, "Attribute Arrays to Transfer", "The paths to the Arrays specifying which Cell Attribute Arrays to transfer to the created Triangle Geometry", - // MultiArraySelectionParameter::ValueType{}, MultiArraySelectionParameter::AllowedTypes{IArray::ArrayType::DataArray}, nx::core::GetAllDataTypes())); + params.insert(std::make_unique( + k_SelectedDataArrayPaths_Key, "Attribute Arrays to Transfer", "The paths to the Arrays specifying which Cell Attribute Arrays to transfer to the created Triangle Geometry", + MultiArraySelectionParameter::ValueType{}, MultiArraySelectionParameter::AllowedTypes{IArray::ArrayType::DataArray}, nx::core::GetAllDataTypes())); params.insertSeparator(Parameters::Separator{"Output Triangle Geometry"}); params.insert( diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/SurfaceNets/MMCellFlag.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/SurfaceNets/MMCellFlag.cpp index 3f0f904f30..ae6db19c6f 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/SurfaceNets/MMCellFlag.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/SurfaceNets/MMCellFlag.cpp @@ -345,3 +345,18 @@ bool MMCellFlag::isEdgeCrossing(Edge edge) const } } } + +uint8_t MMCellFlag::numJunctions() const +{ + return m_BitFlag >> k_NumJunctionsBitShift; +} + +uint32_t MMCellFlag::getBitFlag() const +{ + return m_BitFlag; +} + +void MMCellFlag::clear() +{ + m_BitFlag = 0; +} diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/SurfaceNets/MMCellFlag.h b/src/Plugins/SimplnxCore/src/SimplnxCore/SurfaceNets/MMCellFlag.h index d7d9eaf9e6..fb97f68369 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/SurfaceNets/MMCellFlag.h +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/SurfaceNets/MMCellFlag.h @@ -7,6 +7,7 @@ #pragma once +#include #include class MMCellFlag @@ -57,24 +58,15 @@ class MMCellFlag // edge or face crossings. void set(const int32_t cellLabels[8]); - uint32_t getBitFlag() const - { - return m_BitFlag; - } + uint32_t getBitFlag() const; - void clear() - { - m_BitFlag = 0; - } + void clear(); // Get components of the cell flag VertexType vertexType() const; FaceCrossingType faceCrossingType(Face face) const; bool isEdgeCrossing(Edge edge) const; - uint8_t numJunctions() const - { - return m_BitFlag >> k_NumJunctionsBitShift; - } + uint8_t numJunctions() const; private: static inline constexpr uint32_t k_NumJunctionsBitShift = 29; @@ -83,6 +75,8 @@ class MMCellFlag // The last 3 bits of the bitflag are the number of junctions // numJunctions can at most be 6 uint32_t m_BitFlag = 0; + + size_t m_CellIndex = 0; }; // For iterating over cell faces diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/SurfaceNets/MMCellMap.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/SurfaceNets/MMCellMap.cpp index 5b1b028796..d164375694 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/SurfaceNets/MMCellMap.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/SurfaceNets/MMCellMap.cpp @@ -4,6 +4,7 @@ // // Sarah Frisken, Brigham and Women's Hospital, Boston MA USA +#include #include #include #include @@ -207,40 +208,38 @@ MMCellFlag::VertexType MMCellMap::vertexType(int vertexIndex) // [x0, y0, z0, x1, y1 ...] in clockwise order and the quad face labels are inserted // into quadLabels as [labelTopFaceOfQuad, labelBottomFaceOfQuad]. If there is no edge // crossing, quadCorners and quadLabels will not be set. -bool MMCellMap::getEdgeQuad(int vertexIndex, MMCellFlag::Edge edge, float quadCorners[12], int32_t quadLabels[2]) +bool MMCellMap::getEdgeQuad(int vertexIndex, MMCellFlag::Edge edge, float quadCorners[12], int32_t quadLabels[2], std::array& cellIndex) { - int cellIndex[3]; - getVertexCellIndex(vertexIndex, cellIndex); - if(!isEdgeCrossing(cellArrayIndex(cellIndex), edge)) + getVertexCellIndex(vertexIndex, cellIndex.data()); + if(!isEdgeCrossing(cellArrayIndex(cellIndex.data()), edge)) { return false; } // Because there is an edge crossing, cell map access in the following will be // in-bounds by construction of the cell map. - getEdgeLabels(cellIndex, edge, quadLabels); - getEdgeQuadPositions(cellIndex, edge, quadCorners); + getEdgeLabels(cellIndex.data(), edge, quadLabels); + getEdgeQuadPositions(cellIndex.data(), edge, quadCorners); return true; } // Returns true if there is an edge crossing and false otherwise. If there is an edge -// crossing, we defince a surface quad from vertices in the 4 cells touching the edge. +// crossing, we define a surface quad from vertices in the 4 cells touching the edge. // The indices of these 4 vertices are inserted into quadVtxIndices in clockwise order // and the quad face labels are inserted into quadLabels as [labelTopFaceOfQuad, // labelBottomFaceOfQuad]. If there is no edge crossing, quadCorners and quadLabels // will not be set. -bool MMCellMap::getEdgeQuad(int vertexIndex, MMCellFlag::Edge edge, int quadVtxIndices[4], int32_t quadLabels[2]) +bool MMCellMap::getEdgeQuad(int vertexIndex, MMCellFlag::Edge edge, int quadVtxIndices[4], int32_t quadLabels[2], std::array& cellIndex) { - int cellIndex[3]; - getVertexCellIndex(vertexIndex, cellIndex); - if(!isEdgeCrossing(cellArrayIndex(cellIndex), edge)) + getVertexCellIndex(vertexIndex, cellIndex.data()); + if(!isEdgeCrossing(cellArrayIndex(cellIndex.data()), edge)) { return false; } // Because there is an edge crossing, cell map access in the following will be // in-bounds by construction of the cell map. - getEdgeLabels(cellIndex, edge, quadLabels); - getEdgeQuadVtxIndices(cellIndex, edge, quadVtxIndices); + getEdgeLabels(cellIndex.data(), edge, quadLabels); + getEdgeQuadVtxIndices(cellIndex.data(), edge, quadVtxIndices); return true; } @@ -320,9 +319,14 @@ void MMCellMap::setCellVertices() // The caller is responsible for bounds checking to allow for optimal performance. void MMCellMap::getEdgeLabels(int cellIndex[3], MMCellFlag::Edge edge, int32_t quadLabels[2]) { + std::array idx = {0, 0, 0}; + Cell* zeroCell = getCell(idx.data()); + idx = {52, 27, 52}; + Cell* lastCell = getCell(idx.data()); + Cell* pCell = getCell(cellIndex); - Cell* pCellFirstLabel; - Cell* pCellSecondLabel; + Cell* pCellFirstLabel = nullptr; + Cell* pCellSecondLabel = nullptr; switch(edge) { case MMCellFlag::Edge::LeftBottomEdge: @@ -378,12 +382,17 @@ void MMCellMap::getEdgeLabels(int cellIndex[3], MMCellFlag::Edge edge, int32_t q pCellSecondLabel = pCell; break; } + + ptrdiff_t diff_last_zero = lastCell - zeroCell; + ptrdiff_t diff_first_zero = pCellFirstLabel - zeroCell; + ptrdiff_t diff_first_second = pCellSecondLabel - zeroCell; + quadLabels[0] = pCellFirstLabel->label; quadLabels[1] = pCellSecondLabel->label; } // The caller is responsible for bounds checking to allow for optimal performance. -// Vertices are ordered clockwise around each edge begining with the cell vertex, with +// Vertices are ordered clockwise around each edge beginning with the cell vertex, with // edges oriented left-to-right, back-to-front and bottom-to-top. void MMCellMap::getEdgeQuadPositions(int cellIndex[3], MMCellFlag::Edge edge, float quadCorners[12]) { diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/SurfaceNets/MMCellMap.h b/src/Plugins/SimplnxCore/src/SimplnxCore/SurfaceNets/MMCellMap.h index 2caff34093..4e5b5e59df 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/SurfaceNets/MMCellMap.h +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/SurfaceNets/MMCellMap.h @@ -10,6 +10,8 @@ #include "MMCellFlag.h" #include "MMSurfaceNet.h" +#include + class MMCellMap { public: @@ -27,8 +29,8 @@ class MMCellMap int numVertices(); int numEdgeCrossings(); MMCellFlag::VertexType vertexType(int vertexIndex); - bool getEdgeQuad(int vertexIndex, MMCellFlag::Edge edge, float quadCorners[12], int32_t quadLabels[2]); - bool getEdgeQuad(int vertexIndex, MMCellFlag::Edge edge, int quadVtxIndices[4], int32_t quadLabels[2]); + bool getEdgeQuad(int vertexIndex, MMCellFlag::Edge edge, float quadCorners[12], int32_t quadLabels[2], std::array& cellIndex); + bool getEdgeQuad(int vertexIndex, MMCellFlag::Edge edge, int quadVtxIndices[4], int32_t quadLabels[2], std::array& cellIndex); void getVertexPosition(int vertexIndex, float position[3]); MMCellFlag::VertexType cellVertexType(int cellArrayIndex); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/SurfaceNets/MMGeometryGL.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/SurfaceNets/MMGeometryGL.cpp index 0b6614eef0..5b2f987b8e 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/SurfaceNets/MMGeometryGL.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/SurfaceNets/MMGeometryGL.cpp @@ -71,13 +71,15 @@ MMGeometryGL::MMGeometryGL(MMSurfaceNet* surfaceNet) m_numIndices = 0; float* pVertices = m_vertices; unsigned int* pIndices = m_indices; + std::array cellIndices = {0, 0, 0}; + for(int idxVtx = 0; idxVtx < cellMap->numVertices(); idxVtx++) { float vertexPositions[12]; int32_t labelsTmp[2]; // Back-bottom edge - if(cellMap->getEdgeQuad(idxVtx, MMCellFlag::Edge::BackBottomEdge, vertexPositions, labelsTmp) == true) + if(cellMap->getEdgeQuad(idxVtx, MMCellFlag::Edge::BackBottomEdge, vertexPositions, labelsTmp, cellIndices) == true) { MMGeometryGL::makeGLQuad(vertexPositions, labelsTmp, pVertices, pIndices, m_numVertices); pVertices += 4 * 8; @@ -87,7 +89,7 @@ MMGeometryGL::MMGeometryGL(MMSurfaceNet* surfaceNet) } // Left-bottom edge - if(cellMap->getEdgeQuad(idxVtx, MMCellFlag::Edge::LeftBottomEdge, vertexPositions, labelsTmp) == true) + if(cellMap->getEdgeQuad(idxVtx, MMCellFlag::Edge::LeftBottomEdge, vertexPositions, labelsTmp, cellIndices) == true) { MMGeometryGL::makeGLQuad(vertexPositions, labelsTmp, pVertices, pIndices, m_numVertices); pVertices += 4 * 8; @@ -97,7 +99,7 @@ MMGeometryGL::MMGeometryGL(MMSurfaceNet* surfaceNet) } // Left-back edge - if(cellMap->getEdgeQuad(idxVtx, MMCellFlag::Edge::LeftBackEdge, vertexPositions, labelsTmp) == true) + if(cellMap->getEdgeQuad(idxVtx, MMCellFlag::Edge::LeftBackEdge, vertexPositions, labelsTmp, cellIndices) == true) { MMGeometryGL::makeGLQuad(vertexPositions, labelsTmp, pVertices, pIndices, m_numVertices); pVertices += 4 * 8; diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/SurfaceNets/MMGeometryOBJ.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/SurfaceNets/MMGeometryOBJ.cpp index cf092128ab..1794832d50 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/SurfaceNets/MMGeometryOBJ.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/SurfaceNets/MMGeometryOBJ.cpp @@ -70,27 +70,29 @@ MMGeometryOBJ::MMGeometryOBJ(MMSurfaceNet* surfaceNet) // Create temporary storage for cell quads which are constructed around edges // crossed by the surface. Handle 3 edges per cell. The other 9 cell edges will // be handled when neighboring cells that share edges with this cell are visited. + std::array cellIndices = {0, 0, 0}; + for(int idxVtx = 0; idxVtx < cellMap->numVertices(); idxVtx++) { int vertexIndices[4]; int32_t quadLabels[2]; // Back-bottom edge - if(cellMap->getEdgeQuad(idxVtx, MMCellFlag::Edge::BackBottomEdge, vertexIndices, quadLabels) == true) + if(cellMap->getEdgeQuad(idxVtx, MMCellFlag::Edge::BackBottomEdge, vertexIndices, quadLabels, cellIndices) == true) { MMQuad quad(vertexIndices, quadLabels); m_quads.push_back(quad); } // Left-bottom edge - if(cellMap->getEdgeQuad(idxVtx, MMCellFlag::Edge::LeftBottomEdge, vertexIndices, quadLabels) == true) + if(cellMap->getEdgeQuad(idxVtx, MMCellFlag::Edge::LeftBottomEdge, vertexIndices, quadLabels, cellIndices) == true) { MMQuad quad(vertexIndices, quadLabels); m_quads.push_back(quad); } // Left-back edge - if(cellMap->getEdgeQuad(idxVtx, MMCellFlag::Edge::LeftBackEdge, vertexIndices, quadLabels) == true) + if(cellMap->getEdgeQuad(idxVtx, MMCellFlag::Edge::LeftBackEdge, vertexIndices, quadLabels, cellIndices) == true) { MMQuad quad(vertexIndices, quadLabels); m_quads.push_back(quad); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/SurfaceNets/MMSurfaceNet.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/SurfaceNets/MMSurfaceNet.cpp index 10b5532cc4..4b29713578 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/SurfaceNets/MMSurfaceNet.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/SurfaceNets/MMSurfaceNet.cpp @@ -18,15 +18,15 @@ MMSurfaceNet::MMSurfaceNet(int32_t* labels, int arraySize[3], float voxelSize[3]) : m_cellMap(nullptr) { - if(m_cellMap != NULL) - delete m_cellMap; m_cellMap = new MMCellMap(labels, arraySize, voxelSize); } MMSurfaceNet::~MMSurfaceNet() { // Delete cellMap if it exists if(m_cellMap) + { delete m_cellMap; + } } // Surface smoothing (relaxation) @@ -46,6 +46,9 @@ void MMSurfaceNet::reset() std::vector MMSurfaceNet::labels() { std::vector labels; + std::array cellIndices = {0, 0, 0}; + std::array cellDataIndex = {0, 0}; + if(m_cellMap != nullptr) { // Find the unique material labels @@ -56,21 +59,21 @@ std::vector MMSurfaceNet::labels() int32_t quadLabels[2]; // Back-bottom edge - if(m_cellMap->getEdgeQuad(idxVtx, MMCellFlag::Edge::BackBottomEdge, vertexIndices, quadLabels) == true) + if(m_cellMap->getEdgeQuad(idxVtx, MMCellFlag::Edge::BackBottomEdge, vertexIndices, quadLabels, cellIndices) == true) { labelSet.insert((int)quadLabels[0]); labelSet.insert((int)quadLabels[1]); } // Left-bottom edge - if(m_cellMap->getEdgeQuad(idxVtx, MMCellFlag::Edge::LeftBottomEdge, vertexIndices, quadLabels) == true) + if(m_cellMap->getEdgeQuad(idxVtx, MMCellFlag::Edge::LeftBottomEdge, vertexIndices, quadLabels, cellIndices) == true) { labelSet.insert(quadLabels[0]); labelSet.insert(quadLabels[1]); } // Left-back edge - if(m_cellMap->getEdgeQuad(idxVtx, MMCellFlag::Edge::LeftBackEdge, vertexIndices, quadLabels) == true) + if(m_cellMap->getEdgeQuad(idxVtx, MMCellFlag::Edge::LeftBackEdge, vertexIndices, quadLabels, cellIndices) == true) { labelSet.insert(quadLabels[0]); labelSet.insert(quadLabels[1]); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/SurfaceNets/MMSurfaceNet.h b/src/Plugins/SimplnxCore/src/SimplnxCore/SurfaceNets/MMSurfaceNet.h index de71ed9870..8738941c23 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/SurfaceNets/MMSurfaceNet.h +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/SurfaceNets/MMSurfaceNet.h @@ -57,7 +57,14 @@ class MMCellMap; class MMSurfaceNet { public: + /** + * @brief Constructs the MMSurfaceNet Object + * @param labels + * @param arraySize X Y Z Order + * @param voxelSize + */ MMSurfaceNet(int32_t* labels, int arraySize[3], float voxelSize[3]); + ~MMSurfaceNet(); // Surface smoothing (relaxation) @@ -65,7 +72,7 @@ class MMSurfaceNet { int numRelaxIterations; // More iterations --> smoother and slower float relaxFactor; // Range (0.0, 1.0); larger --> faster but less stable - float maxDistFromCellCenter; // Maximun displacement of relaxed surface in voxel units + float maxDistFromCellCenter; // Maximum displacement of relaxed surface in voxel units }; void relax(const RelaxAttrs relaxAttrs); void reset(); @@ -88,7 +95,7 @@ class MMSurfaceNet friend class MMGeometryGL; friend class MMGeometryOBJ; - MMCellMap* m_cellMap; + MMCellMap* m_cellMap = nullptr; }; #endif diff --git a/src/Plugins/SimplnxCore/test/SurfaceNetsTest.cpp b/src/Plugins/SimplnxCore/test/SurfaceNetsTest.cpp index d6a29f56d8..be22d765eb 100644 --- a/src/Plugins/SimplnxCore/test/SurfaceNetsTest.cpp +++ b/src/Plugins/SimplnxCore/test/SurfaceNetsTest.cpp @@ -13,6 +13,8 @@ using namespace nx::core; using namespace nx::core::UnitTest; using namespace nx::core::Constants; +#define SIMPLNX_WRITE_TEST_OUTPUT + TEST_CASE("SimplnxCore::SurfaceNetsFilter: NO Smoothing", "[SimplnxCore][SurfaceNetsFilter]") { @@ -43,7 +45,7 @@ TEST_CASE("SimplnxCore::SurfaceNetsFilter: NO Smoothing", "[SimplnxCore][Surface args.insertOrAssign(SurfaceNetsFilter::k_GridGeometryDataPath_Key, std::make_any(gridGeomDataPath)); args.insertOrAssign(SurfaceNetsFilter::k_CellFeatureIdsArrayPath_Key, std::make_any(featureIdsDataPath)); const MultiArraySelectionParameter::ValueType selectedArrayPaths = {ebsdSanDataPath.createChildPath("BoundaryCells"), ebsdSanDataPath.createChildPath("ConfidenceIndex"), - ebsdSanDataPath.createChildPath("IPFColors")}; + ebsdSanDataPath.createChildPath("IPFColors"), ebsdSanDataPath.createChildPath("FeatureIds")}; args.insertOrAssign(SurfaceNetsFilter::k_SelectedDataArrayPaths_Key, std::make_any(selectedArrayPaths)); @@ -69,25 +71,26 @@ TEST_CASE("SimplnxCore::SurfaceNetsFilter: NO Smoothing", "[SimplnxCore][Surface auto executeResult = filter.execute(dataStructure, args); REQUIRE(executeResult.result.valid()); - // Check a few things about the generated data. - TriangleGeom& triangleGeom = dataStructure.getDataRefAs(triangleGeometryPath); - IGeometry::SharedTriList* trianglePtr = triangleGeom.getFaces(); - IGeometry::SharedVertexList* verticesPtr = triangleGeom.getVertices(); - - REQUIRE(trianglePtr->getNumberOfTuples() == 63804); - REQUIRE(verticesPtr->getNumberOfTuples() == 28894); + // Write the DataStructure out to the file system +#ifdef SIMPLNX_WRITE_TEST_OUTPUT + WriteTestDataStructure(dataStructure, fs::path(fmt::format("{}/surface_nets.dream3d", unit_test::k_BinaryTestOutputDir))); +#endif - // Compare the shift values - CompareArrays(dataStructure, triangleGeometryPath.createChildPath("SharedTriList"), DataPath({exemplarGeometryPath, "SharedTriList"})); - CompareArrays(dataStructure, triangleGeometryPath.createChildPath("SharedVertexList"), DataPath({exemplarGeometryPath, "SharedVertexList"})); + // // Check a few things about the generated data. + // TriangleGeom& triangleGeom = dataStructure.getDataRefAs(triangleGeometryPath); + // IGeometry::SharedTriList* trianglePtr = triangleGeom.getFaces(); + // IGeometry::SharedVertexList* verticesPtr = triangleGeom.getVertices(); + // + // REQUIRE(trianglePtr->getNumberOfTuples() == 63804); + // REQUIRE(verticesPtr->getNumberOfTuples() == 28894); + // + // // Compare the shift values + // CompareArrays(dataStructure, triangleGeometryPath.createChildPath("SharedTriList"), DataPath({exemplarGeometryPath, "SharedTriList"})); + // CompareArrays(dataStructure, triangleGeometryPath.createChildPath("SharedVertexList"), DataPath({exemplarGeometryPath, "SharedVertexList"})); + // } - CompareExemplarToGeneratedData(dataStructure, dataStructure, triangleGeometryPath.createChildPath(k_FaceDataGroupName), exemplarGeometryPath); - -// Write the DataStructure out to the file system -#ifdef SIMPLNX_WRITE_TEST_OUTPUT - WriteTestDataStructure(dataStructure, fs::path(fmt::format("{}/surface_nets.dream3d", unit_test::k_BinaryTestOutputDir))); -#endif + // CompareExemplarToGeneratedData(dataStructure, dataStructure, triangleGeometryPath.createChildPath(k_FaceDataGroupName), exemplarGeometryPath); } TEST_CASE("SimplnxCore::SurfaceNetsFilter: With Smoothing", "[SimplnxCore][SurfaceNetsFilter]") @@ -146,6 +149,11 @@ TEST_CASE("SimplnxCore::SurfaceNetsFilter: With Smoothing", "[SimplnxCore][Surfa auto executeResult = filter.execute(dataStructure, args); REQUIRE(executeResult.result.valid()); +// Write the DataStructure out to the file system +#ifdef SIMPLNX_WRITE_TEST_OUTPUT + WriteTestDataStructure(dataStructure, fs::path(fmt::format("{}/surface_nets_smoothing.dream3d", unit_test::k_BinaryTestOutputDir))); +#endif + // Check a few things about the generated data. TriangleGeom& triangleGeom = dataStructure.getDataRefAs(triangleGeometryPath); IGeometry::SharedTriList* trianglePtr = triangleGeom.getFaces(); @@ -160,9 +168,4 @@ TEST_CASE("SimplnxCore::SurfaceNetsFilter: With Smoothing", "[SimplnxCore][Surfa } CompareExemplarToGeneratedData(dataStructure, dataStructure, triangleGeometryPath.createChildPath(k_FaceDataGroupName), exemplarGeometryPath); - - // Write the DataStructure out to the file system -#ifdef SIMPLNX_WRITE_TEST_OUTPUT - WriteTestDataStructure(dataStructure, fs::path(fmt::format("{}/surface_nets_smoothing.dream3d", unit_test::k_BinaryTestOutputDir))); -#endif } diff --git a/test/UnitTestCommon/include/simplnx/UnitTest/UnitTestCommon.hpp b/test/UnitTestCommon/include/simplnx/UnitTest/UnitTestCommon.hpp index aaca3b8825..621898695f 100644 --- a/test/UnitTestCommon/include/simplnx/UnitTest/UnitTestCommon.hpp +++ b/test/UnitTestCommon/include/simplnx/UnitTest/UnitTestCommon.hpp @@ -249,12 +249,12 @@ class TestFileSentinel , m_ExpectedTopLevelOutput(std::move(expectedTopLevelOutput)) { const auto errorCode = decompress(); - if(errorCode) - { - std::cout << "std::error_code.value(): " << errorCode.value() << std::endl; - std::cout << "std::error_code.message(): " << errorCode.message() << std::endl; - REQUIRE(errorCode.value() == 0); - } + // if(errorCode) + // { + // std::cout << "std::error_code.value(): " << errorCode.value() << std::endl; + // std::cout << "std::error_code.message(): " << errorCode.message() << std::endl; + // REQUIRE(errorCode.value() == 0); + // } } ~TestFileSentinel()