Skip to content

feat(core): agregar visualización de R-tree/R*-tree en tikzgeom_algor…#97

Open
lrleon wants to merge 1 commit into
masterfrom
feat/tikz-galleries
Open

feat(core): agregar visualización de R-tree/R*-tree en tikzgeom_algor…#97
lrleon wants to merge 1 commit into
masterfrom
feat/tikz-galleries

Conversation

@lrleon

@lrleon lrleon commented Jul 20, 2026

Copy link
Copy Markdown
Owner

…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

    • Añadido un ejemplo de galería TikZ con 20 visualizaciones de algoritmos de geometría computacional y estadísticas.
    • Ampliado el ejemplo de estructuras de árbol para visualizar QuadTree, RTree y RStarTree, incluyendo consultas y métricas.
    • Incorporada una herramienta pública para inspeccionar la estructura interna de los árboles R mediante instantáneas de depuración.
  • Pruebas

    • Añadidas comprobaciones estructurales para árboles R y RStarTree.
    • Añadidas pruebas para las visualizaciones de consultas y árboles espaciales en TikZ.

…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*.
Copilot AI review requested due to automatic review settings July 20, 2026 22:00
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Se añade introspección estructural a RTree, pruebas para RTree y RStarTree, visualizaciones TikZ de árboles espaciales y una galería de 20 ejemplos de geometría computacional. También se reestructura el formato de los helpers de visualización sin cambios observables de lógica.

Changes

Visualización e introspección espacial

Layer / File(s) Summary
Contrato y validación de snapshots
tpl_r_tree.H, Tests/r_tree_test.cc, Tests/r_star_tree_test.cc
RTree incorpora DebugNode, DebugSnapshot y debug_snapshot(). Las pruebas validan estructuras vacías, raíces hoja, profundidades, cajas, índices y conteo de entradas; RStarTree valida las mismas invariantes estructurales.
Helpers y pruebas de visualización TikZ
tikzgeom_algorithms.H, Tests/tikzgeom_algorithms_test.cc
Se reformatea la cabecera de helpers TikZ manteniendo sus contratos y lógica, y se añaden pruebas para visualizar y consultar RTree y RStarTree.
Ejemplo de estructuras arbóreas
Examples/tikz_tree_structures_example.cc
El ejemplo genera escenas de QuadTree, RTree y RStarTree, con regiones, puntos, nodos, impactos y estadísticas en el documento TikZ.
Galería de geometría computacional
Examples/tikz_computational_geometry_gallery_example.cc
Se añade un programa que genera 20 paneles TikZ con visualizaciones de algoritmos geométricos, captions estadísticos y un wrapper LaTeX compilable con pdflatex.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

  • lrleon/Aleph-w#93: Amplía la base de R-tree/R*-tree sobre la que se añade debug_snapshot() y su visualización.

Suggested reviewers: copilot

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed El título resume correctamente la incorporación de visualización de R-tree/R*-tree en TikZ.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Header Docstring Coverage ✅ Passed Las 7 declaraciones públicas nuevas/modificadas en headers de biblioteca están documentadas; cobertura 100%.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/tikz-galleries

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Baseline was recorded on Intel(R) Core(TM) Ultra 7 265KF but this run used AMD EPYC 9V74 80-Core Processor. Absolute times are not comparable across CPUs, so the gate is advisory until the baseline is regenerated on this hardware (run the perf-update workflow on master).

Cellular-automata perf gate

baseline CPU Intel(R) Core(TM) Ultra 7 265KF · compiler gcc 13.3.0 · recorded 2026-06-08T18:09:09Z

Benchmark Baseline (ms) Current (ms) Δ Threshold Status
gol_1024 3426.47 4151.27 +21.2% ±8% ℹ️ advisory
gray_scott_512 7328.14 16983.39 +131.8% ±8% ℹ️ advisory
hashlife_breeder 2057.25 2759.06 +34.1% ±12% ℹ️ advisory
multi_field_lv_512 4285.60 5186.24 +21.0% ±10% ℹ️ advisory
parallel_gol_2048 998.97 8299.51 +730.8% ±20% ℹ️ advisory
wolfram_30_1d 4063.23 12684.85 +212.2% ±8% ℹ️ advisory

Lower wall time is better; Δ is current vs. baseline.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 RTree con DebugNode, DebugSnapshot y el método debug_snapshot() para capturar la estructura completa del árbol (sin Payload).
  • Se añaden helpers en tikzgeom_algorithms.H para 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.

Comment thread tikzgeom_algorithms.H
Comment on lines +2071 to +2072
if (!not t.active)
continue;

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 .first y .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

📥 Commits

Reviewing files that changed from the base of the PR and between 334bed0 and 71ac438.

📒 Files selected for processing (7)
  • Examples/tikz_computational_geometry_gallery_example.cc
  • Examples/tikz_tree_structures_example.cc
  • Tests/r_star_tree_test.cc
  • Tests/r_tree_test.cc
  • Tests/tikzgeom_algorithms_test.cc
  • tikzgeom_algorithms.H
  • tpl_r_tree.H

Comment thread tikzgeom_algorithms.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),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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*\(' -C3

Repository: 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.

Comment thread tikzgeom_algorithms.H
Comment on lines +2071 to +2072
if (!not t.active)
continue;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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.

Suggested change
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants