1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-02 17:46:22 +03:00

0029737: Data Exchange - Revert optimization in XCAF for format compability

Revert changes from 0029338, which were affected on order of GDT attribute sublabels.
This commit is contained in:
ika 2018-05-07 11:51:58 +03:00 committed by abv
parent e50ebf1f0f
commit fbcef69b1a
4 changed files with 261 additions and 94 deletions

View File

@ -12,7 +12,6 @@
// commercial license or contractual agreement.
#include <gp_Pln.hxx>
#include <Standard_GUID.hxx>
#include <Standard_Type.hxx>
#include <TCollection_HAsciiString.hxx>
@ -26,9 +25,6 @@
#include <TDataStd_RealArray.hxx>
#include <TDataStd_Integer.hxx>
#include <TDataStd_Real.hxx>
#include <TDataXtd_Geometry.hxx>
#include <TDataXtd_Plane.hxx>
#include <TDataXtd_Point.hxx>
#include <TNaming_NamedShape.hxx>
#include <TNaming_Builder.hxx>
#include <TNaming_Tool.hxx>
@ -46,12 +42,16 @@ enum ChildLab
ChildLab_ModifierWithValue,
ChildLab_IsDTarget,
ChildLab_DTargetType,
ChildLab_Axis,
ChildLab_AxisLoc,
ChildLab_AxisN,
ChildLab_AxisRef,
ChildLab_DTargetLength,
ChildLab_DTargetWidth,
ChildLab_DTargetNumber,
ChildLab_DatumTarget,
ChildLab_Plane,
ChildLab_PlaneLoc,
ChildLab_PlaneN,
ChildLab_PlaneRef,
ChildLab_Pnt,
ChildLab_PntText,
ChildLab_Presentation
@ -233,7 +233,26 @@ void XCAFDoc_Datum::SetObject(const Handle(XCAFDimTolObjects_DatumObject)& theOb
else if (theObject->HasDatumTargetParams())
{
gp_Ax2 anAx = theObject->GetDatumTargetAxis();
TDataXtd_Plane::Set(Label().FindChild(ChildLab_Axis), gp_Pln(gp_Ax3(anAx)));
Handle(TColStd_HArray1OfReal) aLocArr = new TColStd_HArray1OfReal(1, 3);
for (Standard_Integer i = 1; i <= 3; i++)
aLocArr->SetValue(i, anAx.Location().Coord(i));
Handle(TDataStd_RealArray) aLoc = TDataStd_RealArray::Set(Label().FindChild(ChildLab_AxisLoc), 1, 3);
if (!aLoc.IsNull())
aLoc->ChangeArray(aLocArr);
Handle(TColStd_HArray1OfReal) aNArr = new TColStd_HArray1OfReal(1, 3);
for (Standard_Integer i = 1; i <= 3; i++)
aNArr->SetValue(i, anAx.Direction().Coord(i));
Handle(TDataStd_RealArray) aN = TDataStd_RealArray::Set(Label().FindChild(ChildLab_AxisN), 1, 3);
if (!aN.IsNull())
aN->ChangeArray(aNArr);
Handle(TColStd_HArray1OfReal) aRArr = new TColStd_HArray1OfReal(1, 3);
for (Standard_Integer i = 1; i <= 3; i++)
aRArr->SetValue(i, anAx.XDirection().Coord(i));
Handle(TDataStd_RealArray) aR = TDataStd_RealArray::Set(Label().FindChild(ChildLab_AxisRef), 1, 3);
if (!aR.IsNull())
aR->ChangeArray(aRArr);
if(theObject->GetDatumTargetType() != XCAFDimTolObjects_DatumTargetType_Point)
{
@ -250,17 +269,52 @@ void XCAFDoc_Datum::SetObject(const Handle(XCAFDimTolObjects_DatumObject)& theOb
if (theObject->HasPlane())
{
TDataXtd_Plane::Set(Label().FindChild(ChildLab_Plane), gp_Pln(gp_Ax3(theObject->GetPlane())));
gp_Ax2 anAx = theObject->GetPlane();
Handle(TColStd_HArray1OfReal) aLocArr = new TColStd_HArray1OfReal(1, 3);
for (Standard_Integer i = 1; i <= 3; i++)
aLocArr->SetValue(i, anAx.Location().Coord(i));
Handle(TDataStd_RealArray) aLoc = TDataStd_RealArray::Set(Label().FindChild(ChildLab_PlaneLoc), 1, 3);
if (!aLoc.IsNull())
aLoc->ChangeArray(aLocArr);
Handle(TColStd_HArray1OfReal) aNArr = new TColStd_HArray1OfReal(1, 3);
for (Standard_Integer i = 1; i <= 3; i++)
aNArr->SetValue(i, anAx.Direction().Coord(i));
Handle(TDataStd_RealArray) aN = TDataStd_RealArray::Set(Label().FindChild(ChildLab_PlaneN), 1, 3);
if (!aN.IsNull())
aN->ChangeArray(aNArr);
Handle(TColStd_HArray1OfReal) aRArr = new TColStd_HArray1OfReal(1, 3);
for (Standard_Integer i = 1; i <= 3; i++)
aRArr->SetValue(i, anAx.XDirection().Coord(i));
Handle(TDataStd_RealArray) aR = TDataStd_RealArray::Set(Label().FindChild(ChildLab_PlaneRef), 1, 3);
if (!aR.IsNull())
aR->ChangeArray(aRArr);
}
if (theObject->HasPoint())
{
TDataXtd_Point::Set(Label().FindChild(ChildLab_Pnt), theObject->GetPoint());
gp_Pnt aPnt = theObject->GetPoint();
Handle(TColStd_HArray1OfReal) aLocArr = new TColStd_HArray1OfReal(1, 3);
for (Standard_Integer i = 1; i <= 3; i++)
aLocArr->SetValue(i, aPnt.Coord(i));
Handle(TDataStd_RealArray) aLoc = TDataStd_RealArray::Set(Label().FindChild(ChildLab_Pnt), 1, 3);
if (!aLoc.IsNull())
aLoc->ChangeArray(aLocArr);
}
if (theObject->HasPointText())
{
TDataXtd_Point::Set(Label().FindChild(ChildLab_PntText), theObject->GetPointTextAttach());
gp_Pnt aPntText = theObject->GetPointTextAttach();
Handle(TColStd_HArray1OfReal) aLocArr = new TColStd_HArray1OfReal(1, 3);
for (Standard_Integer i = 1; i <= 3; i++)
aLocArr->SetValue(i, aPntText.Coord(i));
Handle(TDataStd_RealArray) aLoc = TDataStd_RealArray::Set(Label().FindChild(ChildLab_PntText), 1, 3);
if (!aLoc.IsNull())
aLoc->ChangeArray(aLocArr);
}
TopoDS_Shape aPresentation = theObject->GetPresentation();
@ -331,29 +385,30 @@ Handle(XCAFDimTolObjects_DatumObject) XCAFDoc_Datum::GetObject() const
anObj->SetPosition(aPosition->Get());
}
Handle(TDataXtd_Plane) aPlaneAttr;
if (Label().FindChild(ChildLab_Plane).FindAttribute(TDataXtd_Plane::GetID(), aPlaneAttr))
Handle(TDataStd_RealArray) aLoc, aN, aR;
if (Label().FindChild(ChildLab_PlaneLoc).FindAttribute(TDataStd_RealArray::GetID(), aLoc) && aLoc->Length() == 3 &&
Label().FindChild(ChildLab_PlaneN).FindAttribute(TDataStd_RealArray::GetID(), aN) && aN->Length() == 3 &&
Label().FindChild(ChildLab_PlaneRef).FindAttribute(TDataStd_RealArray::GetID(), aR) && aR->Length() == 3)
{
gp_Pln aPlane;
TDataXtd_Geometry::Plane(aPlaneAttr->Label(), aPlane);
gp_Ax2 anAx(aPlane.Location(), aPlane.Axis().Direction(), aPlane.XAxis().Direction());
gp_Pnt aL(aLoc->Value(aLoc->Lower()), aLoc->Value(aLoc->Lower() + 1), aLoc->Value(aLoc->Lower() + 2));
gp_Dir aD(aN->Value(aN->Lower()), aN->Value(aN->Lower() + 1), aN->Value(aN->Lower() + 2));
gp_Dir aDR(aR->Value(aR->Lower()), aR->Value(aR->Lower() + 1), aR->Value(aR->Lower() + 2));
gp_Ax2 anAx(aL, aD, aDR);
anObj->SetPlane(anAx);
}
Handle(TDataXtd_Point) aPntAttr;
if (Label().FindChild(ChildLab_Pnt).FindAttribute(TDataXtd_Point::GetID(), aPntAttr))
Handle(TDataStd_RealArray) aPnt;
if (Label().FindChild(ChildLab_Pnt).FindAttribute(TDataStd_RealArray::GetID(), aPnt) && aPnt->Length() == 3)
{
gp_Pnt aPoint;
TDataXtd_Geometry::Point(aPntAttr->Label(), aPoint);
anObj->SetPoint(aPoint);
gp_Pnt aP(aLoc->Value(aPnt->Lower()), aPnt->Value(aPnt->Lower() + 1), aPnt->Value(aPnt->Lower() + 2));
anObj->SetPoint(aP);
}
Handle(TDataXtd_Point) aPntTextAttr;
if (Label().FindChild(ChildLab_PntText).FindAttribute(TDataXtd_Point::GetID(), aPntTextAttr))
Handle(TDataStd_RealArray) aPntText;
if (Label().FindChild(ChildLab_PntText).FindAttribute(TDataStd_RealArray::GetID(), aPntText) && aPntText->Length() == 3)
{
gp_Pnt aPoint;
TDataXtd_Geometry::Point(aPntTextAttr->Label(), aPoint);
anObj->SetPointTextAttach(aPoint);
gp_Pnt aP(aPntText->Value(aPntText->Lower()), aPntText->Value(aPntText->Lower() + 1), aPntText->Value(aPntText->Lower() + 2));
anObj->SetPointTextAttach(aP);
}
Handle(TDataStd_Integer) aIsDTarget;
@ -382,12 +437,14 @@ Handle(XCAFDimTolObjects_DatumObject) XCAFDoc_Datum::GetObject() const
}
else
{
Handle(TDataXtd_Plane) anAxisAttr;
if (Label().FindChild(ChildLab_Axis).FindAttribute(TDataXtd_Plane::GetID(), anAxisAttr))
if (Label().FindChild(ChildLab_AxisLoc).FindAttribute(TDataStd_RealArray::GetID(), aLoc) && aLoc->Length() == 3 &&
Label().FindChild(ChildLab_AxisN).FindAttribute(TDataStd_RealArray::GetID(), aN) && aN->Length() == 3 &&
Label().FindChild(ChildLab_AxisRef).FindAttribute(TDataStd_RealArray::GetID(), aR) && aR->Length() == 3)
{
gp_Pln aPlane;
TDataXtd_Geometry::Plane(anAxisAttr->Label(), aPlane);
gp_Ax2 anAx(aPlane.Location(), aPlane.Axis().Direction(), aPlane.XAxis().Direction());
gp_Pnt aL(aLoc->Value(aLoc->Lower()), aLoc->Value(aLoc->Lower() + 1), aLoc->Value(aLoc->Lower() + 2));
gp_Dir aD(aN->Value(aN->Lower()), aN->Value(aN->Lower() + 1), aN->Value(aN->Lower() + 2));
gp_Dir aDR(aR->Value(aR->Lower()), aR->Value(aR->Lower() + 1), aR->Value(aR->Lower() + 2));
gp_Ax2 anAx(aL, aD, aDR);
anObj->SetDatumTargetAxis(anAx);
}

View File

@ -13,7 +13,6 @@
#include <XCAFDoc_Dimension.hxx>
#include <gp_Pln.hxx>
#include <TDF_RelocationTable.hxx>
#include <TDF_ChildIterator.hxx>
#include <XCAFDoc.hxx>
@ -25,10 +24,6 @@
#include <TDataStd_ExtStringArray.hxx>
#include <TDataStd_Real.hxx>
#include <TDataStd_RealArray.hxx>
#include <TDataXtd_Axis.hxx>
#include <TDataXtd_Geometry.hxx>
#include <TDataXtd_Plane.hxx>
#include <TDataXtd_Point.hxx>
#include <TNaming_Builder.hxx>
#include <TNaming_NamedShape.hxx>
#include <TColStd_HArray1OfReal.hxx>
@ -51,7 +46,9 @@ enum ChildLab
ChildLab_Dir,
ChildLab_Pnt1,
ChildLab_Pnt2,
ChildLab_Plane,
ChildLab_PlaneLoc,
ChildLab_PlaneN,
ChildLab_PlaneRef,
ChildLab_PntText,
ChildLab_Presentation,
ChildLab_Descriptions,
@ -171,31 +168,80 @@ void XCAFDoc_Dimension::SetObject (const Handle(XCAFDimTolObjects_DimensionObjec
tnBuild.Generated(theObject->GetPath());
}
Handle(TColStd_HArray1OfReal) anArrR;
if(theObject->GetType() == XCAFDimTolObjects_DimensionType_Location_Oriented)
{
gp_Dir aD;
theObject->GetDirection(aD);
TDataXtd_Axis::Set(Label().FindChild(ChildLab_Dir), gp_Lin(gp_Pnt(), aD));
anArrR = new TColStd_HArray1OfReal(1, 3);
anArrR->SetValue(1, aD.X());
anArrR->SetValue(2, aD.Y());
anArrR->SetValue(3, aD.Z());
Handle(TDataStd_RealArray) aDir = TDataStd_RealArray::Set(Label().FindChild(ChildLab_Dir), 1, 3);
if (!aDir.IsNull())
aDir->ChangeArray(anArrR);
}
if (theObject->HasPoint())
{
TDataXtd_Point::Set(Label().FindChild(ChildLab_Pnt1), theObject->GetPoint());
gp_Pnt aPnt1 = theObject->GetPoint();
Handle(TColStd_HArray1OfReal) aPntArr = new TColStd_HArray1OfReal(1, 3);
for (Standard_Integer i = 1; i <= 3; i++)
aPntArr->SetValue(i, aPnt1.Coord(i));
Handle(TDataStd_RealArray) aPnt = TDataStd_RealArray::Set(Label().FindChild(ChildLab_Pnt1), 1, 3);
if (!aPnt.IsNull())
aPnt->ChangeArray(aPntArr);
}
if (theObject->HasPoint2())
{
TDataXtd_Point::Set(Label().FindChild(ChildLab_Pnt2), theObject->GetPoint2());
gp_Pnt aPnt2 = theObject->GetPoint2();
Handle(TColStd_HArray1OfReal) aPntArr = new TColStd_HArray1OfReal(1, 3);
for (Standard_Integer i = 1; i <= 3; i++)
aPntArr->SetValue(i, aPnt2.Coord(i));
Handle(TDataStd_RealArray) aPnt = TDataStd_RealArray::Set(Label().FindChild(ChildLab_Pnt2), 1, 3);
if (!aPnt.IsNull())
aPnt->ChangeArray(aPntArr);
}
if (theObject->HasPlane())
{
TDataXtd_Plane::Set(Label().FindChild(ChildLab_Plane), gp_Pln(gp_Ax3(theObject->GetPlane())));
gp_Ax2 anAx = theObject->GetPlane();
Handle(TColStd_HArray1OfReal) aLocArr = new TColStd_HArray1OfReal(1, 3);
for (Standard_Integer i = 1; i <= 3; i++)
aLocArr->SetValue(i, anAx.Location().Coord(i));
Handle(TDataStd_RealArray) aLoc = TDataStd_RealArray::Set(Label().FindChild(ChildLab_PlaneLoc), 1, 3);
if (!aLoc.IsNull())
aLoc->ChangeArray(aLocArr);
Handle(TColStd_HArray1OfReal) aNArr = new TColStd_HArray1OfReal(1, 3);
for (Standard_Integer i = 1; i <= 3; i++)
aNArr->SetValue(i, anAx.Direction().Coord(i));
Handle(TDataStd_RealArray) aN = TDataStd_RealArray::Set(Label().FindChild(ChildLab_PlaneN), 1, 3);
if (!aN.IsNull())
aN->ChangeArray(aNArr);
Handle(TColStd_HArray1OfReal) aRArr = new TColStd_HArray1OfReal(1, 3);
for (Standard_Integer i = 1; i <= 3; i++)
aRArr->SetValue(i, anAx.XDirection().Coord(i));
Handle(TDataStd_RealArray) aRAtt = TDataStd_RealArray::Set(Label().FindChild(ChildLab_PlaneRef), 1, 3);
if (!aRAtt.IsNull())
aRAtt->ChangeArray(aRArr);
}
if (theObject->HasTextPoint())
{
TDataXtd_Point::Set(Label().FindChild(ChildLab_PntText), theObject->GetPointTextAttach());
gp_Pnt aPntText = theObject->GetPointTextAttach();
Handle(TColStd_HArray1OfReal) aLocArr = new TColStd_HArray1OfReal(1, 3);
for (Standard_Integer i = 1; i <= 3; i++)
aLocArr->SetValue(i, aPntText.Coord(i));
Handle(TDataStd_RealArray) aLoc = TDataStd_RealArray::Set(Label().FindChild(ChildLab_PntText), 1, 3);
if (!aLoc.IsNull())
aLoc->ChangeArray(aLocArr);
}
TopoDS_Shape aPresentation = theObject->GetPresentation();
@ -301,46 +347,46 @@ Handle(XCAFDimTolObjects_DimensionObject) XCAFDoc_Dimension::GetObject() const
anObj->SetPath(TopoDS::Edge(aShape->Get()));
}
Handle(TDataXtd_Axis) aDirAttr;
if (Label().FindChild(ChildLab_Dir).FindAttribute(TDataXtd_Axis::GetID(), aDirAttr))
Handle(TDataStd_RealArray) aDir;
if (Label().FindChild(ChildLab_Dir).FindAttribute(TDataStd_RealArray::GetID(), aDir)
&& !aDir->Array().IsNull() && aDir->Array()->Length() > 0)
{
gp_Ax1 aDir;
TDataXtd_Geometry::Axis(aDirAttr->Label(), aDir);
anObj->SetDirection(aDir.Direction());
gp_Dir aD(aDir->Array()->Value(1), aDir->Array()->Value(2), aDir->Array()->Value(3));
anObj->SetDirection(aD);
}
Handle(TDataXtd_Point) aPnt1Attr;
if (Label().FindChild(ChildLab_Pnt1).FindAttribute(TDataXtd_Point::GetID(), aPnt1Attr))
Handle(TDataStd_RealArray) aPnt1;
if (Label().FindChild(ChildLab_Pnt1).FindAttribute(TDataStd_RealArray::GetID(), aPnt1) && aPnt1->Length() == 3)
{
gp_Pnt aPoint;
TDataXtd_Geometry::Point(aPnt1Attr->Label(), aPoint);
anObj->SetPoint(aPoint);
gp_Pnt aP(aPnt1->Value(aPnt1->Lower()), aPnt1->Value(aPnt1->Lower() + 1), aPnt1->Value(aPnt1->Lower() + 2));
anObj->SetPoint(aP);
}
Handle(TDataXtd_Point) aPnt2Attr;
if (Label().FindChild(ChildLab_Pnt2).FindAttribute(TDataXtd_Point::GetID(), aPnt2Attr))
Handle(TDataStd_RealArray) aPnt2;
if (Label().FindChild(ChildLab_Pnt2).FindAttribute(TDataStd_RealArray::GetID(), aPnt2) && aPnt2->Length() == 3)
{
gp_Pnt aPoint;
TDataXtd_Geometry::Point(aPnt2Attr->Label(), aPoint);
anObj->SetPoint2(aPoint);
gp_Pnt aP(aPnt2->Value(aPnt2->Lower()), aPnt2->Value(aPnt2->Lower() + 1), aPnt2->Value(aPnt2->Lower() + 2));
anObj->SetPoint2(aP);
}
Handle(TDataXtd_Plane) aPlaneAttr;
if (Label().FindChild(ChildLab_Plane).FindAttribute(TDataXtd_Plane::GetID(), aPlaneAttr))
Handle(TDataStd_RealArray) aLoc, aN, aR;
if (Label().FindChild(ChildLab_PlaneLoc).FindAttribute(TDataStd_RealArray::GetID(), aLoc) && aLoc->Length() == 3 &&
Label().FindChild(ChildLab_PlaneN).FindAttribute(TDataStd_RealArray::GetID(), aN) && aN->Length() == 3 &&
Label().FindChild(ChildLab_PlaneRef).FindAttribute(TDataStd_RealArray::GetID(), aR) && aR->Length() == 3)
{
gp_Pln aPlane;
TDataXtd_Geometry::Plane(aPlaneAttr->Label(), aPlane);
gp_Ax2 anAx(aPlane.Location(), aPlane.Axis().Direction(), aPlane.XAxis().Direction());
gp_Pnt aL(aLoc->Value(aLoc->Lower()), aLoc->Value(aLoc->Lower() + 1), aLoc->Value(aLoc->Lower() + 2));
gp_Dir aD(aN->Value(aN->Lower()), aN->Value(aN->Lower() + 1), aN->Value(aN->Lower() + 2));
gp_Dir aDR(aR->Value(aR->Lower()), aR->Value(aR->Lower() + 1), aR->Value(aR->Lower() + 2));
gp_Ax2 anAx(aL, aD, aDR);
anObj->SetPlane(anAx);
}
Handle(TDataXtd_Point) aPntTextAttr;
if (Label().FindChild(ChildLab_PntText).FindAttribute(TDataXtd_Point::GetID(), aPntTextAttr))
Handle(TDataStd_RealArray) aPntText;
if (Label().FindChild(ChildLab_PntText).FindAttribute(TDataStd_RealArray::GetID(), aPntText) && aPntText->Length() == 3)
{
gp_Pnt aPoint;
TDataXtd_Geometry::Point(aPntTextAttr->Label(), aPoint);
anObj->SetPointTextAttach(aPoint);
gp_Pnt aP(aPntText->Value(aPntText->Lower()), aPntText->Value(aPntText->Lower() + 1), aPntText->Value(aPntText->Lower() + 2));
anObj->SetPointTextAttach(aP);
}
Handle(TNaming_NamedShape) aNS;

View File

@ -23,7 +23,6 @@
#include <TDataStd_Real.hxx>
#include <TDataXtd_Geometry.hxx>
#include <TDataXtd_Plane.hxx>
#include <TDataXtd_Point.hxx>
#include <XCAFDimTolObjects_GeomToleranceObject.hxx>
#include <TNaming_Tool.hxx>
#include <TNaming_Builder.hxx>
@ -42,8 +41,12 @@ enum ChildLab
ChildLab_ValueOfZoneModif,
ChildLab_Modifiers,
ChildLab_aMaxValueModif,
ChildLab_Axis,
ChildLab_Plane,
ChildLab_AxisLoc,
ChildLab_AxisN,
ChildLab_AxisRef,
ChildLab_PlaneLoc,
ChildLab_PlaneN,
ChildLab_PlaneRef,
ChildLab_Pnt,
ChildLab_PntText,
ChildLab_Presentation,
@ -147,22 +150,78 @@ void XCAFDoc_GeomTolerance::SetObject (const Handle(XCAFDimTolObjects_GeomTolera
if (theObject->HasAxis())
{
TDataXtd_Plane::Set(Label().FindChild(ChildLab_Axis), gp_Pln(gp_Ax3(theObject->GetPlane())));
gp_Ax2 anAx = theObject->GetAxis();
Handle(TColStd_HArray1OfReal) aLocArr = new TColStd_HArray1OfReal(1, 3);
for (Standard_Integer i = 1; i <= 3; i++)
aLocArr->SetValue(i, anAx.Location().Coord(i));
Handle(TDataStd_RealArray) aLoc = TDataStd_RealArray::Set(Label().FindChild(ChildLab_AxisLoc), 1, 3);
if (!aLoc.IsNull())
aLoc->ChangeArray(aLocArr);
Handle(TColStd_HArray1OfReal) aNArr = new TColStd_HArray1OfReal(1, 3);
for (Standard_Integer i = 1; i <= 3; i++)
aNArr->SetValue(i, anAx.Direction().Coord(i));
Handle(TDataStd_RealArray) aN = TDataStd_RealArray::Set(Label().FindChild(ChildLab_AxisN), 1, 3);
if (!aN.IsNull())
aN->ChangeArray(aNArr);
Handle(TColStd_HArray1OfReal) aRArr = new TColStd_HArray1OfReal(1, 3);
for (Standard_Integer i = 1; i <= 3; i++)
aRArr->SetValue(i, anAx.XDirection().Coord(i));
Handle(TDataStd_RealArray) aR = TDataStd_RealArray::Set(Label().FindChild(ChildLab_AxisRef), 1, 3);
if (!aR.IsNull())
aR->ChangeArray(aRArr);
}
if (theObject->HasPlane())
{
TDataXtd_Plane::Set(Label().FindChild(ChildLab_Plane), gp_Pln(gp_Ax3(theObject->GetPlane())));
gp_Ax2 anAx = theObject->GetPlane();
Handle(TColStd_HArray1OfReal) aLocArr = new TColStd_HArray1OfReal(1, 3);
for (Standard_Integer i = 1; i <= 3; i++)
aLocArr->SetValue(i, anAx.Location().Coord(i));
Handle(TDataStd_RealArray) aLoc = TDataStd_RealArray::Set(Label().FindChild(ChildLab_PlaneLoc), 1, 3);
if (!aLoc.IsNull())
aLoc->ChangeArray(aLocArr);
Handle(TColStd_HArray1OfReal) aNArr = new TColStd_HArray1OfReal(1, 3);
for (Standard_Integer i = 1; i <= 3; i++)
aNArr->SetValue(i, anAx.Direction().Coord(i));
Handle(TDataStd_RealArray) aN = TDataStd_RealArray::Set(Label().FindChild(ChildLab_PlaneN), 1, 3);
if (!aN.IsNull())
aN->ChangeArray(aNArr);
Handle(TColStd_HArray1OfReal) aRArr = new TColStd_HArray1OfReal(1, 3);
for (Standard_Integer i = 1; i <= 3; i++)
aRArr->SetValue(i, anAx.XDirection().Coord(i));
Handle(TDataStd_RealArray) aR = TDataStd_RealArray::Set(Label().FindChild(ChildLab_PlaneRef), 1, 3);
if (!aR.IsNull())
aR->ChangeArray(aRArr);
}
if (theObject->HasPoint())
{
TDataXtd_Point::Set(Label().FindChild(ChildLab_Pnt), theObject->GetPoint());
gp_Pnt aPnt = theObject->GetPoint();
Handle(TColStd_HArray1OfReal) aLocArr = new TColStd_HArray1OfReal(1, 3);
for (Standard_Integer i = 1; i <= 3; i++)
aLocArr->SetValue(i, aPnt.Coord(i));
Handle(TDataStd_RealArray) aLoc = TDataStd_RealArray::Set(Label().FindChild(ChildLab_Pnt), 1, 3);
if (!aLoc.IsNull())
aLoc->ChangeArray(aLocArr);
}
if (theObject->HasPointText())
{
TDataXtd_Point::Set(Label().FindChild(ChildLab_PntText), theObject->GetPointTextAttach());
gp_Pnt aPntText = theObject->GetPointTextAttach();
Handle(TColStd_HArray1OfReal) aLocArr = new TColStd_HArray1OfReal(1, 3);
for (Standard_Integer i = 1; i <= 3; i++)
aLocArr->SetValue(i, aPntText.Coord(i));
Handle(TDataStd_RealArray) aLoc = TDataStd_RealArray::Set(Label().FindChild(ChildLab_PntText), 1, 3);
if (!aLoc.IsNull())
aLoc->ChangeArray(aLocArr);
}
TopoDS_Shape aPresentation = theObject->GetPresentation();
@ -258,38 +317,43 @@ Handle(XCAFDimTolObjects_GeomToleranceObject) XCAFDoc_GeomTolerance::GetObject()
anObj->SetMaxValueModifier(aMaxValueModif->Get());
}
Handle(TDataXtd_Plane) anAxisAttr;
if (Label().FindChild(ChildLab_Axis).FindAttribute(TDataXtd_Plane::GetID(), anAxisAttr))
Handle(TDataStd_RealArray) aLoc;
Handle(TDataStd_RealArray) aN;
Handle(TDataStd_RealArray) aR;
if (Label().FindChild(ChildLab_AxisLoc).FindAttribute(TDataStd_RealArray::GetID(), aLoc) && aLoc->Length() == 3 &&
Label().FindChild(ChildLab_AxisN).FindAttribute(TDataStd_RealArray::GetID(), aN) && aN->Length() == 3 &&
Label().FindChild(ChildLab_AxisRef).FindAttribute(TDataStd_RealArray::GetID(), aR) && aR->Length() == 3)
{
gp_Pln aPlane;
TDataXtd_Geometry::Plane(anAxisAttr->Label(), aPlane);
gp_Ax2 anAx(aPlane.Location(), aPlane.Axis().Direction(), aPlane.XAxis().Direction());
gp_Pnt aL(aLoc->Value(aLoc->Lower()), aLoc->Value(aLoc->Lower() + 1), aLoc->Value(aLoc->Lower() + 2));
gp_Dir aD(aN->Value(aN->Lower()), aN->Value(aN->Lower() + 1), aN->Value(aN->Lower() + 2));
gp_Dir aDR(aR->Value(aR->Lower()), aR->Value(aR->Lower() + 1), aR->Value(aR->Lower() + 2));
gp_Ax2 anAx(aL, aD, aDR);
anObj->SetAxis(anAx);
}
Handle(TDataXtd_Plane) aPlaneAttr;
if (Label().FindChild(ChildLab_Plane).FindAttribute(TDataXtd_Plane::GetID(), aPlaneAttr))
if (Label().FindChild(ChildLab_PlaneLoc).FindAttribute(TDataStd_RealArray::GetID(), aLoc) && aLoc->Length() == 3 &&
Label().FindChild(ChildLab_PlaneN).FindAttribute(TDataStd_RealArray::GetID(), aN) && aN->Length() == 3 &&
Label().FindChild(ChildLab_PlaneRef).FindAttribute(TDataStd_RealArray::GetID(), aR) && aR->Length() == 3)
{
gp_Pln aPlane;
TDataXtd_Geometry::Plane(aPlaneAttr->Label(), aPlane);
gp_Ax2 anAx(aPlane.Location(), aPlane.Axis().Direction(), aPlane.XAxis().Direction());
gp_Pnt aL(aLoc->Value(aLoc->Lower()), aLoc->Value(aLoc->Lower() + 1), aLoc->Value(aLoc->Lower() + 2));
gp_Dir aD(aN->Value(aN->Lower()), aN->Value(aN->Lower() + 1), aN->Value(aN->Lower() + 2));
gp_Dir aDR(aR->Value(aR->Lower()), aR->Value(aR->Lower() + 1), aR->Value(aR->Lower() + 2));
gp_Ax2 anAx(aL, aD, aDR);
anObj->SetPlane(anAx);
}
Handle(TDataXtd_Point) aPntAttr;
if (Label().FindChild(ChildLab_Pnt).FindAttribute(TDataXtd_Point::GetID(), aPntAttr))
Handle(TDataStd_RealArray) aPnt;
if (Label().FindChild(ChildLab_Pnt).FindAttribute(TDataStd_RealArray::GetID(), aPnt) && aPnt->Length() == 3)
{
gp_Pnt aPoint;
TDataXtd_Geometry::Point(aPntAttr->Label(), aPoint);
anObj->SetPoint(aPoint);
gp_Pnt aP(aLoc->Value(aPnt->Lower()), aPnt->Value(aPnt->Lower() + 1), aPnt->Value(aPnt->Lower() + 2));
anObj->SetPoint(aP);
}
Handle(TDataXtd_Point) aPntTextAttr;
if (Label().FindChild(ChildLab_PntText).FindAttribute(TDataXtd_Point::GetID(), aPntTextAttr))
Handle(TDataStd_RealArray) aPntText;
if (Label().FindChild(ChildLab_PntText).FindAttribute(TDataStd_RealArray::GetID(), aPntText) && aPntText->Length() == 3)
{
gp_Pnt aPoint;
TDataXtd_Geometry::Point(aPntTextAttr->Label(), aPoint);
anObj->SetPointTextAttach(aPoint);
gp_Pnt aP(aPntText->Value(aPntText->Lower()), aPntText->Value(aPntText->Lower() + 1), aPntText->Value(aPntText->Lower() + 2));
anObj->SetPointTextAttach(aP);
}
Handle(TNaming_NamedShape) aNS;

View File

@ -19,4 +19,4 @@ XSetDimensionDir D 0:1:4:1 1 1 0
set c_value "6"
set c_type "Location_Oriented"
set c_plusminus "lower -0.001 upper 0.002"
set c_dir "0.70710678118654746;0.70710678118654746;0"
set c_dir "0.70710678118654757;0.70710678118654757;0"