feat(core): agregar visualización de R-tree/R*-tree en tikzgeom_algor…#97
feat(core): agregar visualización de R-tree/R*-tree en tikzgeom_algor…#97lrleon wants to merge 1 commit into
Conversation
…ithms Se añade soporte para visualizar la estructura jerárquica de árboles R y R* (con sus MBR y cajas de entrada) en un plano TikZ, incluyendo consultas de intersección con rectángulos. Se implementan las funciones put_rtree_result, visualize_rtree y visualize_rtree_query, y se extiende la clase RTree (tpl_r_tree.H) con DebugNode, DebugSnapshot y el método debug_snapshot(). Se agregan pruebas unitarias y ejemplos completos de galería que incluyen quadtree y árboles R/R*.
WalkthroughSe añade introspección estructural a ChangesVisualización e introspección espacial
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Cellular-automata perf gatebaseline CPU
Lower wall time is better; Δ is current vs. baseline. |
There was a problem hiding this comment.
Pull request overview
Este PR amplía el módulo de visualización TikZ de Aleph-w para incluir R-tree/R*-tree, incorporando una forma pública de inspeccionar su estructura interna mediante “snapshots” de depuración, y añadiendo pruebas y ejemplos tipo galería para algoritmos/estructuras de geometría computacional.
Changes:
- Se extiende
RTreeconDebugNode,DebugSnapshoty el métododebug_snapshot()para capturar la estructura completa del árbol (sinPayload). - Se añaden helpers en
tikzgeom_algorithms.Hpara renderizar R-tree/R*-tree (estructura + cajas de entrada) y para visualizar consultas por intersección con rectángulos. - Se agregan pruebas unitarias y ejemplos de galería (incluyendo estructuras de árbol y una galería extensa de algoritmos).
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tpl_r_tree.H | Añade estructuras de depuración (DebugNode/DebugSnapshot) y debug_snapshot() para exponer la jerarquía del R-tree/R*-tree. |
| tikzgeom_algorithms.H | Integra renderizado TikZ para snapshots de R-tree/R*-tree y visualización de queries; además reorganiza/expande helpers existentes. |
| Tests/tikzgeom_algorithms_test.cc | Nuevas pruebas de visualización TikZ para RTree y RStarTree (con y sin query). |
| Tests/r_tree_test.cc | Pruebas estructurales para invariantes del DebugSnapshot en RTree. |
| Tests/r_star_tree_test.cc | Pruebas estructurales para invariantes del DebugSnapshot en RStarTree. |
| Examples/tikz_tree_structures_example.cc | Ejemplo extendido: quadtree + R-tree/R*-tree (comparación visual y query). |
| Examples/tikz_computational_geometry_gallery_example.cc | Nuevo ejemplo “galería” con múltiples paneles de algoritmos geométricos renderizados en TikZ. |
| if (!not t.active) | ||
| continue; |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
Examples/tikz_computational_geometry_gallery_example.cc (1)
509-514: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value[Should fix] Usa structured bindings para la descomposición de pares.
Las guías de estilo para C++20 indican que se deben emplear structured bindings al descomponer tuplas o pares, lo que simplifica la lectura del código y elimina la necesidad de acceder repetitivamente a
.firsty.second.♻️ Refactor propuesto
- const auto pair = visualize_closest_pair(plane, pts); + const auto [p1, p2] = visualize_closest_pair(plane, pts); add_caption(plane, Point(-18, 20), "MEC r=" + std::to_string(geom_number_to_double(circle.radius())) + " + closest pair d^2=" + - std::to_string(geom_number_to_double(pair.first.distance_squared_to(pair.second)))); + std::to_string(geom_number_to_double(p1.distance_squared_to(p2))));🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@Examples/tikz_computational_geometry_gallery_example.cc` around lines 509 - 514, Replace the pair variable and its .first/.second accesses in the surrounding visualization block with a C++20 structured binding from visualize_closest_pair(plane, pts), then use the bound elements when calculating distance_squared_to.Sources: Coding guidelines, Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tikzgeom_algorithms.H`:
- Around line 2071-2072: Corrige la condición del filtrado en el bucle de
trapecios para usar `not t.active` directamente, de modo que los trapecios
inactivos se omitan y solo se procesen los activos. Elimina la mezcla de `!` y
`not`, manteniendo el comportamiento coherente con la condición equivalente
cercana.
- Line 1900: Actualiza la inicialización de simplified_style y las demás
llamadas al patrón de tikz_wire_style para no pasar 1.2 como grosor, ya que se
interpreta como dashed=true. Elimina ese argumento si no se necesita un estilo
más grueso; si se requiere controlar el grosor, utiliza o añade una API
explícita para ello, manteniendo separados color, dashed y with_arrow.
---
Nitpick comments:
In `@Examples/tikz_computational_geometry_gallery_example.cc`:
- Around line 509-514: Replace the pair variable and its .first/.second accesses
in the surrounding visualization block with a C++20 structured binding from
visualize_closest_pair(plane, pts), then use the bound elements when calculating
distance_squared_to.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 4368983a-9fb9-42fb-9833-bf779883b0cd
📒 Files selected for processing (7)
Examples/tikz_computational_geometry_gallery_example.ccExamples/tikz_tree_structures_example.ccTests/r_star_tree_test.ccTests/r_tree_test.ccTests/tikzgeom_algorithms_test.cctikzgeom_algorithms.Htpl_r_tree.H
| inline void put_simplification_result( | ||
| Tikz_Plane &plane, const Polygon &original, const Polygon &simplified, | ||
| const Tikz_Style &original_style = tikz_wire_style("gray!50"), | ||
| const Tikz_Style &simplified_style = tikz_wire_style("blue!80", 1.2), |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# ¿Existe alguna sobrecarga de tikz_wire_style con ancho de línea?
rg -nP 'Tikz_Style\s+tikz_wire_style\s*\(' -C3Repository: lrleon/Aleph-w
Length of output: 152
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Show the surrounding code at the cited location.
sed -n '1888,1910p' tikzgeom_algorithms.H
# Search more broadly for the helper and related declarations/usages.
rg -n --hidden --glob '!**/build*' --glob '!**/cmake-build-*' 'tikz_wire_style|wire_style|dashed' .
# If found, show nearby lines for any declaration/definition matches.Repository: lrleon/Aleph-w
Length of output: 21939
1.2 se convierte en bool dashed, no en un grosor.
La firma de tikz_wire_style solo acepta color, dashed y with_arrow, así que ese literal acaba activando dashed = true. Si aquí queréis un estilo más grueso, hace falta otra API; si no, conviene quitar el argumento. El mismo patrón aparece en varias llamadas más.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@tikzgeom_algorithms.H` at line 1900, Actualiza la inicialización de
simplified_style y las demás llamadas al patrón de tikz_wire_style para no pasar
1.2 como grosor, ya que se interpreta como dashed=true. Elimina ese argumento si
no se necesita un estilo más grueso; si se requiere controlar el grosor, utiliza
o añade una API explícita para ello, manteniendo separados color, dashed y
with_arrow.
| if (!not t.active) | ||
| continue; |
There was a problem hiding this comment.
🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win
La condición !not t.active invierte el filtrado y dibuja los trapecios inactivos.
!not t.active equivale a t.active, por lo que el continue salta los trapecios activos y solo procesa los inactivos, justo lo contrario de la intención (compárese con la línea 2155, que usa if (not t.active) continue;). Además, mezclar ! y not incumple la guía de estilo.
As per coding guidelines: "Use and, or, not for logical operations instead of &&, ||, !".
🐛 Corrección propuesta
- if (!not t.active)
+ if (not t.active)
continue;📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (!not t.active) | |
| continue; | |
| if (not t.active) | |
| continue; |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@tikzgeom_algorithms.H` around lines 2071 - 2072, Corrige la condición del
filtrado en el bucle de trapecios para usar `not t.active` directamente, de modo
que los trapecios inactivos se omitan y solo se procesen los activos. Elimina la
mezcla de `!` y `not`, manteniendo el comportamiento coherente con la condición
equivalente cercana.
Source: Coding guidelines
…ithms
Se añade soporte para visualizar la estructura jerárquica de árboles R y R* (con sus MBR y cajas de entrada) en un plano TikZ, incluyendo consultas de intersección con rectángulos. Se implementan las funciones put_rtree_result, visualize_rtree y visualize_rtree_query, y se extiende la clase RTree (tpl_r_tree.H) con DebugNode, DebugSnapshot y el método debug_snapshot(). Se agregan pruebas unitarias y ejemplos completos de galería que incluyen quadtree y árboles R/R*.
Summary by CodeRabbit
Nuevas funcionalidades
Pruebas