Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 576885c

Browse files
committed
Fix formatting.
svn path=/trunk/matplotlib/; revision=6033
1 parent 4fb217b commit 576885c

1 file changed

Lines changed: 29 additions & 12 deletions

File tree

src/agg_py_path_iterator.h

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class PathIterator
1919

2020
public:
2121
PathIterator(const Py::Object& path_obj) :
22-
m_vertices(NULL), m_codes(NULL), m_iterator(0)
22+
m_vertices(NULL), m_codes(NULL), m_iterator(0), m_should_simplify(false)
2323
{
2424
Py::Object vertices_obj = path_obj.getAttr("vertices");
2525
Py::Object codes_obj = path_obj.getAttr("codes");
@@ -28,16 +28,19 @@ class PathIterator
2828
m_vertices = (PyArrayObject*)PyArray_FromObject
2929
(vertices_obj.ptr(), PyArray_DOUBLE, 2, 2);
3030
if (!m_vertices ||
31-
PyArray_NDIM(m_vertices) != 2 ||
3231
PyArray_DIM(m_vertices, 1) != 2)
32+
{
3333
throw Py::ValueError("Invalid vertices array.");
34+
}
3435

3536
if (codes_obj.ptr() != Py_None)
3637
{
3738
m_codes = (PyArrayObject*)PyArray_FromObject
3839
(codes_obj.ptr(), PyArray_UINT8, 1, 1);
3940
if (!m_codes)
4041
throw Py::ValueError("Invalid codes array.");
42+
if (PyArray_DIM(m_codes, 0) != PyArray_DIM(m_vertices, 1))
43+
throw Py::ValueError("Codes array is wrong length");
4144
}
4245

4346
m_should_simplify = should_simplify_obj.isTrue();
@@ -79,11 +82,16 @@ class PathIterator
7982
if (m_iterator >= m_total_vertices) return agg::path_cmd_stop;
8083
unsigned code = vertex_with_code(m_iterator++, x, y);
8184

82-
if (MPL_notisfinite64(*x) || MPL_notisfinite64(*y)) {
83-
do {
84-
if (m_iterator < m_total_vertices) {
85+
if (MPL_notisfinite64(*x) || MPL_notisfinite64(*y))
86+
{
87+
do
88+
{
89+
if (m_iterator < m_total_vertices)
90+
{
8591
vertex(m_iterator++, x, y);
86-
} else {
92+
}
93+
else
94+
{
8795
return agg::path_cmd_stop;
8896
}
8997
} while (MPL_notisfinite64(*x) || MPL_notisfinite64(*y));
@@ -207,7 +215,8 @@ class SimplifyPath
207215
// If the queue is now empty, and the path was fully consumed
208216
// in the last call to the main loop, return agg::path_cmd_stop to
209217
// signal that there are no more points to emit.
210-
if (m_done) {
218+
if (m_done)
219+
{
211220
#if DEBUG_SIMPLIFY
212221
printf(".\n");
213222
#endif
@@ -376,21 +385,26 @@ class SimplifyPath
376385
//direction we are drawing in, move back to we start drawing from
377386
//back there.
378387
if (m_haveMin)
379-
m_queue[m_queue_write++].set(agg::path_cmd_line_to, m_minX, m_minY);
388+
{
389+
m_queue[m_queue_write++].set(agg::path_cmd_line_to, m_minX, m_minY);
390+
}
380391
m_queue[m_queue_write++].set(agg::path_cmd_line_to, m_maxX, m_maxY);
381392

382393
//if we clipped some segments between this line and the next line
383394
//we are starting, we also need to move to the last point.
384-
if (m_clipped)
385-
m_queue[m_queue_write++].set(agg::path_cmd_move_to, m_lastx, m_lasty);
395+
if (m_clipped) {
396+
m_queue[m_queue_write++].set(agg::path_cmd_move_to, m_lastx, m_lasty);
397+
}
386398
else if (!m_lastMax)
399+
{
387400
//if the last line was not the longest line, then move back to
388401
//the end point of the last line in the sequence. Only do this
389402
//if not clipped, since in that case lastx,lasty is not part of
390403
//the line just drawn.
391404

392405
//Would be move_to if not for the artifacts
393-
m_queue[m_queue_write++].set(agg::path_cmd_line_to, m_lastx, m_lasty);
406+
m_queue[m_queue_write++].set(agg::path_cmd_line_to, m_lastx, m_lasty);
407+
}
394408

395409
//now reset all the variables to get ready for the next line
396410
m_origdx = *x - m_lastx;
@@ -421,7 +435,9 @@ class SimplifyPath
421435
if (m_origdNorm2 != 0)
422436
{
423437
if (m_haveMin)
438+
{
424439
m_queue[m_queue_write++].set(agg::path_cmd_line_to, m_minX, m_minY);
440+
}
425441
m_queue[m_queue_write++].set(agg::path_cmd_line_to, m_maxX, m_maxY);
426442
}
427443
m_done = true;
@@ -458,7 +474,8 @@ class SimplifyPath
458474
struct item
459475
{
460476
item() {}
461-
inline void set(const unsigned cmd_, const double& x_, const double& y_) {
477+
inline void set(const unsigned cmd_, const double& x_, const double& y_)
478+
{
462479
cmd = cmd_;
463480
x = x_;
464481
y = y_;

0 commit comments

Comments
 (0)