git.ucc.asn.au
/
ipdf
/
code.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
| inline |
side by side
Make it work on Cabellera (again)
[ipdf/code.git]
/
src
/
document.cpp
diff --git
a/src/document.cpp
b/src/document.cpp
index
892f77a
..
a4d6be6
100644
(file)
--- a/
src/document.cpp
+++ b/
src/document.cpp
@@
-92,10
+92,11
@@
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;
- GenQuadNode(0, QTC_TOP_LEFT);
+ GenQuadChild(0, QTC_TOP_LEFT);
+ GenQuadParent(0, QTC_BOTTOM_RIGHT);
}
-QuadTreeIndex Document::GenQuad
Node
(QuadTreeIndex parent, QuadTreeNodeChildren type)
+QuadTreeIndex Document::GenQuad
Child
(QuadTreeIndex parent, QuadTreeNodeChildren type)
{
QuadTreeIndex new_index = m_quadtree.nodes.size();
m_quadtree.nodes.push_back(QuadTreeNode{QUADTREE_EMPTY, QUADTREE_EMPTY, QUADTREE_EMPTY, QUADTREE_EMPTY, parent, type, 0, 0});
@@
-132,6
+133,41
@@
QuadTreeIndex Document::GenQuadNode(QuadTreeIndex parent, QuadTreeNodeChildren t
return new_index;
}
+// Reparent a quadtree node, making it the "type" child of a new node.
+QuadTreeIndex Document::GenQuadParent(QuadTreeIndex child, QuadTreeNodeChildren type)
+{
+ QuadTreeIndex new_index = m_quadtree.nodes.size();
+ m_quadtree.nodes.push_back(QuadTreeNode{QUADTREE_EMPTY, QUADTREE_EMPTY, QUADTREE_EMPTY, QUADTREE_EMPTY, -1, QTC_UNKNOWN, 0, 0});
+
+ m_quadtree.nodes[new_index].object_begin = m_objects.bounds.size();
+ for (unsigned i = m_quadtree.nodes[child].object_begin; i < m_quadtree.nodes[child].object_end; ++i)
+ {
+ m_objects.bounds.push_back(TransformFromQuadChild(m_objects.bounds[i], type));
+ m_objects.types.push_back(m_objects.types[i]);
+ m_objects.data_indices.push_back(m_objects.data_indices[i]);
+ m_count++;
+ }
+ m_quadtree.nodes[new_index].object_end = m_objects.bounds.size();
+ switch (type)
+ {
+ case QTC_TOP_LEFT:
+ m_quadtree.nodes[new_index].top_left = child;
+ break;
+ case QTC_TOP_RIGHT:
+ m_quadtree.nodes[new_index].top_right = child;
+ break;
+ case QTC_BOTTOM_LEFT:
+ m_quadtree.nodes[new_index].bottom_left = child;
+ break;
+ case QTC_BOTTOM_RIGHT:
+ m_quadtree.nodes[new_index].bottom_right = child;
+ break;
+ default:
+ Fatal("Tried to add a QuadTree child of invalid type!");
+ }
+ return new_index;
+}
+
#endif
void Document::Load(const string & filename)
@@
-244,7
+280,7
@@
void Document::LoadSVG(const string & filename, const Rect & bounds)
input.close();
// Combine all SVG tags into one thing because lazy
- for (xml_node svg
: doc_xml.children
("svg"))
+ for (xml_node svg
= doc_xml.child("svg"); svg; svg = svg.next_sibling
("svg"))
{
Real width = svg.attribute("width").as_float() * bounds.w;
Real height = svg.attribute("width").as_float() * bounds.h;
@@
-253,7
+289,7
@@
void Document::LoadSVG(const string & filename, const Rect & bounds)
// Rectangles
Real coords[4];
const char * attrib_names[] = {"x", "y", "width", "height"};
- for (pugi::xml_node rect
: svg.children
("rect"))
+ for (pugi::xml_node rect
= svg.child("rect"); rect; rect = rect.next_sibling
("rect"))
{
for (size_t i = 0; i < 4; ++i)
coords[i] = rect.attribute(attrib_names[i]).as_float();
@@
-264,7
+300,7
@@
void Document::LoadSVG(const string & filename, const Rect & bounds)
}
// Circles
- for (pugi::xml_node circle
: svg.children
("circle"))
+ for (pugi::xml_node circle
= svg.child("circle"); circle; circle = circle.next_sibling
("circle"))
{
Real cx = circle.attribute("cx").as_float();
Real cy = circle.attribute("cy").as_float();
@@
-282,7
+318,7
@@
void Document::LoadSVG(const string & filename, const Rect & bounds)
}
// paths
- for (pugi::xml_node path
: svg.children
("path"))
+ for (pugi::xml_node path
= svg.child("path"); path; path = path.next_sibling
("path"))
{
string d = path.attribute("d").as_string();
UCC
git Repository :: git.ucc.asn.au