diff --git a/examples/VolumeToLevelSets/VolumeToLevelSets.cpp b/examples/VolumeToLevelSets/VolumeToLevelSets.cpp index 30607ce6..afa3a7ed 100644 --- a/examples/VolumeToLevelSets/VolumeToLevelSets.cpp +++ b/examples/VolumeToLevelSets/VolumeToLevelSets.cpp @@ -30,9 +30,7 @@ int main(int argc, char *argv[]) { mesh->getCellData().getScalarData("Material"); std::vector translator = {3, 2, 4, 7, 7, 6, 5, 7, 1, 0}; - if (materialData == nullptr) { - std::cout << "Could not get material data" << std::endl; - } else { + if (materialData != nullptr) { for (auto &cell : *materialData) { cell = translator[std::round(cell)]; } diff --git a/include/viennals/lsAdvect.hpp b/include/viennals/lsAdvect.hpp index 51bb630e..eef389aa 100644 --- a/include/viennals/lsAdvect.hpp +++ b/include/viennals/lsAdvect.hpp @@ -398,7 +398,7 @@ template class Advect { MarkVoidPoints(levelSets.back()).apply(); auto &pointData = levelSets.back()->getPointData(); voidMarkerPointer = - pointData.getScalarData(MarkVoidPoints::voidPointLabel); + pointData.getScalarData(MarkVoidPoints::voidPointLabel, true); if (voidMarkerPointer == nullptr) { Logger::getInstance() .addWarning("Advect: Cannot find void point markers. Not " diff --git a/include/viennals/lsBooleanOperation.hpp b/include/viennals/lsBooleanOperation.hpp index d06f55a9..89e54856 100644 --- a/include/viennals/lsBooleanOperation.hpp +++ b/include/viennals/lsBooleanOperation.hpp @@ -150,7 +150,7 @@ template class BooleanOperation { // scalars for (unsigned i = 0; i < AData.getScalarDataSize(); ++i) { auto scalarDataLabel = AData.getScalarDataLabel(i); - auto BPointer = BData.getScalarData(scalarDataLabel); + auto BPointer = BData.getScalarData(scalarDataLabel, true); if (BPointer != nullptr) { auto APointer = AData.getScalarData(i); // copy all data into the new scalarData diff --git a/include/viennals/lsCalculateCurvatures.hpp b/include/viennals/lsCalculateCurvatures.hpp index e3716095..b2d41bb0 100644 --- a/include/viennals/lsCalculateCurvatures.hpp +++ b/include/viennals/lsCalculateCurvatures.hpp @@ -173,7 +173,8 @@ template class CalculateCurvatures { // insert into pointData of levelSet if (calculateMean) { auto &pointData = levelSet->getPointData(); - auto scalarDataPointer = pointData.getScalarData(meanCurvatureLabel); + auto scalarDataPointer = + pointData.getScalarData(meanCurvatureLabel, true); // if it does not exist, insert new normals vector if (scalarDataPointer == nullptr) { pointData.insertNextScalarData(meanCurvaturesVector[0], @@ -186,7 +187,8 @@ template class CalculateCurvatures { if (calculateGauss) { auto &pointData = levelSet->getPointData(); - auto scalarDataPointer = pointData.getScalarData(gaussianCurvatureLabel); + auto scalarDataPointer = + pointData.getScalarData(gaussianCurvatureLabel, true); // if it does not exist, insert new normals vector if (scalarDataPointer == nullptr) { pointData.insertNextScalarData(gaussCurvaturesVector[0], diff --git a/include/viennals/lsDetectFeatures.hpp b/include/viennals/lsDetectFeatures.hpp index 335ba7ab..26bb8ed2 100644 --- a/include/viennals/lsDetectFeatures.hpp +++ b/include/viennals/lsDetectFeatures.hpp @@ -71,7 +71,7 @@ template class DetectFeatures { // insert into pointData of levelSet auto &pointData = levelSet->getPointData(); - auto vectorDataPointer = pointData.getScalarData(featureMarkersLabel); + auto vectorDataPointer = pointData.getScalarData(featureMarkersLabel, true); // if it does not exist, insert new feature vector if (vectorDataPointer == nullptr) { pointData.insertNextScalarData(flaggedCells, featureMarkersLabel); diff --git a/include/viennals/lsFromMesh.hpp b/include/viennals/lsFromMesh.hpp index 6bff4de1..3b04f1bc 100644 --- a/include/viennals/lsFromMesh.hpp +++ b/include/viennals/lsFromMesh.hpp @@ -53,7 +53,7 @@ template class FromMesh { auto &domain = levelSet->getDomain(); auto &nodes = mesh->getNodes(); - auto values = mesh->cellData.getScalarData("LSValues"); + auto values = mesh->cellData.getScalarData("LSValues", true); if (values == nullptr) { Logger::getInstance() diff --git a/include/viennals/lsFromVolumeMesh.hpp b/include/viennals/lsFromVolumeMesh.hpp index f6f3478a..b5d1b7e4 100644 --- a/include/viennals/lsFromVolumeMesh.hpp +++ b/include/viennals/lsFromVolumeMesh.hpp @@ -70,7 +70,7 @@ template class FromVolumeMesh { // get the unique material numbers for explicit booling std::vector materialInts; typename PointData::ScalarDataType *materialData = - mesh->cellData.getScalarData("Material"); + mesh->cellData.getScalarData("Material", true); if (materialData != nullptr) { // make unique list of materialIds materialInts = diff --git a/include/viennals/lsMarkVoidPoints.hpp b/include/viennals/lsMarkVoidPoints.hpp index cb8c6257..f6447d6e 100644 --- a/include/viennals/lsMarkVoidPoints.hpp +++ b/include/viennals/lsMarkVoidPoints.hpp @@ -303,7 +303,7 @@ template class MarkVoidPoints { } auto &pointData = domain->getPointData(); - auto voidMarkersPointer = pointData.getScalarData(voidPointLabel); + auto voidMarkersPointer = pointData.getScalarData(voidPointLabel, true); // if vector data does not exist if (voidMarkersPointer == nullptr) { pointData.insertNextScalarData(voidPointMarkers, voidPointLabel); @@ -313,7 +313,7 @@ template class MarkVoidPoints { if (saveComponents) { auto componentMarkersPointer = - pointData.getScalarData("ConnectedComponentId"); + pointData.getScalarData("ConnectedComponentId", true); // if vector data does not exist if (componentMarkersPointer == nullptr) { pointData.insertNextScalarData(componentMarkers, diff --git a/include/viennals/lsPointData.hpp b/include/viennals/lsPointData.hpp index baae835c..188044e6 100644 --- a/include/viennals/lsPointData.hpp +++ b/include/viennals/lsPointData.hpp @@ -95,27 +95,31 @@ class PointData { return indexPointerOrNull(scalarData, index); } - ScalarDataType *getScalarData(std::string searchLabel) { + ScalarDataType *getScalarData(std::string searchLabel, + bool noWarning = false) { if (int i = getScalarDataIndex(searchLabel); i != -1) { return &(scalarData[i]); } - Logger::getInstance() - .addWarning("PointData attempted to access scalar data labeled '" + - searchLabel + - "', which does not exist. Returning nullptr instead.") - .print(); + if (!noWarning) + Logger::getInstance() + .addWarning("PointData attempted to access scalar data labeled '" + + searchLabel + + "', which does not exist. Returning nullptr instead.") + .print(); return nullptr; } - const ScalarDataType *getScalarData(std::string searchLabel) const { + const ScalarDataType *getScalarData(std::string searchLabel, + bool noWarning = false) const { if (int i = getScalarDataIndex(searchLabel); i != -1) { return &(scalarData[i]); } - Logger::getInstance() - .addWarning("PointData attempted to access scalar data labeled '" + - searchLabel + - "', which does not exist. Returning nullptr instead.") - .print(); + if (!noWarning) + Logger::getInstance() + .addWarning("PointData attempted to access scalar data labeled '" + + searchLabel + + "', which does not exist. Returning nullptr instead.") + .print(); return nullptr; } @@ -152,27 +156,31 @@ class PointData { return indexPointerOrNull(vectorData, index); } - VectorDataType *getVectorData(std::string searchLabel) { + VectorDataType *getVectorData(std::string searchLabel, + bool noWarning = false) { if (int i = getVectorDataIndex(searchLabel); i != -1) { return &(vectorData[i]); } - Logger::getInstance() - .addWarning("PointData attempted to access scalar data labeled '" + - searchLabel + - "', which does not exist. Returning nullptr instead.") - .print(); + if (!noWarning) + Logger::getInstance() + .addWarning("PointData attempted to access vector data labeled '" + + searchLabel + + "', which does not exist. Returning nullptr instead.") + .print(); return nullptr; } - const VectorDataType *getVectorData(std::string searchLabel) const { + const VectorDataType *getVectorData(std::string searchLabel, + bool noWarning = false) const { if (int i = getVectorDataIndex(searchLabel); i != -1) { return &(vectorData[i]); } - Logger::getInstance() - .addWarning("PointData attempted to access scalar data labeled '" + - searchLabel + - "', which does not exist. Returning nullptr instead.") - .print(); + if (!noWarning) + Logger::getInstance() + .addWarning("PointData attempted to access vector data labeled '" + + searchLabel + + "', which does not exist. Returning nullptr instead.") + .print(); return nullptr; } diff --git a/include/viennals/lsRemoveStrayPoints.hpp b/include/viennals/lsRemoveStrayPoints.hpp index b80cb2ef..d4c03a45 100644 --- a/include/viennals/lsRemoveStrayPoints.hpp +++ b/include/viennals/lsRemoveStrayPoints.hpp @@ -54,7 +54,7 @@ template class RemoveStrayPoints { } auto voidMarkers = - levelSet->getPointData().getScalarData("VoidPointMarkers"); + levelSet->getPointData().getScalarData("VoidPointMarkers", true); if (voidMarkers == nullptr) { Logger::getInstance() .addWarning("RemoveStrayPoints: No scalar data for void point "