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/polygon_mesh.c
ADDED
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
#include <scriptup.h>
|
|
2
|
+
|
|
3
|
+
// Indices are 1-based. Negative polygon indices mark hidden edges.
|
|
4
|
+
struct polygon_mesh
|
|
5
|
+
{
|
|
6
|
+
VALUE points;
|
|
7
|
+
VALUE polygons;
|
|
8
|
+
VALUE uvs_front;
|
|
9
|
+
VALUE uvs_back;
|
|
10
|
+
VALUE normals;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
#define MESH(obj) ((struct polygon_mesh*)DATA_PTR(obj))
|
|
14
|
+
|
|
15
|
+
static void mesh_mark(void* ptr)
|
|
16
|
+
{
|
|
17
|
+
struct polygon_mesh* m = ptr;
|
|
18
|
+
rb_gc_mark(m->points);
|
|
19
|
+
rb_gc_mark(m->polygons);
|
|
20
|
+
rb_gc_mark(m->uvs_front);
|
|
21
|
+
rb_gc_mark(m->uvs_back);
|
|
22
|
+
rb_gc_mark(m->normals);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
static VALUE polygonmesh_alloc(VALUE klass)
|
|
26
|
+
{
|
|
27
|
+
struct polygon_mesh* m;
|
|
28
|
+
VALUE obj = Data_Make_Struct(klass, struct polygon_mesh, mesh_mark, RUBY_DEFAULT_FREE, m);
|
|
29
|
+
m->points = rb_ary_new();
|
|
30
|
+
m->polygons = rb_ary_new();
|
|
31
|
+
m->uvs_front = rb_ary_new();
|
|
32
|
+
m->uvs_back = rb_ary_new();
|
|
33
|
+
m->normals = rb_ary_new();
|
|
34
|
+
return obj;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Builds a mesh from raw data (used by Face#mesh).
|
|
38
|
+
VALUE su_polygon_mesh_new(VALUE points, VALUE polygons, VALUE uvs_front, VALUE uvs_back, VALUE normals)
|
|
39
|
+
{
|
|
40
|
+
VALUE obj = polygonmesh_alloc(cPolygonMesh);
|
|
41
|
+
struct polygon_mesh* m = MESH(obj);
|
|
42
|
+
m->points = points;
|
|
43
|
+
m->polygons = polygons;
|
|
44
|
+
m->uvs_front = uvs_front;
|
|
45
|
+
m->uvs_back = uvs_back;
|
|
46
|
+
m->normals = normals;
|
|
47
|
+
return obj;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
static VALUE mesh_entry(VALUE ary, VALUE index)
|
|
51
|
+
{
|
|
52
|
+
long i = NUM2LONG(index);
|
|
53
|
+
if (i < 1 || i > RARRAY_LEN(ary))
|
|
54
|
+
return Qnil;
|
|
55
|
+
return RARRAY_AREF(ary, i - 1);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
static VALUE polygonmesh_initialize(int argc, VALUE* argv, VALUE self)
|
|
59
|
+
{
|
|
60
|
+
rb_check_arity(argc, 0, 2);
|
|
61
|
+
for (int i = 0; i < argc; i++)
|
|
62
|
+
NUM2LONG(argv[i]); // capacity hints only
|
|
63
|
+
return self;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
static VALUE polygonmesh_point_index(VALUE self, VALUE point)
|
|
67
|
+
{
|
|
68
|
+
VALUE p = su_point3d_new(su_to_point3d(point));
|
|
69
|
+
VALUE points = MESH(self)->points;
|
|
70
|
+
for (long i = 0; i < RARRAY_LEN(points); i++)
|
|
71
|
+
if (rb_equal(RARRAY_AREF(points, i), p))
|
|
72
|
+
return LONG2NUM(i + 1);
|
|
73
|
+
return INT2FIX(0);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
static VALUE polygonmesh_add_point(VALUE self, VALUE point)
|
|
77
|
+
{
|
|
78
|
+
VALUE index = polygonmesh_point_index(self, point);
|
|
79
|
+
if (index != INT2FIX(0))
|
|
80
|
+
return index;
|
|
81
|
+
rb_ary_push(MESH(self)->points, su_point3d_new(su_to_point3d(point)));
|
|
82
|
+
return LONG2NUM(RARRAY_LEN(MESH(self)->points));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
static VALUE polygonmesh_add_polygon(int argc, VALUE* argv, VALUE self)
|
|
86
|
+
{
|
|
87
|
+
VALUE items = argc == 1 && RB_TYPE_P(argv[0], T_ARRAY) ? argv[0] : rb_ary_new_from_values(argc, argv);
|
|
88
|
+
if (RARRAY_LEN(items) < 3)
|
|
89
|
+
rb_raise(rb_eArgError, "a polygon needs at least 3 points");
|
|
90
|
+
VALUE polygon = rb_ary_new_capa(RARRAY_LEN(items));
|
|
91
|
+
long count = RARRAY_LEN(MESH(self)->points);
|
|
92
|
+
for (long i = 0; i < RARRAY_LEN(items); i++)
|
|
93
|
+
{
|
|
94
|
+
VALUE item = RARRAY_AREF(items, i);
|
|
95
|
+
if (RB_INTEGER_TYPE_P(item))
|
|
96
|
+
{
|
|
97
|
+
long index = NUM2LONG(item);
|
|
98
|
+
if (index == 0 || labs(index) > count)
|
|
99
|
+
rb_raise(rb_eArgError, "invalid point index %ld", index);
|
|
100
|
+
rb_ary_push(polygon, item);
|
|
101
|
+
}
|
|
102
|
+
else
|
|
103
|
+
rb_ary_push(polygon, polygonmesh_add_point(self, item));
|
|
104
|
+
}
|
|
105
|
+
rb_ary_push(MESH(self)->polygons, polygon);
|
|
106
|
+
return LONG2NUM(RARRAY_LEN(MESH(self)->polygons));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
static VALUE polygonmesh_count_points(VALUE self)
|
|
110
|
+
{
|
|
111
|
+
return LONG2NUM(RARRAY_LEN(MESH(self)->points));
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
static VALUE polygonmesh_count_polygons(VALUE self)
|
|
115
|
+
{
|
|
116
|
+
return LONG2NUM(RARRAY_LEN(MESH(self)->polygons));
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
static VALUE polygonmesh_point_at(VALUE self, VALUE index)
|
|
120
|
+
{
|
|
121
|
+
VALUE point = mesh_entry(MESH(self)->points, index);
|
|
122
|
+
return NIL_P(point) ? Qnil : su_point3d_new(su_to_point3d(point));
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
static VALUE polygonmesh_points(VALUE self)
|
|
126
|
+
{
|
|
127
|
+
VALUE points = MESH(self)->points;
|
|
128
|
+
VALUE result = rb_ary_new_capa(RARRAY_LEN(points));
|
|
129
|
+
for (long i = 0; i < RARRAY_LEN(points); i++)
|
|
130
|
+
rb_ary_push(result, su_point3d_new(su_to_point3d(RARRAY_AREF(points, i))));
|
|
131
|
+
return result;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
static VALUE polygonmesh_polygon_at(VALUE self, VALUE index)
|
|
135
|
+
{
|
|
136
|
+
VALUE polygon = mesh_entry(MESH(self)->polygons, index);
|
|
137
|
+
return NIL_P(polygon) ? Qnil : rb_ary_dup(polygon);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
static VALUE polygonmesh_polygon_points_at(VALUE self, VALUE index)
|
|
141
|
+
{
|
|
142
|
+
VALUE polygon = mesh_entry(MESH(self)->polygons, index);
|
|
143
|
+
if (NIL_P(polygon))
|
|
144
|
+
return Qnil;
|
|
145
|
+
VALUE result = rb_ary_new_capa(RARRAY_LEN(polygon));
|
|
146
|
+
for (long i = 0; i < RARRAY_LEN(polygon); i++)
|
|
147
|
+
rb_ary_push(result, polygonmesh_point_at(self, LONG2NUM(labs(NUM2LONG(RARRAY_AREF(polygon, i))))));
|
|
148
|
+
return result;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
static VALUE polygonmesh_polygons(VALUE self)
|
|
152
|
+
{
|
|
153
|
+
VALUE polygons = MESH(self)->polygons;
|
|
154
|
+
VALUE result = rb_ary_new_capa(RARRAY_LEN(polygons));
|
|
155
|
+
for (long i = 0; i < RARRAY_LEN(polygons); i++)
|
|
156
|
+
rb_ary_push(result, rb_ary_dup(RARRAY_AREF(polygons, i)));
|
|
157
|
+
return result;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
static VALUE polygonmesh_set_point(VALUE self, VALUE index, VALUE point)
|
|
161
|
+
{
|
|
162
|
+
long i = NUM2LONG(index);
|
|
163
|
+
if (i < 1 || i > RARRAY_LEN(MESH(self)->points))
|
|
164
|
+
rb_raise(rb_eIndexError, "invalid point index %ld", i);
|
|
165
|
+
rb_ary_store(MESH(self)->points, i - 1, su_point3d_new(su_to_point3d(point)));
|
|
166
|
+
return self;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
static VALUE uv_array(VALUE self, VALUE front)
|
|
170
|
+
{
|
|
171
|
+
return RTEST(front) ? MESH(self)->uvs_front : MESH(self)->uvs_back;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
static VALUE polygonmesh_set_uv(VALUE self, VALUE index, VALUE point, VALUE front)
|
|
175
|
+
{
|
|
176
|
+
long i = NUM2LONG(index);
|
|
177
|
+
if (i < 1 || i > RARRAY_LEN(MESH(self)->points))
|
|
178
|
+
rb_raise(rb_eIndexError, "invalid point index %ld", i);
|
|
179
|
+
rb_ary_store(uv_array(self, front), i - 1, su_point3d_new(su_to_point3d(point)));
|
|
180
|
+
return Qnil;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
static VALUE polygonmesh_uv_at(VALUE self, VALUE index, VALUE front)
|
|
184
|
+
{
|
|
185
|
+
VALUE uv = mesh_entry(uv_array(self, front), index);
|
|
186
|
+
return NIL_P(uv) ? Qnil : su_point3d_new(su_to_point3d(uv));
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
static VALUE polygonmesh_uvs(VALUE self, VALUE front)
|
|
190
|
+
{
|
|
191
|
+
VALUE uvs = uv_array(self, front);
|
|
192
|
+
VALUE result = rb_ary_new_capa(RARRAY_LEN(uvs));
|
|
193
|
+
for (long i = 0; i < RARRAY_LEN(uvs); i++)
|
|
194
|
+
{
|
|
195
|
+
VALUE uv = RARRAY_AREF(uvs, i);
|
|
196
|
+
rb_ary_push(result, NIL_P(uv) ? Qnil : su_point3d_new(su_to_point3d(uv)));
|
|
197
|
+
}
|
|
198
|
+
return result;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
static VALUE polygonmesh_normal_at(VALUE self, VALUE index)
|
|
202
|
+
{
|
|
203
|
+
VALUE normal = mesh_entry(MESH(self)->normals, index);
|
|
204
|
+
return NIL_P(normal) ? Qnil : su_vector3d_new(su_to_vector3d(normal));
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
static VALUE polygonmesh_transform_bang(VALUE self, VALUE transformation)
|
|
208
|
+
{
|
|
209
|
+
struct SUTransformation t = su_to_transformation(transformation);
|
|
210
|
+
VALUE points = MESH(self)->points;
|
|
211
|
+
for (long i = 0; i < RARRAY_LEN(points); i++)
|
|
212
|
+
{
|
|
213
|
+
struct SUPoint3D p = su_to_point3d(RARRAY_AREF(points, i));
|
|
214
|
+
SUPoint3DTransform(&t, &p);
|
|
215
|
+
rb_ary_store(points, i, su_point3d_new(p));
|
|
216
|
+
}
|
|
217
|
+
VALUE normals = MESH(self)->normals;
|
|
218
|
+
for (long i = 0; i < RARRAY_LEN(normals); i++)
|
|
219
|
+
{
|
|
220
|
+
struct SUVector3D v = su_to_vector3d(RARRAY_AREF(normals, i));
|
|
221
|
+
SUVector3DTransform(&t, &v);
|
|
222
|
+
rb_ary_store(normals, i, su_vector3d_new(v));
|
|
223
|
+
}
|
|
224
|
+
return self;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
void Init_polygon_mesh(void)
|
|
228
|
+
{
|
|
229
|
+
static const struct { const char* name; int value; } constants[] = {
|
|
230
|
+
{"NO_SMOOTH_OR_HIDE", 0}, {"HIDE_BASED_ON_INDEX", 1}, {"SOFTEN_BASED_ON_INDEX", 2}, {"AUTO_SOFTEN", 4},
|
|
231
|
+
{"SMOOTH_SOFT_EDGES", 8}, {"MESH_POINTS", 0}, {"MESH_UVQ_FRONT", 1}, {"MESH_UVQ_BACK", 3}, {"MESH_NORMALS", 4},
|
|
232
|
+
};
|
|
233
|
+
for (size_t i = 0; i < sizeof(constants) / sizeof(constants[0]); i++)
|
|
234
|
+
rb_define_const(cPolygonMesh, constants[i].name, INT2FIX(constants[i].value));
|
|
235
|
+
rb_define_alloc_func(cPolygonMesh, polygonmesh_alloc);
|
|
236
|
+
rb_define_method(cPolygonMesh, "initialize", polygonmesh_initialize, -1);
|
|
237
|
+
rb_define_method(cPolygonMesh, "add_point", polygonmesh_add_point, 1);
|
|
238
|
+
rb_define_method(cPolygonMesh, "add_polygon", polygonmesh_add_polygon, -1);
|
|
239
|
+
rb_define_method(cPolygonMesh, "count_points", polygonmesh_count_points, 0);
|
|
240
|
+
rb_define_method(cPolygonMesh, "count_polygons", polygonmesh_count_polygons, 0);
|
|
241
|
+
rb_define_method(cPolygonMesh, "point_at", polygonmesh_point_at, 1);
|
|
242
|
+
rb_define_method(cPolygonMesh, "point_index", polygonmesh_point_index, 1);
|
|
243
|
+
rb_define_method(cPolygonMesh, "points", polygonmesh_points, 0);
|
|
244
|
+
rb_define_method(cPolygonMesh, "polygon_at", polygonmesh_polygon_at, 1);
|
|
245
|
+
rb_define_method(cPolygonMesh, "polygon_points_at", polygonmesh_polygon_points_at, 1);
|
|
246
|
+
rb_define_method(cPolygonMesh, "polygons", polygonmesh_polygons, 0);
|
|
247
|
+
rb_define_method(cPolygonMesh, "set_point", polygonmesh_set_point, 2);
|
|
248
|
+
rb_define_method(cPolygonMesh, "set_uv", polygonmesh_set_uv, 3);
|
|
249
|
+
rb_define_method(cPolygonMesh, "uv_at", polygonmesh_uv_at, 2);
|
|
250
|
+
rb_define_method(cPolygonMesh, "uvs", polygonmesh_uvs, 1);
|
|
251
|
+
rb_define_method(cPolygonMesh, "normal_at", polygonmesh_normal_at, 1);
|
|
252
|
+
rb_define_method(cPolygonMesh, "transform!", polygonmesh_transform_bang, 1);
|
|
253
|
+
}
|
data/ext/scriptup.h
ADDED
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
#ifndef SCRIPTUP_H
|
|
2
|
+
#define SCRIPTUP_H
|
|
3
|
+
|
|
4
|
+
#include <ruby.h>
|
|
5
|
+
#include <stdbool.h>
|
|
6
|
+
#include <SketchUpAPI/sketchup.h>
|
|
7
|
+
#include <math.h>
|
|
8
|
+
|
|
9
|
+
#ifndef M_PI
|
|
10
|
+
#define M_PI 3.14159265358979323846
|
|
11
|
+
#endif
|
|
12
|
+
|
|
13
|
+
// X(var, namespace, "Name", parent) in definition order (parents first).
|
|
14
|
+
#define SCRIPTUP_CLASSES(X) \
|
|
15
|
+
X(cLength, rb_cObject, "Length", rb_cNumeric) \
|
|
16
|
+
X(cModel, mSketchup, "Model", rb_cObject) \
|
|
17
|
+
X(cColor, mSketchup, "Color", rb_cObject) \
|
|
18
|
+
X(cImageRep, mSketchup, "ImageRep", rb_cObject) \
|
|
19
|
+
X(cEntities, mSketchup, "Entities", rb_cObject) \
|
|
20
|
+
X(cBoundingBox, mGeom, "BoundingBox", rb_cObject) \
|
|
21
|
+
X(cVector3d, mGeom, "Vector3d", rb_cObject) \
|
|
22
|
+
X(cPoint3d, mGeom, "Point3d", rb_cObject) \
|
|
23
|
+
X(cVector2d, mGeom, "Vector2d", rb_cObject) \
|
|
24
|
+
X(cPoint2d, mGeom, "Point2d", rb_cObject) \
|
|
25
|
+
X(cTransformation, mGeom, "Transformation", rb_cObject) \
|
|
26
|
+
X(cTransformation2d, mGeom, "Transformation2d", rb_cObject) \
|
|
27
|
+
X(cLatLong, mGeom, "LatLong", rb_cObject) \
|
|
28
|
+
X(cPolygonMesh, mGeom, "PolygonMesh", rb_cObject) \
|
|
29
|
+
X(cInstancePath, mSketchup, "InstancePath", rb_cObject) \
|
|
30
|
+
X(cEntitiesBuilder, mSketchup, "EntitiesBuilder", rb_cObject) \
|
|
31
|
+
X(cTextureWriter, mSketchup, "TextureWriter", rb_cObject) \
|
|
32
|
+
X(cUVHelper, mSketchup, "UVHelper", rb_cObject) \
|
|
33
|
+
X(cCamera, mSketchup, "Camera", rb_cObject) \
|
|
34
|
+
X(cOptionsManager, mSketchup, "OptionsManager", rb_cObject) \
|
|
35
|
+
X(cOptionsProvider, mSketchup, "OptionsProvider", rb_cObject) \
|
|
36
|
+
X(cClassifications, mSketchup, "Classifications", rb_cObject) \
|
|
37
|
+
X(cClassificationSchema, mSketchup, "ClassificationSchema", rb_cObject) \
|
|
38
|
+
X(cEntity, mSketchup, "Entity", rb_cObject) \
|
|
39
|
+
X(cMaterials, mSketchup, "Materials", cEntity) \
|
|
40
|
+
X(cMaterial, mSketchup, "Material", cEntity) \
|
|
41
|
+
X(cDefinitionList, mSketchup, "DefinitionList", cEntity) \
|
|
42
|
+
X(cAttributeDictionary, mSketchup, "AttributeDictionary", cEntity) \
|
|
43
|
+
X(cAttributeDictionaries, mSketchup, "AttributeDictionaries", cEntity) \
|
|
44
|
+
X(cTexture, mSketchup, "Texture", cEntity) \
|
|
45
|
+
X(cBehavior, mSketchup, "Behavior", cEntity) \
|
|
46
|
+
X(cAxes, mSketchup, "Axes", cEntity) \
|
|
47
|
+
X(cPage, mSketchup, "Page", cEntity) \
|
|
48
|
+
X(cPages, mSketchup, "Pages", cEntity) \
|
|
49
|
+
X(cRenderingOptions, mSketchup, "RenderingOptions", cEntity) \
|
|
50
|
+
X(cShadowInfo, mSketchup, "ShadowInfo", cEntity) \
|
|
51
|
+
X(cStyle, mSketchup, "Style", cEntity) \
|
|
52
|
+
X(cStyles, mSketchup, "Styles", cEntity) \
|
|
53
|
+
X(cEnvironment, mSketchup, "Environment", cEntity) \
|
|
54
|
+
X(cEnvironments, mSketchup, "Environments", cEntity) \
|
|
55
|
+
X(cLayer, mSketchup, "Layer", cEntity) \
|
|
56
|
+
X(cLayers, mSketchup, "Layers", cEntity) \
|
|
57
|
+
X(cLayerFolder, mSketchup, "LayerFolder", cEntity) \
|
|
58
|
+
X(cLineStyle, mSketchup, "LineStyle", cEntity) \
|
|
59
|
+
X(cLineStyles, mSketchup, "LineStyles", cEntity) \
|
|
60
|
+
X(cVertex, mSketchup, "Vertex", cEntity) \
|
|
61
|
+
X(cLoop, mSketchup, "Loop", cEntity) \
|
|
62
|
+
X(cEdgeUse, mSketchup, "EdgeUse", cEntity) \
|
|
63
|
+
X(cCurve, mSketchup, "Curve", cEntity) \
|
|
64
|
+
X(cArcCurve, mSketchup, "ArcCurve", cCurve) \
|
|
65
|
+
X(cDrawingelement, mSketchup, "Drawingelement", cEntity) \
|
|
66
|
+
X(cComponentDefinition, mSketchup, "ComponentDefinition", cDrawingelement) \
|
|
67
|
+
X(cComponentInstance, mSketchup, "ComponentInstance", cDrawingelement) \
|
|
68
|
+
X(cConstructionLine, mSketchup, "ConstructionLine", cDrawingelement) \
|
|
69
|
+
X(cConstructionPoint, mSketchup, "ConstructionPoint", cDrawingelement) \
|
|
70
|
+
X(cDimension, mSketchup, "Dimension", cDrawingelement) \
|
|
71
|
+
X(cEdge, mSketchup, "Edge", cDrawingelement) \
|
|
72
|
+
X(cFace, mSketchup, "Face", cDrawingelement) \
|
|
73
|
+
X(cGroup, mSketchup, "Group", cDrawingelement) \
|
|
74
|
+
X(cImage, mSketchup, "Image", cDrawingelement) \
|
|
75
|
+
X(cSectionPlane, mSketchup, "SectionPlane", cDrawingelement) \
|
|
76
|
+
X(cText, mSketchup, "Text", cDrawingelement)
|
|
77
|
+
|
|
78
|
+
#define SCRIPTUP_DECLARE_CLASS(var, ns, name, parent) extern VALUE var;
|
|
79
|
+
extern VALUE mSketchup;
|
|
80
|
+
extern VALUE mGeom;
|
|
81
|
+
SCRIPTUP_CLASSES(SCRIPTUP_DECLARE_CLASS)
|
|
82
|
+
|
|
83
|
+
// Per-file method definitions, called after all classes exist.
|
|
84
|
+
void Init_arc_curve(void);
|
|
85
|
+
void Init_attribute_dictionaries(void);
|
|
86
|
+
void Init_axes(void);
|
|
87
|
+
void Init_attribute_dictionary(void);
|
|
88
|
+
void Init_behavior(void);
|
|
89
|
+
void Init_bounding_box(void);
|
|
90
|
+
void Init_camera(void);
|
|
91
|
+
void Init_classifications(void);
|
|
92
|
+
void Init_color(void);
|
|
93
|
+
void Init_component_definition(void);
|
|
94
|
+
void Init_component_instance(void);
|
|
95
|
+
void Init_construction(void);
|
|
96
|
+
void Init_curve(void);
|
|
97
|
+
void Init_definition_list(void);
|
|
98
|
+
void Init_drawing_element(void);
|
|
99
|
+
void Init_entities(void);
|
|
100
|
+
void Init_entities_builder(void);
|
|
101
|
+
void Init_edge(void);
|
|
102
|
+
void Init_edge_use(void);
|
|
103
|
+
void Init_entity(void);
|
|
104
|
+
void Init_environments(void);
|
|
105
|
+
void Init_face(void);
|
|
106
|
+
void Init_image(void);
|
|
107
|
+
void Init_image_rep(void);
|
|
108
|
+
void Init_instance_path(void);
|
|
109
|
+
void Init_lat_long(void);
|
|
110
|
+
void Init_geom(void);
|
|
111
|
+
void Init_group(void);
|
|
112
|
+
void Init_layer(void);
|
|
113
|
+
void Init_layer_folder(void);
|
|
114
|
+
void Init_layers(void);
|
|
115
|
+
void Init_length(void);
|
|
116
|
+
void Init_line_styles(void);
|
|
117
|
+
void Init_loop(void);
|
|
118
|
+
void Init_material(void);
|
|
119
|
+
void Init_materials(void);
|
|
120
|
+
void Init_model(void);
|
|
121
|
+
void Init_options_store(void);
|
|
122
|
+
void Init_page(void);
|
|
123
|
+
void Init_pages(void);
|
|
124
|
+
void Init_point2d(void);
|
|
125
|
+
void Init_polygon_mesh(void);
|
|
126
|
+
void Init_point3d(void);
|
|
127
|
+
void Init_section_plane(void);
|
|
128
|
+
void Init_styles(void);
|
|
129
|
+
void Init_text(void);
|
|
130
|
+
void Init_texture(void);
|
|
131
|
+
void Init_texture_writer(void);
|
|
132
|
+
void Init_transformation(void);
|
|
133
|
+
void Init_transformation2d(void);
|
|
134
|
+
void Init_uv_helper(void);
|
|
135
|
+
void Init_vector2d(void);
|
|
136
|
+
void Init_vector3d(void);
|
|
137
|
+
void Init_vertex(void);
|
|
138
|
+
|
|
139
|
+
SUModelRef Sketchup_get_active_model(void);
|
|
140
|
+
void Sketchup_set_active_model(SUModelRef model);
|
|
141
|
+
|
|
142
|
+
// helpers.c
|
|
143
|
+
VALUE su_wrap(VALUE klass, void* ptr);
|
|
144
|
+
VALUE su_wrap_or_nil(VALUE klass, void* ptr);
|
|
145
|
+
VALUE su_wrap_entity(SUEntityRef entity);
|
|
146
|
+
SUMaterialRef su_material_from_arg(VALUE entity, VALUE material);
|
|
147
|
+
SUInstancePathRef su_to_instance_path(VALUE obj);
|
|
148
|
+
VALUE su_instance_path_copy(SUInstancePathRef source);
|
|
149
|
+
VALUE su_image_rep_new(SUImageRepRef image);
|
|
150
|
+
VALUE su_camera_wrap(SUCameraRef camera);
|
|
151
|
+
VALUE su_instance_locked_p(VALUE self);
|
|
152
|
+
VALUE su_instance_set_locked(VALUE self, VALUE lock);
|
|
153
|
+
VALUE su_instance_volume(VALUE self);
|
|
154
|
+
VALUE su_instance_manifold_p(VALUE self);
|
|
155
|
+
VALUE su_instance_glued_to(VALUE self);
|
|
156
|
+
void* su_unwrap(VALUE obj, VALUE klass);
|
|
157
|
+
VALUE su_string_to_rb(SUStringRef string);
|
|
158
|
+
int su_clamp_int(VALUE value, int min, int max);
|
|
159
|
+
double su_clamp_double(VALUE value, double min, double max);
|
|
160
|
+
VALUE su_yield_each(VALUE self, VALUE ary);
|
|
161
|
+
VALUE su_find_by(VALUE ary, const char* method, VALUE key);
|
|
162
|
+
VALUE su_fetch(VALUE ary, VALUE index);
|
|
163
|
+
VALUE su_length_new(double inches);
|
|
164
|
+
VALUE su_model_attribute_dictionaries(SUModelRef model);
|
|
165
|
+
VALUE su_color_new(SUColor value);
|
|
166
|
+
VALUE su_color_coerce(VALUE obj);
|
|
167
|
+
VALUE su_point3d_new(struct SUPoint3D value);
|
|
168
|
+
struct SUPoint3D su_to_point3d(VALUE obj);
|
|
169
|
+
struct SUPoint3D su_to_point3d_like(VALUE obj);
|
|
170
|
+
VALUE su_entities_new(SUEntitiesRef entities);
|
|
171
|
+
struct SURay3D su_to_ray3d(VALUE line);
|
|
172
|
+
struct SUPlane3D su_to_plane3d(VALUE plane);
|
|
173
|
+
VALUE su_vector3d_new(struct SUVector3D value);
|
|
174
|
+
struct SUVector3D su_to_vector3d(VALUE obj);
|
|
175
|
+
void su_array_to_xyz(VALUE ary, double xyz[3]);
|
|
176
|
+
void su_array_to_xy(VALUE ary, double xy[2]);
|
|
177
|
+
VALUE su_polygon_mesh_new(VALUE points, VALUE polygons, VALUE uvs_front, VALUE uvs_back, VALUE normals);
|
|
178
|
+
VALUE su_lat_long_new(double latitude, double longitude);
|
|
179
|
+
VALUE su_bounding_box_new(struct SUBoundingBox3D value);
|
|
180
|
+
VALUE su_transformation_new(struct SUTransformation value);
|
|
181
|
+
struct SUTransformation su_to_transformation(VALUE obj);
|
|
182
|
+
struct SUTransformation2D su_to_transformation2d(VALUE obj);
|
|
183
|
+
VALUE su_point2d_new(struct SUPoint2D value);
|
|
184
|
+
struct SUPoint2D su_to_point2d(VALUE obj);
|
|
185
|
+
VALUE su_vector2d_new(struct SUVector2D value);
|
|
186
|
+
struct SUVector2D su_to_vector2d(VALUE obj);
|
|
187
|
+
VALUE su_format_number(double value);
|
|
188
|
+
VALUE su_ruby_from_typed_value(SUTypedValueRef value);
|
|
189
|
+
void su_typed_value_from_ruby(SUTypedValueRef value, VALUE object);
|
|
190
|
+
|
|
191
|
+
#define BOOL2RB(b) ((b) ? Qtrue : Qfalse)
|
|
192
|
+
#define SU_REF(Type, obj) ((Type){DATA_PTR(obj)})
|
|
193
|
+
|
|
194
|
+
// Method generators. Function names follow <class>_<method>, with set_ for
|
|
195
|
+
// writers and _p for predicates, so they can be generated from the RBS.
|
|
196
|
+
#define DEFINE_GETTER(fn, Type, SUFn, CType, init, TO_RUBY) \
|
|
197
|
+
static VALUE fn(VALUE self) \
|
|
198
|
+
{ \
|
|
199
|
+
CType value = init; \
|
|
200
|
+
SUFn(SU_REF(Type, self), &value); \
|
|
201
|
+
return TO_RUBY(value); \
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
#define DEFINE_SETTER(fn, Type, SUFn, FROM_RUBY) \
|
|
205
|
+
static VALUE fn(VALUE self, VALUE value) \
|
|
206
|
+
{ \
|
|
207
|
+
SUFn(SU_REF(Type, self), FROM_RUBY(value)); \
|
|
208
|
+
return value; \
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
#define DEFINE_BOOL_GETTER(fn, Type, SUFn) DEFINE_GETTER(fn, Type, SUFn, bool, false, BOOL2RB)
|
|
212
|
+
#define DEFINE_BOOL_SETTER(fn, Type, SUFn) DEFINE_SETTER(fn, Type, SUFn, RTEST)
|
|
213
|
+
#define DEFINE_SIZE_GETTER(fn, Type, SUFn) DEFINE_GETTER(fn, Type, SUFn, size_t, 0, SIZET2NUM)
|
|
214
|
+
#define DEFINE_DOUBLE_GETTER(fn, Type, SUFn) DEFINE_GETTER(fn, Type, SUFn, double, 0.0, DBL2NUM)
|
|
215
|
+
#define DEFINE_ENUM_GETTER(fn, Type, SUFn, EnumType) DEFINE_GETTER(fn, Type, SUFn, EnumType, 0, INT2NUM)
|
|
216
|
+
#define DEFINE_STRING_SETTER(fn, Type, SUFn) DEFINE_SETTER(fn, Type, SUFn, StringValueCStr)
|
|
217
|
+
|
|
218
|
+
#define DEFINE_STRING_GETTER(fn, Type, SUFn) \
|
|
219
|
+
static VALUE fn(VALUE self) \
|
|
220
|
+
{ \
|
|
221
|
+
SUStringRef string = SU_INVALID; \
|
|
222
|
+
SUStringCreate(&string); \
|
|
223
|
+
SUFn(SU_REF(Type, self), &string); \
|
|
224
|
+
VALUE output = su_string_to_rb(string); \
|
|
225
|
+
SUStringRelease(&string); \
|
|
226
|
+
return output; \
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
#define DEFINE_REF_GETTER(fn, Type, SUFn, OutType, klass) \
|
|
230
|
+
static VALUE fn(VALUE self) \
|
|
231
|
+
{ \
|
|
232
|
+
OutType out = SU_INVALID; \
|
|
233
|
+
SUFn(SU_REF(Type, self), &out); \
|
|
234
|
+
return su_wrap_or_nil(klass, out.ptr); \
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// static VALUE fn(Type ref): Ruby array of wrapped refs from a Num/Get pair.
|
|
238
|
+
#define DEFINE_REF_LIST(fn, Type, NumFn, GetFn, ItemType, klass) \
|
|
239
|
+
static VALUE fn(Type ref) \
|
|
240
|
+
{ \
|
|
241
|
+
size_t count = 0; \
|
|
242
|
+
NumFn(ref, &count); \
|
|
243
|
+
VALUE ary = rb_ary_new_capa((long)count); \
|
|
244
|
+
if (count == 0) \
|
|
245
|
+
return ary; \
|
|
246
|
+
ItemType* items = ZALLOC_N(ItemType, count); \
|
|
247
|
+
GetFn(ref, count, items, &count); \
|
|
248
|
+
for (size_t i = 0; i < count; i++) \
|
|
249
|
+
rb_ary_push(ary, su_wrap(klass, items[i].ptr)); \
|
|
250
|
+
xfree(items); \
|
|
251
|
+
return ary; \
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// static VALUE fn(Type ref): Ruby array of strings from a Num/Get pair.
|
|
255
|
+
#define DEFINE_STRING_LIST(fn, Type, NumFn, GetFn) \
|
|
256
|
+
static VALUE fn(Type ref) \
|
|
257
|
+
{ \
|
|
258
|
+
size_t count = 0; \
|
|
259
|
+
NumFn(ref, &count); \
|
|
260
|
+
VALUE ary = rb_ary_new_capa((long)count); \
|
|
261
|
+
if (count == 0) \
|
|
262
|
+
return ary; \
|
|
263
|
+
SUStringRef* strings = ZALLOC_N(SUStringRef, count); \
|
|
264
|
+
for (size_t i = 0; i < count; i++) \
|
|
265
|
+
{ \
|
|
266
|
+
strings[i].ptr = NULL; \
|
|
267
|
+
SUStringCreate(&strings[i]); \
|
|
268
|
+
} \
|
|
269
|
+
GetFn(ref, count, strings, &count); \
|
|
270
|
+
for (size_t i = 0; i < count; i++) \
|
|
271
|
+
{ \
|
|
272
|
+
rb_ary_push(ary, su_string_to_rb(strings[i])); \
|
|
273
|
+
SUStringRelease(&strings[i]); \
|
|
274
|
+
} \
|
|
275
|
+
xfree(strings); \
|
|
276
|
+
return ary; \
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
#endif // SCRIPTUP_H
|
data/ext/section_plane.c
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#include <scriptup.h>
|
|
2
|
+
|
|
3
|
+
#define SECTION(self) SU_REF(SUSectionPlaneRef, self)
|
|
4
|
+
|
|
5
|
+
DEFINE_STRING_GETTER(sectionplane_name, SUSectionPlaneRef, SUSectionPlaneGetName)
|
|
6
|
+
DEFINE_STRING_SETTER(sectionplane_set_name, SUSectionPlaneRef, SUSectionPlaneSetName)
|
|
7
|
+
DEFINE_STRING_GETTER(sectionplane_symbol, SUSectionPlaneRef, SUSectionPlaneGetSymbol)
|
|
8
|
+
DEFINE_STRING_SETTER(sectionplane_set_symbol, SUSectionPlaneRef, SUSectionPlaneSetSymbol)
|
|
9
|
+
DEFINE_BOOL_GETTER(sectionplane_active_p, SUSectionPlaneRef, SUSectionPlaneIsActive)
|
|
10
|
+
|
|
11
|
+
static VALUE sectionplane_get_plane(VALUE self)
|
|
12
|
+
{
|
|
13
|
+
struct SUPlane3D plane = {0, 0, 1, 0};
|
|
14
|
+
SUSectionPlaneGetPlane(SECTION(self), &plane);
|
|
15
|
+
return rb_ary_new_from_args(4, DBL2NUM(plane.a), DBL2NUM(plane.b), DBL2NUM(plane.c), DBL2NUM(plane.d));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
static VALUE sectionplane_set_plane(VALUE self, VALUE plane)
|
|
19
|
+
{
|
|
20
|
+
struct SUPlane3D p = su_to_plane3d(plane);
|
|
21
|
+
SUSectionPlaneSetPlane(SECTION(self), &p);
|
|
22
|
+
return self;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
static VALUE sectionplane_activate(VALUE self)
|
|
26
|
+
{
|
|
27
|
+
SUEntitiesRef parent = SU_INVALID;
|
|
28
|
+
SUEntityGetParentEntities(SU_REF(SUEntityRef, self), &parent);
|
|
29
|
+
if (SUEntitiesSetActiveSectionPlane(parent, SECTION(self)) != SU_ERROR_NONE)
|
|
30
|
+
rb_raise(rb_eRuntimeError, "cannot activate this section plane");
|
|
31
|
+
return self;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
void Init_section_plane(void)
|
|
35
|
+
{
|
|
36
|
+
rb_define_method(cSectionPlane, "name", sectionplane_name, 0);
|
|
37
|
+
rb_define_method(cSectionPlane, "name=", sectionplane_set_name, 1);
|
|
38
|
+
rb_define_method(cSectionPlane, "symbol", sectionplane_symbol, 0);
|
|
39
|
+
rb_define_method(cSectionPlane, "symbol=", sectionplane_set_symbol, 1);
|
|
40
|
+
rb_define_method(cSectionPlane, "active?", sectionplane_active_p, 0);
|
|
41
|
+
rb_define_method(cSectionPlane, "activate", sectionplane_activate, 0);
|
|
42
|
+
rb_define_method(cSectionPlane, "get_plane", sectionplane_get_plane, 0);
|
|
43
|
+
rb_define_method(cSectionPlane, "set_plane", sectionplane_set_plane, 1);
|
|
44
|
+
}
|