简体   繁体   English

如何删除线框对角线?

[英]How to remove wireframe diagonals?

I wrote a custom exporter for CAD software to export geometry data to ThreeJS editor. 我为CAD软件编写了一个自定义导出器,用于将几何数​​据导出到ThreeJS编辑器。 Now, of course in ThreeJS I wrote a correct loader which is loading all the geometry correctly. 现在,当然,在ThreeJS中,我编写了一个正确的加载器,可以正确加载所有几何图形。

There is just one problem; 只有一个问题。 In wireframe view in ThreeJS I have triangles from each vertex. 在ThreeJS的线框视图中,每个顶点都有一个三角形。 With what technique can I remove the triangulation and diagonals ? 用什么技术可以去除三角剖分和对角线? How can I show wireframe without diagonals ? 如何显示没有对角线的线框?

Source 3D: 源3D: 图片

ThreeJS 3D: (see the triangles and diagonales) ThreeJS 3D :(请参见三角形和对角线) 图片

it looks like you are drawing all points/polygons as single polyline 好像您将所有点/多边形绘制为一条多段线

  • that is not correct you should process each polygon as line loop 这是不正确的,您应该将每个多边形处理为线循环
  • if your mesh is triangulated or quaded then you need to extract the perimeter line 如果您的网格是三角形或四边形,则需要提取周界线

extracting perimeter line 提取周边线

  1. if your mesh is not defined by polygons then you need to group all connected primitives as single polygon 如果您的网格不是由多边形定义的,则需要将所有连接的图元分组为单个多边形
  2. take all lines from single polygon in a list 从列表中的单个多边形获取所有线
  3. find duplicate lines and remove them all 找到重复的行并将其全部删除
    • so all lines that uses the same points (in any order) are duplicate 因此所有使用相同点(以任何顺序)的线都是重复的
    • joined primitives share the same edge 连接的图元具有相同的优势
    • so this is enough for properly triangulated polygons 因此,这对于适当三角剖分的多边形就足够了
  4. some triangulations can be joined by line only not by points 某些三角剖分只能通过线连接而不能通过点连接
    • for these you need to compare all remaining lines 对于这些,您需要比较所有剩余的行
    • take all parallel lines (the same or opposite angle) 取所有平行线(相同或相反的角度)
    • and test if they lies on the same line 并测试它们是否位于同一行
    • if yes and are connected (overlapping) 如果是,并且已连接(重叠)
    • then cut the lines so the overlapped part will be deleted 然后剪切线,以便删除重叠的部分

Bad triangulation 不良三角剖分

  • if primitives are overlapping instead of joined 如果基元重叠而不是合并
  • then draw single polygon to cleared buffer 然后绘制一个多边形到清除的缓冲区
  • then process all lines 然后处理所有行
  • compute midle point for each 计算每个的中点
  • and test if the coordinate is filled in the buffer or not 并测试坐标是否已填充到缓冲区中
  • if it is remove the line 如果是删除行
  • this is not 100% bullet proof 这不是100%的子弹证明
  • you should test more points along each line 您应该沿着每条线测试更多点
  • and if some are in and some out then find the intersections and cut the inside part only 如果有进有出,则找到交点并仅切开内部
  • you can also use vector approach for the inside test but you have to handle multiple overlaps 您也可以使用向量方法进行内部测试,但必须处理多个重叠

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM