INET Framework for OMNeT++/OMNEST
inet::PolyhedronFace Class Reference

#include <PolyhedronFace.h>

Public Types

typedef std::vector< PolyhedronEdge * > Edges
 
typedef std::vector< PolyhedronPoint * > Points
 

Public Member Functions

bool isWrapped () const
 
void setToWrapped ()
 
std::vector< PolyhedronPoint * > & getConflictVector ()
 
const std::vector< PolyhedronPoint * > & getConflictVector () const
 
void computeCentroid ()
 
bool isVisibleFrom (const PolyhedronPoint *point) const
 
PolyhedronEdgegetEdge (unsigned int i) const
 
EdgesgetEdges ()
 
const EdgesgetEdges () const
 
bool hasConflicts () const
 
void addConflictPoint (PolyhedronPoint *point)
 
void computeNormalVector ()
 
PolyhedronEdgefindEdge (PolyhedronEdge *edge)
 
Coord getNormalVector () const
 
Coord getOutwardNormalVector () const
 
void pushEdge (PolyhedronEdge *edge)
 
Coord getCentroid () const
 
void setOutwardNormalVector (const Coord &outwardNormalVector)
 
 PolyhedronFace (PolyhedronPoint *p1, PolyhedronPoint *p2, PolyhedronPoint *p3)
 
virtual ~PolyhedronFace ()
 

Protected Attributes

Edges edges
 
Points pConflict
 
Coord outwardNormalVector
 
Coord normalVector
 
Coord centroid
 
bool wrapped
 

Member Typedef Documentation

◆ Edges

◆ Points

Constructor & Destructor Documentation

◆ PolyhedronFace()

inet::PolyhedronFace::PolyhedronFace ( PolyhedronPoint p1,
PolyhedronPoint p2,
PolyhedronPoint p3 
)
13 {
14  // Constructor for triangular face
18  wrapped = false;
19  PolyhedronEdge *edge1 = new PolyhedronEdge(p1, p2, this);
20  PolyhedronEdge *edge2 = new PolyhedronEdge(p2, p3, this);
21  PolyhedronEdge *edge3 = new PolyhedronEdge(p3, p1, this);
22  edge1->setNextEdge(edge2);
23  edge2->setNextEdge(edge3);
24  edge3->setNextEdge(nullptr);
25  edge1->setPrevEdge(edge3);
26  edge2->setPrevEdge(edge1);
27  edge3->setPrevEdge(edge2);
28  pushEdge(edge1);
29  pushEdge(edge2);
30  pushEdge(edge3);
32 }

◆ ~PolyhedronFace()

inet::PolyhedronFace::~PolyhedronFace ( )
virtual
54 {
55  for (auto& elem : edges)
56  delete elem;
57 }

Member Function Documentation

◆ addConflictPoint()

void inet::PolyhedronFace::addConflictPoint ( PolyhedronPoint point)
inline
47 { pConflict.push_back(point); }

Referenced by inet::Polyhedron::setContlictListForNewFace().

◆ computeCentroid()

void inet::PolyhedronFace::computeCentroid ( )
35 {
36  centroid = Coord(0, 0, 0);
37  unsigned int numberOfPoints = edges.size();
38  for (Edges::const_iterator eit = edges.begin(); eit != edges.end(); eit++) {
39  PolyhedronPoint *point = (*eit)->getP1();
40  centroid += *point;
41  }
42  ASSERT(numberOfPoints != 0);
43  centroid /= numberOfPoints;
44 }

Referenced by pushEdge().

◆ computeNormalVector()

void inet::PolyhedronFace::computeNormalVector ( )
60 {
61  normalVector = edges[0]->getEdgeVector() % edges[0]->getNextEdge()->getEdgeVector();
62 }

Referenced by PolyhedronFace().

◆ findEdge()

PolyhedronEdge * inet::PolyhedronFace::findEdge ( PolyhedronEdge edge)
79 {
80  for (auto currEdge : edges)
81  if (*currEdge == *edge)
82  return currEdge;
83  return nullptr;
84 }

◆ getCentroid()

Coord inet::PolyhedronFace::getCentroid ( ) const
inline

◆ getConflictVector() [1/2]

std::vector<PolyhedronPoint *>& inet::PolyhedronFace::getConflictVector ( )
inline

◆ getConflictVector() [2/2]

const std::vector<PolyhedronPoint *>& inet::PolyhedronFace::getConflictVector ( ) const
inline
40 { return pConflict; }

◆ getEdge()

PolyhedronEdge * inet::PolyhedronFace::getEdge ( unsigned int  i) const
65 {
66  if (i >= edges.size())
67  throw cRuntimeError("Out of range with index = %d", i);
68  return edges.at(i);
69 }

Referenced by inet::Polyhedron::computeOutwardNormalVector(), and isVisibleFrom().

◆ getEdges() [1/2]

Edges& inet::PolyhedronFace::getEdges ( )
inline

◆ getEdges() [2/2]

const Edges& inet::PolyhedronFace::getEdges ( ) const
inline
45 { return edges; }

◆ getNormalVector()

Coord inet::PolyhedronFace::getNormalVector ( ) const
inline

◆ getOutwardNormalVector()

Coord inet::PolyhedronFace::getOutwardNormalVector ( ) const
inline

◆ hasConflicts()

bool inet::PolyhedronFace::hasConflicts ( ) const
inline
46 { return !pConflict.empty(); }

◆ isVisibleFrom()

bool inet::PolyhedronFace::isVisibleFrom ( const PolyhedronPoint point) const
72 {
73  PolyhedronPoint *facePoint = getEdge(0)->getP1();
74  PolyhedronPoint facePointPoint = *point - *facePoint;
75  return facePointPoint * outwardNormalVector > 0;
76 }

Referenced by inet::Polyhedron::setContlictListForNewFace().

◆ isWrapped()

bool inet::PolyhedronFace::isWrapped ( ) const
inline

◆ pushEdge()

void inet::PolyhedronFace::pushEdge ( PolyhedronEdge edge)
47 {
48  edges.push_back(edge);
49  // We need to recompute the centroid
51 }

Referenced by PolyhedronFace().

◆ setOutwardNormalVector()

void inet::PolyhedronFace::setOutwardNormalVector ( const Coord outwardNormalVector)
inline

◆ setToWrapped()

void inet::PolyhedronFace::setToWrapped ( )
inline
38 { wrapped = true; }

Member Data Documentation

◆ centroid

Coord inet::PolyhedronFace::centroid
protected

Referenced by computeCentroid(), and PolyhedronFace().

◆ edges

Edges inet::PolyhedronFace::edges
protected

◆ normalVector

Coord inet::PolyhedronFace::normalVector
protected

◆ outwardNormalVector

Coord inet::PolyhedronFace::outwardNormalVector
protected

Referenced by isVisibleFrom(), and PolyhedronFace().

◆ pConflict

Points inet::PolyhedronFace::pConflict
protected

◆ wrapped

bool inet::PolyhedronFace::wrapped
protected

Referenced by PolyhedronFace().


The documentation for this class was generated from the following files:
inet::PolyhedronFace::outwardNormalVector
Coord outwardNormalVector
Definition: PolyhedronFace.h:31
inet::PolyhedronFace::getEdge
PolyhedronEdge * getEdge(unsigned int i) const
Definition: PolyhedronFace.cc:64
inet::PolyhedronFace::computeNormalVector
void computeNormalVector()
Definition: PolyhedronFace.cc:59
inet::PolyhedronFace::pushEdge
void pushEdge(PolyhedronEdge *edge)
Definition: PolyhedronFace.cc:46
inet::PolyhedronFace::computeCentroid
void computeCentroid()
Definition: PolyhedronFace.cc:34
inet::PolyhedronFace::normalVector
Coord normalVector
Definition: PolyhedronFace.h:32
inet::PolyhedronFace::centroid
Coord centroid
Definition: PolyhedronFace.h:33
inet::PolyhedronFace::wrapped
bool wrapped
Definition: PolyhedronFace.h:34
inet::PolyhedronEdge::getP1
PolyhedronPoint * getP1()
Definition: PolyhedronEdge.h:35
inet::PolyhedronFace::edges
Edges edges
Definition: PolyhedronFace.h:29
inet::Coord::NIL
static const Coord NIL
Constant with all values set to 0.
Definition: Coord.h:26
inet::PolyhedronFace::pConflict
Points pConflict
Definition: PolyhedronFace.h:30