; 根据图面三角网标注任意点高程[mini_tin_redgc].lsp
(or mai_cehui_gcd_blk
	(mai_load_files (mai_panel_search "谜你测绘功能设置文件.lsp"))
)

(defun c:mini_tin_redgc ( / old_cmd addgcptinpm  zInsert ss pt tmp )

(defun addgcptinpm ( pt lst / z )
	(vl-some
		'(lambda( x / y )
			(setq y (mapcar 'mai_3p_2p x))
			(if (> (mai_point_in_data pt (cons (last y) y)) -2) (setq z (cons pt x)))
		)
		lst
	)
	z
)

;;双线性内插计算内插高程值
(defun zInsert ( ptl / pbc pt0 pt1 pt2 pt3 xa xb xc ya yb yc za zb zc pz )
	(mapcar 'set '( pt0 pt1 pt2 pt3) ptl)
	(setq pt0 (mai_3p_2p pt0))
	(mapcar 'set '(xa ya za) pt1)
	(mapcar 'set '(xb yb zb) pt2)
	(mapcar 'set '(xc yc zc) pt3)
	(cond
		(	(mai_equal pt0 (list xa ya)) (setq pz za))
		(	(mai_equal pt0 (list xb yb)) (setq pz zb))
		(	(mai_equal pt0 (list xc yc)) (setq pz zc))
		(	T
			(setq
				pbc (inters pt0 (list xa ya) (list xb yb) (list xc yc) nil)
				pz (mai_divide_point pt2 pt3 (/ (distance (list xb yb) pbc) (distance (list xb yb) (list xc yc))))
				pz (mai_divide_point pt1 pz (/ (distance (list xa ya) pt0) (distance (list xa ya) pbc)))
			)
		)
	)
	pz
)



	(mini_start nil)
	(mai_last_com "mini_tin_redgc")

	(setq
		ss (mai_select_first
				'((0 . "POLYLINE,3dface")) ;(8 . "sjw")
				"选择要标注任意点高程的三角网triangle地形图:<回车退出>"
				"没有找到任何3dface或POLYLINE."
			)
		ss (mapcar 'mai_get_face_points (mai_ssget_2_list ss))
	)
	(mai_get_scale)
	(apply 'mai_create_layer mai_cehui_gcd_blk)
	(while
		(progn
			(initget "S")
			(setq pt (getpoint (strcat "\n[选择标高块(S)]当前块标高块为<" mai_cehui_gc_blkname ">连续内插高程点:<退出>")))
		)
		(if (= pt "S")
			(if (setq tmp (car (mai_Entsel nil (strcat "选择标高块:<" mai_cehui_gc_blkname ">") "没有找到块." '((0 . "insert")) nil)))
				(if (mai_get_blk_atts tmp nil)
					(setq mai_cehui_gc_blkname (mai_dxf 2 tmp))
					(princ "\n所选块没属性。")
				)
			)
			;;角度法判断点在那个三角形 返回((ptx pty ptz) ((p1x p1y p1z) (p2x p2y p2z) (p3x p3y p3z)))
			(if (setq pt (addgcptinpm (mai_3p_2p pt) ss)) ;如果点在三角形线上或三角形内
				(progn
					;;双线性内插计算内插点的高程值 返回内插点(x y z)
					(setq pt (zInsert pt))
					(gxl_cs:gcd pt (caddr pt) mai_scale2 2 (car mai_cehui_gcd_blk))
				)
			)
		)
	)
	(mai_end)
)































































































































