簡體   English   中英

如何從3D Delaunay三角剖分中獲取三角形

[英]How to get triangles from 3D Delaunay triangulation

我有一個3D點雲的三角測量dt (或者可能是四面體化),我想找到一種從中提取三角形的好方法。 注意,我知道如何獲得四面體,它的簡單dt.ConnectivityList ,是否有一種從四面體中獲取三角形的有效方法? 每個三角形應僅在列表中出現一次。

目前我正在做以下事情 - 但是它很慢:

dt = delaunayTriangulation([X Y Z]);
tetrahedra = dt.ConnectivityList;

tris = cell(1, size(tetrahedra, 1)); % contains indices of tris in a tetra
for tt=1:size(tetrahedra, 1)
    vertIds = tetrahedra(tt, :); % vertex indices

    vmask = logical([0 1 1 1]);
    tris{tt} = [vertIds(circshift(vmask, [0 0 0 0]));
                vertIds(circshift(vmask, [1 1 1 1]));
                vertIds(circshift(vmask, [2 2 2 2]));
                vertIds(circshift(vmask, [3 3 3 3]))];
end

tris = unique(sort(cell2mat(tris'), 2), 'rows');

這是一個矢量化版本:

% take all four subsets of three points from the tets and concatenate
tris2 = [tetrahedra(:,[1 2 3]); tetrahedra(:,[1 2 4]); tetrahedra(:,[1 3 4]); tetrahedra(:, [2 3 4])];
% sort each row
tris2 = sort(tris2, 2);
% eliminate duplicates
tris2 = unique(tris2, 'rows');

我得到100,000個測試點(隨機數)

Cellmethod: time=9.870982, numelements = 1344960
Vectmethod: time=1.014797, numelements = 1344960

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM