Skip to content

Commit

Permalink
Handle missing IfcRelationship
Browse files Browse the repository at this point in the history
eg. if all sofas are deleted the IfcRelDefinesByType is deleted too, but
we reincarnate as an empty list so it can be merged.
  • Loading branch information
brunopostle committed Jan 26, 2025
1 parent 9f63603 commit b255eb6
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions ifcmerge
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,19 @@ for my $id ($local->deleted_ids)
{
if (defined $remote->{modified}->{$id})
{
push @errors, "$ARGV[1] deleted entity #$id modified in $ARGV[2]!";
my ($remote_class) = $remote->class_attributes($id);
if ($remote_class =~ /^IfcRel/i)
{
# IfcRelationship may be deleted overzealously, reinsert empty
$local->{file}->{$id} = $remote->{file}->{$id};
$local->{file}->{$id} =~ s/\([0-9#,]+\)/\(\)/;
delete $local->{deleted}->{$id};
$local->{modified}->{$id} = 1;
}
else
{
push @errors, "$ARGV[1] deleted entity #$id modified in $ARGV[2]!";
}
}
else
{
Expand All @@ -84,7 +96,19 @@ for my $id ($remote->deleted_ids)
{
if (defined $local->{modified}->{$id})
{
push @errors, "$ARGV[2] deleted entity #$id modified in $ARGV[1]!";
my ($local_class) = $local->class_attributes($id);
if ($local_class =~ /^IfcRel/i)
{
# IfcRelationship may be deleted overzealously, reinsert empty
$remote->{file}->{$id} = $local->{file}->{$id};
$remote->{file}->{$id} =~ s/\([0-9#,]+\)/\(\)/;
delete $remote->{deleted}->{$id};
$remote->{modified}->{$id} = 1;
}
else
{
push @errors, "$ARGV[2] deleted entity #$id modified in $ARGV[1]!";
}
}
else
{
Expand Down

0 comments on commit b255eb6

Please sign in to comment.