From b78ccf1f9b69249d5f5f9c4c1e137f0f16ea49a7 Mon Sep 17 00:00:00 2001
From: ika <ika@opencascade.com>
Date: Wed, 3 Apr 2024 14:48:45 +0100
Subject: [PATCH] 0033661: Data Exchange, Step Import - Tessellated GDTs are
 not imported

Add processing of tessellated_annotation_occurrence.
Add test cases.
---
 src/STEPCAFControl/STEPCAFControl_Reader.cxx | 10 ++-
 tests/gdt/export/C2                          |  4 +-
 tests/gdt/import/A6                          | 92 ++++++++++++++++++++
 tests/gdt/presentation/C1                    | 10 ++-
 tests/gdt/presentation/C3                    | 16 ++++
 5 files changed, 124 insertions(+), 8 deletions(-)
 create mode 100644 tests/gdt/import/A6
 create mode 100644 tests/gdt/presentation/C3

diff --git a/src/STEPCAFControl/STEPCAFControl_Reader.cxx b/src/STEPCAFControl/STEPCAFControl_Reader.cxx
index 0dd16f6189..dd9eef42fb 100644
--- a/src/STEPCAFControl/STEPCAFControl_Reader.cxx
+++ b/src/STEPCAFControl/STEPCAFControl_Reader.cxx
@@ -2134,11 +2134,12 @@ Standard_Boolean readPMIPresentation(const Handle(Standard_Transient)& thePresen
     return Standard_False;
   }
   Handle(Transfer_TransientProcess) aTP = theTR->TransientProcess();
-  Handle(StepVisual_AnnotationOccurrence) anAO;
+  Handle(StepVisual_StyledItem) anAO;
   NCollection_Vector<Handle(StepVisual_StyledItem)> anAnnotations;
-  if (thePresentEntity->IsKind(STANDARD_TYPE(StepVisual_AnnotationOccurrence)))
+  if (thePresentEntity->IsKind(STANDARD_TYPE(StepVisual_AnnotationOccurrence)) ||
+      thePresentEntity->IsKind(STANDARD_TYPE(StepVisual_TessellatedAnnotationOccurrence)))
   {
-    anAO = Handle(StepVisual_AnnotationOccurrence)::DownCast(thePresentEntity);
+    anAO = Handle(StepVisual_StyledItem)::DownCast(thePresentEntity);
     if (!anAO.IsNull())
     {
       thePresentName = anAO->Name();
@@ -4368,7 +4369,8 @@ Standard_Boolean STEPCAFControl_Reader::ReadGDTs(const Handle(XSControl_WorkSess
       }
     }
     else if (anEnt->IsKind(STANDARD_TYPE(StepVisual_DraughtingCallout)) ||
-      anEnt->IsKind(STANDARD_TYPE(StepVisual_AnnotationOccurrence)))
+      anEnt->IsKind(STANDARD_TYPE(StepVisual_AnnotationOccurrence)) ||
+      anEnt->IsKind(STANDARD_TYPE(StepVisual_TessellatedAnnotationOccurrence)))
     {
       // Protection against import presentation twice
       Handle(StepVisual_DraughtingCallout) aDC;
diff --git a/tests/gdt/export/C2 b/tests/gdt/export/C2
index e36d4b657b..78145b8734 100644
--- a/tests/gdt/export/C2
+++ b/tests/gdt/export/C2
@@ -3,12 +3,12 @@ set filename bug29362_MMT200.stp
 
 set ref_data {
 
- NbOfDimensions          : 2
+ NbOfDimensions          : 4
   NbOfDimensionalSize    : 1
   NbOfDimensionalLocation: 1
   NbOfAngular            : 0
   NbOfWithPath           : 0
-  NbOfCommonLabels       : 0
+  NbOfCommonLabels       : 1
  NbOfTolerances          : 0
   NbOfGTWithModifiers    : 0
   NbOfGTWithMaxTolerance : 0
diff --git a/tests/gdt/import/A6 b/tests/gdt/import/A6
new file mode 100644
index 0000000000..eb971fde63
--- /dev/null
+++ b/tests/gdt/import/A6
@@ -0,0 +1,92 @@
+# !!!! This file is generated automatically, do not edit manually! See end script
+set filename bug33661_nist_ftc_08_asme1_ap242-e1-tg.stp
+
+set ref_data {
+
+ NbOfDimensions          : 60
+ NbOfTolerances          : 0
+ NbOfDatumFeature        : 0
+ NbOfAttachedDatum       : 0
+ NbOfDatumTarget         : 0
+
+ 0:1:1:2:1 Shape.4
+ 	 0:1:4:32 Dimension.4.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 0:1:1:2:2 Shape.5
+ 	 0:1:4:4 Dimension.5.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 	 0:1:4:5 Dimension.5.2 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 0:1:1:2:4 Shape.7
+ 	 0:1:4:14 Dimension.7.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 	 0:1:4:18 Dimension.7.2 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 	 0:1:4:20 Dimension.7.3 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 0:1:1:2:14 Shape.17
+ 	 0:1:4:27 Dimension.17.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 0:1:1:2:62 Shape.65
+ 	 0:1:4:35 Dimension.65.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 0:1:1:2:65 Shape.68
+ 	 0:1:4:36 Dimension.68.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 0:1:1:2:72 Shape.75
+ 	 0:1:4:53 Dimension.75.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 0:1:1:2:84 Shape.87
+ 	 0:1:4:54 Dimension.87.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 0:1:1:2:90 Shape.93
+ 	 0:1:4:31 Dimension.93.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 	 0:1:4:33 Dimension.93.2 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 	 0:1:4:34 Dimension.93.3 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 0:1:1:2:94 Shape.97
+ 	 0:1:4:39 Dimension.97.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 	 0:1:4:40 Dimension.97.2 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 	 0:1:4:51 Dimension.97.3 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 	 0:1:4:52 Dimension.97.4 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 	 0:1:4:55 Dimension.97.5 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 0:1:1:2:96 Shape.99
+ 	 0:1:4:43 Dimension.99.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 	 0:1:4:44 Dimension.99.2 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 	 0:1:4:45 Dimension.99.3 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 	 0:1:4:46 Dimension.99.4 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 	 0:1:4:57 Dimension.99.5 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 0:1:1:2:98 Shape.101
+ 	 0:1:4:47 Dimension.101.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 	 0:1:4:48 Dimension.101.2 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 	 0:1:4:49 Dimension.101.3 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 	 0:1:4:50 Dimension.101.4 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 	 0:1:4:56 Dimension.101.5 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 0:1:1:2:100 Shape.103
+ 	 0:1:4:37 Dimension.103.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 	 0:1:4:38 Dimension.103.2 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 	 0:1:4:41 Dimension.103.3 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 	 0:1:4:42 Dimension.103.4 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 	 0:1:4:58 Dimension.103.5 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 0:1:1:2:102 Shape.105
+ 	 0:1:4:25 Dimension.105.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 	 0:1:4:26 Dimension.105.2 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 0:1:1:2:116 Shape.119
+ 	 0:1:4:24 Dimension.119.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 0:1:1:2:120 Shape.123
+ 	 0:1:4:23 Dimension.123.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 0:1:1:2:161 Shape.164
+ 	 0:1:4:15 Dimension.164.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 0:1:1:2:179 Shape.182
+ 	 0:1:4:1 Dimension.182.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 	 0:1:4:2 Dimension.182.2 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 	 0:1:4:3 Dimension.182.3 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 0:1:1:2:237 Shape.240
+ 	 0:1:4:17 Dimension.240.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 	 0:1:4:19 Dimension.240.2 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 0:1:1:2:246 Shape.249
+ 	 0:1:4:6 Dimension.249.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 	 0:1:4:8 Dimension.249.2 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 	 0:1:4:9 Dimension.249.3 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 0:1:1:2:248 Shape.251
+ 	 0:1:4:7 Dimension.251.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 	 0:1:4:10 Dimension.251.2 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 	 0:1:4:11 Dimension.251.3 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 0:1:1:2:250 Shape.253
+ 	 0:1:4:12 Dimension.253.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 	 0:1:4:13 Dimension.253.2 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 0:1:1:2:256 Shape.259
+ 	 0:1:4:28 Dimension.259.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 	 0:1:4:29 Dimension.259.2 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 	 0:1:4:30 Dimension.259.3 ( N "DGT:Dimension" T 31, V 0, P 0 )
+ 0:1:1:3:1 Shape.276
+ 	 0:1:4:16 Dimension.276.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
+}
diff --git a/tests/gdt/presentation/C1 b/tests/gdt/presentation/C1
index 21a1799203..75d63af0c6 100644
--- a/tests/gdt/presentation/C1
+++ b/tests/gdt/presentation/C1
@@ -2,7 +2,13 @@
 set filename bug29362_MMT200.stp
 
 set ref_data {
-Centre of mass: 0 0 0
-Mass: 0
+Centre of mass: 13.412719368151439 6.1818909424750705 -13.415402720911091
+Mass: 252.25931515680639
+
+}
+
+set ref_data_write {
+Centre of mass: 13.412719368151233 6.1818909424748316 -13.415402720907935
+Mass: 252.25931515678892
 
 }
diff --git a/tests/gdt/presentation/C3 b/tests/gdt/presentation/C3
new file mode 100644
index 0000000000..98899400c2
--- /dev/null
+++ b/tests/gdt/presentation/C3
@@ -0,0 +1,16 @@
+# !!!! This file is generated automatically, do not edit manually! See end script
+puts "TODO CR11111 ALL: Error on writing file"
+
+set filename bug33661_nist_ftc_08_asme1_ap242-e1-tg.stp
+
+set ref_data {
+Centre of mass: -62.99891835601813 78.203476181663817 20.269103705327481
+Mass: 47784.542040997127
+
+}
+
+set ref_data_write {
+Centre of mass: -261.12759307366923 196.9986700086933 -13.86055926862322
+Mass: 17568.06377585962
+
+}