A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
fastClipping.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008 INESC Porto
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Gustavo Carneiro <gjc@inescporto.pt>
7 */
8
9namespace ns3
10{
11
12/**
13 * @ingroup visualizer
14 *
15 * This class is used by the visualizer for the process of removing lines or portions of
16 * lines outside of an area of interest.
17 *
18 * This code has been adapted from
19 * http://en.wikipedia.org/w/index.php?title=Line_clipping&oldid=248609574
20 *
21 **/
23{
24 public:
25 /**
26 * @ingroup visualizer
27 *
28 * The Vector 2 struct
29 */
30 struct Vector2
31 {
32 double x; //!< X coordinate.
33 double y; //!< Y coordinate.
34 };
35
36 /**
37 * @ingroup visualizer
38 *
39 * The line struct
40 */
41 struct Line
42 {
43 Vector2 start; //!< The start point of the line.
44 Vector2 end; //!< The end point of the line.
45 double dx; //!< dX
46 double dy; //!< dY
47 };
48
49 /**
50 * Constructor
51 *
52 * @param clipMin minimum clipping vector
53 * @param clipMax maximum clipping vector
54 */
55 FastClipping(Vector2 clipMin, Vector2 clipMax);
56
57 /**
58 * Clip line function
59 *
60 * @param line the clip line
61 * @returns true if clipped
62 */
63 bool ClipLine(Line& line);
64
65 private:
66 /**
67 * Clip start top function
68 *
69 * @param line the clip line
70 */
71 void ClipStartTop(Line& line) const;
72
73 /**
74 * Clip start bottom function
75 *
76 * @param line the clip line
77 */
78 void ClipStartBottom(Line& line) const;
79
80 /**
81 * Clip start right function
82 *
83 * @param line the clip line
84 */
85 void ClipStartRight(Line& line) const;
86
87 /**
88 * Clip start left function
89 *
90 * @param line the clip line
91 */
92 void ClipStartLeft(Line& line) const;
93
94 /**
95 * Clip end top function
96 *
97 * @param line the clip line
98 */
99 void ClipEndTop(Line& line) const;
100
101 /**
102 * Clip end bottom function
103 *
104 * @param line the clip line
105 */
106 void ClipEndBottom(Line& line) const;
107
108 /**
109 * Clip end right function
110 *
111 * @param line the clip line
112 */
113 void ClipEndRight(Line& line) const;
114
115 /**
116 * Clip end left function
117 *
118 * @param line the clip line
119 */
120 void ClipEndLeft(Line& line) const;
121
122 Vector2 m_clipMin; //!< The minimum point of the bounding area required clipping.
123 Vector2 m_clipMax; //!< The maximum point of the bounding area required clipping.
124};
125} // namespace ns3
void ClipEndTop(Line &line) const
Clip end top function.
void ClipEndBottom(Line &line) const
Clip end bottom function.
Vector2 m_clipMin
The minimum point of the bounding area required clipping.
void ClipStartLeft(Line &line) const
Clip start left function.
void ClipStartTop(Line &line) const
Clip start top function.
void ClipEndLeft(Line &line) const
Clip end left function.
void ClipStartBottom(Line &line) const
Clip start bottom function.
void ClipStartRight(Line &line) const
Clip start right function.
FastClipping(Vector2 clipMin, Vector2 clipMax)
Constructor.
Vector2 m_clipMax
The maximum point of the bounding area required clipping.
bool ClipLine(Line &line)
Clip line function.
void ClipEndRight(Line &line) const
Clip end right function.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
The line struct.
Vector2 start
The start point of the line.
Vector2 end
The end point of the line.
The Vector 2 struct.
double x
X coordinate.
double y
Y coordinate.