-
Notifications
You must be signed in to change notification settings - Fork 0
/
htgeom_types.h
166 lines (156 loc) · 3.99 KB
/
htgeom_types.h
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/* -----------------------------------------------------------------------------
* The Cyberiada Hierarchical Tree Geometry library implemention
*
* The the hierarchiceal tree geometry library: output procedures
*
* Copyright (C) 2024 Alexey Fedoseev <aleksey@fedoseev.net>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see https://www.gnu.org/licenses/
*
* ----------------------------------------------------------------------------- */
#ifndef __HIERARCHICAL_TREE_GEOMETRY_TYPES_H
#define __HIERARCHICAL_TREE_GEOMETRY_TYPES_H
#include <iostream>
#include "htgeom.h"
inline std::ostream& operator<<(std::ostream& os, const HTreePoint* point)
{
if (point) {
os << "(";
os << "x: " << point->x << ", y: " << point->y;
os << ")";
}
return os;
}
inline std::ostream& operator<<(std::ostream& os, const HTreeRect* rect)
{
if (rect) {
os << "(";
os << "x: " << rect->x << ", y: " << rect->y;
os << ", w: " << rect->width << ", h: " << rect->height;
os << ")";
}
return os;
}
inline std::ostream& operator<<(std::ostream& os, const HTreePolyline* polyline)
{
if (polyline) {
os << "Polyline [";
for (const HTreePolyline* pl = polyline; pl; pl = pl->next) {
os << &(pl->point);
if (pl->next) {
os << ", ";
}
}
os << "]";
}
return os;
}
inline std::ostream& operator<<(std::ostream& os, const HTreeNode* node)
{
if (node) {
os << "HTreeNode {";
os << "id: " << node->id;
if (node->point) {
os << ", point: " << node->point;
}
if (node->rect) {
os << ", rect: " << node->rect;
}
if (node->children) {
os << ", children: [";
for (HTreeNode* child = node->children; child; child = child->next) {
os << child;
if (child->next) {
os << ", ";
}
}
os << "]";
}
os << "}";
}
return os;
}
inline std::ostream& operator<<(std::ostream& os, const HTreeEdge* edge)
{
if (edge) {
os << "HTreeEdge {";
os << "id: " << edge->id << ", ";
os << "source: " << edge->source_id << ", ";
os << "target: " << edge->target_id;
if (edge->source_point) {
os << ", source point: " << edge->source_point;
}
if (edge->target_point) {
os << ", target point: " << edge->target_point;
}
if (edge->label_point) {
os << ", label point: " << edge->label_point;
} else if (edge->label_rect) {
os << ", label rect: " << edge->label_rect;
}
if (edge->polyline) {
os << ", polyline: " << edge->polyline;
}
os << "}";
}
return os;
}
inline std::ostream& operator<<(std::ostream& os, const HTree* tree)
{
if (tree) {
os << "HTree {";
os << "nodes: [";
for (HTreeNode* node = tree->nodes; node; node = node->next) {
os << node;
if (node->next) {
os << ", ";
}
}
os << "], edges: [";
for (HTreeEdge* edge = tree->edges; edge; edge = edge->next) {
os << edge;
if (edge->next) {
os << ", ";
}
}
os << "]}";
}
return os;
}
inline std::ostream& operator<<(std::ostream& os, const HTDocument* doc)
{
if (doc) {
os << "HTreeDocument {";
os << "nodes coord: " << doc->node_coord_format <<
", edge coord: " << doc->edge_coord_format <<
", edge polylines coord: " << doc->edge_pl_coord_format <<
", edge format: " << doc->edge_format;
os << ", trees: [";
for (HTree* tree = doc->trees; tree; tree = tree->next) {
os << tree;
if (tree->next) {
os << ", ";
}
}
os << "], bounding rect: ";
if (doc->bounding_rect) {
os << doc->bounding_rect;
} else {
os << "()";
}
os << "}";
}
return os;
}
#endif