https://mooseframework.inl.gov
CSGRegion.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 "CSGSurface.h"
13 
14 namespace CSG
15 {
16 
21 class CSGRegion
22 {
23 public:
25  enum class RegionType
26  {
27  EMPTY = 0,
28  HALFSPACE = 1,
29  COMPLEMENT = 2,
30  INTERSECTION = 3,
31  UNION = 4
32  };
33 
37  CSGRegion();
38 
45  CSGRegion(const CSGSurface & surf, const CSGSurface::Halfspace halfspace);
46 
54  CSGRegion(const CSGRegion & region_a,
55  const CSGRegion & region_b,
56  const std::string & region_type);
57 
64  CSGRegion(const CSGRegion & region, const std::string & region_type);
65 
69  virtual ~CSGRegion() = default;
70 
76  const std::string & toString() const { return _region_str; }
77 
84 
90  const std::string getRegionTypeString() const { return _region_type; }
91 
97  const std::vector<std::reference_wrapper<const CSGSurface>> & getSurfaces() const
98  {
99  return _surfaces;
100  }
101 
103  CSGRegion & operator&=(const CSGRegion & other_region);
104 
106  CSGRegion & operator|=(const CSGRegion & other_region);
107 
109  bool operator==(const CSGRegion & other) const;
110 
112  bool operator!=(const CSGRegion & other) const;
113 
114 protected:
116  std::string _region_str;
117 
119  MooseEnum _region_type{"EMPTY=0 HALFSPACE=1 COMPLEMENT=2 INTERSECTION=3 UNION=4"};
120 
122  std::vector<std::reference_wrapper<const CSGSurface>> _surfaces;
123 };
124 
133 const std::string stripRegionString(std::string region_str, std::string op);
134 
136 
138 const CSGRegion operator+(const CSGSurface & surf);
139 
141 const CSGRegion operator-(const CSGSurface & surf);
142 
144 const CSGRegion operator&(const CSGRegion & region_a, const CSGRegion & region_b);
145 
147 const CSGRegion operator|(const CSGRegion & region_a, const CSGRegion & region_b);
148 
150 const CSGRegion operator~(const CSGRegion & region);
151 
152 } // namespace CSG
std::string _region_str
String representation of region - defaults to empty string.
Definition: CSGRegion.h:116
CSGRegions creates an internal representation of a CSG region, which can refer to an intersection...
Definition: CSGRegion.h:21
CSGRegion()
Default Constructor.
Definition: CSGRegion.C:15
const std::string & toString() const
gets the string representation of the region
Definition: CSGRegion.h:76
Halfspace
Enum for the sign of the half-space being represented by a point and surface.
Definition: CSGSurface.h:30
const CSGRegion operator|(const CSGRegion &region_a, const CSGRegion &region_b)
Overload for creating a region from the union (|) of two regions.
Definition: CSGRegion.C:151
virtual ~CSGRegion()=default
Destructor.
T getEnum() const
get the current value cast to the enum type T
Definition: MooseEnum.h:151
bool operator!=(const CSGRegion &other) const
Operator overload for checking if two CSGRegion objects are not equal.
Definition: CSGRegion.C:188
const CSGRegion operator+(const CSGSurface &surf)
Operation overloads for operation based region construction.
Definition: CSGRegion.C:130
CSGRegion & operator|=(const CSGRegion &other_region)
Operator overload for |= which creates a union of the current region with the other_region.
Definition: CSGRegion.C:83
bool operator==(const CSGRegion &other) const
Operator overload for checking if two CSGRegion objects are equal.
Definition: CSGRegion.C:164
const CSGRegion operator &(const CSGRegion &region_a, const CSGRegion &region_b)
Overload for creating a region from the the intersection (&) of two regions.
Definition: CSGRegion.C:144
RegionType getRegionType() const
Get the region type.
Definition: CSGRegion.h:83
CSGRegion & operator &=(const CSGRegion &other_region)
Operator overload for &= which creates an intersection between the current region and the other_regio...
const std::vector< std::reference_wrapper< const CSGSurface > > & getSurfaces() const
Get the list of surfaces associated with the region.
Definition: CSGRegion.h:97
MooseEnum _region_type
An enum for type of type of operation that defines region.
Definition: CSGRegion.h:119
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:33
RegionType
Enum for representing region types, defined to match _region_type MooseEnum.
Definition: CSGRegion.h:25
CSGSurface creates an internal representation of a Constructive Solid Geometry (CSG) surface...
Definition: CSGSurface.h:26
std::vector< std::reference_wrapper< const CSGSurface > > _surfaces
Surface list associated with the region.
Definition: CSGRegion.h:122
const CSGRegion operator~(const CSGRegion &region)
Overload for creating a region from the complement (~) of another region.
Definition: CSGRegion.C:158
const std::string stripRegionString(std::string region_str, std::string op)
strip the leading and trailing parentheses from the string if only the specified operator is present ...
Definition: CSGRegion.C:91
const std::string getRegionTypeString() const
Get the region type as a string.
Definition: CSGRegion.h:90
const CSGRegion operator-(const CSGSurface &surf)
Overload for creating a region from the negative half-space (-) of a surface.
Definition: CSGRegion.C:137