INET Framework for OMNeT++/OMNEST
inet::physicalenvironment::PhysicalEnvironment Class Reference

This class represents the physical environment. More...

#include <PhysicalEnvironment.h>

Inheritance diagram for inet::physicalenvironment::PhysicalEnvironment:
inet::physicalenvironment::IPhysicalEnvironment

Protected Attributes

Parameters
IGeographicCoordinateSystemcoordinateSystem = nullptr
 
K temperature
 
Coord spaceMin
 
Coord spaceMax
 
Submodules
IObjectCacheobjectCache = nullptr
 
IGroundground = nullptr
 
Internal state
std::vector< const ShapeBase * > shapes
 
std::vector< const Material * > materials
 
std::vector< const PhysicalObject * > objects
 

Cache

std::map< int, const ShapeBase * > idToShapeMap
 
std::map< int, const Material * > idToMaterialMap
 
std::map< int, const PhysicalObject * > idToObjectMap
 
std::map< std::string, const Material * > nameToMaterialMap
 
virtual int numInitStages () const override
 
virtual void initialize (int stage) override
 
virtual void convertPoints (std::vector< Coord > &points)
 
virtual void parseShapes (cXMLElement *xml)
 
virtual void parseMaterials (cXMLElement *xml)
 
virtual void parseObjects (cXMLElement *xml)
 
 PhysicalEnvironment ()
 
virtual ~PhysicalEnvironment ()
 
virtual IObjectCachegetObjectCache () const override
 
virtual IGroundgetGround () const override
 
virtual K getTemperature () const
 
virtual const CoordgetSpaceMin () const override
 
virtual const CoordgetSpaceMax () const override
 
virtual const IMaterialRegistrygetMaterialRegistry () const override
 
virtual int getNumObjects () const override
 
virtual const PhysicalObjectgetObject (int index) const override
 
virtual const PhysicalObjectgetObjectById (int id) const override
 
virtual void visitObjects (const IVisitor *visitor, const LineSegment &lineSegment) const override
 

Additional Inherited Members

Detailed Description

This class represents the physical environment.

The physical environment contains a set of physical objects and it also specifies certain physical properties.

The physical environment draws the physical objects on the canvas of its parent module.

Constructor & Destructor Documentation

◆ PhysicalEnvironment()

inet::physicalenvironment::PhysicalEnvironment::PhysicalEnvironment ( )
25  :
27  spaceMin(Coord(NaN, NaN, NaN)),
28  spaceMax(Coord(NaN, NaN, NaN)),
29  objectCache(nullptr)
30 {
31 }

◆ ~PhysicalEnvironment()

inet::physicalenvironment::PhysicalEnvironment::~PhysicalEnvironment ( )
virtual
34 {
35  for (auto& elem : shapes)
36  delete elem;
37  for (auto& elem : materials)
38  delete elem;
39  for (auto& elem : objects)
40  delete elem;
41 }

Member Function Documentation

◆ convertPoints()

void inet::physicalenvironment::PhysicalEnvironment::convertPoints ( std::vector< Coord > &  points)
protectedvirtual
66 {
67  auto originPosition = coordinateSystem == nullptr ? GeoCoord(deg(0), deg(0), m(0)) : coordinateSystem->computeGeographicCoordinate(Coord::ZERO);
68  Box boundingBox = Box::computeBoundingBox(points);
69  Coord center = boundingBox.getCenter();
70  for (auto& point : points) {
71  point -= center;
72  if (coordinateSystem != nullptr)
73  point = coordinateSystem->computeSceneCoordinate(GeoCoord(deg(point.x) + originPosition.latitude, deg(point.y) + originPosition.longitude, m(0)));
74  }
75 }

Referenced by parseObjects(), and parseShapes().

◆ getGround()

virtual IGround* inet::physicalenvironment::PhysicalEnvironment::getGround ( ) const
inlineoverridevirtual

◆ getMaterialRegistry()

virtual const IMaterialRegistry* inet::physicalenvironment::PhysicalEnvironment::getMaterialRegistry ( ) const
inlineoverridevirtual

◆ getNumObjects()

virtual int inet::physicalenvironment::PhysicalEnvironment::getNumObjects ( ) const
inlineoverridevirtual

Implements inet::physicalenvironment::IPhysicalEnvironment.

87 { return objects.size(); }

◆ getObject()

virtual const PhysicalObject* inet::physicalenvironment::PhysicalEnvironment::getObject ( int  index) const
inlineoverridevirtual

Implements inet::physicalenvironment::IPhysicalEnvironment.

88 { return objects[index]; }

◆ getObjectById()

const PhysicalObject * inet::physicalenvironment::PhysicalEnvironment::getObjectById ( int  id) const
overridevirtual

Implements inet::physicalenvironment::IPhysicalEnvironment.

446 {
447  auto it = idToObjectMap.find(id);
448  return (it != idToObjectMap.end()) ? it->second : nullptr;
449 }

◆ getObjectCache()

virtual IObjectCache* inet::physicalenvironment::PhysicalEnvironment::getObjectCache ( ) const
inlineoverridevirtual

◆ getSpaceMax()

virtual const Coord& inet::physicalenvironment::PhysicalEnvironment::getSpaceMax ( ) const
inlineoverridevirtual

◆ getSpaceMin()

virtual const Coord& inet::physicalenvironment::PhysicalEnvironment::getSpaceMin ( ) const
inlineoverridevirtual

◆ getTemperature()

virtual K inet::physicalenvironment::PhysicalEnvironment::getTemperature ( ) const
inlinevirtual
81 { return temperature; }

◆ initialize()

void inet::physicalenvironment::PhysicalEnvironment::initialize ( int  stage)
overrideprotectedvirtual
44 {
45  if (stage == INITSTAGE_LOCAL) {
46  coordinateSystem = findModuleFromPar<IGeographicCoordinateSystem>(par("coordinateSystemModule"), this);
47  objectCache = dynamic_cast<IObjectCache *>(getSubmodule("objectCache"));
48  ground = dynamic_cast<IGround *>(getSubmodule("ground"));
49  temperature = K(par("temperature"));
50  spaceMin.x = par("spaceMinX");
51  spaceMin.y = par("spaceMinY");
52  spaceMin.z = par("spaceMinZ");
53  spaceMax.x = par("spaceMaxX");
54  spaceMax.y = par("spaceMaxY");
55  spaceMax.z = par("spaceMaxZ");
56  }
57  else if (stage == INITSTAGE_PHYSICAL_ENVIRONMENT) {
58  cXMLElement *environment = par("config");
59  parseShapes(environment);
60  parseMaterials(environment);
61  parseObjects(environment);
62  }
63 }

◆ numInitStages()

virtual int inet::physicalenvironment::PhysicalEnvironment::numInitStages ( ) const
inlineoverrideprotectedvirtual
66 { return NUM_INIT_STAGES; }

◆ parseMaterials()

void inet::physicalenvironment::PhysicalEnvironment::parseMaterials ( cXMLElement *  xml)
protectedvirtual
175 {
176  cXMLElementList children = xml->getChildrenByTagName("material");
177  for (cXMLElementList::const_iterator it = children.begin(); it != children.end(); ++it) {
178  cXMLElement *element = *it;
179  // id
180  const char *idAttribute = element->getAttribute("id");
181  if (!idAttribute)
182  throw cRuntimeError("Missing mandatory id attribute of material");
183  int id = atoi(idAttribute);
184  // name
185  const char *name = element->getAttribute("name");
186  // resistivity
187  const char *resistivityAttribute = element->getAttribute("resistivity");
188  if (!resistivityAttribute)
189  throw cRuntimeError("Missing mandatory resistivity attribute of material");
190  Ohmm resistivity = Ohmm(atof(resistivityAttribute));
191  // relativePermittivity
192  const char *relativePermittivityAttribute = element->getAttribute("relativePermittivity");
193  if (!relativePermittivityAttribute)
194  throw cRuntimeError("Missing mandatory relativePermittivity attribute of material");
195  double relativePermittivity = atof(relativePermittivityAttribute);
196  // relativePermeability
197  const char *relativePermeabilityAttribute = element->getAttribute("relativePermeability");
198  if (!relativePermeabilityAttribute)
199  throw cRuntimeError("Missing mandatory relativePermeability attribute of material");
200  double relativePermeability = atof(relativePermeabilityAttribute);
201  // insert
202  if (containsKey(idToMaterialMap, id))
203  throw cRuntimeError("Material already exists with the same id: '%d'", id);
204  Material *material = new Material(name, resistivity, relativePermittivity, relativePermeability);
205  materials.push_back(material);
206  idToMaterialMap.insert(std::pair<int, const Material *>(id, material));
207  nameToMaterialMap.insert(std::pair<const std::string, const Material *>(material->getName(), material));
208  }
209 }

Referenced by initialize().

◆ parseObjects()

void inet::physicalenvironment::PhysicalEnvironment::parseObjects ( cXMLElement *  xml)
protectedvirtual
212 {
213  Coord computedSpaceMin = Coord::NIL;
214  Coord computedSpaceMax = Coord::NIL;
215  cXMLElementList children = xml->getChildren();
216  for (cXMLElementList::const_iterator it = children.begin(); it != children.end(); ++it) {
217  const char *tok;
218  cXMLElement *element = *it;
219  const char *tag = element->getTagName();
220  if (strcmp(tag, "object"))
221  continue;
222  // id
223  const char *idAttribute = element->getAttribute("id");
224  int id = -1;
225  if (idAttribute)
226  id = atoi(idAttribute);
227  // name
228  const char *name = element->getAttribute("name");
229  // orientation
230  // TODO what about geographic orientation? what about taking GeographicCoordinateSystem into account?
231  Quaternion orientation;
232  const char *orientationAttribute = element->getAttribute("orientation");
233  if (orientationAttribute) {
234  cStringTokenizer tokenizer(orientationAttribute);
235  if ((tok = tokenizer.nextToken()) == nullptr)
236  throw cRuntimeError("Missing orientation alpha at %s", element->getSourceLocation());
237  auto alpha = deg(atof(tok));
238  if ((tok = tokenizer.nextToken()) == nullptr)
239  throw cRuntimeError("Missing orientation beta at %s", element->getSourceLocation());
240  auto beta = deg(atof(tok));
241  if ((tok = tokenizer.nextToken()) == nullptr)
242  throw cRuntimeError("Missing orientation gamma at %s", element->getSourceLocation());
243  auto gamma = deg(atof(tok));
244  orientation = Quaternion(EulerAngles(alpha, beta, gamma));
245  }
246  // shape
247  Coord size = Coord::NIL;
248  const ShapeBase *shape = nullptr;
249  const char *shapeAttribute = element->getAttribute("shape");
250  if (!shapeAttribute)
251  throw cRuntimeError("Missing shape attribute of object");
252  cStringTokenizer shapeTokenizer(shapeAttribute);
253  const char *shapeType = shapeTokenizer.nextToken();
254  if (!strcmp(shapeType, "cuboid")) {
255  if ((tok = shapeTokenizer.nextToken()) == nullptr)
256  throw cRuntimeError("Missing cuboid x at %s", element->getSourceLocation());
257  size.x = atof(tok);
258  if ((tok = shapeTokenizer.nextToken()) == nullptr)
259  throw cRuntimeError("Missing cuboid y at %s", element->getSourceLocation());
260  size.y = atof(tok);
261  if ((tok = shapeTokenizer.nextToken()) == nullptr)
262  throw cRuntimeError("Missing cuboid z at %s", element->getSourceLocation());
263  size.z = atof(tok);
264  shape = new Cuboid(size);
265  shapes.push_back(shape);
266  }
267  else if (!strcmp(shapeType, "sphere")) {
268  if ((tok = shapeTokenizer.nextToken()) == nullptr)
269  throw cRuntimeError("Missing sphere radius at %s", element->getSourceLocation());
270  double radius = atof(tok);
271  shape = new Sphere(radius);
272  size = Coord(radius, radius, radius) * 2;
273  shapes.push_back(shape);
274  }
275  else if (!strcmp(shapeType, "prism")) {
276  double height;
277  if ((tok = shapeTokenizer.nextToken()) == nullptr)
278  throw cRuntimeError("Missing prism height at %s", element->getSourceLocation());
279  height = atof(tok);
280  std::vector<Coord> points;
281  while (shapeTokenizer.hasMoreTokens()) {
282  Coord point;
283  point.x = atof(shapeTokenizer.nextToken());
284  if ((tok = shapeTokenizer.nextToken()) == nullptr)
285  throw cRuntimeError("Missing prism y at %s", element->getSourceLocation());
286  point.y = atof(tok);
287  point.z = -height / 2;
288  points.push_back(point);
289  }
290  if (points.size() < 3)
291  throw cRuntimeError("prism needs at least three points at %s", element->getSourceLocation());
292  size = Box::computeBoundingBox(points).getSize();
293  convertPoints(points);
294  shape = new Prism(height, Polygon(points));
295  shapes.push_back(shape);
296  }
297  else if (!strcmp(shapeType, "polyhedron")) {
298  std::vector<Coord> points;
299  while (shapeTokenizer.hasMoreTokens()) {
300  Coord point;
301  point.x = atof(shapeTokenizer.nextToken());
302  if ((tok = shapeTokenizer.nextToken()) == nullptr)
303  throw cRuntimeError("Missing polyhedron y at %s", element->getSourceLocation());
304  point.y = atof(tok);
305  if ((tok = shapeTokenizer.nextToken()) == nullptr)
306  throw cRuntimeError("Missing polyhedron z at %s", element->getSourceLocation());
307  point.z = atof(tok);
308  points.push_back(point);
309  }
310  if (points.size() < 4)
311  throw cRuntimeError("polyhedron needs at least four points at %s", element->getSourceLocation());
312  size = Box::computeBoundingBox(points).getSize();
313  convertPoints(points);
314  shape = new Polyhedron(points);
315  shapes.push_back(shape);
316  }
317  else {
318  int id = atoi(shapeAttribute);
319  shape = idToShapeMap[id];
320  }
321  if (!shape)
322  throw cRuntimeError("Unknown shape '%s'", shapeAttribute);
323  // position
324  Coord position = Coord::NIL;
325  const char *positionAttribute = element->getAttribute("position");
326  if (positionAttribute) {
327  cStringTokenizer tokenizer(positionAttribute);
328  const char *kind = tokenizer.nextToken();
329  if (!kind)
330  throw cRuntimeError("Missing position kind");
331  if ((tok = tokenizer.nextToken()) == nullptr)
332  throw cRuntimeError("Missing position x at %s", element->getSourceLocation());
333  position.x = atof(tok);
334  if ((tok = tokenizer.nextToken()) == nullptr)
335  throw cRuntimeError("Missing position y at %s", element->getSourceLocation());
336  position.y = atof(tok);
337  if ((tok = tokenizer.nextToken()) == nullptr)
338  throw cRuntimeError("Missing position z at %s", element->getSourceLocation());
339  position.z = atof(tok);
340  if (!strcmp(kind, "min"))
341  position += size / 2;
342  else if (!strcmp(kind, "max"))
343  position -= size / 2;
344  else if (!strcmp(kind, "center"))
345  position += Coord::ZERO;
346  else
347  throw cRuntimeError("Unknown position kind");
348  if (coordinateSystem != nullptr) {
349  auto convertedPosition = coordinateSystem->computeSceneCoordinate(GeoCoord(deg(position.x), deg(position.y), m(0)));
350  position.x = convertedPosition.x;
351  position.y = convertedPosition.y;
352  }
353  }
354  // material
355  const Material *material;
356  const char *materialAttribute = element->getAttribute("material");
357  if (!materialAttribute)
358  throw cRuntimeError("Missing material attribute of object");
359  else if (containsKey(nameToMaterialMap, materialAttribute))
360  material = nameToMaterialMap[materialAttribute];
361  else if (MaterialRegistry::singleton.getMaterial(materialAttribute))
362  material = MaterialRegistry::singleton.getMaterial(materialAttribute);
363  else
364  material = idToMaterialMap[atoi(materialAttribute)];
365  if (!material)
366  throw cRuntimeError("Unknown material '%s'", materialAttribute);
367  // line width
368  double lineWidth = 1;
369  const char *lineWidthAttribute = element->getAttribute("line-width");
370  if (lineWidthAttribute)
371  lineWidth = atof(lineWidthAttribute);
372  // line color
373  cFigure::Color lineColor = cFigure::BLACK;
374  const char *lineColorAttribute = element->getAttribute("line-color");
375  if (lineColorAttribute) {
376  if (strchr(lineColorAttribute, ' ')) {
377  cStringTokenizer tokenizer(lineColorAttribute);
378  if ((tok = tokenizer.nextToken()) == nullptr)
379  throw cRuntimeError("Missing line-color red at %s", element->getSourceLocation());
380  lineColor.red = atoi(tok);
381  if ((tok = tokenizer.nextToken()) == nullptr)
382  throw cRuntimeError("Missing line-color green at %s", element->getSourceLocation());
383  lineColor.green = atoi(tok);
384  if ((tok = tokenizer.nextToken()) == nullptr)
385  throw cRuntimeError("Missing line-color blue at %s", element->getSourceLocation());
386  lineColor.blue = atoi(tok);
387  }
388  else
389  lineColor = cFigure::Color(lineColorAttribute);
390  }
391  // fill color
392  cFigure::Color fillColor = cFigure::WHITE;
393  const char *fillColorAttribute = element->getAttribute("fill-color");
394  if (fillColorAttribute) {
395  if (strchr(fillColorAttribute, ' ')) {
396  cStringTokenizer tokenizer(fillColorAttribute);
397  if ((tok = tokenizer.nextToken()) == nullptr)
398  throw cRuntimeError("Missing fill-color red at %s", element->getSourceLocation());
399  fillColor.red = atoi(tok);
400  if ((tok = tokenizer.nextToken()) == nullptr)
401  throw cRuntimeError("Missing fill-color green at %s", element->getSourceLocation());
402  fillColor.green = atoi(tok);
403  if ((tok = tokenizer.nextToken()) == nullptr)
404  throw cRuntimeError("Missing fill-color blue at %s", element->getSourceLocation());
405  fillColor.blue = atoi(tok);
406  }
407  else
408  fillColor = cFigure::Color(fillColorAttribute);
409  }
410  // opacity
411  double opacity = 1;
412  const char *opacityAttribute = element->getAttribute("opacity");
413  if (opacityAttribute)
414  opacity = atof(opacityAttribute);
415  // texture
416  const char *texture = element->getAttribute("texture");
417  // tags
418  const char *tags = element->getAttribute("tags");
419  // insert object
420  PhysicalObject *object = new PhysicalObject(name, id, position, orientation, shape, material, lineWidth, lineColor, fillColor, opacity, texture, tags);
421  objects.push_back(object);
422  if (id != -1)
423  idToObjectMap.insert(std::pair<int, const PhysicalObject *>(id, object));
424  const Coord min = position - size / 2;
425  const Coord max = position + size / 2;
426  if ((!std::isnan(spaceMin.x) && min.x < spaceMin.x) || (!std::isnan(spaceMax.x) && max.x > spaceMax.x) ||
427  (!std::isnan(spaceMin.y) && min.y < spaceMin.y) || (!std::isnan(spaceMax.y) && max.y > spaceMax.y) ||
428  (!std::isnan(spaceMin.z) && min.z < spaceMin.z) || (!std::isnan(spaceMax.z) && max.z > spaceMax.z))
429  throw cRuntimeError("Object is outside of space limits");
430  if (std::isnan(computedSpaceMin.x) || min.x < computedSpaceMin.x) computedSpaceMin.x = min.x;
431  if (std::isnan(computedSpaceMin.y) || min.y < computedSpaceMin.y) computedSpaceMin.y = min.y;
432  if (std::isnan(computedSpaceMin.z) || min.z < computedSpaceMin.z) computedSpaceMin.z = min.z;
433  if (std::isnan(computedSpaceMax.x) || max.x > computedSpaceMax.x) computedSpaceMax.x = max.x;
434  if (std::isnan(computedSpaceMax.y) || max.y > computedSpaceMax.y) computedSpaceMax.y = max.y;
435  if (std::isnan(computedSpaceMax.z) || max.z > computedSpaceMax.z) computedSpaceMax.z = max.z;
436  }
437  if (std::isnan(spaceMin.x)) spaceMin.x = computedSpaceMin.x;
438  if (std::isnan(spaceMin.y)) spaceMin.y = computedSpaceMin.y;
439  if (std::isnan(spaceMin.z)) spaceMin.z = computedSpaceMin.z;
440  if (std::isnan(spaceMax.x)) spaceMax.x = computedSpaceMax.x;
441  if (std::isnan(spaceMax.y)) spaceMax.y = computedSpaceMax.y;
442  if (std::isnan(spaceMax.z)) spaceMax.z = computedSpaceMax.z;
443 }

Referenced by initialize().

◆ parseShapes()

void inet::physicalenvironment::PhysicalEnvironment::parseShapes ( cXMLElement *  xml)
protectedvirtual
78 {
79  cXMLElementList children = xml->getChildrenByTagName("shape");
80  for (cXMLElementList::const_iterator it = children.begin(); it != children.end(); ++it) {
81  cXMLElement *element = *it;
82  ShapeBase *shape = nullptr;
83  const char *tok;
84  // id
85  const char *idAttribute = element->getAttribute("id");
86  int id = -1;
87  if (idAttribute)
88  id = atoi(idAttribute);
89  if (containsKey(idToShapeMap, id))
90  throw cRuntimeError("Shape already exists with the same id: '%d'", id);
91  // type
92  const char *typeAttribute = element->getAttribute("type");
93  if (!typeAttribute)
94  throw cRuntimeError("Missing type attribute of shape");
95  else if (!strcmp(typeAttribute, "cuboid")) {
96  Coord size;
97  const char *sizeAttribute = element->getAttribute("size");
98  if (!sizeAttribute)
99  throw cRuntimeError("Missing size attribute of cuboid");
100  cStringTokenizer tokenizer(sizeAttribute);
101  if ((tok = tokenizer.nextToken()) == nullptr)
102  throw cRuntimeError("Missing cuboid size x at %s", element->getSourceLocation());
103  size.x = atof(tok);
104  if ((tok = tokenizer.nextToken()) == nullptr)
105  throw cRuntimeError("Missing cuboid size y at %s", element->getSourceLocation());
106  size.y = atof(tok);
107  if ((tok = tokenizer.nextToken()) == nullptr)
108  throw cRuntimeError("Missing cuboid size z at %s", element->getSourceLocation());
109  size.z = atof(tok);
110  shape = new Cuboid(size);
111  }
112  else if (!strcmp(typeAttribute, "sphere")) {
113  double radius;
114  const char *radiusAttribute = element->getAttribute("radius");
115  if (!radiusAttribute)
116  throw cRuntimeError("Missing radius attribute of sphere");
117  radius = atof(radiusAttribute);
118  shape = new Sphere(radius);
119  }
120  else if (!strcmp(typeAttribute, "prism")) {
121  double height;
122  const char *heightAttribute = element->getAttribute("height");
123  if (!heightAttribute)
124  throw cRuntimeError("Missing height attribute of prism");
125  height = atof(heightAttribute);
126  std::vector<Coord> points;
127  const char *pointsAttribute = element->getAttribute("points");
128  if (!pointsAttribute)
129  throw cRuntimeError("Missing points attribute of prism");
130  cStringTokenizer tokenizer(pointsAttribute);
131  while (tokenizer.hasMoreTokens()) {
132  Coord point;
133  point.x = atof(tokenizer.nextToken());
134  if ((tok = tokenizer.nextToken()) == nullptr)
135  throw cRuntimeError("Missing prism y at %s", element->getSourceLocation());
136  point.y = atof(tok);
137  point.z = -height / 2;
138  points.push_back(point);
139  }
140  if (points.size() < 3)
141  throw cRuntimeError("prism needs at least three points at %s", element->getSourceLocation());
142  convertPoints(points);
143  shape = new Prism(height, Polygon(points));
144  }
145  else if (!strcmp(typeAttribute, "polyhedron")) {
146  std::vector<Coord> points;
147  const char *pointsAttribute = element->getAttribute("points");
148  if (!pointsAttribute)
149  throw cRuntimeError("Missing points attribute of polyhedron");
150  cStringTokenizer tokenizer(pointsAttribute);
151  while (tokenizer.hasMoreTokens()) {
152  Coord point;
153  point.x = atof(tokenizer.nextToken());
154  if ((tok = tokenizer.nextToken()) == nullptr)
155  throw cRuntimeError("Missing polyhedron y at %s", element->getSourceLocation());
156  point.y = atof(tok);
157  if ((tok = tokenizer.nextToken()) == nullptr)
158  throw cRuntimeError("Missing polyhedron z at %s", element->getSourceLocation());
159  point.z = atof(tok);
160  points.push_back(point);
161  }
162  if (points.size() < 4)
163  throw cRuntimeError("polyhedron needs at least four points at %s", element->getSourceLocation());
164  convertPoints(points);
165  shape = new Polyhedron(points);
166  }
167  else
168  throw cRuntimeError("Unknown shape type '%s'", typeAttribute);
169  // insert
170  idToShapeMap.insert(std::pair<int, const ShapeBase *>(id, shape));
171  }
172 }

Referenced by initialize().

◆ visitObjects()

void inet::physicalenvironment::PhysicalEnvironment::visitObjects ( const IVisitor visitor,
const LineSegment lineSegment 
) const
overridevirtual

Implements inet::physicalenvironment::IPhysicalEnvironment.

452 {
453  if (objectCache)
454  objectCache->visitObjects(visitor, lineSegment);
455  else
456  for (const auto& elem : objects)
457  visitor->visit(elem);
458 }

Member Data Documentation

◆ coordinateSystem

IGeographicCoordinateSystem* inet::physicalenvironment::PhysicalEnvironment::coordinateSystem = nullptr
protected

◆ ground

IGround* inet::physicalenvironment::PhysicalEnvironment::ground = nullptr
protected

Referenced by initialize().

◆ idToMaterialMap

std::map<int, const Material *> inet::physicalenvironment::PhysicalEnvironment::idToMaterialMap
protected

Referenced by parseMaterials(), and parseObjects().

◆ idToObjectMap

std::map<int, const PhysicalObject *> inet::physicalenvironment::PhysicalEnvironment::idToObjectMap
protected

Referenced by getObjectById(), and parseObjects().

◆ idToShapeMap

std::map<int, const ShapeBase *> inet::physicalenvironment::PhysicalEnvironment::idToShapeMap
protected

Referenced by parseObjects(), and parseShapes().

◆ materials

std::vector<const Material *> inet::physicalenvironment::PhysicalEnvironment::materials
protected

◆ nameToMaterialMap

std::map<std::string, const Material *> inet::physicalenvironment::PhysicalEnvironment::nameToMaterialMap
protected

Referenced by parseMaterials(), and parseObjects().

◆ objectCache

IObjectCache* inet::physicalenvironment::PhysicalEnvironment::objectCache = nullptr
protected

Referenced by initialize(), and visitObjects().

◆ objects

std::vector<const PhysicalObject *> inet::physicalenvironment::PhysicalEnvironment::objects
protected

◆ shapes

std::vector<const ShapeBase *> inet::physicalenvironment::PhysicalEnvironment::shapes
protected

◆ spaceMax

Coord inet::physicalenvironment::PhysicalEnvironment::spaceMax
protected

Referenced by initialize(), and parseObjects().

◆ spaceMin

Coord inet::physicalenvironment::PhysicalEnvironment::spaceMin
protected

Referenced by initialize(), and parseObjects().

◆ temperature

K inet::physicalenvironment::PhysicalEnvironment::temperature
protected

Referenced by initialize().


The documentation for this class was generated from the following files:
inet::INITSTAGE_PHYSICAL_ENVIRONMENT
INET_API InitStage INITSTAGE_PHYSICAL_ENVIRONMENT
Initialization of the physical environment.
inet::physicalenvironment::PhysicalEnvironment::coordinateSystem
IGeographicCoordinateSystem * coordinateSystem
Definition: PhysicalEnvironment.h:38
inet::physicalenvironment::PhysicalEnvironment::objects
std::vector< const PhysicalObject * > objects
Definition: PhysicalEnvironment.h:54
inet::physicalenvironment::PhysicalEnvironment::idToObjectMap
std::map< int, const PhysicalObject * > idToObjectMap
Definition: PhysicalEnvironment.h:61
inet::units::units::deg
fscale< rad, rad2degScale > deg
Definition: Units.h:1158
inet::Coord::ZERO
static const Coord ZERO
Definition: Coord.h:27
inet::physicalenvironment::PhysicalEnvironment::objectCache
IObjectCache * objectCache
Definition: PhysicalEnvironment.h:46
inet::sctp::min
double min(const double a, const double b)
Returns the minimum of a and b.
Definition: SctpAssociation.h:261
inet::physicalenvironment::PhysicalEnvironment::spaceMax
Coord spaceMax
Definition: PhysicalEnvironment.h:41
inet::Coord::x
double x
Definition: Coord.h:36
inet::units::values::K
value< double, units::K > K
Definition: Units.h:1237
inet::physicalenvironment::PhysicalEnvironment::idToShapeMap
std::map< int, const ShapeBase * > idToShapeMap
Definition: PhysicalEnvironment.h:59
inet::physicalenvironment::PhysicalEnvironment::shapes
std::vector< const ShapeBase * > shapes
Definition: PhysicalEnvironment.h:52
inet::physicalenvironment::IObjectCache::visitObjects
virtual void visitObjects(const IVisitor *visitor, const LineSegment &lineSegment) const =0
Calls the visitor with at least all physical objects that intersect with the provided line segment.
inet::physicalenvironment::MaterialRegistry::singleton
static MaterialRegistry singleton
Definition: MaterialRegistry.h:25
inet::physicalenvironment::PhysicalEnvironment::parseMaterials
virtual void parseMaterials(cXMLElement *xml)
Definition: PhysicalEnvironment.cc:174
inet::physicalenvironment::PhysicalEnvironment::spaceMin
Coord spaceMin
Definition: PhysicalEnvironment.h:40
inet::physicalenvironment::PhysicalEnvironment::nameToMaterialMap
std::map< std::string, const Material * > nameToMaterialMap
Definition: PhysicalEnvironment.h:62
inet::Coord::z
double z
Definition: Coord.h:38
NaN
#define NaN
Definition: INETMath.h:91
inet::INITSTAGE_LOCAL
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
kind
removed DscpReq kind
Definition: IUdp-gates.txt:12
NUM_INIT_STAGES
#define NUM_INIT_STAGES
Definition: InitStageRegistry.h:73
inet::physicalenvironment::MaterialRegistry::getMaterial
virtual const Material * getMaterial(const char *name) const override
Definition: MaterialRegistry.cc:33
inet::physicalenvironment::PhysicalEnvironment::parseObjects
virtual void parseObjects(cXMLElement *xml)
Definition: PhysicalEnvironment.cc:211
inet::sctp::max
double max(const double a, const double b)
Returns the maximum of a and b.
Definition: SctpAssociation.h:266
inet::physicalenvironment::PhysicalEnvironment::materials
std::vector< const Material * > materials
Definition: PhysicalEnvironment.h:53
inet::physicalenvironment::PhysicalEnvironment::parseShapes
virtual void parseShapes(cXMLElement *xml)
Definition: PhysicalEnvironment.cc:77
inet::physicalenvironment::PhysicalEnvironment::convertPoints
virtual void convertPoints(std::vector< Coord > &points)
Definition: PhysicalEnvironment.cc:65
inet::physicalenvironment::PhysicalEnvironment::idToMaterialMap
std::map< int, const Material * > idToMaterialMap
Definition: PhysicalEnvironment.h:60
tags
* tags
Definition: IUdp-gates.txt:3
inet::Coord::NIL
static const Coord NIL
Constant with all values set to 0.
Definition: Coord.h:26
inet::units::constants::alpha
const value< double, units::unit > alpha(7.2973525376e-3)
inet::DiffservUtil::Color
Color
Definition: DiffservUtil.h:17
inet::units::units::Ohmm
compose< Ohm, m > Ohmm
Definition: Units.h:945
inet::units::values::m
value< double, units::m > m
Definition: Units.h:1233
inet::IGeographicCoordinateSystem::computeSceneCoordinate
virtual Coord computeSceneCoordinate(const GeoCoord &geographicCoordinate) const =0
inet::physicalenvironment::PhysicalEnvironment::temperature
K temperature
Definition: PhysicalEnvironment.h:39
inet::Box::getSize
Coord getSize() const
Definition: Box.h:33
inet::Box::computeBoundingBox
static Box computeBoundingBox(const std::vector< Coord > &points)
Definition: Box.cc:20
inet::Coord::y
double y
Definition: Coord.h:37
inet::physicalenvironment::PhysicalEnvironment::ground
IGround * ground
Definition: PhysicalEnvironment.h:47
inet::containsKey
bool containsKey(const std::map< K, V, _C > &m, const Tk &a)
Definition: stlutils.h:80