SketchUpと3DSMaxの間でエクスポート/インポートプラグインを作成するときに、まったく同じ問題を解決する必要がありました。Sketchupはコンセプトまたは外側と内側のループを使用しますが、3DSMaxは純粋なジオメトリです。
残念ながら、私はプラグインを持っていないので、できる限りそれを覚えようとします。
foreach point in outerLoop
{
// Loop over all other point to find the nearest valid one
foreach otherPoint in both outerLoop and all innerLoops where otherPoint is not point
{
if otherPoint is adjacent to point
reject otherPoint
if distance between point and otherPoint is bigger than previous distance
reject otherPoint
// Test is vector is point outside the geometry in case of convexe shapes
if cross product of vector from (point - adjacent point) and (point - nearest point) is pointing away from cross product of vectors of (point - both adjacents point)
reject otherPoint
nearestPoint = otherPoint
}
for the two adjacentPoint of nearestPoint
{
if adjacentPoint is also adjacent to point
make triangle(point, adjacentPoint, nearestPoint)
if cross product of vector from (point - adjacent point) and (point - nearest point) is pointing in the same direction as cross product of vectors of (point - both adjacents point)
make triangle(point, adjacentPoint, nearestPoint)
}
}
repeat the above for innerLoops point while only checking against other innerLoops
make triangle function should check if the triangle already exist from previous iteration.
それはとてもきれいではなく、ちょっと野蛮ですが、無制限の数の内部ループで動作し、常に可能な限り最高の三角形を作成します。
パフォーマンスを向上させる方法があると確信していますが、十分な時間を与えたことはありません。