Debug("Successfully saved %u objects to \"%s\"", ObjectCount(), filename.c_str());
}
+#ifndef QUADTREE_DISABLED
+
+void Document::GenBaseQuadtree()
+{
+ m_quadtree.nodes.push_back(QuadTreeNode{QUADTREE_EMPTY, QUADTREE_EMPTY, QUADTREE_EMPTY, QUADTREE_EMPTY, QUADTREE_EMPTY, QTC_UNKNOWN, 0, ObjectCount()});
+ m_quadtree.root_id = 0;
+}
+
+#endif
+
void Document::Load(const string & filename)
{
m_objects.bounds.clear();
#define _DOCUMENT_H
#include "ipdf.h"
+#include "quadtree.h"
namespace IPDF
{
void Add(ObjectType type, const Rect & bounds, unsigned data_index = 0);
unsigned AddBezierData(const Bezier & bezier);
+#ifndef QUADTREE_DISABLED
+ inline const QuadTree& GetQuadTree() const { return m_quadtree; }
+#endif
+
private:
friend class View;
Objects m_objects;
+#ifndef QUADTREE_DISABLED
+ QuadTree m_quadtree;
+ void GenBaseQuadtree();
+#endif
unsigned m_count;
--- /dev/null
+#ifndef _QUADTREE_H
+#define _QUADTREE_H
+
+
+#ifndef QUADTREE_REMOVED
+
+
+#include "common.h"
+
+namespace IPDF
+{
+
+ typedef int QuadTreeIndex;
+ static const QuadTreeIndex QUADTREE_EMPTY = -1;
+
+ enum QuadTreeNodeChildren
+ {
+ QTC_UNKNOWN,
+ QTC_TOP_LEFT,
+ QTC_TOP_RIGHT,
+ QTC_BOTTOM_LEFT,
+ QTC_BOTTOM_RIGHT
+ };
+
+ // Represents a single node in a quadtree.
+ struct QuadTreeNode
+ {
+ // Indices of children nodes, QUADTREE_EMPTY if no such child.
+ QuadTreeIndex top_left;
+ QuadTreeIndex top_right;
+ QuadTreeIndex bottom_left;
+ QuadTreeIndex bottom_right;
+ // Parent node id. QUADTREE_EMPTY if root.
+ QuadTreeIndex parent;
+ // Which child am I?
+ QuadTreeNodeChildren child_type;
+ // First object in the node.
+ unsigned object_begin;
+ // Last object in the node.
+ unsigned object_end;
+ };
+
+ struct QuadTree
+ {
+ QuadTreeIndex root_id;
+ std::vector<QuadTreeNode> nodes;
+ };
+}
+
+#else
+#define QUADTREE_DISABLED
+#endif
+
+#endif
// 2. Implement class inheriting from ObjectRenderer using that type in objectrenderer.h and objectrenderer.cpp
// 3. Add it here
// 4. Profit
+
+
+#ifndef QUADTREE_DISABLED
+ m_quadtree_max_depth = 1;
+ m_current_quadtree_node = document.GetQuadTree().root_id;
+#endif
}
/**
// Trust me it will be easier to generalise things this way. Even though there are pointers.
std::vector<ObjectRenderer*> m_object_renderers;
uint8_t * m_cpu_rendering_pixels; // pixels to be used for CPU rendering
+
+#ifndef QUADTREE_DISABLED
+ QuadTreeIndex m_current_quadtree_node; // The highest node we will traverse.
+ int m_quadtree_max_depth; // The maximum quadtree depth.
+
+#endif
};
}