| 16 | |
| 17 | |
| 18 | def test_aligned_text_mesh(): |
| 19 | sphere = mrmesh.makeSphere(mrmesh.SphereParams()) |
| 20 | params = mrmesh.TextAlignParams() |
| 21 | # find representatice point on mesh |
| 22 | params.startPoint = mrmesh.findProjection(mrmesh.Vector3f(0, 0, 1), sphere).mtp |
| 23 | params.direction = mrmesh.Vector3f(1, 0, 0) |
| 24 | params.text = "Hello World" |
| 25 | params.fontHeight = 0.02 |
| 26 | params.pathToFontFile = os.path.join( |
| 27 | os.path.dirname(os.path.abspath(__file__)), |
| 28 | "../thirdparty/Noto_Sans/NotoSans-Regular.ttf", |
| 29 | ) |
| 30 | # how deep to engrave |
| 31 | params.surfaceOffset = 0.1 |
| 32 | alignedMesh = mrmesh.alignTextToMesh(sphere, params) |
| 33 | booleanRes = mrmesh.boolean( |
| 34 | sphere, alignedMesh, mrmesh.BooleanOperation.Intersection |
| 35 | ) |
| 36 | assert booleanRes.valid(), booleanRes.errorString |
| 37 | gravedPart = booleanRes.mesh |
| 38 | volume = gravedPart.volume() |
| 39 | assert volume > 0 |
| 40 | assert volume < alignedMesh.volume() |