Skip to content

Commit 550b991

Browse files
authored
Merge pull request #1436 from LLNL/feature/gunney/construct-shapes-in-memory
Construct shapes in memory and support more shapes
2 parents b811391 + 8dbe147 commit 550b991

33 files changed

+3105
-407
lines changed

RELEASE-NOTES.md

+4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ The Axom project release numbers follow [Semantic Versioning](http://semver.org/
2020
## [Unreleased] - Release date yyyy-mm-dd
2121

2222
### Added
23+
- A number of new `klee::Geometry` constructors are added, for the different shapes now supported.
24+
This is a temporary change. The class will be subclassed in the future to support a diversity of geometries.
25+
- Support some analytical shapes in `IntersectionShaper`.
26+
- Support generating shapes in memory (not requiring input files).
2327
- `sidre::View` holding array data may now be re-shaped. See `sidre::View::reshapeArray`.
2428
- Sina C++ library is now a component of Axom
2529
- Adds optional dependency on [Open Cascade](https://dev.opencascade.org). The initial intention is

src/axom/klee/Geometry.cpp

+124-3
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,128 @@
66
#include "axom/klee/Geometry.hpp"
77

88
#include "axom/klee/GeometryOperators.hpp"
9+
#include "conduit_blueprint_mesh.hpp"
910

1011
#include <utility>
1112

1213
namespace axom
1314
{
1415
namespace klee
1516
{
16-
bool operator==(const TransformableGeometryProperties &lhs,
17-
const TransformableGeometryProperties &rhs)
17+
bool operator==(const TransformableGeometryProperties& lhs,
18+
const TransformableGeometryProperties& rhs)
1819
{
1920
return lhs.dimensions == rhs.dimensions && lhs.units == rhs.units;
2021
}
2122

22-
Geometry::Geometry(const TransformableGeometryProperties &startProperties,
23+
Geometry::Geometry(const TransformableGeometryProperties& startProperties,
2324
std::string format,
2425
std::string path,
2526
std::shared_ptr<GeometryOperator const> operator_)
2627
: m_startProperties(startProperties)
2728
, m_format(std::move(format))
2829
, m_path(std::move(path))
30+
, m_levelOfRefinement(0)
2931
, m_operator(std::move(operator_))
3032
{ }
3133

34+
Geometry::Geometry(const TransformableGeometryProperties& startProperties,
35+
const axom::sidre::Group* simplexMeshGroup,
36+
const std::string& topology,
37+
std::shared_ptr<GeometryOperator const> operator_)
38+
: m_startProperties(startProperties)
39+
, m_format("blueprint-tets")
40+
, m_path()
41+
, m_meshGroup(simplexMeshGroup)
42+
, m_topology(topology)
43+
, m_levelOfRefinement(0)
44+
, m_operator(std::move(operator_))
45+
{ }
46+
47+
Geometry::Geometry(const TransformableGeometryProperties& startProperties,
48+
const axom::primal::Tetrahedron<double, 3>& tet,
49+
std::shared_ptr<GeometryOperator const> operator_)
50+
: m_startProperties(startProperties)
51+
, m_format("tet3D")
52+
, m_path()
53+
, m_meshGroup(nullptr)
54+
, m_topology()
55+
, m_tet(tet)
56+
, m_levelOfRefinement(0)
57+
, m_operator(std::move(operator_))
58+
{ }
59+
60+
Geometry::Geometry(const TransformableGeometryProperties& startProperties,
61+
const axom::primal::Hexahedron<double, 3>& hex,
62+
std::shared_ptr<GeometryOperator const> operator_)
63+
: m_startProperties(startProperties)
64+
, m_format("hex3D")
65+
, m_path()
66+
, m_meshGroup(nullptr)
67+
, m_topology()
68+
, m_hex(hex)
69+
, m_levelOfRefinement(0)
70+
, m_operator(std::move(operator_))
71+
{ }
72+
73+
Geometry::Geometry(const TransformableGeometryProperties& startProperties,
74+
const Sphere3D& sphere,
75+
axom::IndexType levelOfRefinement,
76+
std::shared_ptr<GeometryOperator const> operator_)
77+
: m_startProperties(startProperties)
78+
, m_format("sphere3D")
79+
, m_path()
80+
, m_meshGroup(nullptr)
81+
, m_topology()
82+
, m_sphere(sphere)
83+
, m_levelOfRefinement(levelOfRefinement)
84+
, m_operator(std::move(operator_))
85+
{ }
86+
87+
Geometry::Geometry(const TransformableGeometryProperties& startProperties,
88+
const axom::Array<double, 2>& discreteFunction,
89+
const Point3D& vorBase,
90+
const Vector3D& vorDirection,
91+
axom::IndexType levelOfRefinement,
92+
std::shared_ptr<GeometryOperator const> operator_)
93+
: m_startProperties(startProperties)
94+
, m_format("vor3D")
95+
, m_path()
96+
, m_meshGroup(nullptr)
97+
, m_topology()
98+
, m_sphere()
99+
, m_discreteFunction(discreteFunction)
100+
, m_vorBase(vorBase)
101+
, m_vorDirection(vorDirection)
102+
, m_levelOfRefinement(levelOfRefinement)
103+
, m_operator(std::move(operator_))
104+
{ }
105+
106+
Geometry::Geometry(const TransformableGeometryProperties& startProperties,
107+
const axom::primal::Plane<double, 3>& plane,
108+
std::shared_ptr<GeometryOperator const> operator_)
109+
: m_startProperties(startProperties)
110+
, m_format("plane3D")
111+
, m_path()
112+
, m_meshGroup(nullptr)
113+
, m_topology()
114+
, m_plane(plane)
115+
, m_levelOfRefinement(0)
116+
, m_operator(std::move(operator_))
117+
{ }
118+
119+
bool Geometry::hasGeometry() const
120+
{
121+
bool isInMemory = m_format == "blueprint-tets" || m_format == "sphere3D" ||
122+
m_format == "tet3D" || m_format == "hex3D" || m_format == "plane3D" ||
123+
m_format == "cone3D" || m_format == "cylinder3D";
124+
if(isInMemory)
125+
{
126+
return true;
127+
}
128+
return !m_path.empty();
129+
}
130+
32131
TransformableGeometryProperties Geometry::getEndProperties() const
33132
{
34133
if(m_operator)
@@ -38,5 +137,27 @@ TransformableGeometryProperties Geometry::getEndProperties() const
38137
return m_startProperties;
39138
}
40139

140+
const axom::sidre::Group* Geometry::getBlueprintMesh() const
141+
{
142+
SLIC_ASSERT_MSG(
143+
m_meshGroup,
144+
axom::fmt::format(
145+
"The Geometry format '{}' is not specified "
146+
"as a blueprint mesh and/or has not been converted into one.",
147+
m_format));
148+
return m_meshGroup;
149+
}
150+
151+
const std::string& Geometry::getBlueprintTopology() const
152+
{
153+
SLIC_ASSERT_MSG(
154+
m_meshGroup,
155+
axom::fmt::format(
156+
"The Geometry format '{}' is not specified "
157+
"as a blueprint mesh and/or has not been converted into one.",
158+
m_format));
159+
return m_topology;
160+
}
161+
41162
} // namespace klee
42163
} // namespace axom

0 commit comments

Comments
 (0)