File: mesh_component.py

package info (click to toggle)
camitk 6.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 389,508 kB
  • sloc: cpp: 103,476; sh: 2,448; python: 1,618; xml: 984; makefile: 128; perl: 84; sed: 20
file content (23 lines) | stat: -rw-r--r-- 1,131 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#
# Script designed to be tested from inside the CamiTK Python interpreter using PythonManager::runScript
# See TestPythonScript.cpp
# 
# The requirements (if any) must defined in the the QRC file
#
import camitk
import numpy

camitk.Application.open(camitk.Core.getTestDataDir() + "/bassin.msh") 
# FIXME with (camitk.Core.getTestDataDir() + "bassin.msh") (no / before bassin.msh) should generate an error and create no top level... Instead it seems it is creating something called testdatabassin → did it opened a directory?
assert len(camitk.Application.getTopLevelComponents()) == 1

mesh = camitk.Application.getTopLevelComponents()[0]
assert mesh.getName() == "bassin"

points = mesh.getPointSetAsNumpy()
actual_barycenter = numpy.mean(points, axis=0)
expected_barycenter = numpy.array([1.8276852, -20.284256, 167.19714], dtype='f')
# same as assert np.array_equal(expected,barycenter)
assert numpy.all(actual_barycenter == expected_barycenter), f"Barycenter should be {expected_barycenter} not {actual_barycenter}"

assert camitk.Application.closeAll(), f"Close all should return true as no components have been modified"