1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0027934: Data Exchange - implement STEP common labels

implement import/export
update test cases
This commit is contained in:
ika
2016-10-05 17:02:27 +03:00
committed by apn
parent 3f317e7d0c
commit 0b622d670d
26 changed files with 402 additions and 208 deletions

View File

@@ -521,7 +521,8 @@ Standard_Boolean STEPCAFControl_GDTProperty::GetDimType(const Handle(TCollection
theType = XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromInnerToInner;
}
if(theType != XCAFDimTolObjects_DimensionType_Location_None)
if(theType != XCAFDimTolObjects_DimensionType_Location_None &&
theType != XCAFDimTolObjects_DimensionType_CommonLabel)
{
return Standard_True;
}

View File

@@ -1765,6 +1765,191 @@ static Standard_Boolean GetMassConversionFactor(Handle(StepBasic_NamedUnit)& NU,
}
return Standard_True;
}
//=======================================================================
//function : readPMIPresentation
//purpose : read polyline or tessellated presentation for
// (Annotation_Curve_Occurrence or Draughting_Callout)
//=======================================================================
Standard_Boolean readPMIPresentation(const Handle(Standard_Transient)& thePresentEntity,
const Handle(XSControl_TransferReader)& theTR,
const Standard_Real theFact,
TopoDS_Shape& thePresentation,
Handle(TCollection_HAsciiString)& thePresentName,
Bnd_Box& theBox)
{
Handle(Transfer_TransientProcess) aTP = theTR->TransientProcess();
Handle(StepVisual_AnnotationCurveOccurrence) anACO;
NCollection_Vector<Handle(StepVisual_StyledItem)> anAnnotations;
if (thePresentEntity->IsKind(STANDARD_TYPE(StepVisual_AnnotationCurveOccurrence)))
{
anACO = Handle(StepVisual_AnnotationCurveOccurrence)::DownCast(thePresentEntity);
thePresentName = anACO->Name();
if (!anACO.IsNull())
anAnnotations.Append(anACO);
}
else if (thePresentEntity->IsKind(STANDARD_TYPE(StepVisual_DraughtingCallout)))
{
Handle(StepVisual_DraughtingCallout) aDCallout =
Handle(StepVisual_DraughtingCallout)::DownCast(thePresentEntity);
thePresentName = aDCallout->Name();
for (Standard_Integer i = 1; i <= aDCallout->NbContents() && anACO.IsNull(); i++) {
anACO = aDCallout->ContentsValue(i).AnnotationCurveOccurrence();
if (!anACO.IsNull())
{
anAnnotations.Append(anACO);
continue;
}
Handle(StepVisual_TessellatedAnnotationOccurrence) aTesselation =
aDCallout->ContentsValue(i).TessellatedAnnotationOccurrence();
if (!aTesselation.IsNull())
anAnnotations.Append(aTesselation);
}
}
if (!anAnnotations.Length())
return Standard_False;
BRep_Builder aB;
TopoDS_Compound aResAnnotation;
aB.MakeCompound(aResAnnotation);
Standard_Integer i = 0;
Bnd_Box aBox;
Standard_Integer nbShapes = 0;
for (; i < anAnnotations.Length(); i++)
{
Handle(StepVisual_StyledItem) anItem = anAnnotations(i);
anACO = Handle(StepVisual_AnnotationCurveOccurrence)::DownCast(anItem);
TopoDS_Shape anAnnotationShape;
if (!anACO.IsNull())
{
Handle(StepRepr_RepresentationItem) aCurveItem = anACO->Item();
anAnnotationShape = STEPConstruct::FindShape(aTP, aCurveItem);
if (anAnnotationShape.IsNull())
{
Handle(Transfer_Binder) binder = theTR->Actor()->Transfer(aCurveItem, aTP);
if (!binder.IsNull() && binder->HasResult()) {
anAnnotationShape = TransferBRep::ShapeResult(aTP, binder);
}
}
}
//case of tessellated entities
else
{
Handle(StepRepr_RepresentationItem) aTessItem = anItem->Item();
if (aTessItem.IsNull())
continue;
Handle(StepVisual_TessellatedGeometricSet) aTessSet = Handle(StepVisual_TessellatedGeometricSet)::DownCast(aTessItem);
if (aTessSet.IsNull())
continue;
NCollection_Handle<StepVisual_Array1OfTessellatedItem> aListItems = aTessSet->Items();
Standard_Integer nb = aListItems.IsNull() ? 0 : aListItems->Length();
Handle(StepVisual_TessellatedCurveSet) aTessCurve;
for (Standard_Integer n = 1; n <= nb && aTessCurve.IsNull(); n++)
{
aTessCurve = Handle(StepVisual_TessellatedCurveSet)::DownCast(aListItems->Value(n));
}
if (aTessCurve.IsNull())
continue;
Handle(StepVisual_CoordinatesList) aCoordList = aTessCurve->CoordList();
if (aCoordList.IsNull())
continue;
Handle(TColgp_HArray1OfXYZ) aPoints = aCoordList->Points();
if (aPoints.IsNull() || aPoints->Length() == 0)
continue;
NCollection_Handle<StepVisual_VectorOfHSequenceOfInteger> aCurves = aTessCurve->Curves();
Standard_Integer aNbC = (aCurves.IsNull() ? 0 : aCurves->Length());
TopoDS_Compound aComp;
aB.MakeCompound(aComp);
Standard_Integer k = 0;
for (; k < aNbC; k++)
{
Handle(TColStd_HSequenceOfInteger) anIndexes = aCurves->Value(k);
TopoDS_Wire aCurW;
aB.MakeWire(aCurW);
for (Standard_Integer n = 1; n < anIndexes->Length(); n++)
{
Standard_Integer ind = anIndexes->Value(n);
Standard_Integer indnext = anIndexes->Value(n + 1);
if (ind > aPoints->Length() || indnext > aPoints->Length())
continue;
gp_Pnt aP1(aPoints->Value(ind) * theFact);
gp_Pnt aP2(aPoints->Value(indnext) * theFact);
BRepBuilderAPI_MakeEdge aMaker(aP1, aP2);
if (aMaker.IsDone())
{
TopoDS_Edge aCurE = aMaker.Edge();
aB.Add(aCurW, aCurE);
}
}
aB.Add(aComp, aCurW);
}
anAnnotationShape = aComp;
}
if (!anAnnotationShape.IsNull())
{
nbShapes++;
aB.Add(aResAnnotation, anAnnotationShape);
if (i == anAnnotations.Length() - 1)
BRepBndLib::AddClose(anAnnotationShape, aBox);
}
}
thePresentation = aResAnnotation;
theBox = aBox;
return (nbShapes > 0);
}
//=======================================================================
//function : readAnnotationPlane
//purpose : read annotation plane
//=======================================================================
Standard_Boolean readAnnotationPlane(const Handle(StepVisual_AnnotationPlane) theAnnotationPlane,
const Standard_Real theFact,
gp_Ax2& thePlane)
{
if (theAnnotationPlane.IsNull())
return Standard_False;
gp_Ax2 aPlaneAxes;
Handle(StepRepr_RepresentationItem) aPlaneItem = theAnnotationPlane->Item();
Handle(StepGeom_Axis2Placement3d) aA2P3D;
//retrieve axes from AnnotationPlane
if (aPlaneItem->IsKind(STANDARD_TYPE(StepGeom_Plane))) {
Handle(StepGeom_Plane) aPlane = Handle(StepGeom_Plane)::DownCast(aPlaneItem);
aA2P3D = aPlane->Position();
}
else if (aPlaneItem->IsKind(STANDARD_TYPE(StepVisual_PlanarBox))) {
Handle(StepVisual_PlanarBox) aBox = Handle(StepVisual_PlanarBox)::DownCast(aPlaneItem);
aA2P3D = aBox->Placement().Axis2Placement3d();
}
if (aA2P3D.IsNull())
return Standard_False;
// build gp_Ax2 from axes
Handle(StepGeom_Direction) anAxis = aA2P3D->Axis(),
aRefDir = aA2P3D->RefDirection();
if (anAxis.IsNull() || aRefDir.IsNull())
return Standard_False;
Handle(TColStd_HArray1OfReal) aCoords;
aCoords = anAxis->DirectionRatios();
gp_Dir aXDir(aCoords->Value(1), aCoords->Value(2), aCoords->Value(3));
aCoords = aRefDir->DirectionRatios();
gp_Dir aYDir(aCoords->Value(1), aCoords->Value(2), aCoords->Value(3));
aPlaneAxes.SetDirection(aXDir.Crossed(aYDir));
aPlaneAxes.SetYDirection(aYDir);
//set location of the annotation plane
Handle(TColStd_HArray1OfReal) aLocCoords;
Handle(StepGeom_CartesianPoint) aLoc = aA2P3D->Location();
gp_Pnt aLocPos(aLoc->CoordinatesValue(1) * theFact, aLoc->CoordinatesValue(2) * theFact, aLoc->CoordinatesValue(3) * theFact);
aPlaneAxes.SetLocation(aLocPos);
thePlane = aPlaneAxes;
return Standard_True;
}
//=======================================================================
//function : readAnnotation
@@ -1803,50 +1988,16 @@ void readAnnotation(const Handle(XSControl_TransferReader)& theTR,
GetLengthConversionFactorFromContext(aDModel->ContextOfItems(), aFact);
// retrieve AnnotationPlane
Standard_Boolean isHasPlane = Standard_False;
gp_Ax2 aPlaneAxes;
Handle(StepRepr_RepresentationItem) aDMIAE = aDMIA->IdentifiedItemValue(1);
if (aDMIAE.IsNull())
return;
gp_Ax2 aPlaneAxes;
subs = aGraph.Sharings(aDMIAE);
Handle(StepVisual_AnnotationPlane) anAnPlane;
for (subs.Start(); subs.More() && anAnPlane.IsNull(); subs.Next()) {
anAnPlane = Handle(StepVisual_AnnotationPlane)::DownCast(subs.Value());
}
if (!anAnPlane.IsNull()) {
Handle(StepRepr_RepresentationItem) aPlaneItem = anAnPlane->Item();
Handle(StepGeom_Axis2Placement3d) aA2P3D;
//retrieve axes from AnnotationPlane
if (aPlaneItem->IsKind(STANDARD_TYPE(StepGeom_Plane))) {
Handle(StepGeom_Plane) aPlane = Handle(StepGeom_Plane)::DownCast(aPlaneItem);
aA2P3D = aPlane->Position();
}
else if (aPlaneItem->IsKind(STANDARD_TYPE(StepVisual_PlanarBox))) {
Handle(StepVisual_PlanarBox) aBox = Handle(StepVisual_PlanarBox)::DownCast(aPlaneItem);
aA2P3D = aBox->Placement().Axis2Placement3d();
}
// build gp_Ax2 from axes
if (!aA2P3D.IsNull())
{
Handle(StepGeom_Direction) anAxis = aA2P3D->Axis(),
aRefDir = aA2P3D->RefDirection();
if (!anAxis.IsNull() && !aRefDir.IsNull()) {
Handle(TColStd_HArray1OfReal) aCoords;
aCoords = anAxis->DirectionRatios();
gp_Dir aXDir(aCoords->Value(1), aCoords->Value(2), aCoords->Value(3));
aCoords = aRefDir->DirectionRatios();
gp_Dir aYDir(aCoords->Value(1), aCoords->Value(2), aCoords->Value(3));
aPlaneAxes.SetDirection(aXDir.Crossed(aYDir));
aPlaneAxes.SetYDirection(aYDir);
//set location of the annotation plane
Handle(TColStd_HArray1OfReal) aLocCoords;
Handle(StepGeom_CartesianPoint) aLoc = aA2P3D->Location();
gp_Pnt aLocPos( aLoc->CoordinatesValue(1) * aFact, aLoc->CoordinatesValue(2) * aFact, aLoc->CoordinatesValue(3) * aFact);
aPlaneAxes.SetLocation(aLocPos);
isHasPlane = Standard_True;
}
}
}
Standard_Boolean isHasPlane = readAnnotationPlane(anAnPlane, aFact, aPlaneAxes);
// set plane axes to XCAF
if (isHasPlane) {
@@ -1869,138 +2020,16 @@ void readAnnotation(const Handle(XSControl_TransferReader)& theTR,
}
// Retrieve presentation
Handle(StepVisual_AnnotationCurveOccurrence) anACO;
NCollection_Vector<Handle(StepVisual_TessellatedAnnotationOccurrence)> aTesselations;
NCollection_Vector<Handle(StepVisual_StyledItem)> anAnnotations;
if (aDMIAE->IsKind(STANDARD_TYPE(StepVisual_AnnotationCurveOccurrence)))
{
anACO = Handle(StepVisual_AnnotationCurveOccurrence)::DownCast(aDMIAE);
if( !anACO.IsNull())
anAnnotations.Append(anACO);
}
else if (aDMIAE->IsKind(STANDARD_TYPE(StepVisual_DraughtingCallout)))
{
Handle(StepVisual_DraughtingCallout) aDCallout =
Handle(StepVisual_DraughtingCallout)::DownCast(aDMIAE);
for (Standard_Integer i = 1; i <= aDCallout->NbContents() && anACO.IsNull(); i++) {
anACO = aDCallout->ContentsValue(i).AnnotationCurveOccurrence();
if(!anACO.IsNull())
{
anAnnotations.Append(anACO);
continue;
}
Handle(StepVisual_TessellatedAnnotationOccurrence) aTesselation =
aDCallout->ContentsValue(i).TessellatedAnnotationOccurrence();
if( !aTesselation.IsNull())
anAnnotations.Append(aTesselation);
}
}
if (!anAnnotations.Length())
return;
BRep_Builder aB;
aB.MakeCompound(aResAnnotation);
Standard_Integer i =0;
Bnd_Box aBox;
Standard_Integer nbShapes =0;
for( ; i < anAnnotations.Length(); i++)
{
Handle(StepVisual_StyledItem) anItem = anAnnotations(i);
aPresentName = anItem->Name();
anACO = Handle(StepVisual_AnnotationCurveOccurrence)::DownCast(anItem);
TopoDS_Shape anAnnotationShape;
if(!anACO.IsNull())
{
Handle(StepRepr_RepresentationItem) aCurveItem = anACO->Item();
anAnnotationShape = STEPConstruct::FindShape (aTP,aCurveItem);
if( anAnnotationShape.IsNull())
{
Handle(Transfer_Binder) binder = theTR->Actor()->Transfer(aCurveItem, aTP);
if ( ! binder.IsNull() && binder->HasResult() ) {
anAnnotationShape = TransferBRep::ShapeResult ( aTP, binder );
}
}
}
//case of tessellated entities
else
{
Handle(StepRepr_RepresentationItem) aTessItem = anItem->Item();
if(aTessItem.IsNull())
continue;
Handle(StepVisual_TessellatedGeometricSet) aTessSet = Handle(StepVisual_TessellatedGeometricSet)::DownCast(aTessItem);
if( aTessSet.IsNull())
continue;
NCollection_Handle<StepVisual_Array1OfTessellatedItem> aListItems = aTessSet->Items();
Standard_Integer nb = aListItems.IsNull() ? 0 : aListItems->Length();
Handle(StepVisual_TessellatedCurveSet) aTessCurve;
for (Standard_Integer n = 1; n <= nb && aTessCurve.IsNull(); n++)
{
aTessCurve = Handle(StepVisual_TessellatedCurveSet)::DownCast(aListItems->Value(n));
}
if( aTessCurve.IsNull())
continue;
Handle(StepVisual_CoordinatesList) aCoordList = aTessCurve->CoordList();
if( aCoordList.IsNull())
continue;
Handle(TColgp_HArray1OfXYZ) aPoints = aCoordList->Points();
if (aPoints.IsNull() || aPoints->Length() == 0)
continue;
NCollection_Handle<StepVisual_VectorOfHSequenceOfInteger> aCurves = aTessCurve->Curves();
Standard_Integer aNbC = (aCurves.IsNull() ? 0 : aCurves->Length());
TopoDS_Compound aComp;
aB.MakeCompound(aComp);
Standard_Integer k = 0;
for( ; k < aNbC; k++)
{
Handle(TColStd_HSequenceOfInteger) anIndexes = aCurves->Value(k);
TopoDS_Wire aCurW;
aB.MakeWire(aCurW);
for(Standard_Integer n = 1; n < anIndexes->Length(); n++)
{
Standard_Integer ind = anIndexes->Value(n);
Standard_Integer indnext = anIndexes->Value(n + 1);
if( ind > aPoints->Length() || indnext > aPoints->Length())
continue;
gp_Pnt aP1(aPoints->Value(ind) * aFact);
gp_Pnt aP2(aPoints->Value(indnext) * aFact);
BRepBuilderAPI_MakeEdge aMaker(aP1, aP2);
if( aMaker.IsDone())
{
TopoDS_Edge aCurE = aMaker.Edge();
aB.Add(aCurW, aCurE);
}
}
aB.Add(aComp, aCurW);
}
anAnnotationShape = aComp;
}
if(!anAnnotationShape.IsNull())
{
nbShapes++;
aB.Add(aResAnnotation, anAnnotationShape);
if( i == anAnnotations.Length() - 1)
BRepBndLib::AddClose(anAnnotationShape, aBox);
}
}
if(!nbShapes)
if (!readPMIPresentation(aDMIAE, theTR, aFact, aResAnnotation, aPresentName, aBox))
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())
if (!aBox.IsVoid())
{
Standard_Real aXmin, aYmin, aZmin,aXmax, aYmax, aZmax;
aBox.Get(aXmin, aYmin, aZmin,aXmax, aYmax, aZmax);
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
aBox.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
if (isHasPlane && !aBox.IsOut(aPlaneAxes.Location())) {
aPtext = aPlaneAxes.Location();
}
@@ -3703,6 +3732,8 @@ Standard_Boolean STEPCAFControl_Reader::ReadGDTs(const Handle(XSControl_WorkSess
Handle(TDocStd_Document)& theDoc) const
{
const Handle(Interface_InterfaceModel) &aModel = theWS->Model();
const Interface_Graph& aGraph = theWS->Graph();
const Handle(XSControl_TransferReader) &aTR = theWS->TransferReader();
Handle(StepData_StepModel) aSM = Handle(StepData_StepModel)::DownCast(aModel);
Interface_EntityIterator anI = aSM->Header();
Handle(HeaderSection_FileSchema) aH;
@@ -3728,6 +3759,55 @@ Standard_Boolean STEPCAFControl_Reader::ReadGDTs(const Handle(XSControl_WorkSess
}
}
}
else if (anEnt->IsKind(STANDARD_TYPE(StepVisual_DraughtingCallout)) ||
anEnt->IsKind(STANDARD_TYPE(StepVisual_AnnotationCurveOccurrence)))
{
// read common PMIs: presentation, which is not connected to any PMI.
Handle(StepVisual_AnnotationPlane) anAnPlane;
Handle(StepAP242_DraughtingModelItemAssociation) aDMIA;
Standard_Boolean isCommonLabel = Standard_True;
for (Interface_EntityIterator anIter = aGraph.Sharings(anEnt); anIter.More(); anIter.Next())
{
if (anIter.Value()->IsKind(STANDARD_TYPE(StepVisual_AnnotationPlane)))
anAnPlane = Handle(StepVisual_AnnotationPlane)::DownCast(anIter.Value());
else
isCommonLabel = Standard_False;
}
if (!isCommonLabel)
continue;
// create empty Dimension
TDF_Label aGDTL = aDGTTool->AddDimension();
Handle(XCAFDoc_Dimension) aDim = XCAFDoc_Dimension::Set(aGDTL);
TCollection_AsciiString aStr("DGT:Common_label");
TDataStd_Name::Set(aGDTL, aStr);
TDF_LabelSequence anEmptySeq1, anEmptySeq2;
aDGTTool->SetDimension(anEmptySeq1, anEmptySeq2, aGDTL);
Handle(XCAFDimTolObjects_DimensionObject) aDimObj = new XCAFDimTolObjects_DimensionObject();
// read annotations
Standard_Real aFact = 1.0;
if (!anAnPlane.IsNull())
{
Handle(StepVisual_DraughtingModel) aDModel;
for (Interface_EntityIterator anIter = aGraph.Sharings(anAnPlane); anIter.More() && aDModel.IsNull(); anIter.Next())
{
if (anIter.Value()->IsKind(STANDARD_TYPE(StepVisual_DraughtingModel)))
aDModel = Handle(StepVisual_DraughtingModel)::DownCast(anIter.Value());
}
if (!aDModel.IsNull())
GetLengthConversionFactorFromContext(aDModel->ContextOfItems(), aFact);
}
gp_Ax2 aPlaneAxes;
readAnnotationPlane(anAnPlane, aFact, aPlaneAxes);
TopoDS_Shape aPresentation;
Handle(TCollection_HAsciiString) aPresentName;
Bnd_Box aBox;
readPMIPresentation(anEnt, aTR, aFact, aPresentation, aPresentName, aBox);
// populate Dimension
aDimObj->SetType(XCAFDimTolObjects_DimensionType_CommonLabel);
aDimObj->SetPlane(aPlaneAxes);
aDimObj->SetPresentation(aPresentation, aPresentName);
aDim->SetObject(aDimObj);
}
}
return Standard_True;
}

View File

@@ -2316,6 +2316,7 @@ static Handle(StepRepr_ShapeAspect) WriteShapeAspect (const Handle(XSControl_Wor
//======================================================================
static void WritePresentation(const Handle(XSControl_WorkSession) &WS,
const TopoDS_Shape thePresentation,
const Handle(TCollection_HAsciiString)& thePrsName,
const gp_Ax2 theAnnotationPlane,
const gp_Pnt theTextPosition,
const Handle(Standard_Transient) theDimension)
@@ -2334,7 +2335,7 @@ 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(new TCollection_HAsciiString(), aTAOs);
aDCallout->Init(thePrsName, aTAOs);
Handle(StepRepr_HArray1OfRepresentationItem) aDCsForDMIA = new StepRepr_HArray1OfRepresentationItem(1, 1);
aDCsForDMIA->SetValue(1, aDCallout);
StepAP242_ItemIdentifiedRepresentationUsageDefinition aDimension;
@@ -2381,6 +2382,61 @@ static void WritePresentation(const Handle(XSControl_WorkSession) &WS,
aModel->AddWithRefs(anAnnPlane);
}
//======================================================================
//function : WritePresentation
//purpose : auxiliary (write annotation plane and presentation for common labels)
//======================================================================
static void WritePresentation(const Handle(XSControl_WorkSession) &WS,
const TopoDS_Shape thePresentation,
const Handle(TCollection_HAsciiString)& thePrsName,
const gp_Ax2 theAnnotationPlane)
{
if (thePresentation.IsNull())
return;
// Get working data
const Handle(Interface_InterfaceModel) &aModel = WS->Model();
// Presentation
Handle(StepVisual_TessellatedGeometricSet) aGeomSet = STEPCAFControl_GDTProperty::GetTessellation(thePresentation);
Handle(StepVisual_TessellatedAnnotationOccurrence) aTAO = new StepVisual_TessellatedAnnotationOccurrence();
aTAO->Init(new TCollection_HAsciiString(), gdtPrsCurveStyle, aGeomSet);
StepVisual_DraughtingCalloutElement aDCElement;
aDCElement.SetValue(aTAO);
Handle(StepVisual_HArray1OfDraughtingCalloutElement) aTAOs = new StepVisual_HArray1OfDraughtingCalloutElement(1, 1);
aTAOs->SetValue(1, aDCElement);
Handle(StepVisual_DraughtingCallout) aDCallout = new StepVisual_DraughtingCallout();
aDCallout->Init(thePrsName, aTAOs);
aModel->AddWithRefs(aDCallout);
// Annotation plane
// Presentation Style
Handle(StepVisual_NullStyleMember) aNullStyle = new StepVisual_NullStyleMember();
aNullStyle->SetEnumText(0, ".NULL.");
StepVisual_PresentationStyleSelect aStyleItem;
aStyleItem.SetValue(aNullStyle);
Handle(StepVisual_HArray1OfPresentationStyleSelect) aStyles = new StepVisual_HArray1OfPresentationStyleSelect(1, 1);
aStyles->SetValue(1, aStyleItem);
Handle(StepVisual_PresentationStyleAssignment) aPrsStyle = new StepVisual_PresentationStyleAssignment();
aPrsStyle->Init(aStyles);
Handle(StepVisual_HArray1OfPresentationStyleAssignment) aPrsStyles =
new StepVisual_HArray1OfPresentationStyleAssignment(1, 1);
aPrsStyles->SetValue(1, aPrsStyle);
// Plane
Handle(StepGeom_Plane) aPlane = new StepGeom_Plane();
Handle(StepGeom_Axis2Placement3d) anAxis = STEPCAFControl_GDTProperty::GetAxis2Placement3D(theAnnotationPlane);
aPlane->Init(new TCollection_HAsciiString(), anAxis);
// Annotation plane element
StepVisual_AnnotationPlaneElement aPlaneElement;
aPlaneElement.SetValue(aDCallout);
Handle(StepVisual_HArray1OfAnnotationPlaneElement) aDCsForAnnPln = new StepVisual_HArray1OfAnnotationPlaneElement(1, 1);
aDCsForAnnPln->SetValue(1, aPlaneElement);
// Init AnnotationPlane entity
Handle(StepVisual_AnnotationPlane) anAnnPlane = new StepVisual_AnnotationPlane();
anAnnPlane->Init(new TCollection_HAsciiString(), aPrsStyles, aPlane, aDCsForAnnPln);
gdtAnnotationPlanes.Append(anAnnPlane);
aModel->AddWithRefs(anAnnPlane);
}
//=======================================================================
//function : WriteDatumAP242
//purpose : auxiliary (write Datum entity for given shape or write all
@@ -2579,7 +2635,7 @@ static Handle(StepDimTol_Datum) WriteDatumAP242(const Handle(XSControl_WorkSessi
Model->AddWithRefs(aSDR);
//Annotation plane and Presentation
WritePresentation(WS, anObject->GetPresentation(), anObject->GetPlane(), anObject->GetPointTextAttach(), aSA);
WritePresentation(WS, anObject->GetPresentation(), anObject->GetPresentationName(), anObject->GetPlane(), anObject->GetPointTextAttach(), aSA);
return aDatum;
}
@@ -3245,7 +3301,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(), anObject->GetPointTextAttach(), aGeomTol);
WritePresentation(WS, anObject->GetPresentation(), anObject->GetPresentationName(), anObject->GetPlane(), anObject->GetPointTextAttach(), aGeomTol);
}
//=======================================================================
@@ -3681,14 +3737,19 @@ Standard_Boolean STEPCAFControl_Writer::WriteDGTsAP242 (const Handle(XSControl_W
for (Standard_Integer i = 1; i <= aDGTLabels.Length(); i++) {
TDF_Label aDimensionL = aDGTLabels.Value(i);
TDF_LabelSequence aFirstShapeL, aSecondShapeL;
if (!DGTTool->GetRefShapeLabel(aDimensionL, aFirstShapeL, aSecondShapeL))
continue;
Handle(XCAFDoc_Dimension) aDimAttr;
if (!aDimensionL.FindAttribute(XCAFDoc_Dimension::GetID(),aDimAttr))
continue;
Handle(XCAFDimTolObjects_DimensionObject) anObject = aDimAttr->GetObject();
if (anObject.IsNull())
continue;
if (anObject->GetType() == XCAFDimTolObjects_DimensionType_CommonLabel)
{
WritePresentation(WS, anObject->GetPresentation(), anObject->GetPresentationName(), anObject->GetPlane());
}
if (!DGTTool->GetRefShapeLabel(aDimensionL, aFirstShapeL, aSecondShapeL))
continue;
// Write links with shapes
Handle(StepRepr_ShapeAspect) aFirstSA, aSecondSA;
@@ -3812,7 +3873,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(), anObject->GetPointTextAttach(), aDimension.Value());
WritePresentation(WS, anObject->GetPresentation(), anObject->GetPresentationName(), anObject->GetPlane(), anObject->GetPointTextAttach(), aDimension.Value());
}
// Write Derived geometry
if (aConnectionPnts.Length() > 0) {