
############################
### diag @ IAM @ DM2_w25 ###
### hu_03 setUp_ver01    ### see examples @ DM2_w23 hu_03 !
############################


##############################
import rhinoscriptsyntax as rs
import random, time, sys   ###
sys.path.append("P:/")     ###                  ### diag's path to DM_lib.py  .. please keep it !                                               
sys.path.append("P:/WWW/limafi/dm2/")### *your* path to DM_lib.py                                            
import DM_lib as dm        ###                  ### "dm" is alias for DM_lib / for adressing definitions etc in "DM_lib.py"
############################## reload( dm )

rs.ShowGrid(show=0)
rs.ShowGridAxes(show=1)
rs.ViewDisplayMode(mode="Wireframe")
rs.AppearanceColor(item=0, color=[222, 222, 22])               ### item=0 => backgroundColor [R,G,B]
rs.UnitSystem(unit_system=3)                                    ### 2..mm / 3..cm / 4..m etc >> printDisplay scale !

dm.PointRadius(displayModeX=0, rad=2, styl=3)                   ### displayModeX=0="Wireframe" / rad=size of points / styl=pointStyle (try 0..5) / default 3, 3
dm.printDisplay(state=1, scale=1, thickness=1, color="Display") ### state=0/1 = off/on / for showing printWidth etc << UnitSystem

rs.EnableRedraw(0)
dm.eAA()                                    ### erase Absolutly All - includes locked, hidden etc objects 



### BASIC SETUP / mandatory input / dm.setUp_hu_03(..):

### arguments @ dm.setUp_hu_03(..):

### allInOne 0: coords of slices / faces / edges / meridians etc in *separate* (sub_)lists
### allInOne 1: all cube_coords and all sphere_coords in *jeweils* 1 (one !) list

### what = "A" : A.ll coords 
### what = "E" : E.dge's coords of cube / meridians of sphere / in 12 separate lists
### what = "F" : F.ace's coords of cube / meridians of sphere / in  6 separate lists

###  all other : arguments/defaults as defined @ library

allInOne  = 1

### DEFAULT arguments:
### allCoords = dm.setUp_hu_03(edge_len=random.uniform(8,16), anz_pts=random.randint(8,16), what="A", angle=random.uniform(-360, 360), axe=dm.randVec(), pos=[0,0,random.uniform(8,16)], allInOne=allInOne, verbose=1)
allCoords = dm.setUp_hu_03(edge_len=random.uniform(8,16), anz_pts=random.randint(8,16), what="A", angle=random.uniform(-360, 360), axe=dm.randVec(), pos=[0,0,random.uniform(8,16)], allInOne=allInOne, verbose=1)

### here YOU mite set YOUR favorite arguments:
#allCoords = dm.setUp_hu_03(edge_len=10, anz_pts=5, what="f", angle=random.uniform(-360, 360)*0, axe=randVec(), pos=[0,0,10], allInOne=allInOne, verbose=1)


######################## dont't touch
coordsSph = allCoords[0]
coordsCub = allCoords[1]
########################

'''
' check setup - just visualization of setUp >> dont execute @ final version of homework <<                                      '
'''
if 0:
    if allInOne == 1:
        pts = rs.AddPoints( coordsSph )
        rs.AddGroup("sph"), rs.AddObjectsToGroup(pts, "sph")
        rs.ObjectColor( pts, [255,200,000])
        pts = rs.AddPoints( coordsCub )
        rs.AddGroup("cub"), rs.AddObjectsToGroup(pts, "cub")
        rs.ObjectColor( pts, [100,200,255])
    else:
        for i,coords in enumerate(coordsCub): 
            pts = rs.AddPoints( coords )
            rs.AddGroup("cub"+str(i)), rs.AddObjectsToGroup(pts, "cub"+str(i))
            rs.ObjectColor(pts, [10*random.randint(1,25), 10*random.randint(1,25),  10*random.randint(1,25)] )
        if len(coordsSph) < 7:
            for i, coords in enumerate(coordsSph):
                pts = rs.AddPoints( coords )
                rs.AddGroup("sph"+str(i)), rs.AddObjectsToGroup(pts, "sph"+str(i))
                rs.ObjectColor(pts, [10*random.randint(15,20), 10*random.randint(15,20),  10*random.randint(1,10)] )
        if len(coordsSph) > 6:
            pts = rs.AddPoints( coordsSph )
            rs.AddGroup("sph"), rs.AddObjectsToGroup(pts, "sph")
            rs.ObjectColor(pts, [10*random.randint(15,20), 10*random.randint(15,20),  10*random.randint(2,2)] )
'''              
' end check setup                                                                                                                   ' 
'''


#######################################
################ HERE YOU GO AS YOU GO:


###WUERFEL
anzahl = 10
anzahl2=15
coords = []
if 1: 
    for x in range(anzahl):  #punkte in x-richtung
        for y in range(anzahl2):
           for z in range(anzahl):
               coords.append([x,y,z])
rs.AddPoints(coords) # punkte darstellen

###WUERFEL2
anzahl2 = 15
coords2 = []
if 1: 
    for x in range(anzahl2):  #punkte in x-richtung
        for y in range(anzahl2):
           for z in range(anzahl2):
               coords2.append([x+10,y,z])
rs.AddPoints(coords2) # punkte darstellen

###WUERFEL3
anzahl3 = 8
coords3 = []
if 1: 
    for x in range(anzahl3):  #punkte in x-richtung
        for y in range(anzahl2):
           for z in range(anzahl3):
               coords3.append([x+25,y,z])
rs.AddPoints(coords3) # punkte darstellen



###KUGEL 1
radius = 3
anzahl_sph = 1000                                           
vec = [radius, 0,0]
sph_coords = []

for i in range(anzahl_sph):
    vec = rs.VectorRotate( vec, random.uniform(0,180), dm.randVec() )
    sph_coords.append(vec)

punkte = rs.AddPoints(sph_coords)
rs.MoveObjects(punkte, [17.5, 0, 7.5])
rs.ObjectColor(punkte, [215,0,0])


#################
#dm.eDup( 1 )
dm.zA( 0.9 ) ### zoom all minus 0.9


