AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
axom::quest::experimental::MeshClipperStrategy Class Reference

Strategy base class for clipping operations for specific geometry instances, for use by MeshClipper. More...

#include </home/docs/checkouts/readthedocs.org/user_builds/axom/checkouts/develop/src/axom/quest/MeshClipperStrategy.hpp>

Public Types

enum class  LabelType : char { LABEL_IN = 0 , LABEL_ON = 1 , LABEL_OUT = 2 }
 A type to denote whether something is inside, on or outside the boundary of a geometry. More...
 
using BoundingBox3DType = axom::primal::BoundingBox< double, 3 >
 
using Cone3DType = axom::primal::Cone< double, 3 >
 
using HexahedronType = axom::primal::Hexahedron< double, 3 >
 
using OctahedronType = axom::primal::Octahedron< double, 3 >
 
using Plane3DType = axom::primal::Plane< double, 3 >
 
using Point3DType = axom::primal::Point< double, 3 >
 
using Ray3DType = axom::primal::Ray< double, 3 >
 
using Segment3DType = axom::primal::Segment< double, 3 >
 
using SphereType = axom::primal::Sphere< double, 3 >
 
using TetrahedronType = axom::primal::Tetrahedron< double, 3 >
 
using Triangle3DType = axom::primal::Triangle< double, 3 >
 
using Vector3DType = axom::primal::Vector< double, 3 >
 
using BoundingBox2DType = axom::primal::BoundingBox< double, 2 >
 
using Point2DType = axom::primal::Point< double, 2 >
 
using CircleType = axom::primal::Sphere< double, 2 >
 
using Plane2DType = axom::primal::Plane< double, 2 >
 
using Ray2DType = axom::primal::Ray< double, 2 >
 
using Segment2DType = axom::primal::Segment< double, 2 >
 

Public Member Functions

 MeshClipperStrategy (const klee::Geometry &kGeom)
 Construct a strategy for the given klee::Geometry object. More...
 
virtual const std::string & name () const
 Optional name for strategy. More...
 
const conduit::Node & info () const
 Information on the geometry. More...
 

Static Public Attributes

static constexpr axom::IndexType NUM_TETS_PER_HEX = ShapeMesh::NUM_TETS_PER_HEX
 
static constexpr axom::IndexType NUM_VERTS_PER_CELL_3D = ShapeMesh::NUM_VERTS_PER_CELL_3D
 

Geometry-specialized methods

conduit::Node m_info
 Information on the geometry. More...
 
numerics::Matrix< double > m_extTrans
 External transformation due to the GeometryOperator. More...
 
virtual const axom::primal::BoundingBox< double, 2 > & getBoundingBox2D () const
 Get the 2D axis-aligned bounding box for the geometry, if it's applicable and available. More...
 
virtual const axom::primal::BoundingBox< double, 3 > & getBoundingBox3D () const
 Get the 3D axis-aligned bounding box for the geometry, if it's applicable and available. More...
 
virtual bool labelCellsInOut (quest::experimental::ShapeMesh &shapeMesh, axom::Array< LabelType > &cellLabels)
 Label each cell in the mesh as inside, outside or both/undetermined, if possible. More...
 
virtual bool labelTetsInOut (quest::experimental::ShapeMesh &shapeMesh, axom::ArrayView< const axom::IndexType > cellIds, axom::Array< LabelType > &tetLabels)
 Label each tetrahedron in the given cells, as inside, outside or both/undetermined, if possible. More...
 
virtual bool specializedClipCells (quest::experimental::ShapeMesh &shapeMesh, axom::ArrayView< double > ovlap, conduit::Node &statistics)
 Clip with a fast geometry-specialized method if possible. More...
 
virtual bool specializedClipCells (quest::experimental::ShapeMesh &shapeMesh, axom::ArrayView< double > ovlap, const axom::ArrayView< IndexType > &cellIds, conduit::Node &statistics)
 Clip with a fast geometry-specialized method if possible. More...
 
virtual bool specializedClipTets (quest::experimental::ShapeMesh &shapeMesh, axom::ArrayView< double > ovlap, const axom::ArrayView< IndexType > &tetIds, conduit::Node &statistics)
 
virtual bool getGeometryAsTets (quest::experimental::ShapeMesh &shapeMesh, axom::Array< TetrahedronType > &tets)
 Get the geometry as discrete tetrahedra, or return false. More...
 
virtual bool getGeometryAsOcts (quest::experimental::ShapeMesh &shapeMesh, axom::Array< OctahedronType > &octs)
 Get the geometry as discrete octahedra, or return false. More...
 

Detailed Description

Strategy base class for clipping operations for specific geometry instances, for use by MeshClipper.

Key methods to implement: (Some combination of these is required.)

  1. getBoundingBox2D or getBoundingBox3D: Axis-aligned bounding box for the geometry.
  2. labelCellsInOut: Label the cells in a mesh as inside, outside or on the shape boundary. If a cell cannot be determined, you can conservatively label it as on the boundary.
  3. labelTetsInOut: Label the tets in a mesh as inside, outside or on the shape boundary. The tets come from decomposing the hexahedral mesh cells. If a tet cannot be determined, you can conservatively label it as on the boundary.
  4. getShapesAsTets: Build an array of tetrahedra to approximate the shape.
  5. getShapesAsOcts: Build an array of octahedra to approximate the shape.
  6. specializedClipCells: Use a fast clipping algorithm (if one is available) to clip the cells in a mesh. Implementation should use special knowledge of the geometry. One version of this method clips all cells in the mesh, one clips only cells in a provided index list and one only clips the tetrahedra (which come from decomposing the mesh cells) in a provided index list. The last two work in conjunction with labelCellsInOut and labelTetsInOut.

Every method should return true if it fulfilled the request, or false if it was a no-op.

Subclasses of MeshClipperStrategy must implement either

  • a specializedClipCells or specializedClipTets method or
  • one of the getShapesAs...() methods. The former is prefered if the use of geometry-specific information can make it faster. labelCellsInOut and labelTetsInOut are optional but if provided, they can improve performance by limiting the slower clipping steps to a smaller subset. getBoundingBox2D or getBoundingBox3D can also improve performance by reducing computation.

Member Typedef Documentation

◆ BoundingBox3DType

◆ Cone3DType

◆ HexahedronType

◆ OctahedronType

◆ Plane3DType

◆ Point3DType

◆ Ray3DType

◆ Segment3DType

◆ SphereType

◆ TetrahedronType

◆ Triangle3DType

◆ Vector3DType

◆ BoundingBox2DType

◆ Point2DType

◆ CircleType

◆ Plane2DType

◆ Ray2DType

◆ Segment2DType

Member Enumeration Documentation

◆ LabelType

A type to denote whether something is inside, on or outside the boundary of a geometry.

Enumerator
LABEL_IN 

Denotes something inside a shape boundary.

LABEL_ON 

Denotes something on a shape boundary.

LABEL_OUT 

Denotes something outside a shape boundary.

Constructor & Destructor Documentation

◆ MeshClipperStrategy()

axom::quest::experimental::MeshClipperStrategy::MeshClipperStrategy ( const klee::Geometry kGeom)

Construct a strategy for the given klee::Geometry object.

Parameters
[in]kGeomDescribes the shape to place into the mesh.

Note for subclasses: This class makes geometry-specific hierarchy data from kGeom available to subclasses via the info() method. It's up to each subclass to define the required content of the hierarchy, validate it fail fast if it's invalid. It's the responsibility of the code that construct mesh clipper implementations to ensure a suitable hierarchy is provided by kGeom.asHierarchy().

Member Function Documentation

◆ name()

virtual const std::string& axom::quest::experimental::MeshClipperStrategy::name ( ) const
virtual

Optional name for strategy.

The base implementation returns "UNNAMED".

◆ info()

const conduit::Node& axom::quest::experimental::MeshClipperStrategy::info ( ) const
inline

Information on the geometry.

The exact information is determined by subclass requirements, provided by the klee::Geometry and possibly further modified by the subclass.

References m_info.

◆ getBoundingBox2D()

virtual const axom::primal::BoundingBox<double, 2>& axom::quest::experimental::MeshClipperStrategy::getBoundingBox2D ( ) const
virtual

Get the 2D axis-aligned bounding box for the geometry, if it's applicable and available.

◆ getBoundingBox3D()

virtual const axom::primal::BoundingBox<double, 3>& axom::quest::experimental::MeshClipperStrategy::getBoundingBox3D ( ) const
virtual

Get the 3D axis-aligned bounding box for the geometry, if it's applicable and available.

◆ labelCellsInOut()

virtual bool axom::quest::experimental::MeshClipperStrategy::labelCellsInOut ( quest::experimental::ShapeMesh shapeMesh,
axom::Array< LabelType > &  cellLabels 
)
inlinevirtual

Label each cell in the mesh as inside, outside or both/undetermined, if possible.

Parameters
[in]shapeMeshMesh to shape into.
[out]labelsOutput

The cell labels should be set to

  • labelIn if the cell is completely inside the shape,
  • labelOut if the cell is completely outside, and
  • labelOn if the cell is both inside and outside (or cannot be easily determined).

The output labels are used in optimizing the clipping algorithm. Subclasses should implement this if it's cost-effective, and skip if it's not. It's safe to label cells as on the boundary if it can't be efficiently determined as inside or outside.

Degenerate cells have zero volume and should be labeled outside for best clipping performance.

Returns
Whether the operation was done. (A false means not done.)

If implementation returns true, it should ensure these post-conditions hold:

Postcondition
labels.size() == shapeMesh.getCellCount()
labels.getAllocatorID() == shapeMesh.getAllocatorId()

References AXOM_UNUSED_VAR.

◆ labelTetsInOut()

virtual bool axom::quest::experimental::MeshClipperStrategy::labelTetsInOut ( quest::experimental::ShapeMesh shapeMesh,
axom::ArrayView< const axom::IndexType cellIds,
axom::Array< LabelType > &  tetLabels 
)
inlinevirtual

Label each tetrahedron in the given cells, as inside, outside or both/undetermined, if possible.

Parameters
[in]shapeMeshBlueprint mesh to shape into.
[in]cellIdsIndices of cells whose constituent tets should be labeled.
[out]tetLabelsOutput

See also comments in labelCellsInOut().

Indices [i*NUM_TETS_PER_HEX, (i+1)*NUM_TETS_PER_HEX) in tetLabels correspond to parent cell index c = cellIds[i].

The NUM_TETS_PER_HEX tets in cell c have indices [c*NUM_TETS_PER_HEX, (c+1)*NUM_TETS_PER_HEX). in shapeMesh.getCellsAsTets().

Degenerate tets have zero volume and MUST be labeled outside. Further computation can fail if degenerate tets are seen.

If implementation returns true, it should ensure these post-conditions hold:

Postcondition
tetLabels.size() == NUM_TETS_PER_HEX * cellIds.size()
labels.getAllocatorID() == shapeMesh.getAllocatorId()
tetLabels should have NUM_TETS_PER_HEX labels for each index in cellIds.

References AXOM_UNUSED_VAR.

◆ specializedClipCells() [1/2]

virtual bool axom::quest::experimental::MeshClipperStrategy::specializedClipCells ( quest::experimental::ShapeMesh shapeMesh,
axom::ArrayView< double >  ovlap,
conduit::Node &  statistics 
)
inlinevirtual

Clip with a fast geometry-specialized method if possible.

Parameters
[in]shapeMeshBlueprint mesh to shape into.
[out]ovlapShape overlap volume of each cell in the shapeMesh. It's initialized to zeros.
[out]statisticsOptional statistics to record consisting of child nodes with integer values.

The default implementation has no specialized method, so it's a no-op and returns false.

If this method returns false, then exactly one of the getShapesAs...() methods must be provided.

Returns
True if clipping was done and false if a no-op.

This method need not be implemented if labelCellsInOut() returns true.

Setting the statistics is not required except for getting accurate statistics.

If implementation returns true, it should ensure these post-conditions hold:

Postcondition
ovlap.size() == shapeMesh.getCellCount()
ovlap.getAllocatorID() == shapeMesh.getAllocatorId()

References AXOM_UNUSED_VAR.

◆ specializedClipCells() [2/2]

virtual bool axom::quest::experimental::MeshClipperStrategy::specializedClipCells ( quest::experimental::ShapeMesh shapeMesh,
axom::ArrayView< double >  ovlap,
const axom::ArrayView< IndexType > &  cellIds,
conduit::Node &  statistics 
)
inlinevirtual

Clip with a fast geometry-specialized method if possible.

Parameters
[in]shapeMeshBlueprint mesh to shape into.
[out]ovlapShape overlap volume of each cell in shapeMesh, initialized to the cell volumes for cell inside the shape and zero for other cells.
[in]cellIdsLimit computation to these cell ids.
[out]statisticsOptional statistics to record consisting of child nodes with integer values.

The default implementation has no specialized method, so it's a no-op and returns false.

If this method returns false, then exactly one of getGeometryAsTets() or getGeometryAsOcts() methods must be provided so that MeshClipper can use the general clipping methods.

Returns
True if clipping was done and false if a no-op.

This method need not be implemented if labelCellsInOut() returns false.

Setting the statistics is not required except for getting accurate statistics.

Precondition
ovlap is pre-initialized for the implementation to add or subtract partial volumes to individual cells.

If implementation returns true, it should ensure these post-conditions hold:

Postcondition
ovlap.size() == shapeMesh.getCellCount()
ovlap.getAllocatorID() == shapeMesh.getAllocatorId()

References AXOM_UNUSED_VAR.

◆ specializedClipTets()

virtual bool axom::quest::experimental::MeshClipperStrategy::specializedClipTets ( quest::experimental::ShapeMesh shapeMesh,
axom::ArrayView< double >  ovlap,
const axom::ArrayView< IndexType > &  tetIds,
conduit::Node &  statistics 
)
inlinevirtual

Clip the tets listed in tetIds.

Parameters
[in]shapeMeshBlueprint mesh to shape into.
[in/out]ovlap Shape overlap volume of each cell in shapeMesh, initialized to the clipping calculation done so far. Clip volumes computed by this method should be added to the current values in this array.
[out]statisticsOptional statistics to record consisting of child nodes with integer values.
[in]tetIdsIndices of tets to clip, referring to the shapeMesh.getCellsAsTets() array. tetIds[i] is the (tetIds[i]NUM_TETS_PER_HEX)-th tetrahedron of cell = tetIds[i]/NUM_TETS_PER_HEX. Its overlap volume should be added to ovlap[c].

Setting the statistics is not required except for getting accurate statistics.

References AXOM_UNUSED_VAR.

◆ getGeometryAsTets()

virtual bool axom::quest::experimental::MeshClipperStrategy::getGeometryAsTets ( quest::experimental::ShapeMesh shapeMesh,
axom::Array< TetrahedronType > &  tets 
)
inlinevirtual

Get the geometry as discrete tetrahedra, or return false.

Parameters
[in]shapeMeshBlueprint mesh to shape into.
[out]tetsArray of non-degenerate tetrahedra filling the space of the shape, fully transformed.

Subclasses implementing this routine should snap to zero any output vertex coordinate that is close to zero.

Degenerate tets are allowed, but they may cause a reduction in clipping performance, so it's best to omit them from tets.

Returns
Whether the shape can be represented as tetrahedra.

If implementation returns true, it should ensure these post-conditions hold:

Postcondition
tets.getAllocatorID() == shapeMesh.getAllocatorId()

References AXOM_UNUSED_VAR.

◆ getGeometryAsOcts()

virtual bool axom::quest::experimental::MeshClipperStrategy::getGeometryAsOcts ( quest::experimental::ShapeMesh shapeMesh,
axom::Array< OctahedronType > &  octs 
)
inlinevirtual

Get the geometry as discrete octahedra, or return false.

Parameters
[in]shapeMeshBlueprint mesh to shape into.
[out]octsArray of non-degenerate octahedra filling the space of the shape, fully transformed.

Subclasses implementing this routine should snap to zero any output vertex coordinate that is close to zero.

Degenerate octs are allowed, but they may cause a reduction in clipping performance, so it's best to omit them from octs.

Returns
Whether the shape can be represented as octahedra.

If implementation returns true, it should ensure these post-conditions hold:

Postcondition
octs.getAllocatorID() == shapeMesh.getAllocatorId()

References AXOM_UNUSED_VAR.

Member Data Documentation

◆ NUM_TETS_PER_HEX

constexpr axom::IndexType axom::quest::experimental::MeshClipperStrategy::NUM_TETS_PER_HEX = ShapeMesh::NUM_TETS_PER_HEX
staticconstexpr

◆ NUM_VERTS_PER_CELL_3D

constexpr axom::IndexType axom::quest::experimental::MeshClipperStrategy::NUM_VERTS_PER_CELL_3D = ShapeMesh::NUM_VERTS_PER_CELL_3D
staticconstexpr

◆ m_info

conduit::Node axom::quest::experimental::MeshClipperStrategy::m_info
protected

Information on the geometry.

This is initially set to a deep copy of the source klee::Geometry hierarchy data. Subclasses may use and change this data as needed.

This information should be sufficient for the subclass to implement the required and optional virtual methods. But it's up to the subclass to define the requirements, validate the data, fail fast if the data is invalid and document the requirements.

◆ m_extTrans

numerics::Matrix<double> axom::quest::experimental::MeshClipperStrategy::m_extTrans
protected

External transformation due to the GeometryOperator.

This is a direct result of the klee::Geometry::getGeometryOperator(). Not to be confused with any geometry's internal transformation (such as a cylinder's orientation and a sphere's center translation), which apply before m_extTrans.


The documentation for this class was generated from the following file: