|
INET Framework for OMNeT++/OMNEST
|
#include <Polyhedron.h>
|
| void | purgeWrappedFaces () |
| |
| void | buildConvexHull () |
| |
| bool | areCollinear (const PolyhedronPoint *lineP1, const PolyhedronPoint *lineP2, const PolyhedronPoint *point) const |
| |
| bool | areCoplanar (const PolyhedronPoint *p1, const PolyhedronPoint *p2, const PolyhedronPoint *p3, const PolyhedronPoint *p4) const |
| |
| bool | areCoplanar (const PolyhedronFace *face1, const PolyhedronFace *face2) const |
| |
| void | mergeFaces (PolyhedronFace *newFace, PolyhedronFace *neighborFace, PolyhedronPoint *point) |
| |
| void | createInitialTetrahedron () |
| |
| void | initializeConflictGraph () |
| |
| void | cleanConflictGraph (const Faces &conflictVector) |
| |
| void | purgeConflictFaces (const Faces &conflictVector) |
| |
| void | connectFaces (PolyhedronFace *newFace) |
| |
| void | setContlictListForNewFace (PolyhedronFace *newFace, const PolyhedronFace *neighbor1, const PolyhedronFace *neighbor2) |
| |
| void | generateAndAddTetrahedronFaces (const Points &tetrahedronPoints) |
| |
| PolyhedronPoint | computeOutwardNormalVector (const PolyhedronFace *face) const |
| |
| void | addFace (PolyhedronFace *face) |
| |
| Edges | computeHorizonEdges (const Faces &visibleFaces) const |
| |
| bool | isVisibleFromView (const PolyhedronFace *face, const RotationMatrix &viewRotation, const RotationMatrix &rotation) const |
| |
◆ Edges
◆ Faces
◆ Points
◆ Polyhedron()
| inet::Polyhedron::Polyhedron |
( |
const std::vector< Coord > & |
points | ) |
|
260 throw cRuntimeError(
"We need at least four points");
261 for (
const auto& point :
points)
262 this->points.push_back(
new PolyhedronPoint(point));
◆ ~Polyhedron()
| inet::Polyhedron::~Polyhedron |
( |
| ) |
|
|
virtual |
407 for (
auto& elem :
faces)
◆ addFace()
◆ areCollinear()
71 PolyhedronPoint P1P2 = *lineP2 - *lineP1;
72 PolyhedronPoint P1Point = *point - *lineP1;
73 return P1P2 % P1Point == Coord(0, 0, 0);
Referenced by createInitialTetrahedron().
◆ areCoplanar() [1/2]
186 Coord faceNormal1 = face1->getNormalVector();
187 Coord faceNormal2 = face2->getNormalVector();
188 return faceNormal1 % faceNormal2 == Coord(0, 0, 0);
◆ areCoplanar() [2/2]
◆ buildConvexHull()
| void inet::Polyhedron::buildConvexHull |
( |
| ) |
|
|
protected |
27 for (
auto currentPoint :
points) {
28 if (currentPoint->isSelected())
30 currentPoint->setToSelected();
32 if (currentPoint->hasConflicts()) {
34 Faces& conflictVector = currentPoint->getConflictVector();
35 Faces copyConflictVector = currentPoint->getConflictVector();
40 for (
auto horizonEdge : horizonEdges) {
42 PolyhedronFace *neighborFace = horizonEdge->getJointFace();
43 PolyhedronFace *parentFace = horizonEdge->getParentFace();
45 PolyhedronFace *newFace =
new PolyhedronFace(horizonEdge->getP1(), horizonEdge->getP2(), currentPoint);
51 mergeFaces(newFace, neighborFace, currentPoint);
Referenced by Polyhedron().
◆ cleanConflictGraph()
| void inet::Polyhedron::cleanConflictGraph |
( |
const Faces & |
conflictVector | ) |
|
|
protected |
245 for (
auto face : conflictVector) {
246 Points& pConflict = face->getConflictVector();
247 for (
auto point : pConflict) {
248 Faces& currFConflict = point->getConflictVector();
249 auto fit2 =
find(currFConflict, face);
250 if (fit2 == currFConflict.end())
251 throw cRuntimeError(
"PolyhedronFace not found in the point's conflict vector");
252 currFConflict.erase(fit2);
Referenced by buildConvexHull().
◆ computeBoundingBoxSize()
| Coord inet::Polyhedron::computeBoundingBoxSize |
( |
| ) |
const |
|
overridevirtual |
Computes the 3 dimensional size of the shapes's bounding box.
Implements inet::ShapeBase.
320 for (
const auto& elem :
points) {
321 Coord point = *(elem);
◆ computeHorizonEdges()
157 for (Faces::const_iterator it = visibleFaces.begin(); it != visibleFaces.end(); it++) {
158 PolyhedronFace *visibleFace = *it;
159 Edges& edges = visibleFace->getEdges();
160 for (
auto visibleEdge : edges) {
164 if (!
contains(visibleFaces, visibleEdge->getJointFace()))
165 horizonEdges.push_back(visibleEdge);
Referenced by buildConvexHull().
◆ computeIntersection()
| bool inet::Polyhedron::computeIntersection |
( |
const LineSegment & |
lineSegment, |
|
|
Coord & |
intersection1, |
|
|
Coord & |
intersection2, |
|
|
Coord & |
normal1, |
|
|
Coord & |
normal2 |
|
) |
| const |
|
overridevirtual |
Computes the intersection with the given line segment in the shape's coordinate system.
Implements inet::ShapeBase.
331 Coord p0 = lineSegment.getPoint1();
332 Coord p1 = lineSegment.getPoint2();
337 Coord segmentDirection = p1 - p0;
340 for (
auto face :
faces) {
341 Coord normalVec = face->getOutwardNormalVector();
342 Coord centroid = face->getCentroid();
343 double N = (centroid - p0) * normalVec;
344 double D = segmentDirection * normalVec;
372 intersection1 = p0 + segmentDirection * tE;
373 intersection2 = p0 + segmentDirection * tL;
374 if (intersection1 == intersection2) {
◆ computeOutwardNormalVector()
274 if (
faces.size() <= 0)
275 throw cRuntimeError(
"You can't compute the outward normal vector if you have no faces at all");
276 PolyhedronFace *testFace =
faces.at(0);
277 if (face == testFace)
278 testFace =
faces.at(1);
279 Coord testCentroid = testFace->getCentroid();
280 PolyhedronPoint *facePoint = face->getEdge(0)->getP1();
281 Coord faceNormal = face->getNormalVector();
282 if ((testCentroid - *facePoint) * faceNormal > 0)
283 return faceNormal * (-1);
Referenced by buildConvexHull(), and generateAndAddTetrahedronFaces().
◆ computeVisibleFaces()
| void inet::Polyhedron::computeVisibleFaces |
( |
std::vector< std::vector< Coord >> & |
faces, |
|
|
const RotationMatrix & |
rotation, |
|
|
const RotationMatrix & |
viewRotation |
|
) |
| const |
◆ connectFaces()
289 Edges& newEdges = newFace->getEdges();
290 for (
auto newEdge : newEdges) {
291 for (
auto currentFace :
faces) {
292 if (currentFace == newFace || currentFace->isWrapped())
continue;
293 PolyhedronEdge *currEdge = currentFace->findEdge(newEdge);
295 currEdge->setJointFace(newFace);
296 newEdge->setJointFace(currentFace);
Referenced by buildConvexHull(), and generateAndAddTetrahedronFaces().
◆ createInitialTetrahedron()
| void inet::Polyhedron::createInitialTetrahedron |
( |
| ) |
|
|
protected |
88 PolyhedronPoint *p1 = *it;
91 PolyhedronPoint *p2 = *it;
94 tetrahedronPoints.push_back(p1);
95 tetrahedronPoints.push_back(p2);
96 PolyhedronPoint *p3 =
nullptr;
98 while (it !=
points.end() && !p3) {
106 throw cRuntimeError(
"All points lie on the same line");
108 tetrahedronPoints.push_back(p3);
109 PolyhedronPoint *p4 =
nullptr;
111 while (it !=
points.end() && !p4) {
119 throw cRuntimeError(
"All points lie in the same plane");
120 tetrahedronPoints.push_back(p4);
Referenced by buildConvexHull().
◆ generateAndAddTetrahedronFaces()
| void inet::Polyhedron::generateAndAddTetrahedronFaces |
( |
const Points & |
tetrahedronPoints | ) |
|
|
protected |
129 PolyhedronFace *face1 =
new PolyhedronFace(tetrahedronPoints[0], tetrahedronPoints[1], tetrahedronPoints[2]);
130 PolyhedronFace *face2 =
new PolyhedronFace(tetrahedronPoints[0], tetrahedronPoints[1], tetrahedronPoints[3]);
131 PolyhedronFace *face3 =
new PolyhedronFace(tetrahedronPoints[0], tetrahedronPoints[2], tetrahedronPoints[3]);
132 PolyhedronFace *face4 =
new PolyhedronFace(tetrahedronPoints[1], tetrahedronPoints[2], tetrahedronPoints[3]);
Referenced by createInitialTetrahedron().
◆ getFaces()
| const Faces& inet::Polyhedron::getFaces |
( |
| ) |
const |
|
inline |
◆ getPoints()
| const Points& inet::Polyhedron::getPoints |
( |
| ) |
const |
|
inline |
◆ initializeConflictGraph()
| void inet::Polyhedron::initializeConflictGraph |
( |
| ) |
|
|
protected |
173 for (
auto point :
points) {
174 for (
auto face :
faces) {
176 if (face->isVisibleFrom(point)) {
177 point->addConflictFace(face);
178 face->addConflictPoint(point);
Referenced by buildConvexHull().
◆ isVisibleFromView()
398 Coord zNormal(0, 0, 1);
399 Coord rotatedFaceNormal = viewRotation.rotateVector(rotation.rotateVector(face->getOutwardNormalVector()));
400 return rotatedFaceNormal * zNormal > 0;
Referenced by computeVisibleFaces().
◆ mergeFaces()
193 Edges& edges = neighborFace->getEdges();
194 auto eit = edges.begin();
195 PolyhedronEdge *edge = *eit;
197 while (edge->getJointFace() != newFace) {
199 if (eit == edges.end())
200 throw cRuntimeError(
"Tried to merge two faces that do not share a common edge");
205 eit = edges.erase(eit);
206 PolyhedronPoint *p1 = edge->getP1();
207 PolyhedronPoint *p2 = edge->getP2();
210 PolyhedronEdge *edge1 =
new PolyhedronEdge(p1, point, neighborFace);
211 PolyhedronEdge *edge2 =
new PolyhedronEdge(point, p2, neighborFace);
213 edges.insert(eit, edge1);
215 edges.insert(eit, edge2);
Referenced by buildConvexHull().
◆ purgeConflictFaces()
| void inet::Polyhedron::purgeConflictFaces |
( |
const Faces & |
conflictVector | ) |
|
|
protected |
268 for (
auto face : conflictVector)
269 face->setToWrapped();
Referenced by buildConvexHull().
◆ purgeWrappedFaces()
| void inet::Polyhedron::purgeWrappedFaces |
( |
| ) |
|
|
protected |
304 auto fit =
faces.begin();
305 while (fit !=
faces.end()) {
306 PolyhedronFace *face = *fit;
307 if (face->isWrapped()) {
308 fit =
faces.erase(fit);
Referenced by buildConvexHull().
◆ setContlictListForNewFace()
224 std::map<PolyhedronPoint *, bool> visited;
225 const Points& conflict1 = neighbor1->getConflictVector();
226 const Points& conflict2 = neighbor2->getConflictVector();
227 for (
const auto& elem : conflict1) {
228 PolyhedronPoint *point = elem;
229 visited.insert(std::pair<PolyhedronPoint *, bool>(point,
true));
230 if (newFace->isVisibleFrom(elem)) {
231 newFace->addConflictPoint(point);
232 point->addConflictFace(newFace);
235 for (
auto point : conflict2) {
236 if (!
containsKey(visited, point) && newFace->isVisibleFrom(point)) {
237 point->addConflictFace(newFace);
238 newFace->addConflictPoint(point);
Referenced by buildConvexHull().
◆ faces
| Faces inet::Polyhedron::faces |
|
protected |
◆ points
| Points inet::Polyhedron::points |
|
protected |
The documentation for this class was generated from the following files:
bool areCollinear(const PolyhedronPoint *lineP1, const PolyhedronPoint *lineP2, const PolyhedronPoint *point) const
Definition: Polyhedron.cc:69
std::vector< PolyhedronPoint * > Points
Definition: Polyhedron.h:26
Points points
Definition: Polyhedron.h:32
Faces faces
Definition: Polyhedron.h:31
double min(const double a, const double b)
Returns the minimum of a and b.
Definition: SctpAssociation.h:261
std::vector< T >::iterator find(std::vector< T > &v, const Tk &a)
Definition: stlutils.h:44
compose< m, compose< kg, pow< s, -2 > > > N
Definition: Units.h:936
void createInitialTetrahedron()
Definition: Polyhedron.cc:83
void connectFaces(PolyhedronFace *newFace)
Definition: Polyhedron.cc:287
std::vector< PolyhedronFace * > Faces
Definition: Polyhedron.h:27
void addFace(PolyhedronFace *face)
Definition: Polyhedron.cc:149
bool contains(const std::vector< T > &v, const Tk &a)
Definition: stlutils.h:65
PolyhedronPoint computeOutwardNormalVector(const PolyhedronFace *face) const
Definition: Polyhedron.cc:272
std::vector< PolyhedronEdge * > Edges
Definition: Polyhedron.h:28
void generateAndAddTetrahedronFaces(const Points &tetrahedronPoints)
Definition: Polyhedron.cc:125
void mergeFaces(PolyhedronFace *newFace, PolyhedronFace *neighborFace, PolyhedronPoint *point)
Definition: Polyhedron.cc:191
double max(const double a, const double b)
Returns the maximum of a and b.
Definition: SctpAssociation.h:266
void buildConvexHull()
Definition: Polyhedron.cc:22
bool areCoplanar(const PolyhedronPoint *p1, const PolyhedronPoint *p2, const PolyhedronPoint *p3, const PolyhedronPoint *p4) const
Definition: Polyhedron.cc:76
void purgeWrappedFaces()
Definition: Polyhedron.cc:302
void cleanConflictGraph(const Faces &conflictVector)
Definition: Polyhedron.cc:243
static const Coord NIL
Constant with all values set to 0.
Definition: Coord.h:26
Edges computeHorizonEdges(const Faces &visibleFaces) const
Definition: Polyhedron.cc:154
void initializeConflictGraph()
Definition: Polyhedron.cc:171
bool isVisibleFromView(const PolyhedronFace *face, const RotationMatrix &viewRotation, const RotationMatrix &rotation) const
Definition: Polyhedron.cc:396
void setContlictListForNewFace(PolyhedronFace *newFace, const PolyhedronFace *neighbor1, const PolyhedronFace *neighbor2)
Definition: Polyhedron.cc:221
void purgeConflictFaces(const Faces &conflictVector)
Definition: Polyhedron.cc:266
bool containsKey(const std::map< K, V, _C > &m, const Tk &a)
Definition: stlutils.h:80