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"
14 
15 #ifdef MOOSE_UNIT_TEST
16 #include "gtest/gtest.h"
17 #endif
18 
19 namespace CSG
20 {
21 
28 {
29 public:
36  CSGUniverse(const std::string & name, bool is_root = false);
37 
45  CSGUniverse(const std::string & name, std::vector<CSGCell *> & cells, bool is_root = false);
46 
50  virtual ~CSGUniverse() = default;
51 
58  const CSGCell & getCell(const std::string & name);
59 
66  bool hasCell(const std::string & name) const;
67 
73  const std::vector<std::reference_wrapper<const CSGCell>> & getAllCells() const { return _cells; }
74 
80  const std::string & getName() const { return _name; }
81 
87  bool isRoot() const { return _is_root; }
88 
90  bool operator==(const CSGUniverse & other) const;
91 
93  bool operator!=(const CSGUniverse & other) const;
94 
95 protected:
101  void addCell(const CSGCell & cell);
102 
108  void removeCell(const std::string & name);
109 
113  void removeAllCells() { _cells.clear(); }
114 
115  // set the name of the universe - intentionally not public because
116  // name needs to be managed at the CSGUniverseList level
117  void setName(const std::string & name) { _name = name; }
118 
120  std::string _name;
121 
123  std::vector<std::reference_wrapper<const CSGCell>> _cells;
124 
126  bool _is_root;
127 
128  // CSGUniverseList needs to be friend to access setName()
129  friend class CSGUniverseList;
130 
131  // CSGUniverseList needs to be friend to access addCell()
132  friend class CSGBase;
133 
134 #ifdef MOOSE_UNIT_TEST
135  FRIEND_TEST(CSGUniverseTest, testGetCell);
138  FRIEND_TEST(CSGUniverseTest, testAddCell);
139  FRIEND_TEST(CSGUniverseTest, testRemoveCell);
140  FRIEND_TEST(CSGUniverseTest, testRemoveAllCells);
141  FRIEND_TEST(CSGUniverseTest, testSetName);
142  FRIEND_TEST(CSGUniverseTest, testUniverseEquality);
144 #endif
145 };
146 } // namespace CSG
std::string name(const ElemQuality q)
std::string _name
Name of universe.
Definition: CSGUniverse.h:120
virtual ~CSGUniverse()=default
Destructor.
void setName(const std::string &name)
Definition: CSGUniverse.h:117
bool hasCell(const std::string &name) const
check if cell of provided name is present in universe
Definition: CSGUniverse.C:50
CSGUniverse creates an internal representation of a Constructive Solid Geometry (CSG) universe...
Definition: CSGUniverse.h:27
const std::vector< std::reference_wrapper< const CSGCell > > & getAllCells() const
Get list of the all cells in the universe.
Definition: CSGUniverse.h:73
const CSGCell & getCell(const std::string &name)
Get the CSGCell object by name.
Definition: CSGUniverse.C:39
void removeCell(const std::string &name)
remove a cell of the specified name from the universe
Definition: CSGUniverse.C:59
bool _is_root
whether or not this universe is the root universe
Definition: CSGUniverse.h:126
bool operator==(const CSGUniverse &other) const
Operator overload for checking if two CSGUniverse objects are equal.
Definition: CSGUniverse.C:73
const std::string & getName() const
Get the name of the universe.
Definition: CSGUniverse.h:80
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:123
CSGCell creates an internal representation of a Constructive Solid Geometry (CSG) cell...
Definition: CSGCell.h:29
bool isRoot() const
return true if the universe is the root universe
Definition: CSGUniverse.h:87
void removeAllCells()
remove all cells from the universe
Definition: CSGUniverse.h:113
CSGUniverse(const std::string &name, bool is_root=false)
Construct a new CSGUniverse object.
Definition: CSGUniverse.C:17
Class for managing transformations in CSG objects.
CSGBase creates an internal representation of a Constructive Solid Geometry (CSG) model...
Definition: CSGBase.h:51
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:28