File: BoundingBox.sip

package info (click to toggle)
tulip 4.8.0dfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 179,264 kB
  • ctags: 64,517
  • sloc: cpp: 600,444; ansic: 36,311; makefile: 22,136; python: 1,304; sh: 946; yacc: 522; xml: 337; pascal: 157; php: 66; lex: 55
file content (222 lines) | stat: -rw-r--r-- 5,830 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
/**
 *
 * This file is part of Tulip (www.tulip-software.org)
 *
 * Authors: David Auber and the Tulip development Team
 * from LaBRI, University of Bordeaux 1 and Inria Bordeaux - Sud Ouest
 *
 * Tulip is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation, either version 3
 * of the License, or (at your option) any later version.
 *
 * Tulip is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 *
 */

// +-------------------------------------------------------------------------+
// | Tulip Python Bindings                                                   |
// | inspired from bindings by the Booggie project development team          |
// | (http://booggie.org/)                                                   |
// +-------------------------------------------------------------------------+

namespace tlp {

struct BoundingBox {
%TypeHeaderCode
#include <tulip/BoundingBox.h>
%End

%Docstring
This class represents the 3D bounding box of an object.
It is defined by two 3d points, the first one being the lowest point (bottom-left corner), 
the second being the highest (top-right corner).

A bounding box can be instantiated and manipulated the following ways::

	# Initialize a non-valid bounding box.
	# The minimum is (1, 1, 1) and the maximum is (-1, -1, -1).
	bb = tlp.BoundingBox()
	
	# Initialize a bounding box by specifying the lowest and highest point.
	# The validity of the bounding box is checked in debug mode (an assertion is raised if it is not valid). 
	bb2 = tlp.BoundingBox(tlp.Vec3f(0,0,0), tlp.Vec3f(10,10,10))
	
	# Reading / writing the bounding box components can be done through the [] operator
	min = bb2[0]
	max = bb2[1]
%End

  BoundingBox();
      
  BoundingBox(const tlp::Vec3f& min, const tlp::Vec3f& max);
      
  tlp::Vec3f center() const;
%Docstring
tlp.BoundingBox.center()

Returns the geometrical center of the bounding box.

:rtype: :class:`tlp.Vec3f` 
%End

  float width() const;
%Docstring
tlp.BoundingBox.width()

Returns the width of the bounding box.

:rtype: float
%End	  
	  
  float height() const;
%Docstring
tlp.BoundingBox.height()

Returns the height of the bounding box.

:rtype: float
%End

  float depth() const;
%Docstring
tlp.BoundingBox.depth()

Returns the depth of the bounding box.

:rtype: float
%End

  void expand(const tlp::Vec3f& point);
%Docstring
tlp.BoundingBox.expand(point)

Expands the bounding box to one containing the vector passed as parameter.
If the vector is inside the bounding box, it remains unchanged.

:param point: A point in the 3D space we want the bounding box to encompass.
:type point: :class:`tlp.Vec3f`
%End


  void translate(const tlp::Vec3f& displacement);
%Docstring
tlp.BoundingBox.translate(displacement)

Translates the bounding box by the displacement given by the vector passed as parameter.

:param displacement: The displacement vector in 3D space to translate this bounding box by.
:type displacement: :class:`tlp.Vec3f`
%End

  void scale(const tlp::Vec3f& factor);
%Docstring
tlp.BoundingBox.scale(factor)

.. versionadded:: 4.4

Scales the bounding box, i.e. multiplying its components by a factor vector.

:param factor: The factor vector to scale this bounding box by.
:type factor: :class:`tlp.Vec3f`
%End

  bool isValid() const;
%Docstring
tlp.BoundingBox.isValid()

Checks whether the bounding box's lowest point is less than it's highest point.
"Less Than" means axis-by-axis comparison, i.e. x1 < x2 && y1 < y2 && z1 < z2.

:rtype: boolean
%End      
      
  bool contains(const tlp::Vec3f& coord) const;
%Docstring
tlp.BoundingBox.contains(point)

.. versionadded:: 3.7

Checks if the given point is inside the current bounding box.
If the bounding box is invalid the result is always :const:`False`.

:param point: a point in the 3D space.
:type point: :class:`tlp.Vec3f`
:rtype: boolean
%End

  bool intersect(const tlp::BoundingBox &boundingBox) const;
%Docstring
tlp.BoundingBox.intersect(boundingBox)

.. versionadded:: 3.7

Checks if the given bounding box intersects the current one.
If one of the bounding boxes is invalid returns :const:`False`.

:param boundingBox: the bounding box on which to check intersection
:type boundingBox: :class:`tlp.BoundingBox`
:rtype: boolean
%End

  bool intersect(const tlp::Vec3f &segStart, const tlp::Vec3f &segEnd) const;
%Docstring
tlp.BoundingBox.intersect(segStart, segEnd)

.. versionadded:: 3.7

Checks if the bounding box intersects the given line segment.
If the bounding box is invalid the result is always :const:`False`.

:param segStart: the start point of the line segment on which to check intersection
:type segStart: :class:`tlp.Vec3f`
:param segEnd: the end point of the line segment on which to check intersection
:type segEnd: :class:`tlp.Vec3f`
:rtype: boolean
%End

  tlp::Vec3f& operator[](const unsigned int i) const /NoCopy/;
%MethodCode
  if (a0 < 2) {
    sipRes = &(*sipCpp)[a0];
  } else {
    sipIsErr = -1;
    PyErr_SetNone(PyExc_IndexError);
  }
%End

  void __setitem__(int i, const tlp::Vec3f &value);
%MethodCode
  if (a0 < 2) {
		(*sipCpp)[a0] = *a1;
  } else {
    sipIsErr = -1;
    PyErr_SetNone(PyExc_IndexError);
  }
%End

	SIP_PYOBJECT __repr__() const;
%MethodCode
  std::ostringstream oss;
  oss << *sipCpp;
  std::string s = oss.str();
  for (size_t i = 0 ; i < s.length() ; ++i) {
    if (s[i] == '(') {
      s[i] = '[';
    } else if (s[i] == ')') {
      s[i] = ']';
    }
  }
#if PY_MAJOR_VERSION >= 3
  sipRes = PyUnicode_FromString(s.c_str());
#else
  sipRes = PyString_FromString(s.c_str());
#endif
%End

};
  
};