# ([(24,0,1.0)*(24,0,1.0),(22,0,1.0)*(24,0,-2.0),(22,0,1.0)*(22,0,1.0), (24,1,1.0)*(24,1,1.0),(22,1,1.0)(24,1,-2.0),(22,1,1.0)*(22,1,1.0), (24,2,1.0)*(24,2,1.0),(22,2,1.0)(24,2,-2.0),(22,2,1.0)*(22,2,1.0),
        # (22,0,-1.0)*(22,0,1.0),(19,0,1.0)*(22,0,2.0),(19,0,-1.0)*(19,0,1.0), (22,1,-1.0)*(22,1,1.0),(19,1,1.0)(22,1,2.0),(19,1,-1.0)*(19,1,1.0), (22,2,-1.0)*(22,2,1.0),(19,2,1.0)(22,2,2.0),(19,2,-1.0)*(19,2,1.0)],0.0),
        # ([(22,0,1.0)*(22,0,1.0),(19,0,1.0)*(22,0,-2.0),(19,0,1.0)*(19,0,1.0), (22,1,1.0)*(22,1,1.0),(19,1,1.0)(22,1,-2.0),(19,1,1.0)*(19,1,1.0), (22,2,1.0)*(22,2,1.0),(19,2,1.0)(22,2,-2.0),(19,2,1.0)*(19,2,1.0),
        # (19,0,-1.0)*(19,0,1.0),(15,0,1.0)*(19,0,2.0),(15,0,-1.0)*(15,0,1.0), (19,1,-1.0)*(19,1,1.0),(15,1,1.0)(19,1,2.0),(15,1,-1.0)*(15,1,1.0), (19,2,-1.0)*(19,2,1.0),(15,2,1.0)(19,2,2.0),(15,2,-1.0)*(15,2,1.0)],0.0),
        # ([(19,0,1.0)*(19,0,1.0),(15,0,1.0)*(19,0,-2.0),(15,0,1.0)*(15,0,1.0), (19,1,1.0)*(19,1,1.0),(15,1,1.0)(19,1,-2.0),(15,1,1.0)*(15,1,1.0), (19,2,1.0)*(19,2,1.0),(15,2,1.0)(19,2,-2.0),(15,2,1.0)*(15,2,1.0),
        # (15,0,-1.0)*(15,0,1.0),(10,0,1.0)*(15,0,2.0),(10,0,-1.0)*(10,0,1.0), (15,1,-1.0)*(15,1,1.0),(10,1,1.0)(15,1,2.0),(10,1,-1.0)*(10,1,1.0), (15,2,-1.0)*(15,2,1.0),(10,2,1.0)(15,2,2.0),(10,2,-1.0)*(10,2,1.0)],0.0),
    ],
    MAX_ITER=500,
)
uf = Folding(source=fold, name="unfolding", tf_lst=[(face_z_0, triangle.N)], n_steps=10)

# ===============================================================================
# Assembling the dome
# ===============================================================================

# need coordinates of node 24, direction of the vector between node 11 an node 16 and between node 15 and node 19 to cinematicaly block the base of the folded pattern.

# rp = RotSymAssembly(source=fold, center=[0.5-0.24/(2*math.cos(math.pi/8)*math.sin(math.pi/8)), 1.2, 0],
# n_segments=n_segs, n_visible=n_segs)
# 0.5-(1.13835329-0.94169147)/(2*math.cos(math.pi/8)*math.sin(math.pi/8)), 1.13835329, 1.27589881

yp = RotSymAssembly(source=init, center=[0.5, 1.2, 0], n_segments=n_segs, n_visible=n_segs)

v = CreasePatternView(root=fold.source)
v.configure_traits()

print "xx", fold.x_1[25]
print "yy", fold.x_1[24]

fold.show()
        + t_ * (H - dH)
    )


# face du dome a suivre
tf_z_t = CnstrTargetFace(F=[get_dome_x_t(R_o, 0, H, 0), s_, get_dome_z_t(R_o, 0, H, 0)])


# Surface limits of the folding

# tf_x_R_i = CnstrTargetFace(F=[R_i, r_, s_])
# tf_x_R_o = CnstrTargetFace(F=[R_o, r_, s_])
tf_z_0 = CnstrTargetFace(F=[r_, s_, 0])

# ===============================================================================
# Initialization object
# ===============================================================================

# init = Initialization(cp=triangle, tf_lst=[(tf_z_t, triangle.N)])


# ===============================================================================
# Form-finding object
# ===============================================================================
form = FormFinding(source=init, tf_lst=[(tf_z_t, triangle.N)], n_steps=10, MAX_ITER=500)


v = CreasePatternView(root=form.source)
v.configure_traits()
form.show()