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