//Last edited on 2019-12-11 17:12:44 by jstolfi #include "duble_closet_stack.inc" #include "double_closet_walls.inc" #macro double_closet_section ( space_dim, sec_dim, shf_N, shf_ht, walls_side_th, walls_rear_th, walls_face_th, walls_bot_th, walls_top_th, shf_face_th, shf_bot_th, sec_hinges, handle_dim, tx_walls_in, tx_walls_out, tx_shelf, tx_handle, tagg, what, ishf, dim_only ) // A single section of the closet of shelves for the workshop. // The X axis is back to front. // The Y axis is across the closet, left to right. // The Z axis is up. // The origin is at the back left bottom corner of the nominal dimensions. // {space_dim} is the dimensions of the available space. // {seccloset_dim} is the nominal dimensions of the section, excl. handles. // {shf_N} is the number of shelves. // {shf_ht} is an array of {shf_N} elems with the shelf heights, bottom to top. // {sec_hinges} says whether there should be hinges on the left side (1), right side (2) or both (3). // {handle_dim} is the dimensions of a box that encloses the handle, nominally. // {walls_side_th} is the thickness of left and right walls. // {walls_rear_th, walls_face_th, walls_face_th, walls_face_th} is the thickness of rear wall. // {walls_bot_th} is the thickness of bottom wall. // {walls_top_th} is the thickness of top wall // {shf_face_th} is the thickness of the front wall (face plate) of shelves. // {shf_bot_th} is the thickness of the bottom wall of shelves. // The doors are swung open by various angles up to {maxopen} (degrees). // If {what=5} returns only the walls of the section. // If {what=4} returns only the cavity within the walls of the section. // If {what=3} returns only the shelves of the section. // If {what=2} returns only shelf {ishf} of the section. // If {what=1} returns only the ??? (minus the face plate). // If {what=0} returns the useful cavity of that shelf (minus walls and clearances). // If {what=-1} returns the handle of the section. // If {what=-2} returns that handle's mounting's hole (to be subtracted from the front wall). // If {dim_only} is true returns only the nominal bounding box of the (sub)object, // (closed, unexploded) instead of the object itself. For the whole object, // the lower corner of the nominal box will be at the origin. // The nominal box of any sub-object will be positioned relative to // that of the whole object. Its position (but not its size) takes // explosion into account. // The nominal bounding box of the whole closet does not include the door // handles. Its low corner will be at the origin. // Unused space: #local skosh = space_dim - closet_dim; // Total unused space around closet. #debug concat("\n!! unused space around closet = ") #debug concat(str(skosh.x,0,1), " ", str(skosh.y,0,1), " ", str(skosh.z,0,1), "\n") #local whole = 7; // Value of {what} for whole closet. #if ((what = whole) & dim_only) #local res = box{ < 0, 0, 0 >, closet_dim texture{ tx_space } } #else // Outer dimensions of walls: #local walls_dim = closet_dim; #if ((what = whole) | (what = 6) | (what = 5) | (what = 4)) // Requires walls or sub-object thereof: #local subwhat = #if (what >= 5) 2; #else 1; #end // What sub-object of the walls? #local walls = object{ double_closet_walls ( walls_dim, walls_side_th, walls_rear_th, walls_face_th, walls_bot_th, walls_top_th, tx_walls_in, tx_walls_out, concat(tagg,".W"), subwhat, isd, dim_only ) } #end #if ((what = whole) | (what <= 3)) // Drawers or sub-object thereof: #local subwhat = #if (what >= 6) 3; #else what; #end // What sub-object? // Get dimensions and position of cavity in walls: #local walls_hole = object{ double_closet_walls ( walls_dim, walls_side_th, walls_rear_th, walls_bot_th, walls_top_th, tx_walls_in, tx_walls_out, "XX", 1, isd, true ) } #local walls_hole_disp = min_extent(walls_hole); #local walls_hole_dim = max_extent(walls_hole) - walls_hole_disp; // Dimensions and position of shelf stack: #local stack_xsz = walls_hole_dim.x - ???; #local stack_ysz = walls_hole_dim.y; #local stack_xsz = stack_xsz + shf_face_th; #local stack_disp = walls_hole_disp + ???*x + ???*z; // Total height of shelves and top clearance: #local stack_zsz = 0; #for( kk, 0, shf_N-1, 1 ) #local stack_zsz = stack_zsz + shf_ht???kk]; #end // Face plate overshoots and false shelves: #local fclear = 0.5; // Clearance around face plates. #local shf_ebtw = 2*fclear; // Clearance between face plates of successive shelves. #if (??? = 0) // Recessed shelves: #local shf_ey = - fclear; // No face plate overshoot in {Y}, some clearance. #local shf_fake_bot_ht = 0; // No false bottom shelf. #local shf_fake_top_ht = 0; // No false top shelf. #elseif (??? = 1) // Protruding shelves: #local shf_ey = walls_side_th; // Face plate overshoot in {Y}. #local shf_ebot = - fclear; // No bottom face plate overshoot in {-Z}. #local shf_etop = - fclear; // No top face plate overshoot in {+Z}. #local shf_fake_bot_ht = ??? + walls_bot_th; // False shelf at bottom. #local shf_fake_top_ht = ??? + walls_top_th; // False shelf at top. #end // The shelf stack or part thereof: #local shelf_stack = object{ wshop_shelf_stack ( stack_xsz, stack_ysz, shf_N, shf_ht, ???, handle_dim, shf_face_th, ???, ???, ???, shf_bot_th, ???, ???, shf_ey, shf_ebot, shf_etop, shf_ebtw, shf_fake_bot_ht, shf_fake_top_ht, ???, max_open, tx_shelf, ???, tx_handle, ???, concat(tagg,".DR"), subwhat, ishf, dim_only ) translate stack_disp } #end #if (what = whole) #local res = union{ object{ walls } object{ shelf_stack } } #elseif ((what = 5) | (what = 4)) #local res = object{ walls } #else #local res = object{ shelf_stack } #end #end res #end