- 积分
- 5494
- 明经币
- 个
- 注册时间
- 2014-4-27
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
本帖最后由 ashleytgg 于 2016-2-12 22:18 编辑
程序简介:
1 主要是方便道路测量,将平面曲线,竖曲线、横坡 综合与断面上,以方便用GPS进行现场测量。
2 未对程序进行纠错处理,只是提供了一个大概的思路。
3 希望改程序能对测量的同行有所帮助,不足的地方乐于大家指出,好改正。虽然是小程序,但也花了我过年一周多的时间,改进和修正。
在新的一年里,祝福我的家人我的亲人,新年快乐,身体健康,每天开心。也祝福大家 一切好。
{ 下面是部分代码 )- ;;对一个二维点集合group_point 绕 点center 旋转 ang 弧度
- (defun rotate_group_point (group_point ang center / lst)
- (setq group_point
- (mapcar '(lambda (point)
- (list (- (car point) (car center))
- (- (cadr point) (cadr center))
- )
- )
- group_point
- )
- )
- (setq lst (list (list (cos ang) (* (sin ang) -1))
- (list (sin ang) (cos ang))
- )
- )
- (setq group_point
- (mapcar '(lambda (point)
- (apply '(lambda (element_1 element_2)
- (list (+ (* (car element_1) (car point))
- (* (cadr element_1) (cadr point))
- )
- (+ (* (car element_2) (car point))
- (* (cadr element_2) (cadr point))
- )
- )
- )
- lst
- )
- )
- group_point
- )
- )
- (setq
- group_point
- (mapcar '(lambda (x)
- (list (+ (car x) (car center))
- (+ (cadr x) (cadr center))
- )
- )
- group_point
- )
- )
- )
- ;; 8888888888888888 88888888888888888888888 88888888888888888
- ;;定义一个队group_data_out 数组进行群变换的函数 ,group_data_out 结构为:(Z_桩号 U ang_象限角 )
- ;; 对点集合 group_point 首先进行镜像变换,然后把变换后的点集合从U_origin 以为到U_insert ,然后围绕U_insert点旋转制定的角度
- (defun transformation_group_data_out
- (group_data_out
- reflex data_origin
- data_insert /
- group_point quadrant_ang
- ang_Δ ang
- U_origin U_insert
- group i
- )
- (setq group (append (list data_origin) group_data_out))
- (if (= reflex -1)
- (setq group
- (mapcar '(lambda (lst / Z U ang)
- (setq Z (car lst)
- U (cadr lst)
- ang (caddr lst)
- )
- (list Z
- (list (car U)
- (* (cadr U) -1)
- )
- (* ang -1)
- )
- )
- group
- )
- )
- ) ; (if (= reflex -1) 函数结束
- (setq data_origin (car group)
- group_data_out (cdr group)
- )
- ;; 对group_data_out 数组进行平移,使得原坐标系中的U_origin点,和实际线元的起点U_insert向符合
- (setq U_origin (cadr data_origin)
- U_insert (cadr data_insert)
- )
- (setq group_data_out
- (mapcar '(lambda (lst / Z U x y ang)
- (setq Z (car lst)
- U (cadr lst)
- x (+ (- (car U) (car U_origin))
- (car U_insert)
- )
- y (+ (- (cadr U) (cadr U_origin))
- (cadr U_insert)
- )
- ang (caddr lst)
- )
- (list Z (list x Y) ang)
- )
- group_data_out
- )
- )
- ;; 对 group_data_out 数组,以线元的起点U_insert进行旋转 quadrant_ang- ang 角度操作
- (setq ang (caddr data_origin)
- quadrant_ang (caddr data_insert)
- )
- (setq group_point
- (mapcar 'cadr group_data_out)
- )
- (setq ang_Δ (- quadrant_ang ang)
- group_point (rotate_group_point group_point ang_Δ U_insert)
- )
- (setq i 0
- group_data_out
- (mapcar '(lambda (lst / U ang)
- (setq U (nth i group_point)
- ang (caddr lst)
- i (+ i 1)
- )
- (list (car lst) U (+ ang ang_Δ))
- )
- group_data_out
- )
- )
- ) ; (defun transformation_group_data_out 函数结束
- ;; (transformation_group_data_out group_data_out reflex data_origin data_insert)
- ;;888888888888888888888888888888888888888888888888888888888888888888888888888888
- ;; 人口变量, 缓和曲线参数A, 缓和曲线长L
- (defun solve_transition_curve_sub (A L /
- group U deflection
- functon_parameter
- )
- ;; (setq L 40.0 A 200 )
- (if (> L 0.000001)
- (progn
- (setq L (* L 1.0)
- A (* A 1.0)
- )
- (setq functon_parameter
- '(((1 0 1.0 1)
- (5 4 40.0 -1)
- (9 8 3456.0 1)
- (13 12 599040.0 -1)
- (17 16 1.75473e+007 1)
- )
- ((3 2 6.0 1)
- (7 6 336.0 -1)
- (11 10 42240.0 1)
- (15 14 9.6768e+006 -1)
- (19 18 3.5301e+009 1)
- )
- )
- )
- ;; 把 L A 带入函数 进行求值
- (setq group
- (mapcar '(lambda (subset)
- (mapcar '(lambda (lst)
- (apply '(lambda (a_1 a_2 a_3 a_4)
- (* (/ (expt L a_1)
- (* (expt A a_2) a_3)
- )
- a_4
- )
- )
- lst
- )
- )
- subset
- )
- )
- functon_parameter
- )
- )
- (setq U
- (mapcar '(lambda (subset)
- (apply '+ subset)
- )
- group
- )
- )
- (setq deflection
- (/ (expt L 2.0) (* (expt A 2.0) 2.0))
- ) ; J为弧度
- (list U deflection)
- ) ; progn函数结束
- ;; 当缓和曲线长L很小时
- (list '(0 0) 0)
- ) ; if 函数结束
- )
- ;; 输出参数为切线支距坐标复数U,偏角deflection
- ;;888888888888888888888888888888888888888888888888888888888888888888888888888888888
- ;; 当线元是缓和曲线时, subset 数据结构为
- ;; ( R_start R_end transition_parameter reflex quadrant_ang Z_start U_insert )
- (defun solve_transition_curve (group_Z subset /
- A Lh lst
- Lh_start Lh_end U_Z_start
- β_start Z_end group_data_out
- data_origin data_insert
- )
- (apply
- '(lambda (R_start R_end transition_parameter
- reflex quadrant_ang Z_start
- U_insert
- )
- (setq Lh (car transition_parameter) ; 缓和曲线长度
- A (cadr transition_parameter) ; 缓和曲线参数
- R_start (* R_start 1.0)
- R_end (* R_end 1.0)
- )
- (if (= R_start 0)
- (setq R_start (expt 10.0 30))
- )
- (if (= R_end 0)
- (setq R_end (expt 10.0 30))
- )
- (if (> R_start R_end)
- ;; 正向缓和曲线时
- (progn
- (setq Lh_start (/ (expt A 2) R_start) ; 起点缓和曲线长度
- lst (solve_transition_curve_sub A Lh_start)
- U_Z_start (car lst) ; 缓和曲线的起点切线支距坐标
- β_start (cadr lst) ;缓和曲线起点象限角
- )
- ;; 对桩号集合group_Z 进行操作
- (setq group_data_out
- (mapcar '(lambda (z / L lst U_Z β_Z)
- (setq L (+ (- Z Z_start) Lh_start))
- (setq lst (solve_transition_curve_sub A L)
- U_Z (car lst)
- β_Z (cadr lst)
- )
- (list Z U_Z β_Z)
- )
- group_Z
- )
- )
- )
- ;; 反向缓和曲线时
- (progn
- (setq Lh_start (/ (expt A 2) R_start)
- lst (solve_transition_curve_sub A Lh_start)
- U_Z_start (car lst)
- β_start (cadr lst)
- )
- (setq Lh_end (/ (expt A 2) R_end) ; 终点缓和曲线长度
- Z_end (+ Z_start Lh)
- )
- (setq group_data_out
- (mapcar '(lambda (z / L lst U_Z β_Z)
- (setq L (+ (- Z_end Z) Lh_end))
- ; 加桩点的缓和曲线长度,从完整缓和曲线的起点算起
- (setq lst (solve_transition_curve_sub A L)
- U_Z (car lst)
- β_Z (cadr lst)
- )
- (list Z U_Z β_Z)
- )
- group_Z
- )
- )
- ;;此时生成的group_data_out与标准的正向缓和曲线线(原点0,启始方位角0,右手螺旋坐标系) 沿着X轴对称 ,
- ;;所以要对group_data_ou 进行沿x轴镜像
- (setq group_data_out
- (mapcar '(lambda (lst / Z U ang)
- (setq Z (car lst)
- U (cadr lst)
- ang (caddr lst)
- )
- (list Z
- (list (* (car U) -1)
- (cadr U)
- )
- (* ang -1)
- )
- )
- group_data_out
- )
- U_Z_start
- (list (* (car U_Z_start) -1)
- (cadr U_Z_start)
- )
- β_start
- (* β_start -1)
- )
- )
- ) ; (if (> R_start R_end) 函数结束
- ;; 创建transformation_group_data_out 函数用参数 data_origin data_insert
- (setq data_origin (list 0 U_Z_start β_start)
- data_insert (list 0 U_insert quadrant_ang)
- )
- ;; 对点集合 group_point 首先进行镜像变换,然后把变换后的点集合从U_origin 以为到U_insert ,然后围绕U_insert点旋转制定的角度
- (transformation_group_data_out
- group_data_out
- reflex
- data_origin
- data_insert
- )
- )
- subset
- )
- )
- ;;88888888888888888888888888888888888888888888888888888888888888888 (expt 10.0 30)
- ;; 当线元是圆曲线时 subset 数据结构为
- ;; ( R_start R_end lenth reflex quadrant_ang Z_start U_insert )
- (defun solve_circular_arc (group_Z subset /
- i group_data_out
- U_center data_origin data_insert
- )
- ;; (tang_test group_data_out )
- (apply
- '(lambda (R_start R_end lenth reflex quadrant_ang Z_start U_insert)
- ;; 设定圆曲线圆心为原点(0 R_start),方向为 右手坐标系,圆曲线线起点坐标(0 0 ),切线为X轴
- (setq R_start (* R_start 1.0)
- U_center (list 0 R_start)
- )
- (setq group_data_out
- (mapcar '(lambda (Z / L β U_Z ang)
- (setq L (- Z Z_start)
- β (/ L R_start)
- ang (- β (/ pi 2))
- U_Z (polar U_center ang R_start)
- )
- (list Z U_Z β)
- )
- group_Z
- )
- )
- ;; 创建transformation_group_data_out 函数用参数 data_origin data_insert
- (setq data_origin (list 0 (list 0 0) 0)
- data_insert (list 0 U_insert quadrant_ang)
- )
- ;; 对点集合 group_point 首先进行镜像变换,然后把变换后的点集合从U_origin 以为到U_insert ,然后围绕U_insert点旋转制定的角度
- (transformation_group_data_out
- group_data_out
- reflex
- data_origin
- data_insert
- )
- )
- subset
- )
- )
- ;;88888888888888888888888888888888888888888888888888888888888888888
- ;; 当线元是直线时 subset 数据结构为
- ;; ( R_start R_end lenth reflex quadrant_ang Z_start U_insert )
- (defun solve_straightway
- (group_Z subset / group_data_out)
- ;; (tang_test group_data_out )
- (apply
- '(lambda (R_start R_end lenth reflex quadrant_ang Z_start U_insert)
- (setq group_data_out
- (mapcar '(lambda (Z / L U_Z)
- (setq L (- Z Z_start)
- U_Z (polar U_insert quadrant_ang L)
- )
- (list Z U_Z quadrant_ang)
- )
- group_Z
- )
- )
- )
- subset
- )
- )
- ;;88888888888888888888888888888888888888888888888888888888888888888
- ;; 交点参数的文件格式, 当交点为完整缓和曲线时 : [ ( 转点号I nil) U_转点 ( Ls1 R Ls2 ) ] ,
- ;; 当交点为非完整缓和曲线交点时 : [ ( 转点号I t) U_转点 ( R_start R R_end Ls1 Ls2) ]
- ;; 输出变量turning_point_group : [ ( 转点号I nil) U_转点 ( Ls1 R Ls2 )(α1 α2 Δ Dist_1 Dist_2 )]
- (defun create_turning_point_group
- (/ n i lst
- fname group turning_point_group
- f1
- ;; 求交点距离角度时用到的参数
- α1 α2 Δ Dist_1
- Dist_2 lst_1 lst_2 lst_3
- U_1 U_2 U_3
- )
- ;; turning_point_group 格式 [ ( 转点号I nil) U_转点 ( Ls1 R Ls2 ) ] , 完整缓和曲线时
- ;; or [ ( 转点号I nil) U_转点 ( R_start R R_end Ls1 Ls2) ] , 非完整缓和曲线交点时
- (setq fname (getfiled "输入存放交点参数的文件" "" "txt" 1))
- (setq f1 (open fname "r"))
- (setq group nil)
- (while (setq lst (read-line f1))
- (setq group (cons lst group))
- ) ; while (/= list nil)循环函数结束
- (close f1)
- (setq i 0
- group_turning_point
- nil
- n (length group)
- )
- (repeat n
- (setq lst (read (nth i group))
- group_turning_point
- (cons lst group_turning_point)
- )
- (setq i (+ i 1))
- )
- (setq group_turning_point
- (vl-sort group_turning_point
- '(lambda (lst1 lst2)
- (< (car (car lst1))
- (car (car lst2))
- )
- )
- )
- )
- ;; 对数组group_turning_point [ ( 转点号I nil) U_转点 ( Ls1 R Ls2 ) ] , 加入第三项 (α1 α2 Δ Dist_1 Dist_2 )
- (setq i 0
- group nil
- )
- (repeat n
- (cond
- ;;当转点为[第二个->倒数第二个] 转点时
- ((and (/= i 0) (/= i (- n 1)))
- (progn
- (setq lst_1 (nth (- i 1) group_turning_point))
- (setq lst_2 (nth i group_turning_point))
- (setq lst_3 (nth (+ i 1) group_turning_point))
- (setq U_1 (cadr lst_1)
- U_2 (cadr lst_2)
- U_3 (cadr lst_3)
- )
- (setq Dist_1 (distance U_1 U_2)
- Dist_2 (distance U_2 U_3)
- )
- (setq α1 (angle U_1 U_2)
- α2 (angle U_2 U_3)
- Δ (- α2 α1)
- )
- ;; 对转角Δ 使其控制在(-pi pi) 之间
- (cond
- ((and (>= Δ (* -1 pi))
- (< Δ pi)
- )
- (setq Δ Δ)
- )
- ((< Δ (* -1 pi))
- (setq Δ (+ Δ (* 2 pi)))
- )
- ((> Δ pi)
- (setq Δ (- Δ (* 2 pi)))
- )
- )
- (setq lst (list α1 α2 Δ Dist_1 Dist_2)
- lst (append lst_2 (list lst))
- group (cons lst group)
- )
- )
- )
- ;;当为第一个转点时的情形 起始转点->下一转点
- ((= i 0)
- (progn
- (setq lst_2 (nth i group_turning_point))
- (setq lst_3 (nth (+ i 1) group_turning_point))
- (setq
- U_2 (cadr lst_2)
- U_3 (cadr lst_3)
- )
- (setq Dist_1 0
- Dist_2 (distance U_2 U_3)
- α2 (angle U_2 U_3)
- lst (list 0 α2 0 0 Dist_2)
- )
- (setq lst (append lst_2 (list lst))
- group (cons lst group)
- )
- )
- )
- ;; 当转点为最后一个转点时的情形 上一转点->终点转点
- ((= i (- n 1))
- (progn
- (setq lst_1 (nth (- i 1) group_turning_point))
- (setq lst_2 (nth i group_turning_point))
- (setq U_1 (cadr lst_1)
- U_2 (cadr lst_2)
- )
- (setq Dist_1 (distance U_1 U_2)
- α1 (angle U_1 U_2)
- lst (list α1 0 0 Dist_1 0)
- )
- (setq lst (append lst_2 (list lst))
- group (cons lst group)
- )
- )
- )
- ) ; cond 函数结束
- (setq i (+ i 1))
- ) ; (repeat n 函数结束
- (setq group_turning_point (reverse group))
- ; 排序函数结束
- ) ; create_turning_point_group_2 函数结束
- ;; (setq group_turning_point ( create_turning_point_group ) )
- ;;888888888888888888888888888888888888888888888888888888888888888888888888888888
- ;; 人口变量缓和曲线长Lh, 缓和曲线半径R, 出口变量缓和曲线出口段内移值p,切线增量q ,偏角β,缓和曲线参数A
- (defun evaluation_transition_curve
- (Lh R /
- A p q
- β group
- functon_parameter
- )
- ;; (setq lh 50 r 480 )
- (setq R (* 1.0 R)
- Lh (* 1.0 Lh)
- )
- (setq functon_parameter
- '(((2 1 24.0)
- (4 3 -2688.0)
- (6 5 506880.0)
- (8 7 -1.54829e+008)
- )
- ((1 0 2.0)
- (3 2 -240.0)
- (5 4 34560.0)
- (7 6 -8.38656e+006)
- (9 8 3.15851e+009)
- )
- )
- )
- ;;把参数parameter_easement_curve 带入求值,
- (setq group
- (mapcar '(lambda (subset)
- (mapcar '(lambda (lst)
- (apply '(lambda (a_1 a_2 a_3)
- (/ (expt Lh a_1)
- (* (expt R a_2) a_3)
- )
- )
- lst
- )
- )
- subset
- )
- )
- functon_parameter
- )
- )
- (setq group
- (mapcar '(lambda (subset)
- (apply '+ subset)
- )
- group
- )
- )
- (setq p (car group)
- q (cadr group)
- β (/ Lh (* R 2.0))
- A (sqrt (* R Lh))
- )
- ;; 出口变量缓和曲线出口段内移值p,切线增量q ,偏角β,缓和曲线参数A
- (list p q β A)
- ) ; evaluation_easement_curve 函数结束
- ;; (evaluation_transition_curve 50 480 ) (evaluation_transition_curve 50 480 )
- ;;888888888888888888888888888888888888888888888888888888888888888888888888888888888
- ;;888888888888888888888888888888888888888888888888888888888888888888888888888888
- ;; (setq group_turning_point ( create_turning_point_group ) )
- ;; 求基本对称路线平曲线的 曲线要素 入口变量: [ ( 转点号I nil) U_转点 ( Lh R Lh )(α1 α2 Δ Dist_1 Dist_2 )]
- ;; 出口变量:该转点各线元的数据[( 转点号I j) R_start R_end transition_parameter reflex quadrant_ang Z_start U_insert ) ]
- (defun evaluation_symmetrical_curve (subset / Z_I U group_data_out)
- ;; (setq subset (nth 15 group_turning_point ))
- (setq Z_I (car (car subset)) ; 转点编号
- subset (cdr subset)
- )
- ;; (setq U_ZD_real (car subset) lst1 (cadr subset) lst2 (caddr subset) )
- (apply '(lambda (U_ZD_real lst1 lst2 /
- ;; 计算交点用参数
- quadrant_ang Δ
- ;; 计算切线长度 T1 T2 所用参数
- T1 T2 a_1 a_2 tangent
- cscΔ cotΔ
- ;; 计算缓和曲线的内蕴参数
- parameter Lh1 Lh2 R
- A1 A2 p1 p2 q1
- q2 β1 β2 βy E
- Ly L adjusted_value reflex
- ;; 建立线元坐标系所用参数
- U_center U_JD U_ZH U_HY U_QZ
- U_YH U_HZ
- ;; 桩号用参数
- Z_JD Z_ZH Z_HY Z_QZ Z_YH
- Z_HZ
- ;; 切线角用参数
- ang_JD ang_ZH ang_HY ang_QZ ang_YH
- ang_HZ
- ;; 对数组 group_data_out 进行移位,镜像,旋转 用参数
- quadrant_ang data_origin data_insert
- ;;创建线元列表所用参数
- lst lst2 lst3 lst4 Line_segments
- )
- (setq Lh1 (car lst1)
- R (cadr lst1)
- Lh2 (caddr lst1)
- quadrant_ang
- (car lst2) ; 设计交点的入口方位角
- Δ (caddr lst2) ; 设计交点偏转系数
- )
- (if (>= Δ 0)
- (setq reflex 1)
- (setq reflex -1
- Δ (* -1 Δ)
- )
- )
- (setq
- parameter
- (evaluation_transition_curve Lh1 R)
- ;; 出口变量缓和曲线出口段内移值p,切线增量q ,偏角β,缓和曲线参数A
- p1 (car parameter)
- q1 (cadr parameter)
- β1 (caddr parameter)
- A1 (nth 3 parameter)
- )
- (cond
- ((= Lh1 Lh2)
- (setq
- β2 β1
- A2 A1
- )
- (setq tangent (/ (sin (/ Δ 2)) (cos (/ Δ 2)))
- T1 (+ (* (+ R p1) tangent) q1)
- T2 T1
- ; 切线长度
- )
- )
- ;; 当出口、进口缓和曲线长度不相等时
- ((/= Lh1 Lh2)
- (setq
- parameter
- (evaluation_transition_curve Lh2 R)
- ;; 出口变量缓和曲线出口段内移值p,切线增量q ,偏角β,缓和曲线参数A
- p2 (car parameter)
- q2 (cadr parameter)
- β2 (caddr parameter)
- A2 (nth 3 parameter)
- )
- (setq cscΔ (/ 1.0 (sin Δ))
- cotΔ (/ (cos Δ) (sin Δ))
- a_1 (* (+ R p2) cscΔ)
- a_2 (* (+ R p1) cotΔ)
- T1 (+ (- a_1 a_2)
- q1
- )
- a_1 (* (+ R p1) cscΔ)
- a_2 (* (+ R p2) cotΔ)
- T2 (+ (- a_1 a_2)
- q2
- )
- )
- )
- ) ; (cond 函数 结束
- (setq a_1 (expt (+ R p1) 2)
- a_2 (expt (- T1 q1) 2)
- E (- (sqrt (+ a_1 a_2)) R) ; 外距
- βy (- Δ (+ β1 β2))
- Ly (* βy R)
- ; 圆曲线长度
- L (+ Ly (+ Lh1 Lh2))
- adjusted_value (- (+ T1 T2) L) ; 切曲差
- )
- ;; 以ZH点为坐标原点,该点的切线方向为X轴,建立右手螺旋坐标系 ,转角 Δ取正数
- ;;转点的桩号 Z_JD = z_QZ + adjusted_value
- (setq ang_JD (/ Δ 2)
- ;; 设置为U_JD ->U_center的垂直方向
- ang_ZH 0
- ang_HY β1
- ang_QZ (+ β1 (/ βy 2))
- ang_YH (- Δ β2)
- ang_HZ Δ
- )
- ;; (angtos (+(/ (- pi Δ) 2)Δ) 1 6 )
- (setq
- U_JD (list T1 0)
- U_center (list q1 (+ R p1))
- U_ZH (list 0 0) ;向量U_center ->U_JD 的方位角 (+ (/ Δ 2)pi)
- U_HY (polar U_center (- ang_HY (* pi 0.5)) R)
- U_QZ (polar U_center (- ang_QZ (* pi 0.5)) R)
- U_YH (polar U_center (- ang_YH (* pi 0.5)) R)
- U_HZ (polar U_JD Δ T2)
- )
- (setq Z_JD T1
- Z_ZH 0
- Z_HY Lh1
- Z_QZ (+ Lh1 (/ Ly 2))
- Z_YH (+ Lh1 Ly)
- Z_HZ L
- )
- (setq group_data_out
- (list
- (list Z_JD U_JD ang_JD)
- (list Z_ZH U_ZH ang_ZH)
- (list Z_HY U_HY ang_HY)
- (list Z_QZ U_QZ ang_QZ)
- (list Z_YH U_YH ang_YH)
- (list Z_HZ U_HZ ang_HZ)
- )
- )
- ;; 创建transformation_group_data_out 函数用参数 data_origin data_insert
- (setq
- data_origin (list 0 U_JD 0)
- data_insert (list 0 U_ZD_real quadrant_ang)
- )
- ;; 对点集合 group_point 首先进行镜像变换,然后把变换后的点集合从U_origin 以为到U_insert ,然后围绕U_insert点旋转制定的角度quadrant_ang
- (setq group_data_out
- (transformation_group_data_out
- group_data_out
- reflex
- data_origin
- data_insert
- )
- )
- ;;利用group_data_out数组 设置线元参数: (( 转点号I j) R_start R_end transition_parameter reflex quadrant_ang Z_start U_insert )
- (cond
- ((and (/= Lh1 0)
- (/= Lh2 0)
- )
- (setq lst (list 1 2 4)
- lst3 (list 0 1 2)
- )
- )
- ((and (= Lh1 0)
- (/= Lh2 0)
- )
- (setq lst (list 2 4)
- lst3 (list 1 2)
- )
- )
- ((and (/= Lh1 0)
- (= Lh2 0)
- )
- (setq lst (list 1 2)
- lst3 (list 0 1)
- )
- )
- ((and (= Lh1 0)
- (= Lh2 0)
- )
- (setq lst (list 2)
- lst3 (list 1)
- )
- )
- ) ; cond 函数结束
- (setq
- group
- (mapcar '(lambda (i / lst2)
- (setq lst2 (nth i group_data_out))
- (list (caddr lst2) (car lst2) (cadr lst2))
- )
- (list 1 2 4)
- )
- lst_4 (list (list (list Z_I 0) 0 R (list Lh1 A1) reflex)
- (list (list Z_I 1) R R Ly reflex)
- (list (list Z_I 2) R 0 (list Lh2 A2) reflex)
- )
- Line_segments (mapcar '(lambda (i)
- (append (nth i lst_4) (nth i group))
- )
- lst3
- )
- )
- (list Line_segments (list T1 T2 adjusted_value))
- )
- subset
- )
- ) ; evaluation_easement_curve 函数结束
- ;;888888888888888888888888888888888888888888888888888888888888888888888888888888888
- ;;888888888888888888888888888888888888888888888888888888888888888888888888888888
- ;; (setq group_turning_point ( create_turning_point_group ) )
- ;; 求包含非完整缓和曲线的线元要素 入口变量: [ ( 转点号I T) U_转点 ( R_start R R_end Lh1 Lh2 )(α1 α2 Δ Dist_1 Dist_2 )]
- ;; 出口变量:该转点各线元的数据[( 转点号I j) R_start R_end transition_parameter reflex quadrant_ang Z_start U_insert ) ]
- (defun evaluation_no_symmetrical_curve (subset / Z_I U group_data_out)
- ;; (setq subset (nth 11 group_turning_point ))
- (setq Z_I (car (car subset)) ; 转点编号
- subset_2 (cdr subset)
- )
- ;; (setq U_ZD_real (car subset_2) lst1 (cadr subset_2) lst2 (caddr subset_2) )
- (apply '(lambda (U_ZD_real lst1 lst2 /
- ;; 计算交点用参数
- quadrant_ang Δ
- ;; 计算切线长度 T1 T2 所用参数
- T1 T2 group_Z Lh1_start Lh2_start
- ;; 计算缓和曲线的内蕴参数
- parameter Lh1 Lh2 R A1
- A2 p1 p2 q1 q2
- β1 β2 βy E Ly
- L adjusted_value reflex
- ;; 建立线元坐标系所用参数
- U_center U_ZD U_ZH U_HY U_QZ
- U_YH U_HZ
- ;; 桩号用参数
- Z_JD Z_ZH Z_HY Z_QZ Z_YH
- Z_HZ
- ;; 切线角用参数
- ang_JD ang_ZH ang_HY ang_QZ ang_YH
- ang_HZ
- ;; 对数组 group_data_out 进行移位,镜像,旋转 用参数
- quadrant_ang data_origin data_insert
- ;;创建线元列表所用参数
- lst lst2 lst3 lst4 Line_segments
- )
- (setq R_start (car lst1)
- R (cadr lst1)
- R_end (caddr lst1)
- Lh1 (nth 3 lst1)
- Lh2 (nth 4 lst1)
- quadrant_ang
- (car lst2) ; 设计交点的入口方位角
- Δ (caddr lst2) ; 设计交点偏转系数
- )
- (if (= R_start 0)
- (setq R_start (expt 10.0 30))
- )
- (if (= R_end 0)
- (setq R_end (expt 10.0 30))
- )
- (if (>= Δ 0)
- (setq reflex 1)
- (setq reflex -1
- Δ (* -1 Δ)
- ) ; (setq Δ (/ pi 3))
- )
- ;; 当出口 缓和曲线长度不相等时
- (if (/= Lh1 0)
- (progn
- ;; 创建lst结构 ( ( 转点号I j) R_start R_end transition_parameter reflex quadrant_ang Z_start U_insert )
- (setq
- A1
- (abs (- (/ 1.0 R)
- (/ 1.0 R_start)
- )
- )
- A1
- (sqrt (/ Lh1 A1))
- )
- ;; 求入口非完整缓和曲线的HY点 ( z_桩号 U_z ang )
- (setq lst (list R_start
- R
- (list Lh1 A1)
- 1
- 0 ; 线元的起点方位角
- 0
- (list 0 0)
- )
- group_Z (list Lh1)
- )
- (setq group (solve_transition_curve group_Z lst)
- U_HY (cadr (car group))
- β1 (caddr (car group))
- )
- ;; (setq group_data_out (solve_transition_curve ( create_group_Z 0 Lh1 1) lst )) (tang_test group_data_out )
- )
- (setq β1 0) ; 当Lh1长度为0 时 , β1 偏角为0
- )
- ;; 求出口口非完整缓和曲线的HY点 ( z_桩号 U_z ang ) (以YH点为0点,右手螺旋坐标系,过YH点的切线为0度 )
- (if (/= Lh2 0)
- (progn
- ;; 创建lst结构 ( R_start R_end transition_parameter reflex quadrant_ang Z_start U_insert )
- (setq
- A2
- (abs (- (/ 1.0 R)
- (/ 1.0 R_end)
- )
- )
- A2
- (sqrt (/ Lh2 A2))
- )
- (setq lst (list R
- R_end
- (list Lh2 A2)
- 1
- 0 ; 线元的起点方位角
- 0
- (list 0 0)
- )
- group_Z (list Lh2)
- )
- (setq group (solve_transition_curve group_Z lst)
- β2 (caddr (car group))
- )
- )
- (setq β2 0) ; 当Lh2长度为0 时 , β2 偏角为0
- ) ; (if (/= Lh2 0) 函数结束
- ;; 计算圆曲线的偏角
- (setq βy (- Δ (+ β2 β1))
- Ly (* R βy) ; 圆曲线长度
- )
- ;; 创建lst结构 ( R_start R_end lenth reflex quadrant_ang Z_start U_insert )
- (setq lst (list R R Ly 1 β1 0 U_HY)
- group_Z (list Ly) ; YH 点的桩号
- )
- (setq group (solve_circular_arc group_Z lst)
- ; 求圆曲线的终点坐标
- U_YH (cadr (car group))
- )
- ;; (setq group_data_out (solve_circular_arc ( create_group_Z 0 Ly 1) lst )) (tang_test group_data_out )
- (if (/= Lh2 0)
- (progn
- ;;求HZ点的 group_data_out 的数组( z_桩号 U_z ang )
- (setq lst (list R
- R_end
- (list Lh2 A2)
- 1
- (+ βy β1) ; 线元的起点方位角
- 0 ; 线元的起始桩号
- U_YH
- )
- group_Z (list Lh2) ; HZ点桩号
- )
- (setq group (solve_transition_curve group_Z lst)
- U_HZ (cadr (car group))
- ; 求第二缓和曲线在 以HZ点为坐标原点,起点缓和曲线切线为X轴方向
- )
- ;; (setq group_data_out (solve_transition_curve ( create_group_Z 0 Lh2 1) lst )) (tang_test group_data_out )
- )
- (setq U_HZ U_YH)
- ) ; (if (/= Lh2 0) 函数结束
- ;; 求次坐标系中的转点坐标 U_ZD
- (setq U_HZ_2 (polar U_HZ Δ 100.0)
- U_ZD (inters U_HZ
- U_HZ_2
- (list 0 0)
- (list 10000 0)
- nil
- )
- )
- ;; (setq tang99 (list (list 0 0) U_HY U_YH U_HZ U_ZD ))( create_LWPOLYLINE tang99 nil "0" )
- (setq T1 (car U_ZD)
- T2 (distance U_ZD U_HZ)
- L (+ Ly (+ Lh1 Lh2))
- adjusted_value (- (+ T1 T2) L) ; 切曲差
- )
- ;; 以ZH点为坐标原点,该点的切线方向为X轴,建立右手螺旋坐标系 ,转角 Δ取正数
- ;;转点的桩号 Z_JD = z_QZ + adjusted_value
- (setq ang_JD (/ Δ 2)
- ;; 设置为U_JD ->U_center的垂直方向
- ang_ZH 0
- ang_HY β1
- ang_QZ (+ β1 (/ βy 2))
- ang_YH (- Δ β2)
- ang_HZ Δ
- )
- ;; (angtos (+(/ (- pi Δ) 2)Δ) 1 6 )
- (setq
- U_center (polar U_HY (+ ang_HY (* pi 0.5)) R)
- U_ZH (list 0 0) ;向量U_center ->U_JD 的方位角 (+ (/ Δ 2)pi)
- U_QZ (polar U_center (- ang_QZ (* pi 0.5)) R)
- )
- (setq Z_JD T1
- Z_ZH 0
- Z_HY Lh1
- Z_QZ (+ Lh1 (/ Ly 2))
- Z_YH (+ Lh1 Ly)
- Z_HZ L
- )
- (setq group_data_out
- (list
- (list Z_JD U_ZD ang_JD)
- (list Z_ZH U_ZH ang_ZH)
- (list Z_HY U_HY ang_HY)
- (list Z_QZ U_QZ ang_QZ)
- (list Z_YH U_YH ang_YH)
- (list Z_HZ U_HZ ang_HZ)
- )
- )
- ;; 创建transformation_group_data_out 函数用参数 data_origin data_insert
- (setq
- data_origin (list 0 U_ZD 0)
- data_insert (list 0 U_ZD_real quadrant_ang)
- )
- ;; 对点集合 group_point 首先进行镜像变换,然后把变换后的点集合从U_origin 以为到U_insert ,然后围绕U_insert点旋转制定的角度quadrant_ang
- (setq group_data_out
- (transformation_group_data_out
- group_data_out
- reflex
- data_origin
- data_insert
- )
- )
- ;;利用group_data_out数组 设置线元参数: ( R_start R_end transition_parameter reflex quadrant_ang Z_start U_insert )
- (cond
- ((and (/= Lh1 0)
- (/= Lh2 0)
- )
- (setq lst (list 1 2 4)
- lst3 (list 0 1 2)
- )
- )
- ((and (= Lh1 0)
- (/= Lh2 0)
- )
- (setq lst (list 2 4)
- lst3 (list 1 2)
- )
- )
- ((and (/= Lh1 0)
- (= Lh2 0)
- )
- (setq lst (list 1 2)
- lst3 (list 0 1)
- )
- )
- ((and (= Lh1 0)
- (= Lh2 0)
- )
- (setq lst (list 2)
- lst3 (list 1)
- )
- )
- ) ; cond 函数结束
- (setq
- group
- (mapcar '(lambda (i / lst2)
- (setq lst2 (nth i group_data_out))
- (list (caddr lst2) (car lst2) (cadr lst2))
- )
- (list 1 2 4)
- )
- lst_4 (list (list (list Z_I 0) R_start R (list Lh1 A1) reflex)
- (list (list Z_I 1) R R Ly reflex)
- (list (list Z_I 2) R R_end (list Lh2 A2) reflex)
- )
- Line_segments (mapcar '(lambda (i)
- (append (nth i lst_4) (nth i group))
- )
- lst3
- )
- )
- (list Line_segments (list T1 T2 adjusted_value))
- )
- subset_2
- )
- ) ; evaluation_easement_curve 函数结束
- ;;888888888888888888888888888888888888888888888888888888888888888888888888888888888
- ;; (setq group_turning_point ( create_turning_point_group ) )
- ;; 求线路的线元参数group_Line_segments [( 转点号I j) R_start R_end transition_parameter reflex quadrant_ang Z_start U_insert ]
- ;; 以及转点参数 group_data_JD ( Z_JD U ang JD reflex )
- (defun create_group_Line_segments
- (group_turning_point
- Z_road_start /
- group_turning_point_2
- lst state
- i dist
- quadrant_ang num
- T_front Δ
- U_insert U
- Z group_parameter
- group_Line_segments
- group_data_JD
- )
- ;; 去掉group_turning_point 中的第一和最后一个转点,不进行处理
- (setq group_turning_point_2
- (cdr group_turning_point)
- group_turning_point_2
- (reverse group_turning_point_2)
- group_turning_point_2
- (cdr group_turning_point_2)
- group_turning_point_2
- (reverse group_turning_point_2)
- )
- ;; 创建线元集合group_Line_segments [( 转点号I j) R_start R_end transition_parameter reflex quadrant_ang Z_start U_insert ]
- ;; 和 转点用的参数集合 group_parameter (list T1 T2 adjusted_value)
- (setq
- group_Line_segments
- nil
- group_parameter
- nil
- )
- (mapcar '(lambda ; (setq subset (nth 9 group_turning_point ) )
- (subset / Line_segments state lst lst2)
- (setq state (cadr (car subset)))
- ; 判断该转点是否包含非完整缓和曲线
- (if state
- (setq lst
- (evaluation_no_symmetrical_curve subset)
- Line_segments
- (car lst)
- lst2 (cadr lst)
- )
- (setq lst
- (evaluation_symmetrical_curve subset)
- Line_segments
- (car lst)
- lst2 (cadr lst)
- )
- )
- (setq group_Line_segments
- (cons Line_segments group_Line_segments)
- group_parameter
- (cons lst2 group_parameter)
- )
- )
- group_turning_point_2
- )
- (setq group_Line_segments
- (reverse group_Line_segments)
- group_parameter
- (reverse group_parameter)
- )
- ;;利用参数group_parameter (list T1 T2 adjusted_value) 和group_turning_point 把直线线元加进group_Line_segments 中
- (setq i 0
- n (length group_Line_segments)
- )
- ;; 把第二个转点至最后一个转点的直线线元加进数组group_Line_segments 中
- (setq group_Line_segments
- (mapcar
- '(lambda
- (lst / dist lst2 T_back
- T_now T_front Δ U_JD quadrant_ang
- U_insert element num Z_start
- )
- (cond
- ((/= i (- n 1)) ; 当转点num 不是最后一个转点时
- (setq T_now (cadr (nth i group_parameter))
- T_back (car (nth i group_parameter))
- adjusted_value (caddr (nth i group_parameter))
- T_front (car (nth (+ i 1) group_parameter))
- lst2 (nth (+ i 1) group_turning_point)
- ; 线元所对应的转点号
- dist (nth 4 (nth 3 lst2))
- quadrant_ang (cadr (nth 3 lst2))
- Δ (- dist (+ T_now T_front))
- ;直线线元的长度
- num (car (car lst2)) ; 转点号
- Z_start (- (+ T_now T_back) adjusted_value)
- ;线元的起点桩号
- )
- )
- ;; 当转点num 是最后一个转点时
- ((= i (- n 1))
- (setq T_now (cadr (nth i group_parameter))
- T_back (car (nth i group_parameter))
- adjusted_value (caddr (nth i group_parameter))
- T_front 0; 最后一个转点的切线长度设置为0
- lst2 (nth (+ i 1) group_turning_point)
- ; 线元所对应的转点号
- dist (nth 4 (nth 3 lst2))
- quadrant_ang (cadr (nth 3 lst2))
- Δ (- dist (+ T_now T_front))
- num (car (car lst2)) ; 转点号
- Z_start (- (+ T_now T_back) adjusted_value)
- ;线元的起点桩号
- )
- )
- )
- (setq i (+ i 1))
- ;; 当 Δ 长度大于0.1米 时, 在该转点处加进直线线元
- (if (> Δ 0.1)
- (progn
- (setq U_JD (cadr lst2)
- U_insert (polar U_JD quadrant_ang T_now)
- num (car (car lst2))
- )
- ;; 创建直线线元[( 转点号I 3) 0 0 Δ reflex quadrant_ang Z_start U_insert ]
- (setq element (list (list num 3)
- 0
- 0
- Δ
- 1
- quadrant_ang
- Z_start
- U_insert
- )
- lst (append lst (list element))
- )
- )
- ) ; (if (> Δ 0.1) 函数结束
- lst
- )
- group_Line_segments
- )
- )
- ;; 把第一直线线元加进数组 group_Line_segments
- (setq lst (car group_turning_point)
- dist (nth 4 (nth 3 lst))
- quadrant_ang (cadr (nth 3 lst))
- U_insert (cadr lst) ; 第一个转点的 坐标
- num (car (car lst)) ; 第一个线元的转点号
- lst (car group_parameter)
- T_front (car lst) ; 第二个转点 的入口方向切线长度
- Δ (- dist T_front)
- )
- ;; 判断第一个线元的转点是否存在
- (if (> Δ 0.1)
- (progn
- (setq element (list (list num 3)
- 0
- 0
- Δ
- 1
- quadrant_ang
- 0
- U_insert
- )
- )
- (setq group_Line_segments
- (append (list (list element)) group_Line_segments)
- )
- )
- )
- ;; 对线元数组 group_Line_segments 中的起始桩号进行处理,
- (if (not Z_road_start)
- (setq Z_road_start 0) ; 当线路起始桩号没有定义时,设置为0
- )
- (setq Z Z_road_start) ; 初始化桩号Z 为路线的起始桩号
- (setq group_Line_segments
- (mapcar
- '(lambda (lst / element lenth)
- (setq lst
- (mapcar
- '(lambda (subset)
- (apply '(lambda (x_0 x_1 x_2 x_3 x_4 x_5 x_6 x_7)
- (list x_0 x_1 x_2 x_3 x_4 x_5 (+ Z x_6) x_7)
- )
- subset
- )
- )
- lst
- )
- ) ; (mapcar '(lambda (subset) 函数结束
- ;; 当一个转点 的全部线元处理完毕后, 对该转点的最后一个线元的结束桩号,赋值给Z
- (setq element (last lst)) ; 该转点的最后一个线元
- (if (= (cadr (car element)) 2)
- (setq lenth (car (nth 3 element)))
- ; 当最后一个线元是缓和曲线时
- (setq lenth (nth 3 element))
- )
- (setq Z (+ (nth 6 element) lenth))
- lst ; 保证输出结果为想要的group_Line_segments 数组
- )
- group_Line_segments
- )
- )
- ;; 对group_turning_point 中的交点 ,求其交点桩号,病并求其象限角,以转角的一半为切线方向
- (setq group_data_JD nil) ; 利用数组group_Line_segments和group_parameter (list T1 T2 adjusted_value) 求解
- (setq i 1)
- (setq group_data_JD
- (mapcar '(lambda (lst / T1 Z Z_JD lst2 U ang JD Δ reflex)
- (setq T1 (car lst)
- lst2 (nth i group_Line_segments)
- Z (nth 6 (car lst2))
- ; 该交点中的第一个线元的起点桩号
- Z_JD (+ Z T1)
- reflex (nth 4 (car lst2))
- )
- (setq lst2 (nth i group_turning_point)
- U (cadr lst2)
- JD (car (car lst2))
- Δ (caddr (nth 3 lst2))
- ang (car (nth 3 lst2))
- ang (+ (* 0.5 Δ) ang)
- )
- (setq i (+ i 1))
- (list Z_JD U ang JD reflex)
- )
- group_parameter
- )
- )
- (list group_Line_segments group_data_JD)
- )
- ;; 88888888888 88888888888888 88888888888888888 88888888888888888888
- ;; 计算线路加宽值8888888888 8888888888888888888 88888888888888888888 88888888888888888888
- ;;从文件中写入加宽数组 , 输出 数组group_widen 其格式为 ( 转点号 widen 线路加宽值)
- (defun write_into_group_widen (/ lst fname f1 group group_widen)
- (setq fname (getfiled "\n输入存放线路交点加宽参数的文件" "" "txt" 1))
- (if (/= fname nil)
- (progn
- (setq f1 (open fname
- "r"
- )
- )
- (while (setq list_1 (read-line f1))
- (setq group (cons list_1 group))
- )
- (setq group (reverse group))
- (setq
- group_widen
- nil
- )
- (setq group_widen
- (mapcar '(lambda (x)
- (read x)
- )
- group
- )
- )
- (close f1) ;关闭文件fname
- ) ; progn 函数结束
- ) ;if (/= fname nil) 函数结束
- group_widen
- ) ; write_into_group_widen 函数结束
- ;; 88888888888888888888888888888888888 (write_into_group_widen )
- ;; (setq group_widen (write_into_group_widen))
- ;; 输入参数 线元 Line_segments [( 转点号I j) R_start R_end transition_parameter reflex quadrant_ang Z_start U_insert ]
- ;; mold加宽类型 ,mold为0时, 绘制普通加宽,mold=1 时,按直线加宽
- (defun calculate_Transition-curve_widen
- (Z group_widen
- Line_segments mold
- / L widen
- k k_2 k_3
- l_x T_1 T_2
- T_3 widen_x lenth
- lst Z_end
- )
- (apply
- '(lambda (x_0 x_1 x_2 transition_parameter reflex x_5 Z_start x_7)
- (setq I (car x_0) ; 转点的编号
- num (cadr x_0) ; 线元在转点中的编号
- )
- (setq lst (assoc I group_widen)
- ; 寻找转点I 所对应的加宽值
- widen (cadr lst)
- )
- (if (not widen)
- (setq widen 0)
- )
- (if (or (= num 0)
- (= num 2)
- )
- ;; 当线元为缓和曲线时
- (progn
- (setq lenth (car transition_parameter)
- lenth (* lenth 1.0)
- Z_end (+ Z_start lenth)
- )
- (if (and
- (>= Z z_start)
- (<= Z z_end)
- )
- (progn
- (cond
- ;; 当线元为进口缓和曲线时
- ((= num 0)
- (setq L (- Z z_start))
- )
- ;; 当线元为出口缓和曲线时
- ((= num 2)
- (setq L (- z_end z))
- )
- ) ; cond 函数结束
- (setq k (/ L lenth))
- ;; 当 mold为0时, 绘制普通加宽,mold=1 时,按直线加宽
- (cond
- ((= mold 0)
- (setq k_2 (* (expt k 3) 4)
- k_3 (* (expt k 4) 3)
- widen_x (* (- k_2 k_3) widen)
- )
- )
- ((= mold 1)
- (setq widen_x (* k widen))
- )
- ) ; 判断 缓和曲线是否为普通或直线加宽的函数 结束
- )
- ) ; (if (and (>= Z z_start) (< Z z_end) ) 函数结束
- )
- ) ; 处理缓和曲线线元加宽值的 函数结束
- (if (= num 1)
- ;; 当线元为圆曲线时
- (progn
- (setq lenth (* transition_parameter 1.0)
- Z_end (+ Z_start lenth)
- )
- (if (and
- (>= Z z_start)
- (<= Z z_end)
- )
- (setq widen_x widen)
- ) ; (if (and (>= Z z_start) (< Z z_end) ) 函数结束
- )
- ) ; 处理圆曲线线元加宽值的 函数结束
- (if (not widen_x)
- (setq widen_x 0)
- widen_x
- )
- )
- Line_segments
- )
- ) ; calculate_Transition-curve_widen函数结束
- ;; (calculate_Transition-curve_widen 7530 group_widen Line_segments 0 )
- ;; (setq group_widen (write_into_group_widen))
- ;; (setq Line_segments (cadr(nth 2 tang99 ))) (setq mold 0 z 7570 I 25 )
- ;; 绘图用函数88888 绘图用函数88888 绘图用函数88888 绘图用函数88888 绘图用函数88888 绘图用函数88888 绘图用函数88888
- ;; 创建一个 桩号的函数
- (defun create_group_Z (Z_start Z_end Z_Δ / lst group_Z z residue)
- (setq group_z (list Z_start)
- Z (+ (fix Z_start) 1)
- )
- ;; 对Z取摸5,使得group_z 为Z_Δ的倍数
- (setq residue (rem Z Z_Δ)
- Z (- Z residue)
- )
- (if (>= Z Z_start)
- (setq Z Z)
- (setq Z (+ Z Z_Δ))
- )
- (while (< Z Z_end)
- (setq group_Z (cons z group_Z))
- (setq z (+ z Z_Δ))
- )
- (setq group_z
- (reverse group_z)
- )
- )
- ;; (setq group_Z ( create_group_Z 10784.9 10834 20 ) )
- (defun f_zhuanghao (Z / 桩号1 桩号2 Z_1 z_2 z_3 桩号3 桩号)
- (setq Z_1 (fix Z)
- Z_2 (rem Z_1 1000) ;整数桩号
- Z_3 (/ (- Z_1 Z_2) 1000) ;公里桩号
- Z_4 (- Z Z_1) ;小数桩号
- )
- (setq 桩号1 (itoa Z_3) ;获得整公里桩号
- 桩号2 (itoa Z_2) ;获得桩号的小里程数
- 桩号3 (substr (rtos Z_4 2 3) 2 4) ;获得桩号的小数
- )
- (cond
- ((and (= Z_2 0) (= Z_4 0))
- (setq 桩号 (strcat "K" 桩号1 "+000"))
- ; 获得桩号的字符表达式如"K3+000" 的形式
- )
- ((and (= (rem Z_2 10) 0) (= Z_4 0))
- (setq 桩号 (strcat "K" 桩号1 "+" 桩号2))
- ; 获得桩号的字符表达式如"+860" 的形式
- )
- (t (setq 桩号 (strcat "K" 桩号1 "+" 桩号2 桩号3)))
- )
- ) ;zhuanghao函数结束
- ;;8888888888888888888888888888888888888888888888
- ;; 对线元参数group_Line_segments [( 转点号num j) R_start R_end transition_parameter reflex quadrant_ang Z_start U_insert ]
- ;; 求出一个新的数组 group_transition ( 转点号num j) (i j k) ,i 和 k 分别为该线元的 前后线元编号 i k 取值为0 ,1 ,2 ,3
- (defun create_group_transition
- (group_Line_segments
- / group_transition
- group n_1
- n group_i
- lst num
- )
- (setq group (apply 'append group_Line_segments))
- ;; 为了计算方便,在数组group的头和尾巴各加入一个数组
- (setq lst (car (car group))
- num (car lst)
- lst (list (list num 3))
- group (append (list lst) group)
- lst (car (last group))
- num (car lst)
- lst (list (list num 3))
- group (append group (list lst))
- )
- (setq n (length group)
- n_1 1
- group_i nil
- )
- (repeat (- n 2)
- (setq group_i (cons n_1 group_i))
- (setq n_1 (+ n_1 1))
- )
- (setq group_i (reverse group_i))
- (setq group_transition nil)
- (mapcar '(lambda (n_1 / lst lst_back lst_front i j k)
- (setq lst (nth n_1 group)
- j (cadr (car lst))
- )
- (setq lst_back (nth (- n_1 1) group)
- lst_front
- (nth (+ n_1 1) group)
- )
- (setq i (cadr (car lst_back))
- k (cadr (car lst_front))
- )
- (setq group_transition
- (cons (list (car lst) (list i j k))
- group_transition
- )
- )
- )
- group_i
- )
- (reverse group_transition)
- ) ; (defun create_group_transition 函数结束
- ;; (setq group_transition ( create_group_transition group_Line_segments ) )
- ;; 创建 group_data_out 和 加宽值
- (defun create_group_data_out_sub (Line_segments mold
- / lst
- Line_segments_type
- str
- )
- ;; (setq Width 5 number 0 )
- (mapcar ; (setq subset (nth 0 (nth 11 group_Line_segments )) )
- '(lambda (subset / lst group_Z num
- Z_start Z_end len group_data_out
- subset_2 i array color
- )
- (setq array (car subset)
- num (cadr array)
- ;; 去除 [( 转点号I j) R_start R_end transition_parameter reflex quadrant_ang Z_start U_insert )]中的第一个元素
- subset_2 (cdr subset)
- reflex (nth 3 subset_2)
- Z_start (nth 5 subset_2)
- )
- (cond
- ((or (= num 0)
- (= num 2)
- )
- (progn
- (setq len (car (caddr subset_2))
- Z_end (+ Z_start len)
- group_Z (create_group_Z Z_start Z_end 5)
- )
- (setq group_data_out
- (solve_transition_curve group_Z subset_2)
- )
- )
- )
- ((= num 1)
- (progn
- (setq len (caddr subset_2)
- Z_end (+ Z_start len)
- group_Z (create_group_Z Z_start Z_end 5)
- )
- (setq group_data_out (solve_circular_arc group_Z subset_2))
- )
- )
- ((= num 3)
- (progn
- (setq len (caddr subset_2)
- Z_end (+ Z_start len)
- group_Z (create_group_Z Z_start Z_end 5)
- )
- (setq group_data_out (solve_straightway group_Z subset_2))
- )
- )
- ) ; cond 函数结束
- ;; 求group_Z 中每个桩号的加宽值
- (if (not mold)
- (setq mold 1) ; mold没有定义时,设置为直线加宽
- )
- (if (and (/= num 3)
- (assoc (car array) group_widen) ; 判断该转点是否加宽
- )
- (setq group_width
- (mapcar
- '(lambda (z / Width)
- (setq Width
- (calculate_Transition-curve_widen
- Z
- group_widen
- subset
- mold
- )
- )
- (* Width reflex) ; 对确定加宽值的左右方向
- )
- group_Z
- )
- )
- ;; 直线线元加宽值设置为0
- (setq group_width
- (mapcar
- '(lambda (z / Width)
- 0
- )
- group_Z
- )
- )
- )
- ;; group_transition ( 转点号num j) (i j k) ,i 和 k 分别为该线元的 前后线元编号 i k 取值为0 ,1 ,2 ,3
- (setq lst (cadr (assoc array group_transition)))
- (cond
- ((= (cadr lst) 3) ; 直线线元时
- (setq color 1
- Line_segments_type
- " 直线"
- )
- )
- ((= (cadr lst) 1) ;圆曲线线元时
- (setq color 2
- Line_segments_type
- " 圆曲线"
- ) ; 黄色
- )
- ;; 当缓和曲线时接直线和圆时
- ((or (equal lst '(3 0 1))
- (equal lst '(1 2 3))
- )
- (setq color 3
- Line_segments_type
- " 缓和曲线"
- ) ; 绿色
- )
- ;; 当缓和曲线时接缓和曲线和圆时
- ((or (equal lst '(2 0 1))
- (equal lst '(1 2 0))
- )
- (progn
- (if (= (cadr lst) 0)
- (setq color 6) ; 洋红色 入口缓和曲线
- (setq color 5) ;蓝色 出口缓和曲线
- )
- (setq Line_segments_type
- " 缓和曲线"
- ) ; 洋红色
- )
- )
- ;; 当缓和曲线是接圆和圆时
- ((or (equal lst '(1 0 1))
- (equal lst '(1 2 1))
- )
- (setq color 4
- Line_segments_type
- " 缓和曲线"
- ) ; 青色
- )
- (t
- (setq color 0
- Line_segments_type
- " 缺省状态"
- )
- )
- )
- ;; 判断线元的起点是什么型号,如ZH HY
- (setq
- array_2 (list (car lst) (cadr lst))
- )
- (cond
- ((equal array_2
- '(3 0)
- )
- (setq str "ZH")
- )
- ((equal array_2
- '(3 1)
- )
- (setq str "ZY")
- )
- ((equal array_2
- '(0 1)
- )
- (setq str "HY")
- )
- ((equal array_2
- '(1 0)
- )
- (setq str "YH")
- )
- ((equal array_2
- '(1 2)
- )
- (setq str "YH")
- )
- ((equal array_2
- '(1 3)
- )
- (setq str "YZ")
- )
- ((equal array_2
- '(2 3)
- )
- (setq str "HZ")
- )
- ((equal array_2
- '(2 0)
- )
- (setq str "HH")
- )
- ((equal array_2
- '(2 1)
- )
- (setq str "HY")
- )
- (t
- (setq str "88")
- )
- ) ; cond 函数结束
- ;; 创建group_Z 的高程值
- (setq group_h_slope
- (mapcar '(lambda (z / h slope)
- ; ( setq z (car group_Z ))
- (setq h (QH2_10N Z group_vertical_curve_2)
- slope (calculate_superelevation
- z
- group_superelevation
- subset
- )
- )
- (if h
- (list h slope)
- (list 100 slope)
- )
- )
- group_Z
- )
- )
- ;; 把 group_data_out 、 group_width 和 group_h_slope 合并起来 组成新的数组 { z U ang width h ( superelevation_L superelevation_R )}
- (setq i 0)
- (setq group
- (mapcar '(lambda (lst / width lst2)
- (setq width (nth i group_width)
- lst2 (nth i group_h_slope)
- i (+ i 1)
- )
- (append lst (list width) lst2)
- )
- group_data_out
- )
- )
- (setq i 0)
- (mapcar
- '(lambda (lst / string j
- residue U_page U_move ang
- group_U superelevation_L superelevation_R
- W_L W_R h_L h_R
- lst2 lst3
- )
- (setq residue (rem number n_grid)
- ; n_grid 为Uniform_group_center 中的格子数
- j (/ (- number residue) n_grid) ; 页数
- U_page (polar U_insert 0 (* j (* frame_wide 1.2)))
- U (nth residue Uniform_group_center)
- ; 桩号Z 在Uniform_group_center 域中的插入点
- U_move (list (+ (car U_page) (car U))
- (+ (cadr U_page) (cadr U))
- )
- )
- ;; 把z U ang width 桩号、坐标、方位角、加宽值 写入 图中
- (setq U (cadr lst) ; (setq lst (car group))
- width (nth 3 lst)
- lst2 (cons width U)
- lst2 (mapcar 'rtos lst2)
- 桩号 (f_zhuanghao (car lst))
- ang (caddr lst)
- ang (angtos (* (- ang (* 0.5 pi)) -1) 1 6)
- ; 把象限角转换成方位角
- lst2 (append (list 桩号 ang) lst2)
- lst2 (mapcar '(lambda (i)
- (nth i lst2)
- )
- (list 0 4 3 1 2)
- )
- )
- (if (/= i 0)
- (setq
- lst3 (list Line_segments_type "\n N(X):"
- "E(Y):" "\n 方位角:"
- "\n 加宽值:"
- )
- )
- (setq
- lst3 (list str "\n N(X):" "E(Y):" "\n 方位角:"
- "\n 加宽值:")
- )
- )
- (setq
- lst2 (append lst2 lst3)
- )
- (setq lst2 (mapcar '(lambda (i)
- (nth i lst2)
- )
- (list 0 5 6 1 7 2 8 3 9 4)
- )
- )
- (setq string (vl-princ-to-string lst2)
- string (vl-string-left-trim "\(" string)
- string (vl-string-right-trim "\)" string)
- )
- (entmake
- (list
- '(0 . "MTEXT")
- '(100 . "AcDbEntity")
- '(100 . "AcDbMText")
- (cons 62 color)
- (cons 40 (* road_wide 0.1))
- (cons 71 5)
- (cons 72 5)
- (cons '1 string)
- (cons 10 (polar U_move (* pi 0.5) (* road_wide -0.25)))
- )
- )
- ;; 用 group 数组和路面宽度road_wide 创建 桩号Z 的标准横断面控制点 U_cen U_L U_R U_L_2 U_R_2
- ;; U_L_2 U_R_2 路面宽度road_wide 加 土路肩宽度的值
- (setq h (nth 4 lst)
- width (nth 3 lst)
- superelevation_L
- (car (nth 5 lst))
- superelevation_R
- (cadr (nth 5 lst))
- )
- (if (> width 0) ; 在Ucs坐标系中以向右为正
- (setq W_L (+ road_wide width)
- W_R
- (* road_wide -1)
- )
- (setq W_L road_wide
- W_R
- (+ (* road_wide -1) width)
- )
- )
- ;; 在Ucs坐标系中以向右为正 , 所以对 W_L W_R 反向
- (setq W_L (* W_L -1)
- W_R (* W_R -1)
- )
- ;; 创建 U U_L U_R U_L_2 U_R_2 各点的高程
- (setq
- superelevation_L (* superelevation_L 0.01)
- superelevation_R (* superelevation_R 0.01)
- h_L
- (* superelevation_L W_L)
- h_R
- (* superelevation_R W_R)
- )
- (setq lst2 (list (- h_L 0.015)
- h_L
- (* h_L 0.5)
- 0
- (* h_R 0.5)
- h_R
- (- h_R 0.015)
- (* h_L 0.85)
- ; 标识横坡superelevation_L 所用点
- (* h_L 0.15)
- ; 标识横坡superelevation_L 所用点
- (* h_R 0.15)
- ; 标识横坡superelevation_R 所用点
- (* h_R 0.85)
- ; 标识横坡superelevation_R 所用点
- )
- lst3 (list (- W_L 0.5)
- W_L
- (* W_L 0.5)
- 0
- (* W_R 0.5)
- W_R
- (+ W_R 0.5)
- (* W_L 0.85)
- ; 标识横坡superelevation_L 所用点
- (* W_L 0.15)
- ; 标识横坡superelevation_L 所用点
- (* W_R 0.15)
- ; 标识横坡superelevation_R 所用点
- (* W_R 0.85)
- ; 标识横坡superelevation_R 所用点
- )
- U (list (car U_move) (+ (cadr U_move) (* road_wide 0.25)))
- )
- (setq j 0) ; (setq U_move (getpoint "输入插入点:"))
- (setq group_U (mapcar '(lambda (x / y)
- (setq y (nth j lst2)
- j (1+ j)
- )
- (list (+ (car U) x)
- (+ (cadr U) y)
- )
- )
- lst3
- )
- )
- (setq group_h (mapcar '(lambda (i / y)
- (setq y (nth i lst2))
- (+ h y)
- )
- (list 0 3 6)
- )
- )
- ;; 把 U_L U U_R 二维多段线写入图中
- (setq pt (mapcar '(lambda (i / U)
- (setq U (nth i group_U))
- U
- )
- (list 0 1 3 5 6)
- )
- )
- (entmake
- (append (list '(0 . "LWPOLYLINE")
- '(100 . "AcDbEntity")
- '(100 . "AcDbPolyline")
- (cons 62 color)
- (cons 90 (length pt))
- (cons 70 0)
- )
- (mapcar '(lambda (U) (cons 10 U)) pt)
- )
- )
- ;; 对group_U 中U_L U U_R 顶点绘制 等边三角形
- (setq j 0
- lst2
- (mapcar '(lambda (U / U_2 U_3)
- (if (or (= j 1) (= j 3))
- (setq U_2 (polar U (* (/ pi 3.0) 1) (/ road_wide 15.0))
- U_3 (polar U (* (/ pi 3.0) 2) (/ road_wide 15.0))
- )
- (setq U_2 (polar U (* (/ pi 3.0) 1) (/ road_wide 9.0))
- U_3 (polar U (* (/ pi 3.0) 2) (/ road_wide 9.0))
- )
- )
- (setq j (1+ j))
- (list U_2 U U_3)
- )
- pt
- )
- )
- (mapcar '(lambda (pt)
- (entmake
- (append (list '(0 . "LWPOLYLINE")
- '(100 . "AcDbEntity")
- '(100 . "AcDbPolyline")
- (cons 62 (+ color 1))
- (cons 90 (length pt))
- (cons 70 1)
- )
- (mapcar '(lambda (U) (cons 10 U)) pt)
- )
- )
- )
- lst2
- )
- ;; 绘制用以标识 superelevation_L 和 superelevation_R 的箭头
- (setq pt
- (mapcar '(lambda (i / U)
- (setq U (nth i group_U))
- (polar U (* pi 0.5) (/ road_wide 15.0))
- )
- (list 7 8 9 10)
- )
- )
- (setq
- lst2
- (apply
- '(lambda (x_0 x_1 x_3 x_4 / x_5 x_6 group_L group_R)
- (if (>= superelevation_L 0)
- (setq
- x_5 (polar x_0 (/ pi 6) (/ road_wide 15.0))
- group_L (list x_5 x_0 x_1)
- )
- (setq
- x_5 (polar x_1 (* 0.8333 pi) (/ road_wide 15.0))
- group_L (list x_0 x_1 x_5)
- )
- )
- (if (< superelevation_R 0)
- (setq
- x_6 (polar x_4 (* 0.8333 pi) (/ road_wide 15.0))
- group_R (list x_3 x_4 x_6)
- )
- (setq
- x_6 (polar x_3 (/ pi 6) (/ road_wide 15.0))
- group_R (list x_6 x_3 x_4)
- )
- )
- (list group_L group_R)
- )
- pt
- )
- )
- (mapcar '(lambda (pt)
- (entmake
- (append (list '(0 . "LWPOLYLINE")
- '(100 . "AcDbEntity")
- '(100 . "AcDbPolyline")
- (cons 62 (+ color 2))
- (cons 90 (length pt))
- (cons 70 0)
- )
- (mapcar '(lambda (U) (cons 10 U)) pt)
- )
- )
- )
- lst2
- )
- ;; 把group 中 h_L h h_R ( superelevation_L superelevation_R ) W_L W_R 写入图中
- (setq
- pt (mapcar '(lambda (i / U U_2)
- (setq U (nth i group_U))
- (if (or (= i 2) (= i 4))
- (polar U (* pi 0.5) (* road_wide 0.3))
- (polar U (* pi 0.5) (* road_wide 0.15))
- )
- )
- (list 0 2 3 4 6)
- )
- )
- (setq
- U (car pt)
- U (list (car U)
- (- (cadr U) (* road_wide 0.35))
- )
- U_2 (last pt)
- U_2 (list (car U_2)
- (- (cadr U_2) (* road_wide 0.35))
- )
- pt (append pt (list U) (list U_2))
- )
- (setq
- lst2 (append group_h
- (nth 5 lst) ; ( superelevation_L superelevation_R )
- (list (abs W_L))
- (list W_R)
- )
- lst2 (mapcar '(lambda (x) (rtos x 2 2)) lst2)
- lst2 (apply '(lambda (h_L h h_R slope_L slope_R W_L W_R)
- (list h_L
- (strcat slope_L " %")
- h
- (strcat slope_R " %")
- h_R
- (strcat "左宽:" W_L)
- (strcat "右宽:" W_R)
- )
- )
- lst2
- )
- )
- (setq j 0)
- (mapcar '(lambda (str / U_move)
- (setq U_move (nth j pt))
- (entmake
- (list '(0 . "TEXT")
- (cons 62 color)
- (append '(10) U_move)
- (cons 40 (* road_wide 0.1))
- (cons '1 str)
- (cons '71 0)
- (cons '72 1)
- (append '(11) U_move)
- )
- )
- (setq j (+ j 1))
- )
- lst2
- )
- (setq number (+ number 1)
- i (+ i 1)
- )
- )
- group
- )
- )
- Line_segments
- )
- )
- ;; (setq group_Line_segments (car ( create_group_Line_segments group_turning_point 6782.755 )) )
- ;; (setq tang (cadr ( create_group_Line_segments group_turning_point 6782.755 )) )
- ;; (setq e (entlast)) (command "zoom" "e") (setq e (car ( entsel)) ) ( entget e )
- ;; (setq group_turning_point (create_turning_point_group)) (setq group_widen (write_into_group_widen))
- ;; (setq group_turning_point ( create_turning_point_group ))
- ;; (setq group_widen (write_into_group_widen))
- ;; (setq group_vertical_curve (create_group_vertical_curve )) 创建竖曲线交点参数数组
- ;; (setq group_vertical_curve_2 ( create_group_vertical_curve_2 group_vertical_curve ) )
- ;; (setq group_superelevation (create_group_superelevation ) ) 创建左右边坡数组
- (defun create_group_data_out (group_Line_segments
- group_widen group_vertical_curve_2
- group_superelevation
- road_wide frame_wide
- U_insert mold
- / number
- Uniform_group_center
- group_transition group_move
- group n_x
- n_y scale
- )
- (setq group_transition (create_group_transition group_Line_segments))
- (if (not road_wide) ; 路面宽度
- (setq road_wide 5.0)
- )
- (if (not frame_wide) ; 图框宽度
- (setq frame_wide 297)
- )
- (setq n_x (/ frame_wide (* road_wide 3.5))
- n_x (fix n_x)
- n_y (/ (* n_x 210) 297)
- n_y (fix n_y)
- n_grid (* n_x n_y)
- )
- (setq Uniform_group_center
- (create_Uniform_distribution
- n_x
- n_y
- frame_wide
- )
- )
- ;; (setq U_insert (getpoint "输入插入点:"))
- (setq number 0)
- (mapcar '(lambda (Line_segments / group)
- (create_group_data_out_sub
- Line_segments
- mold
- )
- )
- group_Line_segments
- )
- ;; 绘制每页的边框
- (if (not (tblobjname "block" "图框"))
- (make_drawing_frame frame_wide U_insert "图框") ;创建一图框
- )
- (setq residue (rem number n_grid)
- n (/ (- number residue) n_grid) ; 页数
- )
- (if (> residue 0)
- (setq n (+ n 1))
- )
- (setq i 0
- scale (/ frame_wide 297.0)
- )
- (repeat n
- (setq b (* (/ frame_wide 297) 210)
- U (list (+ (car U_insert) (* (* frame_wide 1.2) i))
- (cadr U_insert)
- )
- )
- (entmake (list '(0 . "INSERT")
- (cons 2 "图框")
- (cons 10 U)
- (cons 41 scale)
- (cons 42 scale)
- (cons 43 scale)
- )
- )
- (setq i (+ i 1))
- )
- )
- ;; defun create_group_data_out 函数结束
- ;; ( create_group_data_out group_Line_segments group_widen road_wide frame_wide U_insert mold)
- ;; 在一个给定的长方形页面中 建立一个点集合 ,该点集合均匀的分布在页面中,页面左下角点为原点(list 0 0 )
- (defun create_Uniform_distribution
- (n_x n_y Width /
- n_grid i j n_1
- n_grid finite_field
- )
- ;; (setq U_insert (getpoint "输入插入点:"))
- (if (not n_x)
- (setq n_x 8)
- )
- (if (not n_y)
- (setq n_y 4)
- )
- (setq n_grid (* n_x n_y)
- n_1 0
- group nil
- )
- (repeat n_grid
- ;;确定行数 i 列数j ,group 的方向是由:下->上,再从:左->右
- (setq j (rem n_1 n_y)
- i (/ (- n_1 j) n_y)
- )
- (setq group (cons (list i j) group))
- (setq n_1 (+ n_1 1))
- )
- (setq finite_field (reverse group))
- ;; 对新建有限域finite_field 从原点:(0 0) 移位到 (0.75 0.75)
- (setq group
- (mapcar '(lambda (U)
- (apply '(lambda (x y)
- (list (+ x 0.75)
- (+ y 0.75)
- )
- )
- U
- )
- )
- finite_field
- )
- )
- ;; 对数组group (i j) 按原点0 进行放大 ,放大为 图框297*210 大 ,
- (setq scale_x (/ 297.0 (+ n_x 0.5))
- scale_y (/ 210.0 (+ n_y 0.5))
- ;; n_y n_x 加0.5 是为了留下页面的左右、上下空间
- )
- (setq k (/ width 297.0) ; 指定的图框大小
- scale_x (* scale_x k)
- scale_y (* scale_y k)
- )
- (mapcar '(lambda (U)
- (apply '(lambda (x y)
- (list (* x scale_x)
- (* y scale_y)
- )
- )
- U
- )
- )
- group
- )
- ) ; (defun create_Uniform_distribution 函数结束
- ;; (setq Uniform_group_center ( create_Uniform_distribution 5 4 600 ) )
- ;; (setq ss (ssget) ) (setq pt (getpoint "输入插入点:"))
- ;; (emkblk ss pt "tang") (setq name "tang" )
- (defun emkblk (ss pt name / i)
- (entmake
- (list '(0 . "block")
- (cons 2 name)
- '(70 . 0)
- (cons 10 '(0 0))
- )
- )
- (repeat (setq i (sslength ss))
- (entmake (cdr (entget (ssname ss (setq i (1- i))))))
- )
- (entmake '((0 . "ENDBLK")))
- (command "_.erase" ss "")
- (entmake (list '(0 . "INSERT") (cons 2 name) (cons 10 pt)))
- )
- ;; 绘制图框 (setq U_insert (getpoint "输入插入点:"))
- (defun make_drawing_frame
- (a U_insert name / b d U ss group i group_string)
- (if (not a)
- (setq a 600.0)
- )
- (setq b (* (/ a 297.0) 210))
- (setq
- group
- (list '(0 0)
- (list a 0)
- (list a b)
- (list 0 b)
- )
- )
- (entmake
- (append (list '(0 . "LWPOLYLINE")
- '(100 . "AcDbEntity")
- '(100 . "AcDbPolyline")
- (cons 90 (length group))
- (cons 70 1) ; 二维曲线闭合
- )
- (mapcar '(lambda (U) (cons 10 U)) group)
- )
- )
- (setq ss (ssget "L")) ;用刚刚生成的图形创造一个选择集合ss
- (setq d (/ b 29.0))
- (entmakex
- (list '(0 . "line")
- (cons 10 (list 0 d))
- (cons 11 (list a d))
- )
- )
- (ssadd (entlast) ss)
- (setq L (/ a 5)
- U (list L 0)
- i 1
- group nil
- )
- (repeat 4
- (entmakex
- (list '(0 . "line")
- (cons 10 (list (* L i) 0))
- (cons 11 (list (* L i) d))
- )
- )
- (ssadd (entlast) ss)
- (setq U (list (* L (- i 1)) (* 0.1 d))
- group (cons U group)
- )
- (setq i (+ i 1))
- )
- (setq U (list (* L (- i 1)) (* 0.1 d))
- group (cons U group)
- group (reverse group)
- )
- (setq group_string
- (list "项目名称:" "设计单位:" "监理单位:" "施工单位:"
- "制图人:ashleytgg")
- )
- (setq i 0)
- (repeat 5
- (entmake
- (list '(0 . "TEXT")
- (append '(10) (nth i group)) ;第一对齐点(在 OCS 中)
- (cons 40 (* d 0.65)) ; 文字高度
- (cons '1 (nth i group_string)) ; 内容
- )
- )
- (ssadd (entlast) ss)
- (setq i (+ i 1))
- )
- (if (not name)
- (setq name "tang")
- )
- (emkblk ss U_insert name)
- ) ; make_drawing_frame 函数结束
- ;; (setq U_insert (getpoint "输入插入点:")) ( make_drawing_frame 600 U_insert "tang" )
- ;; 绘图用函数函数结束 88888 绘图用函数函数结束88888 绘图用函数函数结束88888 绘图用函数函数结束88888 绘图用函数函数结束88888 绘图用函数函数结束
- ;; dcl 使用函数 888888888888888888 dcl 使用函数 888888888888888888 dcl 使用函数 888888888888888888dcl 使用函数 888888888888888888 dcl 使用函数 888888888888888888
- (defun Dcl_write (lst / dcl_file str file)
- (vl-load-com)
- (setq dcl_file (vl-filename-mktemp nil nil ".dcl"))
- (setq file (open dcl_file "w"))
- (foreach str lst (write-line str file))
- (close file)
- (setq id (load_dialog dcl_file))
- )
- (setq string_dcl
- '("JD_item:list_box{ key="JD_list"; label="交点参数表:"; value=0;"
- "list=" ( 转点号 转点状态nil) 转点坐标 ( Lh1 R Lh2 ) \\n ( 转点号 转点状态t) 转点坐标 (R_start R R_end Lh1 Lh2 )";"
- "fixed_width=true; width=90; allow_accept=true;}"
- "table_wide :list_box{ key="table_wide"; label="交点加宽参数参数表:"; value=0;"
- "list=" 交点号 交点加宽值 ";"
- "allow_accept=true;}"
- "scfg:toggle{ label="曲线加宽方式,选中为直线加宽,不选一般加宽"; key="scfg";}"
- "Z_road_start :edit_box {label="请选择线路起点桩号:"; key= "Z_road_start";value="6782.775";allow_accept=true;}"
- "calculate :button {label="计算线元参数:"; key= "calculate"; fixed_width=true;width=20;}"
- "insert_table_J :button {label="请选择交点参数列表:"; key= "insert_table_J"; fixed_width=true;width=20; }"
- "insert_table_W :button {label="请选择加宽参数列表:"; key= "insert_table_W"; fixed_width=true;width=20; }"
- "JD_item_vertical:list_box{ key="JD_list_vertical"; label="竖曲线交点参数表:"; value=0;"
- "list=" ( 转点号 转点桩号 转点高程 转点半径 ) ";"
- "allow_accept=true;}"
- "insert_table_J_V :button {label="请选择竖曲线交点参数列表:"; key= "insert_table_J_V"; fixed_width=true;width=20; }"
- "display :button {label="显示竖曲线、平面曲线交点参数:"; key= "display"; fixed_width=true;width=40; }"
- "vertical_segments :list_box{ key="vertical_segments"; label="竖曲线线元参数表:"; value=0;"
- "list="( 转点号I j)Z_start Z_end 起点高程 线元起点象限角 R 转角Δ) ";"
- "allow_accept=true;}"
- "Line_segments :list_box{ key="Line_segments"; label="线元参数参数表:"; value=0;"
- "list="( 转点号I j) 起点半径 终点半径 曲线长度 偏转系数 线元起点象限角 起点桩号 起点坐标 ) ";"
- "allow_accept=true;}"
- "N_x :edit_box {label="N(X):"; key= "N_x";value="0";allow_accept=true;}"
- "E_Y :edit_box {label="E(Y):"; key= "E_Y";value="0";allow_accept=true;}"
- "insert_point : button {label="请选择插入点:"; key= "insert_point"; fixed_width=true;width=20;} "
- "road_wide :edit_box {label="请选择路面宽度:(不包括土路肩):"; key= "road_wide";value="5.0";allow_accept=true;}"
- "frame_wide :edit_box {label="请选择设计图框的宽度:"; key= "frame_wide";value="297";allow_accept=true;}"
- "table_superelevation :list_box{ key="table_superelevation"; label="交点超高参数参数表:"; value=0;"
- "list=" 交点号 交点超高值 ";"
- "allow_accept=true;}"
- "insert_table_slope :button {label="请选择超高参数列表:"; key= "insert_table_slope"; fixed_width=true;width=20; }"
- "draw_standard_section:"
- "dialog{ label="绘制公路标准断面"; spacer;"
- "fixed_width=true;width=120;"
- ": boxed_row {JD_item;"
- ": column {"
- "insert_table_J; spacer;"
- "Z_road_start ;"
- "calculate ;"
- "}"
- "}"
- ": boxed_row {JD_item_vertical;"
- ": column { fixed_width=true;width=20;"
- ": column { insert_table_J_V ;display ; }"
- "}"
- "}"
- ": boxed_row {"
- ": boxed_column { fixed_width=true;width=40;"
- "table_wide ;"
- ": column { scfg ; insert_table_W ; }"
- "}"
- ": boxed_column { fixed_width=true;width=60;"
- "table_superelevation ;"
- "insert_table_slope;"
- "}"
- "}"
- ": boxed_row {"
- ": column { fixed_width=true;width=50;"
- "N_x ; E_Y ; insert_point;"
- "}"
- ": column { road_wide ; frame_wide; ok_cancel; }"
- "}"
- "}"
- "display_calculate_message:"
- "dialog{ label="显示计算信息"; spacer;"
- "fixed_width=true;width=140;"
- "Line_segments ;"
- "vertical_segments ;"
- ": boxed_row { ok_cancel; }"
- "}"
- )
- )
- (defun C:use_dcl (/ id
- sdt group_vertical_curve
- group_vertical_curve_2
- parameter list_key
- U group
- group_JD_list group_JD_plane
- group_JD_Width group_JD_slope
- group_vertical_segments
- mold group_turning_point
- group_Line_segments group_widen
- group_superelevation
- )
- (if nil
- (setq ID
- (load_dialog
- "D:\\工作文件\\新建文件夹\\work\\公路曲线简易程序\\用变换群绘制公路曲线\\绘制标准断面\\绘制标准断面"
- )
- )
- (Dcl_write string_dcl)
- )
- (setq sdt 1
- list_key (list "JD_list" "Z_road_start"
- "JD_list_vertical" "table_wide"
- "scfg" "table_superelevation"
- "N_x" "E_Y"
- "road_wide" "frame_wide"
- )
- )
- (while (>= sdt 0)
- (if (< sdt 10)
- (progn
- (if (not (new_dialog "draw_standard_section" id))
- (exit)
- )
- ;; 对对对话框中的参数进行重新设置
- (if (or (= sdt 3) (= sdt 6))
- (progn
- (if (or group_JD_plane
- group_JD_list
- group_JD_Width
- group_JD_slope
- )
- (progn
- (start_list "JD_list" 3)
- (mapcar 'add_list group_JD_plane)
- (end_list)
- (start_list "JD_list_vertical" 3)
- (mapcar 'add_list group_JD_list)
- (end_list)
- (start_list "table_wide" 3)
- (mapcar 'add_list group_JD_Width)
- (end_list)
- (start_list "table_superelevation" 3)
- (mapcar 'add_list group_JD_slope)
- (end_list)
- )
- )
- (set_inform_dialog parameter list_key)
- )
- )
- (action_tile
- "cancel"
- "(done_dialog -2 )"
- )
- (action_tile ; 竖曲线交点参数 插入表格的动作函数
- "insert_table_J_V"
- "(action_insert_table_J_V)"
- )
- (action_tile ; 平面曲线交点参数 插入表格的动作函数
- "insert_table_J"
- "(action_insert_table_J)"
- )
- (action_tile ; 计算平面曲线交点参数 的线元参数列表
- "calculate"
- "(action_calculate \t group_turning_point)
- (setq parameter(get_inform_dialog \t list_key))(done_dialog 18 )"
- )
- (action_tile ; 平面曲线交点的加宽参数插入的动作函数
- "insert_table_W"
- "(action_insert_table_W)"
- )
- (action_tile
- "insert_point"
- "(setq parameter(get_inform_dialog \t list_key))(done_dialog 3 )"
- )
- (action_tile ; 绘制标准断面
- "accept"
- "(setq parameter(get_inform_dialog \t list_key))(done_dialog -8 )"
- )
- (action_tile
- "display"
- "(setq parameter(get_inform_dialog \t list_key)) (done_dialog 18 )"
- )
- (action_tile ;交点的超高参数插入的动作函数
- "insert_table_slope"
- "(action_insert_table_slope)"
- )
- (setq sdt (start_dialog))
- )
- ) ; (if (< sdt 10) 函数结束
- (if (>= sdt 10)
- (progn
- (if (not (new_dialog "display_calculate_message" id))
- (exit)
- )
- (action_display group_vertical_segments group_Line_segments)
- (action_tile
- "accept"
- "(done_dialog 6 )"
- )
- (action_tile
- "cancel"
- "(done_dialog -2 )"
- )
- (setq sdt (start_dialog))
- )
- ) ; (if (>= sdt 10) 函数结束
- (if (= sdt 3)
- (setq u (getpoint "请选择插入点:")
- U (list (cadr U) (car U))
- U (mapcar 'rtos U)
- parameter
- (mapcar '(lambda (i)
- (nth i parameter)
- )
- (list 0 1 2 3 4 5 8 9)
- )
- parameter (append parameter U)
- parameter
- (mapcar '(lambda (i)
- (nth i parameter)
- )
- (list 0 1 2 3 4 5 8 9 6 7)
- )
- )
- ) ; (if (= sdt 3) 函数结束
- ) ; (while (> sdt 0) 函数结束
- (unload_dialog id)
- (if (= sdt -8)
- (progn
- ;; lst 结构为 mold "N_x" "E_Y" "road_wide" "frame_wide"
- (setq lst (mapcar '(lambda (i)
- (nth i parameter)
- )
- (list 4 6 7 8 9)
- )
- mold (atoi (car lst))
- lst (cdr lst)
- lst (mapcar 'atof lst)
- U_insert (list (cadr lst) (car lst))
- road_wide (caddr lst)
- frame_wide (nth 3 lst)
- )
- (if group_Line_segments
- (create_group_data_out
- group_Line_segments group_widen
- group_vertical_curve_2
- group_superelevation road_wide
- frame_wide U_insert
- mold
- ) ; mold 为加宽方式
- (princ "您还没有输入完整的线路参数!")
- )
- )
- ) ; (if (= sdt 8) 函数结束
- )
- ;; 定义"insert_table_J_V" 按钮的动作
- (defun action_insert_table_J_V
- (/ lst n group)
- (setq group_vertical_curve (create_group_vertical_curve))
- (setq group_vertical_curve_2
- (create_group_vertical_curve_2
- group_vertical_curve
- )
- )
- (setq n (length group_vertical_curve))
- (setq group_JD_list
- (mapcar '(lambda (lst)
- (apply '(lambda (JD Z h R)
- (strcat "JD: "
- (itoa JD)
- " 转点桩号:"
- (rtos Z 2 3)
- " 转点高程:"
- (rtos h 2 2)
- " 转点半径:"
- (rtos R 2 2)
- )
- )
- lst
- )
- )
- group_vertical_curve
- )
- )
- (setq group_vertical_segments
- (mapcar '(lambda (lst ; (setq lst ( nth 5 group_vertical_curve_2 ) )
- / lst2 lst3 element i j)
- (setq lst2 (mapcar '(lambda (i)
- (rtos (nth i lst) 2 2)
- )
- (list 1 2 3 5)
- )
- lst3 (mapcar '(lambda (i)
- (angtos (nth i lst) 1 6)
- )
- (list 4 6)
- )
- element (car lst) ; 对第一个元素进行处理
- i (itoa (car element))
- j (itoa (cadr element))
- element (strcat i "-" j)
- lst (append (list element) lst2 lst3)
- ; lst 顺序为 (list 0 1 2 3 5 4 6 )
- ;; 对lst 进行逆置换, 对 (list 0 1 2 3 5 4 6 ) 用 (list 0 1 2 3 5 4 6 ) 置换
- lst (mapcar '(lambda (i)
- (nth i lst)
- )
- (list 0 1 2 3 5 4 6)
- )
- )
- ;; 对lst数组进行注释
- (setq
- lst2 (list "JD:" "Z_start:" "Z_end:"
- "H:" "α0:" "R:"
- "α_Δ:"
- )
- lst (append lst lst2)
- lst (mapcar '(lambda (i)
- (nth i lst)
- )
- (list 7 0 8 1 9 2 10 3 11 4 12 5 13 6)
- )
- )
- (setq lst (vl-princ-to-string lst)
- lst (vl-string-left-trim "\(" lst)
- lst (vl-string-right-trim "\)" lst)
- )
- )
- group_vertical_curve_2
- )
- )
- (start_list "JD_list_vertical" 3)
- (mapcar 'add_list group_JD_list)
- (end_list)
- (set_tile "JD_list_vertical" (itoa n))
- )
- ;; 用参数parameter 对控件集合list_key 进行参数重置
- (defun set_inform_dialog
- (parameter list_key / i lst)
- (setq i 0)
- (mapcar '(lambda (x / str)
- (setq str (nth i parameter))
- (set_tile x str)
- (setq i (+ 1 i))
- )
- list_key
- )
- )
- ;;( set_inform_dialog parameter list_key )
- ;;获取控件集合list_key 的参数parameter
- (defun get_inform_dialog
- (list_key / lst)
- (mapcar '(lambda (x) (get_tile x))
- list_key
- )
- )
- ;; 定义平面曲线插入交点文件按钮的函数
- (defun action_insert_table_J (/ lst group)
- (setq group_turning_point (create_turning_point_group))
- ;; 用group_turning_point 数组分别对列表框 "JD_list"
- (setq group
- (mapcar
- '(lambda (lst / state subset_label)
- (apply '(lambda (x_0 x_1 x_2 x_3)
- (setq x_1 (mapcar 'rtos x_1)
- x_1 (list "N:" (cadr x_1) " E:" (car x_1))
- x_1 (apply 'strcat x_1)
- )
- (if (cadr x_0)
- (progn
- (setq state "Yes")
- (setq
- x_2 (apply '(lambda (y_0 y_1 y_2 y_3 y_4)
- (setq subset_label (list "R_s"
- "R"
- "R_e"
- "Lh1"
- "Lh2")
- subset (list y_0 y_1 y_2 y_3 y_4)
- subset (append subset subset_label)
- )
- (mapcar '(lambda (i)
- (nth i subset)
- )
- (list 5 0 6 1 7 2 8 3 9 4)
- )
- )
- x_2
- )
- )
- )
- (progn
- (setq state "No")
- (setq x_2 (apply '(lambda (y_0 y_1 y_2)
- (setq subset_label (list "Lh1" "R" "Lh2")
- subset (list y_0 y_1 y_2)
- subset (append subset subset_label)
- )
- (mapcar '(lambda (i)
- (nth i subset)
- )
- (list 3 0 4 1 5 2)
- )
- )
- x_2
- )
- )
- )
- ) ; (if (cadr x_0) 函数结束
- (setq x_2 (vl-princ-to-string x_2)
- x_2 (vl-string-left-trim "\(" x_2)
- x_2 (vl-string-right-trim "\)" x_2)
- )
- (list "JD:" (car x_0) state x_1 x_2)
- )
- lst
- )
- )
- group_turning_point
- )
- )
- (setq group_JD_plane
- (mapcar '(lambda (lst / string)
- (setq string (vl-princ-to-string lst)
- string (vl-string-left-trim "\(" string)
- string (vl-string-right-trim "\)" string)
- )
- )
- group
- )
- )
- (start_list "JD_list" 3)
- (mapcar 'add_list group_JD_plane)
- (end_list)
- ) ; action_insert_table_J 函数结束
- (defun action_insert_table_W (/ lst group)
- (setq group_widen (write_into_group_widen))
- ;; 用group_widen 数组分别对列表框 "table_wide" 进行填充
- (setq group_JD_Width
- (mapcar '(lambda (lst
- /
- JD
- W
- )
- (setq JD (itoa (car lst))
- W (rtos (cadr lst) 2 3)
- )
- (strcat "JD: " JD " 加宽:" W)
- )
- group_widen
- )
- )
- (start_list "table_wide" 3)
- (mapcar 'add_list group_JD_Width)
- (end_list)
- ) ; action_insert_table_W 函数结束
- (defun action_calculate
- (group_turning_point / lst group road_start group_sum n)
- (setq road_start (get_tile "Z_road_start")
- road_start (atof road_start)
- )
- (if group_turning_point
- (setq
- lst
- (create_group_Line_segments group_turning_point road_start)
- group_Line_segments
- (car lst)
- )
- )
- ) ; action_calculate 函数结束
- ;; 显示按钮 display 的动作函数
- (defun action_display
- (group_vertical_segments
- group_Line_segments /
- n group
- group_sum
- )
- (if group_vertical_segments
- (progn
- (start_list "vertical_segments" 3)
- (mapcar 'add_list group_vertical_segments)
- (end_list)
- (setq n (length group_vertical_curve_2))
- (set_tile "vertical_segments" (itoa n))
- )
- )
- (if group_Line_segments
- (progn
- (setq group_sum (apply 'append group_Line_segments))
- ;; 用 group_Line_segments 填充列表框 "Line_segments"
- (setq group_sum
- (mapcar ; (setq lst (car group_sum)) (setq x_7 ( nth 7 lst))
- '(lambda (lst / lenth lst_label)
- (apply '(lambda (x_0 x_1 x_2 x_3 x_4 x_5 x_6 x_7)
- (setq x_0 (mapcar 'itoa x_0)
- x_0 (list (car x_0) "-" (cadr x_0))
- x_0 (apply 'strcat x_0)
- )
- (setq x_7 (mapcar 'rtos x_7)
- x_7 (list "N:" (cadr x_7) " E:" (car x_7))
- x_7 (apply 'strcat x_7)
- )
- (setq
- x_6 (f_zhuanghao x_6)
- )
- (if (atom x_3)
- (setq lenth x_3)
- (setq lenth (car x_3))
- )
- (setq lenth (* lenth 1.0)
- x_3 (rtos lenth 2 2)
- x_5 (angtos x_5 1 6)
- )
- ;; 对(list x_0 x_1 x_2 x_3 x_4 x_5 x_6 x_7 ) 进行标注
- (setq lst (list x_0 x_1 x_2 x_3 x_4 x_5 x_6 x_7)
- lst_label (list "R_s:"
- "R_e:"
- "lenth:"
- "reflex:"
- "α_s:"
- )
- lst (append lst lst_label)
- )
- ;; lst顺序为 (0 1 2 3 4 5 6 7 8 9 10 11 12 )
- (mapcar '(lambda (i)
- (nth i lst)
- )
- (list 0 8 1 9 2 10 3 11 4 12 5 6 7)
- )
- )
- lst
- )
- )
- group_sum
- )
- )
- (setq group ; (setq lst (car group_sum ))
- (mapcar '(lambda (lst / string)
- (setq string (vl-princ-to-string lst))
- (setq string (vl-string-left-trim "\(" string)
- string (vl-string-right-trim "\)" string)
- )
- )
- group_sum
- )
- )
- (start_list "Line_segments" 3)
- (mapcar 'add_list group)
- (end_list)
- )
- ;; 当group_Line_segments 数组为空时
- (progn
- (start_list "Line_segments" 2)
- (mapcar 'add_list
- (list "group_Line_segments 交点数组为空!")
- )
- (end_list)
- )
- )
- (setq n (length group))
- (set_tile "Line_segments" (itoa n))
- )
- ;; ( action_display group_vertical_segments group_Line_segments )
- ;; 定义插入 交点超高参数 的动作函数
- (defun action_insert_table_slope (/ n)
- (setq group_superelevation (create_group_superelevation))
- (setq group_JD_slope
- (mapcar '(lambda (lst / JD slope lst2 slope_back slope_front)
- (if (= (length lst) 2)
- (setq JD (itoa (car lst))
- slope (rtos (cadr lst))
- lst2 (strcat "JD: " JD " 超高值: " slope " %")
- )
- )
- (if (= (length lst) 3)
- (setq JD (itoa (car lst))
- slope_bakc (rtos (car (cadr lst)))
- slope (rtos (cadr (cadr lst)))
- slope_front (rtos (car (caddr lst)))
- lst2 (strcat "JD: "
- JD
- " 超高开始值: "
- slope_bakc
- " %"
- " 超高值: "
- slope
- " %"
- " 超高结束值: "
- slope_front
- " %"
- )
- )
- )
- lst2
- )
- group_superelevation
- )
- )
- (start_list "table_superelevation" 3)
- (mapcar 'add_list group_JD_slope)
- (end_list)
- (setq n (length group_JD_slope))
- (set_tile "table_superelevation" (itoa n))
- )
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册
x
|