mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0027372: Import/Export dimension text position
Modify Import/Export STEP. Add Draw commands to set and get orientation and position of dimension text. Add Draw commands to set and get presentation. Add test.
This commit is contained in:
@@ -975,12 +975,12 @@ Handle(StepGeom_Axis2Placement3d) STEPCAFControl_GDTProperty::GetAxis2Placement3
|
||||
Handle(StepGeom_Direction) anAxis, aRefDirection;
|
||||
Handle(TColStd_HArray1OfReal) anAxisCoords = new TColStd_HArray1OfReal(1, 3);
|
||||
for (Standard_Integer i = 1; i <= 3; i++)
|
||||
anAxisCoords->SetValue(i, theAxis.Direction().Coord(i));
|
||||
anAxisCoords->SetValue(i, theAxis.XDirection().Coord(i));
|
||||
anAxis = new StepGeom_Direction();
|
||||
anAxis->Init(new TCollection_HAsciiString(), anAxisCoords);
|
||||
Handle(TColStd_HArray1OfReal) aDirCoords = new TColStd_HArray1OfReal(1, 3);
|
||||
for (Standard_Integer i = 1; i <= 3; i++)
|
||||
aDirCoords->SetValue(i, theAxis.XDirection().Coord(i));
|
||||
aDirCoords->SetValue(i, theAxis.YDirection().Coord(i));
|
||||
aRefDirection = new StepGeom_Direction();
|
||||
aRefDirection->Init(new TCollection_HAsciiString(), aDirCoords);
|
||||
anA2P3D->Init(new TCollection_HAsciiString(), aPoint, Standard_True, anAxis, Standard_True, aRefDirection);
|
||||
|
@@ -1805,27 +1805,21 @@ void readAnnotation(const Handle(XSControl_TransferReader)& theTR,
|
||||
if (theDimObject->IsKind(STANDARD_TYPE(XCAFDimTolObjects_DimensionObject))) {
|
||||
Handle(XCAFDimTolObjects_DimensionObject) anObj =
|
||||
Handle(XCAFDimTolObjects_DimensionObject)::DownCast(theDimObject);
|
||||
|
||||
Handle(TColgp_HArray1OfPnt) aPnts = new TColgp_HArray1OfPnt(1, 1);
|
||||
anObj->SetPlane(aPlaneAxes);
|
||||
|
||||
|
||||
}
|
||||
else if (theDimObject->IsKind(STANDARD_TYPE(XCAFDimTolObjects_DatumObject))) {
|
||||
Handle(XCAFDimTolObjects_DatumObject) anObj =
|
||||
Handle(XCAFDimTolObjects_DatumObject)::DownCast(theDimObject);
|
||||
anObj->SetPlane(aPlaneAxes);
|
||||
|
||||
}
|
||||
else if (theDimObject->IsKind(STANDARD_TYPE(XCAFDimTolObjects_GeomToleranceObject))) {
|
||||
Handle(XCAFDimTolObjects_GeomToleranceObject) anObj =
|
||||
Handle(XCAFDimTolObjects_GeomToleranceObject)::DownCast(theDimObject);
|
||||
anObj->SetPlane(aPlaneAxes);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Retrieve presentation
|
||||
Handle(StepVisual_AnnotationCurveOccurrence) anACO;
|
||||
NCollection_Vector<Handle(StepVisual_TessellatedAnnotationOccurrence)> aTesselations;
|
||||
@@ -1953,11 +1947,21 @@ void readAnnotation(const Handle(XSControl_TransferReader)& theTR,
|
||||
if(!nbShapes)
|
||||
return;
|
||||
gp_Pnt aPtext(0., 0., 0.);
|
||||
// if Annotation plane location inside bounding box set it to text position
|
||||
// else set the center of bounding box to text position
|
||||
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);
|
||||
if (isHasPlane && !aBox.IsOut(aPlaneAxes.Location())) {
|
||||
aPtext = aPlaneAxes.Location();
|
||||
}
|
||||
else {
|
||||
aPtext = gp_Pnt((aXmin + aXmax) * 0.5, (aYmin + aYmax) * 0.5, (aZmin + aZmax) * 0.5);
|
||||
}
|
||||
}
|
||||
else {
|
||||
aPtext = aPlaneAxes.Location();
|
||||
}
|
||||
|
||||
// set point to XCAF
|
||||
|
@@ -2322,6 +2322,7 @@ static Handle(StepRepr_ShapeAspect) WriteShapeAspect (const Handle(XSControl_Wor
|
||||
static void WritePresentation(const Handle(XSControl_WorkSession) &WS,
|
||||
const TopoDS_Shape thePresentation,
|
||||
const gp_Ax2 theAnnotationPlane,
|
||||
const gp_Pnt theTextPosition,
|
||||
const Handle(Standard_Transient) theDimension)
|
||||
{
|
||||
if (thePresentation.IsNull())
|
||||
@@ -2365,6 +2366,13 @@ static void WritePresentation(const Handle(XSControl_WorkSession) &WS,
|
||||
// Plane
|
||||
Handle(StepGeom_Plane) aPlane = new StepGeom_Plane();
|
||||
Handle(StepGeom_Axis2Placement3d) anAxis = STEPCAFControl_GDTProperty::GetAxis2Placement3D(theAnnotationPlane);
|
||||
// Set text position to plane origin
|
||||
Handle(StepGeom_CartesianPoint) aTextPos = new StepGeom_CartesianPoint();
|
||||
Handle(TColStd_HArray1OfReal) aCoords = new TColStd_HArray1OfReal(1, 3);
|
||||
for (Standard_Integer i = 1; i <= 3; i++)
|
||||
aCoords->SetValue(i, theTextPosition.Coord(i));
|
||||
aTextPos->Init(new TCollection_HAsciiString(), aCoords);
|
||||
anAxis->SetLocation(aTextPos);
|
||||
aPlane->Init(new TCollection_HAsciiString(), anAxis);
|
||||
// Annotation plane element
|
||||
StepVisual_AnnotationPlaneElement aPlaneElement;
|
||||
@@ -2576,7 +2584,7 @@ static Handle(StepDimTol_Datum) WriteDatumAP242(const Handle(XSControl_WorkSessi
|
||||
Model->AddWithRefs(aSDR);
|
||||
|
||||
//Annotation plane and Presentation
|
||||
WritePresentation(WS, anObject->GetPresentation(), anObject->GetPlane(), aSA);
|
||||
WritePresentation(WS, anObject->GetPresentation(), anObject->GetPlane(), anObject->GetPointTextAttach(), aSA);
|
||||
|
||||
return aDatum;
|
||||
}
|
||||
@@ -3187,7 +3195,7 @@ static void WriteGeomTolerance (const Handle(XSControl_WorkSession) &WS,
|
||||
Model->AddWithRefs(aGeomTol);
|
||||
WriteToleranceZone(WS, anObject, aGeomTol, theRC);
|
||||
//Annotation plane and Presentation
|
||||
WritePresentation(WS, anObject->GetPresentation(), anObject->GetPlane(), aGeomTol);
|
||||
WritePresentation(WS, anObject->GetPresentation(), anObject->GetPlane(), anObject->GetPointTextAttach(), aGeomTol);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -3747,7 +3755,7 @@ Standard_Boolean STEPCAFControl_Writer::WriteDGTsAP242 (const Handle(XSControl_W
|
||||
// Write values
|
||||
WriteDimValues(WS, anObject, aRC, aDimension);
|
||||
//Annotation plane and Presentation
|
||||
WritePresentation(WS, anObject->GetPresentation(), anObject->GetPlane(), aDimension.Value());
|
||||
WritePresentation(WS, anObject->GetPresentation(), anObject->GetPlane(), anObject->GetPointTextAttach(), aDimension.Value());
|
||||
}
|
||||
|
||||
//----------------------------//
|
||||
|
Reference in New Issue
Block a user