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

IfcVoxelData explicit attribute definition seems incorrect #755

Open
iegorychev opened this issue Feb 21, 2024 · 3 comments
Open

IfcVoxelData explicit attribute definition seems incorrect #755

iegorychev opened this issue Feb 21, 2024 · 3 comments
Assignees
Labels
EXPRESS Issues or pull requests relating to EXPRESS schema

Comments

@iegorychev
Copy link
Collaborator

iegorychev commented Feb 21, 2024

ENTITY IfcIntegerVoxelData
 SUBTYPE OF (IfcVoxelData);
	Values : ARRAY [1:GridSize] OF IfcInteger;
	Unit : OPTIONAL IfcUnit;
 DERIVE
	GridSize : IfcInteger :=  SIZEOF(SELF\IfcProduct.Representation.Representations[1].Items[1]\IfcVoxelGrid.Voxels);
END_ENTITY;

Usage of DERIVED attribute GridSize seems incorrect here as in the moment of IfcIntegerVoxelData creation GridSize is UNSET and ARRAY can not be instantiated in terms of EXPRESS, ISO 10303 p.11 says:
8.2.1 Array data type
NOTE 1 The bounds may be positive, negative or zero, but may not be indeterminate (?) (see 14.2).

That's why probably all previous IFC schemas use approach with kind of attribute "duplication", as

ENTITY IfcRationalBSplineCurveWithKnots
 SUBTYPE OF (IfcBSplineCurveWithKnots);
	WeightsData : LIST [2:?] OF IfcReal;
 DERIVE
	Weights : ARRAY [0:UpperIndexOnControlPoints] OF IfcReal := IfcListToArray(WeightsData,0,SELF\IfcBSplineCurve.UpperIndexOnControlPoints);

which looks more correct.

@SergejMuhic SergejMuhic self-assigned this Feb 21, 2024
@SergejMuhic SergejMuhic added the EXPRESS Issues or pull requests relating to EXPRESS schema label Feb 21, 2024
@SergejMuhic
Copy link
Collaborator

Yes, that is correct. I can confirm that is not only an issue in EXPRESS but also in other languages (obviously 😄 ).

Same problem popped up I tried to compile the toolkit.

As proposed in a separate conversation, let's look at the updated proposal which I would post here once we aligned. After that I will create a PR with the amended code.

@SergejMuhic
Copy link
Collaborator

SergejMuhic commented Feb 22, 2024

My proposal would be the following:

  • adding a data attribute (ValueData) from which the array is derived
  • adding a function (IfcListToArrayOfSize) that fills the array
ENTITY IfcIntegerVoxelData
 SUBTYPE OF (IfcVoxelData);
	ValueData : LIST [1:?] OF IfcInteger;
	Unit : OPTIONAL IfcUnit;
 DERIVE
	GridSize : INTEGER := SIZEOF(SELF\IfcProduct.Representation.Representations[1].Items[1]\IfcVoxelGrid.Voxels);
	Values : ARRAY [1:GridSize] OF IfcInteger := IfcListToArrayOfSize(ValueData,1,SELF.GridSize,SELF\IfcProduct.Representation.Representations[1].Items[1]\IfcVoxelGrid.Voxels);
END_ENTITY;

FUNCTION IfcListToArrayOfSize
(Lis : LIST [0:?] OF GENERIC : T;
       Low, U : INTEGER;
	   Condition : LIST[Low:U] OF BOOLEAN) : ARRAY OF GENERIC : T;
   LOCAL
     LisIndex : INTEGER := 1;
     Res : ARRAY [Low:U] OF GENERIC : T;
   END_LOCAL;
      
   IF (SIZEOF(QUERY(item <* Condition | item)) <> SIZEOF(Lis)) THEN
     RETURN(?);
   END_IF;
	  
   Res := [Low : U];
   REPEAT i := 1 TO SIZEOF(Condition);
     IF (Condition[i]) THEN
       Res[i] := Lis[LisIndex];
	   LisIndex := LisIndex + 1;
	 END_IF;
   END_REPEAT;
   RETURN(Res);
END_FUNCTION;

@SergejMuhic
Copy link
Collaborator

@iegorychev this was completely reworked. If you want to have a look, there was a bunch of changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
EXPRESS Issues or pull requests relating to EXPRESS schema
Projects
Status: TODO
Development

No branches or pull requests

2 participants