zoukankan      html  css  js  c++  java
  • poly 奇数偶数 隔点选择。 实时的 线 面的选择, 就是和max2011 石墨一样的办法,我只是没有用when 。

    ---段数的跳一个 选择一个,这样进行处理。点数的,面数的处理
    ---起初我是这么想的。用when 语句进行操作,单我按下按钮时,就是这样的,当我点击的线符合拓扑结构时。
    ---产生横向与纵向的连长,但是我后来就不这么想了。
    ---尤其是在听了路生的教导后。我不想在刷什么。我要做的工作是,在max的基础上,做东西。补不足。 max 能实现的,大家都在用,所以习惯了,
    ---不是很好改了。
    ---好了,写东西了。起初只是想写线的,现在看来,我要写 点的 边的, 面的  奇数 偶数的选择。2011.4.22 晚
    ---由于在选择中选择缺口 返回的是边,所以 所以这样按缺口选择的 估计有特定的函数,或有特定的组,
    ---这个我在后卖在考虑。
     fn odd_numbers_even_numbers input_poly type_t  odd_even  num  =
     (
      ---结构是点 边 面   在往下就是 奇数性 还有就是偶数性
      
        case of ---这个是我的手动的处理。所以这里面我只列举3 中情况进行处理。
      (

      (type_t == "select_vertex"):(
       
       local mod_array =#()
       local mod_back_array =#()
        Back_Verts_array = polyop.getVertSelection  input_poly
        Back_Verts_array =Back_Verts_array as array
       if Back_Verts_array.count !=0 then
       (
        Back_Verts_array =sort  Back_Verts_array --数组排列方便选择。
        
        for i in 1 to Back_Verts_array.count do
        (
         if  (mod  i num )as integer ==0 then
         (
             append   mod_array   Back_Verts_array[i]
          
         )else
         (
          append   mod_back_array   Back_Verts_array[i]
          
         )---end else
         
        )---end for
        
       
       
       if odd_even=="odd"then
       (
         polyop.setVertSelection   input_poly  mod_back_array
       )--end odd
       if odd_even=="even" then
       (
         polyop.setVertSelection   input_poly  mod_array
       )---end enen
       )----end back_vertex_array
       
      )---end ()
      (type_t == "select_edge"):(
       local mod_array =#()
       local mod_back_array =#()
        Back_Verts_array = polyop.getEdgeSelection  input_poly
        Back_Verts_array =Back_Verts_array as array
       if Back_Verts_array.count !=0 then
       (
        Back_Verts_array =sort  Back_Verts_array --数组排列方便选择。
        
        for i in 1 to Back_Verts_array.count do
        (
         if  (mod  i num )as integer ==0 then
         (
             append   mod_array   Back_Verts_array[i]
          
         )else
         (
          append   mod_back_array   Back_Verts_array[i]
          
         )---end else
         
        )---end for
        
       
       
       if odd_even=="odd"then
       (
         polyop.setEdgeSelection   input_poly  mod_back_array
       )--end odd
       if odd_even=="even" then
       (
         polyop.setEdgeSelection   input_poly  mod_array
       )---end enen
       
       )----end back_vertex_array
       
      )---end ()
      (type_t == "select_polygon"):(
       
       local mod_array =#()
       local mod_back_array =#()
        Back_Verts_array = polyop.getFaceSelection  input_poly
        Back_Verts_array =Back_Verts_array as array
       if Back_Verts_array.count !=0 then
       (
        Back_Verts_array =sort  Back_Verts_array --数组排列方便选择。
        
        for i in 1 to Back_Verts_array.count do
        (
         if  (mod  i num )as integer ==0 then
         (
             append   mod_array   Back_Verts_array[i]
          
         )else
         (
          append   mod_back_array   Back_Verts_array[i]
          
         )---end else
         
        )---end for
        
       
       
       if odd_even=="odd"then
       (
         polyop.setFaceSelection   input_poly  mod_back_array
       )--end odd
       if odd_even=="even" then
       (
         polyop.setFaceSelection   input_poly  mod_array
       )---end enen
       
       )else return  false ----end back_vertex_array
       
       
       
      )---end ()


       )---enf case
     )---end fn
     
    ---我觉得点的选择可以由面点会来,这个就不用写了。其实原来也是有面转成点,这个不是很费时间。
    ---我做的工具也是配合max 的命令一期操作的,所以这个就不选了。

     ------------------------------------------------------------------------------------- 
      
      
    fn max_2011_mode_style input_poly type_t ring_and_loop  by_num =
    (

    ---针对于我想的这里算法。来对点线面进行处理。我的方法就是
    --1.(先以线为例说明点和面都是这里过度的。)试验的对像确保是一个可操作的对象结构。
    --2.得知序列返回数组,返回之前选择的 组内对应的号数。 在组内做递加 和递减 最小不能小于1 最大不能超过组本身的数
    --3.两个数组相加 在进行边的选择,
    --4.之后依次展开 处理。
    --5.结构是:
    ---------------1. 点线面的大结构
    ---------------2.在处理横选择 还是纵选择的问题
    ---------------3. 选择处理
      case of ---这个是我的手动的处理。所以这里面我只列举3 中情况进行处理。
      (
       
      (type_t == "select_vertex"):(
       ---2011.4.23 2.35 对于点击莫一个线向外边散开,隔一个选择一个思路我是有了。
       
       --在这个的操作中,对于线我已经做好,对于面我可以转换成线,在操作,最后在返回面,造成
       --假象上的对于面的处理。其实还是从线的方式出发。
       --对于点 在转换成线的过程中,就不是很好办理。我是可以通过线 转点在选择点,
       --从研究上来说是可行的,但是从应用 和美术来说极为不好,所以这部分呢不写 不要了。
       --想要的效果同样是能做出来。
       
      )---end ()

      (type_t == "select_edge"):(
       ---2011.4.23 2.35 对于点击莫一个线向外边散开,隔一个选择一个思路我是有了。
       ---判断选择线是一个进行操作,这个是我要的效果。
       local up_array =#()
       local down_array = #()
       local total_array =()---向上向下的数组加在一起,就是我要选择的东西。
       
       
       Back_Verts_array = polyop.getEdgeSelection  input_poly
       Back_Verts_array=Back_Verts_array as array
       if  Back_Verts_array.count ==1 then
       (
       if ring_and_loop=="ring"then
       (
        input_poly.EditablePoly.SelectEdgeRing ()
        ---加入循环命令。
        --查看现在选择的号数,和之前的查找编号。如果数组的个数小于两个是什么都不做的。
        form_Back_Verts_array= Back_Verts_array[1] ---这里面保证是一个。
        
        now_Back_Verts_array = polyop.getEdgeSelection  input_poly
        now_Back_Verts_array=now_Back_Verts_array as array
        now_Back_Verts_array_count =now_Back_Verts_array.count ---数量
        ---下一步就是查找顶点所在的个数,在一个模型中,顶点数组肯定是不会有重复的。
        if now_Back_Verts_array_count <3 then return false ----如果数组中就这有两个的话
         ---循环 隔选就没有意义了。
        
        ----在数组中查找肯定是能查找出来,这个是肯定的。
         unm_edge = findItem   now_Back_Verts_array  form_Back_Verts_array
        -----寄存选择的线在数组中的位置。
        local true_tt =true
        while true_tt do
        ( 
         --append up_array 这里面我为什么想放在这里,我是怕溜掉了unm_edge
         --后来想想他还像下循环,都这样的话旧哟哟重复的了
         -- 这里我不查找数组的重复,我最后做个加法运算。加上他就行了,这样快。
         unm_edge+=by_num
         ----这里就是循环一遍把东西往数组中加入一遍。
         if unm_edge<= now_Back_Verts_array_count then
         (
         append up_array now_Back_Verts_array[unm_edge]
         )
         
         if unm_edge>=now_Back_Verts_array_count then
         (
          true_tt=false
          
         )
         
        )---end while
        
        local true_true =true
        while true_true do
        ( 
         --append up_array 这里面我为什么想放在这里,我是怕溜掉了unm_edge
         --后来想想他还像下循环,都这样的话旧哟哟重复的了
         -- 这里我不查找数组的重复,我最后做个加法运算。加上他就行了,这样快。
         unm_edge-=by_num
         ----这里就是循环一遍把东西往数组中加入一遍。
         if unm_edge >=1 then
         (
         append down_array  now_Back_Verts_array[unm_edge]
         )
         
         if unm_edge <=1 then
         (
          true_true=false
          
         )
        
         
        )---end while
        total_array =up_array +down_array +Back_Verts_array

         polyop.setEdgeSelection   input_poly  total_array
        
       )----end if ring
       
       
       if ring_and_loop=="loop"then
       (
        input_poly.EditablePoly.SelectEdgeLoop ()
        ---加入循环命令。
        --查看现在选择的号数,和之前的查找编号。如果数组的个数小于两个是什么都不做的。
        form_Back_Verts_array= Back_Verts_array[1] ---这里面保证是一个。
        
        now_Back_Verts_array = polyop.getEdgeSelection  input_poly
        now_Back_Verts_array=now_Back_Verts_array as array
        now_Back_Verts_array_count =now_Back_Verts_array.count ---数量
        ---下一步就是查找顶点所在的个数,在一个模型中,顶点数组肯定是不会有重复的。
        if now_Back_Verts_array_count <3 then return false ----如果数组中就这有两个的话
         ---循环 隔选就没有意义了。
        
        ----在数组中查找肯定是能查找出来,这个是肯定的。
         unm_edge = findItem   now_Back_Verts_array  form_Back_Verts_array
        -----寄存选择的线在数组中的位置。
        local true_tt =true
        while true_tt do
        ( 
         --append up_array 这里面我为什么想放在这里,我是怕溜掉了unm_edge
         --后来想想他还像下循环,都这样的话旧哟哟重复的了
         -- 这里我不查找数组的重复,我最后做个加法运算。加上他就行了,这样快。
         unm_edge+=by_num
         ----这里就是循环一遍把东西往数组中加入一遍。
         if unm_edge<= now_Back_Verts_array_count then
         (
         append up_array now_Back_Verts_array[unm_edge]
         )
         
         if unm_edge>=now_Back_Verts_array_count then
         (
          true_tt=false
          
         )
         
        )---end while
        
        local true_true =true
        while true_true do
        ( 
         --append up_array 这里面我为什么想放在这里,我是怕溜掉了unm_edge
         --后来想想他还像下循环,都这样的话旧哟哟重复的了
         -- 这里我不查找数组的重复,我最后做个加法运算。加上他就行了,这样快。
         unm_edge-=by_num
         ----这里就是循环一遍把东西往数组中加入一遍。
         if unm_edge >=1 then
         (
         append down_array  now_Back_Verts_array[unm_edge]
         )
         
         if unm_edge <=1 then
         (
          true_true=false
          
         )
        
         
        )---end while
        total_array =up_array +down_array +Back_Verts_array

         polyop.setEdgeSelection   input_poly  total_array
        
       )----end if loop
       
       
      )---end if back_vertx_array.count
        
      )---end ()

      (type_t == "select_polygon"):(
       ---2011.4.23 2.35 对于点击莫一个线向外边散开,隔一个选择一个思路我是有了。
       
       ---判断选择线是一个进行操作,这个是我要的效果。
       local up_array =#()
       local down_array = #()
       local total_array =()---向上向下的数组加在一起,就是我要选择的东西。
       
       
       Back_Verts_array = polyop.getFaceSelection input_poly
       Back_Verts_array=Back_Verts_array as array
       if  Back_Verts_array.count ==1 then
       (
       if ring_and_loop=="ring"then
       (
         
        ---加入循环命令。
        --查看现在选择的号数,和之前的查找编号。如果数组的个数小于两个是什么都不做的。
        form_Back_Verts_array= Back_Verts_array[1] ---这里面保证是一个。
        --input_poly.EditablePoly.SelectEdgeRing ()
        --用面返回边,用边做循环 返回面,在进行面的处理。
        polygon_to_edge_array = polyop.getFaceEdges input_poly  form_Back_Verts_array
        ---返回的第一个是ring 第二个是loop
         polyop.setEdgeSelection  input_poly  polygon_to_edge_array[1]--这里是转折点
         input_poly.EditablePoly.SelectEdgeRing ()
        input_poly.EditablePoly.ConvertSelection  #Edge #Face --转成面
        
        now_Back_Verts_array = polyop.getFaceSelection  input_poly
        now_Back_Verts_array=now_Back_Verts_array as array
        now_Back_Verts_array_count =now_Back_Verts_array.count ---数量
        ---下一步就是查找顶点所在的个数,在一个模型中,顶点数组肯定是不会有重复的。
        if now_Back_Verts_array_count <3 then return false ----如果数组中就这有两个的话
         ---循环 隔选就没有意义了。
        
        ----在数组中查找肯定是能查找出来,这个是肯定的。
         unm_edge = findItem   now_Back_Verts_array  form_Back_Verts_array
        -----寄存选择的线在数组中的位置。
        local true_tt =true
        while true_tt do
        ( 
         --append up_array 这里面我为什么想放在这里,我是怕溜掉了unm_edge
         --后来想想他还像下循环,都这样的话旧哟哟重复的了
         -- 这里我不查找数组的重复,我最后做个加法运算。加上他就行了,这样快。
         unm_edge+=by_num
         ----这里就是循环一遍把东西往数组中加入一遍。
         if unm_edge<= now_Back_Verts_array_count then
         (
         append up_array now_Back_Verts_array[unm_edge]
         )
         
         if unm_edge>=now_Back_Verts_array_count then
         (
          true_tt=false
          
         )
         
        )---end while
        
        local true_true =true
        while true_true do
        ( 
         --append up_array 这里面我为什么想放在这里,我是怕溜掉了unm_edge
         --后来想想他还像下循环,都这样的话旧哟哟重复的了
         -- 这里我不查找数组的重复,我最后做个加法运算。加上他就行了,这样快。
         unm_edge-=by_num
         ----这里就是循环一遍把东西往数组中加入一遍。
         if unm_edge >=1 then
         (
         append down_array  now_Back_Verts_array[unm_edge]
         )
         
         if unm_edge <=1 then
         (
          true_true=false
          
         )
        
         
        )---end while
        total_array =up_array +down_array +Back_Verts_array

         polyop.setFaceSelection  input_poly  total_array
        
       )----end if ring
       
       
       if ring_and_loop=="loop"then
       (
        
         
        ---加入循环命令。
        --查看现在选择的号数,和之前的查找编号。如果数组的个数小于两个是什么都不做的。
        form_Back_Verts_array= Back_Verts_array[1] ---这里面保证是一个。
        --input_poly.EditablePoly.SelectEdgeRing ()
        --用面返回边,用边做循环 返回面,在进行面的处理。
        polygon_to_edge_array = polyop.getFaceEdges input_poly  form_Back_Verts_array
        ---返回的第一个是ring 第二个是loop
         polyop.setEdgeSelection  input_poly  polygon_to_edge_array[2]--这里是转折点
        -- input_poly.EditablePoly.SelectEdgeLoop ()
        input_poly.EditablePoly.SelectEdgeRing ()---这里我变化了数组个数所以都是要ring
        input_poly.EditablePoly.ConvertSelection  #Edge #Face --转成面
        
        now_Back_Verts_array = polyop.getFaceSelection  input_poly
        now_Back_Verts_array=now_Back_Verts_array as array
        now_Back_Verts_array_count =now_Back_Verts_array.count ---数量
        ---下一步就是查找顶点所在的个数,在一个模型中,顶点数组肯定是不会有重复的。
        if now_Back_Verts_array_count <3 then return false ----如果数组中就这有两个的话
         ---循环 隔选就没有意义了。
        
        ----在数组中查找肯定是能查找出来,这个是肯定的。
         unm_edge = findItem   now_Back_Verts_array  form_Back_Verts_array
        -----寄存选择的线在数组中的位置。
        local true_tt =true
        while true_tt do
        ( 
         --append up_array 这里面我为什么想放在这里,我是怕溜掉了unm_edge
         --后来想想他还像下循环,都这样的话旧哟哟重复的了
         -- 这里我不查找数组的重复,我最后做个加法运算。加上他就行了,这样快。
         unm_edge+=by_num
         ----这里就是循环一遍把东西往数组中加入一遍。
         if unm_edge<= now_Back_Verts_array_count then
         (
         append up_array now_Back_Verts_array[unm_edge]
         )
         
         if unm_edge>=now_Back_Verts_array_count then
         (
          true_tt=false
          
         )
         
        )---end while
        
        local true_true =true
        while true_true do
        ( 
         --append up_array 这里面我为什么想放在这里,我是怕溜掉了unm_edge
         --后来想想他还像下循环,都这样的话旧哟哟重复的了
         -- 这里我不查找数组的重复,我最后做个加法运算。加上他就行了,这样快。
         unm_edge-=by_num
         ----这里就是循环一遍把东西往数组中加入一遍。
         if unm_edge >=1 then
         (
         append down_array  now_Back_Verts_array[unm_edge]
         )
         
         if unm_edge <=1 then
         (
          true_true=false
          
         )
        
         
        )---end while
        total_array =up_array +down_array +Back_Verts_array

         polyop.setFaceSelection  input_poly  total_array

        
       )----end if loop
       
       
         )---end if back_vertx_array.count
     
      )---end ()    
       
      )----end case

     
    )-------end fn max_2011

  • 相关阅读:
    matlab简单线性规划&单纯形法
    matlab多变量绘图函数(类似ggplot2)
    matlab近似泛函优化
    如何求矩阵的逆矩阵
    数值分析手写笔记
    latex绘图小结
    数理统计手写笔记
    matlab kriging模型
    运筹学与最优化手写笔记
    matlab既约梯度法习题
  • 原文地址:https://www.cnblogs.com/gaitian00/p/2025422.html
Copyright © 2011-2022 走看看