sketchup-api-stubs 0.6.1 → 0.7.4
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/.yardopts +2 -0
- data/lib/sketchup-api-stubs.rb +1 -1
- data/lib/sketchup-api-stubs/sketchup.rb +145 -145
- data/lib/sketchup-api-stubs/stubs/Geom/BoundingBox.rb +318 -318
- data/lib/sketchup-api-stubs/stubs/Geom/Bounds2d.rb +172 -172
- data/lib/sketchup-api-stubs/stubs/Geom/LatLong.rb +126 -126
- data/lib/sketchup-api-stubs/stubs/Geom/OrientedBounds2d.rb +102 -102
- data/lib/sketchup-api-stubs/stubs/Geom/Point2d.rb +400 -401
- data/lib/sketchup-api-stubs/stubs/Geom/Point3d.rb +661 -661
- data/lib/sketchup-api-stubs/stubs/Geom/PolygonMesh.rb +492 -492
- data/lib/sketchup-api-stubs/stubs/Geom/Transformation.rb +478 -478
- data/lib/sketchup-api-stubs/stubs/Geom/Transformation2d.rb +263 -263
- data/lib/sketchup-api-stubs/stubs/Geom/UTM.rb +141 -141
- data/lib/sketchup-api-stubs/stubs/Geom/Vector2d.rb +522 -523
- data/lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb +691 -691
- data/lib/sketchup-api-stubs/stubs/Layout.rb +25 -25
- data/lib/sketchup-api-stubs/stubs/Layout/AngularDimension.rb +573 -569
- data/lib/sketchup-api-stubs/stubs/Layout/AutoTextDefinition.rb +411 -411
- data/lib/sketchup-api-stubs/stubs/Layout/AutoTextDefinitions.rb +174 -186
- data/lib/sketchup-api-stubs/stubs/Layout/ConnectionPoint.rb +70 -70
- data/lib/sketchup-api-stubs/stubs/Layout/Document.rb +514 -455
- data/lib/sketchup-api-stubs/stubs/Layout/Ellipse.rb +29 -29
- data/lib/sketchup-api-stubs/stubs/Layout/Entities.rb +143 -155
- data/lib/sketchup-api-stubs/stubs/Layout/Entity.rb +353 -359
- data/lib/sketchup-api-stubs/stubs/Layout/FormattedText.rb +349 -349
- data/lib/sketchup-api-stubs/stubs/Layout/Grid.rb +311 -123
- data/lib/sketchup-api-stubs/stubs/Layout/Group.rb +261 -261
- data/lib/sketchup-api-stubs/stubs/Layout/Image.rb +91 -86
- data/lib/sketchup-api-stubs/stubs/Layout/Label.rb +371 -371
- data/lib/sketchup-api-stubs/stubs/Layout/Layer.rb +218 -218
- data/lib/sketchup-api-stubs/stubs/Layout/LayerInstance.rb +128 -128
- data/lib/sketchup-api-stubs/stubs/Layout/Layers.rb +220 -232
- data/lib/sketchup-api-stubs/stubs/Layout/LinearDimension.rb +567 -563
- data/lib/sketchup-api-stubs/stubs/Layout/LockedEntityError.rb +10 -10
- data/lib/sketchup-api-stubs/stubs/Layout/LockedLayerError.rb +11 -11
- data/lib/sketchup-api-stubs/stubs/Layout/Page.rb +183 -183
- data/lib/sketchup-api-stubs/stubs/Layout/PageInfo.rb +387 -387
- data/lib/sketchup-api-stubs/stubs/Layout/Pages.rb +204 -216
- data/lib/sketchup-api-stubs/stubs/Layout/Path.rb +344 -344
- data/lib/sketchup-api-stubs/stubs/Layout/Rectangle.rb +174 -174
- data/lib/sketchup-api-stubs/stubs/Layout/SketchUpModel.rb +694 -547
- data/lib/sketchup-api-stubs/stubs/Layout/Style.rb +1519 -1519
- data/lib/sketchup-api-stubs/stubs/Layout/Table.rb +290 -290
- data/lib/sketchup-api-stubs/stubs/Layout/TableCell.rb +149 -149
- data/lib/sketchup-api-stubs/stubs/Layout/TableColumn.rb +139 -139
- data/lib/sketchup-api-stubs/stubs/Layout/TableRow.rb +135 -135
- data/lib/sketchup-api-stubs/stubs/Sketchup/Animation.rb +140 -140
- data/lib/sketchup-api-stubs/stubs/Sketchup/AppObserver.rb +157 -157
- data/lib/sketchup-api-stubs/stubs/Sketchup/ArcCurve.rb +209 -209
- data/lib/sketchup-api-stubs/stubs/Sketchup/AttributeDictionaries.rb +152 -152
- data/lib/sketchup-api-stubs/stubs/Sketchup/AttributeDictionary.rb +281 -281
- data/lib/sketchup-api-stubs/stubs/Sketchup/Axes.rb +149 -149
- data/lib/sketchup-api-stubs/stubs/Sketchup/Behavior.rb +328 -328
- data/lib/sketchup-api-stubs/stubs/Sketchup/Camera.rb +577 -577
- data/lib/sketchup-api-stubs/stubs/Sketchup/ClassificationSchema.rb +63 -63
- data/lib/sketchup-api-stubs/stubs/Sketchup/Classifications.rb +122 -122
- data/lib/sketchup-api-stubs/stubs/Sketchup/Color.rb +281 -281
- data/lib/sketchup-api-stubs/stubs/Sketchup/ComponentDefinition.rb +562 -554
- data/lib/sketchup-api-stubs/stubs/Sketchup/ComponentInstance.rb +593 -593
- data/lib/sketchup-api-stubs/stubs/Sketchup/Console.rb +76 -76
- data/lib/sketchup-api-stubs/stubs/Sketchup/ConstructionLine.rb +257 -257
- data/lib/sketchup-api-stubs/stubs/Sketchup/ConstructionPoint.rb +32 -32
- data/lib/sketchup-api-stubs/stubs/Sketchup/Curve.rb +194 -194
- data/lib/sketchup-api-stubs/stubs/Sketchup/DefinitionList.rb +329 -329
- data/lib/sketchup-api-stubs/stubs/Sketchup/DefinitionObserver.rb +72 -72
- data/lib/sketchup-api-stubs/stubs/Sketchup/DefinitionsObserver.rb +102 -102
- data/lib/sketchup-api-stubs/stubs/Sketchup/Dimension.rb +165 -165
- data/lib/sketchup-api-stubs/stubs/Sketchup/DimensionLinear.rb +312 -312
- data/lib/sketchup-api-stubs/stubs/Sketchup/DimensionObserver.rb +38 -38
- data/lib/sketchup-api-stubs/stubs/Sketchup/DimensionRadial.rb +87 -87
- data/lib/sketchup-api-stubs/stubs/Sketchup/Drawingelement.rb +390 -390
- data/lib/sketchup-api-stubs/stubs/Sketchup/Edge.rb +508 -508
- data/lib/sketchup-api-stubs/stubs/Sketchup/EdgeUse.rb +211 -211
- data/lib/sketchup-api-stubs/stubs/Sketchup/Entities.rb +1119 -1097
- data/lib/sketchup-api-stubs/stubs/Sketchup/EntitiesObserver.rb +125 -125
- data/lib/sketchup-api-stubs/stubs/Sketchup/Entity.rb +544 -537
- data/lib/sketchup-api-stubs/stubs/Sketchup/EntityObserver.rb +59 -59
- data/lib/sketchup-api-stubs/stubs/Sketchup/ExtensionsManager.rb +125 -125
- data/lib/sketchup-api-stubs/stubs/Sketchup/Face.rb +750 -750
- data/lib/sketchup-api-stubs/stubs/Sketchup/FrameChangeObserver.rb +104 -104
- data/lib/sketchup-api-stubs/stubs/Sketchup/Group.rb +697 -697
- data/lib/sketchup-api-stubs/stubs/Sketchup/Http.rb +27 -27
- data/lib/sketchup-api-stubs/stubs/Sketchup/Http/Request.rb +285 -285
- data/lib/sketchup-api-stubs/stubs/Sketchup/Http/Response.rb +62 -62
- data/lib/sketchup-api-stubs/stubs/Sketchup/Image.rb +409 -409
- data/lib/sketchup-api-stubs/stubs/Sketchup/ImageRep.rb +226 -226
- data/lib/sketchup-api-stubs/stubs/Sketchup/Importer.rb +190 -190
- data/lib/sketchup-api-stubs/stubs/Sketchup/InputPoint.rb +393 -393
- data/lib/sketchup-api-stubs/stubs/Sketchup/InstanceObserver.rb +82 -82
- data/lib/sketchup-api-stubs/stubs/Sketchup/InstancePath.rb +303 -303
- data/lib/sketchup-api-stubs/stubs/Sketchup/Layer.rb +285 -262
- data/lib/sketchup-api-stubs/stubs/Sketchup/Layers.rb +244 -231
- data/lib/sketchup-api-stubs/stubs/Sketchup/LayersObserver.rb +136 -136
- data/lib/sketchup-api-stubs/stubs/Sketchup/Licensing.rb +48 -48
- data/lib/sketchup-api-stubs/stubs/Sketchup/Licensing/ExtensionLicense.rb +86 -86
- data/lib/sketchup-api-stubs/stubs/Sketchup/LineStyle.rb +24 -24
- data/lib/sketchup-api-stubs/stubs/Sketchup/LineStyles.rb +112 -123
- data/lib/sketchup-api-stubs/stubs/Sketchup/Loop.rb +137 -137
- data/lib/sketchup-api-stubs/stubs/Sketchup/Material.rb +416 -416
- data/lib/sketchup-api-stubs/stubs/Sketchup/Materials.rb +311 -311
- data/lib/sketchup-api-stubs/stubs/Sketchup/MaterialsObserver.rb +141 -141
- data/lib/sketchup-api-stubs/stubs/Sketchup/Menu.rb +95 -95
- data/lib/sketchup-api-stubs/stubs/Sketchup/Model.rb +1638 -1483
- data/lib/sketchup-api-stubs/stubs/Sketchup/ModelObserver.rb +356 -356
- data/lib/sketchup-api-stubs/stubs/Sketchup/OptionsManager.rb +132 -132
- data/lib/sketchup-api-stubs/stubs/Sketchup/OptionsProvider.rb +284 -282
- data/lib/sketchup-api-stubs/stubs/Sketchup/OptionsProviderObserver.rb +58 -58
- data/lib/sketchup-api-stubs/stubs/Sketchup/Page.rb +770 -650
- data/lib/sketchup-api-stubs/stubs/Sketchup/Pages.rb +353 -353
- data/lib/sketchup-api-stubs/stubs/Sketchup/PagesObserver.rb +76 -76
- data/lib/sketchup-api-stubs/stubs/Sketchup/PickHelper.rb +456 -456
- data/lib/sketchup-api-stubs/stubs/Sketchup/RegionalSettings.rb +43 -43
- data/lib/sketchup-api-stubs/stubs/Sketchup/RenderingOptions.rb +364 -356
- data/lib/sketchup-api-stubs/stubs/Sketchup/RenderingOptionsObserver.rb +44 -44
- data/lib/sketchup-api-stubs/stubs/Sketchup/SectionPlane.rb +150 -150
- data/lib/sketchup-api-stubs/stubs/Sketchup/Selection.rb +454 -454
- data/lib/sketchup-api-stubs/stubs/Sketchup/SelectionObserver.rb +115 -115
- data/lib/sketchup-api-stubs/stubs/Sketchup/Set.rb +212 -212
- data/lib/sketchup-api-stubs/stubs/Sketchup/ShadowInfo.rb +257 -257
- data/lib/sketchup-api-stubs/stubs/Sketchup/ShadowInfoObserver.rb +57 -57
- data/lib/sketchup-api-stubs/stubs/Sketchup/Style.rb +69 -69
- data/lib/sketchup-api-stubs/stubs/Sketchup/Styles.rb +211 -211
- data/lib/sketchup-api-stubs/stubs/Sketchup/Text.rb +262 -262
- data/lib/sketchup-api-stubs/stubs/Sketchup/Texture.rb +225 -225
- data/lib/sketchup-api-stubs/stubs/Sketchup/TextureWriter.rb +237 -237
- data/lib/sketchup-api-stubs/stubs/Sketchup/Tool.rb +829 -829
- data/lib/sketchup-api-stubs/stubs/Sketchup/Tools.rb +132 -132
- data/lib/sketchup-api-stubs/stubs/Sketchup/ToolsObserver.rb +154 -154
- data/lib/sketchup-api-stubs/stubs/Sketchup/UVHelper.rb +61 -61
- data/lib/sketchup-api-stubs/stubs/Sketchup/Vertex.rb +142 -142
- data/lib/sketchup-api-stubs/stubs/Sketchup/View.rb +1301 -995
- data/lib/sketchup-api-stubs/stubs/Sketchup/ViewObserver.rb +43 -43
- data/lib/sketchup-api-stubs/stubs/UI/Command.rb +310 -310
- data/lib/sketchup-api-stubs/stubs/UI/HtmlDialog.rb +356 -356
- data/lib/sketchup-api-stubs/stubs/UI/Notification.rb +229 -229
- data/lib/sketchup-api-stubs/stubs/UI/Toolbar.rb +240 -240
- data/lib/sketchup-api-stubs/stubs/UI/WebDialog.rb +633 -633
- data/lib/sketchup-api-stubs/stubs/_top_level.rb +311 -303
- data/lib/sketchup-api-stubs/stubs/array.rb +741 -741
- data/lib/sketchup-api-stubs/stubs/geom.rb +348 -233
- data/lib/sketchup-api-stubs/stubs/languagehandler.rb +92 -92
- data/lib/sketchup-api-stubs/stubs/length.rb +278 -262
- data/lib/sketchup-api-stubs/stubs/numeric.rb +249 -249
- data/lib/sketchup-api-stubs/stubs/sketchup.rb +1310 -1310
- data/lib/sketchup-api-stubs/stubs/sketchupextension.rb +353 -353
- data/lib/sketchup-api-stubs/stubs/string.rb +24 -24
- data/lib/sketchup-api-stubs/stubs/ui.rb +667 -660
- metadata +2 -16
@@ -1,492 +1,492 @@
|
|
1
|
-
# Copyright:: Copyright
|
2
|
-
# License:: The MIT License (MIT)
|
3
|
-
|
4
|
-
# The {#Geom::PolygonMesh} class contains methods to create polygon mesh
|
5
|
-
# structures. This is useful if you need to write a custom importer/exporter in
|
6
|
-
# Ruby that works at the level of triangulated polygons. For example, you can
|
7
|
-
# determine the triangles that make up a 15-sided {#Sketchup::Face} by using
|
8
|
-
# this class, or write a {#Sketchup::Importer} that reads a data file, creates
|
9
|
-
# a mesh from it, and draws faces based on the mesh.
|
10
|
-
#
|
11
|
-
# You can construct a mesh manually using the methods of this class, or you
|
12
|
-
# can get a mesh from a face by calling the Face.mesh method. See
|
13
|
-
# {Sketchup::Entities#add_faces_from_mesh} for an easy way to convert a mesh
|
14
|
-
# back into faces.
|
15
|
-
#
|
16
|
-
# @example
|
17
|
-
# # Grab a mesh from a given face.
|
18
|
-
# my_mesh = some_face.mesh
|
19
|
-
#
|
20
|
-
# # Create a new group that we will populate with the mesh.
|
21
|
-
# group = Sketchup.active_model.entities.add_group
|
22
|
-
# group.entities.add_faces_from_mesh(my_mesh)
|
23
|
-
#
|
24
|
-
# @version SketchUp 6.0
|
25
|
-
class Geom::PolygonMesh
|
26
|
-
|
27
|
-
# Constants
|
28
|
-
|
29
|
-
AUTO_SOFTEN = nil # Stub value.
|
30
|
-
HIDE_BASED_ON_INDEX = nil # Stub value.
|
31
|
-
NO_SMOOTH_OR_HIDE = nil # Stub value.
|
32
|
-
SMOOTH_SOFT_EDGES = nil # Stub value.
|
33
|
-
SOFTEN_BASED_ON_INDEX = nil # Stub value.
|
34
|
-
|
35
|
-
MESH_NORMALS = nil # Stub value.
|
36
|
-
MESH_POINTS = nil # Stub value.
|
37
|
-
MESH_UVQ_BACK = nil # Stub value.
|
38
|
-
MESH_UVQ_FRONT = nil # Stub value.
|
39
|
-
|
40
|
-
# Instance Methods
|
41
|
-
|
42
|
-
# The {#add_point} method is used to add a point to the mesh.
|
43
|
-
#
|
44
|
-
# The index can be used for creating polygons.
|
45
|
-
#
|
46
|
-
# @example
|
47
|
-
# mesh = Geom::PolygonMesh.new
|
48
|
-
# point = Geom::Point3d.new(0, 1, 2)
|
49
|
-
# index = mesh.add_point(point)
|
50
|
-
#
|
51
|
-
# @param [Geom::Point3d] point
|
52
|
-
#
|
53
|
-
# @return [Integer] the index in the mesh for the point
|
54
|
-
#
|
55
|
-
# @version SketchUp 6.0
|
56
|
-
def add_point(point)
|
57
|
-
end
|
58
|
-
|
59
|
-
# The +add_polygon+ method is used for adding a polygon to a
|
60
|
-
# PolygonMesh. All variations of this method require at least 3 elements
|
61
|
-
# to define a polygon, although more may be given.
|
62
|
-
#
|
63
|
-
# @overload add_polygon(index, index, index, ...)
|
64
|
-
#
|
65
|
-
# Adds a polygon from a list of the mesh's vertex indices.
|
66
|
-
# @example
|
67
|
-
# mesh = Geom::PolygonMesh.new
|
68
|
-
# # add points to mesh...
|
69
|
-
# mesh.add_point(Geom::Point3d.new(0, 0, 0))
|
70
|
-
# mesh.add_point(Geom::Point3d.new(1, 0, 0))
|
71
|
-
# mesh.add_point(Geom::Point3d.new(1, 1, 0))
|
72
|
-
# polygon_index = mesh.add_polygon(1, 2, 3)
|
73
|
-
# @param [Integer] index
|
74
|
-
# An index of a vertex in the mesh. Remember that mesh indices start at 1.
|
75
|
-
# @param [Integer] ...
|
76
|
-
# Additional indices (optional)
|
77
|
-
#
|
78
|
-
# @overload add_polygon(index_array)
|
79
|
-
#
|
80
|
-
# Adds a polygon from an Array of the mesh's vertex indices.
|
81
|
-
# @example
|
82
|
-
# mesh = Geom::PolygonMesh.new
|
83
|
-
# # add points to mesh...
|
84
|
-
# mesh.add_point(Geom::Point3d.new(0, 0, 0))
|
85
|
-
# mesh.add_point(Geom::Point3d.new(1, 0, 0))
|
86
|
-
# mesh.add_point(Geom::Point3d.new(1, 1, 0))
|
87
|
-
# polygon_index = mesh.add_polygon([1, 2, 3])
|
88
|
-
# @param [Array<Integer>] index_array
|
89
|
-
# An {Array} of point indices.
|
90
|
-
#
|
91
|
-
# @overload add_polygon(point3d, point3d, point3d, ...)
|
92
|
-
#
|
93
|
-
# Adds a polygon from a list of Point3d objects.
|
94
|
-
# @example
|
95
|
-
# mesh = Geom::PolygonMesh.new
|
96
|
-
# point1 = Geom::Point3d.new(0, 1, 2)
|
97
|
-
# point2 = Geom::Point3d.new(1, 0, 2)
|
98
|
-
# point3 = Geom::Point3d.new(2, 0, 1)
|
99
|
-
# polygon_index = mesh.add_polygon(point1, point2, point3)
|
100
|
-
# @param [Geom::Point3d] point3d
|
101
|
-
# @raise [ArgumentError] When using Arrays in place of Point3d objects.
|
102
|
-
# Normally Arrays may be used in place of Point3d objects in most
|
103
|
-
# SketchUp methods. This method is an exception to that rule.
|
104
|
-
# @param [Geom::Point3d] ...
|
105
|
-
# Additional points (optional)
|
106
|
-
#
|
107
|
-
# @overload add_polygon(point3d_array)
|
108
|
-
#
|
109
|
-
# Adds a polygon from an Array of Point3d objects.
|
110
|
-
# @example
|
111
|
-
# mesh = Geom::PolygonMesh.new
|
112
|
-
# point1 = Geom::Point3d.new(0, 1, 2)
|
113
|
-
# point2 = Geom::Point3d.new(1, 0, 2)
|
114
|
-
# point3 = Geom::Point3d.new(2, 0, 1)
|
115
|
-
# polygon_index = mesh.add_polygon([point1, point2, point3])
|
116
|
-
# @param [Array<Geom::Point3d>] point3d_array
|
117
|
-
#
|
118
|
-
# @overload add_polygon(array)
|
119
|
-
#
|
120
|
-
# Adds a polygon from an Array of 3-element Arrays.
|
121
|
-
# @example
|
122
|
-
# pts = [[0, 0, 0], [1, 0, 0], [1, 1, 0], [0.5, 2, 0], [0, 1, 0]]
|
123
|
-
# mesh = Geom::PolygonMesh.new
|
124
|
-
# polygon_index = mesh.add_polygon(pts)
|
125
|
-
# Sketchup.active_model.entities.add_faces_from_mesh(mesh)
|
126
|
-
# @param [Array<Array(3)>] array
|
127
|
-
# An array of arrays of length 3, where the inner arrays are used as if
|
128
|
-
# they were Point3d objects.
|
129
|
-
#
|
130
|
-
# @return [Integer] The index of the polygon in the mesh.
|
131
|
-
#
|
132
|
-
# @return [0] Invalid index. Returned if the method failed to create a
|
133
|
-
# polygon.
|
134
|
-
#
|
135
|
-
# @version SketchUp 6.0
|
136
|
-
def add_polygon(*args)
|
137
|
-
end
|
138
|
-
|
139
|
-
# The {#count_points} method is used to count the number of points in a mesh.
|
140
|
-
#
|
141
|
-
# @example
|
142
|
-
# mesh = Geom::PolygonMesh.new
|
143
|
-
# point = Geom::Point3d.new(0, 1, 2)
|
144
|
-
# mesh.add_point(point)
|
145
|
-
# num = mesh.count_points
|
146
|
-
#
|
147
|
-
# @return [Integer] the number of points in a mesh
|
148
|
-
#
|
149
|
-
# @version SketchUp 6.0
|
150
|
-
def count_points
|
151
|
-
end
|
152
|
-
|
153
|
-
# The {#count_polygons} count the number of polygons in the mesh.
|
154
|
-
#
|
155
|
-
# @example
|
156
|
-
# mesh = Geom::PolygonMesh.new
|
157
|
-
# point1 = Geom::Point3d.new(0, 1, 2)
|
158
|
-
# point2 = Geom::Point3d.new(1, 0, 2)
|
159
|
-
# point3 = Geom::Point3d.new(2, 0, 1)
|
160
|
-
# mesh.add_polygon(point1, point2, point3)
|
161
|
-
# nump = mesh.count_polygons
|
162
|
-
#
|
163
|
-
# @return [Integer] the number of polygons in the mesh
|
164
|
-
#
|
165
|
-
# @version SketchUp 6.0
|
166
|
-
def count_polygons
|
167
|
-
end
|
168
|
-
|
169
|
-
# Create a new empty polygon mesh. The number of points and polygons are
|
170
|
-
# optional and are just used as a hint to decide how much space to
|
171
|
-
# pre-allocate to speed up adding points and polygons.
|
172
|
-
#
|
173
|
-
# @example
|
174
|
-
# mesh = Geom::PolygonMesh.new
|
175
|
-
#
|
176
|
-
# @overload initialize
|
177
|
-
#
|
178
|
-
# @return [Geom::PolygonMesh]
|
179
|
-
#
|
180
|
-
# @overload initialize(numpts)
|
181
|
-
#
|
182
|
-
# @param [Integer] numpts How many points will be in the mesh.
|
183
|
-
# @return [Geom::PolygonMesh]
|
184
|
-
#
|
185
|
-
# @overload initialize(numpts, numpolys)
|
186
|
-
#
|
187
|
-
# @param [Integer] numpts How many points will be in the mesh.
|
188
|
-
# @param [Integer] numpolys How many polygons will be in the mesh.
|
189
|
-
# @return [Geom::PolygonMesh]
|
190
|
-
#
|
191
|
-
# @raise [RangeError] If number of points or polygons are negative numbers.
|
192
|
-
#
|
193
|
-
# @version SketchUp 6.0
|
194
|
-
def initialize(*args)
|
195
|
-
end
|
196
|
-
|
197
|
-
# The {#normal_at} method is used to determine the vertex normal at a
|
198
|
-
# particular index in the mesh. This only works for meshes retrieved from
|
199
|
-
# {Sketchup::Face#mesh} with the +PolygonMeshNormals+ flag.
|
200
|
-
#
|
201
|
-
# @example
|
202
|
-
# flags = 4 # PolygonMeshNormals
|
203
|
-
# mesh = face.mesh(flags)
|
204
|
-
# normal = mesh.normal_at(1)
|
205
|
-
#
|
206
|
-
# @note Index starts at 1.
|
207
|
-
#
|
208
|
-
# @param [Integer] index
|
209
|
-
# The index in the mesh for the vertex normal to be
|
210
|
-
# retrieved
|
211
|
-
#
|
212
|
-
# @return [Geom::Vector3d, nil]
|
213
|
-
#
|
214
|
-
# @version SketchUp 6.0
|
215
|
-
def normal_at(index)
|
216
|
-
end
|
217
|
-
|
218
|
-
# The {#point_at} method is used to retrieve the point at a specific index in
|
219
|
-
# the mesh.
|
220
|
-
#
|
221
|
-
# @example
|
222
|
-
# mesh = Geom::PolygonMesh.new
|
223
|
-
# point1 = Geom::Point3d.new(0, 1, 2)
|
224
|
-
# point2 = Geom::Point3d.new(10, 20, 30)
|
225
|
-
# mesh.add_point(point1)
|
226
|
-
# mesh.add_point(point2)
|
227
|
-
# point_from_index = mesh.point_at(1)
|
228
|
-
#
|
229
|
-
# @note Index starts at 1.
|
230
|
-
#
|
231
|
-
# @param [Integer] index
|
232
|
-
# The index in the mesh for the point to be retrieved
|
233
|
-
#
|
234
|
-
# @return [Geom::Point3d, nil]
|
235
|
-
#
|
236
|
-
# @version SketchUp 6.0
|
237
|
-
def point_at(index)
|
238
|
-
end
|
239
|
-
|
240
|
-
# The {#point_index} method is used to retrieve the index of a point in the
|
241
|
-
# mesh.
|
242
|
-
#
|
243
|
-
# @example
|
244
|
-
# mesh = Geom::PolygonMesh.new
|
245
|
-
# point1 = Geom::Point3d.new(0, 1, 2)
|
246
|
-
# point2 = Geom::Point3d.new(10, 20, 30)
|
247
|
-
# mesh.add_point(point1)
|
248
|
-
# mesh.add_point(point2)
|
249
|
-
# index = mesh.point_index(point2)
|
250
|
-
#
|
251
|
-
# @note Returns 0 if point is not found.
|
252
|
-
#
|
253
|
-
# @param [Geom::Point3d] point
|
254
|
-
#
|
255
|
-
# @return [Integer] the index in the mesh for the {Geom::Point3d} object
|
256
|
-
#
|
257
|
-
# @version SketchUp 6.0
|
258
|
-
def point_index(point)
|
259
|
-
end
|
260
|
-
|
261
|
-
# The {#points} method is used to retrieve an array of points (vertices) in the
|
262
|
-
# mesh
|
263
|
-
#
|
264
|
-
# @example
|
265
|
-
# mesh = Geom::PolygonMesh.new
|
266
|
-
# point1 = Geom::Point3d.new(0, 1, 2)
|
267
|
-
# point2 = Geom::Point3d.new(10, 20, 30)
|
268
|
-
# mesh.add_point(point1)
|
269
|
-
# mesh.add_point(point2)
|
270
|
-
# # Returns array of points in the mesh.
|
271
|
-
# points = mesh.points
|
272
|
-
#
|
273
|
-
# @return [Array<Geom::Point3d>]
|
274
|
-
#
|
275
|
-
# @version SketchUp 6.0
|
276
|
-
def points
|
277
|
-
end
|
278
|
-
|
279
|
-
# The {#polygon_at} method is used to retrieve an array of vertex index values
|
280
|
-
# for a polygon at a specific index.
|
281
|
-
#
|
282
|
-
# @example
|
283
|
-
# mesh = Geom::PolygonMesh.new
|
284
|
-
# point1 = Geom::Point3d.new(0, 1, 2)
|
285
|
-
# point2 = Geom::Point3d.new(1, 0, 2)
|
286
|
-
# point3 = Geom::Point3d.new(2, 0, 1)
|
287
|
-
# index = mesh.add_polygon(point1, point2, point3)
|
288
|
-
# polygon = mesh.polygon_at(index)
|
289
|
-
#
|
290
|
-
# @note Index starts at 1.
|
291
|
-
#
|
292
|
-
# @note The returned array can contain negative
|
293
|
-
# values with the sign indicating a hidden edge. For example, a return value
|
294
|
-
# of +[-1, 2, 3]+ indicates that the edge from +1+ to +2+ is hidden. The
|
295
|
-
# negative values should not be used as an index for {#point_at}, take the
|
296
|
-
# absolute value of the index value in the polygon array. So if you
|
297
|
-
# get +[-1, 2,3]+ use +1+ as the argument to {#point_at}.
|
298
|
-
#
|
299
|
-
# @param [Integer] index
|
300
|
-
# The index of the desired polygon.
|
301
|
-
#
|
302
|
-
# @return [Array<Geom::Point3d>, nil]
|
303
|
-
#
|
304
|
-
# @version SketchUp 6.0
|
305
|
-
def polygon_at(index)
|
306
|
-
end
|
307
|
-
|
308
|
-
# The {#polygon_points_at} method is used to retrieve the points for a polygon
|
309
|
-
# that is at a specific index in the mesh.
|
310
|
-
#
|
311
|
-
# @example
|
312
|
-
# mesh = Geom::PolygonMesh.new
|
313
|
-
# point1 = Geom::Point3d.new(0, 1, 2)
|
314
|
-
# point2 = Geom::Point3d.new(1, 0, 2)
|
315
|
-
# point3 = Geom::Point3d.new(2, 0, 1)
|
316
|
-
# index = mesh.add_polygon(point1, point2, point3)
|
317
|
-
# points = mesh.polygon_points_at(index)
|
318
|
-
#
|
319
|
-
# @note Index starts at 1.
|
320
|
-
#
|
321
|
-
# @param [Integer] index
|
322
|
-
# An index for a polygon in the mesh.
|
323
|
-
#
|
324
|
-
# @return [Array<Geom::Point3d>, nil]
|
325
|
-
#
|
326
|
-
# @version SketchUp 6.0
|
327
|
-
def polygon_points_at(index)
|
328
|
-
end
|
329
|
-
|
330
|
-
# The {#polygons} method is used to retrieve an array of all polygons in the
|
331
|
-
# mesh.
|
332
|
-
#
|
333
|
-
# The returned array contains an array that can have a negative value with the
|
334
|
-
# sign indicating a hidden edge. For example, a return value of +[-1, 2, 3]+
|
335
|
-
# indicates that the edge from +1+ to +2+ is hidden.
|
336
|
-
#
|
337
|
-
# @example
|
338
|
-
# polygons = polygonmesh.polygons
|
339
|
-
#
|
340
|
-
# @return [Array<Array<Integer>>, Array<nil>]
|
341
|
-
#
|
342
|
-
# @version SketchUp 6.0
|
343
|
-
def polygons
|
344
|
-
end
|
345
|
-
|
346
|
-
# The {#set_point} method is used to set the point at a specific index in the
|
347
|
-
# mesh.
|
348
|
-
#
|
349
|
-
# @example
|
350
|
-
# mesh = Geom::PolygonMesh.new
|
351
|
-
# point1 = Geom::Point3d.new(0, 1, 2)
|
352
|
-
# point2 = Geom::Point3d.new(10, 20, 30)
|
353
|
-
# index = mesh.add_point(point1)
|
354
|
-
# mesh.set_point(index, point2)
|
355
|
-
#
|
356
|
-
# @param [Integer] index
|
357
|
-
# The index where the point will be set.
|
358
|
-
#
|
359
|
-
# @param [Geom::Point3d] point
|
360
|
-
# A Point3d object to set at the index.
|
361
|
-
#
|
362
|
-
# @return [Geom::PolygonMesh]
|
363
|
-
#
|
364
|
-
# @version SketchUp 6.0
|
365
|
-
def set_point(index, point)
|
366
|
-
end
|
367
|
-
|
368
|
-
# The {#set_uv} method is used to define UV mapping coordinates to points in
|
369
|
-
# the mesh.
|
370
|
-
#
|
371
|
-
# Beware that the polygons connected to the point will share UV coordiates so
|
372
|
-
# UV mapping coordinates needs to be continuous across the polygon mesh.
|
373
|
-
#
|
374
|
-
# When setting the UV for a point one need to make sure to have the correct
|
375
|
-
# index for the point. It's therefore best to add the points using {#add_point}
|
376
|
-
# and use the index it returns for following calls to set_uv and
|
377
|
-
# {#add_polygon}.
|
378
|
-
#
|
379
|
-
# If you are not able to calculate how many points there will be in your mesh
|
380
|
-
# make sure to not specify an index in {#set_uv} higher than the number of
|
381
|
-
# times you have called {#set_uv}.
|
382
|
-
#
|
383
|
-
# @example
|
384
|
-
# mesh = Geom::PolygonMesh.new(4)
|
385
|
-
# # Create points for a triangle.
|
386
|
-
# point1 = Geom::Point3d.new(0, 0, 0)
|
387
|
-
# point2 = Geom::Point3d.new(9, 0, 0)
|
388
|
-
# point3 = Geom::Point3d.new(9, 9, 0)
|
389
|
-
# point4 = Geom::Point3d.new(0, 9, 0)
|
390
|
-
# # Create UV mapping to tile 2x cross triangle.
|
391
|
-
# uv1 = Geom::Point3d.new(0, 0, 0)
|
392
|
-
# uv2 = Geom::Point3d.new(2, 0, 0)
|
393
|
-
# uv3 = Geom::Point3d.new(2, 2, 0)
|
394
|
-
# uv4 = Geom::Point3d.new(0, 2, 0)
|
395
|
-
# # Add points and UV data to mesh.
|
396
|
-
# index1 = mesh.add_point(point1)
|
397
|
-
# index2 = mesh.add_point(point2)
|
398
|
-
# index3 = mesh.add_point(point3)
|
399
|
-
# index4 = mesh.add_point(point4)
|
400
|
-
# mesh.set_uv(index1, uv1, true)
|
401
|
-
# mesh.set_uv(index2, uv2, true)
|
402
|
-
# mesh.set_uv(index3, uv3, true)
|
403
|
-
# mesh.set_uv(index4, uv4, true)
|
404
|
-
# # Add polygons.
|
405
|
-
# mesh.add_polygon(index1, index2, index3)
|
406
|
-
# mesh.add_polygon(index1, index3, index4)
|
407
|
-
#
|
408
|
-
# @note If you don't specify how many points you will be adding to the mesh
|
409
|
-
# when you initiate it you may risk the UV data becoming out of sync.
|
410
|
-
#
|
411
|
-
# @param [Integer] index
|
412
|
-
# An Integer representing the UV index.
|
413
|
-
#
|
414
|
-
# @param [Geom::Point3d] point
|
415
|
-
# A Point3d object representing UV coordinates.
|
416
|
-
#
|
417
|
-
# @param [Boolean] front
|
418
|
-
# A boolean representing the front or back.
|
419
|
-
#
|
420
|
-
# @return [nil]
|
421
|
-
#
|
422
|
-
# @version SketchUp 2014
|
423
|
-
def set_uv(index, point, front)
|
424
|
-
end
|
425
|
-
|
426
|
-
# The {#transform!} method is used to apply a transformation to a mesh.
|
427
|
-
#
|
428
|
-
# @example
|
429
|
-
# point1 = Geom::Point3d.new(100, 200, 300)
|
430
|
-
# tr = Geom::Transformation.new(point1)
|
431
|
-
# mesh = Geom::PolygonMesh.new
|
432
|
-
# point2 = Geom::Point3d.new(0, 1, 2)
|
433
|
-
# mesh.add_point(point2)
|
434
|
-
# mesh.transform!(tr)
|
435
|
-
#
|
436
|
-
# @param [Geom::Transformation] transformation
|
437
|
-
#
|
438
|
-
# @return [Geom::PolygonMesh]
|
439
|
-
#
|
440
|
-
# @version SketchUp 6.0
|
441
|
-
def transform!(transformation)
|
442
|
-
end
|
443
|
-
|
444
|
-
# The {#uv_at} method is used to access a uv (texture coordinates) at a
|
445
|
-
# specific index.
|
446
|
-
#
|
447
|
-
# "UVs" is a way of referring to the u,v texture coordinates (as
|
448
|
-
# opposed to the X, Y, and Z axis that you construct your meshes on), which
|
449
|
-
# are points defining 1-by-1 positions within an image. These coordinates
|
450
|
-
# connect to points in your 3D model, to position an image texture onto it's
|
451
|
-
# surface (similar to virtual "thumb tacks")
|
452
|
-
#
|
453
|
-
# These coordinates pin an exact spot on an image that you wish to use to
|
454
|
-
# texture your model to a specific point on an object's surface. Between these
|
455
|
-
# points, your software will stretch the image smoothly. This is what is
|
456
|
-
# referred to as UV mapping.
|
457
|
-
#
|
458
|
-
# @example
|
459
|
-
# point = mesh.uv_at(1, true)
|
460
|
-
#
|
461
|
-
# @param [Integer] index
|
462
|
-
# The index for the texture coordinate.
|
463
|
-
#
|
464
|
-
# @param [Boolean] front
|
465
|
-
# Set to +true+ to get the UV for the front size,
|
466
|
-
# +false+ for the back side.
|
467
|
-
#
|
468
|
-
# @return [Geom::Point3d, nil] a Point3d object where the x equals the u
|
469
|
-
# value and the y equals the v value.
|
470
|
-
# Returns nil on failure.
|
471
|
-
#
|
472
|
-
# @version SketchUp 6.0
|
473
|
-
def uv_at(index, front)
|
474
|
-
end
|
475
|
-
|
476
|
-
# The {#uvs} method is used to retrieve an array of uv coordinates in the
|
477
|
-
# mesh.
|
478
|
-
#
|
479
|
-
# @example
|
480
|
-
# # Get a mesh with front and back UVs.
|
481
|
-
# mesh = face.mesh(1 | 2)
|
482
|
-
# uvs = mesh.uvs(true)
|
483
|
-
#
|
484
|
-
# @param [Boolean] front
|
485
|
-
#
|
486
|
-
# @return [Array<Geom::Point3d>]
|
487
|
-
#
|
488
|
-
# @version SketchUp 6.0
|
489
|
-
def uvs(front)
|
490
|
-
end
|
491
|
-
|
492
|
-
end
|
1
|
+
# Copyright:: Copyright 2020 Trimble Inc.
|
2
|
+
# License:: The MIT License (MIT)
|
3
|
+
|
4
|
+
# The {#Geom::PolygonMesh} class contains methods to create polygon mesh
|
5
|
+
# structures. This is useful if you need to write a custom importer/exporter in
|
6
|
+
# Ruby that works at the level of triangulated polygons. For example, you can
|
7
|
+
# determine the triangles that make up a 15-sided {#Sketchup::Face} by using
|
8
|
+
# this class, or write a {#Sketchup::Importer} that reads a data file, creates
|
9
|
+
# a mesh from it, and draws faces based on the mesh.
|
10
|
+
#
|
11
|
+
# You can construct a mesh manually using the methods of this class, or you
|
12
|
+
# can get a mesh from a face by calling the Face.mesh method. See
|
13
|
+
# {Sketchup::Entities#add_faces_from_mesh} for an easy way to convert a mesh
|
14
|
+
# back into faces.
|
15
|
+
#
|
16
|
+
# @example
|
17
|
+
# # Grab a mesh from a given face.
|
18
|
+
# my_mesh = some_face.mesh
|
19
|
+
#
|
20
|
+
# # Create a new group that we will populate with the mesh.
|
21
|
+
# group = Sketchup.active_model.entities.add_group
|
22
|
+
# group.entities.add_faces_from_mesh(my_mesh)
|
23
|
+
#
|
24
|
+
# @version SketchUp 6.0
|
25
|
+
class Geom::PolygonMesh
|
26
|
+
|
27
|
+
# Constants
|
28
|
+
|
29
|
+
AUTO_SOFTEN = nil # Stub value.
|
30
|
+
HIDE_BASED_ON_INDEX = nil # Stub value.
|
31
|
+
NO_SMOOTH_OR_HIDE = nil # Stub value.
|
32
|
+
SMOOTH_SOFT_EDGES = nil # Stub value.
|
33
|
+
SOFTEN_BASED_ON_INDEX = nil # Stub value.
|
34
|
+
|
35
|
+
MESH_NORMALS = nil # Stub value.
|
36
|
+
MESH_POINTS = nil # Stub value.
|
37
|
+
MESH_UVQ_BACK = nil # Stub value.
|
38
|
+
MESH_UVQ_FRONT = nil # Stub value.
|
39
|
+
|
40
|
+
# Instance Methods
|
41
|
+
|
42
|
+
# The {#add_point} method is used to add a point to the mesh.
|
43
|
+
#
|
44
|
+
# The index can be used for creating polygons.
|
45
|
+
#
|
46
|
+
# @example
|
47
|
+
# mesh = Geom::PolygonMesh.new
|
48
|
+
# point = Geom::Point3d.new(0, 1, 2)
|
49
|
+
# index = mesh.add_point(point)
|
50
|
+
#
|
51
|
+
# @param [Geom::Point3d] point
|
52
|
+
#
|
53
|
+
# @return [Integer] the index in the mesh for the point
|
54
|
+
#
|
55
|
+
# @version SketchUp 6.0
|
56
|
+
def add_point(point)
|
57
|
+
end
|
58
|
+
|
59
|
+
# The +add_polygon+ method is used for adding a polygon to a
|
60
|
+
# PolygonMesh. All variations of this method require at least 3 elements
|
61
|
+
# to define a polygon, although more may be given.
|
62
|
+
#
|
63
|
+
# @overload add_polygon(index, index, index, ...)
|
64
|
+
#
|
65
|
+
# Adds a polygon from a list of the mesh's vertex indices.
|
66
|
+
# @example
|
67
|
+
# mesh = Geom::PolygonMesh.new
|
68
|
+
# # add points to mesh...
|
69
|
+
# mesh.add_point(Geom::Point3d.new(0, 0, 0))
|
70
|
+
# mesh.add_point(Geom::Point3d.new(1, 0, 0))
|
71
|
+
# mesh.add_point(Geom::Point3d.new(1, 1, 0))
|
72
|
+
# polygon_index = mesh.add_polygon(1, 2, 3)
|
73
|
+
# @param [Integer] index
|
74
|
+
# An index of a vertex in the mesh. Remember that mesh indices start at 1.
|
75
|
+
# @param [Integer] ...
|
76
|
+
# Additional indices (optional)
|
77
|
+
#
|
78
|
+
# @overload add_polygon(index_array)
|
79
|
+
#
|
80
|
+
# Adds a polygon from an Array of the mesh's vertex indices.
|
81
|
+
# @example
|
82
|
+
# mesh = Geom::PolygonMesh.new
|
83
|
+
# # add points to mesh...
|
84
|
+
# mesh.add_point(Geom::Point3d.new(0, 0, 0))
|
85
|
+
# mesh.add_point(Geom::Point3d.new(1, 0, 0))
|
86
|
+
# mesh.add_point(Geom::Point3d.new(1, 1, 0))
|
87
|
+
# polygon_index = mesh.add_polygon([1, 2, 3])
|
88
|
+
# @param [Array<Integer>] index_array
|
89
|
+
# An {Array} of point indices.
|
90
|
+
#
|
91
|
+
# @overload add_polygon(point3d, point3d, point3d, ...)
|
92
|
+
#
|
93
|
+
# Adds a polygon from a list of Point3d objects.
|
94
|
+
# @example
|
95
|
+
# mesh = Geom::PolygonMesh.new
|
96
|
+
# point1 = Geom::Point3d.new(0, 1, 2)
|
97
|
+
# point2 = Geom::Point3d.new(1, 0, 2)
|
98
|
+
# point3 = Geom::Point3d.new(2, 0, 1)
|
99
|
+
# polygon_index = mesh.add_polygon(point1, point2, point3)
|
100
|
+
# @param [Geom::Point3d] point3d
|
101
|
+
# @raise [ArgumentError] When using Arrays in place of Point3d objects.
|
102
|
+
# Normally Arrays may be used in place of Point3d objects in most
|
103
|
+
# SketchUp methods. This method is an exception to that rule.
|
104
|
+
# @param [Geom::Point3d] ...
|
105
|
+
# Additional points (optional)
|
106
|
+
#
|
107
|
+
# @overload add_polygon(point3d_array)
|
108
|
+
#
|
109
|
+
# Adds a polygon from an Array of Point3d objects.
|
110
|
+
# @example
|
111
|
+
# mesh = Geom::PolygonMesh.new
|
112
|
+
# point1 = Geom::Point3d.new(0, 1, 2)
|
113
|
+
# point2 = Geom::Point3d.new(1, 0, 2)
|
114
|
+
# point3 = Geom::Point3d.new(2, 0, 1)
|
115
|
+
# polygon_index = mesh.add_polygon([point1, point2, point3])
|
116
|
+
# @param [Array<Geom::Point3d>] point3d_array
|
117
|
+
#
|
118
|
+
# @overload add_polygon(array)
|
119
|
+
#
|
120
|
+
# Adds a polygon from an Array of 3-element Arrays.
|
121
|
+
# @example
|
122
|
+
# pts = [[0, 0, 0], [1, 0, 0], [1, 1, 0], [0.5, 2, 0], [0, 1, 0]]
|
123
|
+
# mesh = Geom::PolygonMesh.new
|
124
|
+
# polygon_index = mesh.add_polygon(pts)
|
125
|
+
# Sketchup.active_model.entities.add_faces_from_mesh(mesh)
|
126
|
+
# @param [Array<Array(3)>] array
|
127
|
+
# An array of arrays of length 3, where the inner arrays are used as if
|
128
|
+
# they were Point3d objects.
|
129
|
+
#
|
130
|
+
# @return [Integer] The index of the polygon in the mesh.
|
131
|
+
#
|
132
|
+
# @return [0] Invalid index. Returned if the method failed to create a
|
133
|
+
# polygon.
|
134
|
+
#
|
135
|
+
# @version SketchUp 6.0
|
136
|
+
def add_polygon(*args)
|
137
|
+
end
|
138
|
+
|
139
|
+
# The {#count_points} method is used to count the number of points in a mesh.
|
140
|
+
#
|
141
|
+
# @example
|
142
|
+
# mesh = Geom::PolygonMesh.new
|
143
|
+
# point = Geom::Point3d.new(0, 1, 2)
|
144
|
+
# mesh.add_point(point)
|
145
|
+
# num = mesh.count_points
|
146
|
+
#
|
147
|
+
# @return [Integer] the number of points in a mesh
|
148
|
+
#
|
149
|
+
# @version SketchUp 6.0
|
150
|
+
def count_points
|
151
|
+
end
|
152
|
+
|
153
|
+
# The {#count_polygons} count the number of polygons in the mesh.
|
154
|
+
#
|
155
|
+
# @example
|
156
|
+
# mesh = Geom::PolygonMesh.new
|
157
|
+
# point1 = Geom::Point3d.new(0, 1, 2)
|
158
|
+
# point2 = Geom::Point3d.new(1, 0, 2)
|
159
|
+
# point3 = Geom::Point3d.new(2, 0, 1)
|
160
|
+
# mesh.add_polygon(point1, point2, point3)
|
161
|
+
# nump = mesh.count_polygons
|
162
|
+
#
|
163
|
+
# @return [Integer] the number of polygons in the mesh
|
164
|
+
#
|
165
|
+
# @version SketchUp 6.0
|
166
|
+
def count_polygons
|
167
|
+
end
|
168
|
+
|
169
|
+
# Create a new empty polygon mesh. The number of points and polygons are
|
170
|
+
# optional and are just used as a hint to decide how much space to
|
171
|
+
# pre-allocate to speed up adding points and polygons.
|
172
|
+
#
|
173
|
+
# @example
|
174
|
+
# mesh = Geom::PolygonMesh.new
|
175
|
+
#
|
176
|
+
# @overload initialize
|
177
|
+
#
|
178
|
+
# @return [Geom::PolygonMesh]
|
179
|
+
#
|
180
|
+
# @overload initialize(numpts)
|
181
|
+
#
|
182
|
+
# @param [Integer] numpts How many points will be in the mesh.
|
183
|
+
# @return [Geom::PolygonMesh]
|
184
|
+
#
|
185
|
+
# @overload initialize(numpts, numpolys)
|
186
|
+
#
|
187
|
+
# @param [Integer] numpts How many points will be in the mesh.
|
188
|
+
# @param [Integer] numpolys How many polygons will be in the mesh.
|
189
|
+
# @return [Geom::PolygonMesh]
|
190
|
+
#
|
191
|
+
# @raise [RangeError] If number of points or polygons are negative numbers.
|
192
|
+
#
|
193
|
+
# @version SketchUp 6.0
|
194
|
+
def initialize(*args)
|
195
|
+
end
|
196
|
+
|
197
|
+
# The {#normal_at} method is used to determine the vertex normal at a
|
198
|
+
# particular index in the mesh. This only works for meshes retrieved from
|
199
|
+
# {Sketchup::Face#mesh} with the +PolygonMeshNormals+ flag.
|
200
|
+
#
|
201
|
+
# @example
|
202
|
+
# flags = 4 # PolygonMeshNormals
|
203
|
+
# mesh = face.mesh(flags)
|
204
|
+
# normal = mesh.normal_at(1)
|
205
|
+
#
|
206
|
+
# @note Index starts at 1.
|
207
|
+
#
|
208
|
+
# @param [Integer] index
|
209
|
+
# The index in the mesh for the vertex normal to be
|
210
|
+
# retrieved
|
211
|
+
#
|
212
|
+
# @return [Geom::Vector3d, nil]
|
213
|
+
#
|
214
|
+
# @version SketchUp 6.0
|
215
|
+
def normal_at(index)
|
216
|
+
end
|
217
|
+
|
218
|
+
# The {#point_at} method is used to retrieve the point at a specific index in
|
219
|
+
# the mesh.
|
220
|
+
#
|
221
|
+
# @example
|
222
|
+
# mesh = Geom::PolygonMesh.new
|
223
|
+
# point1 = Geom::Point3d.new(0, 1, 2)
|
224
|
+
# point2 = Geom::Point3d.new(10, 20, 30)
|
225
|
+
# mesh.add_point(point1)
|
226
|
+
# mesh.add_point(point2)
|
227
|
+
# point_from_index = mesh.point_at(1)
|
228
|
+
#
|
229
|
+
# @note Index starts at 1.
|
230
|
+
#
|
231
|
+
# @param [Integer] index
|
232
|
+
# The index in the mesh for the point to be retrieved
|
233
|
+
#
|
234
|
+
# @return [Geom::Point3d, nil]
|
235
|
+
#
|
236
|
+
# @version SketchUp 6.0
|
237
|
+
def point_at(index)
|
238
|
+
end
|
239
|
+
|
240
|
+
# The {#point_index} method is used to retrieve the index of a point in the
|
241
|
+
# mesh.
|
242
|
+
#
|
243
|
+
# @example
|
244
|
+
# mesh = Geom::PolygonMesh.new
|
245
|
+
# point1 = Geom::Point3d.new(0, 1, 2)
|
246
|
+
# point2 = Geom::Point3d.new(10, 20, 30)
|
247
|
+
# mesh.add_point(point1)
|
248
|
+
# mesh.add_point(point2)
|
249
|
+
# index = mesh.point_index(point2)
|
250
|
+
#
|
251
|
+
# @note Returns 0 if point is not found.
|
252
|
+
#
|
253
|
+
# @param [Geom::Point3d] point
|
254
|
+
#
|
255
|
+
# @return [Integer] the index in the mesh for the {Geom::Point3d} object
|
256
|
+
#
|
257
|
+
# @version SketchUp 6.0
|
258
|
+
def point_index(point)
|
259
|
+
end
|
260
|
+
|
261
|
+
# The {#points} method is used to retrieve an array of points (vertices) in the
|
262
|
+
# mesh
|
263
|
+
#
|
264
|
+
# @example
|
265
|
+
# mesh = Geom::PolygonMesh.new
|
266
|
+
# point1 = Geom::Point3d.new(0, 1, 2)
|
267
|
+
# point2 = Geom::Point3d.new(10, 20, 30)
|
268
|
+
# mesh.add_point(point1)
|
269
|
+
# mesh.add_point(point2)
|
270
|
+
# # Returns array of points in the mesh.
|
271
|
+
# points = mesh.points
|
272
|
+
#
|
273
|
+
# @return [Array<Geom::Point3d>]
|
274
|
+
#
|
275
|
+
# @version SketchUp 6.0
|
276
|
+
def points
|
277
|
+
end
|
278
|
+
|
279
|
+
# The {#polygon_at} method is used to retrieve an array of vertex index values
|
280
|
+
# for a polygon at a specific index.
|
281
|
+
#
|
282
|
+
# @example
|
283
|
+
# mesh = Geom::PolygonMesh.new
|
284
|
+
# point1 = Geom::Point3d.new(0, 1, 2)
|
285
|
+
# point2 = Geom::Point3d.new(1, 0, 2)
|
286
|
+
# point3 = Geom::Point3d.new(2, 0, 1)
|
287
|
+
# index = mesh.add_polygon(point1, point2, point3)
|
288
|
+
# polygon = mesh.polygon_at(index)
|
289
|
+
#
|
290
|
+
# @note Index starts at 1.
|
291
|
+
#
|
292
|
+
# @note The returned array can contain negative
|
293
|
+
# values with the sign indicating a hidden edge. For example, a return value
|
294
|
+
# of +[-1, 2, 3]+ indicates that the edge from +1+ to +2+ is hidden. The
|
295
|
+
# negative values should not be used as an index for {#point_at}, take the
|
296
|
+
# absolute value of the index value in the polygon array. So if you
|
297
|
+
# get +[-1, 2,3]+ use +1+ as the argument to {#point_at}.
|
298
|
+
#
|
299
|
+
# @param [Integer] index
|
300
|
+
# The index of the desired polygon.
|
301
|
+
#
|
302
|
+
# @return [Array<Geom::Point3d>, nil]
|
303
|
+
#
|
304
|
+
# @version SketchUp 6.0
|
305
|
+
def polygon_at(index)
|
306
|
+
end
|
307
|
+
|
308
|
+
# The {#polygon_points_at} method is used to retrieve the points for a polygon
|
309
|
+
# that is at a specific index in the mesh.
|
310
|
+
#
|
311
|
+
# @example
|
312
|
+
# mesh = Geom::PolygonMesh.new
|
313
|
+
# point1 = Geom::Point3d.new(0, 1, 2)
|
314
|
+
# point2 = Geom::Point3d.new(1, 0, 2)
|
315
|
+
# point3 = Geom::Point3d.new(2, 0, 1)
|
316
|
+
# index = mesh.add_polygon(point1, point2, point3)
|
317
|
+
# points = mesh.polygon_points_at(index)
|
318
|
+
#
|
319
|
+
# @note Index starts at 1.
|
320
|
+
#
|
321
|
+
# @param [Integer] index
|
322
|
+
# An index for a polygon in the mesh.
|
323
|
+
#
|
324
|
+
# @return [Array<Geom::Point3d>, nil]
|
325
|
+
#
|
326
|
+
# @version SketchUp 6.0
|
327
|
+
def polygon_points_at(index)
|
328
|
+
end
|
329
|
+
|
330
|
+
# The {#polygons} method is used to retrieve an array of all polygons in the
|
331
|
+
# mesh.
|
332
|
+
#
|
333
|
+
# The returned array contains an array that can have a negative value with the
|
334
|
+
# sign indicating a hidden edge. For example, a return value of +[-1, 2, 3]+
|
335
|
+
# indicates that the edge from +1+ to +2+ is hidden.
|
336
|
+
#
|
337
|
+
# @example
|
338
|
+
# polygons = polygonmesh.polygons
|
339
|
+
#
|
340
|
+
# @return [Array<Array<Integer>>, Array<nil>]
|
341
|
+
#
|
342
|
+
# @version SketchUp 6.0
|
343
|
+
def polygons
|
344
|
+
end
|
345
|
+
|
346
|
+
# The {#set_point} method is used to set the point at a specific index in the
|
347
|
+
# mesh.
|
348
|
+
#
|
349
|
+
# @example
|
350
|
+
# mesh = Geom::PolygonMesh.new
|
351
|
+
# point1 = Geom::Point3d.new(0, 1, 2)
|
352
|
+
# point2 = Geom::Point3d.new(10, 20, 30)
|
353
|
+
# index = mesh.add_point(point1)
|
354
|
+
# mesh.set_point(index, point2)
|
355
|
+
#
|
356
|
+
# @param [Integer] index
|
357
|
+
# The index where the point will be set.
|
358
|
+
#
|
359
|
+
# @param [Geom::Point3d] point
|
360
|
+
# A Point3d object to set at the index.
|
361
|
+
#
|
362
|
+
# @return [Geom::PolygonMesh]
|
363
|
+
#
|
364
|
+
# @version SketchUp 6.0
|
365
|
+
def set_point(index, point)
|
366
|
+
end
|
367
|
+
|
368
|
+
# The {#set_uv} method is used to define UV mapping coordinates to points in
|
369
|
+
# the mesh.
|
370
|
+
#
|
371
|
+
# Beware that the polygons connected to the point will share UV coordiates so
|
372
|
+
# UV mapping coordinates needs to be continuous across the polygon mesh.
|
373
|
+
#
|
374
|
+
# When setting the UV for a point one need to make sure to have the correct
|
375
|
+
# index for the point. It's therefore best to add the points using {#add_point}
|
376
|
+
# and use the index it returns for following calls to set_uv and
|
377
|
+
# {#add_polygon}.
|
378
|
+
#
|
379
|
+
# If you are not able to calculate how many points there will be in your mesh
|
380
|
+
# make sure to not specify an index in {#set_uv} higher than the number of
|
381
|
+
# times you have called {#set_uv}.
|
382
|
+
#
|
383
|
+
# @example
|
384
|
+
# mesh = Geom::PolygonMesh.new(4)
|
385
|
+
# # Create points for a triangle.
|
386
|
+
# point1 = Geom::Point3d.new(0, 0, 0)
|
387
|
+
# point2 = Geom::Point3d.new(9, 0, 0)
|
388
|
+
# point3 = Geom::Point3d.new(9, 9, 0)
|
389
|
+
# point4 = Geom::Point3d.new(0, 9, 0)
|
390
|
+
# # Create UV mapping to tile 2x cross triangle.
|
391
|
+
# uv1 = Geom::Point3d.new(0, 0, 0)
|
392
|
+
# uv2 = Geom::Point3d.new(2, 0, 0)
|
393
|
+
# uv3 = Geom::Point3d.new(2, 2, 0)
|
394
|
+
# uv4 = Geom::Point3d.new(0, 2, 0)
|
395
|
+
# # Add points and UV data to mesh.
|
396
|
+
# index1 = mesh.add_point(point1)
|
397
|
+
# index2 = mesh.add_point(point2)
|
398
|
+
# index3 = mesh.add_point(point3)
|
399
|
+
# index4 = mesh.add_point(point4)
|
400
|
+
# mesh.set_uv(index1, uv1, true)
|
401
|
+
# mesh.set_uv(index2, uv2, true)
|
402
|
+
# mesh.set_uv(index3, uv3, true)
|
403
|
+
# mesh.set_uv(index4, uv4, true)
|
404
|
+
# # Add polygons.
|
405
|
+
# mesh.add_polygon(index1, index2, index3)
|
406
|
+
# mesh.add_polygon(index1, index3, index4)
|
407
|
+
#
|
408
|
+
# @note If you don't specify how many points you will be adding to the mesh
|
409
|
+
# when you initiate it you may risk the UV data becoming out of sync.
|
410
|
+
#
|
411
|
+
# @param [Integer] index
|
412
|
+
# An Integer representing the UV index.
|
413
|
+
#
|
414
|
+
# @param [Geom::Point3d] point
|
415
|
+
# A Point3d object representing UV coordinates.
|
416
|
+
#
|
417
|
+
# @param [Boolean] front
|
418
|
+
# A boolean representing the front or back.
|
419
|
+
#
|
420
|
+
# @return [nil]
|
421
|
+
#
|
422
|
+
# @version SketchUp 2014
|
423
|
+
def set_uv(index, point, front)
|
424
|
+
end
|
425
|
+
|
426
|
+
# The {#transform!} method is used to apply a transformation to a mesh.
|
427
|
+
#
|
428
|
+
# @example
|
429
|
+
# point1 = Geom::Point3d.new(100, 200, 300)
|
430
|
+
# tr = Geom::Transformation.new(point1)
|
431
|
+
# mesh = Geom::PolygonMesh.new
|
432
|
+
# point2 = Geom::Point3d.new(0, 1, 2)
|
433
|
+
# mesh.add_point(point2)
|
434
|
+
# mesh.transform!(tr)
|
435
|
+
#
|
436
|
+
# @param [Geom::Transformation] transformation
|
437
|
+
#
|
438
|
+
# @return [Geom::PolygonMesh]
|
439
|
+
#
|
440
|
+
# @version SketchUp 6.0
|
441
|
+
def transform!(transformation)
|
442
|
+
end
|
443
|
+
|
444
|
+
# The {#uv_at} method is used to access a uv (texture coordinates) at a
|
445
|
+
# specific index.
|
446
|
+
#
|
447
|
+
# "UVs" is a way of referring to the u,v texture coordinates (as
|
448
|
+
# opposed to the X, Y, and Z axis that you construct your meshes on), which
|
449
|
+
# are points defining 1-by-1 positions within an image. These coordinates
|
450
|
+
# connect to points in your 3D model, to position an image texture onto it's
|
451
|
+
# surface (similar to virtual "thumb tacks")
|
452
|
+
#
|
453
|
+
# These coordinates pin an exact spot on an image that you wish to use to
|
454
|
+
# texture your model to a specific point on an object's surface. Between these
|
455
|
+
# points, your software will stretch the image smoothly. This is what is
|
456
|
+
# referred to as UV mapping.
|
457
|
+
#
|
458
|
+
# @example
|
459
|
+
# point = mesh.uv_at(1, true)
|
460
|
+
#
|
461
|
+
# @param [Integer] index
|
462
|
+
# The index for the texture coordinate.
|
463
|
+
#
|
464
|
+
# @param [Boolean] front
|
465
|
+
# Set to +true+ to get the UV for the front size,
|
466
|
+
# +false+ for the back side.
|
467
|
+
#
|
468
|
+
# @return [Geom::Point3d, nil] a Point3d object where the x equals the u
|
469
|
+
# value and the y equals the v value.
|
470
|
+
# Returns nil on failure.
|
471
|
+
#
|
472
|
+
# @version SketchUp 6.0
|
473
|
+
def uv_at(index, front)
|
474
|
+
end
|
475
|
+
|
476
|
+
# The {#uvs} method is used to retrieve an array of uv coordinates in the
|
477
|
+
# mesh.
|
478
|
+
#
|
479
|
+
# @example
|
480
|
+
# # Get a mesh with front and back UVs.
|
481
|
+
# mesh = face.mesh(1 | 2)
|
482
|
+
# uvs = mesh.uvs(true)
|
483
|
+
#
|
484
|
+
# @param [Boolean] front
|
485
|
+
#
|
486
|
+
# @return [Array<Geom::Point3d>]
|
487
|
+
#
|
488
|
+
# @version SketchUp 6.0
|
489
|
+
def uvs(front)
|
490
|
+
end
|
491
|
+
|
492
|
+
end
|