Author | Manuela Ruiz (mruiz@lcc.uma.es) |
A sort of Constraint: the shapes in the design cannot be outside an area
points | array of points limitting the area |
Initializing
# File lib/constraints.rb, line 133 133: def initialize(points = nil) 134: if points 135: @area = Area.new points 136: else 137: @area = Area.new Constants::PTS_AREA.clone 138: end 139: @name = Constants::AREA_CONSTRAINT_NAME 140: end
Writer for the involved area
# File lib/constraints.rb, line 189 189: def area=(new_area) 190: @area.erase 191: @area = new_area 192: end
Deletes the area
# File lib/constraints.rb, line 184 184: def delete() 185: @area.erase 186: end
Returns true iff the shapes in the design are inside the area
# File lib/constraints.rb, line 143 143: def satisfied?() 144: execution = Shade.project.execution 145: 146: satisfied = true 147: j = 0 148: n_layers = Sketchup.active_model.layers.length 149: layer_name = "Layer0" 150: while (satisfied and (j < n_layers)) 151: layer_name = Sketchup.active_model.layers[j].name 152: 153: segments = execution.current_shape.s[layer_name] 154: segments.reset_iterator 155: 156: while satisfied and (s_node = segments.get_next) 157: s_list = s_node.list 158: s_list.reset_iterator 159: while satisfied and (s = s_list.get_next) 160: satisfied = ((@area.cover_point? s.key.tail.point.transform(Constants::AXIOM_T)) && (@area.cover_point? s.key.head.point.transform(Constants::AXIOM_T))) 161: end 162: end 163: 164: if satisfied 165: points = execution.current_shape.p[layer_name] 166: points.reset_iterator 167: while satisfied and (p_node = points.get_next) 168: if !(p_node.key.value == Constants::INTERSECTION_LABEL) 169: p_list = p_node.list 170: p_list.reset_iterator 171: while satisfied and (p = p_list.get_next) 172: satisfied = (@area.cover_point? p.key.point.transform(Constants::AXIOM_T)) 173: end 174: end 175: end 176: end 177: 178: j += 1 179: end 180: return satisfied 181: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.