]> OCCT Git - occt-copy.git/commitdiff
Semantic name Get/Set functions added to XCAFDimTolObjects_*Object classes. Added...
authorsnn <snn@opencascade.com>
Mon, 26 Feb 2018 12:16:18 +0000 (15:16 +0300)
committersnn <snn@opencascade.com>
Mon, 26 Feb 2018 12:16:18 +0000 (15:16 +0300)
src/STEPCAFControl/STEPCAFControl_Reader.cxx
src/XCAFDimTolObjects/XCAFDimTolObjects_DatumObject.cxx
src/XCAFDimTolObjects/XCAFDimTolObjects_DatumObject.hxx
src/XCAFDimTolObjects/XCAFDimTolObjects_DimensionObject.cxx
src/XCAFDimTolObjects/XCAFDimTolObjects_DimensionObject.hxx
src/XCAFDimTolObjects/XCAFDimTolObjects_GeomToleranceObject.cxx
src/XCAFDimTolObjects/XCAFDimTolObjects_GeomToleranceObject.hxx
src/XCAFDoc/XCAFDoc_Datum.cxx
src/XCAFDoc/XCAFDoc_Dimension.cxx
src/XCAFDoc/XCAFDoc_GeomTolerance.cxx
src/XDEDRAW/XDEDRAW_GDTs.cxx

index 064425124cf7e4ef0b50a19b4f2a5c35e0aaf51a..e1781783804013b1a68ac9989e64a91b6e79562a 100644 (file)
@@ -2720,21 +2720,27 @@ static TDF_Label createGDTObjectInXCAF(const Handle(Standard_Transient)& theEnt,
   {
     return aGDTL;
   }
+
+  Handle(TCollection_HAsciiString) aSemanticName;
+
   // protection against invalid input
   if (theEnt->IsKind(STANDARD_TYPE(StepDimTol_GeometricTolerance))) {
     Handle(StepDimTol_GeometricTolerance) aGeomTol = Handle(StepDimTol_GeometricTolerance)::DownCast(theEnt);
     if (aGeomTol->TolerancedShapeAspect().IsNull())
       return aGDTL;
+    aSemanticName = aGeomTol->Name();
   }
   if (theEnt->IsKind(STANDARD_TYPE(StepShape_DimensionalSize))) {
     Handle(StepShape_DimensionalSize) aDim = Handle(StepShape_DimensionalSize)::DownCast(theEnt);
     if (aDim->AppliesTo().IsNull())
       return aGDTL;
+    aSemanticName = aDim->Name();
   }
   if (theEnt->IsKind(STANDARD_TYPE(StepShape_DimensionalLocation))) {
     Handle(StepShape_DimensionalLocation) aDim = Handle(StepShape_DimensionalLocation)::DownCast(theEnt);
     if (aDim->RelatedShapeAspect().IsNull() || aDim->RelatingShapeAspect().IsNull())
       return aGDTL;
+    aSemanticName = aDim->Name();
   }
 
   Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool( theDoc->Main() );
@@ -3139,6 +3145,13 @@ static TDF_Label createGDTObjectInXCAF(const Handle(Standard_Transient)& theEnt,
         anObj->AddModifier(XCAFDimTolObjects_GeomToleranceModif_All_Over);
       aGTol->SetObject(anObj);
     }
+
+    if (aSemanticName)
+    {
+      TCollection_ExtendedString str(aSemanticName->String());
+      TDataStd_Name::Set(aGDTL, str);
+    }
+
     readDatumsAP242(theEnt, aGDTL, theDoc, theWS);
   }
   return aGDTL;
index b0554abada80d8621082b5fa3640c6043f2cd093..56728584d8597638e0dab08321481354a1a11bb1 100644 (file)
@@ -52,6 +52,27 @@ XCAFDimTolObjects_DatumObject::XCAFDimTolObjects_DatumObject(const Handle(XCAFDi
   myHasPlane = theObj->myHasPlane;
   myHasPnt = theObj->myHasPnt;
   myHasPntText = theObj->myHasPntText;
+  mySemanticName = theObj->mySemanticName;
+}
+
+//=======================================================================
+//function : 
+//purpose  : 
+//=======================================================================
+
+Handle(TCollection_HAsciiString) XCAFDimTolObjects_DatumObject::GetSemanticName() const
+{
+  return mySemanticName;
+}
+
+//=======================================================================
+//function : 
+//purpose  : 
+//=======================================================================
+
+void XCAFDimTolObjects_DatumObject::SetSemanticName(const Handle(TCollection_HAsciiString)& theName)
+{
+  mySemanticName = theName;
 }
 
 //=======================================================================
index a9f8bd3b94afd765bbc9577aaf63c3183b88fd3f..d775cc1dc54c6dd43e52e5a69fa490370a822d47 100644 (file)
@@ -44,7 +44,13 @@ public:
   Standard_EXPORT XCAFDimTolObjects_DatumObject();
   
   Standard_EXPORT XCAFDimTolObjects_DatumObject(const Handle(XCAFDimTolObjects_DatumObject)& theObj);
-  
+
+  //! Returns semantic name
+  Standard_EXPORT Handle(TCollection_HAsciiString) GetSemanticName() const;
+
+  //! Sets semantic name
+  Standard_EXPORT void SetSemanticName(const Handle(TCollection_HAsciiString)& theName);
+
   Standard_EXPORT Handle(TCollection_HAsciiString) GetName() const;
   
   Standard_EXPORT void SetName (const Handle(TCollection_HAsciiString)& theTag);
@@ -181,7 +187,8 @@ private:
   Standard_Boolean myHasPnt;
   Standard_Boolean myHasPntText;
   TopoDS_Shape myPresentation;
-   Handle(TCollection_HAsciiString) myPresentationName;
+  Handle(TCollection_HAsciiString) mySemanticName;
+  Handle(TCollection_HAsciiString) myPresentationName;
 };
 
 #endif // _XCAFDimTolObjects_DatumObject_HeaderFile
index 5cfb3704e95fa52d09c9aa86b0a78688ce214a03..f810bf99400968b25d639c6f4e133d9ae691760f 100644 (file)
@@ -57,6 +57,27 @@ XCAFDimTolObjects_DimensionObject::XCAFDimTolObjects_DimensionObject(const Handl
   myHasPlane = theObj->myHasPlane;
   myPlane = theObj->myPlane;
   myHasPntText = theObj->myHasPntText;
+  mySemanticName = theObj->mySemanticName;
+}
+
+//=======================================================================
+//function : 
+//purpose  : 
+//=======================================================================
+
+Handle(TCollection_HAsciiString) XCAFDimTolObjects_DimensionObject::GetSemanticName() const
+{
+  return mySemanticName;
+}
+
+//=======================================================================
+//function : 
+//purpose  : 
+//=======================================================================
+
+void XCAFDimTolObjects_DimensionObject::SetSemanticName(const Handle(TCollection_HAsciiString)& theName)
+{
+  mySemanticName = theName;
 }
 
 //=======================================================================
index 7e635b195b594fe44107d63315a8e657883d44d4..dbb99c6d5fa07f54e1577e8d5b412fe534abf9f0 100644 (file)
@@ -54,6 +54,12 @@ public:
   
   Standard_EXPORT XCAFDimTolObjects_DimensionObject(const Handle(XCAFDimTolObjects_DimensionObject)& theObj);
   
+  //! Returns semantic name
+  Standard_EXPORT Handle(TCollection_HAsciiString) GetSemanticName() const;
+
+  //! Sets semantic name
+  Standard_EXPORT void SetSemanticName(const Handle(TCollection_HAsciiString)& theName);
+
   Standard_EXPORT void SetQualifier (const XCAFDimTolObjects_DimensionQualifier theQualifier);
   
   Standard_EXPORT XCAFDimTolObjects_DimensionQualifier GetQualifier() const;
@@ -186,7 +192,7 @@ public:
     return myPresentation;
   }
 
-   //! Returns graphical presentation of the object
+  //! Returns graphical presentation of the object
   Standard_EXPORT Handle(TCollection_HAsciiString) GetPresentationName() const
   {
     return myPresentationName;
@@ -252,6 +258,7 @@ private:
   Standard_Boolean myHasPntText;
   gp_Pnt myPntText;
   TopoDS_Shape myPresentation;
+  Handle(TCollection_HAsciiString) mySemanticName;
   Handle(TCollection_HAsciiString) myPresentationName;
   NCollection_Vector<Handle(TCollection_HAsciiString)> myDescriptions;
   NCollection_Vector<Handle(TCollection_HAsciiString)> myDescriptionNames;
index f1e5c77dd00a0b10f1141991edcfea14470b3477..fecc52655c87bf319209dae840e97bb37e1f046f 100644 (file)
@@ -51,6 +51,27 @@ XCAFDimTolObjects_GeomToleranceObject::XCAFDimTolObjects_GeomToleranceObject(con
   myHasPlane = theObj->myHasPlane;
   myHasPnt = theObj->myHasPnt;
   myHasPntText = theObj->myHasPntText;
+  mySemanticName = theObj->mySemanticName;
+}
+
+//=======================================================================
+//function : 
+//purpose  : 
+//=======================================================================
+
+Handle(TCollection_HAsciiString) XCAFDimTolObjects_GeomToleranceObject::GetSemanticName() const
+{
+  return mySemanticName;
+}
+
+//=======================================================================
+//function : 
+//purpose  : 
+//=======================================================================
+
+void XCAFDimTolObjects_GeomToleranceObject::SetSemanticName(const Handle(TCollection_HAsciiString)& theName)
+{
+  mySemanticName = theName;
 }
 
 //=======================================================================
index 5fdf62084a8283ac6d34d62242cf63a12e8f446a..ae9b1396a21f3a2f4e19038e26ea7320bb4fdb75 100644 (file)
@@ -46,6 +46,12 @@ public:
   
   Standard_EXPORT XCAFDimTolObjects_GeomToleranceObject(const Handle(XCAFDimTolObjects_GeomToleranceObject)& theObj);
   
+  //! Returns semantic name
+  Standard_EXPORT Handle(TCollection_HAsciiString) GetSemanticName() const;
+
+  //! Sets semantic name
+  Standard_EXPORT void SetSemanticName(const Handle(TCollection_HAsciiString)& theName);
+
   Standard_EXPORT void SetType (const XCAFDimTolObjects_GeomToleranceType theType);
   
   Standard_EXPORT XCAFDimTolObjects_GeomToleranceType GetType() const;
@@ -163,14 +169,8 @@ private:
   Standard_Boolean myHasPnt;
   Standard_Boolean myHasPntText;
   TopoDS_Shape myPresentation;
+  Handle(TCollection_HAsciiString) mySemanticName;
   Handle(TCollection_HAsciiString) myPresentationName;
-
 };
 
-
-
-
-
-
-
 #endif // _XCAFDimTolObjects_GeomToleranceObject_HeaderFile
index 2e4538a594f2486d21c3a47b775cd45bb98cf86f..b813704ea6c754c2787718f2194648995c915199 100644 (file)
@@ -172,6 +172,13 @@ Handle(TCollection_HAsciiString) XCAFDoc_Datum::GetIdentification() const
 void XCAFDoc_Datum::SetObject(const Handle(XCAFDimTolObjects_DatumObject)& theObject)
 {
   Backup();
+
+  if (theObject->GetSemanticName())
+  {
+    TCollection_ExtendedString str(theObject->GetSemanticName()->String());
+    TDataStd_Name::Set(Label(), str);
+  }
+
   TDF_ChildIterator anIter(Label());
   for(;anIter.More(); anIter.Next())
   {
@@ -342,6 +349,16 @@ Handle(XCAFDimTolObjects_DatumObject) XCAFDoc_Datum::GetObject() const
 {
   Handle(XCAFDimTolObjects_DatumObject) anObj = new XCAFDimTolObjects_DatumObject();
 
+  Handle(TDataStd_Name) aSemanticNameAttr;
+  Handle(TCollection_HAsciiString) aSemanticName;
+  if (Label().FindAttribute(TDataStd_Name::GetID(), aSemanticNameAttr))
+  {
+    const TCollection_ExtendedString& aName = aSemanticNameAttr->Get();
+    if (!aName.IsEmpty())
+      aSemanticName = new TCollection_HAsciiString(aName);
+  }
+  anObj->SetSemanticName(aSemanticName);
+
   Handle(TDataStd_AsciiString) anAttName;
   if(Label().FindChild(ChildLab_Name).FindAttribute(TDataStd_AsciiString::GetID(), anAttName))
   {
index a210dac8ceb4b9416585a92f17a3756029fef4cc..3e6f104d294af2536bcc8fb50cf0f49f14b64741 100644 (file)
@@ -100,7 +100,12 @@ void XCAFDoc_Dimension::SetObject (const Handle(XCAFDimTolObjects_DimensionObjec
 {
   Backup();
 
-  //Label().ForForgetAllAttributes();
+  if (theObject->GetSemanticName())
+  {
+    TCollection_ExtendedString str(theObject->GetSemanticName()->String());
+    TDataStd_Name::Set(Label(), str);
+  }
+
   TDF_ChildIterator anIter(Label());
   for(;anIter.More(); anIter.Next())
   {
@@ -282,6 +287,16 @@ Handle(XCAFDimTolObjects_DimensionObject) XCAFDoc_Dimension::GetObject()  const
 {
   Handle(XCAFDimTolObjects_DimensionObject) anObj = new XCAFDimTolObjects_DimensionObject();
 
+  Handle(TDataStd_Name) aSemanticNameAttr;
+  Handle(TCollection_HAsciiString) aSemanticName;
+  if (Label().FindAttribute(TDataStd_Name::GetID(), aSemanticNameAttr))
+  {
+    const TCollection_ExtendedString& aName = aSemanticNameAttr->Get();
+    if (!aName.IsEmpty())
+      aSemanticName = new TCollection_HAsciiString(aName);
+  }
+  anObj->SetSemanticName(aSemanticName);
+
   Handle(TDataStd_Integer) aType;
   if(Label().FindChild(ChildLab_Type).FindAttribute(TDataStd_Integer::GetID(), aType))
   {
@@ -332,7 +347,6 @@ Handle(XCAFDimTolObjects_DimensionObject) XCAFDoc_Dimension::GetObject()  const
     anObj->SetPath(TopoDS::Edge(aShape->Get()));
   }
 
-
   Handle(TDataStd_RealArray) aDir;
   if(Label().FindChild(ChildLab_Dir).FindAttribute(TDataStd_RealArray::GetID(), aDir)
      && !aDir->Array().IsNull() && aDir->Array()->Length() > 0)
@@ -378,21 +392,17 @@ Handle(XCAFDimTolObjects_DimensionObject) XCAFDoc_Dimension::GetObject()  const
   TDF_Label aLPres = Label().FindChild( ChildLab_Presentation);
   if ( aLPres.FindAttribute(TNaming_NamedShape::GetID(), aNS) ) 
   {
-
     TopoDS_Shape aPresentation = TNaming_Tool::GetShape(aNS);
     if( !aPresentation.IsNull())
     {
-     
       Handle(TDataStd_Name) aNameAtrr;
       Handle(TCollection_HAsciiString) aPresentName;
       if (aLPres.FindAttribute(TDataStd_Name::GetID(),aNameAtrr))
       {
         const TCollection_ExtendedString& aName = aNameAtrr->Get();
-
         if( !aName.IsEmpty())
           aPresentName = new TCollection_HAsciiString(aName);
       }
-
       anObj->SetPresentation(aPresentation, aPresentName);
     }
   }
index 0ef458fef3cf5b60a9709f007c6c03c78f7a0193..da0e1605a30d48400eb18221f393e737c024a171 100644 (file)
@@ -97,7 +97,12 @@ void XCAFDoc_GeomTolerance::SetObject (const Handle(XCAFDimTolObjects_GeomTolera
 {
   Backup();
 
-  //Label().ForForgetAllAttributes();
+  if (theObject->GetSemanticName())
+  {
+    TCollection_ExtendedString str(theObject->GetSemanticName()->String());
+    TDataStd_Name::Set(Label(), str);
+  }
+
   TDF_ChildIterator anIter(Label());
   for(;anIter.More(); anIter.Next())
   {
@@ -244,6 +249,16 @@ Handle(XCAFDimTolObjects_GeomToleranceObject) XCAFDoc_GeomTolerance::GetObject()
 {
   Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = new XCAFDimTolObjects_GeomToleranceObject();
 
+  Handle(TDataStd_Name) aSemanticNameAttr;
+  Handle(TCollection_HAsciiString) aSemanticName;
+  if (Label().FindAttribute(TDataStd_Name::GetID(), aSemanticNameAttr))
+  {
+    const TCollection_ExtendedString& aName = aSemanticNameAttr->Get();
+    if (!aName.IsEmpty())
+      aSemanticName = new TCollection_HAsciiString(aName);
+  }
+  anObj->SetSemanticName(aSemanticName);
+
   Handle(TDataStd_Integer) aType;
   if(Label().FindChild(ChildLab_Type).FindAttribute(TDataStd_Integer::GetID(), aType))
   {
index e22e89ac90a23565ce1abe0173704c79364320c4..eae550e82641569ff6040dd5e3e96793b4820a03 100644 (file)
@@ -137,6 +137,10 @@ static Standard_Integer DumpDGTs (Draw_Interpretor& di, Standard_Integer argc, c
         if (argc > 3)
         {
           di <<" (";
+          if (aDimTolObj->GetSemanticName())
+          {
+            di << " N \"" << aDimTolObj->GetSemanticName()->String() << "\"";
+          }
           di << " T " << aDimTolObj->GetType();
           if(aDimTolObj->IsDimWithRange())
           {
@@ -207,6 +211,10 @@ static Standard_Integer DumpDGTs (Draw_Interpretor& di, Standard_Integer argc, c
         if (argc > 3)
         {
           di <<" (";
+          if (aDimTolObj->GetSemanticName())
+          {
+            di << " N \"" << aDimTolObj->GetSemanticName()->String() << "\"";
+          }
           di << " T " << aDimTolObj->GetType();
           di << " TV " << aDimTolObj->GetTypeOfValue();
           di << ", V " << aDimTolObj->GetValue();
@@ -244,7 +252,6 @@ static Standard_Integer DumpDGTs (Draw_Interpretor& di, Standard_Integer argc, c
               di << " ZMV " <<aDimTolObj->GetValueOfZoneModifier();
             }
           }
-
           di << " )";
         }
         Handle(XCAFDoc_GraphNode) aNode;
@@ -262,7 +269,11 @@ static Standard_Integer DumpDGTs (Draw_Interpretor& di, Standard_Integer argc, c
               di << " Datum."<< i << "."<< j << "."<< k;
               if (argc > 3)
               {
-                di <<" (";
+                di << " (";
+                if (aDimTolObj->GetSemanticName())
+                {
+                  di << " N \"" << aDimTolObj->GetSemanticName()->String() << "\"";
+                }
                 XCAFDimTolObjects_DatumModifiersSequence aModif = 
                   aDatumObj->GetModifiers();
                 if (!aModif.IsEmpty())
@@ -313,6 +324,10 @@ static Standard_Integer DumpDGTs (Draw_Interpretor& di, Standard_Integer argc, c
           if (argc > 3)
           {
             di <<" (";
+            if (aDatumObj->GetSemanticName())
+            {
+              di << " N \"" << aDatumObj->GetSemanticName()->String() << "\"";
+            }
             di << " T " << aDatumObj->GetDatumTargetType();
             if (aDatumObj->GetDatumTargetType() != XCAFDimTolObjects_DatumTargetType_Area)
             {
@@ -2506,6 +2521,97 @@ static Standard_Integer getGDTPresentation (Draw_Interpretor& di, Standard_Integ
   return 0;
 }
 
+static Standard_Integer getGDTSemanticName(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+  if (argc < 3) {
+    di << "Use: XGetGDTSemanticName Doc GDT_Label\n";
+    return 1;
+  }
+  Handle(TDocStd_Document) Doc;
+  DDocStd::GetDocument(argv[1], Doc);
+  if (Doc.IsNull()) { di << argv[1] << " is not a document\n"; return 1; }
+
+  TDF_Label aLabel;
+  TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
+  if (aLabel.IsNull())
+  {
+    di << "GDT " << argv[2] << " is absent in " << argv[1] << "\n";
+    return 1;
+  }
+  Handle(TCollection_HAsciiString) aSemanticName;
+  // Dimension
+  Handle(XCAFDoc_Dimension) aDimension;
+  if (aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
+  {
+    Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
+    aSemanticName = anObj->GetSemanticName();
+  }
+  // Geometric Tolerance
+  Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
+  if (aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
+  {
+    Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
+    aSemanticName = anObj->GetSemanticName();
+  }
+  // Datum
+  Handle(XCAFDoc_Datum) aDatum;
+  if (aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
+  {
+    Handle(XCAFDimTolObjects_DatumObject) anObj = aDatum->GetObject();
+    aSemanticName = anObj->GetSemanticName();
+  }
+  if (aSemanticName)
+  {
+    di << aSemanticName->String();
+  }
+  return 0;
+}
+
+static Standard_Integer setGDTSemanticName(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+  if (argc < 3) {
+    di << "Use: XSetGDTSemanticName Doc GDT_Label Name\n";
+    return 1;
+  }
+  Handle(TDocStd_Document) Doc;
+  DDocStd::GetDocument(argv[1], Doc);
+  if (Doc.IsNull()) { di << argv[1] << " is not a document\n"; return 1; }
+
+  TDF_Label aLabel;
+  TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
+  if (aLabel.IsNull())
+  {
+    di << "GDT " << argv[2] << " is absent in " << argv[1] << "\n";
+    return 1;
+  }
+  Handle(TCollection_HAsciiString) aSemanticName = new TCollection_HAsciiString(argv[3]);
+  // Dimension
+  Handle(XCAFDoc_Dimension) aDimension;
+  if (aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
+  {
+    Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
+    anObj->SetSemanticName(aSemanticName);
+    aDimension->SetObject(anObj);
+  }
+  // Geometric Tolerance
+  Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
+  if (aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
+  {
+    Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
+    anObj->SetSemanticName(aSemanticName);
+    aGeomTolerance->SetObject(anObj);
+  }
+  // Datum
+  Handle(XCAFDoc_Datum) aDatum;
+  if (aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
+  {
+    Handle(XCAFDimTolObjects_DatumObject) anObj = aDatum->GetObject();
+    anObj->SetSemanticName(aSemanticName);
+    aDatum->SetObject(anObj);
+  }
+  return 0;
+}
+
 //=======================================================================
 //function : InitCommands
 //purpose  : 
@@ -2874,4 +2980,12 @@ void XDEDRAW_GDTs::InitCommands(Draw_Interpretor& di)
   di.Add ("XGetGDTPresentation","XGetGDTPresentation Doc GDT_Label Shape"
     "Returns Presentation into Shape",
     __FILE__, getGDTPresentation, g);
+
+  di.Add("XGetGDTSemanticName", "XGetGDTSemanticName Doc GDT_Label"
+    "Returns semantic name",
+    __FILE__, getGDTSemanticName, g);
+
+  di.Add("XSetGDTSemanticName", "XGetGDTSemanticName Doc GDT_Label Name"
+    "Set semantic name",
+    __FILE__, setGDTSemanticName, g);
 }