X-Git-Url: https://git.ucc.asn.au/?p=ipdf%2Fcode.git;a=blobdiff_plain;f=src%2Fdocument.cpp;h=ead1b8e6bda4427a7f6171469df1da7833e1e51c;hp=c4ba2103748ef4007ffd09ef35708509d8336c75;hb=813591a7d8a7364003233939f52b0031f3a40d20;hpb=16f404f3edf222c467639f3e898eeb505075cde8 diff --git a/src/document.cpp b/src/document.cpp index c4ba210..ead1b8e 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -130,8 +130,27 @@ int Document::ClipObjectToQuadChild(int object_id, QuadTreeNodeChildren type) m_objects.data_indices.push_back(m_objects.data_indices[object_id]); return 1; } - case GROUP: - break; + case BEZIER: + { + Rect child_node_bounds = TransformFromQuadChild({0,0,1,1}, type); + Rect clip_bezier_bounds; + clip_bezier_bounds.x = (child_node_bounds.x - m_objects.bounds[object_id].x) / m_objects.bounds[object_id].w; + clip_bezier_bounds.y = (child_node_bounds.y - m_objects.bounds[object_id].y) / m_objects.bounds[object_id].h; + clip_bezier_bounds.w = child_node_bounds.w / m_objects.bounds[object_id].w; + clip_bezier_bounds.h = child_node_bounds.h / m_objects.bounds[object_id].h; + std::vector new_curves = m_objects.beziers[m_objects.data_indices[object_id]].ClipToRectangle(clip_bezier_bounds); + for (size_t i = 0; i < new_curves.size(); ++i) + { + Rect new_bounds = TransformToQuadChild(m_objects.bounds[object_id], type); + //new_bounds = TransformToQuadChild(new_bounds, type); + //Bezier new_curve_data = new_curves[i].ToRelative(new_bounds); + unsigned index = AddBezierData(new_curves[i]); + m_objects.bounds.push_back(new_bounds); + m_objects.types.push_back(BEZIER); + m_objects.data_indices.push_back(index); + } + return new_curves.size(); + } default: Debug("Adding %s -> %s", m_objects.bounds[object_id].Str().c_str(), TransformToQuadChild(m_objects.bounds[object_id], type).Str().c_str()); m_objects.bounds.push_back(TransformToQuadChild(m_objects.bounds[object_id], type));