dymokomi/luce-cad
Source of release 0.9.3
0.9.3 / tests / regressions / nurbs_tests.luc
## Rectangular trims of a model's B-spline patches, and planar patches that
## are not planar refused (evaluation itself: contracts/nurbs_contract).
from luce_cad.model import CadModel
from luce_geocore.geocore import Vector3
from checks import near
pub func nurbs_tests() -> unit!:
let cad = CadModel()
cad.add_nurbs([Vector3(), Vector3(0.0, 0.0, 2.0), Vector3(2.0, 0.0, 0.0), Vector3(2.0, 0.0, 2.0)], [1.0, 1.0, 1.0, 1.0], 2, 2, 1, 1, [0.0, 0.0, 1.0, 1.0], [0.0, 0.0, 1.0, 1.0])
cad.trim_rectangle(0, 0.25, 0.75, 0.0, 0.5)
let trimmed = cad.tessellate(2)
assert(cad.face_count() == 1 and trimmed.face_count() == 4)
near(trimmed.bounds().minimum.x, 0.5)
near(trimmed.bounds().maximum.x, 1.5)
near(trimmed.bounds().maximum.z, 1.0)
assert(cad.tessellate(4).face_count() == 16 and cad.face_count() == 1)
var bad_trim = false
cad.trim_rectangle(0, -0.1, 0.75, 0.0, 0.5) catch failure:
bad_trim = true
assert(bad_trim)
near(cad.tessellate(2).bounds().minimum.x, 0.5)
var nonplanar = false
cad.add_planar([Vector3(), Vector3(1.0, 0.0, 0.0), Vector3(1.0, 1.0, 1.0), Vector3(0.0, 1.0, 0.0)]) catch failure:
nonplanar = true
assert(nonplanar and cad.face_count() == 1)
print("PASS rectangular trims and planar rejection")