• Boolean operations between triangle meshes


    Boolean operations between triangle meshes

    eryar@163.com

    Abstract. Boolean operations is one of basic and well known on 3D models. The operations are widely used in computer graphics, game, CAD, EDA. The blog introduce the function in some open source program. 

    Key Words. Boolean Operations, Mesh, Triangle Mesh Boolean Operations,

    1.Introduction

    OpenCASCADE提供了基于BREP体的Boolean Operations,但是如果Topo体中只包含三角网格信息的话,是不支持布尔运算的。典型的例子就是由STL导入生成的模型在OpenCASCADE中是不能进行布尔运算。

    有一些开源库提供了基于三角网格的布尔运算的功能。如MeshLab、Cork等。本文主要就来介绍一下这两个库中的基于三角网格的布尔运算功能。

    wps_clip_image-6945

    Figure 1. Boolean Operation cut between Cylinder and Torus mesh

    基于网格有布尔运算主要应用于没有几何信息的模型,如游戏、3D打印中的网格模型。

    2.MeshLab CSG

    MeshLab中提供了网格的布尔运算功能,源码在filter_csg中。程序界面如下图所示:

    wps_clip_image-25211

    Figure 2. CSG Operation in MeshLab

    下图所示为两个网格球的公共部分Intersection的结果:

    wps_clip_image-31437

    Figure 3. Intersection between sphere meshes

    由上图可以看出,经过布尔运算后,网格变密了。

    wps_clip_image-5546

    Figure 4. Union between sphere meshes

    上图所示为两个网格球的合并union结果。合并后的网格也变密了。

    wps_clip_image-19657

    Figure 5. Difference between sphere meshes

    3.Cork 

    Cork是一个小巧的用于网格布尔运算的开源库(LGPL),可以从如下地址下载:

    https://github.com/gilbo/cork

    下面使用cork编译出来的程序来测试下前面两个球的网格。在Windows中可以编译一个测试的应用程序,可以输入命令来测试效果:

    wps_clip_image-14008

    Figure 6. Cork help info

    将测试文件ballA.off和ballB.off复制到编译出来的程序wincork相同的文件夹中,分别输入以下命令来得到相应的布尔运算结果:

    F:Meshcorkwinwincork>wincork -union balla.off ballb.off union.off
    
    F:Meshcorkwinwincork>wincork -diff balla.off ballb.off diff.off
    
    F:Meshcorkwinwincork>wincork -isct balla.off ballb.off isct.off

    然后将生成的union.off、diff.off和isct.off在MeshLab中打开如下图所示:

    wps_clip_image-6071

    Figure 7. Union between two sphere meshes

    wps_clip_image-29249

    Figure 8. Difference between two sphere meshes

    wps_clip_image-7233

    Figure 9. Intersection between two sphere meshes

    从上面结果可以看出cork库得到的结果网格效果好,没有加密。

    4. Conclusion

    基于网格的布尔运算也是三维建模中一个基本功能,一些开源库提供了对网格进行布尔运算的支持。如MeshLab, Cork, CGAL等。

    本文通过在MeshLab和Cork中对两个球的网格进行布尔运算,对比运算的结果,发现使用Cork得到的网格没有加密,数据量会小一些。

    由于OpenCASCADE目前的版本不支持基于网格的布尔运算,在其官网上提供了一个功能请求:https://tracker.dev.opencascade.org/view.php?id=29776

    wps_clip_image-7484

  • 相关阅读:
    Apache(文章测试)
    这是一篇Markdown手册
    Linux MySQL 8.0 忘记密码
    composer 自动加载源码解析
    Linux 连接 Internet
    PHP namespace、abstract、interface、trait使用介绍
    网络基础知识
    CentOS7安装Nginx、MySQL、PHP
    局域网内使用ssh连接两台计算机总结
    整数和浮点数的表示方法
  • 原文地址:https://www.cnblogs.com/opencascade/p/Boolean_Operations_Mesh.html
Copyright © 2020-2023  润新知