Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IVS-368 reverse depth #343

Open
wants to merge 2 commits into
base: development
Choose a base branch
from
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
12 changes: 7 additions & 5 deletions features/steps/validation_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def handle_then(context, fn, **kwargs):
)
)

def map_then_state(items, fn, context, current_path=[], depth=0, **kwargs):
def map_then_state(items, fn, context, current_path=[], depth=0, current_depth=0, **kwargs):
def apply_then_operation(fn, inst, context, current_path, depth=0, **kwargs):
if inst is None:
return
Expand Down Expand Up @@ -277,13 +277,15 @@ def should_apply(items, depth):
else:
return is_nested(items) and all(should_apply(v, depth-1) for v in items if v is not None)

# debugging:
print(' '*current_depth,current_depth,':',items)

if context.is_global_rule:
return apply_then_operation(fn, [items], context, current_path=None, **kwargs)
elif should_apply(items, depth):
elif depth == current_depth:
return apply_then_operation(fn, items, context, current_path, **kwargs)
elif is_nested(items):
new_depth = depth if depth > 0 else 0
return type(items)(map_then_state(v, fn, context, current_path + [i], new_depth, **kwargs) for i, v in enumerate(items))
elif depth > current_depth:
return type(items)(map_then_state(v, fn, context, current_path + [i], depth, current_depth + 1, **kwargs) for i, v in enumerate(items))
else:
return apply_then_operation(fn, items, context, current_path = None, **kwargs)

Expand Down
33 changes: 33 additions & 0 deletions test/files/gem003/pass-gem003-no-representations.ifc
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
ISO-10303-21;
HEADER;
FILE_DESCRIPTION(('ViewDefinition [CoordinationView]'),'2;1');
FILE_NAME('','2022-12-15T18:14:41',(''),(''),'IfcOpenShell-v0.7.0-fa6bbf2d','IfcOpenShell-v0.7.0-fa6bbf2d','');
FILE_SCHEMA(('IFC2X3'));
ENDSEC;
DATA;
#1=IFCPERSON($,$,'',$,$,$,$,$);
#2=IFCORGANIZATION($,'',$,$,$);
#3=IFCPERSONANDORGANIZATION(#1,#2,$);
#4=IFCAPPLICATION(#2,'v0.7.0-fa6bbf2d','IfcOpenShell-v0.7.0-fa6bbf2d','');
#5=IFCOWNERHISTORY(#3,#4,$,.ADDED.,$,#3,#4,1671128081);
#6=IFCDIRECTION((1.,0.,0.));
#7=IFCDIRECTION((0.,0.,1.));
#8=IFCCARTESIANPOINT((0.,0.,0.));
#9=IFCAXIS2PLACEMENT3D(#8,#7,#6);
#10=IFCDIRECTION((0.,1.,0.));
#11=IFCGEOMETRICREPRESENTATIONCONTEXT($,'Model',3,1.E-05,#9,#10);
#12=IFCDIMENSIONALEXPONENTS(0,0,0,0,0,0,0);
#13=IFCSIUNIT(*,.LENGTHUNIT.,$,.METRE.);
#14=IFCSIUNIT(*,.AREAUNIT.,$,.SQUARE_METRE.);
#15=IFCSIUNIT(*,.VOLUMEUNIT.,$,.CUBIC_METRE.);
#16=IFCSIUNIT(*,.PLANEANGLEUNIT.,$,.RADIAN.);
#17=IFCMEASUREWITHUNIT(IFCPLANEANGLEMEASURE(0.017453292519943295),#16);
#18=IFCCONVERSIONBASEDUNIT(#12,.PLANEANGLEUNIT.,'DEGREE',#17);
#19=IFCUNITASSIGNMENT((#13,#14,#15,#18));
#20=IFCPROJECT('0M3CJS3Jr8g9o2tE2hIZwd',#5,'',$,$,$,$,(#11),#19);
#21=IFCSITE('3BMYxcNaTCZ9FZsYwmeBiO',#5,$,$,$,$,$,$,$,$,$,$,$,$);
#22=IFCBUILDING('1lvrVAw69FkAt63ZT8LNn_',#5,$,$,$,$,$,$,$,$,$,$);
#23=IFCRELAGGREGATES('3bGLQpDg9598wi1bbeSo9n',#5,$,$,#21,(#22));
#43=IFCWALL('2OJum5pDz65wCA5MjRtX8E',#5,'Wall','An awesome wall',$,$,$,$);
ENDSEC;
END-ISO-10303-21;
Loading