Skip to content

Commit

Permalink
debug ajout d'un triangle unique en entrée
Browse files Browse the repository at this point in the history
  • Loading branch information
mwoussen committed Aug 8, 2023
1 parent 21880e5 commit b4e56cd
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 9 deletions.
8 changes: 2 additions & 6 deletions examples/quick_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,13 @@
print("--- START")

# one triangle as a geometric element
# we write our triangle in a CaribuScene format
organ_id = 1
triangle_vertices = [(0,0,0), (1,0,0), (1,1,1)]
triangle = {organ_id : [triangle_vertices]}
geometry = { "scenes" : [triangle] }
triangle_vertices = [(0.,0.,0.), (1.,0.,0.), (1.,1.,1.)]

# surfacic lighting with CARIBU
lighting = LightVegeManager(lightmodel="caribu")

# build the scene
lighting.build(geometry)
lighting.build(geometry=triangle_vertices)

# compute lighting
energy = 500
Expand Down
4 changes: 4 additions & 0 deletions src/lightvegemanager/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,10 @@ def build(self, geometry={}, global_scene_tesselate_level=0):
:type global_scene_tesselate_level: int, optional
:raises ValueError: Currently, converting voxels mesh to triangles mesh is not possible
"""
# pre-check of scenes input, if it has only one triangle or one list of triangles
if isatriangle(geometry) or all(isatriangle(s) for s in geometry):
geometry = {"scenes" : geometry}

self.__geometry = geometry

# First process of the scenes list, it gathers all triangulations
Expand Down
27 changes: 24 additions & 3 deletions tests/test_trianglesmesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,30 @@ def test_isatriangle():
assert not isatriangle(tr4)
assert not isatriangle(tr5)

# single triangle
tr = [(0., 0., 0.), (0., 1., 0.), (1., 1., 1.)]
expected1 = (
{0 : [tr] },
{0 : [0, 0]}
)

# list of triangles
triangles = [
[(0., 0., 0.), (0., 1., 0.), (1., 1., 1.)],
[(0., 0., 10.), (0., 1., 10.), (1., 1., 11.)],
[(0., 0., 20.), (0., 1., 20.), (1., 1., 21.)],
]
expected2 = (
{0 : triangles },
{0 : [0, 0]}
)

@pytest.mark.parametrize("test_input, expected", [(tr, expected1), (triangles, expected2)])
def test_chain_triangulations_simple(test_input, expected):
complete_trimesh, matching_ids, legume_grid, id_legume_scene = chain_triangulations(test_input)
assert complete_trimesh == expected[0]
assert matching_ids == expected[1]


def test_chain_triangulations():
# single triangle
Expand Down Expand Up @@ -218,9 +242,6 @@ def test_chain_triangulations():
for t in itertools.chain(*complete_trimesh.values()):
assert isatriangle(t)

test_chain_triangulations()


transformation_1 = {"scenes unit": {0: "m", 1: "dm"}}
expected_1 = {
0: [[(0.0, 0.0, 0.0), (0.0, 100.0, 0.0), (100.0, 100.0, 100.0)]],
Expand Down

0 comments on commit b4e56cd

Please sign in to comment.