mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0027235: Export GDT: Annotation plane and Presentation.
Implement Null_Style STEP type. Implement export of annotation planes and presentation as tessellated geometry. Add tests.
This commit is contained in:
@@ -13,6 +13,11 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <Geom_BSplineCurve.hxx>
|
||||
#include <Geom_Curve.hxx>
|
||||
#include <Geom_Line.hxx>
|
||||
#include <ShapeConstruct_Curve.hxx>
|
||||
#include <STEPCAFControl_GDTProperty.hxx>
|
||||
#include <StepBasic_MeasureValueMember.hxx>
|
||||
#include <StepGeom_CartesianPoint.hxx>
|
||||
@@ -25,6 +30,11 @@
|
||||
#include <StepDimTol_StraightnessTolerance.hxx>
|
||||
#include <StepDimTol_SurfaceProfileTolerance.hxx>
|
||||
#include <StepRepr_DescriptiveRepresentationItem.hxx>
|
||||
#include <StepVisual_CoordinatesList.hxx>
|
||||
#include <StepVisual_TessellatedCurveSet.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <XCAFDimTolObjects_DatumModifiersSequence.hxx>
|
||||
#include <XCAFDimTolObjects_DatumModifWithValue.hxx>
|
||||
|
||||
@@ -973,7 +983,7 @@ Handle(StepGeom_Axis2Placement3d) STEPCAFControl_GDTProperty::GetAxis2Placement3
|
||||
aDirCoords->SetValue(i, theAxis.XDirection().Coord(i));
|
||||
aRefDirection = new StepGeom_Direction();
|
||||
aRefDirection->Init(new TCollection_HAsciiString(), aDirCoords);
|
||||
anA2P3D->Init(new TCollection_HAsciiString("orientation"), aPoint, Standard_True, anAxis, Standard_True, aRefDirection);
|
||||
anA2P3D->Init(new TCollection_HAsciiString(), aPoint, Standard_True, anAxis, Standard_True, aRefDirection);
|
||||
return anA2P3D;
|
||||
}
|
||||
|
||||
@@ -1321,3 +1331,58 @@ Handle(TCollection_HAsciiString) STEPCAFControl_GDTProperty::GetTolValueType(con
|
||||
return new TCollection_HAsciiString("unknown");
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetTessellation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(StepVisual_TessellatedGeometricSet) STEPCAFControl_GDTProperty::GetTessellation(const TopoDS_Shape theShape)
|
||||
{
|
||||
// Build coordinate list and curves
|
||||
NCollection_Handle<StepVisual_VectorOfHSequenceOfInteger> aCurves = new StepVisual_VectorOfHSequenceOfInteger;
|
||||
NCollection_Vector<gp_XYZ> aCoords;
|
||||
Standard_Integer aPntNb = 1;
|
||||
for (TopExp_Explorer aCurveIt(theShape, TopAbs_EDGE); aCurveIt.More(); aCurveIt.Next()) {
|
||||
Handle(TColStd_HSequenceOfInteger) aCurve = new TColStd_HSequenceOfInteger;
|
||||
// Find out type of edge curve
|
||||
Standard_Real aFirst = 0, aLast = 0;
|
||||
Handle(Geom_Curve) anEdgeCurve = BRep_Tool::Curve(TopoDS::Edge(aCurveIt.Current()), aFirst, aLast);
|
||||
if (anEdgeCurve.IsNull())
|
||||
continue;
|
||||
// Line
|
||||
if (anEdgeCurve->IsKind(STANDARD_TYPE(Geom_Line))) {
|
||||
for (TopExp_Explorer aVertIt(aCurveIt.Current(), TopAbs_VERTEX); aVertIt.More(); aVertIt.Next()) {
|
||||
aCoords.Append(BRep_Tool::Pnt(TopoDS::Vertex(aVertIt.Current())).XYZ());
|
||||
aCurve->Append(aPntNb);
|
||||
aPntNb++;
|
||||
}
|
||||
}
|
||||
// BSpline
|
||||
else {
|
||||
ShapeConstruct_Curve aSCC;
|
||||
Handle(Geom_BSplineCurve) aBSCurve = aSCC.ConvertToBSpline(anEdgeCurve,
|
||||
aFirst, aLast, Precision::Confusion());
|
||||
for (Standard_Integer i = 1; i <= aBSCurve->NbPoles(); i++) {
|
||||
aCoords.Append(aBSCurve->Pole(i).XYZ());
|
||||
aCurve->Append(aPntNb);
|
||||
aPntNb++;
|
||||
}
|
||||
}
|
||||
aCurves->Append(aCurve);
|
||||
}
|
||||
|
||||
Handle(TColgp_HArray1OfXYZ) aPoints = new TColgp_HArray1OfXYZ(1, aCoords.Length());
|
||||
for (Standard_Integer i = 1; i <= aPoints->Length(); i++) {
|
||||
aPoints->SetValue(i, aCoords.Value(i - 1));
|
||||
}
|
||||
// STEP entities
|
||||
Handle(StepVisual_CoordinatesList) aCoordList = new StepVisual_CoordinatesList();
|
||||
aCoordList->Init(new TCollection_HAsciiString(), aPoints);
|
||||
Handle(StepVisual_TessellatedCurveSet) aCurveSet = new StepVisual_TessellatedCurveSet();
|
||||
aCurveSet->Init(new TCollection_HAsciiString(), aCoordList, aCurves);
|
||||
NCollection_Handle<StepVisual_Array1OfTessellatedItem> aTessItems = new StepVisual_Array1OfTessellatedItem(1, 1);
|
||||
aTessItems->SetValue(1, aCurveSet);
|
||||
Handle(StepVisual_TessellatedGeometricSet) aGeomSet = new StepVisual_TessellatedGeometricSet();
|
||||
aGeomSet->Init(new TCollection_HAsciiString(), aTessItems);
|
||||
return aGeomSet;
|
||||
}
|
||||
|
@@ -31,6 +31,7 @@
|
||||
#include <StepDimTol_HArray1OfDatumReferenceModifier.hxx>
|
||||
#include <StepGeom_Axis2Placement3d.hxx>
|
||||
#include <StepRepr_CompoundRepresentationItem.hxx>
|
||||
#include <StepVisual_TessellatedGeometricSet.hxx>
|
||||
#include <XCAFDimTolObjects_DimensionModifiersSequence.hxx>
|
||||
#include <StepShape_LimitsAndFits.hxx>
|
||||
#include <XCAFDimTolObjects_DatumModifiersSequence.hxx>
|
||||
@@ -106,6 +107,8 @@ public:
|
||||
const Standard_Real theValue,
|
||||
const StepBasic_Unit theUnit);
|
||||
|
||||
Standard_EXPORT static Handle(StepVisual_TessellatedGeometricSet) GetTessellation(const TopoDS_Shape theShape);
|
||||
|
||||
};
|
||||
|
||||
#endif // _STEPCAFControl_GDTProperty_HeaderFile
|
||||
|
@@ -1886,7 +1886,7 @@ void readAnnotation(const Handle(XSControl_TransferReader)& theTR,
|
||||
Handle(StepVisual_TessellatedGeometricSet) aTessSet = Handle(StepVisual_TessellatedGeometricSet)::DownCast(aTessItem);
|
||||
if( aTessSet.IsNull())
|
||||
continue;
|
||||
NCollection_Handle<StepVisual_Array1OfTessellaltedItem> aListItems = aTessSet->Items();
|
||||
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++)
|
||||
|
@@ -27,9 +27,11 @@
|
||||
#include <Interface_Static.hxx>
|
||||
#include <Message_Messenger.hxx>
|
||||
#include <MoniTool_DataMapIteratorOfDataMapOfShapeTransient.hxx>
|
||||
#include <NCollection_Vector.hxx>
|
||||
#include <OSD_Path.hxx>
|
||||
#include <Quantity_TypeOfColor.hxx>
|
||||
#include <StepAP214_Protocol.hxx>
|
||||
#include <StepAP242_DraughtingModelItemAssociation.hxx>
|
||||
#include <StepAP242_GeometricItemSpecificUsage.hxx>
|
||||
#include <StepBasic_DerivedUnit.hxx>
|
||||
#include <StepBasic_DerivedUnitElement.hxx>
|
||||
@@ -106,6 +108,7 @@
|
||||
#include <StepGeom_Direction.hxx>
|
||||
#include <StepGeom_GeometricRepresentationContextAndGlobalUnitAssignedContext.hxx>
|
||||
#include <StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx.hxx>
|
||||
#include <StepGeom_Plane.hxx>
|
||||
#include <StepGeom_Surface.hxx>
|
||||
#include <StepRepr_CompGroupShAspAndCompShAspAndDatumFeatAndShAsp.hxx>
|
||||
#include <StepRepr_CompositeShapeAspect.hxx>
|
||||
@@ -153,7 +156,10 @@
|
||||
#include <StepShape_ToleranceValue.hxx>
|
||||
#include <StepShape_TypeQualifier.hxx>
|
||||
#include <StepShape_ValueFormatTypeQualifier.hxx>
|
||||
#include <StepVisual_AnnotationPlane.hxx>
|
||||
#include <StepVisual_CurveStyle.hxx>
|
||||
#include <StepVisual_DraughtingCallout.hxx>
|
||||
#include <StepVisual_DraughtingModel.hxx>
|
||||
#include <StepVisual_HArray1OfInvisibleItem.hxx>
|
||||
#include <StepVisual_HArray1OfLayeredItem.hxx>
|
||||
#include <StepVisual_HArray1OfPresentationStyleAssignment.hxx>
|
||||
@@ -161,6 +167,7 @@
|
||||
#include <StepVisual_Invisibility.hxx>
|
||||
#include <StepVisual_InvisibleItem.hxx>
|
||||
#include <StepVisual_MechanicalDesignGeometricPresentationRepresentation.hxx>
|
||||
#include <StepVisual_NullStyleMember.hxx>
|
||||
#include <StepVisual_PointStyle.hxx>
|
||||
#include <StepVisual_PresentationLayerAssignment.hxx>
|
||||
#include <StepVisual_PresentationRepresentation.hxx>
|
||||
@@ -168,6 +175,8 @@
|
||||
#include <StepVisual_PresentationStyleByContext.hxx>
|
||||
#include <StepVisual_StyledItem.hxx>
|
||||
#include <StepVisual_SurfaceStyleUsage.hxx>
|
||||
#include <StepVisual_TessellatedAnnotationOccurrence.hxx>
|
||||
#include <StepVisual_TessellatedGeometricSet.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <TCollection_HAsciiString.hxx>
|
||||
#include <TColStd_HArray1OfReal.hxx>
|
||||
@@ -232,6 +241,9 @@ enum DimensionalValueNumber {
|
||||
DimensionalValueNumber_Lower,
|
||||
DimensionalValueNumber_Upper
|
||||
};
|
||||
static NCollection_Vector<Handle(StepVisual_AnnotationPlane)> gdtAnnotationPlanes;
|
||||
static Handle(StepVisual_DraughtingModel) gdtPresentationDM;
|
||||
static Handle(StepVisual_HArray1OfPresentationStyleAssignment) gdtPrsCurveStyle;
|
||||
|
||||
// added by skl 15.01.2004 for D> writing
|
||||
//#include <StepRepr_CompoundItemDefinition.hxx>
|
||||
@@ -2302,6 +2314,69 @@ static Handle(StepRepr_ShapeAspect) WriteShapeAspect (const Handle(XSControl_Wor
|
||||
return aSA;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : WritePresentation
|
||||
//purpose : auxiliary (write annotation plane and presentation)
|
||||
//======================================================================
|
||||
static void WritePresentation(const Handle(XSControl_WorkSession) &WS,
|
||||
const TopoDS_Shape thePresentation,
|
||||
const gp_Ax2 theAnnotationPlane,
|
||||
const Handle(Standard_Transient) theDimension)
|
||||
{
|
||||
if (thePresentation.IsNull())
|
||||
return;
|
||||
// Get working data
|
||||
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(new TCollection_HAsciiString(), aTAOs);
|
||||
Handle(StepRepr_HArray1OfRepresentationItem) aDCsForDMIA = new StepRepr_HArray1OfRepresentationItem(1, 1);
|
||||
aDCsForDMIA->SetValue(1, aDCallout);
|
||||
StepAP242_ItemIdentifiedRepresentationUsageDefinition aDimension;
|
||||
aDimension.SetValue(theDimension);
|
||||
Handle(StepAP242_DraughtingModelItemAssociation) aDMIA =
|
||||
new StepAP242_DraughtingModelItemAssociation();
|
||||
aDMIA->Init(new TCollection_HAsciiString("PMI representation to presentation link"),
|
||||
new TCollection_HAsciiString(), aDimension, gdtPresentationDM, aDCsForDMIA);
|
||||
aModel->AddWithRefs(aDMIA);
|
||||
|
||||
// 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
|
||||
@@ -2416,6 +2491,7 @@ static Handle(StepDimTol_Datum) WriteDatumAP242(const Handle(XSControl_WorkSessi
|
||||
gp_Ax2 aDTAxis = anObject->GetDatumTargetAxis();
|
||||
Handle(StepGeom_Axis2Placement3d) anA2P3D =
|
||||
STEPCAFControl_GDTProperty::GetAxis2Placement3D(aDTAxis);
|
||||
anA2P3D->SetName(new TCollection_HAsciiString("orientation"));
|
||||
Handle(StepRepr_HArray1OfRepresentationItem) anItems;
|
||||
// Process each datum target type
|
||||
if (aDatumType == XCAFDimTolObjects_DatumTargetType_Point) {
|
||||
@@ -2498,6 +2574,9 @@ static Handle(StepDimTol_Datum) WriteDatumAP242(const Handle(XSControl_WorkSessi
|
||||
aSDR->Init(aRDefinition, aShapeRepr);
|
||||
Model->AddWithRefs(aSDR);
|
||||
|
||||
//Annotation plane and Presentation
|
||||
WritePresentation(WS, anObject->GetPresentation(), anObject->GetPlane(), aSA);
|
||||
|
||||
return aDatum;
|
||||
}
|
||||
|
||||
@@ -2838,6 +2917,7 @@ static Handle(StepDimTol_HArray1OfDatumSystemOrReference) WriteDatumSystem(const
|
||||
if (anObject->HasAxis()) {
|
||||
Handle(StepGeom_Axis2Placement3d) anAxis =
|
||||
STEPCAFControl_GDTProperty::GetAxis2Placement3D(anObject->GetAxis());
|
||||
anAxis->SetName(new TCollection_HAsciiString("orientation"));
|
||||
Handle(StepAP242_GeometricItemSpecificUsage) aGISU = new StepAP242_GeometricItemSpecificUsage();
|
||||
StepAP242_ItemIdentifiedRepresentationUsageDefinition aDefinition;
|
||||
aDefinition.SetValue(aDS);
|
||||
@@ -3087,6 +3167,8 @@ 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);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -3474,6 +3556,14 @@ Standard_Boolean STEPCAFControl_Writer::WriteDGTsAP242 (const Handle(XSControl_W
|
||||
if(DGTTool.IsNull())
|
||||
return Standard_False;
|
||||
|
||||
// Common entities for presentation
|
||||
gdtPresentationDM = new StepVisual_DraughtingModel();
|
||||
STEPConstruct_Styles aStyles (WS);
|
||||
Handle(StepVisual_Colour) aCurvColor = aStyles.EncodeColor(Quantity_NOC_WHITE);
|
||||
Handle(StepRepr_RepresentationItem) anItem = NULL;
|
||||
gdtPrsCurveStyle = new StepVisual_HArray1OfPresentationStyleAssignment(1, 1);
|
||||
gdtPrsCurveStyle->SetValue(1, aStyles.MakeColorPSA(anItem, aCurvColor, aCurvColor));
|
||||
|
||||
TDF_LabelSequence aDGTLabels;
|
||||
STEPConstruct_DataMapOfAsciiStringTransient aDatumMap;
|
||||
Handle(StepRepr_RepresentationContext) aRC;
|
||||
@@ -3642,6 +3732,8 @@ 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());
|
||||
}
|
||||
|
||||
//----------------------------//
|
||||
@@ -3662,6 +3754,18 @@ Standard_Boolean STEPCAFControl_Writer::WriteDGTsAP242 (const Handle(XSControl_W
|
||||
WriteGeomTolerance(WS, aFirstShapeL, aGeomTolL, aDatumSystem, aRC);
|
||||
}
|
||||
|
||||
// Write Draughting model for Annotation Planes
|
||||
if (gdtAnnotationPlanes.Length() == 0)
|
||||
return Standard_True;
|
||||
|
||||
Handle(StepRepr_HArray1OfRepresentationItem) aItems =
|
||||
new StepRepr_HArray1OfRepresentationItem(1, gdtAnnotationPlanes.Length());
|
||||
for (Standard_Integer i = 1; i <= aItems->Length(); i++) {
|
||||
aItems->SetValue(i, gdtAnnotationPlanes.Value(i - 1));
|
||||
}
|
||||
gdtPresentationDM->Init(new TCollection_HAsciiString(), aItems, aRC);
|
||||
aModel->AddWithRefs(gdtPresentationDM);
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user