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等。本文主要就来介绍一下这两个库中的基于三角网格的布尔运算功能。

Figure 1. Boolean Operation cut between Cylinder and Torus mesh

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

2.MeshLab CSG

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

Figure 2. CSG Operation in MeshLab

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

Figure 3. Intersection between sphere meshes

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

Figure 4. Union between sphere meshes

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

Figure 5. Difference between sphere meshes

3.Cork

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

https://github.com/gilbo/cork

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

Figure 6. Cork help info

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

  1. F:\Mesh\cork\win\wincork\>wincork -union balla.off ballb.off union.off
  2.  
  3. F:\Mesh\cork\win\wincork\>wincork -diff balla.off ballb.off diff.off
  4.  
  5. F:\Mesh\cork\win\wincork\>wincork -isct balla.off ballb.off isct.off

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

Figure 7. Union between two sphere meshes

Figure 8. Difference between two sphere meshes

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

Boolean operations between triangle meshes的更多相关文章

  1. Thread: BooleanRT : Realtime 3D boolean operations for (Runtime,Editor)

    A Product by Mixed Dimensions What is BooleanRT? BooleanRT is a real-time 3D boolean operations exte ...

  2. OpenCascade Modeling Algorithms Boolean Operations

    Modeling Algorithms Boolean Operations of Opencascade eryar@163.com 布尔操作(Boolean Operations)是通过两个形状( ...

  3. [算法]Comparison of the different algorithms for Polygon Boolean operations

    Comparison of the different algorithms for  Polygon Boolean operations. Michael Leonov 1998 http://w ...

  4. python开发_python中的Boolean运算和真假值

    python中的真假值: Truth Value Testing Any object can be tested for truth value, for use in an if or while ...

  5. Computer Graphics Research Software

    Computer Graphics Research Software Helping you avoid re-inventing the wheel since 2009! Last update ...

  6. CG&CAD resource

    Computational Geometry The Geometry Center (UIUC) Computational Geometry Pages (UIUC) Geometry in Ac ...

  7. Fundamentals of Computer Graphics 中文版(第二版) (Peter Shirley 著)

    1 引言 2 数学知识 3 光栅算法 4 信号处理 5 线性代数 6 矩阵变换 7 观察 8 隐藏面消除 9 表面明暗处理 10 光线追踪 11 纹理映射 12 完整的图形流水线 13 图形学的数据结 ...

  8. Discrete.Differential.Geometry-An.Applied.Introduction(sig2008)笔记

    -------------------------------------------------------------- Chapter 1: Introduction to Discrete D ...

  9. zhihu spark集群,书籍,论文

    spark集群中的节点可以只处理自身独立数据库里的数据,然后汇总吗? 修改 我将spark搭建在两台机器上,其中一台既是master又是slave,另一台是slave,两台机器上均装有独立的mongo ...

随机推荐

  1. WebAPI的自动化监控和预警

    Metrics.net + influxdb + grafana 构建WebAPI的自动化监控和预警 前言 这次主要分享通过Metrics.net + influxdb + grafana 构建Web ...

  2. 8.ES6测试

    转自:http://www.ruanyifeng.com/blog/2015/12/a-mocha-tutorial-of-examples.html 如果测试脚本是用ES6写的,那么运行测试之前,需 ...

  3. AES简单加密解密的方法实现

    package com.mstf.aes; import java.io.UnsupportedEncodingException; import java.security.InvalidKeyEx ...

  4. linux傻瓜式安装lnmp

    一.百度 https://lnmp.org/install.html 二.点击 <安装> 三.登录 linux cd /usr/local/ wget -c http://soft.vps ...

  5. Java web application——Listener

    应用程序事件提供ServletContext和HttpSession以及ServletRequest对象状态更改的通知,用户编写响应状态更改的事件监听器类,并配置和部署他们.Servlet容器会调用事 ...

  6. JDBC连接ORACLE无法登陆java.sql.SQLException: ORA-01017: invalid username/password; logon denied

    当用jdbc连接Oracle数据库的时候 private Connection getConnection() throws SQLException { OracleDataSource ods = ...

  7. python 异步IO

    参考链接:https://www.liaoxuefeng.com/wiki/0014316089557264a6b348958f449949df42a6d3a2e542c000/00143208573 ...

  8. python中的装饰器decorator

    python中的装饰器 装饰器是为了解决以下描述的问题而产生的方法 我们在已有的函数代码的基础上,想要动态的为这个函数增加功能而又不改变原函数的代码 例如有三个函数: def f1(x): retur ...

  9. 洛谷 P1542 包裹快递

    P1542 包裹快递 题目描述 小K成功地破解了密文.但是乘车到X国的时候,发现钱包被偷了,于是无奈之下只好作快递员来攒足路费去Orz教主…… 一个快递公司要将n个包裹分别送到n个地方,并分配给邮递员 ...

  10. UITextField监控文字变化方法

    项目里须要在不隐藏键盘的情况下.来更改button 的状态. 这里就是要对uitextfield监控.uitextfield继承于UIControl.所以能够 使用addTarget方法.详细例如以下 ...