]> OCCT Git - occt-copy.git/commitdiff
0027975: Data Exchange - Add possibility to connect DGTs to vertices.
authorika <ika@opencascade.com>
Tue, 18 Oct 2016 10:24:29 +0000 (13:24 +0300)
committerapn <apn@opencascade.com>
Thu, 3 Nov 2016 11:15:34 +0000 (14:15 +0300)
Implement new function to find Product_Definition_Shape entity.
Modify Reader to add possibility of import DGTs, connected to some geometry items.
Update test cases.

src/STEPCAFControl/STEPCAFControl_Reader.cxx
src/STEPCAFControl/STEPCAFControl_Writer.cxx
tests/gdt/export/A6
tests/gdt/export/A7
tests/gdt/export/A8
tests/gdt/export/B4
tests/gdt/presentation/A6
tests/gdt/presentation/A7
tests/gdt/presentation/B3

index e524631439afffdc537ab088eee21f972cb4b187..99665f2834a1c1605a9fc6865497bb564f1dc6e9 100644 (file)
@@ -2224,6 +2224,31 @@ static Standard_Boolean ReadDatums(const Handle(XCAFDoc_ShapeTool) &STool,
   return Standard_True;
 }
 
+//=======================================================================
+//function : FindShapeIndexForDGT
+//purpose  : auxiliary find shape index in map og imported shapes
+//=======================================================================
+static Standard_Integer FindShapeIndexForDGT(const Handle(Standard_Transient)& theEnt,
+  const Handle(XSControl_WorkSession)& theWS)
+{
+  const Handle(Transfer_TransientProcess) &aTP = theWS->TransferReader()->TransientProcess();
+  // try to find index of given entity
+  Standard_Integer anIndex = aTP->MapIndex(theEnt);
+  if (anIndex > 0)
+    return anIndex;
+  // if theEnt is a geometry item try to find its topological item
+  const Interface_Graph& aGraph = aTP->Graph();
+  Interface_EntityIterator anIter = aGraph.Sharings(theEnt);
+  for (anIter.Start(); anIter.More(); anIter.Next()) {
+    if (anIter.Value()->IsKind(STANDARD_TYPE(StepShape_TopologicalRepresentationItem)))
+    {
+      anIndex = aTP->MapIndex(anIter.Value());
+      if (anIndex > 0)
+        return anIndex;
+    }
+  }
+  return 0;
+}
 
 //=======================================================================
 //function : setDatumToXCAF
@@ -2306,7 +2331,7 @@ static Standard_Boolean setDatumToXCAF(const Handle(StepDimTol_Datum)& theDat,
       aRI = aPGISU->IdentifiedItemValue(i);
     }
     if(aRI.IsNull()) continue;
-    Standard_Integer index = aTP->MapIndex(aRI);
+    Standard_Integer index = FindShapeIndexForDGT(aRI, theWS);
     TopoDS_Shape aSh;
     if(index >0) {
       Handle(Transfer_Binder) binder = aTP->MapItem(index);
@@ -2362,7 +2387,7 @@ static Standard_Boolean setDatumToXCAF(const Handle(StepDimTol_Datum)& theDat,
                   anItem = aPGISU->IdentifiedItemValue(1);
                 }
                 if(anItem.IsNull()) continue;
-                Standard_Integer anItemIndex = aTP->MapIndex(anItem);
+                Standard_Integer anItemIndex = FindShapeIndexForDGT(anItem, theWS);
                 if(anItemIndex >0) {
                   Handle(Transfer_Binder) binder = aTP->MapItem(anItemIndex);
                   TopoDS_Shape anItemShape = TransferBRep::ShapeResult(binder);
@@ -2658,6 +2683,7 @@ static void collectShapeAspect(const Handle(StepRepr_ShapeAspect)& theSA,
   }
 }
 
+
 //=======================================================================
 //function : createGeomTolObjectInXCAF
 //purpose  : 
@@ -2991,7 +3017,7 @@ static TDF_Label createGDTObjectInXCAF(const Handle(Standard_Transient)& theEnt,
   // Collect shapes
   for(Standard_Integer i = aSeqRI1.Lower(); i <= aSeqRI1.Upper() ;i++)
   {
-    Standard_Integer anIndex = aTP->MapIndex(aSeqRI1.Value(i));
+    Standard_Integer anIndex = FindShapeIndexForDGT(aSeqRI1.Value(i), theWS);
     TopoDS_Shape aSh;
     if(anIndex >0) {
       Handle(Transfer_Binder) aBinder = aTP->MapItem(anIndex);
@@ -3009,7 +3035,7 @@ static TDF_Label createGDTObjectInXCAF(const Handle(Standard_Transient)& theEnt,
     //for dimensional location
     for(Standard_Integer i = aSeqRI2.Lower(); i <= aSeqRI2.Upper() ;i++)
     {
-      Standard_Integer anIndex = aTP->MapIndex(aSeqRI2.Value(i));
+      Standard_Integer anIndex = FindShapeIndexForDGT(aSeqRI2.Value(i), theWS);
       TopoDS_Shape aSh;
       if(anIndex >0) {
         Handle(Transfer_Binder) aBinder = aTP->MapItem(anIndex);
@@ -3412,7 +3438,7 @@ static void setDimObjectToXCAF(const Handle(Standard_Transient)& theEnt,
         for(anIterGRI.Start(); anIterGRI.More() && aPGISU.IsNull(); anIterGRI.Next()) {
           aPRI = Handle(StepRepr_RepresentationItem)::DownCast(anIterGRI.Value());
         }
-        Standard_Integer anIndex = aTP->MapIndex(aPRI);
+        Standard_Integer anIndex = FindShapeIndexForDGT(aPRI, theWS);
         TopoDS_Edge aSh;
         if(anIndex >0) {
           Handle(Transfer_Binder) aBinder = aTP->MapItem(anIndex);
index f8e85130c7bea2a647ae0c1ac2183ecc0e573e43..b5b4f3e447a44ce01767eebf5b0e1f5b46acf3ad 100644 (file)
@@ -2112,11 +2112,56 @@ static Standard_Boolean FindPDSforDGT(const Interface_Graph &aGraph,
   return Standard_True;
 }
 
+//=======================================================================
+//function : FindPDS
+//purpose  : auxilary: find Product_definition_shape entity for given entity
+//=======================================================================
+static Handle(StepRepr_ProductDefinitionShape) FindPDS(const Interface_Graph &theGraph,
+                                                       const Handle(Standard_Transient) &theEnt,
+                                                       Handle(StepRepr_RepresentationContext) &theRC)
+{
+  if (theEnt.IsNull())
+    return NULL;
+  Handle(StepRepr_ProductDefinitionShape) aPDS;
+
+  // try to find shape_representation in sharings
+  Interface_EntityIterator anIter = theGraph.Sharings(theEnt);
+  for (anIter.Start(); anIter.More() && aPDS.IsNull(); anIter.Next()) {
+    Handle(StepShape_ShapeRepresentation) aSR = Handle(StepShape_ShapeRepresentation)::DownCast(anIter.Value());
+    if (aSR.IsNull())
+      continue;
+    theRC = aSR->ContextOfItems();
+    Interface_EntityIterator aSDRIt = theGraph.Sharings(aSR);
+    for (aSDRIt.Start(); aSDRIt.More() && aPDS.IsNull(); aSDRIt.Next()) {
+      Handle(StepShape_ShapeDefinitionRepresentation) aSDR =
+        Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(aSDRIt.Value());
+      if (aSDR.IsNull()) continue;
+      Handle(StepRepr_PropertyDefinition) aPropD = aSDR->Definition().PropertyDefinition();
+      if (aPropD.IsNull()) continue;
+      aPDS = Handle(StepRepr_ProductDefinitionShape)::DownCast(aPropD);
+    }
+  }
+  if (!aPDS.IsNull())
+    return aPDS;
+
+  anIter = theGraph.Sharings(theEnt);
+  for (anIter.Start(); anIter.More(); anIter.Next()) {
+    if (anIter.Value()->IsKind(STANDARD_TYPE(StepShape_TopologicalRepresentationItem)) ||
+      anIter.Value()->IsKind(STANDARD_TYPE(StepGeom_GeometricRepresentationItem)))
+    {
+      aPDS = FindPDS(theGraph, anIter.Value(), theRC);
+      if (!aPDS.IsNull())
+        return aPDS;
+    }
+  }
+
+  return aPDS;
+}
+
 //=======================================================================
 //function : GetUnit
 //purpose  : auxiliary
 //=======================================================================
-
 static StepBasic_Unit GetUnit(const Handle(StepRepr_RepresentationContext)& theRC,
                               const Standard_Boolean isAngle = Standard_False)
 {
@@ -2264,9 +2309,7 @@ static Handle(StepRepr_ShapeAspect) WriteShapeAspect (const Handle(XSControl_Wor
   Handle(StepRepr_ProductDefinitionShape) aPDS;
   Handle(StepRepr_RepresentationContext) aRC;
   Handle(Standard_Transient) anEnt = aSeqRI.Value(1);
-  Handle(StepShape_AdvancedFace) anAF;
-  Handle(StepShape_EdgeCurve) anEC;
-  FindPDSforDGT(aGraph, anEnt, aPDS, aRC, anAF, anEC);
+  aPDS = FindPDS(aGraph, anEnt, aRC);
   if(aPDS.IsNull()) 
     return NULL;
 
@@ -2335,7 +2378,8 @@ static void WritePresentation(const Handle(XSControl_WorkSession) &WS,
   Handle(StepVisual_HArray1OfDraughtingCalloutElement) aTAOs = new StepVisual_HArray1OfDraughtingCalloutElement(1, 1);
   aTAOs->SetValue(1, aDCElement);
   Handle(StepVisual_DraughtingCallout) aDCallout = new StepVisual_DraughtingCallout();
-  aDCallout->Init(thePrsName, aTAOs);
+  Handle(TCollection_HAsciiString) aPrsName = thePrsName.IsNull() ? new TCollection_HAsciiString() : thePrsName;
+  aDCallout->Init(aPrsName, aTAOs);
   Handle(StepRepr_HArray1OfRepresentationItem) aDCsForDMIA = new StepRepr_HArray1OfRepresentationItem(1, 1);
   aDCsForDMIA->SetValue(1, aDCallout);
   StepAP242_ItemIdentifiedRepresentationUsageDefinition aDimension;
@@ -2405,7 +2449,8 @@ static void WritePresentation(const Handle(XSControl_WorkSession) &WS,
   Handle(StepVisual_HArray1OfDraughtingCalloutElement) aTAOs = new StepVisual_HArray1OfDraughtingCalloutElement(1, 1);
   aTAOs->SetValue(1, aDCElement);
   Handle(StepVisual_DraughtingCallout) aDCallout = new StepVisual_DraughtingCallout();
-  aDCallout->Init(thePrsName, aTAOs);
+  Handle(TCollection_HAsciiString) aPrsName = thePrsName.IsNull() ? new TCollection_HAsciiString() : thePrsName;
+  aDCallout->Init(aPrsName, aTAOs);
   aModel->AddWithRefs(aDCallout);
 
   // Annotation plane
@@ -2464,8 +2509,6 @@ static Handle(StepDimTol_Datum) WriteDatumAP242(const Handle(XSControl_WorkSessi
   Handle(StepRepr_ProductDefinitionShape) aPDS;
   Handle(StepRepr_RepresentationContext) aRC;
   Handle(Standard_Transient) anEnt;
-  Handle(StepShape_AdvancedFace) anAF;
-  Handle(StepShape_EdgeCurve) anEC;
   TopoDS_Shape aShape;
   TopLoc_Location aLoc;
   TColStd_SequenceOfTransient aSeqRI;
@@ -2477,7 +2520,7 @@ static Handle(StepDimTol_Datum) WriteDatumAP242(const Handle(XSControl_WorkSessi
     return NULL;
   }
   anEnt = aSeqRI.Value(1);
-  FindPDSforDGT(aGraph, anEnt, aPDS, aRC, anAF, anEC);
+  aPDS = FindPDS(aGraph, anEnt, aRC);
   if (aPDS.IsNull()) 
     return NULL;
 
index ca6b320bf4c1b1f5141827611888d582fd07a42a..7aac1c57d4dad74b817441c0afa013e85fc47652 100644 (file)
@@ -1,6 +1,6 @@
 # !!!! This file is generated automatically, do not edit manually! See end script
 set filename bug27645_nist_ftc_06_asme1_cr3000_rd.prt.stp
-puts "TODO CR26859 ALL:Error : 3 differences with reference data found :"
+puts "TODO CR26859 ALL:Error : 1 differences with reference data found :"
 puts "TODO CR26859 ALL:Error on writing file"
 
 set ref_data {
index 53a48fd0ee34548d690d5859559d20e626eb9ce4..142e6baae6287e340b9b4984cc19e54dfaaaca89 100644 (file)
@@ -1,7 +1,5 @@
 # !!!! This file is generated automatically, do not edit manually! See end script
 set filename bug27808_nist_ftc_06_asme1_ct5240_rd.stp
-puts "TODO CR26859 ALL:Error : 3 differences with reference data found :"
-puts "TODO CR26859 ALL:Error on writing file"
 
 set ref_data {
 
index f33cc1e0c85cb2e4bc2cb6143805106f010ad711..974b04928522fcb6e7e35c51e6c46c5b5279c8ee 100644 (file)
@@ -1,7 +1,5 @@
 # !!!! This file is generated automatically, do not edit manually! See end script
 set filename bug27645_nist_ftc_06_asme1_ct5240_rd-1.stp
-puts "TODO CR26859 ALL:Error : 3 differences with reference data found :"
-puts "TODO CR26859 ALL:Error on writing file"
 
 set ref_data {
 
index 2c8080f3537e283eaa1f7798ec68d89abc3d4de1..6276f3ed318de5342202e04d3cc6a4aa64990f0e 100644 (file)
@@ -1,7 +1,5 @@
 # !!!! This file is generated automatically, do not edit manually! See end script
 set filename bug27808_nist_ftc_09_asme1_ct5240_rd.stp
-puts "TODO CR26859 ALL:Error : 2 differences with reference data found :"
-puts "TODO CR26859 ALL:Error on writing file"
 
 set ref_data {
 
index 3bc1bb30e7b86b39311095b3d19498079aa2fb5b..4e49156ef4ac4bf4638e72820b5b89399cc4160a 100644 (file)
@@ -1,10 +1,8 @@
 # !!!! This file is generated automatically, do not edit manually! See end script
 set filename bug27808_nist_ftc_06_asme1_ct5240_rd.stp
-puts "TODO CR27235 ALL:Error : 4 differences with reference data found :"
-puts "TODO CR27235 ALL:Error on writing file"
 
 set ref_data {
-Centre of mass: 4.9764239505863603 64.18438466729144 -67.058903377273126
-Mass: 24387.315415267363
+Centre of mass: 4.9764105227425732 64.184386470151395 -67.058886121406474
+Mass: 24387.315219228582
 
 }
index 71823c7aa28b5691397e9f9cac0b13484a8722fc..6564284869246e5791514092b5895a483212affc 100644 (file)
@@ -1,7 +1,5 @@
 # !!!! This file is generated automatically, do not edit manually! See end script
 set filename bug27645_nist_ftc_06_asme1_ct5240_rd-1.stp
-puts "TODO CR27235 ALL:Error : 4 differences with reference data found :"
-puts "TODO CR27235 ALL:Error on writing file"
 
 set ref_data {
 Centre of mass: 126.40116834489778 1630.2833705491985 -1703.2961457827012
index 2ecabeebcaf7ce182ecdfdf8ce9c1e95350dfd2a..05f5401dba5961b2860033cec31f5e34fb0339f1 100644 (file)
@@ -1,7 +1,5 @@
 # !!!! This file is generated automatically, do not edit manually! See end script
 set filename bug27808_nist_ftc_09_asme1_ct5240_rd.stp
-puts "TODO CR27235 ALL:Error : 4 differences with reference data found :"
-puts "TODO CR27235 ALL:Error on writing file"
 
 set ref_data {
 Centre of mass: -20.281360550123736 7.5575111121398644 -1.4132597243023584