-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRNode.cpp
More file actions
41 lines (31 loc) · 1.01 KB
/
Copy pathRNode.cpp
File metadata and controls
41 lines (31 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "RNode.h"
// Definición del constructor por defecto
Nodo::Nodo() {
// Implementación del constructor (si es que necesitas hacer algo aquí)
}
// Definición del constructor con rectángulos
Nodo::Nodo(const std::vector<Rectangulo>& rects) {
for (const Rectangulo& r : rects) {
entradas.push_back(Entrada(r));
}
}
// Definición del constructor con nodos
Nodo::Nodo(const std::vector<Nodo*>& childNodes) {
for (Nodo* child : childNodes) {
entradas.push_back(Entrada(child->calcularMBR(), child));
}
}
Rectangulo Nodo::calcularMBR() {
if (entradas.empty()) {
return Rectangulo(); // Un rectángulo por defecto si no hay entradas.
}
Rectangulo mbr = entradas[0].mbr;
for (size_t i = 1; i < entradas.size(); i++) {
const Rectangulo& rect = entradas[i].mbr;
mbr.x1 = std::min(mbr.x1, rect.x1);
mbr.y1 = std::min(mbr.y1, rect.y1);
mbr.x2 = std::max(mbr.x2, rect.x2);
mbr.y2 = std::max(mbr.y2, rect.y2);
}
return mbr;
}