https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
19namespace CSG
20{
21
28{
29public:
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
98 virtual bool isEngUnit() const { return false; }
99
101 bool operator==(const CSGUniverse & other) const;
102
104 bool operator!=(const CSGUniverse & other) const;
105
106protected:
112 void addCell(const CSGCell & cell);
113
119 void removeCell(const std::string & name);
120
124 void removeAllCells() { _cells.clear(); }
125
126 // set the name of the universe - intentionally not public because
127 // name needs to be managed at the CSGUniverseList level
128 void setName(const std::string & name) { _name = name; }
129
131 std::string _name;
132
134 std::vector<std::reference_wrapper<const CSGCell>> _cells;
135
138
139 // CSGUniverseList needs to be friend to access setName()
140 friend class CSGUniverseList;
141
142 // CSGBase needs to be friend to access addCell()
143 friend class CSGBase;
144
145#ifdef MOOSE_UNIT_TEST
148 FRIEND_TEST(CSGUniverseTest, testGetCell);
149 FRIEND_TEST(CSGUniverseTest, testAddCell);
150 FRIEND_TEST(CSGUniverseTest, testRemoveCell);
151 FRIEND_TEST(CSGUniverseTest, testRemoveAllCells);
152 FRIEND_TEST(CSGUniverseTest, testSetName);
153 FRIEND_TEST(CSGUniverseTest, testUniverseEquality);
155#endif
156};
157} // namespace CSG
CSGBase creates an internal representation of a Constructive Solid Geometry (CSG) model.
Definition CSGBase.h:54
CSGCell creates an internal representation of a Constructive Solid Geometry (CSG) cell,...
Definition CSGCell.h:30
Class for managing transformations in CSG objects.
CSGUniverseList creates a container for CSGUniverse objects to pass to CSGBase.
CSGUniverse creates an internal representation of a Constructive Solid Geometry (CSG) universe,...
Definition CSGUniverse.h:28
virtual bool isEngUnit() const
Whether this universe is an engineering unit.
Definition CSGUniverse.h:98
FRIEND_TEST(CSGUniverseTest, testRemoveAllCells)
FRIEND_TEST(CSGUniverseTest, testAddCell)
const std::string & getName() const
Get the name of the universe.
Definition CSGUniverse.h:80
FRIEND_TEST(CSGUniverseTest, testSetName)
void setName(const std::string &name)
FRIEND_TEST(CSGUniverseTest, testGetCell)
Friends for unit testing.
void addCell(const CSGCell &cell)
add cell to universe
Definition CSGUniverse.C:29
virtual ~CSGUniverse()=default
Destructor.
bool operator!=(const CSGUniverse &other) const
Operator overload for checking if two CSGUniverse objects are not equal.
void removeAllCells()
remove all cells from the universe
const CSGCell & getCell(const std::string &name)
Get the CSGCell object by name.
Definition CSGUniverse.C:40
std::vector< std::reference_wrapper< const CSGCell > > _cells
list of references to cells in universe
FRIEND_TEST(CSGUniverseTest, testRemoveCell)
void removeCell(const std::string &name)
remove a cell of the specified name from the universe
Definition CSGUniverse.C:60
bool _is_root
whether or not this universe is the root universe
const std::vector< std::reference_wrapper< const CSGCell > > & getAllCells() const
Get list of the all cells in the universe.
Definition CSGUniverse.h:73
FRIEND_TEST(CSGUniverseTest, testUniverseEquality)
std::string _name
Name of universe.
bool hasCell(const std::string &name) const
check if cell of provided name is present in universe
Definition CSGUniverse.C:51
bool operator==(const CSGUniverse &other) const
Operator overload for checking if two CSGUniverse objects are equal.
Definition CSGUniverse.C:74
bool isRoot() const
return true if the universe is the root universe
Definition CSGUniverse.h:87