scriptup 2026.0.1 → 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.
- checksums.yaml +4 -4
- data/README.md +43 -24
- data/ext/arc_curve.c +50 -0
- data/ext/attribute_dictionaries.c +49 -32
- data/ext/attribute_dictionary.c +54 -127
- data/ext/axes.c +79 -0
- data/ext/behavior.c +100 -9
- data/ext/bounding_box.c +195 -0
- data/ext/camera.c +178 -0
- data/ext/classifications.c +85 -0
- data/ext/color.c +91 -163
- data/ext/component_definition.c +78 -162
- data/ext/component_instance.c +88 -9
- data/ext/construction.c +59 -0
- data/ext/curve.c +87 -0
- data/ext/definition_list.c +89 -109
- data/ext/depend +1 -0
- data/ext/drawing_element.c +96 -117
- data/ext/edge.c +147 -0
- data/ext/edge_use.c +37 -0
- data/ext/entities.c +573 -16
- data/ext/entities_builder.c +145 -0
- data/ext/entity.c +175 -215
- data/ext/environments.c +149 -0
- data/ext/extconf.rb +54 -10
- data/ext/face.c +331 -0
- data/ext/geom.c +172 -0
- data/ext/group.c +86 -0
- data/ext/helpers.c +244 -0
- data/ext/image.c +182 -0
- data/ext/image_rep.c +158 -0
- data/ext/instance_path.c +185 -0
- data/ext/lat_long.c +88 -0
- data/ext/layer.c +98 -0
- data/ext/layer_folder.c +99 -0
- data/ext/layers.c +122 -0
- data/ext/length.c +253 -0
- data/ext/line_styles.c +60 -0
- data/ext/loop.c +24 -0
- data/ext/material.c +144 -197
- data/ext/materials.c +49 -60
- data/ext/model.c +232 -26
- data/ext/options_store.c +188 -0
- data/ext/page.c +168 -0
- data/ext/pages.c +135 -0
- data/ext/point2d.c +195 -0
- data/ext/point3d.c +340 -0
- data/ext/polygon_mesh.c +253 -0
- data/ext/scriptup.h +279 -0
- data/ext/section_plane.c +44 -0
- data/ext/sketchup.c +102 -76
- data/ext/styles.c +91 -0
- data/ext/text.c +135 -0
- data/ext/texture.c +74 -83
- data/ext/texture_writer.c +104 -0
- data/ext/transformation.c +309 -0
- data/ext/transformation2d.c +190 -0
- data/ext/uv_helper.c +41 -0
- data/ext/vector2d.c +238 -0
- data/ext/vector3d.c +294 -0
- data/ext/vertex.c +67 -0
- data/lib/sketchup.rb +2 -2
- data/sig/_top_level.rbs +188 -0
- data/sig/array.rbs +52 -0
- data/sig/geom/bounding_box.rbs +28 -0
- data/sig/geom/bounds2d.rbs +20 -0
- data/sig/geom/lat_long.rbs +13 -0
- data/sig/geom/oriented_bounds2d.rbs +10 -0
- data/sig/geom/point2d.rbs +32 -0
- data/sig/geom/point3d.rbs +46 -0
- data/sig/geom/polygon_mesh.rbs +35 -0
- data/sig/geom/transformation.rbs +44 -0
- data/sig/geom/transformation2d.rbs +26 -0
- data/sig/geom/utm.rbs +14 -0
- data/sig/geom/vector2d.rbs +40 -0
- data/sig/geom/vector3d.rbs +49 -0
- data/sig/geom.rbs +25 -0
- data/sig/language_handler.rbs +8 -0
- data/sig/layout/angular_dimension.rbs +32 -0
- data/sig/layout/auto_text_definition.rbs +73 -0
- data/sig/layout/auto_text_definitions.rbs +15 -0
- data/sig/layout/connection_point.rbs +6 -0
- data/sig/layout/dictionary.rbs +18 -0
- data/sig/layout/document.rbs +61 -0
- data/sig/layout/ellipse.rbs +5 -0
- data/sig/layout/entities.rbs +10 -0
- data/sig/layout/entity.rbs +28 -0
- data/sig/layout/formatted_text.rbs +30 -0
- data/sig/layout/grid.rbs +24 -0
- data/sig/layout/group.rbs +17 -0
- data/sig/layout/image.rbs +7 -0
- data/sig/layout/label.rbs +31 -0
- data/sig/layout/layer.rbs +21 -0
- data/sig/layout/layer_instance.rbs +9 -0
- data/sig/layout/layers.rbs +18 -0
- data/sig/layout/linear_dimension.rbs +39 -0
- data/sig/layout/locked_entity_error.rbs +4 -0
- data/sig/layout/locked_layer_error.rbs +4 -0
- data/sig/layout/page.rbs +20 -0
- data/sig/layout/page_info.rbs +37 -0
- data/sig/layout/pages.rbs +17 -0
- data/sig/layout/path.rbs +34 -0
- data/sig/layout/rectangle.rbs +15 -0
- data/sig/layout/reference_entity.rbs +7 -0
- data/sig/layout/sketch_up_model.rbs +54 -0
- data/sig/layout/style.rbs +150 -0
- data/sig/layout/table.rbs +17 -0
- data/sig/layout/table_cell.rbs +13 -0
- data/sig/layout/table_column.rbs +10 -0
- data/sig/layout/table_row.rbs +10 -0
- data/sig/layout.rbs +4 -0
- data/sig/length.rbs +37 -0
- data/sig/numeric.rbs +23 -0
- data/sig/sketchup/animation.rbs +8 -0
- data/sig/sketchup/app_observer.rbs +11 -0
- data/sig/sketchup/arc_curve.rbs +14 -0
- data/sig/sketchup/attribute_dictionaries.rbs +11 -0
- data/sig/sketchup/attribute_dictionary.rbs +18 -0
- data/sig/sketchup/axes.rbs +13 -0
- data/sig/sketchup/behavior.rbs +19 -0
- data/sig/sketchup/camera.rbs +33 -0
- data/sig/sketchup/classification_schema.rbs +8 -0
- data/sig/sketchup/classifications.rbs +12 -0
- data/sig/sketchup/color.rbs +22 -0
- data/sig/sketchup/component_definition.rbs +43 -0
- data/sig/sketchup/component_instance.rbs +32 -0
- data/sig/sketchup/console.rbs +8 -0
- data/sig/sketchup/construction_line.rbs +17 -0
- data/sig/sketchup/construction_point.rbs +5 -0
- data/sig/sketchup/curve.rbs +13 -0
- data/sig/sketchup/definition_list.rbs +26 -0
- data/sig/sketchup/definition_observer.rbs +6 -0
- data/sig/sketchup/definitions_observer.rbs +8 -0
- data/sig/sketchup/dimension.rbs +18 -0
- data/sig/sketchup/dimension_linear.rbs +24 -0
- data/sig/sketchup/dimension_observer.rbs +5 -0
- data/sig/sketchup/dimension_radial.rbs +9 -0
- data/sig/sketchup/drawingelement.rbs +18 -0
- data/sig/sketchup/edge.rbs +24 -0
- data/sig/sketchup/edge_use.rbs +13 -0
- data/sig/sketchup/entities.rbs +61 -0
- data/sig/sketchup/entities_builder.rbs +15 -0
- data/sig/sketchup/entities_observer.rbs +9 -0
- data/sig/sketchup/entity.rbs +21 -0
- data/sig/sketchup/entity_observer.rbs +6 -0
- data/sig/sketchup/environment.rbs +25 -0
- data/sig/sketchup/environments.rbs +18 -0
- data/sig/sketchup/environments_observer.rbs +8 -0
- data/sig/sketchup/extensions_manager.rbs +11 -0
- data/sig/sketchup/face.rbs +44 -0
- data/sig/sketchup/frame_change_observer.rbs +5 -0
- data/sig/sketchup/group.rbs +38 -0
- data/sig/sketchup/http/request.rbs +17 -0
- data/sig/sketchup/http/response.rbs +7 -0
- data/sig/sketchup/http.rbs +27 -0
- data/sig/sketchup/image.rbs +23 -0
- data/sig/sketchup/image_rep.rbs +17 -0
- data/sig/sketchup/importer.rbs +14 -0
- data/sig/sketchup/input_point.rbs +25 -0
- data/sig/sketchup/instance_observer.rbs +6 -0
- data/sig/sketchup/instance_path.rbs +20 -0
- data/sig/sketchup/layer.rbs +20 -0
- data/sig/sketchup/layer_folder.rbs +26 -0
- data/sig/sketchup/layers.rbs +30 -0
- data/sig/sketchup/layers_observer.rbs +13 -0
- data/sig/sketchup/licensing/extension_license.rbs +8 -0
- data/sig/sketchup/licensing.rbs +15 -0
- data/sig/sketchup/line_style.rbs +5 -0
- data/sig/sketchup/line_styles.rbs +13 -0
- data/sig/sketchup/load_handler.rbs +8 -0
- data/sig/sketchup/loop.rbs +10 -0
- data/sig/sketchup/material.rbs +74 -0
- data/sig/sketchup/materials.rbs +22 -0
- data/sig/sketchup/materials_observer.rbs +10 -0
- data/sig/sketchup/menu.rbs +9 -0
- data/sig/sketchup/model.rbs +105 -0
- data/sig/sketchup/model_observer.rbs +23 -0
- data/sig/sketchup/options_manager.rbs +12 -0
- data/sig/sketchup/options_provider.rbs +23 -0
- data/sig/sketchup/options_provider_observer.rbs +5 -0
- data/sig/sketchup/overlay.rbs +21 -0
- data/sig/sketchup/overlays_manager.rbs +10 -0
- data/sig/sketchup/page.rbs +55 -0
- data/sig/sketchup/pages.rbs +25 -0
- data/sig/sketchup/pages_observer.rbs +7 -0
- data/sig/sketchup/pick_helper.rbs +28 -0
- data/sig/sketchup/regional_settings.rbs +7 -0
- data/sig/sketchup/rendering_options.rbs +89 -0
- data/sig/sketchup/rendering_options_observer.rbs +5 -0
- data/sig/sketchup/section_plane.rbs +12 -0
- data/sig/sketchup/selection.rbs +31 -0
- data/sig/sketchup/selection_observer.rbs +8 -0
- data/sig/sketchup/set.rbs +15 -0
- data/sig/sketchup/shadow_info.rbs +18 -0
- data/sig/sketchup/shadow_info_observer.rbs +5 -0
- data/sig/sketchup/skp.rbs +5 -0
- data/sig/sketchup/snap.rbs +10 -0
- data/sig/sketchup/style.rbs +9 -0
- data/sig/sketchup/styles.rbs +21 -0
- data/sig/sketchup/text.rbs +22 -0
- data/sig/sketchup/texture.rbs +14 -0
- data/sig/sketchup/texture_writer.rbs +14 -0
- data/sig/sketchup/tool.rbs +45 -0
- data/sig/sketchup/tools.rbs +14 -0
- data/sig/sketchup/tools_observer.rbs +6 -0
- data/sig/sketchup/uv_helper.rbs +6 -0
- data/sig/sketchup/vertex.rbs +11 -0
- data/sig/sketchup/view.rbs +87 -0
- data/sig/sketchup/view_observer.rbs +6 -0
- data/sig/sketchup.rbs +137 -0
- data/sig/sketchup_extension.rbs +23 -0
- data/sig/string.rbs +5 -0
- data/sig/ui/command.rbs +20 -0
- data/sig/ui/html_dialog.rbs +29 -0
- data/sig/ui/notification.rbs +16 -0
- data/sig/ui/toolbar.rbs +18 -0
- data/sig/ui/web_dialog.rbs +38 -0
- data/sig/ui.rbs +66 -0
- metadata +204 -287
- data/ext/attribute_dictionaries.h +0 -8
- data/ext/attribute_dictionary.h +0 -8
- data/ext/behavior.h +0 -8
- data/ext/color.h +0 -8
- data/ext/component_definition.h +0 -8
- data/ext/component_instance.h +0 -8
- data/ext/definition_list.h +0 -8
- data/ext/drawing_element.h +0 -8
- data/ext/entities.h +0 -8
- data/ext/entity.h +0 -8
- data/ext/material.h +0 -8
- data/ext/materials.h +0 -8
- data/ext/model.h +0 -8
- data/ext/not_implemented.c +0 -88
- data/ext/not_implemented.h +0 -20
- data/ext/sketchup.h +0 -9
- data/ext/texture.h +0 -8
- data/ext/typed_value.c +0 -84
- data/ext/typed_value.h +0 -11
- data/ext/utils.h +0 -111
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Frameworks/libCommonGeometry.dylib +0 -0
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Frameworks/libCommonGeoutils.dylib +0 -0
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Frameworks/libCommonImage.dylib +0 -4
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Frameworks/libCommonPreferences.dylib +0 -0
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Frameworks/libCommonUnits.dylib +0 -0
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Frameworks/libCommonUtils.dylib +0 -0
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Frameworks/libCommonZip.dylib +0 -0
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/application/application.h +0 -36
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/application/model.h +0 -59
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/application/overlay.h +0 -262
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/application/ruby_api.h +0 -118
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/color.h +0 -107
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/common.h +0 -178
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/defs.h +0 -19
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/extension_license.h +0 -70
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/geometry/bounding_box.h +0 -34
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/geometry/plane3d.h +0 -153
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/geometry/point2d.h +0 -96
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/geometry/point3d.h +0 -98
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/geometry/ray3d.h +0 -64
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/geometry/transformation.h +0 -321
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/geometry/transformation2d.h +0 -163
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/geometry/vector2d.h +0 -235
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/geometry/vector3d.h +0 -285
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/geometry.h +0 -154
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/import_export/modelexporterplugin.h +0 -165
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/import_export/modelimporterplugin.h +0 -187
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/import_export/pluginprogresscallback.h +0 -84
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/initialize.h +0 -43
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/length_formatter.h +0 -424
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/arccurve.h +0 -244
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/arrow_type.h +0 -17
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/attribute_dictionary.h +0 -161
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/axes.h +0 -242
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/camera.h +0 -398
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/classification_attribute.h +0 -89
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/classification_info.h +0 -125
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/classifications.h +0 -86
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/component_definition.h +0 -629
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/component_definition_snap_to_behavior_private.h +0 -46
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/component_instance.h +0 -344
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/curve.h +0 -143
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/defs.h +0 -147
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/dimension.h +0 -224
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/dimension_linear.h +0 -421
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/dimension_radial.h +0 -194
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/dimension_style.h +0 -253
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/drawing_element.h +0 -198
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/dynamic_component_attribute.h +0 -92
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/dynamic_component_info.h +0 -70
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/edge.h +0 -271
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/edge_use.h +0 -214
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/entities.h +0 -879
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/entity.h +0 -189
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/entity_list.h +0 -80
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/entity_list_iterator.h +0 -90
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/environment.h +0 -382
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/environments.h +0 -133
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/face.h +0 -702
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/font.h +0 -138
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/geometry.h +0 -20
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/geometry_input.h +0 -695
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/group.h +0 -245
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/guide_line.h +0 -155
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/guide_point.h +0 -153
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/image.h +0 -289
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/image_rep.h +0 -275
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/instancepath.h +0 -266
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/layer.h +0 -265
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/layer_folder.h +0 -301
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/line_style.h +0 -211
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/line_styles.h +0 -81
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/location.h +0 -65
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/loop.h +0 -182
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/material.h +0 -797
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/mesh_helper.h +0 -187
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/model.h +0 -1826
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/model_entity_type_private.h +0 -44
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/model_version.h +0 -49
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/opening.h +0 -72
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/options_manager.h +0 -79
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/options_provider.h +0 -166
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/polyline3d.h +0 -140
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/rendering_options.h +0 -180
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/scene.h +0 -1016
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/schema.h +0 -56
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/schema_type.h +0 -26
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/section_plane.h +0 -212
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/selection.h +0 -156
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/shadow_info.h +0 -147
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/skp.h +0 -45
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/snap.h +0 -183
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/space.h +0 -26
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/style.h +0 -303
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/styles.h +0 -192
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/text.h +0 -392
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/texture.h +0 -380
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/texture_writer.h +0 -280
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/typed_value.h +0 -390
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/uv_helper.h +0 -79
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/vertex.h +0 -154
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/sketchup.h +0 -125
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/sketchup_info.h +0 -65
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/slapi.h +0 -16
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/transformation.h +0 -16
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/unicodestring.h +0 -239
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/utils/math_helpers.h +0 -124
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Resources/Info.plist +0 -50
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/SketchUpAPI +0 -0
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/_CodeSignature/CodeResources +0 -891
- data/sketchup-sdk-win/binaries/layout/x64/LayOutAPI.dll +0 -0
- data/sketchup-sdk-win/binaries/layout/x64/LayOutAPI.lib +0 -0
- data/sketchup-sdk-win/binaries/layout/x64/LayOutControllers.dll +0 -0
- data/sketchup-sdk-win/binaries/layout/x64/LayOutModel.dll +0 -0
- data/sketchup-sdk-win/binaries/layout/x64/LayOutRTF.dll +0 -0
- data/sketchup-sdk-win/binaries/layout/x64/LayOutUtils.dll +0 -0
- data/sketchup-sdk-win/binaries/layout/x64/LayOutView.dll +0 -4
- data/sketchup-sdk-win/binaries/layout/x64/SketchUpCommonPreferences.dll +0 -0
- data/sketchup-sdk-win/binaries/layout/x64/SketchUpViewerAPI.dll +0 -0
- data/sketchup-sdk-win/binaries/layout/x64/SketchUpViewerAPI.lib +0 -0
- data/sketchup-sdk-win/binaries/layout/x64/pdflib.dll +0 -0
- data/sketchup-sdk-win/binaries/sketchup/x64/SketchUpAPI.dll +0 -0
- data/sketchup-sdk-win/binaries/sketchup/x64/SketchUpAPI.lib +0 -0
- data/sketchup-sdk-win/binaries/sketchup/x64/SketchUpCommonPreferences.dll +0 -0
- data/sketchup-sdk-win/binaries/sketchup/x64/sketchup.lib +0 -0
- data/sketchup-sdk-win/headers/LayOutAPI/application/application.h +0 -117
- data/sketchup-sdk-win/headers/LayOutAPI/common.h +0 -22
- data/sketchup-sdk-win/headers/LayOutAPI/geometry/geometry.h +0 -78
- data/sketchup-sdk-win/headers/LayOutAPI/initialize.h +0 -36
- data/sketchup-sdk-win/headers/LayOutAPI/layout.h +0 -49
- data/sketchup-sdk-win/headers/LayOutAPI/model/angulardimension.h +0 -468
- data/sketchup-sdk-win/headers/LayOutAPI/model/autotextdefinition.h +0 -569
- data/sketchup-sdk-win/headers/LayOutAPI/model/autotextdefinitionlist.h +0 -79
- data/sketchup-sdk-win/headers/LayOutAPI/model/connectionpoint.h +0 -107
- data/sketchup-sdk-win/headers/LayOutAPI/model/defs.h +0 -42
- data/sketchup-sdk-win/headers/LayOutAPI/model/dictionary.h +0 -120
- data/sketchup-sdk-win/headers/LayOutAPI/model/document.h +0 -937
- data/sketchup-sdk-win/headers/LayOutAPI/model/documentexportoptions.h +0 -78
- data/sketchup-sdk-win/headers/LayOutAPI/model/ellipse.h +0 -78
- data/sketchup-sdk-win/headers/LayOutAPI/model/entity.h +0 -402
- data/sketchup-sdk-win/headers/LayOutAPI/model/entityiterator.h +0 -49
- data/sketchup-sdk-win/headers/LayOutAPI/model/entitylist.h +0 -114
- data/sketchup-sdk-win/headers/LayOutAPI/model/formattedtext.h +0 -397
- data/sketchup-sdk-win/headers/LayOutAPI/model/grid.h +0 -251
- data/sketchup-sdk-win/headers/LayOutAPI/model/group.h +0 -244
- data/sketchup-sdk-win/headers/LayOutAPI/model/image.h +0 -146
- data/sketchup-sdk-win/headers/LayOutAPI/model/imagerep.h +0 -109
- data/sketchup-sdk-win/headers/LayOutAPI/model/label.h +0 -332
- data/sketchup-sdk-win/headers/LayOutAPI/model/layer.h +0 -207
- data/sketchup-sdk-win/headers/LayOutAPI/model/layerinstance.h +0 -117
- data/sketchup-sdk-win/headers/LayOutAPI/model/layerlist.h +0 -69
- data/sketchup-sdk-win/headers/LayOutAPI/model/lineardimension.h +0 -508
- data/sketchup-sdk-win/headers/LayOutAPI/model/page.h +0 -331
- data/sketchup-sdk-win/headers/LayOutAPI/model/pageinfo.h +0 -372
- data/sketchup-sdk-win/headers/LayOutAPI/model/pagelist.h +0 -81
- data/sketchup-sdk-win/headers/LayOutAPI/model/path.h +0 -464
- data/sketchup-sdk-win/headers/LayOutAPI/model/rectangle.h +0 -240
- data/sketchup-sdk-win/headers/LayOutAPI/model/referenceentity.h +0 -120
- data/sketchup-sdk-win/headers/LayOutAPI/model/sketchupmodel.h +0 -681
- data/sketchup-sdk-win/headers/LayOutAPI/model/style.h +0 -1116
- data/sketchup-sdk-win/headers/LayOutAPI/model/table.h +0 -472
- data/sketchup-sdk-win/headers/LayOutAPI/model/typed_value.h +0 -180
- data/sketchup-sdk-win/headers/SketchUpAPI/application/application.h +0 -36
- data/sketchup-sdk-win/headers/SketchUpAPI/application/model.h +0 -59
- data/sketchup-sdk-win/headers/SketchUpAPI/application/overlay.h +0 -262
- data/sketchup-sdk-win/headers/SketchUpAPI/application/ruby_api.h +0 -118
- data/sketchup-sdk-win/headers/SketchUpAPI/color.h +0 -107
- data/sketchup-sdk-win/headers/SketchUpAPI/common.h +0 -178
- data/sketchup-sdk-win/headers/SketchUpAPI/defs.h +0 -19
- data/sketchup-sdk-win/headers/SketchUpAPI/extension_license.h +0 -70
- data/sketchup-sdk-win/headers/SketchUpAPI/geometry/bounding_box.h +0 -34
- data/sketchup-sdk-win/headers/SketchUpAPI/geometry/plane3d.h +0 -153
- data/sketchup-sdk-win/headers/SketchUpAPI/geometry/point2d.h +0 -96
- data/sketchup-sdk-win/headers/SketchUpAPI/geometry/point3d.h +0 -98
- data/sketchup-sdk-win/headers/SketchUpAPI/geometry/ray3d.h +0 -64
- data/sketchup-sdk-win/headers/SketchUpAPI/geometry/transformation.h +0 -321
- data/sketchup-sdk-win/headers/SketchUpAPI/geometry/transformation2d.h +0 -163
- data/sketchup-sdk-win/headers/SketchUpAPI/geometry/vector2d.h +0 -235
- data/sketchup-sdk-win/headers/SketchUpAPI/geometry/vector3d.h +0 -285
- data/sketchup-sdk-win/headers/SketchUpAPI/geometry.h +0 -154
- data/sketchup-sdk-win/headers/SketchUpAPI/import_export/modelexporterplugin.h +0 -165
- data/sketchup-sdk-win/headers/SketchUpAPI/import_export/modelimporterplugin.h +0 -187
- data/sketchup-sdk-win/headers/SketchUpAPI/import_export/pluginprogresscallback.h +0 -84
- data/sketchup-sdk-win/headers/SketchUpAPI/initialize.h +0 -43
- data/sketchup-sdk-win/headers/SketchUpAPI/length_formatter.h +0 -424
- data/sketchup-sdk-win/headers/SketchUpAPI/model/arccurve.h +0 -244
- data/sketchup-sdk-win/headers/SketchUpAPI/model/arrow_type.h +0 -17
- data/sketchup-sdk-win/headers/SketchUpAPI/model/attribute_dictionary.h +0 -161
- data/sketchup-sdk-win/headers/SketchUpAPI/model/axes.h +0 -242
- data/sketchup-sdk-win/headers/SketchUpAPI/model/camera.h +0 -398
- data/sketchup-sdk-win/headers/SketchUpAPI/model/classification_attribute.h +0 -89
- data/sketchup-sdk-win/headers/SketchUpAPI/model/classification_info.h +0 -125
- data/sketchup-sdk-win/headers/SketchUpAPI/model/classifications.h +0 -86
- data/sketchup-sdk-win/headers/SketchUpAPI/model/component_definition.h +0 -629
- data/sketchup-sdk-win/headers/SketchUpAPI/model/component_definition_snap_to_behavior_private.h +0 -46
- data/sketchup-sdk-win/headers/SketchUpAPI/model/component_instance.h +0 -344
- data/sketchup-sdk-win/headers/SketchUpAPI/model/curve.h +0 -143
- data/sketchup-sdk-win/headers/SketchUpAPI/model/defs.h +0 -147
- data/sketchup-sdk-win/headers/SketchUpAPI/model/dimension.h +0 -224
- data/sketchup-sdk-win/headers/SketchUpAPI/model/dimension_linear.h +0 -421
- data/sketchup-sdk-win/headers/SketchUpAPI/model/dimension_radial.h +0 -194
- data/sketchup-sdk-win/headers/SketchUpAPI/model/dimension_style.h +0 -253
- data/sketchup-sdk-win/headers/SketchUpAPI/model/drawing_element.h +0 -198
- data/sketchup-sdk-win/headers/SketchUpAPI/model/dynamic_component_attribute.h +0 -92
- data/sketchup-sdk-win/headers/SketchUpAPI/model/dynamic_component_info.h +0 -70
- data/sketchup-sdk-win/headers/SketchUpAPI/model/edge.h +0 -271
- data/sketchup-sdk-win/headers/SketchUpAPI/model/edge_use.h +0 -214
- data/sketchup-sdk-win/headers/SketchUpAPI/model/entities.h +0 -879
- data/sketchup-sdk-win/headers/SketchUpAPI/model/entity.h +0 -189
- data/sketchup-sdk-win/headers/SketchUpAPI/model/entity_list.h +0 -80
- data/sketchup-sdk-win/headers/SketchUpAPI/model/entity_list_iterator.h +0 -90
- data/sketchup-sdk-win/headers/SketchUpAPI/model/environment.h +0 -382
- data/sketchup-sdk-win/headers/SketchUpAPI/model/environments.h +0 -133
- data/sketchup-sdk-win/headers/SketchUpAPI/model/face.h +0 -702
- data/sketchup-sdk-win/headers/SketchUpAPI/model/font.h +0 -138
- data/sketchup-sdk-win/headers/SketchUpAPI/model/geometry.h +0 -20
- data/sketchup-sdk-win/headers/SketchUpAPI/model/geometry_input.h +0 -695
- data/sketchup-sdk-win/headers/SketchUpAPI/model/group.h +0 -245
- data/sketchup-sdk-win/headers/SketchUpAPI/model/guide_line.h +0 -155
- data/sketchup-sdk-win/headers/SketchUpAPI/model/guide_point.h +0 -153
- data/sketchup-sdk-win/headers/SketchUpAPI/model/image.h +0 -289
- data/sketchup-sdk-win/headers/SketchUpAPI/model/image_rep.h +0 -275
- data/sketchup-sdk-win/headers/SketchUpAPI/model/instancepath.h +0 -266
- data/sketchup-sdk-win/headers/SketchUpAPI/model/layer.h +0 -265
- data/sketchup-sdk-win/headers/SketchUpAPI/model/layer_folder.h +0 -301
- data/sketchup-sdk-win/headers/SketchUpAPI/model/line_style.h +0 -211
- data/sketchup-sdk-win/headers/SketchUpAPI/model/line_styles.h +0 -81
- data/sketchup-sdk-win/headers/SketchUpAPI/model/location.h +0 -65
- data/sketchup-sdk-win/headers/SketchUpAPI/model/loop.h +0 -182
- data/sketchup-sdk-win/headers/SketchUpAPI/model/material.h +0 -797
- data/sketchup-sdk-win/headers/SketchUpAPI/model/mesh_helper.h +0 -187
- data/sketchup-sdk-win/headers/SketchUpAPI/model/model.h +0 -1826
- data/sketchup-sdk-win/headers/SketchUpAPI/model/model_entity_type_private.h +0 -44
- data/sketchup-sdk-win/headers/SketchUpAPI/model/model_version.h +0 -49
- data/sketchup-sdk-win/headers/SketchUpAPI/model/opening.h +0 -72
- data/sketchup-sdk-win/headers/SketchUpAPI/model/options_manager.h +0 -79
- data/sketchup-sdk-win/headers/SketchUpAPI/model/options_provider.h +0 -166
- data/sketchup-sdk-win/headers/SketchUpAPI/model/polyline3d.h +0 -140
- data/sketchup-sdk-win/headers/SketchUpAPI/model/rendering_options.h +0 -180
- data/sketchup-sdk-win/headers/SketchUpAPI/model/scene.h +0 -1016
- data/sketchup-sdk-win/headers/SketchUpAPI/model/schema.h +0 -56
- data/sketchup-sdk-win/headers/SketchUpAPI/model/schema_type.h +0 -26
- data/sketchup-sdk-win/headers/SketchUpAPI/model/section_plane.h +0 -212
- data/sketchup-sdk-win/headers/SketchUpAPI/model/selection.h +0 -156
- data/sketchup-sdk-win/headers/SketchUpAPI/model/shadow_info.h +0 -147
- data/sketchup-sdk-win/headers/SketchUpAPI/model/skp.h +0 -45
- data/sketchup-sdk-win/headers/SketchUpAPI/model/snap.h +0 -183
- data/sketchup-sdk-win/headers/SketchUpAPI/model/space.h +0 -26
- data/sketchup-sdk-win/headers/SketchUpAPI/model/style.h +0 -303
- data/sketchup-sdk-win/headers/SketchUpAPI/model/styles.h +0 -192
- data/sketchup-sdk-win/headers/SketchUpAPI/model/text.h +0 -392
- data/sketchup-sdk-win/headers/SketchUpAPI/model/texture.h +0 -380
- data/sketchup-sdk-win/headers/SketchUpAPI/model/texture_writer.h +0 -280
- data/sketchup-sdk-win/headers/SketchUpAPI/model/typed_value.h +0 -390
- data/sketchup-sdk-win/headers/SketchUpAPI/model/uv_helper.h +0 -79
- data/sketchup-sdk-win/headers/SketchUpAPI/model/vertex.h +0 -154
- data/sketchup-sdk-win/headers/SketchUpAPI/sketchup.h +0 -125
- data/sketchup-sdk-win/headers/SketchUpAPI/sketchup_info.h +0 -65
- data/sketchup-sdk-win/headers/SketchUpAPI/slapi.h +0 -16
- data/sketchup-sdk-win/headers/SketchUpAPI/transformation.h +0 -16
- data/sketchup-sdk-win/headers/SketchUpAPI/unicodestring.h +0 -239
- data/sketchup-sdk-win/headers/SketchUpAPI/utils/math_helpers.h +0 -124
data/ext/pages.c
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
#include <scriptup.h>
|
|
2
|
+
|
|
3
|
+
#define MODEL(self) SU_REF(SUModelRef, self)
|
|
4
|
+
|
|
5
|
+
DEFINE_REF_LIST(pages_list, SUModelRef, SUModelGetNumScenes, SUModelGetScenes, SUSceneRef, cPage)
|
|
6
|
+
|
|
7
|
+
static VALUE pages_to_a(VALUE self) { return pages_list(MODEL(self)); }
|
|
8
|
+
static VALUE pages_each(VALUE self) { su_yield_each(self, pages_to_a(self)); return Qnil; }
|
|
9
|
+
|
|
10
|
+
static VALUE pages_length(VALUE self)
|
|
11
|
+
{
|
|
12
|
+
size_t count = 0;
|
|
13
|
+
SUModelGetNumScenes(MODEL(self), &count);
|
|
14
|
+
return SIZET2NUM(count);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static VALUE pages_aref(VALUE self, VALUE key)
|
|
18
|
+
{
|
|
19
|
+
if (RB_TYPE_P(key, T_STRING))
|
|
20
|
+
{
|
|
21
|
+
SUSceneRef scene = SU_INVALID;
|
|
22
|
+
SUModelGetSceneWithName(MODEL(self), StringValueCStr(key), &scene);
|
|
23
|
+
return su_wrap_or_nil(cPage, scene.ptr);
|
|
24
|
+
}
|
|
25
|
+
return rb_ary_entry(pages_to_a(self), NUM2LONG(key));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
static VALUE pages_unique_name(VALUE self, VALUE base)
|
|
29
|
+
{
|
|
30
|
+
StringValue(base);
|
|
31
|
+
VALUE pages = pages_to_a(self);
|
|
32
|
+
VALUE candidate = base;
|
|
33
|
+
for (long n = 1; !NIL_P(su_find_by(pages, "name", candidate)); n++)
|
|
34
|
+
candidate = rb_sprintf("%"PRIsVALUE" (%ld)", base, n);
|
|
35
|
+
return candidate;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
static VALUE pages_add(int argc, VALUE* argv, VALUE self)
|
|
39
|
+
{
|
|
40
|
+
VALUE name, flags, index;
|
|
41
|
+
rb_scan_args(argc, argv, "03", &name, &flags, &index);
|
|
42
|
+
VALUE unique = pages_unique_name(self, NIL_P(name) ? rb_str_new_cstr("Scene") : name);
|
|
43
|
+
SUSceneRef scene = SU_INVALID;
|
|
44
|
+
SUSceneCreate(&scene);
|
|
45
|
+
SUSceneSetName(scene, StringValueCStr(unique));
|
|
46
|
+
if (!NIL_P(flags))
|
|
47
|
+
SUSceneSetFlags(scene, NUM2UINT(flags));
|
|
48
|
+
int out_index = 0;
|
|
49
|
+
enum SUResult result = SUModelAddScene(MODEL(self), NIL_P(index) ? -1 : NUM2INT(index), scene, &out_index);
|
|
50
|
+
if (result != SU_ERROR_NONE)
|
|
51
|
+
{
|
|
52
|
+
SUSceneRelease(&scene);
|
|
53
|
+
rb_raise(rb_eArgError, "cannot add the page (error %d)", result);
|
|
54
|
+
}
|
|
55
|
+
// Return the model's own scene: on Windows it isn't the ref that was added.
|
|
56
|
+
SUSceneRef added = SU_INVALID;
|
|
57
|
+
SUModelGetSceneWithName(MODEL(self), StringValueCStr(unique), &added);
|
|
58
|
+
return su_wrap(cPage, SUIsValid(added) ? added.ptr : scene.ptr);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
static VALUE pages_add_matchphoto_page(int argc, VALUE* argv, VALUE self)
|
|
62
|
+
{
|
|
63
|
+
VALUE image, camera, name;
|
|
64
|
+
rb_scan_args(argc, argv, "12", &image, &camera, &name);
|
|
65
|
+
SUCameraRef cam = {NIL_P(camera) ? NULL : su_unwrap(camera, cCamera)};
|
|
66
|
+
SUCameraRef created = SU_INVALID;
|
|
67
|
+
if (SUIsInvalid(cam))
|
|
68
|
+
{
|
|
69
|
+
SUCameraCreate(&created);
|
|
70
|
+
cam = created;
|
|
71
|
+
}
|
|
72
|
+
VALUE unique = pages_unique_name(self, NIL_P(name) ? rb_str_new_cstr("Photo") : name);
|
|
73
|
+
SUSceneRef scene = SU_INVALID;
|
|
74
|
+
enum SUResult result = SUModelAddMatchPhotoScene(MODEL(self), StringValueCStr(image), cam, StringValueCStr(unique), &scene);
|
|
75
|
+
if (SUIsValid(created))
|
|
76
|
+
SUCameraRelease(&created);
|
|
77
|
+
if (result != SU_ERROR_NONE)
|
|
78
|
+
rb_raise(rb_eArgError, "cannot add a match photo page from %"PRIsVALUE, image);
|
|
79
|
+
return su_wrap(cPage, scene.ptr);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
static VALUE pages_erase(VALUE self, VALUE page)
|
|
83
|
+
{
|
|
84
|
+
SUSceneRef scene = {su_unwrap(page, cPage)};
|
|
85
|
+
return BOOL2RB(SUModelRemoveScenes(MODEL(self), 1, &scene) == SU_ERROR_NONE);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
static VALUE pages_reorder(VALUE self, VALUE page, VALUE index)
|
|
89
|
+
{
|
|
90
|
+
if (SUModelReorderScene(MODEL(self), (SUSceneRef){su_unwrap(page, cPage)}, NUM2SIZET(index)) != SU_ERROR_NONE)
|
|
91
|
+
rb_raise(rb_eArgError, "invalid page index");
|
|
92
|
+
return Qnil;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
static VALUE pages_selected_page(VALUE self)
|
|
96
|
+
{
|
|
97
|
+
SUSceneRef scene = SU_INVALID;
|
|
98
|
+
SUModelGetActiveScene(MODEL(self), &scene);
|
|
99
|
+
return su_wrap_or_nil(cPage, scene.ptr);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
static VALUE pages_set_selected_page(VALUE self, VALUE page)
|
|
103
|
+
{
|
|
104
|
+
return BOOL2RB(SUModelSetActiveScene(MODEL(self), (SUSceneRef){su_unwrap(page, cPage)}) == SU_ERROR_NONE);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
static VALUE pages_parent(VALUE self)
|
|
108
|
+
{
|
|
109
|
+
return su_wrap(cModel, DATA_PTR(self));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Model#pages
|
|
113
|
+
static VALUE model_pages(VALUE model)
|
|
114
|
+
{
|
|
115
|
+
return su_wrap(cPages, DATA_PTR(model));
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
void Init_pages(void)
|
|
119
|
+
{
|
|
120
|
+
rb_include_module(cPages, rb_mEnumerable);
|
|
121
|
+
rb_define_method(cPages, "each", pages_each, 0);
|
|
122
|
+
rb_define_method(cPages, "[]", pages_aref, 1);
|
|
123
|
+
rb_define_method(cPages, "count", pages_length, 0);
|
|
124
|
+
rb_define_method(cPages, "length", pages_length, 0);
|
|
125
|
+
rb_define_method(cPages, "size", pages_length, 0);
|
|
126
|
+
rb_define_method(cPages, "add", pages_add, -1);
|
|
127
|
+
rb_define_method(cPages, "add_matchphoto_page", pages_add_matchphoto_page, -1);
|
|
128
|
+
rb_define_method(cPages, "erase", pages_erase, 1);
|
|
129
|
+
rb_define_method(cPages, "reorder", pages_reorder, 2);
|
|
130
|
+
rb_define_method(cPages, "selected_page", pages_selected_page, 0);
|
|
131
|
+
rb_define_method(cPages, "selected_page=", pages_set_selected_page, 1);
|
|
132
|
+
rb_define_method(cPages, "unique_name", pages_unique_name, 1);
|
|
133
|
+
rb_define_method(cPages, "parent", pages_parent, 0);
|
|
134
|
+
rb_define_method(cModel, "pages", model_pages, 0);
|
|
135
|
+
}
|
data/ext/point2d.c
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
#include <scriptup.h>
|
|
2
|
+
|
|
3
|
+
#define PT(obj) ((struct SUPoint2D*)DATA_PTR(obj))
|
|
4
|
+
|
|
5
|
+
static VALUE point2d_alloc(VALUE klass)
|
|
6
|
+
{
|
|
7
|
+
struct SUPoint2D* p;
|
|
8
|
+
VALUE obj = Data_Make_Struct(klass, struct SUPoint2D, 0, RUBY_DEFAULT_FREE, p);
|
|
9
|
+
*p = (struct SUPoint2D){0.0, 0.0};
|
|
10
|
+
return obj;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
VALUE su_point2d_new(struct SUPoint2D value)
|
|
14
|
+
{
|
|
15
|
+
VALUE obj = point2d_alloc(cPoint2d);
|
|
16
|
+
*PT(obj) = value;
|
|
17
|
+
return obj;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
struct SUPoint2D su_to_point2d(VALUE obj)
|
|
21
|
+
{
|
|
22
|
+
if (rb_obj_is_kind_of(obj, cPoint2d))
|
|
23
|
+
return *PT(obj);
|
|
24
|
+
double xy[2];
|
|
25
|
+
su_array_to_xy(obj, xy);
|
|
26
|
+
return (struct SUPoint2D){xy[0], xy[1]};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
static VALUE point2d_initialize(int argc, VALUE* argv, VALUE self)
|
|
30
|
+
{
|
|
31
|
+
rb_check_arity(argc, 0, 2);
|
|
32
|
+
if (argc == 1)
|
|
33
|
+
*PT(self) = su_to_point2d(argv[0]);
|
|
34
|
+
else if (argc == 2)
|
|
35
|
+
*PT(self) = (struct SUPoint2D){NUM2DBL(argv[0]), NUM2DBL(argv[1])};
|
|
36
|
+
return self;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
static VALUE point2d_initialize_copy(VALUE self, VALUE other)
|
|
40
|
+
{
|
|
41
|
+
*PT(self) = *PT(other);
|
|
42
|
+
return self;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
static VALUE point2d_set_bang(int argc, VALUE* argv, VALUE self)
|
|
46
|
+
{
|
|
47
|
+
return point2d_initialize(argc, argv, self);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
#define DEFINE_COMPONENT(axis) \
|
|
51
|
+
static VALUE point2d_##axis(VALUE self) { return su_length_new(PT(self)->axis); } \
|
|
52
|
+
static VALUE point2d_set_##axis(VALUE self, VALUE value) \
|
|
53
|
+
{ \
|
|
54
|
+
PT(self)->axis = NUM2DBL(value); \
|
|
55
|
+
return value; \
|
|
56
|
+
}
|
|
57
|
+
DEFINE_COMPONENT(x)
|
|
58
|
+
DEFINE_COMPONENT(y)
|
|
59
|
+
|
|
60
|
+
static double* point2d_component(VALUE self, VALUE index)
|
|
61
|
+
{
|
|
62
|
+
long i = NUM2LONG(index);
|
|
63
|
+
if (i < 0 || i > 1)
|
|
64
|
+
rb_raise(rb_eIndexError, "index %ld out of range [0, 1]", i);
|
|
65
|
+
return i == 0 ? &PT(self)->x : &PT(self)->y;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
static VALUE point2d_aref(VALUE self, VALUE index)
|
|
69
|
+
{
|
|
70
|
+
return su_length_new(*point2d_component(self, index));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
static VALUE point2d_aset(VALUE self, VALUE index, VALUE value)
|
|
74
|
+
{
|
|
75
|
+
*point2d_component(self, index) = NUM2DBL(value);
|
|
76
|
+
return value;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
static VALUE point2d_to_a(VALUE self)
|
|
80
|
+
{
|
|
81
|
+
return rb_ary_new_from_args(2, su_length_new(PT(self)->x), su_length_new(PT(self)->y));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
static VALUE point2d_to_s(VALUE self)
|
|
85
|
+
{
|
|
86
|
+
return rb_sprintf("(%"PRIsVALUE", %"PRIsVALUE")",
|
|
87
|
+
rb_obj_as_string(su_length_new(PT(self)->x)), rb_obj_as_string(su_length_new(PT(self)->y)));
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
static VALUE point2d_inspect(VALUE self)
|
|
91
|
+
{
|
|
92
|
+
return rb_sprintf("Point2d(%"PRIsVALUE", %"PRIsVALUE")", su_format_number(PT(self)->x), su_format_number(PT(self)->y));
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
static VALUE point2d_plus(VALUE self, VALUE vector)
|
|
96
|
+
{
|
|
97
|
+
struct SUVector2D v = su_to_vector2d(vector);
|
|
98
|
+
struct SUPoint2D result;
|
|
99
|
+
SUPoint2DOffset(PT(self), &v, &result);
|
|
100
|
+
return su_point2d_new(result);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
static VALUE point2d_minus(VALUE self, VALUE other)
|
|
104
|
+
{
|
|
105
|
+
if (rb_obj_is_kind_of(other, cVector2d))
|
|
106
|
+
{
|
|
107
|
+
struct SUVector2D v = su_to_vector2d(other);
|
|
108
|
+
return su_point2d_new((struct SUPoint2D){PT(self)->x - v.x, PT(self)->y - v.y});
|
|
109
|
+
}
|
|
110
|
+
struct SUPoint2D q = su_to_point2d(other);
|
|
111
|
+
return su_vector2d_new((struct SUVector2D){PT(self)->x - q.x, PT(self)->y - q.y});
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
static VALUE point2d_eq(VALUE self, VALUE other)
|
|
115
|
+
{
|
|
116
|
+
if (!rb_obj_is_kind_of(other, cPoint2d) && !RB_TYPE_P(other, T_ARRAY))
|
|
117
|
+
return Qfalse;
|
|
118
|
+
struct SUPoint2D q = su_to_point2d(other);
|
|
119
|
+
bool equal = false;
|
|
120
|
+
SUPoint2DGetEqual(PT(self), &q, &equal);
|
|
121
|
+
return BOOL2RB(equal);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
static VALUE point2d_distance(VALUE self, VALUE other)
|
|
125
|
+
{
|
|
126
|
+
struct SUPoint2D q = su_to_point2d(other);
|
|
127
|
+
double distance = 0.0;
|
|
128
|
+
SUPoint2DDistanceToSUPoint2D(PT(self), &q, &distance);
|
|
129
|
+
return su_length_new(distance);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
static VALUE point2d_vector_to(VALUE self, VALUE other)
|
|
133
|
+
{
|
|
134
|
+
struct SUPoint2D q = su_to_point2d(other);
|
|
135
|
+
struct SUVector2D v;
|
|
136
|
+
SUVector2DCreate(&v, PT(self), &q);
|
|
137
|
+
return su_vector2d_new(v);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
static VALUE point2d_offset_bang(int argc, VALUE* argv, VALUE self)
|
|
141
|
+
{
|
|
142
|
+
VALUE vector;
|
|
143
|
+
VALUE distance;
|
|
144
|
+
rb_scan_args(argc, argv, "11", &vector, &distance);
|
|
145
|
+
struct SUVector2D v = su_to_vector2d(vector);
|
|
146
|
+
if (!NIL_P(distance) && SUVector2DSetLength(&v, NUM2DBL(distance)) != SU_ERROR_NONE)
|
|
147
|
+
rb_raise(rb_eArgError, "Cannot offset by a zero length vector");
|
|
148
|
+
struct SUPoint2D result;
|
|
149
|
+
SUPoint2DOffset(PT(self), &v, &result);
|
|
150
|
+
*PT(self) = result;
|
|
151
|
+
return self;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
static VALUE point2d_offset(int argc, VALUE* argv, VALUE self)
|
|
155
|
+
{
|
|
156
|
+
return point2d_offset_bang(argc, argv, su_point2d_new(*PT(self)));
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
static VALUE point2d_transform_bang(VALUE self, VALUE transformation)
|
|
160
|
+
{
|
|
161
|
+
struct SUTransformation2D t = su_to_transformation2d(transformation);
|
|
162
|
+
SUPoint2DTransform(&t, PT(self));
|
|
163
|
+
return self;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
static VALUE point2d_transform(VALUE self, VALUE transformation)
|
|
167
|
+
{
|
|
168
|
+
return point2d_transform_bang(su_point2d_new(*PT(self)), transformation);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
void Init_point2d(void)
|
|
172
|
+
{
|
|
173
|
+
rb_define_alloc_func(cPoint2d, point2d_alloc);
|
|
174
|
+
rb_define_method(cPoint2d, "transform", point2d_transform, 1);
|
|
175
|
+
rb_define_method(cPoint2d, "transform!", point2d_transform_bang, 1);
|
|
176
|
+
rb_define_method(cPoint2d, "initialize", point2d_initialize, -1);
|
|
177
|
+
rb_define_method(cPoint2d, "initialize_copy", point2d_initialize_copy, 1);
|
|
178
|
+
rb_define_method(cPoint2d, "set!", point2d_set_bang, -1);
|
|
179
|
+
rb_define_method(cPoint2d, "x", point2d_x, 0);
|
|
180
|
+
rb_define_method(cPoint2d, "x=", point2d_set_x, 1);
|
|
181
|
+
rb_define_method(cPoint2d, "y", point2d_y, 0);
|
|
182
|
+
rb_define_method(cPoint2d, "y=", point2d_set_y, 1);
|
|
183
|
+
rb_define_method(cPoint2d, "[]", point2d_aref, 1);
|
|
184
|
+
rb_define_method(cPoint2d, "[]=", point2d_aset, 2);
|
|
185
|
+
rb_define_method(cPoint2d, "to_a", point2d_to_a, 0);
|
|
186
|
+
rb_define_method(cPoint2d, "to_s", point2d_to_s, 0);
|
|
187
|
+
rb_define_method(cPoint2d, "inspect", point2d_inspect, 0);
|
|
188
|
+
rb_define_method(cPoint2d, "+", point2d_plus, 1);
|
|
189
|
+
rb_define_method(cPoint2d, "-", point2d_minus, 1);
|
|
190
|
+
rb_define_method(cPoint2d, "==", point2d_eq, 1);
|
|
191
|
+
rb_define_method(cPoint2d, "distance", point2d_distance, 1);
|
|
192
|
+
rb_define_method(cPoint2d, "vector_to", point2d_vector_to, 1);
|
|
193
|
+
rb_define_method(cPoint2d, "offset", point2d_offset, -1);
|
|
194
|
+
rb_define_method(cPoint2d, "offset!", point2d_offset_bang, -1);
|
|
195
|
+
}
|
data/ext/point3d.c
ADDED
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
#include <scriptup.h>
|
|
2
|
+
|
|
3
|
+
#define PT(obj) ((struct SUPoint3D*)DATA_PTR(obj))
|
|
4
|
+
|
|
5
|
+
static VALUE point3d_alloc(VALUE klass)
|
|
6
|
+
{
|
|
7
|
+
struct SUPoint3D* p;
|
|
8
|
+
VALUE obj = Data_Make_Struct(klass, struct SUPoint3D, 0, RUBY_DEFAULT_FREE, p);
|
|
9
|
+
*p = (struct SUPoint3D){0.0, 0.0, 0.0};
|
|
10
|
+
return obj;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
VALUE su_point3d_new(struct SUPoint3D value)
|
|
14
|
+
{
|
|
15
|
+
VALUE obj = point3d_alloc(cPoint3d);
|
|
16
|
+
*PT(obj) = value;
|
|
17
|
+
return obj;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Accepts a Point3d or a 2/3 element numeric array.
|
|
21
|
+
struct SUPoint3D su_to_point3d(VALUE obj)
|
|
22
|
+
{
|
|
23
|
+
if (rb_obj_is_kind_of(obj, cPoint3d))
|
|
24
|
+
return *PT(obj);
|
|
25
|
+
double xyz[3];
|
|
26
|
+
su_array_to_xyz(obj, xyz);
|
|
27
|
+
return (struct SUPoint3D){xyz[0], xyz[1], xyz[2]};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Geom::point3d_like: also accepts a Vertex.
|
|
31
|
+
struct SUPoint3D su_to_point3d_like(VALUE obj)
|
|
32
|
+
{
|
|
33
|
+
if (rb_obj_is_kind_of(obj, cVertex))
|
|
34
|
+
{
|
|
35
|
+
struct SUPoint3D p = {0, 0, 0};
|
|
36
|
+
SUVertexGetPosition(SU_REF(SUVertexRef, obj), &p);
|
|
37
|
+
return p;
|
|
38
|
+
}
|
|
39
|
+
return su_to_point3d(obj);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// A line is [point, vector] or [point, point].
|
|
43
|
+
struct SURay3D su_to_ray3d(VALUE line)
|
|
44
|
+
{
|
|
45
|
+
if (!RB_TYPE_P(line, T_ARRAY) || RARRAY_LEN(line) != 2)
|
|
46
|
+
rb_raise(rb_eArgError, "a line must be [point, vector] or [point, point]");
|
|
47
|
+
struct SURay3D ray;
|
|
48
|
+
ray.point = su_to_point3d(RARRAY_AREF(line, 0));
|
|
49
|
+
VALUE second = RARRAY_AREF(line, 1);
|
|
50
|
+
if (rb_obj_is_kind_of(second, cPoint3d))
|
|
51
|
+
{
|
|
52
|
+
struct SUPoint3D to = *PT(second);
|
|
53
|
+
SUVector3DCreate(&ray.normal, &ray.point, &to);
|
|
54
|
+
}
|
|
55
|
+
else
|
|
56
|
+
ray.normal = su_to_vector3d(second);
|
|
57
|
+
SUVector3DNormalize(&ray.normal);
|
|
58
|
+
return ray;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// A plane is [point, normal], [a, b, c, d] or [point, point, point].
|
|
62
|
+
struct SUPlane3D su_to_plane3d(VALUE plane)
|
|
63
|
+
{
|
|
64
|
+
if (!RB_TYPE_P(plane, T_ARRAY))
|
|
65
|
+
rb_raise(rb_eArgError, "a plane must be [point, normal] or [a, b, c, d]");
|
|
66
|
+
struct SUPlane3D result = {0.0, 0.0, 1.0, 0.0};
|
|
67
|
+
enum SUResult status = SU_ERROR_INVALID_INPUT;
|
|
68
|
+
long length = RARRAY_LEN(plane);
|
|
69
|
+
if (length == 2)
|
|
70
|
+
{
|
|
71
|
+
struct SUPoint3D point = su_to_point3d(RARRAY_AREF(plane, 0));
|
|
72
|
+
struct SUVector3D normal = su_to_vector3d(RARRAY_AREF(plane, 1));
|
|
73
|
+
status = SUPlane3DSetWithPointAndNormal(&result, &point, &normal);
|
|
74
|
+
}
|
|
75
|
+
else if (length == 3)
|
|
76
|
+
{
|
|
77
|
+
struct SUPoint3D a = su_to_point3d(RARRAY_AREF(plane, 0));
|
|
78
|
+
struct SUPoint3D b = su_to_point3d(RARRAY_AREF(plane, 1));
|
|
79
|
+
struct SUPoint3D c = su_to_point3d(RARRAY_AREF(plane, 2));
|
|
80
|
+
status = SUPlane3DSetWithPoints(&result, &a, &b, &c);
|
|
81
|
+
}
|
|
82
|
+
else if (length == 4)
|
|
83
|
+
status = SUPlane3DSetWithCoefficients(&result, NUM2DBL(RARRAY_AREF(plane, 0)), NUM2DBL(RARRAY_AREF(plane, 1)),
|
|
84
|
+
NUM2DBL(RARRAY_AREF(plane, 2)), NUM2DBL(RARRAY_AREF(plane, 3)));
|
|
85
|
+
if (status != SU_ERROR_NONE)
|
|
86
|
+
rb_raise(rb_eArgError, "invalid plane");
|
|
87
|
+
return result;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
static VALUE point3d_initialize(int argc, VALUE* argv, VALUE self)
|
|
91
|
+
{
|
|
92
|
+
rb_check_arity(argc, 0, 3);
|
|
93
|
+
if (argc == 1)
|
|
94
|
+
*PT(self) = su_to_point3d(argv[0]);
|
|
95
|
+
else if (argc >= 2)
|
|
96
|
+
*PT(self) = (struct SUPoint3D){NUM2DBL(argv[0]), NUM2DBL(argv[1]), argc == 3 ? NUM2DBL(argv[2]) : 0.0};
|
|
97
|
+
return self;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
static VALUE point3d_initialize_copy(VALUE self, VALUE other)
|
|
101
|
+
{
|
|
102
|
+
*PT(self) = *PT(other);
|
|
103
|
+
return self;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
static VALUE point3d_set_bang(int argc, VALUE* argv, VALUE self)
|
|
107
|
+
{
|
|
108
|
+
return point3d_initialize(argc, argv, self);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
static VALUE point3d_linear_combination(VALUE klass, VALUE w1, VALUE p1, VALUE w2, VALUE p2)
|
|
112
|
+
{
|
|
113
|
+
double a = NUM2DBL(w1);
|
|
114
|
+
double b = NUM2DBL(w2);
|
|
115
|
+
struct SUPoint3D p = su_to_point3d(p1);
|
|
116
|
+
struct SUPoint3D q = su_to_point3d(p2);
|
|
117
|
+
return su_point3d_new((struct SUPoint3D){a * p.x + b * q.x, a * p.y + b * q.y, a * p.z + b * q.z});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
#define DEFINE_COMPONENT(axis) \
|
|
121
|
+
static VALUE point3d_##axis(VALUE self) { return su_length_new(PT(self)->axis); } \
|
|
122
|
+
static VALUE point3d_set_##axis(VALUE self, VALUE value) \
|
|
123
|
+
{ \
|
|
124
|
+
PT(self)->axis = NUM2DBL(value); \
|
|
125
|
+
return value; \
|
|
126
|
+
}
|
|
127
|
+
DEFINE_COMPONENT(x)
|
|
128
|
+
DEFINE_COMPONENT(y)
|
|
129
|
+
DEFINE_COMPONENT(z)
|
|
130
|
+
|
|
131
|
+
static double* point3d_component(VALUE self, VALUE index)
|
|
132
|
+
{
|
|
133
|
+
long i = NUM2LONG(index);
|
|
134
|
+
if (i < 0 || i > 2)
|
|
135
|
+
rb_raise(rb_eIndexError, "index %ld out of range [0, 2]", i);
|
|
136
|
+
double* components[3] = {&PT(self)->x, &PT(self)->y, &PT(self)->z};
|
|
137
|
+
return components[i];
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
static VALUE point3d_aref(VALUE self, VALUE index)
|
|
141
|
+
{
|
|
142
|
+
return su_length_new(*point3d_component(self, index));
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
static VALUE point3d_aset(VALUE self, VALUE index, VALUE value)
|
|
146
|
+
{
|
|
147
|
+
*point3d_component(self, index) = NUM2DBL(value);
|
|
148
|
+
return value;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
static VALUE point3d_to_a(VALUE self)
|
|
152
|
+
{
|
|
153
|
+
struct SUPoint3D* p = PT(self);
|
|
154
|
+
return rb_ary_new_from_args(3, su_length_new(p->x), su_length_new(p->y), su_length_new(p->z));
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
static VALUE point3d_to_s(VALUE self)
|
|
158
|
+
{
|
|
159
|
+
VALUE parts = rb_ary_new_capa(3);
|
|
160
|
+
VALUE values = point3d_to_a(self);
|
|
161
|
+
for (long i = 0; i < 3; i++)
|
|
162
|
+
rb_ary_push(parts, rb_obj_as_string(RARRAY_AREF(values, i)));
|
|
163
|
+
return rb_sprintf("(%"PRIsVALUE")", rb_ary_join(parts, rb_str_new_cstr(", ")));
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
static VALUE point3d_inspect(VALUE self)
|
|
167
|
+
{
|
|
168
|
+
struct SUPoint3D* p = PT(self);
|
|
169
|
+
return rb_sprintf("Point3d(%"PRIsVALUE", %"PRIsVALUE", %"PRIsVALUE")",
|
|
170
|
+
su_format_number(p->x), su_format_number(p->y), su_format_number(p->z));
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
static VALUE point3d_plus(VALUE self, VALUE vector)
|
|
174
|
+
{
|
|
175
|
+
struct SUVector3D v = su_to_vector3d(vector);
|
|
176
|
+
struct SUPoint3D result;
|
|
177
|
+
SUPoint3DOffset(PT(self), &v, &result);
|
|
178
|
+
return su_point3d_new(result);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
static VALUE point3d_minus(VALUE self, VALUE other)
|
|
182
|
+
{
|
|
183
|
+
struct SUPoint3D* p = PT(self);
|
|
184
|
+
if (rb_obj_is_kind_of(other, cVector3d))
|
|
185
|
+
{
|
|
186
|
+
struct SUVector3D v = su_to_vector3d(other);
|
|
187
|
+
return su_point3d_new((struct SUPoint3D){p->x - v.x, p->y - v.y, p->z - v.z});
|
|
188
|
+
}
|
|
189
|
+
struct SUPoint3D q = su_to_point3d(other);
|
|
190
|
+
return su_vector3d_new((struct SUVector3D){p->x - q.x, p->y - q.y, p->z - q.z});
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
static VALUE point3d_lt(VALUE self, VALUE other)
|
|
194
|
+
{
|
|
195
|
+
struct SUPoint3D q = su_to_point3d(other);
|
|
196
|
+
bool less = false;
|
|
197
|
+
SUPoint3DLessThan(PT(self), &q, &less);
|
|
198
|
+
return BOOL2RB(less);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
static VALUE point3d_eq(VALUE self, VALUE other)
|
|
202
|
+
{
|
|
203
|
+
if (!rb_obj_is_kind_of(other, cPoint3d) && !RB_TYPE_P(other, T_ARRAY))
|
|
204
|
+
return Qfalse;
|
|
205
|
+
struct SUPoint3D q = su_to_point3d(other);
|
|
206
|
+
bool equal = false;
|
|
207
|
+
SUPoint3DGetEqual(PT(self), &q, &equal);
|
|
208
|
+
return BOOL2RB(equal);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
static VALUE point3d_distance(VALUE self, VALUE other)
|
|
212
|
+
{
|
|
213
|
+
struct SUPoint3D q = su_to_point3d(other);
|
|
214
|
+
double distance = 0.0;
|
|
215
|
+
SUPoint3DDistanceToSUPoint3D(PT(self), &q, &distance);
|
|
216
|
+
return su_length_new(distance);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
static VALUE point3d_vector_to(VALUE self, VALUE other)
|
|
220
|
+
{
|
|
221
|
+
struct SUPoint3D q = su_to_point3d(other);
|
|
222
|
+
struct SUVector3D v;
|
|
223
|
+
SUVector3DCreate(&v, PT(self), &q);
|
|
224
|
+
return su_vector3d_new(v);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
static VALUE point3d_offset_bang(int argc, VALUE* argv, VALUE self)
|
|
228
|
+
{
|
|
229
|
+
VALUE vector;
|
|
230
|
+
VALUE length;
|
|
231
|
+
rb_scan_args(argc, argv, "11", &vector, &length);
|
|
232
|
+
struct SUVector3D v = su_to_vector3d(vector);
|
|
233
|
+
if (!NIL_P(length) && SUVector3DSetLength(&v, NUM2DBL(length)) != SU_ERROR_NONE)
|
|
234
|
+
rb_raise(rb_eArgError, "Cannot offset by a zero length vector");
|
|
235
|
+
struct SUPoint3D result;
|
|
236
|
+
SUPoint3DOffset(PT(self), &v, &result);
|
|
237
|
+
*PT(self) = result;
|
|
238
|
+
return self;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
static VALUE point3d_offset(int argc, VALUE* argv, VALUE self)
|
|
242
|
+
{
|
|
243
|
+
return point3d_offset_bang(argc, argv, su_point3d_new(*PT(self)));
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
static VALUE point3d_distance_to_line(VALUE self, VALUE line)
|
|
247
|
+
{
|
|
248
|
+
struct SURay3D ray = su_to_ray3d(line);
|
|
249
|
+
double distance = 0.0;
|
|
250
|
+
SURay3DDistanceTo(&ray, PT(self), &distance);
|
|
251
|
+
return DBL2NUM(distance);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
static VALUE point3d_on_line_p(VALUE self, VALUE line)
|
|
255
|
+
{
|
|
256
|
+
struct SURay3D ray = su_to_ray3d(line);
|
|
257
|
+
bool on = false;
|
|
258
|
+
SURay3DIsOn(&ray, PT(self), &on);
|
|
259
|
+
return BOOL2RB(on);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
static VALUE point3d_project_to_line(VALUE self, VALUE line)
|
|
263
|
+
{
|
|
264
|
+
struct SURay3D ray = su_to_ray3d(line);
|
|
265
|
+
struct SUPoint3D result;
|
|
266
|
+
SURay3DProjectTo(&ray, PT(self), &result);
|
|
267
|
+
return su_point3d_new(result);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
static VALUE point3d_distance_to_plane(VALUE self, VALUE plane)
|
|
271
|
+
{
|
|
272
|
+
struct SUPlane3D p = su_to_plane3d(plane);
|
|
273
|
+
double distance = 0.0;
|
|
274
|
+
SUPlane3DDistanceTo(&p, PT(self), &distance);
|
|
275
|
+
return DBL2NUM(distance);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
static VALUE point3d_on_plane_p(VALUE self, VALUE plane)
|
|
279
|
+
{
|
|
280
|
+
struct SUPlane3D p = su_to_plane3d(plane);
|
|
281
|
+
bool on = false;
|
|
282
|
+
SUPlane3DIsOn(&p, PT(self), &on);
|
|
283
|
+
return BOOL2RB(on);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
static VALUE point3d_project_to_plane(VALUE self, VALUE plane)
|
|
287
|
+
{
|
|
288
|
+
struct SUPlane3D p = su_to_plane3d(plane);
|
|
289
|
+
struct SUPoint3D result;
|
|
290
|
+
SUPlane3DProjectTo(&p, PT(self), &result);
|
|
291
|
+
return su_point3d_new(result);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
static VALUE point3d_transform_bang(VALUE self, VALUE transformation)
|
|
295
|
+
{
|
|
296
|
+
struct SUTransformation t = su_to_transformation(transformation);
|
|
297
|
+
SUPoint3DTransform(&t, PT(self));
|
|
298
|
+
return self;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
static VALUE point3d_transform(VALUE self, VALUE transformation)
|
|
302
|
+
{
|
|
303
|
+
return point3d_transform_bang(su_point3d_new(*PT(self)), transformation);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
void Init_point3d(void)
|
|
307
|
+
{
|
|
308
|
+
rb_define_alloc_func(cPoint3d, point3d_alloc);
|
|
309
|
+
rb_define_method(cPoint3d, "transform", point3d_transform, 1);
|
|
310
|
+
rb_define_method(cPoint3d, "transform!", point3d_transform_bang, 1);
|
|
311
|
+
rb_define_singleton_method(cPoint3d, "linear_combination", point3d_linear_combination, 4);
|
|
312
|
+
rb_define_method(cPoint3d, "initialize", point3d_initialize, -1);
|
|
313
|
+
rb_define_method(cPoint3d, "initialize_copy", point3d_initialize_copy, 1);
|
|
314
|
+
rb_define_method(cPoint3d, "set!", point3d_set_bang, -1);
|
|
315
|
+
rb_define_method(cPoint3d, "x", point3d_x, 0);
|
|
316
|
+
rb_define_method(cPoint3d, "x=", point3d_set_x, 1);
|
|
317
|
+
rb_define_method(cPoint3d, "y", point3d_y, 0);
|
|
318
|
+
rb_define_method(cPoint3d, "y=", point3d_set_y, 1);
|
|
319
|
+
rb_define_method(cPoint3d, "z", point3d_z, 0);
|
|
320
|
+
rb_define_method(cPoint3d, "z=", point3d_set_z, 1);
|
|
321
|
+
rb_define_method(cPoint3d, "[]", point3d_aref, 1);
|
|
322
|
+
rb_define_method(cPoint3d, "[]=", point3d_aset, 2);
|
|
323
|
+
rb_define_method(cPoint3d, "to_a", point3d_to_a, 0);
|
|
324
|
+
rb_define_method(cPoint3d, "to_s", point3d_to_s, 0);
|
|
325
|
+
rb_define_method(cPoint3d, "inspect", point3d_inspect, 0);
|
|
326
|
+
rb_define_method(cPoint3d, "+", point3d_plus, 1);
|
|
327
|
+
rb_define_method(cPoint3d, "-", point3d_minus, 1);
|
|
328
|
+
rb_define_method(cPoint3d, "<", point3d_lt, 1);
|
|
329
|
+
rb_define_method(cPoint3d, "==", point3d_eq, 1);
|
|
330
|
+
rb_define_method(cPoint3d, "distance", point3d_distance, 1);
|
|
331
|
+
rb_define_method(cPoint3d, "vector_to", point3d_vector_to, 1);
|
|
332
|
+
rb_define_method(cPoint3d, "offset", point3d_offset, -1);
|
|
333
|
+
rb_define_method(cPoint3d, "offset!", point3d_offset_bang, -1);
|
|
334
|
+
rb_define_method(cPoint3d, "distance_to_line", point3d_distance_to_line, 1);
|
|
335
|
+
rb_define_method(cPoint3d, "on_line?", point3d_on_line_p, 1);
|
|
336
|
+
rb_define_method(cPoint3d, "project_to_line", point3d_project_to_line, 1);
|
|
337
|
+
rb_define_method(cPoint3d, "distance_to_plane", point3d_distance_to_plane, 1);
|
|
338
|
+
rb_define_method(cPoint3d, "on_plane?", point3d_on_plane_p, 1);
|
|
339
|
+
rb_define_method(cPoint3d, "project_to_plane", point3d_project_to_plane, 1);
|
|
340
|
+
}
|