3

以下是定义我的简单 3D 几何的要点。

datN = {{{-0.47150460764747554`, 0.29559274991660417`, 
 0.010131794240974218`}, {-0.4762714873728534`, 
 0.2955927499166042`, 
 0.010567957416020535`}, {-0.4835042628911566`, 
 0.29559274991660417`, 
 0.01066658601048008`}, {-0.49133736140975415`, 
 0.29559274991660417`, 
 0.01010572204377315`}, {-0.4974365622729896`, 
 0.29559274991660417`, 
 0.009602808597554033`}, {-0.4999590574180981`, 
 0.2955927499166041`, 
 0.010150149141898643`}, {-0.497870343592127`, 
 0.2955927499166042`, 
 0.011728012221066566`}, {-0.491634397829927`, 
 0.2955927499166041`, 
 0.013089897457762985`}, {-0.4834169387190052`, 
 0.2955927499166042`, 
 0.013009607974106477`}, {-0.47609963350102275`, 
 0.2955927499166043`, 
 0.011622413291940486`}, {-0.471504606936728`, 
 0.2955927499166041`, 
 0.010131794240974216`}}, {{-0.5619323339485054`, 
 0.13709660728856332`, 
 0.010131794240974218`}, {-0.5878076066290028`, 
 0.13709660728856335`, 
 0.01249934738636439`}, {-0.6270680976744502`, 
 0.13709660728856332`, 
 0.0130347168361427`}, {-0.6695872237650179`, 
 0.13709660728856332`, 
 0.00999027080199048`}, {-0.7026945171227986`, 
 0.13709660728856332`, 
 0.007260388089336815`}, {-0.7163869644835803`, 
 0.13709660728856332`, 
 0.010231427144215837`}, {-0.705049141229765`, 
 0.13709660728856338`, 
 0.018796282936276536`}, {-0.6711995779276564`, 
 0.13709660728856332`, 
 0.02618878157043711`}, {-0.6265940901692914`, 
 0.13709660728856332`, 
 0.02575295931296998`}, {-0.5868747603960375`, 
 0.13709660728856335`, 
 0.018223077560156144`}, {-0.5619323300904714`, 
 0.1370966072885633`, 0.010131794240974216`}}};

现在我们准备面和顶点

pt = Flatten[{datN[[1]], datN[[2]]}, 1];
facets = Join[{{Flatten@Map[Position[pt, #] &, datN[[1]]]}}, 
Table[{Flatten@
  Map[Position[pt, #] &, {datN[[1]][[i]], datN[[2]][[i]], 
    datN[[2]][[i + 1]], datN[[1]][[i + 1]]}]}, {i, 1, 
 10}], {{Flatten@Map[Position[pt, #] &, datN[[2]]]}}];

然后,我们在文档中描述的同一行中使用 TetGen,这是最简单的带有盒子的示例。

Needs["TetGenLink`"]
inInst = TetGenCreate[];
TetGenSetPoints[inInst, pt];
TetGenSetFacets[inInst, facets];
outInst = TetGenTetrahedralize[inInst, "pq1.414a0.01"];
coords = TetGenGetPoints[outInst];
surface = TetGenGetFaces[outInst];

我们可以看到没有生成网格,也TetGenGetPoints无法重新调整顶点。结果非常令人失望。

GraphicsGrid@{{Graphics3D[GraphicsComplex[pt, Map[Polygon, facets]], 
Boxed -> False], 
Graphics3D[GraphicsComplex[coords, Polygon[surface]]]}}

在此处输入图像描述

为什么会发生这种奇怪的事情。TetGen 文档也不令人满意。

4

1 回答 1

6

虽然datN两个子列表的起点和终点实际上是相同的,但就 Mathematica 而言,它们算作不同的点。这意味着它facets实际上并不代表一个封闭的多面体(边 {datN[[1,1]], datN[[2,1]]}和之间有一个微小的间隙{datN[[1,-1]], datN[[2,-1]]})。

datN[[1]]为了解决这个问题,您可以从和的定义中删除端点,dat[[2]]并将任何出现的 替换datN[[i]][[11]]为,例如datN[[i]][[1]]facets

datN2 = Drop[#, -1]& /@ datN;
pt = Flatten[datN2, 1];
facets = Join[
    {{Flatten@Map[Position[pt, #] &, datN2[[1]]]}}, 
    Table[{Flatten@
       Map[Position[pt, #] &, {datN2[[1]][[i]], datN2[[2]][[i]], 
         datN2[[2]][[Mod[i, 10] + 1]], 
         datN2[[1]][[Mod[i, 10] + 1]]}]}, {i, 1, 10}], 
    {{Flatten@Map[Position[pt, #] &, datN2[[2]]]}}];

其余代码保持不变,即

Needs["TetGenLink`"]
inInst = TetGenCreate[];
TetGenSetPoints[inInst, pt];
TetGenSetFacets[inInst, facets];
outInst = TetGenTetrahedralize[inInst, "pq1.414a0.01"];
coords = TetGenGetPoints[outInst];
surface = TetGenGetFaces[outInst];

然后绘制曲面会得到以下结果:

GraphicsGrid@{{Graphics3D[GraphicsComplex[pt, Map[Polygon, facets]], 
  Boxed -> False], 
Graphics3D[GraphicsComplex[coords, Polygon[surface]]]}}

四面体化

于 2011-10-14T16:06:44.973 回答