Boolean operations between triangle meshes

Boolean operations between triangle meshes

[email protected]

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相同的文件夹中,分别输入以下命令来得到相应的布尔运算结果:

F:\Mesh\cork\win\wincork\>wincork -union balla.off ballb.off union.off

F:\Mesh\cork\win\wincork\>wincork -diff balla.off ballb.off diff.off

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

原文地址:https://www.cnblogs.com/opencascade/p/Boolean_Operations_Mesh.html

时间: 2024-10-07 19:28:11

Boolean operations between triangle meshes的相关文章

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

Comparison of the different algorithms for  Polygon Boolean operations. Michael Leonov 1998 http://www.angusj.com/delphi/clipper.php#screenshots http://www.complex-a5.ru/polyboolean/comp.html http://www.angusj.com/delphi/clipper.php#screenshots Intro

Boolean Operations -- and, or, not

Boolean Operations -- and, or, not 布尔运算操作,优先级按升序排序: x or y                 如果x为假,那么y,否则x                         短路运算符,只有当参数x为False,才计算参数y x and y              如果x为假,则x,否则y                             短路运算符,只有当参数x为True,才计算参数y not x                 如果

Computer Graphics Research Software

Helping you avoid re-inventing the wheel since 2009! Last updated December 5, 2012.Try searching this page for keywords like 'segmentation' or 'PLY'.If you would like to contribute links, please e-mail them to [email protected]. Papers & Archives Gra

计算机图形学研究常用工具软件和代码

Computer Graphics Research Software Helping you avoid re-inventing the wheel since 2009! Last updated December 5, 2012.Try searching this page for keywords like 'segmentation' or 'PLY'.If you would like to contribute links, please e-mail them to [ema

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

-------------------------------------------------------------- Chapter 1: Introduction to Discrete Differential Geometry: The Geometry of Plane Curves . A better approximation than the tangent is the circle of curvature. . If the curve is sufficientl

OpenSCAD三维造型设计语言

cube Creates a cube at the origin of the coordinate system. When center is true the cube will be centered on the origin, otherwise it is created in the first octant. The argument names are optional if the arguments are given in the same order as spec

Octave中无法使用rgb2gray()函数

在Octave中加载图像并转成灰度图时,发现rgb2gray()函数不存在,上网搜了一下,stackoverflow上给出了相关解释,如下: The problem is that you didn't load your packages. When you type pkg list you can find which ones are loaded by an asterisk in front of their names. Load a package with pkg load i

多边形三角网剖分资料(转)

仔细查了一下资料.关于多边形三角网剖分,已经有人在网上做了归纳总结. OpenGL的 glutesselation虽然好用,但是据说算法效率不行. 比较好的算法还是Ploy2Tri算法.有时间还是得试一试. Triangulation of Simple PolygonsBen Discoe, notes from 2001.02.11, updated through 2009.01 I needed some code for tessellating polygons, which cou

Python著名的lib和开发框架(均为转载)

第一,https://github.com/vinta/awesome-python Awesome Python A curated list of awesome Python frameworks, libraries, software and resources. Inspired by awesome-php. Awesome Python Admin Panels Algorithms and Design Patterns Anti-spam Asset Management A