jenncad 1.0.0.pre.alpha12 → 1.0.0.pre.alpha13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jenncad/exporters/openscad.rb +2 -1
- data/lib/jenncad/features/aggregation.rb +1 -1
- data/lib/jenncad/part.rb +6 -2
- data/lib/jenncad/primitives/boolean_object.rb +3 -0
- data/lib/jenncad/primitives/slot.rb +16 -1
- data/lib/jenncad/shortcuts.rb +5 -0
- data/lib/jenncad/thing.rb +35 -32
- data/lib/jenncad/version.rb +1 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c4383fe5f1fe2d17d69eccd66bd28db4678281fd542bd13434064d4051044727
|
4
|
+
data.tar.gz: 0eb4435e845c47ec9b75d113c04b7beae9ce762a2dfa57b598412a243ded0163
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35001c199911e59f66a2ef3ce3b8c6193e5654ebc5463f52add3cb11a5aa3c1684c51dbaad7a3edaf4c0042cf2b2d35410ea01bfdce45e5adc72a96f30ec002b
|
7
|
+
data.tar.gz: 163e8e50aa1dd6ba930fd41e93075aca9f8bed93c6650f3a9984fbc86ddb34f0ae4a499d7fc981a38dfe9bdb1f56a0667a4cec018a530b701f4707141d79233c
|
@@ -245,7 +245,8 @@ module JennCad::Exporters
|
|
245
245
|
|
246
246
|
def handle_aggregation(part, tabindex=0)
|
247
247
|
register_module(part) unless @modules[part.name]
|
248
|
-
|
248
|
+
$log.debug "aggregation #{part.name} transformations: #{part.transformations.inspect}" if part && part.option(:debug)
|
249
|
+
transform(part.clone) do
|
249
250
|
new_obj(part, part.name, nil)
|
250
251
|
end
|
251
252
|
end
|
data/lib/jenncad/part.rb
CHANGED
@@ -3,9 +3,13 @@ module JennCad
|
|
3
3
|
class Part < Thing
|
4
4
|
|
5
5
|
def to_openscad
|
6
|
-
a = Aggregation.new(self.class.to_s, self.
|
6
|
+
a = Aggregation.new(self.class.to_s, self.get_contents)
|
7
7
|
a.transformations = @transformations
|
8
|
-
|
8
|
+
if self.has_explicit_color?
|
9
|
+
a.color(self.color)
|
10
|
+
else
|
11
|
+
a.color(:auto)
|
12
|
+
end
|
9
13
|
a
|
10
14
|
end
|
11
15
|
|
@@ -7,7 +7,9 @@ module JennCad::Primitives
|
|
7
7
|
else
|
8
8
|
@parts = parts
|
9
9
|
end
|
10
|
+
|
10
11
|
@parent = @parts.first.parent
|
12
|
+
|
11
13
|
after_add
|
12
14
|
end
|
13
15
|
|
@@ -22,6 +24,7 @@ module JennCad::Primitives
|
|
22
24
|
end
|
23
25
|
|
24
26
|
def add(part)
|
27
|
+
return if part.nil?
|
25
28
|
@parts << part
|
26
29
|
after_add
|
27
30
|
end
|
@@ -36,10 +36,25 @@ module JennCad::Primitives
|
|
36
36
|
@d = @opts[:d]
|
37
37
|
@a = @opts[:a]
|
38
38
|
@h = @opts[:h]
|
39
|
-
@r = @opts[:r]
|
39
|
+
@r = @opts[:r] || nil
|
40
|
+
if @r
|
41
|
+
@d = @r * 2
|
42
|
+
end
|
40
43
|
@fn = @opts[:fn]
|
41
44
|
@len_x = @opts[:x]
|
42
45
|
@len_y = @opts[:y]
|
46
|
+
tx = @opts[:tx] || @opts[:total_x] || nil
|
47
|
+
ty = @opts[:ty] || @opts[:total_y] || nil
|
48
|
+
if tx
|
49
|
+
@len_x = tx - @d
|
50
|
+
end
|
51
|
+
if ty
|
52
|
+
@len_y = ty - @d
|
53
|
+
end
|
54
|
+
|
55
|
+
# TODO: this needs anchors like cube
|
56
|
+
# TODO: color on this needs to apply to hull, not on the cylinders.
|
57
|
+
|
43
58
|
end
|
44
59
|
|
45
60
|
def to_openscad
|
data/lib/jenncad/shortcuts.rb
CHANGED
@@ -92,6 +92,11 @@ module JennCad
|
|
92
92
|
|
93
93
|
private
|
94
94
|
def boolean_operation(part, klass)
|
95
|
+
if part.respond_to? :transformations
|
96
|
+
# Since ruby doesn't provide a way to make a deep clone, this seems to be the simplest solution that will effectively do that:
|
97
|
+
part = Marshal.load(Marshal.dump(part))
|
98
|
+
end
|
99
|
+
|
95
100
|
case self
|
96
101
|
when nil
|
97
102
|
part
|
data/lib/jenncad/thing.rb
CHANGED
@@ -20,6 +20,7 @@ module JennCad
|
|
20
20
|
@anchors = {}
|
21
21
|
@parent = args[:parent]
|
22
22
|
@opts ||= args
|
23
|
+
@cache = nil
|
23
24
|
end
|
24
25
|
|
25
26
|
def option(key)
|
@@ -39,13 +40,19 @@ module JennCad
|
|
39
40
|
|
40
41
|
def anchor(name, thing=nil)
|
41
42
|
if thing
|
42
|
-
|
43
|
+
res = thing.anchor(name)
|
44
|
+
return res unless res.nil?
|
43
45
|
end
|
44
46
|
@anchors ||= {}
|
45
47
|
if anch = @anchors[name]
|
46
48
|
return anch
|
47
49
|
elsif @parent
|
48
50
|
return @parent.anchor(name)
|
51
|
+
elsif self.respond_to? :get_contents
|
52
|
+
con = get_contents
|
53
|
+
if con.respond_to? :anchor
|
54
|
+
con.anchor(name)
|
55
|
+
end
|
49
56
|
end
|
50
57
|
end
|
51
58
|
alias :a :anchor
|
@@ -209,6 +216,7 @@ module JennCad
|
|
209
216
|
# move to anchor
|
210
217
|
def movea(key, thing=nil)
|
211
218
|
an = anchor(key, thing)
|
219
|
+
|
212
220
|
unless an
|
213
221
|
$log.error "Error: Anchor #{key} not found"
|
214
222
|
$log.error "Available anchors: #{@anchors}"
|
@@ -341,36 +349,14 @@ module JennCad
|
|
341
349
|
def get_children(item, stop_at)
|
342
350
|
res = [item]
|
343
351
|
if item.respond_to?(:parts) && item.parts != nil
|
344
|
-
item.parts.each do |
|
345
|
-
unless stop_at != nil &&
|
346
|
-
res << get_children(
|
352
|
+
item.parts.each do |pa|
|
353
|
+
unless stop_at != nil && pa.kind_of?(stop_at)
|
354
|
+
res << get_children(pa, stop_at)
|
347
355
|
end
|
348
356
|
end
|
349
357
|
end
|
350
358
|
res
|
351
359
|
end
|
352
|
-
=begin def make_openscad_compatible
|
353
|
-
make_openscad_compatible!(self)
|
354
|
-
end
|
355
|
-
|
356
|
-
def make_openscad_compatible!(item)
|
357
|
-
if item.respond_to?(:parts) && item.parts != nil
|
358
|
-
item.parts.each_with_index do |part, i|
|
359
|
-
if part.respond_to? :to_openscad
|
360
|
-
item.parts[i] = part.to_openscad
|
361
|
-
else
|
362
|
-
item.parts[i] = part.make_openscad_compatible
|
363
|
-
end
|
364
|
-
end
|
365
|
-
elsif item.respond_to? :part
|
366
|
-
item = item.part.make_openscad_compatible
|
367
|
-
end
|
368
|
-
if item.respond_to? :to_openscad
|
369
|
-
item = item.to_openscad
|
370
|
-
end
|
371
|
-
item
|
372
|
-
end
|
373
|
-
=end
|
374
360
|
|
375
361
|
def inherit_color(other)
|
376
362
|
self.set_option(:color, other.option(:color))
|
@@ -386,11 +372,14 @@ module JennCad
|
|
386
372
|
|
387
373
|
def only_color?(parts, lvl=0)
|
388
374
|
return true if parts == nil
|
375
|
+
unless parts.kind_of? Array
|
376
|
+
parts = [parts]
|
377
|
+
end
|
389
378
|
|
390
379
|
parts.each do |part|
|
391
|
-
#
|
380
|
+
#puts " " * lvl + "[only_color?] #{part}"
|
392
381
|
if part.has_explicit_color?
|
393
|
-
#
|
382
|
+
#puts " " * lvl + "found explicit color here: #{part.color}"
|
394
383
|
return false
|
395
384
|
end
|
396
385
|
if !only_color?(part.parts, lvl+1)
|
@@ -406,14 +395,14 @@ module JennCad
|
|
406
395
|
parts.each do |part|
|
407
396
|
unless part.has_explicit_color?
|
408
397
|
if only_color?(part.parts, lvl+1)
|
409
|
-
#
|
398
|
+
#puts " " * lvl + "children have no explicit color, setting it here"
|
410
399
|
part.set_auto_color(col)
|
411
400
|
else
|
412
|
-
#
|
401
|
+
#puts " " * lvl + "[set_auto_color_for_children] #{part}"
|
413
402
|
set_auto_color_for_children(col, part.parts, lvl+1)
|
414
403
|
end
|
415
404
|
else
|
416
|
-
#
|
405
|
+
#puts " " * lvl + "[set_auto_color_for_children] this part has a color #{part.color}, ignoring their children"
|
417
406
|
end
|
418
407
|
|
419
408
|
end
|
@@ -489,8 +478,15 @@ module JennCad
|
|
489
478
|
|
490
479
|
def get_contents
|
491
480
|
return @parts unless @parts.nil?
|
481
|
+
|
482
|
+
if @cache
|
483
|
+
return @cache
|
484
|
+
end
|
485
|
+
|
492
486
|
if self.respond_to? :part
|
493
|
-
|
487
|
+
# cache things to prevent calling the code in #part multiple times
|
488
|
+
@cache = part
|
489
|
+
return @cache
|
494
490
|
end
|
495
491
|
end
|
496
492
|
|
@@ -503,6 +499,9 @@ module JennCad
|
|
503
499
|
|
504
500
|
def find_calculated_h(parts)
|
505
501
|
return if parts == nil
|
502
|
+
unless parts.kind_of? Array
|
503
|
+
parts = [parts]
|
504
|
+
end
|
506
505
|
parts.each do |part|
|
507
506
|
if z = calculated_h
|
508
507
|
return z
|
@@ -513,6 +512,10 @@ module JennCad
|
|
513
512
|
|
514
513
|
def set_heights_for_auto_extrude(parts, parent=nil)
|
515
514
|
return if parts.nil?
|
515
|
+
unless parts.kind_of? Array
|
516
|
+
parts = [parts]
|
517
|
+
end
|
518
|
+
|
516
519
|
parts.each do |part|
|
517
520
|
if part.option(:auto_extrude)
|
518
521
|
part.z = parent.calculated_h
|
data/lib/jenncad/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jenncad
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.pre.
|
4
|
+
version: 1.0.0.pre.alpha13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jennifer Glauche
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-05-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: geo3d
|