您的位置:首页 > 其它

在原来基础上加人可选择的,删线算法。

2011-05-01 21:27 120 查看
---在次整理思路
--由于 getSegLengths $ 1 cum:false 返回的是一个 段的% 顶点的长度 还有就是顶点的总长度。
--是一个数组,我们只用他的段的长度 用 pathInterp $ 1 .323 |pathInterp <shape> [ <curve_num> ] <parameter>
--求出顶点坐标。通过顶点坐标的比较。选择相应的段,删除就好

--- 问题1 我们怎么知道我们从getSegLengths $ 1 cum:false 中找出我们想要的段?

----通过测试我们发现 我们想要数组中要的段的个数其实 和线的顶点个数是一样的
----这个顶点个数我们可以用 numSegments $ 1 来得出 。这里可能还有多个因素,我现在的实例就是用的第一个
---想取得因素用numSplines $

----问题2 我们知道了线有几个因素,选择相应的因素 知道了各个点的顶点坐标,我们在做什么? (或者说我们知道顶点坐标有什么用)?

---我们是通过没两个相邻的点想比较,最后收尾比较。 对了这里补充下(:这里只是用于闭口的模型。这个脚本是针对闭口的线写的。)
---我们把 x y 坐标上同时存在的容差距离,过滤出吸血编号, setSegSelection $ 1 #(1) keep:true --- 选择段
-- 用 splineOps.delete $ 删掉,*(之间涉及到层级转换,在写的过程中慢慢体会,)
---在吧点转到段的方式上,是所在的点数是小的,。对应的段。最好还有个数组的 首 尾比较,选在点的的段。

---其实这个删除线的思路是这样的,
---1.判断线的顶端个数。
--2.依次比较两个点之间的坐标。 手动的输入 x y 轴的容差值,(记住这里判断的是象连接的两个点。)
--3. 当大于某个容差值时候,通过算法 找到相应的线段,删除掉。
---判断是否是线。

------****************************************
--1. 判断是否是线,激活界面
--2.并且还是要选择一个,如果选择了两个线 不受理
--3.选择线判断因素个数
--4. 对每个因素返回点 的个数
--5.判断两点之间的 想 x y 的容差值
--6.通过算法选择相应的线段,
--7.删除归到顶层级。

---****************************************
--fn spline_wrongis

/*
fn gt_selctt =
(
kol =1
if $selection.count >1 then
(
if AboutRollout != undefined then destroydialog AboutRollout
rollout AboutRollout "About"
(
label lbl5 "选择数量大于1 将不执行," pos:[10,10]
label lbl3 "以此提醒。"
timer tmclose "" interval:1000 active:true
on AboutRollout rbuttonup press do destroydialog AboutRollout ------ 右键进行消除
on tmclose tick do destroydialog AboutRollout --时间按点到消除 给我提供了思路。
)createdialog AboutRollout 200 100 modal:true style:#(#style_border,#style_sysmenu,#style_sunkenedge)

kol+=1
return kol
)else ( return kol )

)
2011.5.1 函数注销。
*/
/* ---放在单击事件里的事情
gt_oo = gt_selctt()
if gt_oo ==2 then return false ---看来我要到处用到这两句了。
*/
---然后再判断选择的物体必须是线。这样就在线中进行操作了。排除了所有的后忧患。
---记住要是改功能就要改函数名字。

fn gt_select_spline_classof_shape =
(
kol =1
oop=false
if classof $ !=SplineShape and classof $ !=line then oop = true

if oop then
(
if AboutRollout != undefined then destroydialog AboutRollout
rollout AboutRollout "About"
(
label lbl5 "选择的将不是线的类,终止程序。" pos:[10,10]
label lbl3 "以此提醒。"
timer tmclose "" interval:1000 active:true
on AboutRollout rbuttonup press do destroydialog AboutRollout ------ 右键进行消除
on tmclose tick do destroydialog AboutRollout --时间按点到消除 给我提供了思路。
)createdialog AboutRollout 200 100 modal:true style:#(#style_border,#style_sysmenu,#style_sunkenedge)

kol+=1
return kol
)else ( return kol )

)

/* ----在在下面放入第二个单击事件,进阶着上一个进行。

gt_oo_cl = gt_select_spline_classof_shape()
if gt_oo_cl ==2 then return false ---看来我要到处用到这两句了。
*/
---判断他的因素有多少个,我这样处理,当一个因素时单独处理,(这样一个因素处理完了,多个因素在处理就方便多了。)
---当大于一个因素时,在进行循环处理。
---当零个因素时,不处理,提出警告。
---************************************************************************************
--*** 说明我这个脚本,只是处理 线的平面状态,
--*** 用点的方式找坐标我做不好,所以 我还是用,体的形式。这里是 借鉴的“十六月”的。
--***
--************************************************************************************

--****************************************************
--***2011.4.28 我想起来了,我在之前的表情幽灵中,用到过表情坐标的。
--***
--***
--******************************************************************
--*****************************************************************
--***2011.5.1前几天找到了,收集点坐标的函数。也不用再转成体了,现在的算法,有点慢,其实是把东西转了一大圈。
--***现在也能对,线的多因素进行分离操作了。效果就是非常的好。
--****
--***现在所做的允许多个数量线的访问,所以选择多个的效果就注销的。
--***
--*** 针对不同视图,这里要写一个,
--***
--********************************************************************
fn spline_wrongisright tolerance_x_num obj true_t =
(
count_spline = numSplines obj ---线有多少因素。

new_obj = case count_spline of
(
0: (
messagebox "选择的形体节点对,但是 没有可编辑因素。" title:"盖天编写"
return false
)---end ()

1: (
-- local spline_vertex_array =#() -------顶点数值。段数数值
local spline_vertex_pos_array =#() -----顶点位置数值
local spline_vertex_num_array =#() ---- 顶点序号数值(其实是到时候选择的边的编号)

vertex_count_num = numSegments obj 1
-----求综合数值

/*
2011.5.1 又该方案。这里之前是用poly 思路来源于网上的“十六月”这个速度还是慢了点,现在要改成纯线操作。
--getSegLengths_num = getSegLengths $ 1 byVertex:true numArcSteps:100 -- cum:false
s1=$
maxOps.cloneNodes $ cloneType:#copy newnodes:&s2
select s2
s2.steps =0
--macros.run "Modifiers" "Extrude"
convertTo s2 Editable_Poly
count=polyop.getNumVerts($)
*/

----把% 段长 单独的放到一个数组。
--vertex_count_num 和 count 的数量是一样的。
for i in 1 to vertex_count_num do
(
oop = getKnotPoint obj 1 i
append spline_vertex_pos_array oop
)----end for
---------利用函数 把点的pos 放到一个数组中,方便下来的比较。
-- select s2
-- delete s2

-- select s1

----我想了还是利用循环
/*
----这个原先是段数的相加,这里就不要了。因为我用了上面的拾取点的形式。

local temporarily =0
for each in 1 to spline_vertex_array.count do
(
pos_to_pos = pathInterp $ 1 temporarily
append spline_vertex_pos_array pos_to_pos
temporarily+=spline_vertex_array[each]
)---end for each

*/
----上面暂时先用这种方法。
/*
---我觉的用上面的出来的数字觉得不是很对 改一下
local temporarily =spline_vertex_array[1]
for each in 1 to spline_vertex_array.count do
(
pos_to_pos = pathInterp $ 1 temporarily
append spline_vertex_pos_array pos_to_pos
if each+1 >spline_vertex_array.count then
()else
(
temporarily+=spline_vertex_array[each+1]
)
) */ ---end for each
----上面暂时先用这种方法。 经我试验 证明了还是要用 我所为“要改的” 其实是正确的。

---现在就是判断容差值的时间到了,x y 的相减的绝对值,
unm_array = (spline_vertex_pos_array.count)-1
for o in 1 to unm_array do
(
yu= o+1

if abs (spline_vertex_pos_array[yu].x-spline_vertex_pos_array[o].x)>tolerance_x_num and abs(spline_vertex_pos_array[yu].y-spline_vertex_pos_array[o].y)>tolerance_x_num then
(
append spline_vertex_num_array o ---数组以后对应的就是一个选择边的数组。

) ---end abs

)---end for in
-------------------最后在单独的加入数组的首尾 段
if true_t do
(
linshi = spline_vertex_pos_array.count

if abs( spline_vertex_pos_array[linshi].x-spline_vertex_pos_array[1].x )>tolerance_x_num and abs( spline_vertex_pos_array[linshi].y-spline_vertex_pos_array[1].y )>tolerance_x_num then
(
append spline_vertex_num_array linshi

)---end abs
)---end if true_t
---------------------- 这时上面的组有段数了。 只要转奥层级删除就好了
max modify mode
subobjectLevel = 2
setSegSelection obj 1 spline_vertex_num_array keep:false
max delete ---z
-- splineOps.delete obj
-- max create mode
subobjectLevel = 0

----英应该就是上面的这个过程。(前提是线上没有层级)转动修改面板 到2 层级选择 选段 删除 转到 0 层。

)---end ()
default: (
for ecch in 1 to count_spline do
(
local spline_vertex_pos_array =#() -----顶点位置数值
local spline_vertex_num_array =#() ---- 顶点序号数值(其实是到时候选择的边的编号)

vertex_count_num = numSegments obj ecch
-----求综合数值

for i in 1 to vertex_count_num do
(
oop = getKnotPoint obj ecch i
append spline_vertex_pos_array oop
)----end for

unm_array = (spline_vertex_pos_array.count)-1
for o in 1 to unm_array do
(
yu= o+1

if abs (spline_vertex_pos_array[yu].x-spline_vertex_pos_array[o].x)>tolerance_x_num and abs(spline_vertex_pos_array[yu].y-spline_vertex_pos_array[o].y)>tolerance_x_num then
(
append spline_vertex_num_array o ---数组以后对应的就是一个选择边的数组。

) ---end abs

)---end for in
-------------------最后在单独的加入数组的首尾 段
linshi = spline_vertex_pos_array.count

if abs( spline_vertex_pos_array[linshi].x-spline_vertex_pos_array[1].x )>tolerance_x_num and abs( spline_vertex_pos_array[linshi].y-spline_vertex_pos_array[1].y )>tolerance_x_num then
(
append spline_vertex_num_array linshi

)---end abs
---------------------- 这时上面的组有段数了。 只要转奥层级删除就好了
max modify mode
subobjectLevel = 2
setSegSelection obj ecch spline_vertex_num_array keep:false
max delete ---z
subobjectLevel = 0
)----end for

)----end ()
)---end case
-- subobjectLevel = 0 ---这个就是不能反倒0 的层级。

)---end fn

try (destroydialog gt_closs_spline)catch()
rollout gt_closs_spline "spline_1.0(盖天)" width:160 height:100
(
groupBox grp1 "容差" pos:[4,2] width:152 height:67
spinner tolerance_x_spn "X" pos:[26,21] width:50 height:16 range:[0,10000,0.02] type:#float scale:0.0001
spinner tolerance_y_spn "Y" pos:[93,21] width:50 height:16 range:[0,10000,0.02] type:#float scale:0.0001 enabled:false
button pressed_del_btn "执行删除" pos:[22,42] width:109 height:20

checkbox setup "断线处理" checked:false pos:[6,70]
--groupBox grp2 "" pos:[4,73] width:152 height:311

--- bitmap the_bmp pos:[8,90] width:145 height:285 fileName:"image_20110501094049.gif" ---到时候做一个钟表控制的效果。
on tolerance_x_spn changed arg do
(
tolerance_y_spn.value = arg
)---end on

on pressed_del_btn pressed do
( try (
DisableSceneRedraw()
--gt_oo = gt_selctt()
--if gt_oo ==2 then return false ---看来我要到处用到这两句了。
--这里做循环,
sel_obj_array=selection as array
clearSelection()
---************************************
---****对于线删除线段的操作,成组后在循环操作中,必须一个一个的操作,和手工是一样的,
---****要选择后收集节点,取消选择,在选择数组的的每个节点,进行函数的操作。
--*******************************************
for i in 1 to sel_obj_array.count do
(
select sel_obj_array[i]

gt_oo_cl = gt_select_spline_classof_shape()
if gt_oo_cl ==2 then
( EnableSceneRedraw()
return false ---看来我要到处用到这两句了。
)
---处理之前收集线的操作,只要是对旋转
---1.旋转归0
---2.函数操作
---3.旋转归位
try (
XX= $.rotation.controller[1].value
YY= $.rotation.controller[2].value
ZZ= $.rotation.controller[3].value

if classof XX== float and classof YY== float and classof ZZ== float then
(
$.rotation.controller[1].value=0
$.rotation.controller[2].value=0
$.rotation.controller[3].value=0
if setup.checked then
(
spline_wrongisright tolerance_x_spn.value $ false
$.rotation.controller[1].value=XX
$.rotation.controller[2].value=YY
$.rotation.controller[3].value=ZZ
)else
(
spline_wrongisright tolerance_x_spn.value $ true
$.rotation.controller[1].value=XX
$.rotation.controller[2].value=YY
$.rotation.controller[3].value=ZZ
)---end else check

)

)catch (print "")

)
EnableSceneRedraw()
)catch (print"错")
)--end

)
createdialog gt_closs_spline
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: