##############################
import rhinoscriptsyntax as rs
import random, time, itertools
import sys
sys.path.append("P:/WWW/lorax234/dm2/import")          
import dm2_lib as dm2
##############################


rs.UnitSystem(4)                                        # km = 5, meters = 4, cm = 3 etc
rs.Command("-groundplane Options On=No enter enter", 0) # groundplane > off
rs.ShowGrid(None, 0)
rs.ShowGridAxes(None, 0)
rs.EnableRedraw(0)
rs.ViewDisplayMode(view=None, mode="Rendered")
dm2.eA()                
rs.Redraw()


pointsX = [ [0, 5, 0], 
            [5, 0, 0], 
            [5, 10, 0]
            ]
if 0:
    ptA = dm2.pntRandVec(-5, 5)
    ptB = dm2.pntRandVec(-5, 5)
    ptX = dm2.pntRandVec(-5, 5)
    dm2.pointsX = [ptA, ptB, ptX]
    pointsX = [ptA, ptB, ptX]

tetraCoords = dm2.getTetraCoords( points=pointsX, flipH=0, flipAB=0, drawTetra=1, drawAll=0 )
tetraCoords = dm2.getTetraCoords( points=pointsX, flipH=0, flipAB=1, drawTetra=1, drawAll=0 )



if 1: 
    for i, FaceCoordList in enumerate(tetraCoords):
        print "face", i, 
        print FaceCoordList
    
    print
    for i, cor in enumerate(tetraCoords[0]):
        print "cor", i, 
        print cor


#my tool for tetra:

pointsX = [ [0, 5, 0], 
            [5, 0, 0], 
            [5, 10, 0]
            ]
if 0:
    ptA = dm2.pntRandVec(-5, 5)
    ptB = dm2.pntRandVec(-5, 5)
    ptX = dm2.pntRandVec(-5, 5)
    dm2.pointsX = [ptA, ptB, ptX]
    pointsX = [ptA, ptB, ptX]

tetraCoords = dm2.getTetraCoords( points=pointsX, flipH=0, flipAB=0, drawTetra=1, drawAll=0 )
tetraCoords = dm2.getTetraCoords( points=pointsX, flipH=0, flipAB=1, drawTetra=1, drawAll=0 )

tetraCoordsC = dm2.getTetraCoords( points=pointsX, flipH=0, flipAB=1, drawTetra=1, drawAll=0 )
ranList = 2
for x in range (1,3):
    ranList = random.randint(2,3)
    pointsX = tetraCoords [ranList]
    tetraCoords = dm2.getTetraCoords( points=pointsX, flipH=0, flipAB=0, drawTetra=1, drawAll=0 )



pointsX1 = [ [0, 6, 0], 
            [6, 0, 0], 
            [6, 10, 0]
            ]
if 0:
    ptA1 = dm2.pntRandVec(-6, 6)
    ptB1 = dm2.pntRandVec(-6, 6)
    ptX1 = dm2.pntRandVec(-6, 6)
    dm2.pointsX = [ptA1, ptB1, ptX1]
    pointsX1 = [ptA1, ptB1, ptX1]

tetraCoords = dm2.getTetraCoords( points=pointsX1, flipH=0, flipAB=0, drawTetra=1, drawAll=0 )
tetraCoords = dm2.getTetraCoords( points=pointsX1, flipH=0, flipAB=1, drawTetra=1, drawAll=0 )

tetraCoordsB = dm2.getTetraCoords( points=pointsX1, flipH=0, flipAB=1, drawTetra=1, drawAll=0 )
ranList = 2
for x in range (1,3):
    ranList = random.randint(2,3)
    pointsX = tetraCoords [ranList]
    tetraCoords = dm2.getTetraCoords( points=pointsX, flipH=0, flipAB=0, drawTetra=1, drawAll=0 )



pointsX2 = [ [0, 7, 0], 
            [7, 0, 0], 
            [7, 10, 0]
            ]
if 0:
    ptA2 = dm2.pntRandVec(-7, 7)
    ptB2 = dm2.pntRandVec(-7, 7)
    ptX2 = dm2.pntRandVec(-7, 7)
    dm2.pointsX = [ptA2, ptB2, ptX2]
    pointsX1 = [ptA2, ptB2, ptX2]

tetraCoords = dm2.getTetraCoords( points=pointsX2, flipH=0, flipAB=0, drawTetra=1, drawAll=0 )
tetraCoords = dm2.getTetraCoords( points=pointsX2, flipH=0, flipAB=1, drawTetra=1, drawAll=0 )

tetraCoordsA = dm2.getTetraCoords( points=pointsX2, flipH=0, flipAB=1, drawTetra=1, drawAll=0 )
ranList = 2
for x in range (1,3):
    ranList = random.randint(2,3)
    pointsX = tetraCoords [ranList]
    tetraCoords = dm2.getTetraCoords( points=pointsX, flipH=0, flipAB=0, drawTetra=1, drawAll=0 )

