jenncad 1.0.0.pre.alpha10 → 1.0.0.pre.alpha11

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 14729ddf8a7adb190fd55bd555bff63515420acd3468daaa2d254a06069f213d
4
- data.tar.gz: 41237b37c2a7bb301981fce8a44d7772e37fcd75880dba73b47872d4f9729dbe
3
+ metadata.gz: 5e77957381ff8c5d69c62508dad6309d647b56377085319443b6938c2bf88ce2
4
+ data.tar.gz: 0f1893fcea231e2009fc6a3b5f6224483e413e648f7681d6ae0e85be64bba92e
5
5
  SHA512:
6
- metadata.gz: 58e2c3db175c7fdbcdc34817460f44460766c4469dca347fe4a98163c2dd212e9510069f458ee152475385bb56d80f5a62b119002b8debd9c41b7a05ec567fe0
7
- data.tar.gz: d094fd51199bb1de45d3952f9fc66f4f2aa685177f3c4064c984459b95ad4082d1af52b202bedf71a749e5a9c8347eea334042703aea5c229e591537fb9e2a5b
6
+ metadata.gz: '047058746e5a8bb3c44995c5ea21edf308272844722f02820300de08493bfc24bec0cd74e26c4343d9fe2ffe514f9c8c57a3ba0981c871c0b161f18705099652'
7
+ data.tar.gz: 724cbde8c1efa685b3762b7a51c27efd0812a8839d7147e832bede775a695b9e05af0dfbc996b139c531b5f78af26e6560a27efc99024fbbda54f8cf2835e3ef
@@ -8,7 +8,6 @@ module JennCad::Primitives
8
8
  @parts = parts
9
9
  end
10
10
  @parent = @parts.first.parent
11
-
12
11
  after_add
13
12
  end
14
13
 
@@ -30,10 +29,17 @@ module JennCad::Primitives
30
29
  def after_add
31
30
  @parts.flatten!
32
31
  @parts.compact!
32
+ inherit_debug
33
33
  inherit_z
34
34
  inherit_zref
35
35
  end
36
36
 
37
+ def inherit_debug
38
+ if @parts.map{|l| l.option(:debug)}.include? true
39
+ set_option(:debug, true)
40
+ end
41
+ end
42
+
37
43
  def inherit_z
38
44
  heights = @parts.map{|l| l.calc_z.to_f}.uniq
39
45
  if heights.size > 1
@@ -77,6 +83,8 @@ module JennCad::Primitives
77
83
  when Array
78
84
  res << obj.map{|l| only_additives_of(l)}
79
85
  when SubtractObject
86
+ # include the thing that something was subtracted from to get the Z height if that is behind another layer of SubtractObject
87
+ res << only_additives_of(obj.parts.first)
80
88
  when IntersectionObject
81
89
  else
82
90
  res << obj
@@ -2,6 +2,7 @@ module JennCad::Primitives
2
2
  class Cube < Primitive
3
3
  extend JennCad::Features::Cuttable
4
4
 
5
+ attr_accessor :corners, :sides
5
6
 
6
7
  def feed_opts(args)
7
8
  # FIXME: this doesn't seem to work
@@ -47,6 +48,7 @@ module JennCad::Primitives
47
48
  @h = @z.dup
48
49
  @calc_h = @z.dup
49
50
 
51
+
50
52
  set_anchors
51
53
  end
52
54
 
@@ -56,28 +58,91 @@ module JennCad::Primitives
56
58
  if @opts[:center] || @opts[:center_x]
57
59
  left = -@opts[:x] / 2.0
58
60
  right = @opts[:x] / 2.0
61
+ mid_x = 0
59
62
  else
60
63
  left = 0
61
64
  right = @opts[:x]
65
+ mid_x = @opts[:x] / 2.0
62
66
  end
63
67
  if @opts[:center] || @opts[:center_y]
64
68
  bottom = -@opts[:y] / 2.0
65
69
  top = @opts[:y] / 2.0
70
+ mid_y = 0
66
71
  else
67
72
  bottom = 0
68
73
  top = @opts[:y]
74
+ mid_y = @opts[:y] / 2.0
69
75
  end
70
76
 
71
- set_anchor :left, x: left
72
- set_anchor :right, x: right
73
- set_anchor :top, y: top
74
- set_anchor :bottom, y: bottom
77
+ set_anchor :left, x: left, y: mid_y
78
+ set_anchor :right, x: right, y: mid_y
79
+ set_anchor :top, x: mid_x, y: top
80
+ set_anchor :bottom, x: mid_x, y: bottom
75
81
  set_anchor :top_left, x: left, y: top
76
82
  set_anchor :top_right, x: right, y: top
77
83
  set_anchor :bottom_left, x: left, y: bottom
78
84
  set_anchor :bottom_right, x: right, y: bottom
85
+
86
+ # we need to re-do the inner ones, if they were defined
87
+ if @inner_anchor_defs && @inner_anchor_defs.size > 0
88
+ @inner_anchor_defs.each do |anch|
89
+ inner_anchors(anch[:dist], anch[:prefix], true)
90
+ end
91
+ end
92
+
93
+ self
79
94
  end
80
95
 
96
+ def inner_anchors(dist, prefix=:inner_, recreate=false)
97
+ @inner_anchor_defs ||= []
98
+ @inner_anchor_defs << { "dist": dist, "prefix": prefix } unless recreate
99
+
100
+ # $log.info "dist: #{dist}, prefix: #{prefix}"
101
+ sides = {
102
+ left: {x: dist, y: 0},
103
+ right: {x: -dist, y: 0},
104
+ top: {x: 0, y: -dist},
105
+ bottom: {x: 0, y: dist},
106
+ }
107
+ corners = {
108
+ top_left: {x: dist, y: -dist},
109
+ top_right: {x: -dist, y: -dist},
110
+ bottom_left: {x: dist, y: dist},
111
+ bottom_right: {x: -dist, y: dist},
112
+ }
113
+ new_sides = []
114
+ new_corners = []
115
+
116
+ sides.merge(corners).each do |key, vals|
117
+ new_dist = anchor(key).dup
118
+ new_dist[:x] += vals[:x]
119
+ new_dist[:y] += vals[:y]
120
+ name = [prefix, key].join.to_sym
121
+ # $log.info "Set anchor #{name} , new dist #{new_dist}"
122
+ set_anchor name, new_dist
123
+ if sides.include? key
124
+ new_sides << name
125
+ end
126
+ if corners.include? key
127
+ new_corners << name
128
+ end
129
+ end
130
+
131
+ sides_name = [prefix, "sides"].join
132
+ corners_name = [prefix, "corners"].join
133
+ all_name = [prefix, "all"].join
134
+ self.class.__send__(:attr_accessor, sides_name.to_sym)
135
+ self.class.__send__(:attr_accessor, corners_name.to_sym)
136
+ self.class.__send__(:attr_accessor, all_name.to_sym)
137
+ self.__send__("#{sides_name}=", new_sides)
138
+ self.__send__("#{corners_name}=", new_corners)
139
+ self.__send__("#{all_name}=", new_corners+new_sides)
140
+
141
+
142
+ self
143
+ end
144
+
145
+
81
146
  # used for openscad export
82
147
  def size
83
148
  [@x, @y, z+z_margin]
@@ -3,10 +3,16 @@ module JennCad::Primitives
3
3
  def inherit_z
4
4
  @z = 0
5
5
  @calc_z = parts.first.calc_z.to_f
6
+
6
7
  only_additives_of(@parts).each do |p|
8
+ if option(:debug)
9
+ $log.debug "inherit_z checks for: #{p}"
10
+ end
7
11
  z = p.z.to_f
8
12
  @z = z if z > @z
9
13
  end
14
+ $log.debug "inherit_z called, biggest z found: #{@z}" if option(:debug)
15
+
10
16
  end
11
17
 
12
18
  def get_heights(obj)
@@ -58,7 +64,7 @@ module JennCad::Primitives
58
64
  when JennCad::Circle
59
65
  when JennCad::BooleanObject
60
66
  else
61
- pp part if part.opts[:debug]
67
+ $log.debug part if part.opts[:debug]
62
68
  part.opts[:margins][:z] ||= 0.0
63
69
  unless part.opts[:margins][:z] == 0.2
64
70
  part.opts[:margins][:z] = 0.2
@@ -66,7 +72,7 @@ module JennCad::Primitives
66
72
  end
67
73
  end
68
74
  elsif part.z == compare_h
69
- # puts "fixing possible z fighting: #{part.class} #{part.z}"
75
+ $log.debug "fixing possible z fighting: #{part.class} #{part.z}" if part.opts[:debug]
70
76
  part.opts[:margins][:z] += 0.008
71
77
  part.mz(-0.004)
72
78
  elsif part.calc_z == compare_z
data/lib/jenncad/thing.rb CHANGED
@@ -19,9 +19,6 @@ module JennCad
19
19
  @calc_h = args[:z] || 0
20
20
  @anchors = {}
21
21
  @parent = args[:parent]
22
- if @parent
23
- log.info "Parent: #{@parent}"
24
- end
25
22
  @opts ||= args
26
23
  end
27
24
 
@@ -1,4 +1,4 @@
1
1
  module JennCad
2
- VERSION = "1.0.0-alpha10"
2
+ VERSION = "1.0.0-alpha11"
3
3
  end
4
4
 
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.alpha10
4
+ version: 1.0.0.pre.alpha11
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-04-29 00:00:00.000000000 Z
11
+ date: 2022-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: geo3d