https://mooseframework.inl.gov
Loading...
Searching...
No Matches
OrientedBoundingBox.h
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10#pragma once
11
12#include "MooseTypes.h"
13
14#include "libmesh/point.h"
15
16#include <filesystem>
17#include <iosfwd>
18#include <utility>
19#include <vector>
20
21namespace libMesh
22{
23namespace Parallel
24{
25class Communicator;
26}
27}
28
45{
46public:
47 // --- Construction ---
48
51
62 explicit OrientedBoundingBox(const std::vector<std::pair<Point, Point>> & axis_pairs);
63
64 // --- Queries / introspection ---
65
74 bool contains(const Point & pt, const Real tolerance = libMesh::TOLERANCE) const;
75
77 Point centroid() const;
78
80 Point getAxisDirection(unsigned int i) const;
81
83 Real getAxisLength(unsigned int i) const;
84
86 Point getMinimalCorner() const;
87
89 Point getMaximalCorner() const;
90
91 // --- I/O helpers ---
92
94 void print(std::ostream & os) const;
95
108 void writeMesh(const std::filesystem::path & path,
109 const libMesh::Parallel::Communicator & comm) const;
110
125 void writeRayAlongShortestAxis(const std::filesystem::path & ray_path,
126 const libMesh::Parallel::Communicator & comm) const;
127
138 Real getProjectedLength(const Point & pt, unsigned int i) const;
139
140private:
143 std::vector<Point> _dirs;
144 std::vector<Real> _len;
145 unsigned int _dim = 0u;
146};
Oriented bounding box in 2 D or 3 D.
OrientedBoundingBox()
Default-constructs an empty box (zero dimension, no axes).
std::vector< Real > _len
length along each basis (size = _dim)
Point _minimal_corner
shared minimal corner
Real getAxisLength(unsigned int i) const
unsigned int _dim
spatial dimension (2 or 3)
std::vector< Point > _dirs
orthonormal basis vectors (size = _dim)
bool contains(const Point &pt, const Real tolerance=libMesh::TOLERANCE) const
Test whether a point lies inside or on the box.
void writeRayAlongShortestAxis(const std::filesystem::path &ray_path, const libMesh::Parallel::Communicator &comm) const
Write a single-EDGE2 mesh representing a "ray" emanating from the box.
Point getAxisDirection(unsigned int i) const
Point _maximal_corner
shared maximal corner
void writeMesh(const std::filesystem::path &path, const libMesh::Parallel::Communicator &comm) const
Write the oriented box as a single libMesh element to a mesh file.
Real getProjectedLength(const Point &pt, unsigned int i) const
Get the length of the projection of a point onto axis i.
void print(std::ostream &os) const
Print a summary (dimension, origin, axes).
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
static constexpr Real TOLERANCE