Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ The Axom project release numbers follow [Semantic Versioning](http://semver.org/
internal `quest::internal::read_*_mesh()`/`logger_init()` helpers are now declared only when Axom is
configured with MPI. Serial code that passed the placeholder `MPI_COMM_SELF` explicitly should drop the argument.
- We can now configure Axom without MPI when some of its dependencies were configured with MPI.
- Quest: Status-returning reader/writer operations in `C2CReader`, `MFEMReader`, `ProEReader`,
`STEPReader`, `STLReader`, `STLWriter`, and their parallel variants are now marked `[[nodiscard]]`.
Callers that previously ignored returned status values must check them to avoid compiler diagnostics.

### Fixed
- MIR/Bump: `MergeCoordsetPoints` now only emits its node-merge `SLIC_INFO` when MIR `verbose` is enabled on the Conduit options passed through ELVIRA.
Expand Down
3 changes: 2 additions & 1 deletion src/axom/quest/examples/containment_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ class ContainmentDriver
AXOM_ANNOTATE_SCOPE("load stl");
quest::STLReader reader;
reader.setFileName(inputFile);
reader.read();
const int read_status = reader.read();
SLIC_ERROR_IF(read_status != 0, "Failed to load STL file '" << inputFile << "'.");

// Create surface mesh
m_surfaceMesh.reset(new UMesh(3, mint::TRIANGLE));
Expand Down
3 changes: 2 additions & 1 deletion src/axom/quest/examples/quest_bvh_two_pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,8 @@ int main(int argc, char** argv)
{
axom::quest::STLReader reader;
reader.setFileName(args.file_name);
reader.read();
const int read_status = reader.read();
SLIC_ERROR_IF(read_status != 0, "Failed to load STL file '" << args.file_name << "'.");

// Get surface mesh
surface_mesh.reset(new UMesh(3, mint::TRIANGLE));
Expand Down
3 changes: 2 additions & 1 deletion src/axom/quest/examples/quest_proe_bbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ int main(int argc, char** argv)
// To keep all tets, do not set a TetPred.

// Read in the file.
reader.read();
const int read_status = reader.read();
SLIC_ERROR_IF(read_status != 0, "Failed to load Pro/E file '" << args.file_name << "'.");

// Get surface mesh
UMesh mesh(3, axom::mint::TET);
Expand Down
28 changes: 16 additions & 12 deletions src/axom/quest/examples/quest_step_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1103,11 +1103,12 @@ int main(int argc, char** argv)
constexpr bool extract_trimmed_surface = true;

axom::mint::UnstructuredMesh<axom::mint::SINGLE_SHAPE> mesh(3, axom::mint::TRIANGLE);
stepReader.getTriangleMesh(&mesh,
deflection,
angular_deflection,
relative_deflection,
extract_trimmed_surface);
const int triangulation_status = stepReader.getTriangleMesh(&mesh,
deflection,
angular_deflection,
relative_deflection,
extract_trimmed_surface);
SLIC_ERROR_IF(triangulation_status != 0, "Failed to triangulate the trimmed STEP model.");

#ifdef AXOM_USE_MPI
if(validate_model && !validate_triangle_mesh(mesh))
Expand All @@ -1129,7 +1130,8 @@ int main(int argc, char** argv)
else
{
axom::quest::STLWriter writer(output_file, true);
writer.write(&mesh);
const int write_status = writer.write(&mesh);
SLIC_ERROR_IF(write_status != 0, "Failed to write STL file '" << output_file << "'.");
}

SLIC_INFO(axom::fmt::format(axom::utilities::locale(),
Expand All @@ -1154,11 +1156,12 @@ int main(int argc, char** argv)
constexpr bool extract_trimmed_surface = false;

axom::mint::UnstructuredMesh<axom::mint::SINGLE_SHAPE> mesh(3, axom::mint::TRIANGLE);
stepReader.getTriangleMesh(&mesh,
deflection,
angular_deflection,
relative_deflection,
extract_trimmed_surface);
const int triangulation_status = stepReader.getTriangleMesh(&mesh,
deflection,
angular_deflection,
relative_deflection,
extract_trimmed_surface);
SLIC_ERROR_IF(triangulation_status != 0, "Failed to triangulate the untrimmed STEP model.");

#ifdef AXOM_USE_MPI
if(validate_model && !validate_triangle_mesh(mesh))
Expand All @@ -1180,7 +1183,8 @@ int main(int argc, char** argv)
else
{
axom::quest::STLWriter writer(output_file, true);
writer.write(&mesh);
const int write_status = writer.write(&mesh);
SLIC_ERROR_IF(write_status != 0, "Failed to write STL file '" << output_file << "'.");
}

SLIC_INFO(
Expand Down
33 changes: 15 additions & 18 deletions src/axom/quest/io/C2CReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,11 @@
#include <string>
#include <utility>

namespace axom
{
namespace quest
namespace axom::quest
{
namespace
{
c2c::LengthUnit toC2CLengthUnit(utilities::LengthUnit unit)
constexpr c2c::LengthUnit toC2CLengthUnit(utilities::LengthUnit unit)
{
switch(unit)
{
Expand Down Expand Up @@ -82,7 +80,7 @@ bool C2CReader::hasValidExtension(const std::string& filename)

int C2CReader::read()
{
SLIC_WARNING_IF(m_fileName.empty(), "Missing a filename in C2CReader::read()");
SLIC_WARNING_ROOT_IF(m_fileName.empty(), "Missing a filename in C2CReader::read()");

// Always clear prior results so callers never observe stale curves after a failed read
this->clear();
Expand All @@ -104,7 +102,7 @@ C2CReader::ResultType C2CReader::readInternal(const std::string& filename, Curve
{
if(!hasValidExtension(filename))
{
SLIC_WARNING(axom::fmt::format("{} is not a valid c2c file", filename));
SLIC_WARNING_ROOT(axom::fmt::format("{} is not a valid c2c file", filename));
return ResultType::Failure;
}

Expand All @@ -119,11 +117,11 @@ C2CReader::ResultType C2CReader::readInternal(const std::string& filename, Curve
}
catch(const std::exception& e)
{
SLIC_WARNING(axom::fmt::format("Failed to read c2c file '{}': {}", filename, e.what()));
SLIC_WARNING_ROOT(axom::fmt::format("Failed to read c2c file '{}': {}", filename, e.what()));
}
catch(...)
{
SLIC_WARNING(axom::fmt::format("Failed to read c2c file '{}'", filename));
SLIC_WARNING_ROOT(axom::fmt::format("Failed to read c2c file '{}'", filename));
}

return ResultType::Failure;
Expand All @@ -135,10 +133,10 @@ C2CReader::ResultType C2CReader::readAssembly(const std::string& filename, Curve
std::string assemblyDir;
utilities::filesystem::getDirName(assemblyDir, filename);

SLIC_INFO(fmt::format("Loading assembly with {} pieces", assembly.getNumEntries()));
SLIC_INFO_ROOT(fmt::format("Loading assembly with {} pieces", assembly.getNumEntries()));

// Make an initial guess at the number of curves we may need.
const int contoursPerFileGuess = 6;
constexpr int contoursPerFileGuess = 6;
CurveArray assemblyCurves;
assemblyCurves.reserve(assembly.getNumEntries() * contoursPerFileGuess);

Expand Down Expand Up @@ -172,7 +170,7 @@ C2CReader::ResultType C2CReader::readContour(const std::string& filename, CurveA
c2c::Contour contour = c2c::parseContour(filename);
const c2c::LengthUnit c2cLengthUnit = toC2CLengthUnit(m_lengthUnit);

SLIC_INFO(fmt::format("Loading contour with {} pieces", contour.getPieces().size()));
SLIC_INFO_ROOT(fmt::format("Loading contour with {} pieces", contour.getPieces().size()));

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dylan-copeland -- this is the line that was getting in your way


inputCurves.reserve(inputCurves.size() + contour.getPieces().size());

Expand All @@ -199,7 +197,7 @@ C2CReader::ResultType C2CReader::readContour(const std::string& filename, CurveA
const int degree = static_cast<int>(nkts - npts - 1);
if(degree < 0)
{
SLIC_WARNING(
SLIC_WARNING_ROOT(
fmt::format("Invalid contour file '{}': computed negative NURBS degree for piece "
"{} (npts={}, nkts={})",
filename,
Expand All @@ -211,7 +209,7 @@ C2CReader::ResultType C2CReader::readContour(const std::string& filename, CurveA

if(npts <= degree)
{
SLIC_WARNING(
SLIC_WARNING_ROOT(
fmt::format("Invalid contour file '{}': piece {} has too few control points for degree "
"(degree={}, npts={}, nkts={})",
filename,
Expand All @@ -229,7 +227,7 @@ C2CReader::ResultType C2CReader::readContour(const std::string& filename, CurveA

if(!knotvec.isValid(true))
{
SLIC_WARNING(
SLIC_WARNING_ROOT(
fmt::format("Invalid contour file '{}': piece {} converted to an invalid NURBS knot vector "
"(degree={}).",
filename,
Expand All @@ -244,7 +242,7 @@ C2CReader::ResultType C2CReader::readContour(const std::string& filename, CurveA
{
if(static_cast<axom::IndexType>(nurbsData.weights.size()) != controlPoints.size())
{
SLIC_WARNING(
SLIC_WARNING_ROOT(
fmt::format("Invalid contour file '{}': piece {} has {} weights for {} control points",
filename,
piece_index,
Expand Down Expand Up @@ -304,8 +302,7 @@ void C2CReader::log()
++index;
}

SLIC_INFO(sstr.str());
SLIC_INFO_ROOT(sstr.str());
}

} // end namespace quest
} // end namespace axom
} // namespace axom::quest
17 changes: 8 additions & 9 deletions src/axom/quest/io/C2CReader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
#include <string>
#include <vector>

namespace axom
{
namespace quest
namespace axom::quest
{
/*
* \class C2CReader
Expand All @@ -38,6 +36,7 @@ class C2CReader
using NURBSCurve = axom::primal::NURBSCurve<double, 2>;
using CurveArray = axom::Array<NURBSCurve>;
using CurveArrayView = axom::ArrayView<NURBSCurve>;
using ConstCurveArrayView = axom::ArrayView<const NURBSCurve>;

enum class ResultType
{
Expand Down Expand Up @@ -67,7 +66,7 @@ class C2CReader
*
* \return 0 for a successful read; non-zero otherwise
*/
virtual int read();
[[nodiscard]] virtual int read();

/// \brief Utility function to log details about the read in file
virtual void log();
Expand All @@ -78,6 +77,7 @@ class C2CReader
* \return A view that contains the curves.
*/
CurveArrayView getCurvesView() { return m_nurbsData.view(); }
ConstCurveArrayView getCurvesView() const { return m_nurbsData.view(); }

protected:
/*!
Expand All @@ -88,7 +88,7 @@ class C2CReader
*
* \return Success on success, Failure otherwise.
*/
ResultType readInternal(const std::string& filename, CurveArray& inputCurves);
[[nodiscard]] ResultType readInternal(const std::string& filename, CurveArray& inputCurves);

/*!
* \brief Internal helper for reading a contour file.
Expand All @@ -98,7 +98,7 @@ class C2CReader
*
* \return Success on success, Failure otherwise.
*/
ResultType readContour(const std::string& filename, CurveArray& inputCurves);
[[nodiscard]] ResultType readContour(const std::string& filename, CurveArray& inputCurves);

/*!
* \brief Internal helper for reading an assembly file.
Expand All @@ -108,13 +108,12 @@ class C2CReader
*
* \return Success on success, Failure otherwise.
*/
ResultType readAssembly(const std::string& filename, CurveArray& inputCurves);
[[nodiscard]] ResultType readAssembly(const std::string& filename, CurveArray& inputCurves);

protected:
std::string m_fileName;
utilities::LengthUnit m_lengthUnit {utilities::LengthUnit::cm};
CurveArray m_nurbsData;
};

} // namespace quest
} // namespace axom
} // namespace axom::quest
25 changes: 13 additions & 12 deletions src/axom/quest/io/MFEMReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ int read_mfem(const std::string& fileName,
{
if(!axom::utilities::filesystem::pathExists(fileName))
{
SLIC_WARNING(axom::fmt::format("Cannot open the provided MFEM mesh file '{}'", fileName));
SLIC_WARNING_ROOT(axom::fmt::format("Cannot open the provided MFEM mesh file '{}'", fileName));
return MFEMReader::READ_FAILED;
}

Expand All @@ -59,7 +59,7 @@ int read_mfem(const std::string& fileName,

if(mesh->Dimension() != 1 || mesh->SpaceDimension() != 2)
{
SLIC_WARNING(
SLIC_WARNING_ROOT(
axom::fmt::format("Mesh must have dimension 1 and spatial dimension 2. The supplied mesh "
"is dimension {} with spatial dimension {}.",
mesh->Dimension(),
Expand All @@ -72,7 +72,7 @@ int read_mfem(const std::string& fileName,
const auto* fec = fes != nullptr ? fes->FEColl() : nullptr;
if(nodes == nullptr || fes == nullptr || fec == nullptr)
{
SLIC_WARNING("Mesh does not have a valid nodes grid function");
SLIC_WARNING_ROOT("Mesh does not have a valid nodes grid function");
return MFEMReader::READ_FAILED;
}

Expand Down Expand Up @@ -105,7 +105,7 @@ int read_mfem(const std::string& fileName,
mesh->NURBSext->GetPatchDofs(patchId, dofs);
if(dofs.Size() <= 0)
{
SLIC_WARNING(
SLIC_WARNING_ROOT(
axom::fmt::format("MFEM patch {} has no DOFs; cannot extract NURBS curve.", patchId));
return {};
}
Expand Down Expand Up @@ -205,15 +205,15 @@ int read_mfem(const std::string& fileName,
mesh->NURBSext->GetPatchKnotVectors(patchId, kvs);
if(kvs.Size() < 1 || kvs[0] == nullptr)
{
SLIC_WARNING(
SLIC_WARNING_ROOT(
axom::fmt::format("MFEM patch {} has no valid knot vector; cannot extract NURBS curve.",
patchId));
return MFEMReader::READ_FAILED;
}
const mfem::KnotVector& kv0 = *kvs[0];
if(kv0.Size() <= 0)
{
SLIC_WARNING(
SLIC_WARNING_ROOT(
axom::fmt::format("MFEM patch {} has an empty knot vector; cannot extract NURBS curve.",
patchId));
return MFEMReader::READ_FAILED;
Expand All @@ -224,7 +224,8 @@ int read_mfem(const std::string& fileName,
const primal::KnotVector<double> kv(knots_view, kv0.GetOrder(), SkipTag {});
if(!kv.isValid(true))
{
SLIC_WARNING(axom::fmt::format("MFEM patch {} has an invalid knot vector: {}", patchId, kv));
SLIC_WARNING_ROOT(
axom::fmt::format("MFEM patch {} has an invalid knot vector: {}", patchId, kv));
return MFEMReader::READ_FAILED;
}

Expand Down Expand Up @@ -262,7 +263,7 @@ int read_mfem(const std::string& fileName,
const bool is_bernstein = dynamic_cast<const mfem::H1Pos_FECollection*>(fec) != nullptr;
if(!is_bernstein)
{
SLIC_WARNING(axom::fmt::format(
SLIC_WARNING_ROOT(axom::fmt::format(
"Non-NURBS meshes must define their nodes in the positive Bernstein basis "
"(mfem::H1Pos_FECollection). Got FECollection '{}'.",
fec->Name()));
Expand Down Expand Up @@ -298,7 +299,7 @@ int read_mfem(const std::string& fileName,
return MFEMReader::READ_SUCCESS;
}

} // end namespace internal
} // namespace internal

int MFEMReader::read(CurveArray& curves)
{
Expand All @@ -308,7 +309,7 @@ int MFEMReader::read(CurveArray& curves)

int MFEMReader::read(CurveArray& curves, axom::Array<int>& attributes)
{
SLIC_WARNING_IF(m_fileName.empty(), "Missing a filename in MFEMReader::read()");
SLIC_WARNING_ROOT_IF(m_fileName.empty(), "Missing a filename in MFEMReader::read()");

curves.clear();
attributes.clear();
Expand Down Expand Up @@ -337,7 +338,7 @@ int MFEMReader::read(CurvedPolygonArray& curvedPolygons)

int MFEMReader::read(CurvedPolygonArray& curvedPolygons, axom::Array<int>& attributes)
{
SLIC_WARNING_IF(m_fileName.empty(), "Missing a filename in MFEMReader::read()");
SLIC_WARNING_ROOT_IF(m_fileName.empty(), "Missing a filename in MFEMReader::read()");

curvedPolygons.clear();
attributes.clear();
Expand All @@ -363,4 +364,4 @@ int MFEMReader::read(CurvedPolygonArray& curvedPolygons, axom::Array<int>& attri
return ret;
}

} // end namespace axom::quest
} // namespace axom::quest
Loading