PolygonModifier

PolygonModifier

패키지: aspose.threed.entities (aspose-3d-foss 26.1.0)

PolygonModifier 다각형 테셀레이션 작업을 제공하는 정적 유틸리티 클래스입니다 MeshScene 객체. 모든 메서드는 클래스 메서드입니다; PolygonModifier 직접 인스턴스화되지 않습니다.

from aspose.threed.entities import PolygonModifier

주요 작업은 삼각형화이며, ear-clipping 기법을 사용해 사각형 및 n-곤을 삼각형으로 변환합니다. 이는 삼각형 기하만 허용하는 포맷(STL, 일부 glTF 파이프라인)으로 내보내기 전에 필요합니다.


Methods

triangulate(arg) — 삼각형화 Mesh

새로운 것을 반환합니다 Mesh 모든 다각형이 삼각형으로 변환된 형태입니다. 원본 메시는 수정되지 않습니다. 정점 요소 레이어(노멀, UV, 색상)는 새로운 메시로 복사됩니다.

@staticmethod
def triangulate(mesh: Mesh) -> Mesh
MethodsMethodsMethods
meshMesh삼각형화할 원본 메시.

반환값: Mesh — 삼각형 다각형만 포함하는 새로운 메시.

from aspose.threed.entities import Mesh, PolygonModifier
from aspose.threed.utilities import Vector4

mesh = Mesh()
# Use _control_points to mutate the backing list (control_points returns a copy)
for x, z in [(0, 0), (1, 0), (1, 1), (0, 1)]:
    mesh._control_points.append(Vector4(float(x), 0.0, float(z), 1.0))
mesh.create_polygon(0, 1, 2, 3)   # one quad

tri_mesh = PolygonModifier.triangulate(mesh)
print(tri_mesh.polygon_count)     # 2

triangulate(scene) — 모든 메시를 삼각형화 Scene

전체 씬 그래프를 순회하며 모든 것을 삼각형화합니다 Mesh 엔티티가 제자리에 있습니다. 이 호출 후에는 장면에 삼각형이 아닌 폴리곤이 남지 않습니다.

@staticmethod
def triangulate(scene: Scene) -> None
MethodsMethodsMethods
sceneScene메시 엔티티가 삼각형화될 장면.

반환값: None

from aspose.threed import Scene
from aspose.threed.entities import PolygonModifier

scene = Scene.from_file("model_with_quads.obj")
PolygonModifier.triangulate(scene)
scene.save("model_triangulated.stl")

triangulate(control_points, polygon) — 단일 폴리곤을 삼각형화

저수준 오버로드: 제어점 리스트와 하나의 폴리곤을 형성하는 정점 인덱스 리스트가 주어지면, 팬 삼각형화에 의해 생성된 삼각형 인덱스 삼중항 리스트를 반환합니다.

@staticmethod
def triangulate(
    control_points: list[Vector4],
    polygon: list[int],
) -> list[list[int]]
MethodsMethodsMethods
control_pointslist[Vector4]전체 정점 위치 배열.
polygonlist[int]다음에 대한 인덱스 control_points 분할할 폴리곤을 정의합니다.

반환값: list[list[int]] — 목록 [i, j, k] 삼중항으로, 각각은 하나의 출력 삼각형을 나타냅니다.

from aspose.threed.entities import PolygonModifier
from aspose.threed.utilities import Vector4

pts = [
    Vector4(0.0, 0.0, 0.0, 1.0),
    Vector4(1.0, 0.0, 0.0, 1.0),
    Vector4(1.0, 1.0, 0.0, 1.0),
    Vector4(0.0, 1.0, 0.0, 1.0),
]
quad_indices = [0, 1, 2, 3]
triangles = PolygonModifier.triangulate(pts, quad_indices)
print(triangles)   # e.g. [[0, 1, 2], [0, 2, 3]]

triangulate(control_points, polygons, generate_normals, normals_out) — 선택적 노멀 생성이 가능한 배치 삼각형화

폴리곤 인덱스 리스트 목록을 배치 삼각형화합니다. 선택적으로 각 출력 삼각형에 대한 면 노멀을 계산하고 이를 normals_out.

@staticmethod
def triangulate(
    control_points: list[Vector4],
    polygons: list[list[int]],
    generate_normals: bool = False,
    normals_out: list[Vector3] | None = None,
) -> list[list[int]]
MethodsMethodsMethods
control_pointslist[Vector4]정점 위치 배열.
polygonslist[list[int]]다각형 정의 목록이며, 각 정의는 정점 인덱스의 리스트입니다.
generate_normalsboolMethods True, 각 출력 삼각형에 대한 면 법선을 계산합니다.
normals_out`list[Vector3]None`

반환: list[list[int]] — 모든 출력 삼각형 삼중항을 순서대로.

from aspose.threed.entities import PolygonModifier
from aspose.threed.utilities import Vector4, Vector3

pts = [
    Vector4(0, 0, 0, 1), Vector4(1, 0, 0, 1),
    Vector4(1, 1, 0, 1), Vector4(0, 1, 0, 1),
]
polys = [[0, 1, 2, 3]]
normals: list[Vector3] = []
tris = PolygonModifier.triangulate(pts, polys, True, normals)
print(len(tris))     # 2
print(len(normals))  # 2

또 보기

 한국어