面的面积大小合线的长度的判断。


---看到别人的东西是根据选择体的线,选择相应的体中的线。
--1.选择线判断两点距离。其实这我也就明白了容差在这里到底是什么意思。---、
--2.把模型的所有点找到。做递归的两点距离判断。 在容差范围内的,看看是否能还原出线。如果不行就没事。如果行就加到数组中
--3.进行选择。
--4. 关与线的方式我想不出来什么 我觉得就是递增判断距离。--其实后来我用的不是那个。是用的循环线。
 
 --判断物体收集所以线
 --因为每条线都有两个点,判断线的距离。
 
 fn Equal_spline input_poly tolerance =   ---这个函数是查找相等的线,input_poly 是输入的模型信息,判断是poly tolerance 容差数子。
  --在一定范围内的线被选择。
 (
    local line_space =0 --初始化间距
    local endge_length_array =#() ---收集的线的长度数组。
  --只对于是poly 或者是mesh
  if  superclassof input_poly ==GeometryClass  then
  (
    if classof input_poly == Editable_Poly then  --polyop.getEdgeSelection --这个以后还有很到的改善的地方,主要应用于层级的poly mesh
    (
    ---求的总边数
             oop_Eng =  polyop.getNumEdges  input_poly
             
            ---先判断第一个边。找起长度。在进行循环比较
              Edge_array = polyop.getEdgeSelection  input_poly  as array --转成数组好判断个数这个很好。
     if Edge_array.count == 1 then
     (
    
      verts_array = polyop.getEdgeVerts input_poly  Edge_array[1] ---返回边的顶点。--着是个数组
      ---还有这里肯定是两个点的数组。所以我在这里直接用索引就好了。
     
      ---判断距离
     
       date_dis_1 = polyop.getVert  input_poly  verts_array[1]
       date_dis_2 = polyop.getVert  input_poly  verts_array[2]
     
         line_space = distance  date_dis_1 date_dis_2
        -- line_space=line_space+tolerance
      
     )else  return false
               
     ---这里面做循环判断间距。距离在一定范围内加入数组。
     for i in 1 to oop_Eng do ---对每个边进行循环,也就是说,要有很多的point 数组产生 这里要进行长度判断。
     (
      verts_array = polyop.getEdgeVerts input_poly i
     
       date_dis_3 = polyop.getVert  input_poly  verts_array[1]
       date_dis_4 = polyop.getVert  input_poly  verts_array[2]
     
       local_line_space =distance  date_dis_3 date_dis_4
      ---这里要明白一点容差是上下的。所有这里有不同。
     
         tolerance_shang = line_space+tolerance
         tolerance_xia =line_space-tolerance
      
       if local_line_space <=tolerance_shang  and  local_line_space>=tolerance_xia   then ---
       (
         endge_length_array[(endge_length_array.count) +1]= i
       
       )
                     
     
     )---end for oop_Eng
     ---选择边的数组就好
    
     polyop.setEdgeSelection input_poly  endge_length_array
    
 
    )--end classof poly
   
    ---同样在里面找到上面的函数应用到mesh
    --1.返回返回mesh的所有的边数
    --2.对当前的选择边转数组
    --3.比较距离。(这里面中要的是能找到返回点的坐标的函数)
    --4. 循环比较做处理。
    ---我现在的感觉是,搭建物体形体最好是用mesh 编辑物体最好到poly
   
  ---mesh 没有相应转换的参数。所以要是进行比较就比较困难了。这里就制作 poly 的编辑。
  
  )---end if
 
 
 )---end fn
 
 ----下面是根据面的大小做判断,根据面积 ,其实这个函数最好的就是对正边形做判断。处理。
 ---- 原来是利用面的返回值做计算
 fn  Equal_face  input_poly  tolerance = --函数 变量 input_face 是输入的poly tolerance 是容量的大小
 ( 
  local line_space_area =0 --初始化面积。
  local append_faces_area = #()
 
   if  superclassof input_poly ==GeometryClass  then
  (
    if classof input_poly == Editable_Poly then  --polyop.getEdgeSelection --这个以后还有很到的改善的地方,主要应用于层级的poly mesh
    (
     ---求总的面数
     total_output_face =  polyop.getNumFaces input_poly
       ---判断当前的面返回的点。是一个数组 非别是三点 四点 和多点
      being_Verts= polyop.getFaceSelection  input_poly as array
     if being_Verts.count==1 then ---确保选择的是一个面,这个处理的效果非常的好。
     ( 
     
     
       being_Verts_array =  polyop.getFaceVerts  input_poly   being_Verts[1]
       ----数量的表达
       being_Verts_array_count = being_Verts_array.count
       
        case being_Verts_array_count  of
     (
                        3:(
       ---因为这里返回的是点,还是需要用距离算出来。
                 date_dis_1 = polyop.getVert  input_poly  being_Verts_array[1]
                 date_dis_2 = polyop.getVert  input_poly  being_Verts_array[2]
        date_dis_3 = polyop.getVert  input_poly  being_Verts_array[3]
       
         line_space = distance  date_dis_1 date_dis_2
         line_space_1 = distance  date_dis_1 date_dis_3
         ---我做出了两个间距。下面我就计算假性的面积
        line_space_area = line_space *line_space_1 /2
       
       
       
      )
      4:(
         date_dis_1 = polyop.getVert  input_poly  being_Verts_array[1]
                  date_dis_2 = polyop.getVert  input_poly  being_Verts_array[2]
         date_dis_3 = polyop.getVert  input_poly  being_Verts_array[3]
         date_dis_4 = polyop.getVert  input_poly  being_Verts_array[4]
        ----这里面当做矩形看待处理面积
          line_space = distance  date_dis_1 date_dis_2
          line_space_1 = distance  date_dis_3 date_dis_4
        line_space_area = line_space *line_space_1
       
      )
      ----当等于5 6 7 8 时就是按下面的进行计算。
      default:(
       ----对于多个面的我同样是 假性的算出 矩形的面积。来处理
         date_dis_1 = polyop.getVert  input_poly  being_Verts_array[1]
                  date_dis_2 = polyop.getVert  input_poly  being_Verts_array[2]
         date_dis_3 = polyop.getVert  input_poly  being_Verts_array[3]
         date_dis_4 = polyop.getVert  input_poly  being_Verts_array[4]
        ----这里面当做矩形看待处理面积
          line_space = distance  date_dis_1 date_dis_2
          line_space_1 = distance  date_dis_3 date_dis_4
          line_space_area = line_space *line_space_1
       
       
      )

     )----case  of  
     -------------------下面就是循环处理所有面,通过比较面积处理。

     
   
     )else return false
    
      for i in 1 to total_output_face do
      (
       ---在查询面时同样也是要建立一个空组。
         being_Verts_array =  polyop.getFaceVerts  input_poly   i
       ----数量的表达
    ----通过测试表明,如果形体架线不正确,那么可能返回的面数很多,但是其实在面里又返回不了点 就会出现 undefined
       --所以加入排错
       if being_Verts_array ==undefined do  Continue
       being_Verts_array_count = being_Verts_array.count
       
        case ( being_Verts_array_count)  of
     (
                        3:(
       ---因为这里返回的是点,还是需要用距离算出来。
                 date_dis_1 = polyop.getVert  input_poly  being_Verts_array[1]
                 date_dis_2 = polyop.getVert  input_poly  being_Verts_array[2]
        date_dis_3 = polyop.getVert  input_poly  being_Verts_array[3]
       
         line_space = distance  date_dis_1 date_dis_2
         line_space_1 = distance  date_dis_1 date_dis_3
         ---我做出了两个间距。下面我就计算假性的面积
        local_line_space_area = line_space *line_space_1 /2
       if local_line_space_area <= line_space_area+tolerance and local_line_space_area >= line_space_area - tolerance  then
       (
                 append  append_faces_area i
        
        
       )
       
      )
      4:(
         date_dis_1 = polyop.getVert  input_poly  being_Verts_array[1]
                  date_dis_2 = polyop.getVert  input_poly  being_Verts_array[2]
         date_dis_3 = polyop.getVert  input_poly  being_Verts_array[3]
         date_dis_4 = polyop.getVert  input_poly  being_Verts_array[4]
        ----这里面当做矩形看待处理面积
          line_space = distance  date_dis_1 date_dis_2
          line_space_1 = distance  date_dis_3 date_dis_4
         local_line_space_area = line_space *line_space_1
       if local_line_space_area <= line_space_area+tolerance and local_line_space_area >= line_space_area - tolerance  then
       (
                 append  append_faces_area i
        
        
       )
       
      )
      ----当等于5 6 7 8 时就是按下面的进行计算。
      default:(
       ----对于多个面的我同样是 假性的算出 矩形的面积。来处理
         date_dis_1 = polyop.getVert  input_poly  being_Verts_array[1]
                  date_dis_2 = polyop.getVert  input_poly  being_Verts_array[2]
         date_dis_3 = polyop.getVert  input_poly  being_Verts_array[3]
         date_dis_4 = polyop.getVert  input_poly  being_Verts_array[4]
        ----这里面当做矩形看待处理面积
          line_space = distance  date_dis_1 date_dis_2
          line_space_1 = distance  date_dis_3 date_dis_4
           local_line_space_area = line_space *line_space_1
       if local_line_space_area <= line_space_area+tolerance and local_line_space_area >= line_space_area - tolerance  then
       (
                 append  append_faces_area i
        
        
       )
       
       
      )

     )----case  of
     
      
      )--end for face
     
      ---通过上面完成面的收集 ,下来就是进行选择处理。
      polyop.setFaceSelection  input_poly  append_faces_area
 
    
    )--enfd  poly
 
  ) ----end if super classof
 )---end fn
 
 ----对于边面的选择机制 ,我 还是要加入数组的相加处理的,这点很重要。

 try(cui.UnRegisterDialogBar gt_up_down_select)catch()-----这个是法则。
try (DestroyDialog gt_up_down_select )catch()
rollout gt_up_down_select  "容差选择" width:160 height:89
(
 spinner up_down_num_spn "上下容差值:" pos:[11,5] width:135 height:16 range:[0,1e+008,0.01] type:#float scale:0.00001
 button equal_lenght_btn "同长度的边选择" pos:[16,27] width:122 height:18
 button equal_face_btn "同面积的面选择" pos:[18,53] width:122 height:18
 on equal_lenght_btn pressed do
 (
  Equal_spline $ up_down_num_spn.value
 )---end on
  on equal_face_btn pressed do
 (
  Equal_face $ up_down_num_spn.value
 )---end on
 
 
 
)
createdialog gt_up_down_select

cui.RegisterDialogBar gt_up_down_select style:#(#cui_dock_left,#cui_dock_right, #cui_floatable)
cui.DockDialogBar gt_up_down_select #cui_dock_right

posted on 2011-04-23 15:14  盖天00  阅读(261)  评论(0编辑  收藏  举报

导航