Line data Source code
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 : 17 : /** 18 : * CSGSurfaceList is a container for storing CSGSurface objects in the CSGBase object 19 : */ 20 : class CSGSurfaceList 21 : { 22 : protected: 23 : /** 24 : * Default constructor 25 : */ 26 : CSGSurfaceList(); 27 : 28 : /** 29 : * Copy constructor 30 : */ 31 : CSGSurfaceList(const CSGSurfaceList & other_surface_list); 32 : 33 : /** 34 : * Destructor 35 : */ 36 118 : virtual ~CSGSurfaceList() = default; 37 : 38 : /** 39 : * @brief Get non-const map of all names to surfaces in surface list 40 : * 41 : * @return map of all names to CSGSurface pointers 42 : */ 43 24 : std::unordered_map<std::string, std::unique_ptr<CSGSurface>> & getSurfaceListMap() 44 : { 45 24 : return _surfaces; 46 : } 47 : 48 : /** 49 : * @brief Get const map of all names to surfaces in surface list 50 : * 51 : * @return map of all names to CSGSurface pointers 52 : */ 53 11 : const std::unordered_map<std::string, std::unique_ptr<CSGSurface>> & getSurfaceListMap() const 54 : { 55 11 : return _surfaces; 56 : } 57 : 58 : /** 59 : * @brief Get list of references to all surfaces in surface list 60 : * 61 : * @return list of references to surfaces 62 : */ 63 : std::vector<std::reference_wrapper<const CSGSurface>> getAllSurfaces() const; 64 : 65 : /** 66 : * @brief return whether surface with given name exists in surface list 67 : * 68 : * @param name name of surface 69 : * @return true if surface name exists, false otherwise 70 : */ 71 4 : bool hasSurface(const std::string & name) const 72 : { 73 4 : return _surfaces.find(name) != _surfaces.end(); 74 : } 75 : 76 : /** 77 : * @brief Get a surface by name 78 : * 79 : * @param name name of surface 80 : * 81 : * @return reference to CSGSurface of the specified name 82 : */ 83 : CSGSurface & getSurface(const std::string & name) const; 84 : 85 : /** 86 : * @brief add a surface object to existing SurfaceList. Ownership of surface will be transferred 87 : * to surface list object that calls this function 88 : * 89 : * @param surf CSGSurface to add 90 : * 91 : * @return reference to CSGSurface 92 : */ 93 : CSGSurface & addSurface(std::unique_ptr<CSGSurface> surf); 94 : 95 : /** 96 : * @brief rename the specified surface 97 : * 98 : * @param name new name of surface 99 : */ 100 : void renameSurface(const CSGSurface & surface, const std::string & name); 101 : 102 : /// Operator overload for checking if two CSGSurfaceList objects are equal 103 : bool operator==(const CSGSurfaceList & other) const; 104 : 105 : /// Operator overload for checking if two CSGSurfaceList objects are not equal 106 : bool operator!=(const CSGSurfaceList & other) const; 107 : 108 : /// Mapping of surface names to pointers of stored surface objects 109 : std::unordered_map<std::string, std::unique_ptr<CSGSurface>> _surfaces; 110 : 111 : // Only CSGBase should be calling the methods in CSGSurfaceList 112 : friend class CSGBase; 113 : }; 114 : } // namespace CSG