PolygonModifier

PolygonModifier

पैकेज: aspose.threed.entities (aspose-3d-foss 26.1.0)

PolygonModifier एक स्थैतिक उपयोगिता वर्ग है जो बहुभुज टेसलेशन संचालन प्रदान करता है on Mesh और Scene ऑब्जेक्ट्स। सभी मेथड्स क्लास मेथड्स हैं; PolygonModifier कोई भी सीधे इंस्टैंशिएट नहीं किया जाता।.

from aspose.threed.entities import PolygonModifier

मुख्य संचालन त्रिकोणीयकरण है: क्वाड और n‑गॉन को ईयर‑क्लिपिंग द्वारा त्रिकोणों में बदलना। यह उन स्वरूपों में निर्यात करने से पहले आवश्यक है जो केवल त्रिकोणीय ज्यामिति स्वीकार करते हैं (STL, कुछ glTF पाइपलाइन)।.


Methods

triangulate(arg) — एक को त्रिकोणित करें Mesh

एक नया लौटाएँ Mesh जिसमें प्रत्येक बहुभुज को त्रिकोणों में परिवर्तित किया गया है। मूल मेष में कोई परिवर्तन नहीं किया गया है। वर्टेक्स तत्व लेयर्स (नॉर्मल्स, UVs, रंग) को नए मेष में कॉपी किया जाता है।.

@staticmethod
def triangulate(mesh: Mesh) -> Mesh
SignatureDescription
triangulate(arg1, arg2, arg3, arg4)Union[None, 'Mesh', List[List[int]]]Triangulates polygon data and returns None, a Mesh, or a list of triangle index lists
process_node(node)Processes the given node to apply polygon modifications

Returns: 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

Returns: 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]]

वापसी: list[list[int]] — एक सूची [i, j, k] triplets, प्रत्येक एक आउटपुट triangle का प्रतिनिधित्व करता है।.

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) — वैकल्पिक नॉर्मल जेनरेशन के साथ बैच ट्रायएंगुलेट

Batch-triangulate एक बहुभुज इंडेक्स सूचियों की सूची को। वैकल्पिक रूप से प्रत्येक आउटपुट त्रिभुज के लिए फेस नॉर्मल्स की गणना करें और उन्हें जोड़ें 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]]

वापसी: 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

संबंधित देखें

 हिन्दी