AECgeeks / infra-repo-issue-test-2

0 stars 0 forks source link

jwg12 IfcGetBasisSurface #6

Open aothms opened 2 years ago

aothms commented 2 years ago

Changes where required to accomodate IfcSegment changes (affecting IfcCompositiveCurveOnSurface)

aothms commented 2 years ago
--- tmp/a/IFC.exp   2022-08-26 22:32:18.631600600 +0200
+++ tmp/b/IFC.exp   2022-09-05 20:18:03.017322700 +0200
@@ -13065,24 +13065,36 @@
       REPEAT i := 1 TO N;
       Surfs := Surfs + IfcAssociatedSurface(C\IfcSurfaceCurve.AssociatedGeometry[i]);
       END_REPEAT;
     END_IF;
   END_IF;
   IF 'IFC4X3_DEV.IFCCOMPOSITECURVEONSURFACE' IN TYPEOF (C) THEN

     (* For an IfcCompositeCurveOnSurface the BasisSurface is the intersection of the BasisSurface of all the segments. *)

     N := SIZEOF(C\IfcCompositeCurve.Segments);
-    Surfs := IfcGetBasisSurface(C\IfcCompositeCurve.Segments[1].ParentCurve);
+    
+    IF ('IFC4X3_DEV.IFCCURVESEGMENT' IN TYPEOF(Segment)) THEN
+      Surfs := IfcGetBasisSurface(C\IfcCompositeCurve.Segments[1]\IfcCurveSegment.ParentCurve);
+    END_IF;
+    IF ('IFC4X3_DEV.IFCCOMPOSITECURVESEGMENT' IN TYPEOF(Segment)) THEN
+      Surfs := IfcGetBasisSurface(C\IfcCompositeCurve.Segments[1]\IfcCompositeCurveSegment.ParentCurve);
+    END_IF;
+    
     IF N > 1 THEN
       REPEAT i := 2 TO N;
-        Surfs := Surfs * IfcGetBasisSurface(C\IfcCompositeCurve.Segments[1].ParentCurve);
+        IF ('IFC4X3_DEV.IFCCURVESEGMENT' IN TYPEOF(Segment)) THEN
+          Surfs := Surfs * IfcGetBasisSurface(C\IfcCompositeCurve.Segments[i]\IfcCurveSegment.ParentCurve);
+        END_IF;
+        IF ('IFC4X3_DEV.IFCCOMPOSITECURVESEGMENT' IN TYPEOF(Segment)) THEN
+          Surfs := Surfs * IfcGetBasisSurface(C\IfcCompositeCurve.Segments[i]\IfcCompositeCurveSegment.ParentCurve);
+        END_IF;
       END_REPEAT;
     END_IF;
   END_IF;
   RETURN(Surfs);

 END_FUNCTION;

 FUNCTION IfcListToArray
 (Lis : LIST [0:?] OF GENERIC : T;
        Low,U : INTEGER) : ARRAY OF GENERIC : T;
SergejMuhic commented 2 years ago

This is not going to work. Segment is undefined.

aothms commented 2 years ago

Correct. Substituting one copy-pasta error for the other. How about:

(C : IfcCurveOnSurface) : SET[0:2] OF IfcSurface;

  LOCAL
    Surfs : SET[0:2] OF IfcSurface;
    N : INTEGER;
  END_LOCAL;

  Surfs := [];
  IF 'IFCGEOMETRYRESOURCE.IFCPCURVE' IN TYPEOF (C) THEN
    Surfs := [C\IfcPCurve.BasisSurface];
  ELSE
    IF 'IFCGEOMETRYRESOURCE.IFCSURFACECURVE' IN TYPEOF (C) THEN
      N := SIZEOF(C\IfcSurfaceCurve.AssociatedGeometry);
      REPEAT i := 1 TO N;
      Surfs := Surfs + IfcAssociatedSurface(C\IfcSurfaceCurve.AssociatedGeometry[i]);
      END_REPEAT;
    END_IF;
  END_IF;
  IF 'IFCGEOMETRYRESOURCE.IFCCOMPOSITECURVEONSURFACE' IN TYPEOF (C) THEN

    (* For an IfcCompositeCurveOnSurface the BasisSurface is the intersection of the BasisSurface of all the segments. *)

    N := SIZEOF(C\IfcCompositeCurve.Segments);

    IF ('IFC4X3.IFCCURVESEGMENT' IN TYPEOF(C\IfcCompositeCurve.Segments[1])) THEN
      Surfs := IfcGetBasisSurface(C\IfcCompositeCurve.Segments[1]\IfcCurveSegment.ParentCurve);
    END_IF;
    IF ('IFC4X3.IFCCOMPOSITECURVESEGMENT' IN TYPEOF(C\IfcCompositeCurve.Segments[1])) THEN
      Surfs := IfcGetBasisSurface(C\IfcCompositeCurve.Segments[1]\IfcCompositeCurveSegment.ParentCurve);
    END_IF;

    IF N > 1 THEN
      REPEAT i := 2 TO N;       
        IF ('IFC4X3.IFCCURVESEGMENT' IN TYPEOF(C\IfcCompositeCurve.Segments[i])) THEN
          Surfs := Surfs * IfcGetBasisSurface(C\IfcCompositeCurve.Segments[i]\IfcCurveSegment.ParentCurve);
        END_IF;
        IF ('IFC4X3.IFCCOMPOSITECURVESEGMENT' IN TYPEOF(C\IfcCompositeCurve.Segments[i])) THEN
          Surfs := Surfs * IfcGetBasisSurface(C\IfcCompositeCurve.Segments[i]\IfcCompositeCurveSegment.ParentCurve);
        END_IF;
      END_REPEAT;
    END_IF;
  END_IF;
  RETURN(Surfs);

END_FUNCTION

Edit: don't mind the IFCGEOMETRYRESOURCE, it's stored like that, but not written out to exp.