From: gka Date: Mon, 18 Jan 2016 12:18:50 +0000 (+0300) Subject: Implementation presentations of the PMI read from STEP X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=ccc8b4232148bf666e301c4414285b19c7915431;p=occt-copy.git Implementation presentations of the PMI read from STEP --- diff --git a/src/STEPCAFControl/STEPCAFControl_Reader.cxx b/src/STEPCAFControl/STEPCAFControl_Reader.cxx index 3b9d9aa4b6..ff62c27c52 100644 --- a/src/STEPCAFControl/STEPCAFControl_Reader.cxx +++ b/src/STEPCAFControl/STEPCAFControl_Reader.cxx @@ -244,6 +244,8 @@ #include #include #include +#include +#include // skl 21.08.2003 for reading G&DT //#include @@ -1864,17 +1866,18 @@ TopoDS_Shape readAnnotation(const Handle(XSControl_TransferReader)& theTR, aB.MakeCompound(aResAnnotation); Standard_Integer i =0; + Bnd_Box aBox; for( ; i < anAnnotations.Length(); i++) { Handle(StepVisual_StyledItem) anItem = anAnnotations(i); theName = anItem->Name(); //debug name of dimension==================== - TCollection_AsciiString aCurName = theName.IsNull() ? + /* TCollection_AsciiString aCurName = theName.IsNull() ? (TCollection_AsciiString("Size") + TCollection_AsciiString(numsize++)) : theName->String(); aCurName += "_"; aCurName += TCollection_AsciiString(i); - aCurName += ".brep"; + aCurName += ".brep";*/ //======================== Handle(StepVisual_AnnotationCurveOccurrence) anACO = Handle(StepVisual_AnnotationCurveOccurrence)::DownCast(anItem); @@ -1894,26 +1897,29 @@ TopoDS_Shape readAnnotation(const Handle(XSControl_TransferReader)& theTR, } } - - //if (aCurveItem->IsKind(STANDARD_TYPE(StepShape_GeometricCurveSet))) { - // Handle(StepShape_GeometricCurveSet) aCurveSet = - // Handle(StepShape_GeometricCurveSet)::DownCast(aCurveItem); - - - - // Standard_Integer i = 1; - // for ( ; i <= aCurveSet->NbElements() && aCurve.IsNull(); i++) { - // aCurve = Handle(StepGeom_Polyline)::DownCast(aCurveSet->ElementsValue(i).Curve()); - // } - // if (isDimLoc) { - // for ( ; i <= aCurveSet->NbElements() && aCurve2.IsNull(); i++) { - // aCurve2 = Handle(StepGeom_Polyline)::DownCast(aCurveSet->ElementsValue(i).Curve()); - // } - // } - //} - //else { - // aCurve = Handle(StepGeom_Polyline)::DownCast(aCurveItem); - //} + + // //get text attacment point + //// if( i == anAnnotations.Length() -1) + //// { + // if (aCurveItem->IsKind(STANDARD_TYPE(StepShape_GeometricCurveSet))) + // { + // Handle(StepShape_GeometricCurveSet) aCurveSet = + // Handle(StepShape_GeometricCurveSet)::DownCast(aCurveItem); + + // Standard_Integer n = 1; + // for ( ; n <= aCurveSet->NbElements() && aCurve.IsNull(); n++) + // { + // aCurve = Handle(StepGeom_Polyline)::DownCast(aCurveSet->ElementsValue(n).Curve()); + // } + // if (isDimLoc) { + // for ( ; i <= aCurveSet->NbElements() && aCurve2.IsNull(); i++) { + // aCurve2 = Handle(StepGeom_Polyline)::DownCast(aCurveSet->ElementsValue(i).Curve()); + // } + // } + // } + // else { + // aCurve = Handle(StepGeom_Polyline)::DownCast(aCurveItem); + // } //isDimLoc = isDimLoc && !aCurve2.IsNull() && aCurve2->NbPoints() > 0; @@ -1956,14 +1962,12 @@ TopoDS_Shape readAnnotation(const Handle(XSControl_TransferReader)& theTR, isDimLoc = !aPoints.IsNull() && aPoints->Length() > 0; if( isDimLoc) { - //debug + NCollection_Handle aCurves = aTessCurve->Curves(); Standard_Integer aNbC = (aCurves.IsNull() ? 0 : aCurves->Length()); - //BRep_Builder aB; TopoDS_Compound aComp; aB.MakeCompound(aComp); - // TopoDS_Wire aCurW; - //aB.MakeWire(aCurW); + Standard_Integer k = 0; for( ; k < aNbC; k++) { @@ -1994,57 +1998,51 @@ TopoDS_Shape readAnnotation(const Handle(XSControl_TransferReader)& theTR, anAnotationShape = aComp; } - - //// - // aXYZ1 += aPoints->Value(1); - // aXYZ2 += aPoints->Value(aPoints->Length()); - // nbP++; } if(!anAnotationShape.IsNull()) { - aCurName.RemoveAll(' '); + //aCurName.RemoveAll(' '); //BRepTools::Write(anAnotationShape, aCurName.ToCString()); + aB.Add(aResAnnotation, anAnotationShape); + if( i == anAnnotations.Length()-1) + BRepBndLib::AddClose(anAnotationShape, aBox); } - /*if(nbP) - { - aPoint = gp_Pnt(aXYZ1/ nbP); - aPoint2 = gp_Pnt(aXYZ2/ nbP); - }*/ + + } + + gp_Pnt aPtext(0.,0.,0.); + if( !aBox.IsVoid()) + { + Standard_Real aXmin, aYmin, aZmin,aXmax, aYmax, aZmax; + aBox.Get(aXmin, aYmin, aZmin,aXmax, aYmax, aZmax); + aPtext = gp_Pnt((aXmin + aXmax) *0.5, (aYmin + aYmax) *0.5, (aZmin + aZmax) *0.5); + //TopoDS_Vertex aV1; + //debug add point of text location + //aB.MakeVertex(aV1, aPtext , 0); + //aB.Add(aResAnnotation,aV1); + //Handle(TColgp_HArray1OfPnt) aPnts = new TColgp_HArray1OfPnt(1, 1); + //aPnts->SetValue(1, aP); } - ////////////////////// - // set point to XCAF - /* if (theDimObject->IsKind(STANDARD_TYPE(XCAFDimTolObjects_DimensionObject))) + if (theDimObject->IsKind(STANDARD_TYPE(XCAFDimTolObjects_DimensionObject))) { Handle(XCAFDimTolObjects_DimensionObject) anObj = Handle(XCAFDimTolObjects_DimensionObject)::DownCast(theDimObject); - - Handle(TColgp_HArray1OfPnt) aPnts; - if (isDimLoc) - aPnts = new TColgp_HArray1OfPnt(1, 2); - else - aPnts = new TColgp_HArray1OfPnt(1, 1); - aPnts->SetValue(1, aPoint); - if (isDimLoc) - { - aPnts->SetValue(1, aPoint); - aPnts->SetValue(2, aPoint2); - } - - anObj->SetPoints(aPnts); + anObj->SetPointTextAttach(aPtext); + } else if (theDimObject->IsKind(STANDARD_TYPE(XCAFDimTolObjects_DatumObject))) { Handle(XCAFDimTolObjects_DatumObject) anObj = Handle(XCAFDimTolObjects_DatumObject)::DownCast(theDimObject); - anObj->SetPoint(aPoint); + anObj->SetPointTextAttach(aPtext); } else if (theDimObject->IsKind(STANDARD_TYPE(XCAFDimTolObjects_GeomToleranceObject))) { Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = Handle(XCAFDimTolObjects_GeomToleranceObject)::DownCast(theDimObject); - anObj->SetPoint(aPoint); - }*/ + anObj->SetPointTextAttach(aPtext); + } return aResAnnotation; } @@ -2343,11 +2341,14 @@ static Standard_Boolean setDatumToXCAF(const Handle(StepDimTol_Datum)& theDat, Handle(TCollection_HAsciiString) aName; TopoDS_Shape anAnnotation = readAnnotation(aTR, aSAR->RelatingShapeAspect(), aDatObj,aName); - TDF_Label aL = aSTool->AddShape(anAnnotation, Standard_False); - if( !aName.IsNull() && !aL.IsNull()) + TDF_Label aPresentLabel = aSTool->AddShape(anAnnotation, Standard_False); + TDF_Label aDatL = aDat->Label(); + if( !aPresentLabel.IsNull()) + aDGTTool->SetPresentation( aDatL, aPresentLabel); + if( !aName.IsNull() && !aPresentLabel.IsNull()) { TCollection_ExtendedString str ( aName->String() ); - TDataStd_Name::Set ( aL, str ); + TDataStd_Name::Set ( aPresentLabel, str ); } aDat->SetObject(aDatObj); @@ -3314,22 +3315,27 @@ static void setDimObjectToXCAF(const Handle(Standard_Transient)& theEnt, } aDimObj->SetType(aType); - Handle(TCollection_HAsciiString) anAnnotName; - - TopoDS_Shape anAnnotation = readAnnotation(aTR, theEnt, aDimObj, anAnnotName); - aSTool->AddShape(anAnnotation, Standard_False); - - TDF_Label aL = aSTool->AddShape(anAnnotation, Standard_False); - if( !anAnnotName.IsNull() && !aL.IsNull()) - { - TCollection_ExtendedString str ( anAnnotName->String() ); - TDataStd_Name::Set ( aL, str ); - } + if(!aDimObj.IsNull()) { + Handle(XCAFDoc_Dimension) aDim; + if(aDimL.FindAttribute(XCAFDoc_Dimension::GetID(),aDim)) { + Handle(TCollection_HAsciiString) anAnnotName; + + TopoDS_Shape anAnnotation = readAnnotation(aTR, theEnt, aDimObj, anAnnotName); + aSTool->AddShape(anAnnotation, Standard_False); + + TDF_Label aPresentLabel = aSTool->AddShape(anAnnotation, Standard_False); + if( !aPresentLabel.IsNull()) + aDGTTool->SetPresentation( aDimL, aPresentLabel); + if( !anAnnotName.IsNull() && !aPresentLabel.IsNull()) + { + TCollection_ExtendedString str ( anAnnotName->String() ); + TDataStd_Name::Set ( aPresentLabel, str ); + } aDim->SetObject(aDimObj); } } @@ -3598,6 +3604,8 @@ static void setGeomTolObjectToXCAF(const Handle(Standard_Transient)& theEnt, TopoDS_Shape anAnnotation = readAnnotation(aTR, theEnt, aTolObj, aName); TDF_Label aL = aSTool->AddShape(anAnnotation, Standard_False); + if( !aL.IsNull()) + aDGTTool->SetPresentation(aGTol->Label(), aL); if( !aName.IsNull() && !aL.IsNull()) { TCollection_ExtendedString str ( aName->String() ); diff --git a/src/XCAFDimTolObjects/XCAFDimTolObjects_DatumObject.cxx b/src/XCAFDimTolObjects/XCAFDimTolObjects_DatumObject.cxx index 884444db4d..652334046e 100644 --- a/src/XCAFDimTolObjects/XCAFDimTolObjects_DatumObject.cxx +++ b/src/XCAFDimTolObjects/XCAFDimTolObjects_DatumObject.cxx @@ -26,7 +26,7 @@ XCAFDimTolObjects_DatumObject::XCAFDimTolObjects_DatumObject() myIsDTarget = Standard_False; myHasPlane = Standard_False; myHasPnt = Standard_False; - myHasPnt2 = Standard_False; + myHasPntText = Standard_False; } //======================================================================= @@ -46,10 +46,10 @@ XCAFDimTolObjects_DatumObject::XCAFDimTolObjects_DatumObject(const Handle(XCAFDi myDTargetType = theObj->myDTargetType; myPlane = theObj->myPlane; myPnt= theObj->myPnt; - myPnt2= theObj->myPnt2; + myPntText= theObj->myPntText; myHasPlane = theObj->myHasPlane; myHasPnt = theObj->myHasPnt; - myHasPnt2 = theObj->myHasPnt2; + myHasPntText = theObj->myHasPntText; } //======================================================================= diff --git a/src/XCAFDimTolObjects/XCAFDimTolObjects_DatumObject.hxx b/src/XCAFDimTolObjects/XCAFDimTolObjects_DatumObject.hxx index 2eeecc6dd0..f6b719f1cd 100644 --- a/src/XCAFDimTolObjects/XCAFDimTolObjects_DatumObject.hxx +++ b/src/XCAFDimTolObjects/XCAFDimTolObjects_DatumObject.hxx @@ -105,21 +105,31 @@ public: myHasPnt = Standard_True; } - const gp_Pnt& GetPoint() const { return myPnt; } + const gp_Pnt& GetPoint() const + { + return myPnt; + } - void SetPoint2 (const gp_Pnt& thePnt) + + void SetPointTextAttach (const gp_Pnt& thePntText) { - myPnt2 = thePnt; - myHasPnt2 = Standard_True; + myPntText = thePntText; + myHasPntText = Standard_True; } - const gp_Pnt& GetPoint2() const { return myPnt2; } + const gp_Pnt& GetPointTextAttach() const + { + return myPntText; + } Standard_Boolean HasPlane() const { return myHasPlane; } Standard_Boolean HasPoint() const { return myHasPnt; } - Standard_Boolean HasPoint2() const { return myHasPnt2; } + Standard_Boolean HasTextPoint() const + { + return myHasPntText; + } DEFINE_STANDARD_RTTIEXT(XCAFDimTolObjects_DatumObject,Standard_Transient) @@ -139,10 +149,10 @@ private: Standard_Integer myDatumTargetNumber; gp_Ax2 myPlane; gp_Pnt myPnt; - gp_Pnt myPnt2; + gp_Pnt myPntText; Standard_Boolean myHasPlane; Standard_Boolean myHasPnt; - Standard_Boolean myHasPnt2; + Standard_Boolean myHasPntText; }; #endif // _XCAFDimTolObjects_DatumObject_HeaderFile diff --git a/src/XCAFDimTolObjects/XCAFDimTolObjects_DimensionObject.cxx b/src/XCAFDimTolObjects/XCAFDimTolObjects_DimensionObject.cxx index 78b2eea3ce..8a053ba738 100644 --- a/src/XCAFDimTolObjects/XCAFDimTolObjects_DimensionObject.cxx +++ b/src/XCAFDimTolObjects/XCAFDimTolObjects_DimensionObject.cxx @@ -27,7 +27,7 @@ IMPLEMENT_STANDARD_RTTIEXT(XCAFDimTolObjects_DimensionObject,Standard_Transient) XCAFDimTolObjects_DimensionObject::XCAFDimTolObjects_DimensionObject() { myHasPlane = Standard_False; - myHasPnt2 = Standard_False; + myHasPntText = Standard_False; } //======================================================================= @@ -49,10 +49,10 @@ XCAFDimTolObjects_DimensionObject::XCAFDimTolObjects_DimensionObject(const Handl myPath = theObj->myPath; myDir = theObj->myDir; myPnts = theObj->myPnts; - myPnt2= theObj->myPnt2; + myPntText= theObj->myPntText; myHasPlane = theObj->myHasPlane; myPlane = theObj->myPlane; - myHasPnt2 = theObj->myHasPnt2; + myHasPntText = theObj->myHasPntText; } //======================================================================= diff --git a/src/XCAFDimTolObjects/XCAFDimTolObjects_DimensionObject.hxx b/src/XCAFDimTolObjects/XCAFDimTolObjects_DimensionObject.hxx index 3549cfbf4e..f5346c8a09 100644 --- a/src/XCAFDimTolObjects/XCAFDimTolObjects_DimensionObject.hxx +++ b/src/XCAFDimTolObjects/XCAFDimTolObjects_DimensionObject.hxx @@ -117,13 +117,13 @@ public: Standard_EXPORT void SetPoints (const Handle(TColgp_HArray1OfPnt)& thePnts); - void SetPoint2 (const gp_Pnt& thePnt) + void SetPointTextAttach (const gp_Pnt& thePntText) { - myPnt2 = thePnt; - myHasPnt2 = Standard_True; + myPntText = thePntText; + myHasPntText = Standard_True; } - const gp_Pnt& GetPoint2() const { return myPnt2; } + const gp_Pnt& GetPointTextAttach() const { return myPntText; } void SetPlane (const gp_Ax2& thePlane) { @@ -137,7 +137,7 @@ public: Standard_Boolean HasPoints() const { return (!myPnts.IsNull() && myPnts->Length() > 0); } - Standard_Boolean HasPoint2() const { return myHasPnt2; } + Standard_Boolean HasPoint2() const { return myHasPntText; } DEFINE_STANDARD_RTTIEXT(XCAFDimTolObjects_DimensionObject,Standard_Transient) @@ -155,10 +155,11 @@ private: TopoDS_Edge myPath; gp_Dir myDir; Handle(TColgp_HArray1OfPnt) myPnts; - gp_Pnt myPnt2; gp_Ax2 myPlane; Standard_Boolean myHasPlane; - Standard_Boolean myHasPnt2; + Standard_Boolean myHasPnt; + Standard_Boolean myHasPntText; + gp_Pnt myPntText; }; diff --git a/src/XCAFDimTolObjects/XCAFDimTolObjects_GeomToleranceObject.cxx b/src/XCAFDimTolObjects/XCAFDimTolObjects_GeomToleranceObject.cxx index 91e7a08e77..f1e5c77dd0 100644 --- a/src/XCAFDimTolObjects/XCAFDimTolObjects_GeomToleranceObject.cxx +++ b/src/XCAFDimTolObjects/XCAFDimTolObjects_GeomToleranceObject.cxx @@ -25,7 +25,7 @@ XCAFDimTolObjects_GeomToleranceObject::XCAFDimTolObjects_GeomToleranceObject() myHasAxis = Standard_False; myHasPlane = Standard_False; myHasPnt = Standard_False; - myHasPnt2 = Standard_False; + myHasPntText = Standard_False; } //======================================================================= @@ -47,10 +47,10 @@ XCAFDimTolObjects_GeomToleranceObject::XCAFDimTolObjects_GeomToleranceObject(con myHasAxis = theObj->myHasAxis; myPlane = theObj->myPlane; myPnt= theObj->myPnt; - myPnt2= theObj->myPnt2; + myPntText= theObj->myPntText; myHasPlane = theObj->myHasPlane; myHasPnt = theObj->myHasPnt; - myHasPnt2 = theObj->myHasPnt2; + myHasPntText = theObj->myHasPntText; } //======================================================================= diff --git a/src/XCAFDimTolObjects/XCAFDimTolObjects_GeomToleranceObject.hxx b/src/XCAFDimTolObjects/XCAFDimTolObjects_GeomToleranceObject.hxx index 42ce2c1848..b5fef8bdb5 100644 --- a/src/XCAFDimTolObjects/XCAFDimTolObjects_GeomToleranceObject.hxx +++ b/src/XCAFDimTolObjects/XCAFDimTolObjects_GeomToleranceObject.hxx @@ -100,19 +100,24 @@ public: const gp_Pnt& GetPoint() const { return myPnt; } - void SetPoint2 (const gp_Pnt& thePnt) + void SetPointTextAttach (const gp_Pnt& thePntText) { - myPnt2 = thePnt; - myHasPnt2 = Standard_True; + myPntText = thePntText; + myHasPntText = Standard_True; } - const gp_Pnt& GetPoint2() const { return myPnt2; } - + const gp_Pnt& GetPointTextAttach() const + { + return myPntText; + } Standard_Boolean HasPlane() const { return myHasPlane; } Standard_Boolean HasPoint() const { return myHasPnt; } - Standard_Boolean HasPoint2() const { return myHasPnt2; } + Standard_Boolean HasPointText() const + { + return myHasPntText; + } DEFINE_STANDARD_RTTIEXT(XCAFDimTolObjects_GeomToleranceObject,Standard_Transient) @@ -130,10 +135,10 @@ private: Standard_Boolean myHasAxis; gp_Ax2 myPlane; gp_Pnt myPnt; - gp_Pnt myPnt2; + gp_Pnt myPntText;; Standard_Boolean myHasPlane; Standard_Boolean myHasPnt; - Standard_Boolean myHasPnt2; + Standard_Boolean myHasPntText; }; diff --git a/src/XCAFDoc/XCAFDoc_Datum.cxx b/src/XCAFDoc/XCAFDoc_Datum.cxx index 755a92711d..0f1503e501 100644 --- a/src/XCAFDoc/XCAFDoc_Datum.cxx +++ b/src/XCAFDoc/XCAFDoc_Datum.cxx @@ -52,7 +52,8 @@ enum ChildLab ChildLab_PlaneN, ChildLab_PlaneRef, ChildLab_Pnt, - ChildLab_Pnt2, + ChildLab_PntText, + ChildLab_Presentation }; //======================================================================= @@ -327,17 +328,17 @@ void XCAFDoc_Datum::SetObject(const Handle(XCAFDimTolObjects_DatumObject)& theOb Label().FindChild(ChildLab_Pnt).AddAttribute(aLoc); } - if (theObject->HasPoint2()) + if (theObject->HasTextPoint()) { Handle(TDataStd_RealArray) aLoc = new TDataStd_RealArray(); - gp_Pnt aPnt2 = theObject->GetPoint2(); + 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, aPnt2.Coord(i)); + aLocArr->SetValue(i, aPntText.Coord(i)); aLoc->ChangeArray(aLocArr); - Label().FindChild(ChildLab_Pnt2).AddAttribute(aLoc); + Label().FindChild(ChildLab_PntText).AddAttribute(aLoc); } } @@ -402,11 +403,11 @@ Handle(XCAFDimTolObjects_DatumObject) XCAFDoc_Datum::GetObject() const anObj->SetPoint(aP); } - Handle(TDataStd_RealArray) aPnt2; - if(Label().FindChild(ChildLab_Pnt2).FindAttribute(TDataStd_RealArray::GetID(), aPnt2) && aPnt2->Length() == 3 ) + Handle(TDataStd_RealArray) aPntText; + if(Label().FindChild(ChildLab_PntText).FindAttribute(TDataStd_RealArray::GetID(), aPntText) && aPntText->Length() == 3 ) { - gp_Pnt aP (aPnt2->Value(aPnt2->Lower()), aPnt2->Value(aPnt2->Lower()+1), aPnt2->Value(aPnt2->Lower()+2)); - anObj->SetPoint2(aP); + gp_Pnt aP (aPntText->Value(aPntText->Lower()), aPntText->Value(aPntText->Lower()+1), aPntText->Value(aPntText->Lower()+2)); + anObj->SetPointTextAttach(aP); } Handle(TDataStd_Integer) aIsDTarget; diff --git a/src/XCAFDoc/XCAFDoc_DimTolTool.cxx b/src/XCAFDoc/XCAFDoc_DimTolTool.cxx index 8267f03d76..df186812bd 100644 --- a/src/XCAFDoc/XCAFDoc_DimTolTool.cxx +++ b/src/XCAFDoc/XCAFDoc_DimTolTool.cxx @@ -11,7 +11,7 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. - +#include #include #include #include @@ -34,6 +34,7 @@ #include #include + IMPLEMENT_STANDARD_RTTIEXT(XCAFDoc_DimTolTool,TDF_Attribute) //======================================================================= @@ -885,6 +886,62 @@ Standard_Boolean XCAFDoc_DimTolTool::GetTolerOfDatumLabels(const TDF_Label& theD return Standard_True; } +//======================================================================= +//function : SetPresentation +//purpose : +//======================================================================= +Standard_Boolean XCAFDoc_DimTolTool::SetPresentation(const TDF_Label& theDimLabel, const TopoDS_Shape& theShape) +{ + TDF_Label aShapeL; + if ( ! ShapeTool()->Search (theShape, aShapeL ) ) + return Standard_False; + SetPresentation( theDimLabel,aShapeL); + return Standard_True; +} + +//======================================================================= +//function : SetPresentation +//purpose : +//======================================================================= + +void XCAFDoc_DimTolTool::SetPresentation(const TDF_Label& theDimLabel, + const TDF_Label& theShapeLabel) +{ + Handle(TDataStd_TreeNode) refNode, mainNode; + mainNode = TDataStd_TreeNode::Set ( theDimLabel, XCAFDoc::ShapeRefGUID() ); + refNode = TDataStd_TreeNode::Set ( theShapeLabel, XCAFDoc::ShapeRefGUID() ); + refNode->Remove(); // abv: fix against bug in TreeNode::Append() + mainNode->Append(refNode); + +} + +//======================================================================= +//function : GetPresentation +//purpose : +//======================================================================= + +TopoDS_Shape XCAFDoc_DimTolTool::GetPresentation (const TDF_Label& theDimLabel) +{ + TDF_Label aPresentLabel = GetPresentationLabel ( theDimLabel); + TopoDS_Shape aShape; + if( !aPresentLabel.IsNull()) + aShape = ShapeTool()->GetShape(aPresentLabel); + return aShape; +} +//======================================================================= +//function : GetPresentation +//purpose : +//======================================================================= +TDF_Label XCAFDoc_DimTolTool::GetPresentationLabel(const TDF_Label& theDimLabel) +{ + TDF_Label aShapeLabel; + Handle(TDataStd_TreeNode) Node; + if ( ! theDimLabel.FindAttribute ( XCAFDoc::ShapeRefGUID(), Node) || + ! Node->HasFather() ) + return aShapeLabel; + aShapeLabel = Node->Father()->Label(); + return aShapeLabel; +} //======================================================================= //function : ID diff --git a/src/XCAFDoc/XCAFDoc_Dimension.cxx b/src/XCAFDoc/XCAFDoc_Dimension.cxx index 70224613c4..d3dfbeb4a0 100644 --- a/src/XCAFDoc/XCAFDoc_Dimension.cxx +++ b/src/XCAFDoc/XCAFDoc_Dimension.cxx @@ -45,7 +45,9 @@ enum ChildLab ChildLab_PlaneLoc, ChildLab_PlaneN, ChildLab_PlaneRef, - ChildLab_Pnt2, + ChildLab_PntText, + ChildLab_Presentation + }; //======================================================================= @@ -217,18 +219,21 @@ void XCAFDoc_Dimension::SetObject (const Handle(XCAFDimTolObjects_DimensionObjec Label().FindChild(ChildLab_PlaneRef).AddAttribute(aR); } - if (theObject->HasPoint2()) + if (theObject->HasTextPoint()) { Handle(TDataStd_RealArray) aLoc = new TDataStd_RealArray(); - gp_Pnt aPnt2 = theObject->GetPoint2(); + 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, aPnt2.Coord(i)); + aLocArr->SetValue(i, aPntText.Coord(i)); aLoc->ChangeArray(aLocArr); - Label().FindChild(ChildLab_Pnt2).AddAttribute(aLoc); + Label().FindChild(ChildLab_PntText).AddAttribute(aLoc); } + + + } //======================================================================= @@ -325,13 +330,18 @@ Handle(XCAFDimTolObjects_DimensionObject) XCAFDoc_Dimension::GetObject() const anObj->SetPlane(anAx); } - Handle(TDataStd_RealArray) aPnt2; - if(Label().FindChild(ChildLab_Pnt2).FindAttribute(TDataStd_RealArray::GetID(), aPnt2) && aPnt2->Length() == 3 ) + Handle(TDataStd_RealArray) aPntText; + if(Label().FindChild(ChildLab_PntText).FindAttribute(TDataStd_RealArray::GetID(), aPntText) && aPntText->Length() == 3 ) { - gp_Pnt aP(aPnt2->Value(aPnt2->Lower()), aPnt2->Value(aPnt2->Lower()+1), aPnt2->Value(aPnt2->Lower()+2)); - anObj->SetPoint2(aP); + gp_Pnt aP(aPntText->Value(aPntText->Lower()), aPntText->Value(aPntText->Lower()+1), aPntText->Value(aPntText->Lower()+2)); + anObj->SetPointTextAttach(aP); } + /* Handle(TNaming_NamedShape) NS; + TDF_Label aLPres = Label().FindChild( ChildLab_Presentation); + if ( ! aLPres.FindAttribute(TNaming_NamedShape::GetID(), NS) ) + return Standard_False; + TopoDS_Shape aPresShape = TNaming_Tool::GetShape(NS);*/ return anObj; } diff --git a/src/XCAFDoc/XCAFDoc_GeomTolerance.cxx b/src/XCAFDoc/XCAFDoc_GeomTolerance.cxx index 7c15323eb5..25166baee8 100644 --- a/src/XCAFDoc/XCAFDoc_GeomTolerance.cxx +++ b/src/XCAFDoc/XCAFDoc_GeomTolerance.cxx @@ -42,7 +42,8 @@ enum ChildLab ChildLab_PlaneN, ChildLab_PlaneRef, ChildLab_Pnt, - ChildLab_Pnt2, + ChildLab_PntText, + ChildLab_Presentation }; //======================================================================= @@ -221,17 +222,17 @@ void XCAFDoc_GeomTolerance::SetObject (const Handle(XCAFDimTolObjects_GeomTolera Label().FindChild(ChildLab_Pnt).AddAttribute(aLoc); } - if (theObject->HasPoint2()) + if (theObject->HasPointText()) { Handle(TDataStd_RealArray) aLoc = new TDataStd_RealArray(); - gp_Pnt aPnt2 = theObject->GetPoint2(); + 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, aPnt2.Coord(i)); + aLocArr->SetValue(i, aPntText.Coord(i)); aLoc->ChangeArray(aLocArr); - Label().FindChild(ChildLab_Pnt2).AddAttribute(aLoc); + Label().FindChild(ChildLab_PntText).AddAttribute(aLoc); } } @@ -328,11 +329,11 @@ Handle(XCAFDimTolObjects_GeomToleranceObject) XCAFDoc_GeomTolerance::GetObject() anObj->SetPoint(aP); } - Handle(TDataStd_RealArray) aPnt2; - if(Label().FindChild(ChildLab_Pnt2).FindAttribute(TDataStd_RealArray::GetID(), aPnt2) && aPnt2->Length() == 3 ) + Handle(TDataStd_RealArray) aPntText; + if(Label().FindChild(ChildLab_PntText).FindAttribute(TDataStd_RealArray::GetID(), aPntText) && aPntText->Length() == 3 ) { - gp_Pnt aP(aPnt2->Value(aPnt2->Lower()), aPnt2->Value(aPnt2->Lower()+1), aPnt2->Value(aPnt2->Lower()+2)); - anObj->SetPoint2(aP); + gp_Pnt aP(aPntText->Value(aPntText->Lower()), aPntText->Value(aPntText->Lower()+1), aPntText->Value(aPntText->Lower()+2)); + anObj->SetPointTextAttach(aP); } return anObj;