https://mooseframework.inl.gov
CSGUniverse.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 "CSGCellList.h"
13 
14 #ifdef MOOSE_UNIT_TEST
15 #include "gtest/gtest.h"
16 #endif
17 
18 namespace CSG
19 {
20 
27 {
28 public:
35  CSGUniverse(const std::string & name, bool is_root = false);
36 
44  CSGUniverse(const std::string & name, std::vector<CSGCell *> & cells, bool is_root = false);
45 
49  virtual ~CSGUniverse() = default;
50 
57  const CSGCell & getCell(const std::string & name);
58 
65  bool hasCell(const std::string & name) const;
66 
72  const std::vector<std::reference_wrapper<const CSGCell>> & getAllCells() const { return _cells; }
73 
79  const std::string & getName() const { return _name; }
80 
86  bool isRoot() const { return _is_root; }
87 
89  bool operator==(const CSGUniverse & other) const;
90 
92  bool operator!=(const CSGUniverse & other) const;
93 
94 protected:
100  void addCell(const CSGCell & cell);
101 
107  void removeCell(const std::string & name);
108 
112  void removeAllCells() { _cells.clear(); }
113 
114  // set the name of the universe - intentionally not public because
115  // name needs to be managed at the CSGUniverseList level
116  void setName(const std::string & name) { _name = name; }
117 
119  std::string _name;
120 
122  std::vector<std::reference_wrapper<const CSGCell>> _cells;
123 
125  bool _is_root;
126 
127  // CSGUniverseList needs to be friend to access setName()
128  friend class CSGUniverseList;
129 
130  // CSGUniverseList needs to be friend to access addCell()
131  friend class CSGBase;
132 
133 #ifdef MOOSE_UNIT_TEST
134  FRIEND_TEST(CSGUniverseTest, testGetCell);
137  FRIEND_TEST(CSGUniverseTest, testAddCell);
138  FRIEND_TEST(CSGUniverseTest, testRemoveCell);
139  FRIEND_TEST(CSGUniverseTest, testRemoveAllCells);
140  FRIEND_TEST(CSGUniverseTest, testSetName);
142 #endif
143 };
144 } // namespace CSG
std::string name(const ElemQuality q)
std::string _name
Name of universe.
Definition: CSGUniverse.h:119
virtual ~CSGUniverse()=default
Destructor.
void setName(const std::string &name)
Definition: CSGUniverse.h:116
bool hasCell(const std::string &name) const
check if cell of provided name is present in universe
Definition: CSGUniverse.C:47
CSGUniverse creates an internal representation of a Constructive Solid Geometry (CSG) universe...
Definition: CSGUniverse.h:26
const std::vector< std::reference_wrapper< const CSGCell > > & getAllCells() const
Get list of the all cells in the universe.
Definition: CSGUniverse.h:72
const CSGCell & getCell(const std::string &name)
Get the CSGCell object by name.
Definition: CSGUniverse.C:36
void removeCell(const std::string &name)
remove a cell of the specified name from the universe
Definition: CSGUniverse.C:56
bool _is_root
whether or not this universe is the root universe
Definition: CSGUniverse.h:125
bool operator==(const CSGUniverse &other) const
Operator overload for checking if two CSGUniverse objects are equal.
Definition: CSGUniverse.C:70
const std::string & getName() const
Get the name of the universe.
Definition: CSGUniverse.h:79
CSGUniverseList creates a container for CSGUniverse objects to pass to CSGBase.
std::vector< std::reference_wrapper< const CSGCell > > _cells
list of references to cells in universe
Definition: CSGUniverse.h:122
CSGCell creates an internal representation of a Constructive Solid Geometry (CSG) cell...
Definition: CSGCell.h:27
bool isRoot() const
return true if the universe is the root universe
Definition: CSGUniverse.h:86
void removeAllCells()
remove all cells from the universe
Definition: CSGUniverse.h:112
CSGUniverse(const std::string &name, bool is_root=false)
Construct a new CSGUniverse object.
Definition: CSGUniverse.C:15
CSGBase creates an internal representation of a Constructive Solid Geometry (CSG) model...
Definition: CSGBase.h:29
bool operator!=(const CSGUniverse &other) const
Operator overload for checking if two CSGUniverse objects are not equal.
Definition: CSGUniverse.C:93
FRIEND_TEST(CSGUniverseTest, testGetCell)
Friends for unit testing.
void addCell(const CSGCell &cell)
add cell to universe
Definition: CSGUniverse.C:25