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

Constructor & Destructor Documentation

inet::PolyhedronFace::PolyhedronFace ( PolyhedronPoint p1,
PolyhedronPoint p2,
PolyhedronPoint p3 
)
23 {
24  // Constructor for triangular face
28  wrapped = false;
29  PolyhedronEdge *edge1 = new PolyhedronEdge(p1, p2, this);
30  PolyhedronEdge *edge2 = new PolyhedronEdge(p2, p3, this);
31  PolyhedronEdge *edge3 = new PolyhedronEdge(p3, p1, this);
32  edge1->setNextEdge(edge2);
33  edge2->setNextEdge(edge3);
34  edge3->setNextEdge(nullptr);
35  edge1->setPrevEdge(edge3);
36  edge2->setPrevEdge(edge1);
37  edge3->setPrevEdge(edge2);
38  pushEdge(edge1);
39  pushEdge(edge2);
40  pushEdge(edge3);
42 }
void computeNormalVector()
Definition: PolyhedronFace.cc:70
Coord normalVector
Definition: PolyhedronFace.h:41
static const Coord NIL
Constant with all values set to 0.
Definition: Coord.h:40
void pushEdge(PolyhedronEdge *edge)
Definition: PolyhedronFace.cc:57
bool wrapped
Definition: PolyhedronFace.h:43
Coord outwardNormalVector
Definition: PolyhedronFace.h:40
Coord centroid
Definition: PolyhedronFace.h:42
inet::PolyhedronFace::~PolyhedronFace ( )
virtual
65 {
66  for (auto & elem : edges)
67  delete elem;
68 }
Edges edges
Definition: PolyhedronFace.h:38

Member Function Documentation

void inet::PolyhedronFace::addConflictPoint ( PolyhedronPoint point)
inline

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

56 { pConflict.push_back(point); }
Points pConflict
Definition: PolyhedronFace.h:39
void inet::PolyhedronFace::computeCentroid ( )

Referenced by pushEdge().

45 {
46  centroid = Coord(0,0,0);
47  unsigned int numberOfPoints = edges.size();
48  for (Edges::const_iterator eit = edges.begin(); eit != edges.end(); eit++)
49  {
50  PolyhedronPoint *point = (*eit)->getP1();
51  centroid += *point;
52  }
53  ASSERT(numberOfPoints != 0);
54  centroid /= numberOfPoints;
55 }
Edges edges
Definition: PolyhedronFace.h:38
Coord centroid
Definition: PolyhedronFace.h:42
void inet::PolyhedronFace::computeNormalVector ( )

Referenced by PolyhedronFace().

71 {
72  normalVector = edges[0]->getEdgeVector() % edges[0]->getNextEdge()->getEdgeVector();
73 }
Coord normalVector
Definition: PolyhedronFace.h:41
Edges edges
Definition: PolyhedronFace.h:38
PolyhedronEdge * inet::PolyhedronFace::findEdge ( PolyhedronEdge edge)
90 {
91  for (auto currEdge : edges)
92  {
93 
94  if (*currEdge == *edge)
95  return currEdge;
96  }
97  return nullptr;
98 }
Edges edges
Definition: PolyhedronFace.h:38
Coord inet::PolyhedronFace::getCentroid ( ) const
inline

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

62 { return centroid; }
Coord centroid
Definition: PolyhedronFace.h:42
std::vector<PolyhedronPoint *>& inet::PolyhedronFace::getConflictVector ( )
inline

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

48 { return pConflict; }
Points pConflict
Definition: PolyhedronFace.h:39
const std::vector<PolyhedronPoint *>& inet::PolyhedronFace::getConflictVector ( ) const
inline
49 { return pConflict; }
Points pConflict
Definition: PolyhedronFace.h:39
PolyhedronEdge * inet::PolyhedronFace::getEdge ( unsigned int  i) const

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

76 {
77  if (i >= edges.size())
78  throw cRuntimeError("Out of range with index = %d", i);
79  return edges.at(i);
80 }
Edges edges
Definition: PolyhedronFace.h:38
Edges& inet::PolyhedronFace::getEdges ( )
inline
const Edges& inet::PolyhedronFace::getEdges ( ) const
inline
54 { return edges; }
Edges edges
Definition: PolyhedronFace.h:38
Coord inet::PolyhedronFace::getNormalVector ( ) const
inline

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

59 { return normalVector; }
Coord normalVector
Definition: PolyhedronFace.h:41
Coord inet::PolyhedronFace::getOutwardNormalVector ( ) const
inline

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

60 { return outwardNormalVector; }
Coord outwardNormalVector
Definition: PolyhedronFace.h:40
bool inet::PolyhedronFace::hasConflicts ( ) const
inline
55 { return !pConflict.empty(); }
Points pConflict
Definition: PolyhedronFace.h:39
bool inet::PolyhedronFace::isVisibleFrom ( const PolyhedronPoint point) const

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

83 {
84  PolyhedronPoint *facePoint = getEdge(0)->getP1();
85  PolyhedronPoint facePointPoint = *point - *facePoint;
86  return facePointPoint * outwardNormalVector > 0;
87 }
PolyhedronEdge * getEdge(unsigned int i) const
Definition: PolyhedronFace.cc:75
PolyhedronPoint * getP1()
Definition: PolyhedronEdge.h:45
Coord outwardNormalVector
Definition: PolyhedronFace.h:40
bool inet::PolyhedronFace::isWrapped ( ) const
inline

Referenced by inet::Polyhedron::connectFaces(), and inet::Polyhedron::purgeWrappedFaces().

46 { return wrapped; }
bool wrapped
Definition: PolyhedronFace.h:43
void inet::PolyhedronFace::pushEdge ( PolyhedronEdge edge)

Referenced by PolyhedronFace().

58 {
59  edges.push_back(edge);
60  // We need to recompute the centroid
62 }
void computeCentroid()
Definition: PolyhedronFace.cc:44
Edges edges
Definition: PolyhedronFace.h:38
void inet::PolyhedronFace::setOutwardNormalVector ( const Coord outwardNormalVector)
inline
void inet::PolyhedronFace::setToWrapped ( )
inline
47 { wrapped = true; }
bool wrapped
Definition: PolyhedronFace.h:43

Member Data Documentation

Coord inet::PolyhedronFace::centroid
protected

Referenced by computeCentroid(), and PolyhedronFace().

Edges inet::PolyhedronFace::edges
protected
Coord inet::PolyhedronFace::normalVector
protected
Coord inet::PolyhedronFace::outwardNormalVector
protected

Referenced by isVisibleFrom(), and PolyhedronFace().

Points inet::PolyhedronFace::pConflict
protected
bool inet::PolyhedronFace::wrapped
protected

Referenced by PolyhedronFace().


The documentation for this class was generated from the following files: