scriptup 2026.0.0 → 2026.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (489) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +43 -24
  3. data/ext/arc_curve.c +50 -0
  4. data/ext/attribute_dictionaries.c +49 -32
  5. data/ext/attribute_dictionary.c +54 -127
  6. data/ext/axes.c +79 -0
  7. data/ext/behavior.c +100 -9
  8. data/ext/bounding_box.c +195 -0
  9. data/ext/camera.c +178 -0
  10. data/ext/classifications.c +85 -0
  11. data/ext/color.c +91 -163
  12. data/ext/component_definition.c +78 -162
  13. data/ext/component_instance.c +88 -9
  14. data/ext/construction.c +59 -0
  15. data/ext/curve.c +87 -0
  16. data/ext/definition_list.c +89 -109
  17. data/ext/depend +1 -0
  18. data/ext/drawing_element.c +96 -117
  19. data/ext/edge.c +147 -0
  20. data/ext/edge_use.c +37 -0
  21. data/ext/entities.c +573 -16
  22. data/ext/entities_builder.c +145 -0
  23. data/ext/entity.c +175 -212
  24. data/ext/environments.c +149 -0
  25. data/ext/extconf.rb +54 -10
  26. data/ext/face.c +331 -0
  27. data/ext/geom.c +172 -0
  28. data/ext/group.c +86 -0
  29. data/ext/helpers.c +244 -0
  30. data/ext/image.c +182 -0
  31. data/ext/image_rep.c +158 -0
  32. data/ext/instance_path.c +185 -0
  33. data/ext/lat_long.c +88 -0
  34. data/ext/layer.c +98 -0
  35. data/ext/layer_folder.c +99 -0
  36. data/ext/layers.c +122 -0
  37. data/ext/length.c +253 -0
  38. data/ext/line_styles.c +60 -0
  39. data/ext/loop.c +24 -0
  40. data/ext/material.c +144 -197
  41. data/ext/materials.c +49 -60
  42. data/ext/model.c +232 -26
  43. data/ext/options_store.c +188 -0
  44. data/ext/page.c +168 -0
  45. data/ext/pages.c +135 -0
  46. data/ext/point2d.c +195 -0
  47. data/ext/point3d.c +340 -0
  48. data/ext/polygon_mesh.c +253 -0
  49. data/ext/scriptup.h +279 -0
  50. data/ext/section_plane.c +44 -0
  51. data/ext/sketchup.c +102 -76
  52. data/ext/styles.c +91 -0
  53. data/ext/text.c +135 -0
  54. data/ext/texture.c +74 -83
  55. data/ext/texture_writer.c +104 -0
  56. data/ext/transformation.c +309 -0
  57. data/ext/transformation2d.c +190 -0
  58. data/ext/uv_helper.c +41 -0
  59. data/ext/vector2d.c +238 -0
  60. data/ext/vector3d.c +294 -0
  61. data/ext/vertex.c +67 -0
  62. data/lib/sketchup.rb +2 -2
  63. data/sig/_top_level.rbs +188 -0
  64. data/sig/array.rbs +52 -0
  65. data/sig/geom/bounding_box.rbs +28 -0
  66. data/sig/geom/bounds2d.rbs +20 -0
  67. data/sig/geom/lat_long.rbs +13 -0
  68. data/sig/geom/oriented_bounds2d.rbs +10 -0
  69. data/sig/geom/point2d.rbs +32 -0
  70. data/sig/geom/point3d.rbs +46 -0
  71. data/sig/geom/polygon_mesh.rbs +35 -0
  72. data/sig/geom/transformation.rbs +44 -0
  73. data/sig/geom/transformation2d.rbs +26 -0
  74. data/sig/geom/utm.rbs +14 -0
  75. data/sig/geom/vector2d.rbs +40 -0
  76. data/sig/geom/vector3d.rbs +49 -0
  77. data/sig/geom.rbs +25 -0
  78. data/sig/language_handler.rbs +8 -0
  79. data/sig/layout/angular_dimension.rbs +32 -0
  80. data/sig/layout/auto_text_definition.rbs +73 -0
  81. data/sig/layout/auto_text_definitions.rbs +15 -0
  82. data/sig/layout/connection_point.rbs +6 -0
  83. data/sig/layout/dictionary.rbs +18 -0
  84. data/sig/layout/document.rbs +61 -0
  85. data/sig/layout/ellipse.rbs +5 -0
  86. data/sig/layout/entities.rbs +10 -0
  87. data/sig/layout/entity.rbs +28 -0
  88. data/sig/layout/formatted_text.rbs +30 -0
  89. data/sig/layout/grid.rbs +24 -0
  90. data/sig/layout/group.rbs +17 -0
  91. data/sig/layout/image.rbs +7 -0
  92. data/sig/layout/label.rbs +31 -0
  93. data/sig/layout/layer.rbs +21 -0
  94. data/sig/layout/layer_instance.rbs +9 -0
  95. data/sig/layout/layers.rbs +18 -0
  96. data/sig/layout/linear_dimension.rbs +39 -0
  97. data/sig/layout/locked_entity_error.rbs +4 -0
  98. data/sig/layout/locked_layer_error.rbs +4 -0
  99. data/sig/layout/page.rbs +20 -0
  100. data/sig/layout/page_info.rbs +37 -0
  101. data/sig/layout/pages.rbs +17 -0
  102. data/sig/layout/path.rbs +34 -0
  103. data/sig/layout/rectangle.rbs +15 -0
  104. data/sig/layout/reference_entity.rbs +7 -0
  105. data/sig/layout/sketch_up_model.rbs +54 -0
  106. data/sig/layout/style.rbs +150 -0
  107. data/sig/layout/table.rbs +17 -0
  108. data/sig/layout/table_cell.rbs +13 -0
  109. data/sig/layout/table_column.rbs +10 -0
  110. data/sig/layout/table_row.rbs +10 -0
  111. data/sig/layout.rbs +4 -0
  112. data/sig/length.rbs +37 -0
  113. data/sig/numeric.rbs +23 -0
  114. data/sig/sketchup/animation.rbs +8 -0
  115. data/sig/sketchup/app_observer.rbs +11 -0
  116. data/sig/sketchup/arc_curve.rbs +14 -0
  117. data/sig/sketchup/attribute_dictionaries.rbs +11 -0
  118. data/sig/sketchup/attribute_dictionary.rbs +18 -0
  119. data/sig/sketchup/axes.rbs +13 -0
  120. data/sig/sketchup/behavior.rbs +19 -0
  121. data/sig/sketchup/camera.rbs +33 -0
  122. data/sig/sketchup/classification_schema.rbs +8 -0
  123. data/sig/sketchup/classifications.rbs +12 -0
  124. data/sig/sketchup/color.rbs +22 -0
  125. data/sig/sketchup/component_definition.rbs +43 -0
  126. data/sig/sketchup/component_instance.rbs +32 -0
  127. data/sig/sketchup/console.rbs +8 -0
  128. data/sig/sketchup/construction_line.rbs +17 -0
  129. data/sig/sketchup/construction_point.rbs +5 -0
  130. data/sig/sketchup/curve.rbs +13 -0
  131. data/sig/sketchup/definition_list.rbs +26 -0
  132. data/sig/sketchup/definition_observer.rbs +6 -0
  133. data/sig/sketchup/definitions_observer.rbs +8 -0
  134. data/sig/sketchup/dimension.rbs +18 -0
  135. data/sig/sketchup/dimension_linear.rbs +24 -0
  136. data/sig/sketchup/dimension_observer.rbs +5 -0
  137. data/sig/sketchup/dimension_radial.rbs +9 -0
  138. data/sig/sketchup/drawingelement.rbs +18 -0
  139. data/sig/sketchup/edge.rbs +24 -0
  140. data/sig/sketchup/edge_use.rbs +13 -0
  141. data/sig/sketchup/entities.rbs +61 -0
  142. data/sig/sketchup/entities_builder.rbs +15 -0
  143. data/sig/sketchup/entities_observer.rbs +9 -0
  144. data/sig/sketchup/entity.rbs +21 -0
  145. data/sig/sketchup/entity_observer.rbs +6 -0
  146. data/sig/sketchup/environment.rbs +25 -0
  147. data/sig/sketchup/environments.rbs +18 -0
  148. data/sig/sketchup/environments_observer.rbs +8 -0
  149. data/sig/sketchup/extensions_manager.rbs +11 -0
  150. data/sig/sketchup/face.rbs +44 -0
  151. data/sig/sketchup/frame_change_observer.rbs +5 -0
  152. data/sig/sketchup/group.rbs +38 -0
  153. data/sig/sketchup/http/request.rbs +17 -0
  154. data/sig/sketchup/http/response.rbs +7 -0
  155. data/sig/sketchup/http.rbs +27 -0
  156. data/sig/sketchup/image.rbs +23 -0
  157. data/sig/sketchup/image_rep.rbs +17 -0
  158. data/sig/sketchup/importer.rbs +14 -0
  159. data/sig/sketchup/input_point.rbs +25 -0
  160. data/sig/sketchup/instance_observer.rbs +6 -0
  161. data/sig/sketchup/instance_path.rbs +20 -0
  162. data/sig/sketchup/layer.rbs +20 -0
  163. data/sig/sketchup/layer_folder.rbs +26 -0
  164. data/sig/sketchup/layers.rbs +30 -0
  165. data/sig/sketchup/layers_observer.rbs +13 -0
  166. data/sig/sketchup/licensing/extension_license.rbs +8 -0
  167. data/sig/sketchup/licensing.rbs +15 -0
  168. data/sig/sketchup/line_style.rbs +5 -0
  169. data/sig/sketchup/line_styles.rbs +13 -0
  170. data/sig/sketchup/load_handler.rbs +8 -0
  171. data/sig/sketchup/loop.rbs +10 -0
  172. data/sig/sketchup/material.rbs +74 -0
  173. data/sig/sketchup/materials.rbs +22 -0
  174. data/sig/sketchup/materials_observer.rbs +10 -0
  175. data/sig/sketchup/menu.rbs +9 -0
  176. data/sig/sketchup/model.rbs +105 -0
  177. data/sig/sketchup/model_observer.rbs +23 -0
  178. data/sig/sketchup/options_manager.rbs +12 -0
  179. data/sig/sketchup/options_provider.rbs +23 -0
  180. data/sig/sketchup/options_provider_observer.rbs +5 -0
  181. data/sig/sketchup/overlay.rbs +21 -0
  182. data/sig/sketchup/overlays_manager.rbs +10 -0
  183. data/sig/sketchup/page.rbs +55 -0
  184. data/sig/sketchup/pages.rbs +25 -0
  185. data/sig/sketchup/pages_observer.rbs +7 -0
  186. data/sig/sketchup/pick_helper.rbs +28 -0
  187. data/sig/sketchup/regional_settings.rbs +7 -0
  188. data/sig/sketchup/rendering_options.rbs +89 -0
  189. data/sig/sketchup/rendering_options_observer.rbs +5 -0
  190. data/sig/sketchup/section_plane.rbs +12 -0
  191. data/sig/sketchup/selection.rbs +31 -0
  192. data/sig/sketchup/selection_observer.rbs +8 -0
  193. data/sig/sketchup/set.rbs +15 -0
  194. data/sig/sketchup/shadow_info.rbs +18 -0
  195. data/sig/sketchup/shadow_info_observer.rbs +5 -0
  196. data/sig/sketchup/skp.rbs +5 -0
  197. data/sig/sketchup/snap.rbs +10 -0
  198. data/sig/sketchup/style.rbs +9 -0
  199. data/sig/sketchup/styles.rbs +21 -0
  200. data/sig/sketchup/text.rbs +22 -0
  201. data/sig/sketchup/texture.rbs +14 -0
  202. data/sig/sketchup/texture_writer.rbs +14 -0
  203. data/sig/sketchup/tool.rbs +45 -0
  204. data/sig/sketchup/tools.rbs +14 -0
  205. data/sig/sketchup/tools_observer.rbs +6 -0
  206. data/sig/sketchup/uv_helper.rbs +6 -0
  207. data/sig/sketchup/vertex.rbs +11 -0
  208. data/sig/sketchup/view.rbs +87 -0
  209. data/sig/sketchup/view_observer.rbs +6 -0
  210. data/sig/sketchup.rbs +137 -0
  211. data/sig/sketchup_extension.rbs +23 -0
  212. data/sig/string.rbs +5 -0
  213. data/sig/ui/command.rbs +20 -0
  214. data/sig/ui/html_dialog.rbs +29 -0
  215. data/sig/ui/notification.rbs +16 -0
  216. data/sig/ui/toolbar.rbs +18 -0
  217. data/sig/ui/web_dialog.rbs +38 -0
  218. data/sig/ui.rbs +66 -0
  219. metadata +204 -275
  220. data/ext/attribute_dictionaries.h +0 -8
  221. data/ext/attribute_dictionary.h +0 -8
  222. data/ext/behavior.h +0 -8
  223. data/ext/color.h +0 -8
  224. data/ext/component_definition.h +0 -8
  225. data/ext/component_instance.h +0 -8
  226. data/ext/definition_list.h +0 -8
  227. data/ext/drawing_element.h +0 -8
  228. data/ext/entities.h +0 -8
  229. data/ext/entity.h +0 -8
  230. data/ext/material.h +0 -8
  231. data/ext/materials.h +0 -8
  232. data/ext/model.h +0 -8
  233. data/ext/not_implemented.c +0 -88
  234. data/ext/not_implemented.h +0 -20
  235. data/ext/sketchup.h +0 -9
  236. data/ext/texture.h +0 -8
  237. data/ext/typed_value.c +0 -84
  238. data/ext/typed_value.h +0 -11
  239. data/ext/utils.h +0 -111
  240. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/application/application.h +0 -36
  241. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/application/model.h +0 -59
  242. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/application/overlay.h +0 -248
  243. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/application/ruby_api.h +0 -118
  244. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/color.h +0 -107
  245. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/common.h +0 -178
  246. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/defs.h +0 -19
  247. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/extension_license.h +0 -62
  248. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/geometry/bounding_box.h +0 -34
  249. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/geometry/plane3d.h +0 -153
  250. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/geometry/point2d.h +0 -96
  251. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/geometry/point3d.h +0 -98
  252. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/geometry/ray3d.h +0 -64
  253. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/geometry/transformation.h +0 -321
  254. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/geometry/transformation2d.h +0 -163
  255. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/geometry/vector2d.h +0 -235
  256. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/geometry/vector3d.h +0 -285
  257. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/geometry.h +0 -152
  258. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/import_export/modelexporterplugin.h +0 -165
  259. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/import_export/modelimporterplugin.h +0 -183
  260. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/import_export/pluginprogresscallback.h +0 -84
  261. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/initialize.h +0 -43
  262. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/length_formatter.h +0 -424
  263. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/arccurve.h +0 -244
  264. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/arrow_type.h +0 -17
  265. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/attribute_dictionary.h +0 -161
  266. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/axes.h +0 -242
  267. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/camera.h +0 -398
  268. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/classification_attribute.h +0 -89
  269. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/classification_info.h +0 -125
  270. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/classifications.h +0 -86
  271. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/component_definition.h +0 -588
  272. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/component_instance.h +0 -344
  273. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/curve.h +0 -143
  274. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/defs.h +0 -142
  275. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/dimension.h +0 -222
  276. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/dimension_linear.h +0 -421
  277. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/dimension_radial.h +0 -194
  278. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/dimension_style.h +0 -253
  279. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/drawing_element.h +0 -198
  280. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/dynamic_component_attribute.h +0 -92
  281. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/dynamic_component_info.h +0 -70
  282. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/edge.h +0 -271
  283. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/edge_use.h +0 -214
  284. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/entities.h +0 -834
  285. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/entity.h +0 -186
  286. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/entity_list.h +0 -80
  287. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/entity_list_iterator.h +0 -90
  288. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/face.h +0 -686
  289. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/font.h +0 -138
  290. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/geometry.h +0 -20
  291. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/geometry_input.h +0 -685
  292. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/group.h +0 -244
  293. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/guide_line.h +0 -155
  294. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/guide_point.h +0 -153
  295. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/image.h +0 -288
  296. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/image_rep.h +0 -275
  297. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/instancepath.h +0 -266
  298. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/layer.h +0 -265
  299. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/layer_folder.h +0 -301
  300. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/line_style.h +0 -211
  301. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/line_styles.h +0 -81
  302. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/location.h +0 -65
  303. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/loop.h +0 -182
  304. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/material.h +0 -390
  305. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/mesh_helper.h +0 -187
  306. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/model.h +0 -1663
  307. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/model_version.h +0 -49
  308. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/opening.h +0 -72
  309. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/options_manager.h +0 -79
  310. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/options_provider.h +0 -166
  311. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/polyline3d.h +0 -140
  312. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/rendering_options.h +0 -179
  313. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/scene.h +0 -836
  314. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/schema.h +0 -56
  315. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/schema_type.h +0 -26
  316. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/section_plane.h +0 -212
  317. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/selection.h +0 -156
  318. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/shadow_info.h +0 -147
  319. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/skp.h +0 -45
  320. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/style.h +0 -303
  321. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/styles.h +0 -190
  322. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/text.h +0 -384
  323. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/texture.h +0 -358
  324. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/texture_writer.h +0 -280
  325. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/typed_value.h +0 -390
  326. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/uv_helper.h +0 -79
  327. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/vertex.h +0 -154
  328. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/sketchup.h +0 -122
  329. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/sketchup_info.h +0 -65
  330. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/slapi.h +0 -16
  331. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/transformation.h +0 -16
  332. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/unicodestring.h +0 -239
  333. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/utils/math_helpers.h +0 -124
  334. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Libraries/libCommonGeometry.dylib +0 -0
  335. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Libraries/libCommonGeoutils.dylib +0 -0
  336. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Libraries/libCommonImage.dylib +0 -4
  337. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Libraries/libCommonPreferences.dylib +0 -0
  338. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Libraries/libCommonUnits.dylib +0 -0
  339. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Libraries/libCommonUtils.dylib +0 -0
  340. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Libraries/libCommonZip.dylib +0 -0
  341. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Resources/Info.plist +0 -50
  342. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/SketchUpAPI +0 -0
  343. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/_CodeSignature/CodeResources +0 -835
  344. data/sketchup-sdk-win/binaries/layout/x64/LayOutAPI.dll +0 -0
  345. data/sketchup-sdk-win/binaries/layout/x64/LayOutAPI.lib +0 -0
  346. data/sketchup-sdk-win/binaries/layout/x64/LayOutControllers.dll +0 -0
  347. data/sketchup-sdk-win/binaries/layout/x64/LayOutModel.dll +0 -0
  348. data/sketchup-sdk-win/binaries/layout/x64/LayOutRTF.dll +0 -0
  349. data/sketchup-sdk-win/binaries/layout/x64/LayOutUtils.dll +0 -0
  350. data/sketchup-sdk-win/binaries/layout/x64/SketchUpCommonPreferences.dll +0 -0
  351. data/sketchup-sdk-win/binaries/layout/x64/SketchUpViewerAPI.dll +0 -0
  352. data/sketchup-sdk-win/binaries/layout/x64/SketchUpViewerAPI.lib +0 -0
  353. data/sketchup-sdk-win/binaries/layout/x64/pdflib.dll +0 -0
  354. data/sketchup-sdk-win/binaries/sketchup/x64/SketchUpAPI.dll +0 -0
  355. data/sketchup-sdk-win/binaries/sketchup/x64/SketchUpAPI.lib +0 -0
  356. data/sketchup-sdk-win/binaries/sketchup/x64/SketchUpCommonPreferences.dll +0 -0
  357. data/sketchup-sdk-win/binaries/sketchup/x64/sketchup.lib +0 -0
  358. data/sketchup-sdk-win/headers/LayOutAPI/application/application.h +0 -117
  359. data/sketchup-sdk-win/headers/LayOutAPI/common.h +0 -22
  360. data/sketchup-sdk-win/headers/LayOutAPI/geometry/geometry.h +0 -78
  361. data/sketchup-sdk-win/headers/LayOutAPI/initialize.h +0 -36
  362. data/sketchup-sdk-win/headers/LayOutAPI/layout.h +0 -49
  363. data/sketchup-sdk-win/headers/LayOutAPI/model/angulardimension.h +0 -468
  364. data/sketchup-sdk-win/headers/LayOutAPI/model/autotextdefinition.h +0 -569
  365. data/sketchup-sdk-win/headers/LayOutAPI/model/autotextdefinitionlist.h +0 -79
  366. data/sketchup-sdk-win/headers/LayOutAPI/model/connectionpoint.h +0 -107
  367. data/sketchup-sdk-win/headers/LayOutAPI/model/defs.h +0 -42
  368. data/sketchup-sdk-win/headers/LayOutAPI/model/dictionary.h +0 -120
  369. data/sketchup-sdk-win/headers/LayOutAPI/model/document.h +0 -864
  370. data/sketchup-sdk-win/headers/LayOutAPI/model/documentexportoptions.h +0 -59
  371. data/sketchup-sdk-win/headers/LayOutAPI/model/ellipse.h +0 -78
  372. data/sketchup-sdk-win/headers/LayOutAPI/model/entity.h +0 -330
  373. data/sketchup-sdk-win/headers/LayOutAPI/model/entityiterator.h +0 -49
  374. data/sketchup-sdk-win/headers/LayOutAPI/model/entitylist.h +0 -114
  375. data/sketchup-sdk-win/headers/LayOutAPI/model/formattedtext.h +0 -397
  376. data/sketchup-sdk-win/headers/LayOutAPI/model/grid.h +0 -251
  377. data/sketchup-sdk-win/headers/LayOutAPI/model/group.h +0 -243
  378. data/sketchup-sdk-win/headers/LayOutAPI/model/image.h +0 -146
  379. data/sketchup-sdk-win/headers/LayOutAPI/model/imagerep.h +0 -109
  380. data/sketchup-sdk-win/headers/LayOutAPI/model/label.h +0 -332
  381. data/sketchup-sdk-win/headers/LayOutAPI/model/layer.h +0 -207
  382. data/sketchup-sdk-win/headers/LayOutAPI/model/layerinstance.h +0 -117
  383. data/sketchup-sdk-win/headers/LayOutAPI/model/layerlist.h +0 -69
  384. data/sketchup-sdk-win/headers/LayOutAPI/model/lineardimension.h +0 -456
  385. data/sketchup-sdk-win/headers/LayOutAPI/model/page.h +0 -261
  386. data/sketchup-sdk-win/headers/LayOutAPI/model/pageinfo.h +0 -372
  387. data/sketchup-sdk-win/headers/LayOutAPI/model/pagelist.h +0 -81
  388. data/sketchup-sdk-win/headers/LayOutAPI/model/path.h +0 -464
  389. data/sketchup-sdk-win/headers/LayOutAPI/model/rectangle.h +0 -240
  390. data/sketchup-sdk-win/headers/LayOutAPI/model/referenceentity.h +0 -120
  391. data/sketchup-sdk-win/headers/LayOutAPI/model/sketchupmodel.h +0 -624
  392. data/sketchup-sdk-win/headers/LayOutAPI/model/skpfilereference.h +0 -94
  393. data/sketchup-sdk-win/headers/LayOutAPI/model/style.h +0 -1080
  394. data/sketchup-sdk-win/headers/LayOutAPI/model/table.h +0 -470
  395. data/sketchup-sdk-win/headers/LayOutAPI/model/typed_value.h +0 -156
  396. data/sketchup-sdk-win/headers/SketchUpAPI/application/application.h +0 -36
  397. data/sketchup-sdk-win/headers/SketchUpAPI/application/model.h +0 -59
  398. data/sketchup-sdk-win/headers/SketchUpAPI/application/overlay.h +0 -248
  399. data/sketchup-sdk-win/headers/SketchUpAPI/application/ruby_api.h +0 -118
  400. data/sketchup-sdk-win/headers/SketchUpAPI/color.h +0 -107
  401. data/sketchup-sdk-win/headers/SketchUpAPI/common.h +0 -178
  402. data/sketchup-sdk-win/headers/SketchUpAPI/defs.h +0 -19
  403. data/sketchup-sdk-win/headers/SketchUpAPI/extension_license.h +0 -62
  404. data/sketchup-sdk-win/headers/SketchUpAPI/geometry/bounding_box.h +0 -34
  405. data/sketchup-sdk-win/headers/SketchUpAPI/geometry/plane3d.h +0 -153
  406. data/sketchup-sdk-win/headers/SketchUpAPI/geometry/point2d.h +0 -96
  407. data/sketchup-sdk-win/headers/SketchUpAPI/geometry/point3d.h +0 -98
  408. data/sketchup-sdk-win/headers/SketchUpAPI/geometry/ray3d.h +0 -64
  409. data/sketchup-sdk-win/headers/SketchUpAPI/geometry/transformation.h +0 -321
  410. data/sketchup-sdk-win/headers/SketchUpAPI/geometry/transformation2d.h +0 -163
  411. data/sketchup-sdk-win/headers/SketchUpAPI/geometry/vector2d.h +0 -235
  412. data/sketchup-sdk-win/headers/SketchUpAPI/geometry/vector3d.h +0 -285
  413. data/sketchup-sdk-win/headers/SketchUpAPI/geometry.h +0 -152
  414. data/sketchup-sdk-win/headers/SketchUpAPI/import_export/modelexporterplugin.h +0 -165
  415. data/sketchup-sdk-win/headers/SketchUpAPI/import_export/modelimporterplugin.h +0 -183
  416. data/sketchup-sdk-win/headers/SketchUpAPI/import_export/pluginprogresscallback.h +0 -84
  417. data/sketchup-sdk-win/headers/SketchUpAPI/initialize.h +0 -43
  418. data/sketchup-sdk-win/headers/SketchUpAPI/length_formatter.h +0 -424
  419. data/sketchup-sdk-win/headers/SketchUpAPI/model/arccurve.h +0 -244
  420. data/sketchup-sdk-win/headers/SketchUpAPI/model/arrow_type.h +0 -17
  421. data/sketchup-sdk-win/headers/SketchUpAPI/model/attribute_dictionary.h +0 -161
  422. data/sketchup-sdk-win/headers/SketchUpAPI/model/axes.h +0 -242
  423. data/sketchup-sdk-win/headers/SketchUpAPI/model/camera.h +0 -398
  424. data/sketchup-sdk-win/headers/SketchUpAPI/model/classification_attribute.h +0 -89
  425. data/sketchup-sdk-win/headers/SketchUpAPI/model/classification_info.h +0 -125
  426. data/sketchup-sdk-win/headers/SketchUpAPI/model/classifications.h +0 -86
  427. data/sketchup-sdk-win/headers/SketchUpAPI/model/component_definition.h +0 -588
  428. data/sketchup-sdk-win/headers/SketchUpAPI/model/component_instance.h +0 -344
  429. data/sketchup-sdk-win/headers/SketchUpAPI/model/curve.h +0 -143
  430. data/sketchup-sdk-win/headers/SketchUpAPI/model/defs.h +0 -142
  431. data/sketchup-sdk-win/headers/SketchUpAPI/model/dimension.h +0 -222
  432. data/sketchup-sdk-win/headers/SketchUpAPI/model/dimension_linear.h +0 -421
  433. data/sketchup-sdk-win/headers/SketchUpAPI/model/dimension_radial.h +0 -194
  434. data/sketchup-sdk-win/headers/SketchUpAPI/model/dimension_style.h +0 -253
  435. data/sketchup-sdk-win/headers/SketchUpAPI/model/drawing_element.h +0 -198
  436. data/sketchup-sdk-win/headers/SketchUpAPI/model/dynamic_component_attribute.h +0 -92
  437. data/sketchup-sdk-win/headers/SketchUpAPI/model/dynamic_component_info.h +0 -70
  438. data/sketchup-sdk-win/headers/SketchUpAPI/model/edge.h +0 -271
  439. data/sketchup-sdk-win/headers/SketchUpAPI/model/edge_use.h +0 -214
  440. data/sketchup-sdk-win/headers/SketchUpAPI/model/entities.h +0 -834
  441. data/sketchup-sdk-win/headers/SketchUpAPI/model/entity.h +0 -186
  442. data/sketchup-sdk-win/headers/SketchUpAPI/model/entity_list.h +0 -80
  443. data/sketchup-sdk-win/headers/SketchUpAPI/model/entity_list_iterator.h +0 -90
  444. data/sketchup-sdk-win/headers/SketchUpAPI/model/face.h +0 -686
  445. data/sketchup-sdk-win/headers/SketchUpAPI/model/font.h +0 -138
  446. data/sketchup-sdk-win/headers/SketchUpAPI/model/geometry.h +0 -20
  447. data/sketchup-sdk-win/headers/SketchUpAPI/model/geometry_input.h +0 -685
  448. data/sketchup-sdk-win/headers/SketchUpAPI/model/group.h +0 -244
  449. data/sketchup-sdk-win/headers/SketchUpAPI/model/guide_line.h +0 -155
  450. data/sketchup-sdk-win/headers/SketchUpAPI/model/guide_point.h +0 -153
  451. data/sketchup-sdk-win/headers/SketchUpAPI/model/image.h +0 -288
  452. data/sketchup-sdk-win/headers/SketchUpAPI/model/image_rep.h +0 -275
  453. data/sketchup-sdk-win/headers/SketchUpAPI/model/instancepath.h +0 -266
  454. data/sketchup-sdk-win/headers/SketchUpAPI/model/layer.h +0 -265
  455. data/sketchup-sdk-win/headers/SketchUpAPI/model/layer_folder.h +0 -301
  456. data/sketchup-sdk-win/headers/SketchUpAPI/model/line_style.h +0 -211
  457. data/sketchup-sdk-win/headers/SketchUpAPI/model/line_styles.h +0 -81
  458. data/sketchup-sdk-win/headers/SketchUpAPI/model/location.h +0 -65
  459. data/sketchup-sdk-win/headers/SketchUpAPI/model/loop.h +0 -182
  460. data/sketchup-sdk-win/headers/SketchUpAPI/model/material.h +0 -390
  461. data/sketchup-sdk-win/headers/SketchUpAPI/model/mesh_helper.h +0 -187
  462. data/sketchup-sdk-win/headers/SketchUpAPI/model/model.h +0 -1663
  463. data/sketchup-sdk-win/headers/SketchUpAPI/model/model_version.h +0 -49
  464. data/sketchup-sdk-win/headers/SketchUpAPI/model/opening.h +0 -72
  465. data/sketchup-sdk-win/headers/SketchUpAPI/model/options_manager.h +0 -79
  466. data/sketchup-sdk-win/headers/SketchUpAPI/model/options_provider.h +0 -166
  467. data/sketchup-sdk-win/headers/SketchUpAPI/model/polyline3d.h +0 -140
  468. data/sketchup-sdk-win/headers/SketchUpAPI/model/rendering_options.h +0 -179
  469. data/sketchup-sdk-win/headers/SketchUpAPI/model/scene.h +0 -836
  470. data/sketchup-sdk-win/headers/SketchUpAPI/model/schema.h +0 -56
  471. data/sketchup-sdk-win/headers/SketchUpAPI/model/schema_type.h +0 -26
  472. data/sketchup-sdk-win/headers/SketchUpAPI/model/section_plane.h +0 -212
  473. data/sketchup-sdk-win/headers/SketchUpAPI/model/selection.h +0 -156
  474. data/sketchup-sdk-win/headers/SketchUpAPI/model/shadow_info.h +0 -147
  475. data/sketchup-sdk-win/headers/SketchUpAPI/model/skp.h +0 -45
  476. data/sketchup-sdk-win/headers/SketchUpAPI/model/style.h +0 -303
  477. data/sketchup-sdk-win/headers/SketchUpAPI/model/styles.h +0 -190
  478. data/sketchup-sdk-win/headers/SketchUpAPI/model/text.h +0 -384
  479. data/sketchup-sdk-win/headers/SketchUpAPI/model/texture.h +0 -358
  480. data/sketchup-sdk-win/headers/SketchUpAPI/model/texture_writer.h +0 -280
  481. data/sketchup-sdk-win/headers/SketchUpAPI/model/typed_value.h +0 -390
  482. data/sketchup-sdk-win/headers/SketchUpAPI/model/uv_helper.h +0 -79
  483. data/sketchup-sdk-win/headers/SketchUpAPI/model/vertex.h +0 -154
  484. data/sketchup-sdk-win/headers/SketchUpAPI/sketchup.h +0 -122
  485. data/sketchup-sdk-win/headers/SketchUpAPI/sketchup_info.h +0 -65
  486. data/sketchup-sdk-win/headers/SketchUpAPI/slapi.h +0 -16
  487. data/sketchup-sdk-win/headers/SketchUpAPI/transformation.h +0 -16
  488. data/sketchup-sdk-win/headers/SketchUpAPI/unicodestring.h +0 -239
  489. data/sketchup-sdk-win/headers/SketchUpAPI/utils/math_helpers.h +0 -124
data/ext/geom.c ADDED
@@ -0,0 +1,172 @@
1
+ #include <scriptup.h>
2
+
3
+ #define GEOM_TOLERANCE 1.0e-3
4
+
5
+ static struct SUVector3D sub(struct SUPoint3D a, struct SUPoint3D b)
6
+ {
7
+ return (struct SUVector3D){a.x - b.x, a.y - b.y, a.z - b.z};
8
+ }
9
+
10
+ static double dot(struct SUVector3D a, struct SUVector3D b)
11
+ {
12
+ return a.x * b.x + a.y * b.y + a.z * b.z;
13
+ }
14
+
15
+ static struct SUPoint3D along(struct SURay3D ray, double t)
16
+ {
17
+ return (struct SUPoint3D){ray.point.x + ray.normal.x * t, ray.point.y + ray.normal.y * t, ray.point.z + ray.normal.z * t};
18
+ }
19
+
20
+ // Closest points between two lines; false if they are parallel.
21
+ static bool closest(struct SURay3D a, struct SURay3D b, struct SUPoint3D* pa, struct SUPoint3D* pb)
22
+ {
23
+ struct SUVector3D w = sub(a.point, b.point);
24
+ double aa = dot(a.normal, a.normal);
25
+ double ab = dot(a.normal, b.normal);
26
+ double bb = dot(b.normal, b.normal);
27
+ double aw = dot(a.normal, w);
28
+ double bw = dot(b.normal, w);
29
+ double denominator = aa * bb - ab * ab;
30
+ if (fabs(denominator) < 1.0e-12)
31
+ return false;
32
+ *pa = along(a, (ab * bw - bb * aw) / denominator);
33
+ *pb = along(b, (aa * bw - ab * aw) / denominator);
34
+ return true;
35
+ }
36
+
37
+ static VALUE geom_closest_points(VALUE self, VALUE line1, VALUE line2)
38
+ {
39
+ struct SURay3D a = su_to_ray3d(line1);
40
+ struct SURay3D b = su_to_ray3d(line2);
41
+ struct SUPoint3D pa;
42
+ struct SUPoint3D pb;
43
+ if (!closest(a, b, &pa, &pb))
44
+ {
45
+ pa = a.point;
46
+ SURay3DProjectTo(&b, &pa, &pb);
47
+ }
48
+ return rb_ary_new_from_args(2, su_point3d_new(pa), su_point3d_new(pb));
49
+ }
50
+
51
+ static VALUE geom_intersect_line_line(VALUE self, VALUE line1, VALUE line2)
52
+ {
53
+ struct SUPoint3D pa;
54
+ struct SUPoint3D pb;
55
+ if (!closest(su_to_ray3d(line1), su_to_ray3d(line2), &pa, &pb))
56
+ return Qnil;
57
+ double distance = 0.0;
58
+ SUPoint3DDistanceToSUPoint3D(&pa, &pb, &distance);
59
+ return distance < GEOM_TOLERANCE ? su_point3d_new(pa) : Qnil;
60
+ }
61
+
62
+ static VALUE geom_intersect_line_plane(VALUE self, VALUE line, VALUE plane)
63
+ {
64
+ struct SURay3D ray = su_to_ray3d(line);
65
+ struct SUPlane3D p = su_to_plane3d(plane);
66
+ struct SUVector3D normal = {p.a, p.b, p.c};
67
+ double denominator = dot(normal, ray.normal);
68
+ if (fabs(denominator) < 1.0e-12)
69
+ return Qnil;
70
+ double t = -(dot(normal, (struct SUVector3D){ray.point.x, ray.point.y, ray.point.z}) + p.d) / denominator;
71
+ return su_point3d_new(along(ray, t));
72
+ }
73
+
74
+ static VALUE geom_intersect_plane_plane(VALUE self, VALUE plane1, VALUE plane2)
75
+ {
76
+ struct SUPlane3D p = su_to_plane3d(plane1);
77
+ struct SUPlane3D q = su_to_plane3d(plane2);
78
+ struct SUVector3D n1 = {p.a, p.b, p.c};
79
+ struct SUVector3D n2 = {q.a, q.b, q.c};
80
+ struct SUVector3D direction;
81
+ SUVector3DCross(&n1, &n2, &direction);
82
+ double length = sqrt(dot(direction, direction));
83
+ if (length < 1.0e-12)
84
+ return Qnil;
85
+ // Point on both planes: ((d2 n1 - d1 n2) x direction) / |direction|^2
86
+ struct SUVector3D v = {q.d * n1.x - p.d * n2.x, q.d * n1.y - p.d * n2.y, q.d * n1.z - p.d * n2.z};
87
+ struct SUVector3D c;
88
+ SUVector3DCross(&v, &direction, &c);
89
+ double l2 = length * length;
90
+ struct SUPoint3D point = {c.x / l2, c.y / l2, c.z / l2};
91
+ SUVector3DNormalize(&direction);
92
+ return rb_ary_new_from_args(2, su_point3d_new(point), su_vector3d_new(direction));
93
+ }
94
+
95
+ static VALUE geom_linear_combination(VALUE self, VALUE w1, VALUE a, VALUE w2, VALUE b)
96
+ {
97
+ if (rb_obj_is_kind_of(a, cVector3d))
98
+ {
99
+ struct SUVector3D va = su_to_vector3d(a);
100
+ struct SUVector3D vb = su_to_vector3d(b);
101
+ double x = NUM2DBL(w1);
102
+ double y = NUM2DBL(w2);
103
+ return su_vector3d_new((struct SUVector3D){x * va.x + y * vb.x, x * va.y + y * vb.y, x * va.z + y * vb.z});
104
+ }
105
+ return rb_funcall(cPoint3d, (rb_intern)("linear_combination"), 4, w1, a, w2, b);
106
+ }
107
+
108
+ static VALUE geom_fit_plane_to_points(int argc, VALUE* argv, VALUE self)
109
+ {
110
+ VALUE points = argc == 1 && RB_TYPE_P(argv[0], T_ARRAY) && !rb_obj_is_kind_of(RARRAY_AREF(argv[0], 0), rb_cNumeric)
111
+ ? argv[0] : rb_ary_new_from_values(argc, argv);
112
+ long count = RARRAY_LEN(points);
113
+ if (count < 3)
114
+ rb_raise(rb_eArgError, "at least 3 points are required");
115
+ // Newell's method: normal from the polygon, plane through the centroid.
116
+ struct SUVector3D normal = {0, 0, 0};
117
+ struct SUPoint3D centroid = {0, 0, 0};
118
+ for (long i = 0; i < count; i++)
119
+ {
120
+ struct SUPoint3D a = su_to_point3d(RARRAY_AREF(points, i));
121
+ struct SUPoint3D b = su_to_point3d(RARRAY_AREF(points, (i + 1) % count));
122
+ normal.x += (a.y - b.y) * (a.z + b.z);
123
+ normal.y += (a.z - b.z) * (a.x + b.x);
124
+ normal.z += (a.x - b.x) * (a.y + b.y);
125
+ centroid.x += a.x / count;
126
+ centroid.y += a.y / count;
127
+ centroid.z += a.z / count;
128
+ }
129
+ struct SUPlane3D plane;
130
+ if (SUPlane3DSetWithPointAndNormal(&plane, &centroid, &normal) != SU_ERROR_NONE)
131
+ rb_raise(rb_eArgError, "points are collinear");
132
+ return rb_ary_new_from_args(4, DBL2NUM(plane.a), DBL2NUM(plane.b), DBL2NUM(plane.c), DBL2NUM(plane.d));
133
+ }
134
+
135
+ static bool on_segment(double px, double py, double ax, double ay, double bx, double by)
136
+ {
137
+ double cross = (bx - ax) * (py - ay) - (by - ay) * (px - ax);
138
+ double length = hypot(bx - ax, by - ay);
139
+ if (length < 1.0e-12)
140
+ return hypot(px - ax, py - ay) < GEOM_TOLERANCE;
141
+ return fabs(cross) / length < GEOM_TOLERANCE && px >= fmin(ax, bx) - GEOM_TOLERANCE &&
142
+ px <= fmax(ax, bx) + GEOM_TOLERANCE && py >= fmin(ay, by) - GEOM_TOLERANCE && py <= fmax(ay, by) + GEOM_TOLERANCE;
143
+ }
144
+
145
+ static VALUE geom_point_in_polygon_2D(VALUE self, VALUE point, VALUE polygon, VALUE check_border)
146
+ {
147
+ struct SUPoint3D p = su_to_point3d(point);
148
+ Check_Type(polygon, T_ARRAY);
149
+ long count = RARRAY_LEN(polygon);
150
+ bool inside = false;
151
+ for (long i = 0, j = count - 1; i < count; j = i++)
152
+ {
153
+ struct SUPoint3D a = su_to_point3d(RARRAY_AREF(polygon, i));
154
+ struct SUPoint3D b = su_to_point3d(RARRAY_AREF(polygon, j));
155
+ if (on_segment(p.x, p.y, a.x, a.y, b.x, b.y))
156
+ return BOOL2RB(RTEST(check_border));
157
+ if ((a.y > p.y) != (b.y > p.y) && p.x < (b.x - a.x) * (p.y - a.y) / (b.y - a.y) + a.x)
158
+ inside = !inside;
159
+ }
160
+ return BOOL2RB(inside);
161
+ }
162
+
163
+ void Init_geom(void)
164
+ {
165
+ rb_define_singleton_method(mGeom, "closest_points", geom_closest_points, 2);
166
+ rb_define_singleton_method(mGeom, "fit_plane_to_points", geom_fit_plane_to_points, -1);
167
+ rb_define_singleton_method(mGeom, "intersect_line_line", geom_intersect_line_line, 2);
168
+ rb_define_singleton_method(mGeom, "intersect_line_plane", geom_intersect_line_plane, 2);
169
+ rb_define_singleton_method(mGeom, "intersect_plane_plane", geom_intersect_plane_plane, 2);
170
+ rb_define_singleton_method(mGeom, "linear_combination", geom_linear_combination, 4);
171
+ rb_define_singleton_method(mGeom, "point_in_polygon_2D", geom_point_in_polygon_2D, 3);
172
+ }
data/ext/group.c ADDED
@@ -0,0 +1,86 @@
1
+ #include <scriptup.h>
2
+
3
+ #define GROUP(self) SU_REF(SUGroupRef, self)
4
+
5
+ DEFINE_STRING_GETTER(group_name, SUGroupRef, SUGroupGetName)
6
+ DEFINE_STRING_SETTER(group_set_name, SUGroupRef, SUGroupSetName)
7
+ DEFINE_STRING_GETTER(group_guid, SUGroupRef, SUGroupGetGuid)
8
+ DEFINE_REF_GETTER(group_definition, SUGroupRef, SUGroupGetDefinition, SUComponentDefinitionRef, cComponentDefinition)
9
+
10
+ static VALUE group_entities(VALUE self)
11
+ {
12
+ SUEntitiesRef entities = SU_INVALID;
13
+ SUGroupGetEntities(GROUP(self), &entities);
14
+ return su_entities_new(entities);
15
+ }
16
+
17
+ static VALUE group_description(VALUE self)
18
+ {
19
+ return rb_funcall(group_definition(self), (rb_intern)("description"), 0);
20
+ }
21
+
22
+ static VALUE group_set_description(VALUE self, VALUE description)
23
+ {
24
+ return rb_funcall(group_definition(self), (rb_intern)("description="), 1, description);
25
+ }
26
+
27
+ static VALUE group_transformation(VALUE self)
28
+ {
29
+ struct SUTransformation t;
30
+ SUGroupGetTransform(GROUP(self), &t);
31
+ return su_transformation_new(t);
32
+ }
33
+
34
+ static VALUE group_set_transformation(VALUE self, VALUE transformation)
35
+ {
36
+ struct SUTransformation t = su_to_transformation(transformation);
37
+ SUGroupSetTransform(GROUP(self), &t);
38
+ return transformation;
39
+ }
40
+
41
+ static VALUE group_move_bang(VALUE self, VALUE transformation)
42
+ {
43
+ group_set_transformation(self, transformation);
44
+ return self;
45
+ }
46
+
47
+ static VALUE group_transform_bang(VALUE self, VALUE transformation)
48
+ {
49
+ struct SUTransformation by = su_to_transformation(transformation);
50
+ struct SUTransformation current;
51
+ struct SUTransformation result;
52
+ SUGroupGetTransform(GROUP(self), &current);
53
+ SUTransformationMultiply(&by, &current, &result);
54
+ SUGroupSetTransform(GROUP(self), &result);
55
+ return self;
56
+ }
57
+
58
+ static VALUE group_local_bounds(VALUE self)
59
+ {
60
+ SUEntitiesRef entities = SU_INVALID;
61
+ SUGroupGetEntities(GROUP(self), &entities);
62
+ struct SUBoundingBox3D bbox;
63
+ SUEntitiesGetBoundingBox(entities, &bbox);
64
+ return su_bounding_box_new(bbox);
65
+ }
66
+
67
+ void Init_group(void)
68
+ {
69
+ rb_define_method(cGroup, "name", group_name, 0);
70
+ rb_define_method(cGroup, "name=", group_set_name, 1);
71
+ rb_define_method(cGroup, "guid", group_guid, 0);
72
+ rb_define_method(cGroup, "definition", group_definition, 0);
73
+ rb_define_method(cGroup, "entities", group_entities, 0);
74
+ rb_define_method(cGroup, "description", group_description, 0);
75
+ rb_define_method(cGroup, "description=", group_set_description, 1);
76
+ rb_define_method(cGroup, "locked?", su_instance_locked_p, 0);
77
+ rb_define_method(cGroup, "locked=", su_instance_set_locked, 1);
78
+ rb_define_method(cGroup, "transformation", group_transformation, 0);
79
+ rb_define_method(cGroup, "transformation=", group_set_transformation, 1);
80
+ rb_define_method(cGroup, "move!", group_move_bang, 1);
81
+ rb_define_method(cGroup, "transform!", group_transform_bang, 1);
82
+ rb_define_method(cGroup, "volume", su_instance_volume, 0);
83
+ rb_define_method(cGroup, "manifold?", su_instance_manifold_p, 0);
84
+ rb_define_method(cGroup, "local_bounds", group_local_bounds, 0);
85
+ rb_define_method(cGroup, "glued_to", su_instance_glued_to, 0);
86
+ }
data/ext/helpers.c ADDED
@@ -0,0 +1,244 @@
1
+ #include <scriptup.h>
2
+
3
+ VALUE su_wrap(VALUE klass, void* ptr)
4
+ {
5
+ return Data_Wrap_Struct(klass, 0, 0, ptr);
6
+ }
7
+
8
+ VALUE su_wrap_or_nil(VALUE klass, void* ptr)
9
+ {
10
+ return ptr ? su_wrap(klass, ptr) : Qnil;
11
+ }
12
+
13
+ void* su_unwrap(VALUE obj, VALUE klass)
14
+ {
15
+ if (!rb_obj_is_kind_of(obj, klass))
16
+ rb_raise(rb_eTypeError, "wrong argument type %"PRIsVALUE" (expected %"PRIsVALUE")", rb_obj_class(obj), klass);
17
+ return DATA_PTR(obj);
18
+ }
19
+
20
+ VALUE su_string_to_rb(SUStringRef string)
21
+ {
22
+ size_t length = 0;
23
+ SUStringGetUTF8Length(string, &length);
24
+ VALUE output = rb_utf8_str_new(0, (long)length);
25
+ SUStringGetUTF8(string, length + 1, RSTRING_PTR(output), &length);
26
+ return output;
27
+ }
28
+
29
+ int su_clamp_int(VALUE value, int min, int max)
30
+ {
31
+ int i = NUM2INT(value);
32
+ return i < min ? min : i > max ? max : i;
33
+ }
34
+
35
+ double su_clamp_double(VALUE value, double min, double max)
36
+ {
37
+ double d = NUM2DBL(value);
38
+ return d < min ? min : d > max ? max : d;
39
+ }
40
+
41
+ VALUE su_yield_each(VALUE self, VALUE ary)
42
+ {
43
+ for (long i = 0; i < RARRAY_LEN(ary); i++)
44
+ rb_yield(RARRAY_AREF(ary, i));
45
+ return self;
46
+ }
47
+
48
+ VALUE su_find_by(VALUE ary, const char* method, VALUE key)
49
+ {
50
+ ID id = (rb_intern)(method);
51
+ for (long i = 0; i < RARRAY_LEN(ary); i++)
52
+ {
53
+ VALUE item = RARRAY_AREF(ary, i);
54
+ if (rb_equal(rb_funcall(item, id, 0), key))
55
+ return item;
56
+ }
57
+ return Qnil;
58
+ }
59
+
60
+ VALUE su_fetch(VALUE ary, VALUE index)
61
+ {
62
+ long i = NUM2LONG(index);
63
+ if (i < 0 || i >= RARRAY_LEN(ary))
64
+ rb_raise(rb_eIndexError, "index %ld out of range [0, %ld)", i, RARRAY_LEN(ary));
65
+ return RARRAY_AREF(ary, i);
66
+ }
67
+
68
+ VALUE su_ruby_from_typed_value(SUTypedValueRef value)
69
+ {
70
+ enum SUTypedValueType type = SUTypedValueType_Empty;
71
+ if (SUTypedValueGetType(value, &type) != SU_ERROR_NONE)
72
+ return Qnil;
73
+ switch (type)
74
+ {
75
+ case SUTypedValueType_Byte:
76
+ {
77
+ char byte = 0;
78
+ SUTypedValueGetByte(value, &byte);
79
+ return INT2FIX(byte);
80
+ }
81
+ case SUTypedValueType_Short:
82
+ {
83
+ int16_t i = 0;
84
+ SUTypedValueGetInt16(value, &i);
85
+ return INT2FIX(i);
86
+ }
87
+ case SUTypedValueType_Int32:
88
+ {
89
+ int32_t i = 0;
90
+ SUTypedValueGetInt32(value, &i);
91
+ return INT2NUM(i);
92
+ }
93
+ case SUTypedValueType_Float:
94
+ {
95
+ float f = 0;
96
+ SUTypedValueGetFloat(value, &f);
97
+ return DBL2NUM(f);
98
+ }
99
+ case SUTypedValueType_Double:
100
+ {
101
+ double d = 0;
102
+ SUTypedValueGetDouble(value, &d);
103
+ return DBL2NUM(d);
104
+ }
105
+ case SUTypedValueType_Bool:
106
+ {
107
+ bool b = false;
108
+ SUTypedValueGetBool(value, &b);
109
+ return BOOL2RB(b);
110
+ }
111
+ case SUTypedValueType_String:
112
+ {
113
+ SUStringRef string = SU_INVALID;
114
+ SUStringCreate(&string);
115
+ SUTypedValueGetString(value, &string);
116
+ VALUE output = su_string_to_rb(string);
117
+ SUStringRelease(&string);
118
+ return output;
119
+ }
120
+ case SUTypedValueType_Color:
121
+ {
122
+ SUColor color = {0, 0, 0, 255};
123
+ SUTypedValueGetColor(value, &color);
124
+ return su_color_new(color);
125
+ }
126
+ case SUTypedValueType_Time:
127
+ {
128
+ int64_t time = 0;
129
+ SUTypedValueGetTime(value, &time);
130
+ return rb_time_new((time_t)time, 0);
131
+ }
132
+ case SUTypedValueType_Vector3D:
133
+ {
134
+ double v[3] = {0, 0, 0};
135
+ SUTypedValueGetVector3d(value, v);
136
+ return su_vector3d_new((struct SUVector3D){v[0], v[1], v[2]});
137
+ }
138
+ case SUTypedValueType_Array:
139
+ {
140
+ size_t count = 0;
141
+ SUTypedValueGetNumArrayItems(value, &count);
142
+ VALUE ary = rb_ary_new_capa((long)count);
143
+ if (count == 0)
144
+ return ary;
145
+ // The items stay owned by the array.
146
+ SUTypedValueRef* items = ZALLOC_N(SUTypedValueRef, count);
147
+ SUTypedValueGetArrayItems(value, count, items, &count);
148
+ for (size_t i = 0; i < count; i++)
149
+ rb_ary_push(ary, su_ruby_from_typed_value(items[i]));
150
+ xfree(items);
151
+ return ary;
152
+ }
153
+ case SUTypedValueType_Empty:
154
+ default:
155
+ return Qnil;
156
+ }
157
+ }
158
+
159
+ void su_typed_value_from_ruby(SUTypedValueRef value, VALUE object)
160
+ {
161
+ switch (rb_type(object))
162
+ {
163
+ case T_FLOAT:
164
+ SUTypedValueSetDouble(value, NUM2DBL(object));
165
+ break;
166
+ case T_FIXNUM:
167
+ case T_BIGNUM:
168
+ SUTypedValueSetInt32(value, NUM2INT(object));
169
+ break;
170
+ case T_TRUE:
171
+ case T_FALSE:
172
+ SUTypedValueSetBool(value, RTEST(object));
173
+ break;
174
+ case T_STRING:
175
+ SUTypedValueSetString(value, StringValueCStr(object));
176
+ break;
177
+ case T_ARRAY:
178
+ {
179
+ long count = RARRAY_LEN(object);
180
+ SUTypedValueRef* items = ZALLOC_N(SUTypedValueRef, count > 0 ? count : 1);
181
+ for (long i = 0; i < count; i++)
182
+ {
183
+ items[i].ptr = NULL;
184
+ SUTypedValueCreate(&items[i]);
185
+ su_typed_value_from_ruby(items[i], RARRAY_AREF(object, i));
186
+ }
187
+ SUTypedValueSetArrayItems(value, (size_t)count, items);
188
+ for (long i = 0; i < count; i++)
189
+ SUTypedValueRelease(&items[i]);
190
+ xfree(items);
191
+ break;
192
+ }
193
+ default:
194
+ if (rb_obj_is_kind_of(object, cColor))
195
+ {
196
+ SUTypedValueSetColor(value, DATA_PTR(object));
197
+ break;
198
+ }
199
+ if (rb_obj_is_kind_of(object, cVector3d))
200
+ {
201
+ struct SUVector3D v = su_to_vector3d(object);
202
+ double xyz[3] = {v.x, v.y, v.z};
203
+ SUTypedValueSetVector3d(value, xyz);
204
+ break;
205
+ }
206
+ if (rb_obj_is_kind_of(object, rb_cTime))
207
+ {
208
+ SUTypedValueSetTime(value, NUM2LL(rb_funcall(object, (rb_intern)("to_i"), 0)));
209
+ break;
210
+ }
211
+ rb_raise(rb_eNotImpError, "unsupported attribute value type %"PRIsVALUE, rb_obj_class(object));
212
+ }
213
+ }
214
+
215
+ // Accepts a 2 or 3 element numeric array; z defaults to 0.
216
+ void su_array_to_xyz(VALUE ary, double xyz[3])
217
+ {
218
+ if (!RB_TYPE_P(ary, T_ARRAY))
219
+ rb_raise(rb_eTypeError, "wrong argument type %"PRIsVALUE" (expected Array)", rb_obj_class(ary));
220
+ long length = RARRAY_LEN(ary);
221
+ if (length != 2 && length != 3)
222
+ rb_raise(rb_eArgError, "expected an array of 2 or 3 numbers, got %ld", length);
223
+ xyz[0] = NUM2DBL(RARRAY_AREF(ary, 0));
224
+ xyz[1] = NUM2DBL(RARRAY_AREF(ary, 1));
225
+ xyz[2] = length == 3 ? NUM2DBL(RARRAY_AREF(ary, 2)) : 0.0;
226
+ }
227
+
228
+ // Formats like SketchUp: whole numbers without a decimal part.
229
+ VALUE su_format_number(double value)
230
+ {
231
+ if (value == floor(value) && fabs(value) < 1e15)
232
+ return rb_sprintf("%lld", (long long)value);
233
+ return rb_funcall(DBL2NUM(value), (rb_intern)("to_s"), 0);
234
+ }
235
+
236
+ void su_array_to_xy(VALUE ary, double xy[2])
237
+ {
238
+ if (!RB_TYPE_P(ary, T_ARRAY))
239
+ rb_raise(rb_eTypeError, "wrong argument type %"PRIsVALUE" (expected Array)", rb_obj_class(ary));
240
+ if (RARRAY_LEN(ary) != 2)
241
+ rb_raise(rb_eArgError, "expected an array of 2 numbers, got %ld", RARRAY_LEN(ary));
242
+ xy[0] = NUM2DBL(RARRAY_AREF(ary, 0));
243
+ xy[1] = NUM2DBL(RARRAY_AREF(ary, 1));
244
+ }
data/ext/image.c ADDED
@@ -0,0 +1,182 @@
1
+ #include <scriptup.h>
2
+
3
+ #define IMAGE(self) SU_REF(SUImageRef, self)
4
+
5
+ DEFINE_STRING_GETTER(image_path, SUImageRef, SUImageGetFileName)
6
+
7
+ static struct SUTransformation image_transform(VALUE self)
8
+ {
9
+ struct SUTransformation t;
10
+ SUImageGetTransform(IMAGE(self), &t);
11
+ return t;
12
+ }
13
+
14
+ static void image_size(VALUE self, double* width, double* height)
15
+ {
16
+ *width = 0.0;
17
+ *height = 0.0;
18
+ SUImageGetDimensions(IMAGE(self), width, height);
19
+ }
20
+
21
+ static VALUE image_width(VALUE self)
22
+ {
23
+ double width, height;
24
+ image_size(self, &width, &height);
25
+ return su_length_new(width);
26
+ }
27
+
28
+ static VALUE image_height(VALUE self)
29
+ {
30
+ double width, height;
31
+ image_size(self, &width, &height);
32
+ return su_length_new(height);
33
+ }
34
+
35
+ // Rescales the image's x and y axes to the requested world size.
36
+ static void image_resize(VALUE self, double width, double height)
37
+ {
38
+ if (width <= 0 || height <= 0)
39
+ rb_raise(rb_eArgError, "image size must be positive");
40
+ double current_width, current_height;
41
+ image_size(self, &current_width, &current_height);
42
+ struct SUTransformation t = image_transform(self);
43
+ double sx = width / current_width;
44
+ double sy = height / current_height;
45
+ for (int i = 0; i < 3; i++)
46
+ {
47
+ t.values[i] *= sx;
48
+ t.values[4 + i] *= sy;
49
+ }
50
+ SUImageSetTransform(IMAGE(self), &t);
51
+ }
52
+
53
+ static VALUE image_set_width(VALUE self, VALUE width)
54
+ {
55
+ double w, h;
56
+ image_size(self, &w, &h);
57
+ double new_width = NUM2DBL(width);
58
+ image_resize(self, new_width, h * new_width / w);
59
+ return width;
60
+ }
61
+
62
+ static VALUE image_set_height(VALUE self, VALUE height)
63
+ {
64
+ double w, h;
65
+ image_size(self, &w, &h);
66
+ double new_height = NUM2DBL(height);
67
+ image_resize(self, w * new_height / h, new_height);
68
+ return height;
69
+ }
70
+
71
+ // image.size = width, height arrives as one array.
72
+ static VALUE image_set_size(int argc, VALUE* argv, VALUE self)
73
+ {
74
+ VALUE size = argc == 1 ? argv[0] : rb_ary_new_from_values(argc, argv);
75
+ double wh[2];
76
+ su_array_to_xy(size, wh);
77
+ image_resize(self, wh[0], wh[1]);
78
+ return size;
79
+ }
80
+
81
+ static VALUE image_image_rep(VALUE self)
82
+ {
83
+ SUImageRepRef rep = SU_INVALID;
84
+ SUImageRepCreate(&rep);
85
+ if (SUImageGetImageRep(IMAGE(self), &rep) != SU_ERROR_NONE)
86
+ {
87
+ SUImageRepRelease(&rep);
88
+ return Qnil;
89
+ }
90
+ return su_image_rep_new(rep);
91
+ }
92
+
93
+ // Pixel sizes come from the image rep (SUImageGetPixelDimensions is deprecated).
94
+ static VALUE image_pixelwidth(VALUE self)
95
+ {
96
+ VALUE rep = image_image_rep(self);
97
+ return NIL_P(rep) ? INT2FIX(0) : rb_funcall(rep, (rb_intern)("width"), 0);
98
+ }
99
+
100
+ static VALUE image_pixelheight(VALUE self)
101
+ {
102
+ VALUE rep = image_image_rep(self);
103
+ return NIL_P(rep) ? INT2FIX(0) : rb_funcall(rep, (rb_intern)("height"), 0);
104
+ }
105
+
106
+ static VALUE image_transformation(VALUE self)
107
+ {
108
+ return su_transformation_new(image_transform(self));
109
+ }
110
+
111
+ static VALUE image_set_transformation(VALUE self, VALUE transformation)
112
+ {
113
+ struct SUTransformation t = su_to_transformation(transformation);
114
+ SUImageSetTransform(IMAGE(self), &t);
115
+ return transformation;
116
+ }
117
+
118
+ static VALUE image_transform_bang(VALUE self, VALUE transformation)
119
+ {
120
+ struct SUTransformation by = su_to_transformation(transformation);
121
+ struct SUTransformation current = image_transform(self);
122
+ struct SUTransformation result;
123
+ SUTransformationMultiply(&by, &current, &result);
124
+ SUImageSetTransform(IMAGE(self), &result);
125
+ return self;
126
+ }
127
+
128
+ static VALUE image_origin(VALUE self)
129
+ {
130
+ struct SUTransformation t = image_transform(self);
131
+ struct SUPoint3D origin;
132
+ SUTransformationGetOrigin(&t, &origin);
133
+ return su_point3d_new(origin);
134
+ }
135
+
136
+ static VALUE image_set_origin(VALUE self, VALUE point)
137
+ {
138
+ struct SUPoint3D p = su_to_point3d(point);
139
+ struct SUTransformation t = image_transform(self);
140
+ t.values[12] = p.x;
141
+ t.values[13] = p.y;
142
+ t.values[14] = p.z;
143
+ SUImageSetTransform(IMAGE(self), &t);
144
+ return point;
145
+ }
146
+
147
+ static VALUE image_normal(VALUE self)
148
+ {
149
+ struct SUTransformation t = image_transform(self);
150
+ struct SUVector3D z;
151
+ SUTransformationGetZAxis(&t, &z);
152
+ SUVector3DNormalize(&z);
153
+ return su_vector3d_new(z);
154
+ }
155
+
156
+ static VALUE image_zrotation(VALUE self)
157
+ {
158
+ struct SUTransformation t = image_transform(self);
159
+ double angle = 0.0;
160
+ SUTransformationGetZRotation(&t, &angle);
161
+ return DBL2NUM(angle);
162
+ }
163
+
164
+ void Init_image(void)
165
+ {
166
+ rb_define_method(cImage, "path", image_path, 0);
167
+ rb_define_method(cImage, "width", image_width, 0);
168
+ rb_define_method(cImage, "height", image_height, 0);
169
+ rb_define_method(cImage, "width=", image_set_width, 1);
170
+ rb_define_method(cImage, "height=", image_set_height, 1);
171
+ rb_define_method(cImage, "size=", image_set_size, -1);
172
+ rb_define_method(cImage, "pixelwidth", image_pixelwidth, 0);
173
+ rb_define_method(cImage, "pixelheight", image_pixelheight, 0);
174
+ rb_define_method(cImage, "image_rep", image_image_rep, 0);
175
+ rb_define_method(cImage, "transformation", image_transformation, 0);
176
+ rb_define_method(cImage, "transformation=", image_set_transformation, 1);
177
+ rb_define_method(cImage, "transform!", image_transform_bang, 1);
178
+ rb_define_method(cImage, "origin", image_origin, 0);
179
+ rb_define_method(cImage, "origin=", image_set_origin, 1);
180
+ rb_define_method(cImage, "normal", image_normal, 0);
181
+ rb_define_method(cImage, "zrotation", image_zrotation, 0);
182
+ }