Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions tools/RegressionSceneData.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ def default(self, obj):
return obj.tolist()
return JSONEncoder.default(self, obj)


def is_mapped(node):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for the record, your test is based on an implicit rule that a mapped state is in the same Node than the mapping. But that's not mandatory...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I guess there is no way from the MechanicalObject to know if it is mapped?
This means we should process all MechancalMapping first?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, anyway, this is mostly to match the old regression behavior. For me we should test all mechanicalObject, mapped or not.

mapping = node.getMechanicalMapping()

return mapping != None
# no mapping in this node context



class RegressionSceneData:
def __init__(self, file_scene_path: str = None, file_ref_path: str = None, steps = 1000,
Expand All @@ -77,7 +85,7 @@ def __init__(self, file_scene_path: str = None, file_ref_path: str = None, steps
self.file_ref_path = file_ref_path
self.steps = int(steps)
self.epsilon = float(epsilon)
self.meca_in_mapping = meca_in_mapping
self.meca_in_mapping = bool(meca_in_mapping)
self.dump_number_step = int(dump_number_step)
self.meca_objs = []
self.filenames = []
Expand Down Expand Up @@ -114,14 +122,18 @@ def print_meca_objs(self):


def parse_node(self, node, level = 0):
# first check current node
mstate = node.getMechanicalState()
if mstate and is_simulated(node):
if self.meca_in_mapping is True or is_mapped(node) is False:
self.meca_objs.append(mstate)
if self.verbose:
print(" " * level + f"- Adding MechanicalObject: {mstate.name.value} from Node: {node.name.value}")

# recursively check children
for child in node.children:
mstate = child.getMechanicalState()
if mstate:
if is_simulated(child):
self.meca_objs.append(mstate)

self.parse_node(child, level + 1)


def add_compare_state(self):
counter = 0
Expand Down
6 changes: 5 additions & 1 deletion tools/RegressionSceneList.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,12 @@ def process_file(self):
full_file_path = os.path.join(self.file_dir, values[0])
full_ref_file_path = os.path.join(self.ref_dir_path, values[0])

meca_in_mapping = False
if values[3] == '1': # converting string to Bool always gives True
meca_in_mapping = True

scene_data = RegressionSceneData.RegressionSceneData(full_file_path, full_ref_file_path,
values[1], values[2], values[3], values[4],
values[1], values[2], meca_in_mapping, values[4],
self.disable_progress_bar, self.verbose)

#scene_data.printInfo()
Expand Down