Skip to content

Commit

Permalink
add3
Browse files Browse the repository at this point in the history
  • Loading branch information
DimasfromLavoisier committed Nov 12, 2024
1 parent b2a5d1d commit abaf9fe
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 51 deletions.
15 changes: 8 additions & 7 deletions example_scripts/pysimulation_quick_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,20 @@ def callback(output=None):
simBuilder.setFullwaveNoise(False)
simBuilder.setPlatformNoiseDisabled(True)
simBuilder.setCallback(callback)
simBuilder.setExportToFile(False)
sim = simBuilder.build()

# Run the simulation
sim.start()

# Pause and resume simulation
sim.pause()
print('Simulation paused!')
time.sleep(2.5)
print('Resuming simulation ...')
time.sleep(0.5)
sim.resume()
print('Simulation resumed!')
#sim.pause()
# print('Simulation paused!')
#time.sleep(2.5)
# print('Resuming simulation ...')
#time.sleep(0.5)
# sim.resume()
# print('Simulation resumed!')

# Join simulation thread
output = sim.join()
Expand Down
2 changes: 1 addition & 1 deletion python/pyhelios/output_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def outputToList(output=None):
# Fill measurements
for meas in measurements:
pos = meas.position
ori = meas.beam_origin
ori = meas.beam_origin
dir = meas.beam_direction
lMeasurements.append([
pos[0], pos[1], pos[2],
Expand Down
2 changes: 1 addition & 1 deletion python/pyhelios/simulation_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __init__(
if copy:
return

self.sim = pyhelios.Simulation(
self.sim = pyhelios.PyheliosSimulation(
surveyPath,
assetsDir,
outputDir,
Expand Down
55 changes: 13 additions & 42 deletions tests/python/test_bindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ def tup_mul(v, scalar):
return (v[0] * scalar, v[1] * scalar, v[2] * scalar)

def test_aabb_instantiation():
aabb = _helios.AABB.create()
aabb = _helios.AABB()
assert aabb is not None, "Failed to create AABB instance"

def test_aabb_properties():
aabb = _helios.AABB.create()
aabb = _helios.AABB()
min_vertex = aabb.min_vertex
max_vertex = aabb.max_vertex
assert isinstance(min_vertex, _helios.Vertex), "min_vertex should be a Vertex instance"
Expand Down Expand Up @@ -59,8 +59,7 @@ def test_primitive_properties():
triangle = _helios.Triangle(v0, v1, v2)
assert triangle.scene_part is None, "scene_part should be None by default"
assert triangle.material is None, "material should be None by default"
assert isinstance(triangle.AABB, _helios.AABB), "AABB should be an AABB instance"
assert isinstance(triangle.centroid, tuple) and len(triangle.centroid) == 3, "centroid should be a 3-tuple"


def test_triangle_face_normal():
v0 = _helios.Vertex(0.0, 0.0, 0.0)
Expand Down Expand Up @@ -144,7 +143,7 @@ def test_primitive_num_vertices():
v1 = _helios.Vertex(1.0, 0.0, 0.0)
v2 = _helios.Vertex(0.0, 1.0, 0.0)
triangle = _helios.Triangle(v0, v1, v2)
num_vertices = triangle.num_vertices
num_vertices = len(triangle.vertices)
assert num_vertices == 3, "num_vertices should return 3"
#GLMDVEC3
def test_primitive_vertices():
Expand All @@ -162,14 +161,14 @@ def test_primitive_vertices():


def test_detailed_voxel_instantiation():
double_values = _helios.DoubleVector([0.1, 0.2, 0.3])
double_values = [0.1, 0.2, 0.3]
voxel = _helios.DetailedVoxel([1.0, 2.0, 3.0], 0.5, [1, 2], double_values)#[0.1, 0.2, 0.3])
assert isinstance(voxel, _helios.DetailedVoxel)
assert voxel.nb_echos == 1
assert voxel.nb_sampling == 2

def test_detailed_voxel_properties():
double_values = _helios.DoubleVector([0.1, 0.2, 0.3])
double_values = [0.1, 0.2, 0.3]
voxel = _helios.DetailedVoxel([1.0, 2.0, 3.0], 0.5, [1, 2], double_values)
voxel.nb_echos = 3
assert voxel.nb_echos == 3
Expand Down Expand Up @@ -310,34 +309,6 @@ def test_scanning_strip_methods():
assert strip.has(1)
assert not strip.has(2) # Not in the strip

''' Test `isLastLegInStrip`
boost python did not bind the 'wasProcessed' of the Leg class'''
# leg.wasProcessed = False
# assert not strip.isLastLegInStrip()

# leg.wasProcessed = True
# assert strip.isLastLegInStrip()


def test_simulation_cycle_callback():
def callback(args):
measurements, trajectories, outpath, outpaths, final = args # Unpack the tuple
assert all(isinstance(m, _helios.Measurement) for m in measurements)
assert all(isinstance(t, _helios.Trajectory) for t in trajectories)
assert outpath == "test_path"
assert all(isinstance(p, str) for p in outpaths)
assert final is False


sim_callback = _helios.SimulationCycleCallback(callback)

# Create mock data for measurements and trajectories
measurements = [_helios.Measurement() for _ in range(3)]
trajectories = [_helios.Trajectory() for _ in range(2)]
# Directly use Python lists
sim_callback(measurements, trajectories, "test_path")


def test_fwf_settings_instantiation():
# Test default constructor
fwf = _helios.FWFSettings()
Expand Down Expand Up @@ -508,8 +479,8 @@ def test_material_properties():
material.mat_file_path = "path/to/material.mat"
assert material.mat_file_path == "path/to/material.mat"

material.map_Kd = "path/to/mapKd.png"
assert material.map_Kd == "path/to/mapKd.png"
material.map_kd = "path/to/mapKd.png"
assert material.map_kd == "path/to/mapKd.png"

material.reflectance = 0.5
assert material.reflectance == 0.5
Expand All @@ -531,9 +502,9 @@ def test_material_properties():
kd_array = np.array([0, 0, 0, 0], dtype=np.float32)
ks_array = np.array([0, 0, 0, 0], dtype=np.float32)

assert np.array_equal(material.ka, ka_array)
assert np.array_equal(material.kd, kd_array)
assert np.array_equal(material.ks, ks_array)
assert np.array_equal(material.ambient_components, ka_array)
assert np.array_equal(material.diffuse_components, kd_array)
assert np.array_equal(material.specular_components, ks_array)


def test_survey_instantiation():
Expand Down Expand Up @@ -1491,11 +1462,11 @@ def test_calc_time_propagation(self, scanner):


def test_simulation_initialization():
sim = _helios.Simulation()
sim = _helios.PyheliosSimulation()
assert sim is not None

def test_simulation_initialization_with_params():
sim = _helios.Simulation(
sim = _helios.PyheliosSimulation(
"surveyPath",
("assetsPath1", "assetsPath2"),
"outputPath",
Expand Down

0 comments on commit abaf9fe

Please sign in to comment.