Luce packages
LuceLuce BaseLuciaOS

dymokomi/luced-3d

Source of release 0.11.6

0.11.6 / tests / editor / import_tests.luc

## The File node imports through the format packages, reloads and undoes.
## The formats' own decoding tests live in luce-obj, luce-step and luce-fbx.
from geometry_tests import near
from workspace import Workspace
from network import Network
import node_commands

pub func import_tests() -> unit!:
    let w = Workspace()
    node_commands.add_node(w, "File", 0.0, 0.0)
    node_commands.set_text(w, 0, "tests/fixtures/triangle.obj")
    assert((w.geometry else trap("file geometry")).point_count() == 3)
    let node = w.selected() else trap("file node")
    let evaluations = node.evaluations
    node_commands.reload_file(w)
    assert(node.evaluations == evaluations + 1)
    node_commands.add_node(w, "Transform", 0.0, 100.0)
    node_commands.set_parameter(w, 7, 2.0)
    near((w.geometry else trap("scaled file")).bounds().maximum.x, 2.0)
    w.undo()
    near((w.geometry else trap("undo import scale")).bounds().maximum.x, 1.0)
    # A STEP face no mesher can follow (a corner off its plane) is left out
    # of the tessellation, which names it; the square beside it meshes.
    let graph = Network(false)
    let file = graph.add("File", 0.0, 0.0)
    file.texts[0] = "tests/fixtures/step_skip.step"
    let meshed = graph.evaluate_data(file.id).tessellated(8)
    assert(meshed.warning.starts_with("Skipped CAD face 1: "))
    assert((meshed.mesh else trap("tessellated square")).face_count() >= 1)
    print("PASS File node import, reload and undo; a STEP face no mesher follows is named")