MCPcopy Create free account
hub / github.com/NatLabRockies/OpenStudio / clone

Method clone

src/model/Building.cpp:127–248  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

125 }
126
127 ModelObject Building_Impl::clone(Model t_model) const {
128 boost::optional<Building> result;
129
130 if (t_model == model()) {
131 // Clone attempted into same Model - return the existing instance
132 result = getObject<ModelObject>().cast<Building>();
133 } else {
134
135 auto otherBuilding = t_model.building();
136 if (otherBuilding) {
137 otherBuilding->remove();
138 }
139
140 //auto buildings = t_model.getConcreteModelObjects<Building>();
141 //if( ! buildings.empty() ) {
142 // // If Destination model already has a building then first remove it
143 // buildings.front().remove();
144 //}
145
146 // Clone Building and child objects.
147
148 // This call clones only the building and it's resources
149 result = ModelObject_Impl::clone(t_model).cast<Building>();
150
151 // DLM: why did the ParentObject::clone not work?
152 // DLM: ParentObject::clone only preserves links between child and parent objects, it does not preserve links between levels of the hierarchy
153 // we could potentially add ThermalZone as a resource of Space (or vice versa or both) but I am not sure what the implications of that are
154
155 // Clone children since we are not relying on the implementation provided by ParentObject::clone
156
157 // Meter instances
158 auto t_meters = meters();
159 for (const auto& meter : t_meters) {
160 meter.clone(t_model);
161 }
162
163 // BuildingStory instances
164 auto t_stories = buildingStories();
165 // Map of the source model story handle to the target model story "cloned" ModelObject
166 std::map<Handle, BuildingStory> m_storyMap;
167
168 for (const auto& story : t_stories) {
169 auto clone = story.clone(t_model).cast<BuildingStory>();
170 m_storyMap.insert(std::pair<Handle, BuildingStory>(story.handle(), clone));
171 }
172
173 // ShadingSurfaceGroup
174 auto t_shadingSurfaceGroups = shadingSurfaceGroups();
175 for (const auto& surfaceGroup : t_shadingSurfaceGroups) {
176 surfaceGroup.clone(t_model);
177 }
178
179 // ThermalZone instances
180 auto t_zones = thermalZones();
181 // Map of the source model zone handle to the target model zone "cloned" ModelObject
182 std::map<Handle, ThermalZone> m_zoneMap;
183
184 for (const auto& zone : t_zones) {

Callers

nothing calls this directly

Calls 15

adjacentSurfaceMethod · 0.80
nameStringMethod · 0.80
adjacentSubSurfaceMethod · 0.80
buildingStoryMethod · 0.80
setBuildingStoryMethod · 0.80
setAdjacentSurfaceMethod · 0.80
setAdjacentSubSurfaceMethod · 0.80
cloneFunction · 0.50
buildingMethod · 0.45
removeMethod · 0.45
insertMethod · 0.45
handleMethod · 0.45

Tested by

no test coverage detected