1#! /usr/bin/env python
2# -*- coding: utf-8 -*-
3# ===========================================================================
4#  Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
5#  Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
6#  Copyright (c) 2009-2012 Mateusz Loskot (mateusz@loskot.net), London, UK
7#
8#  Use, modification and distribution is subject to the Boost Software License,
9#  Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
10#  http://www.boost.org/LICENSE_1_0.txt)
11# ============================================================================
12
13import os, sys
14
15script_dir = os.path.dirname(__file__)
16os.chdir(os.path.abspath(script_dir))
17print("Boost.Geometry is making .qbk files in %s" % os.getcwd())
18
19if 'DOXYGEN' in os.environ:
20    doxygen_cmd = os.environ['DOXYGEN']
21else:
22    doxygen_cmd = 'doxygen'
23
24if 'DOXYGEN_XML2QBK' in os.environ:
25    doxygen_xml2qbk_cmd = os.environ['DOXYGEN_XML2QBK']
26else:
27    doxygen_xml2qbk_cmd = 'doxygen_xml2qbk'
28
29cmd = doxygen_xml2qbk_cmd
30cmd = cmd + " --xml doxy/doxygen_output/xml/%s.xml"
31cmd = cmd + " --start_include boost/geometry/"
32cmd = cmd + " --convenience_header_path ../../../boost/geometry/"
33cmd = cmd + " --convenience_headers geometry.hpp,geometries/geometries.hpp"
34cmd = cmd + " --skip_namespace boost::geometry::"
35cmd = cmd + " --copyright src/copyright_block.qbk"
36cmd = cmd + " --output_member_variables false"
37cmd = cmd + " > generated/%s.qbk"
38
39def run_command(command):
40    if os.system(command) != 0:
41        raise Exception("Error running %s" % command)
42
43def remove_all_files(dir):
44    if os.path.exists(dir):
45        for f in os.listdir(dir):
46            os.remove(dir+f)
47
48def call_doxygen():
49    os.chdir("doxy")
50    remove_all_files("doxygen_output/xml/")
51    run_command(doxygen_cmd)
52    os.chdir("..")
53
54def group_to_quickbook(section):
55    run_command(cmd % ("group__" + section.replace("_", "__"), section))
56
57def model_to_quickbook(section):
58    run_command(cmd % ("classboost_1_1geometry_1_1model_1_1" + section.replace("_", "__"), section))
59
60def model_to_quickbook2(classname, section):
61    run_command(cmd % ("classboost_1_1geometry_1_1model_1_1" + classname, section))
62
63def struct_to_quickbook(section):
64    run_command(cmd % ("structboost_1_1geometry_1_1" + section.replace("_", "__"), section))
65
66def class_to_quickbook(section):
67    run_command(cmd % ("classboost_1_1geometry_1_1" + section.replace("_", "__"), section))
68
69def class_to_quickbook2(classname, section):
70    run_command(cmd % ("classboost_1_1geometry_1_1" + classname, section))
71
72def strategy_to_quickbook(section):
73    p = section.find("::")
74    ns = section[:p]
75    strategy = section[p+2:]
76    run_command(cmd % ("classboost_1_1geometry_1_1strategy_1_1"
77        + ns.replace("_", "__") + "_1_1" + strategy.replace("_", "__"),
78        ns + "_" + strategy))
79
80def cs_to_quickbook(section):
81    run_command(cmd % ("structboost_1_1geometry_1_1cs_1_1" + section.replace("_", "__"), section))
82
83
84call_doxygen()
85
86algorithms = ["append", "assign", "make", "clear"
87    , "area", "buffer", "centroid", "convert", "correct", "covered_by"
88    , "convex_hull", "crosses", "difference", "disjoint", "distance"
89    , "envelope", "equals", "expand", "for_each", "is_empty"
90    , "is_simple", "is_valid", "intersection", "intersects", "length"
91    , "num_geometries", "num_interior_rings", "num_points"
92    , "num_segments", "overlaps", "perimeter", "relate", "relation"
93    , "reverse", "simplify", "sym_difference", "touches"
94    , "transform", "union", "unique", "within"]
95
96access_functions = ["get", "set", "exterior_ring", "interior_rings"
97    , "num_points", "num_interior_rings", "num_geometries"]
98
99coordinate_systems = ["cartesian", "geographic", "polar", "spherical", "spherical_equatorial"]
100
101core = ["closure", "coordinate_system", "coordinate_type", "cs_tag"
102    , "dimension", "exception", "interior_type"
103    , "degree", "radian"
104    , "is_radian", "point_order"
105    , "point_type", "ring_type", "tag", "tag_cast" ]
106
107exceptions = ["exception", "centroid_exception"];
108
109iterators = ["circular_iterator", "closing_iterator"
110    , "ever_circling_iterator"]
111
112models = ["point", "linestring", "box"
113    , "polygon", "segment", "ring"
114    , "multi_linestring", "multi_point", "multi_polygon", "referring_segment"]
115
116
117strategies = ["distance::pythagoras", "distance::pythagoras_box_box"
118    , "distance::pythagoras_point_box", "distance::haversine"
119    , "distance::cross_track", "distance::cross_track_point_box"
120    , "distance::projected_point"
121    , "within::winding", "within::franklin", "within::crossings_multiply"
122    , "area::surveyor", "area::huiller"
123    , "buffer::point_circle", "buffer::point_square"
124    , "buffer::join_round", "buffer::join_miter"
125    , "buffer::end_round", "buffer::end_flat"
126    , "buffer::distance_symmetric", "buffer::distance_asymmetric"
127    , "buffer::side_straight"
128    , "centroid::bashein_detmer", "centroid::average"
129    , "convex_hull::graham_andrew"
130    , "simplify::douglas_peucker"
131    , "side::side_by_triangle", "side::side_by_cross_track", "side::spherical_side_formula"
132    , "transform::inverse_transformer", "transform::map_transformer"
133    , "transform::rotate_transformer", "transform::scale_transformer"
134    , "transform::translate_transformer", "transform::ublas_transformer"
135    ]
136
137views = ["box_view", "segment_view"
138    , "closeable_view", "reversible_view", "identity_view"]
139
140
141
142for i in algorithms:
143    group_to_quickbook(i)
144
145for i in access_functions:
146    group_to_quickbook(i)
147
148for i in coordinate_systems:
149    cs_to_quickbook(i)
150
151for i in core:
152    struct_to_quickbook(i)
153
154for i in exceptions:
155    class_to_quickbook(i)
156
157for i in iterators:
158    struct_to_quickbook(i)
159
160for i in models:
161    model_to_quickbook(i)
162
163for i in strategies:
164    strategy_to_quickbook(i)
165
166for i in views:
167    struct_to_quickbook(i)
168
169
170model_to_quickbook2("d2_1_1point__xy", "point_xy")
171
172group_to_quickbook("arithmetic")
173group_to_quickbook("enum")
174group_to_quickbook("register")
175group_to_quickbook("svg")
176class_to_quickbook("svg_mapper")
177group_to_quickbook("wkt")
178
179class_to_quickbook2("de9im_1_1matrix", "de9im_matrix")
180class_to_quickbook2("de9im_1_1mask", "de9im_mask")
181class_to_quickbook2("de9im_1_1static__mask", "de9im_static_mask")
182
183os.chdir("index")
184execfile("make_qbk.py")
185os.chdir("..")
186
187# Use either bjam or b2 or ../../../b2 (the last should be done on Release branch)
188run_command("b2")
189