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

0028235: Data Exchange - DG&T datum XCAF object has incomplete list of shape references

Update STEP import and export of datums.
Update test cases.
This commit is contained in:
ika
2016-12-20 15:12:09 +03:00
committed by apn
parent 5da3dfdf08
commit 400af1bcf6
41 changed files with 947 additions and 655 deletions

View File

@@ -15,6 +15,7 @@
#include <BRep_Builder.hxx>
#include <Geom_Axis2Placement.hxx>
#include <Interface_EntityIterator.hxx>
#include <Interface_InterfaceModel.hxx>
#include <StepData_StepModel.hxx>
@@ -172,6 +173,7 @@
#include <StepShape_ToleranceValue.hxx>
#include <StepShape_ValueFormatTypeQualifier.hxx>
#include <StepShape_Vertex.hxx>
#include <StepToGeom.hxx>
#include <StepVisual_AnnotationCurveOccurrence.hxx>
#include <StepVisual_AnnotationPlane.hxx>
#include <StepVisual_DraughtingCallout.hxx>
@@ -1961,7 +1963,7 @@ Standard_Boolean readAnnotationPlane(const Handle(StepVisual_AnnotationPlane) th
// (Dimension, Geometric_Tolerance, Datum_Feature or Placed_Datum_Target_Feature)
//=======================================================================
void readAnnotation(const Handle(XSControl_TransferReader)& theTR,
const Handle(Standard_Transient) theGDT,
const Handle(Standard_Transient)& theGDT,
const Handle(Standard_Transient)& theDimObject)
{
if (theGDT.IsNull() || theDimObject.IsNull())
@@ -2258,240 +2260,307 @@ static Standard_Integer FindShapeIndexForDGT(const Handle(Standard_Transient)& t
return 0;
}
//=======================================================================
//function : collectShapeAspect
//purpose :
//=======================================================================
static void collectShapeAspect(const Handle(StepRepr_ShapeAspect)& theSA,
const Handle(XSControl_WorkSession)& theWS,
NCollection_Sequence<Handle(StepRepr_ShapeAspect)>& theSAs)
{
if (theSA.IsNull())
return;
Handle(XSControl_TransferReader) aTR = theWS->TransferReader();
Handle(Transfer_TransientProcess) aTP = aTR->TransientProcess();
const Interface_Graph& aGraph = aTP->Graph();
// Retrieve Shape_Aspect, connected to Representation_Item from Derived_Shape_Aspect
if (theSA->IsKind(STANDARD_TYPE(StepRepr_DerivedShapeAspect))) {
Interface_EntityIterator anIter = aGraph.Sharings(theSA);
Handle(StepRepr_ShapeAspectDerivingRelationship) aSADR = NULL;
for (; aSADR.IsNull() && anIter.More(); anIter.Next()) {
aSADR = Handle(StepRepr_ShapeAspectDerivingRelationship)::DownCast(anIter.Value());
}
if (!aSADR.IsNull())
collectShapeAspect(aSADR->RelatedShapeAspect(), theWS, theSAs);
}
else if (theSA->IsKind(STANDARD_TYPE(StepDimTol_DatumFeature)) ||
theSA->IsKind(STANDARD_TYPE(StepDimTol_DatumTarget))) {
theSAs.Append(theSA);
return;
}
else {
// Find all children Shape_Aspect
Standard_Boolean isSimple = Standard_True;
Interface_EntityIterator anIter = aGraph.Sharings(theSA);
for (; anIter.More(); anIter.Next()) {
if (anIter.Value()->IsKind(STANDARD_TYPE(StepRepr_ShapeAspectRelationship)) &&
!anIter.Value()->IsKind(STANDARD_TYPE(StepShape_DimensionalLocation))) {
Handle(StepRepr_ShapeAspectRelationship) aSAR =
Handle(StepRepr_ShapeAspectRelationship)::DownCast(anIter.Value());
if (aSAR->RelatingShapeAspect() == theSA && !aSAR->RelatedShapeAspect().IsNull()
&& !aSAR->RelatedShapeAspect()->IsKind(STANDARD_TYPE(StepDimTol_Datum))) {
collectShapeAspect(aSAR->RelatedShapeAspect(), theWS, theSAs);
isSimple = Standard_False;
}
}
}
// If not Composite_Shape_Aspect (or subtype) append to sequence.
if (isSimple)
theSAs.Append(theSA);
}
}
//=======================================================================
//function : getShapeLabel
//purpose :
//=======================================================================
static TDF_Label getShapeLabel(const Handle(StepRepr_RepresentationItem)& theItem,
const Handle(XSControl_WorkSession)& theWS,
const Handle(XCAFDoc_ShapeTool)& theShapeTool)
{
TDF_Label aShapeL;
const Handle(Transfer_TransientProcess) &aTP = theWS->TransferReader()->TransientProcess();
Standard_Integer index = FindShapeIndexForDGT(theItem, theWS);
TopoDS_Shape aShape;
if (index > 0) {
Handle(Transfer_Binder) aBinder = aTP->MapItem(index);
aShape = TransferBRep::ShapeResult(aBinder);
}
if (aShape.IsNull())
return aShapeL;
theShapeTool->Search(aShape, aShapeL, Standard_True, Standard_True, Standard_True);
return aShapeL;
}
//=======================================================================
//function : setDatumToXCAF
//purpose :
//=======================================================================
static Standard_Boolean setDatumToXCAF(const Handle(StepDimTol_Datum)& theDat,
const TDF_Label theGDTL,
const Standard_Integer thePositionCounter,
const XCAFDimTolObjects_DatumModifiersSequence& aXCAFModifiers,
const XCAFDimTolObjects_DatumModifWithValue aXCAFModifWithVal,
const Standard_Real aModifValue,
const Handle(TDocStd_Document)& theDoc,
const Handle(XSControl_WorkSession)& theWS)
const TDF_Label theGDTL,
const Standard_Integer thePositionCounter,
const XCAFDimTolObjects_DatumModifiersSequence& theXCAFModifiers,
const XCAFDimTolObjects_DatumModifWithValue theXCAFModifWithVal,
const Standard_Real theModifValue,
const Handle(TDocStd_Document)& theDoc,
const Handle(XSControl_WorkSession)& theWS)
{
Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool( theDoc->Main() );
Handle(XCAFDoc_DimTolTool) aDGTTool = XCAFDoc_DocumentTool::DimTolTool( theDoc->Main() );
Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool(theDoc->Main());
Handle(XCAFDoc_DimTolTool) aDGTTool = XCAFDoc_DocumentTool::DimTolTool(theDoc->Main());
const Handle(XSControl_TransferReader) &aTR = theWS->TransferReader();
const Handle(Transfer_TransientProcess) &aTP = aTR->TransientProcess();
const Interface_Graph& aGraph = aTP->Graph();
Handle(XCAFDoc_Datum) aDat;
TDF_Label aShL;
Standard_Boolean aRefShapeIsFound = Standard_False;
Standard_Boolean aFirstStep = Standard_True;
Interface_EntityIterator anIterD = aGraph.Sharings(theDat);
for(anIterD.Start(); anIterD.More(); anIterD.Next()) {
Handle(StepRepr_ShapeAspectRelationship) aSAR =
Handle(StepRepr_ShapeAspectRelationship)::DownCast(anIterD.Value());
if(aSAR.IsNull()) continue;
TDF_LabelSequence aShapeLabels;
Handle(XCAFDimTolObjects_DatumObject) aDatObj = new XCAFDimTolObjects_DatumObject();
Handle(StepRepr_ShapeAspect) aSA = aSAR->RelatingShapeAspect();
if (aSA.IsNull()) continue;
Handle(StepAP242_GeometricItemSpecificUsage) aPGISU;
if(aSA->IsKind(STANDARD_TYPE(StepRepr_CompShAspAndDatumFeatAndShAsp)))
{
//processing for complex entity
Interface_EntityIterator anIterC = aGraph.Sharings(aSA);
for(anIterC.Start(); anIterC.More(); anIterC.Next()) {
Handle(StepRepr_ShapeAspectRelationship) SAR =
Handle(StepRepr_ShapeAspectRelationship)::DownCast(anIterC.Value());
if(SAR.IsNull()) continue;
Handle(StepRepr_ShapeAspect) aS = SAR->RelatedShapeAspect();
if(aS.IsNull()) continue;
Interface_EntityIterator anIterSA = aGraph.Sharings(aS);
for(anIterSA.Start(); anIterSA.More() && aPGISU.IsNull(); anIterSA.Next()) {
aPGISU = Handle(StepAP242_GeometricItemSpecificUsage)::DownCast(anIterSA.Value());
}
if(!aPGISU.IsNull()){
aSA = aS;
break;
}
}
}
else if(aSA->IsKind(STANDARD_TYPE(StepDimTol_PlacedDatumTargetFeature)))
{
//processing for datum target
Interface_EntityIterator anIterDTF = aGraph.Sharings(aSA);
for(anIterDTF.Start(); anIterDTF.More(); anIterDTF.Next()) {
if(anIterDTF.Value()->IsKind(STANDARD_TYPE(StepRepr_FeatureForDatumTargetRelationship)))
{
Handle(StepRepr_FeatureForDatumTargetRelationship) aFFDTR =
Handle(StepRepr_FeatureForDatumTargetRelationship)::DownCast(anIterDTF.Value());
Handle(StepRepr_ShapeAspect) aTmpSA = aFFDTR->RelatedShapeAspect();
Interface_EntityIterator anIterDSWP = aGraph.Sharings(aTmpSA);
for(anIterDSWP.Start(); anIterDSWP.More() && aPGISU.IsNull(); anIterDSWP.Next()) {
aPGISU = Handle(StepAP242_GeometricItemSpecificUsage)::DownCast(anIterDSWP.Value());
}
}
}
}
if (aSA.IsNull()) continue;
Interface_EntityIterator anIterDSWP = aGraph.Sharings(aSA);
for(anIterDSWP.Start(); anIterDSWP.More() && aPGISU.IsNull(); anIterDSWP.Next()) {
aPGISU = Handle(StepAP242_GeometricItemSpecificUsage)::DownCast(anIterDSWP.Value());
}
if(aPGISU.IsNull()) continue;
// get representation item
Handle(StepRepr_RepresentationItem) aRI;
for(Standard_Integer i = 1 ; i <= aPGISU->NbIdentifiedItem() && aRI.IsNull(); i++)
{
aRI = aPGISU->IdentifiedItemValue(i);
}
if(aRI.IsNull()) continue;
Standard_Integer index = FindShapeIndexForDGT(aRI, theWS);
TopoDS_Shape aSh;
if(index >0) {
Handle(Transfer_Binder) binder = aTP->MapItem(index);
aSh = TransferBRep::ShapeResult(binder);
}
if(aSh.IsNull()) continue;
if( !aSTool->Search(aSh, aShL, Standard_True, Standard_True, Standard_True) ) continue;
Handle(TDataStd_TreeNode) aNode;
if(aFirstStep && aShL.FindAttribute(XCAFDoc::DatumRefGUID(),aNode) && aNode->HasFirst() &&
aNode->First()->Label().FindAttribute(XCAFDoc_Datum::GetID(),aDat))
{
//if datums already attached, not need add datum target
aRefShapeIsFound = Standard_True;
}
aFirstStep = Standard_False;
Handle(XCAFDimTolObjects_DatumObject) aDatObj;
if(aSA->IsKind(STANDARD_TYPE(StepDimTol_PlacedDatumTargetFeature)))
{
if(!aRefShapeIsFound)
{
//if datum targers not yet added
TDF_Label aDatL = aDGTTool->AddDatum();
aDat = XCAFDoc_Datum::Set(aDatL);
aDGTTool->SetDatum(aShL, aDatL);
aDatObj = aDat->GetObject();
aDatObj->SetName(theDat->Identification());
aDatObj->SetPosition (thePositionCounter);
if(!aXCAFModifiers.IsEmpty())
aDatObj->SetModifiers(aXCAFModifiers);
if (aXCAFModifWithVal != XCAFDimTolObjects_DatumModifWithValue_None)
aDatObj->SetModifierWithValue(aXCAFModifWithVal, aModifValue);
aDGTTool->SetDatumToGeomTol(aDatL, theGDTL);
Handle(StepDimTol_PlacedDatumTargetFeature) aPDTF = Handle(StepDimTol_PlacedDatumTargetFeature)::DownCast(aSA);
if (aPDTF->TargetId()->IsIntegerValue())
aDatObj->SetDatumTargetNumber(aPDTF->TargetId()->IntegerValue());
else
aDatObj->SetDatumTargetNumber(0);
aDatObj->IsDatumTarget(Standard_True);
XCAFDimTolObjects_DatumTargetType aType;
if(STEPCAFControl_GDTProperty::GetDatumTargetType(aSA->Description(),aType))
{
aDatObj->SetDatumTargetType(aType);
if(aType == XCAFDimTolObjects_DatumTargetType_Area)
{
Interface_EntityIterator anIterDTF = aGraph.Shareds(aSA);
for(anIterDTF.Start(); anIterDTF.More(); anIterDTF.Next()) {
if(anIterDTF.Value()->IsKind(STANDARD_TYPE(StepAP242_GeometricItemSpecificUsage)))
{
Handle(StepAP242_GeometricItemSpecificUsage) aGISU
= Handle(StepAP242_GeometricItemSpecificUsage)::DownCast(anIterDSWP.Value());
Handle(StepRepr_RepresentationItem) anItem;
if(aPGISU->NbIdentifiedItem() > 0) {
anItem = aPGISU->IdentifiedItemValue(1);
}
if(anItem.IsNull()) continue;
Standard_Integer anItemIndex = FindShapeIndexForDGT(anItem, theWS);
if(anItemIndex >0) {
Handle(Transfer_Binder) binder = aTP->MapItem(anItemIndex);
TopoDS_Shape anItemShape = TransferBRep::ShapeResult(binder);
aDatObj->SetDatumTarget(anItemShape);
}
}
}
}
else
{
Interface_EntityIterator anIterDTF = aGraph.Shareds(aSA);
for(anIterDTF.Start(); anIterDTF.More(); anIterDTF.Next()) {
if(anIterDTF.Value()->IsKind(STANDARD_TYPE(StepRepr_PropertyDefinition)))
{
Interface_EntityIterator anIterPD = aGraph.Shareds(anIterDTF.Value());
for(anIterPD.Start(); anIterPD.More(); anIterPD.Next()) {
if(anIterPD.Value()->IsKind(STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation)))
{
Interface_EntityIterator anIterSDR = aGraph.Sharings(anIterPD.Value());
for(anIterSDR.Start(); anIterSDR.More(); anIterSDR.Next()) {
if(anIterSDR.Value()->IsKind(STANDARD_TYPE(StepShape_ShapeRepresentationWithParameters)))
{
Handle(StepShape_ShapeRepresentationWithParameters) aSRWP
= Handle(StepShape_ShapeRepresentationWithParameters)::DownCast(anIterSDR.Value());
for(Standard_Integer r = aSRWP->Items()->Lower(); r <= aSRWP->Items()->Upper(); r++)
{
if(aSRWP->ItemsValue(r)->IsKind(STANDARD_TYPE(StepGeom_Axis2Placement3d)))
{
Handle(StepGeom_Axis2Placement3d) anAx
= Handle(StepGeom_Axis2Placement3d)::DownCast(aSRWP->ItemsValue(r));
Handle(TColStd_HArray1OfReal) aDirArr = anAx->Axis()->DirectionRatios();
Handle(TColStd_HArray1OfReal) aDirRArr = anAx->RefDirection()->DirectionRatios();
Handle(TColStd_HArray1OfReal) aLocArr = anAx->Location()->Coordinates();
gp_Dir aDir;
gp_Dir aDirR;
gp_Pnt aPnt;
if(!aDirArr.IsNull() && aDirArr->Length() > 2 &&
!aDirRArr.IsNull() && aDirRArr->Length() > 2 &&
!aLocArr.IsNull() && aLocArr->Length() > 2)
{
aDir.SetCoord(aDirArr->Lower(), aDirArr->Lower()+1, aDirArr->Lower()+2);
aDirR.SetCoord(aDirRArr->Lower(), aDirRArr->Lower()+1, aDirRArr->Lower()+2);
aPnt.SetCoord(aLocArr->Lower(), aLocArr->Lower()+1, aLocArr->Lower()+2);
gp_Ax2 anA(aPnt, aDir, aDirR);
aDatObj->SetDatumTargetAxis(anA);
}
}
else if(aSRWP->ItemsValue(r)->IsKind(STANDARD_TYPE(StepRepr_ReprItemAndLengthMeasureWithUnit)))
{
Handle(StepRepr_ReprItemAndLengthMeasureWithUnit) aM =
Handle(StepRepr_ReprItemAndLengthMeasureWithUnit)::DownCast(aSRWP->ItemsValue(r));
Standard_Real aVal = aM->GetMeasureWithUnit()->ValueComponent();
StepBasic_Unit anUnit = aM->GetMeasureWithUnit()->UnitComponent();
Standard_Real aFact=1.;
if(anUnit.IsNull()) continue;
if( !(anUnit.CaseNum(anUnit.Value())==1) ) continue;
Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
if(GetLengthConversionFactor(NU,aFact)) aVal=aVal*aFact;
if(aM->Name()->String().IsEqual("target length") ||
aM->Name()->String().IsEqual("target diameter"))
aDatObj->SetDatumTargetLength(aVal);
else
aDatObj->SetDatumTargetWidth(aVal);
}
}
}
}
}
}
}
}
}
}
}
}
else
{
//processing for darum feature
TDF_Label aDatL = aDGTTool->AddDatum();
aDat = XCAFDoc_Datum::Set(aDatL);
aDGTTool->SetDatum(aShL, aDatL);
aDatObj = aDat->GetObject();
aDatObj->SetName(theDat->Identification());
aDatObj->SetPosition (thePositionCounter);
if(!aXCAFModifiers.IsEmpty())
aDatObj->SetModifiers(aXCAFModifiers);
if (aXCAFModifWithVal != XCAFDimTolObjects_DatumModifWithValue_None)
aDatObj->SetModifierWithValue(aXCAFModifWithVal, aModifValue);
aDGTTool->SetDatumToGeomTol(aDatL, theGDTL);
}
if(!aDatObj.IsNull()) {
// Collect all links to shapes
NCollection_Sequence<Handle(StepRepr_ShapeAspect)> aSAs;
Interface_EntityIterator anIterD = aGraph.Sharings(theDat);
for (anIterD.Start(); anIterD.More(); anIterD.Next()) {
Handle(StepRepr_ShapeAspectRelationship) aSAR = Handle(StepRepr_ShapeAspectRelationship)::DownCast(anIterD.Value());
if (aSAR.IsNull() || aSAR->RelatingShapeAspect().IsNull())
continue;
collectShapeAspect(aSAR->RelatingShapeAspect(), theWS, aSAs);
Handle(StepDimTol_DatumFeature) aDF = Handle(StepDimTol_DatumFeature)::DownCast(aSAR->RelatingShapeAspect());
if (!aSAR->RelatingShapeAspect()->IsKind(STANDARD_TYPE(StepDimTol_DatumTarget)))
readAnnotation(aTR, aSAR->RelatingShapeAspect(), aDatObj);
aDat->SetObject(aDatObj);
}
// Collect shape labels
for (Standard_Integer i = 1; i <= aSAs.Length(); i++) {
Handle(StepRepr_ShapeAspect) aSA = aSAs.Value(i);
if (aSA.IsNull())
continue;
// Skip datum targets
if (aSA->IsKind(STANDARD_TYPE(StepDimTol_DatumTarget)))
continue;
// Process all connected GISU
Interface_EntityIterator anIter = aGraph.Sharings(aSA);
for (; anIter.More(); anIter.Next()) {
Handle(StepAP242_GeometricItemSpecificUsage) aGISU = Handle(StepAP242_GeometricItemSpecificUsage)::DownCast(anIter.Value());
if (aGISU.IsNull())
continue;
for (Standard_Integer i = 1; i <= aGISU->NbIdentifiedItem(); i++) {
TDF_Label aShapeL = getShapeLabel(aGISU->IdentifiedItemValue(i), theWS, aSTool);
if (!aShapeL.IsNull())
aShapeLabels.Append(aShapeL);
}
}
}
return !aDat.IsNull();
// Process datum targets and create objects for them
Standard_Boolean isExistDatumTarget = Standard_False;
for (Standard_Integer i = 1; i <= aSAs.Length(); i++) {
Handle(StepDimTol_PlacedDatumTargetFeature) aDT = Handle(StepDimTol_PlacedDatumTargetFeature)::DownCast(aSAs.Value(i));
if (aDT.IsNull())
continue;
Handle(XCAFDimTolObjects_DatumObject) aDatObj = new XCAFDimTolObjects_DatumObject();
XCAFDimTolObjects_DatumTargetType aType;
if (!STEPCAFControl_GDTProperty::GetDatumTargetType(aDT->Description(), aType))
continue;
aDatObj->SetDatumTargetType(aType);
Standard_Boolean isValidDT = Standard_False;
// Feature for datum target
TDF_LabelSequence aDTShapeLabels;
Interface_EntityIterator anIter = aGraph.Sharings(aDT);
Handle(StepRepr_FeatureForDatumTargetRelationship) aRelationship;
for (; anIter.More() && aRelationship.IsNull(); anIter.Next()) {
aRelationship = Handle(StepRepr_FeatureForDatumTargetRelationship)::DownCast(anIter.Value());
}
if (!aRelationship.IsNull()) {
Handle(StepRepr_ShapeAspect) aSA = aRelationship->RelatingShapeAspect();
Interface_EntityIterator aSAIter = aGraph.Sharings(aSA);
for (; aSAIter.More(); aSAIter.Next()) {
Handle(StepAP242_GeometricItemSpecificUsage) aGISU = Handle(StepAP242_GeometricItemSpecificUsage)::DownCast(aSAIter.Value());
if (aGISU.IsNull())
continue;
for (Standard_Integer i = 1; i <= aGISU->NbIdentifiedItem(); i++) {
TDF_Label aShapeL = getShapeLabel(aGISU->IdentifiedItemValue(i), theWS, aSTool);
if (!aShapeL.IsNull()) {
aDTShapeLabels.Append(aShapeL);
isValidDT = Standard_True;
}
}
}
}
if (aType != XCAFDimTolObjects_DatumTargetType_Area && !isValidDT) {
// Try another way of feature connection
for (anIter.Start(); anIter.More(); anIter.Next()) {
Handle(StepAP242_GeometricItemSpecificUsage) aGISU = Handle(StepAP242_GeometricItemSpecificUsage)::DownCast(anIter.Value());
if (aGISU.IsNull())
continue;
for (Standard_Integer i = 1; i <= aGISU->NbIdentifiedItem(); i++) {
TDF_Label aShapeL = getShapeLabel(aGISU->IdentifiedItemValue(i), theWS, aSTool);
if (!aShapeL.IsNull()) {
aDTShapeLabels.Append(aShapeL);
isValidDT = Standard_True;
}
}
}
}
if (aType == XCAFDimTolObjects_DatumTargetType_Area) {
// Area datum target
Interface_EntityIterator anIterDTF = aGraph.Shareds(aDT);
Handle(StepAP242_GeometricItemSpecificUsage) aGISU;
for (; anIterDTF.More() && aGISU.IsNull(); anIterDTF.Next()) {
aGISU = Handle(StepAP242_GeometricItemSpecificUsage)::DownCast(anIterDTF.Value());
}
Handle(StepRepr_RepresentationItem) anItem;
if (aGISU->NbIdentifiedItem() > 0)
anItem = aGISU->IdentifiedItemValue(1);
if (anItem.IsNull())
continue;
Standard_Integer anItemIndex = FindShapeIndexForDGT(anItem, theWS);
if (anItemIndex > 0) {
Handle(Transfer_Binder) aBinder = aTP->MapItem(anItemIndex);
TopoDS_Shape anItemShape = TransferBRep::ShapeResult(aBinder);
aDatObj->SetDatumTarget(anItemShape);
isValidDT = Standard_True;
}
}
else {
// Point/line/rectangle/circle datum targets
Interface_EntityIterator anIter = aGraph.Sharings(aDT);
Handle(StepRepr_PropertyDefinition) aPD;
for (; anIter.More() && aPD.IsNull(); anIter.Next()) {
aPD = Handle(StepRepr_PropertyDefinition)::DownCast(anIter.Value());
}
if (!aPD.IsNull()) {
anIter = aGraph.Sharings(aPD);
Handle(StepShape_ShapeDefinitionRepresentation) aSDR;
for (; anIter.More() && aSDR.IsNull(); anIter.Next()) {
aSDR = Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(anIter.Value());
}
if (!aSDR.IsNull()) {
Handle(StepShape_ShapeRepresentationWithParameters) aSRWP
= Handle(StepShape_ShapeRepresentationWithParameters)::DownCast(aSDR->UsedRepresentation());
if (!aSRWP.IsNull()) {
isValidDT = Standard_True;
// Collect parameters of datum target
for (Standard_Integer i = aSRWP->Items()->Lower(); i <= aSRWP->Items()->Upper(); i++)
{
if (aSRWP->ItemsValue(i).IsNull())
continue;
if (aSRWP->ItemsValue(i)->IsKind(STANDARD_TYPE(StepGeom_Axis2Placement3d)))
{
Handle(StepGeom_Axis2Placement3d) anAx
= Handle(StepGeom_Axis2Placement3d)::DownCast(aSRWP->ItemsValue(i));
Handle(Geom_Axis2Placement) anAxis = StepToGeom::MakeAxis2Placement(anAx);
aDatObj->SetDatumTargetAxis(anAxis->Ax2());
}
else if (aSRWP->ItemsValue(i)->IsKind(STANDARD_TYPE(StepRepr_ReprItemAndLengthMeasureWithUnit)))
{
Handle(StepRepr_ReprItemAndLengthMeasureWithUnit) aM =
Handle(StepRepr_ReprItemAndLengthMeasureWithUnit)::DownCast(aSRWP->ItemsValue(i));
Standard_Real aVal = aM->GetMeasureWithUnit()->ValueComponent();
StepBasic_Unit anUnit = aM->GetMeasureWithUnit()->UnitComponent();
Standard_Real aFact = 1.;
if (anUnit.IsNull())
continue;
Handle(StepBasic_NamedUnit) aNU = anUnit.NamedUnit();
if (aNU.IsNull())
continue;
if (GetLengthConversionFactor(aNU, aFact))
aVal = aVal * aFact;
if (aM->Name()->String().IsEqual("target length") ||
aM->Name()->String().IsEqual("target diameter"))
aDatObj->SetDatumTargetLength(aVal);
else
aDatObj->SetDatumTargetWidth(aVal);
}
}
}
}
}
}
// Create datum target object
if (isValidDT) {
TDF_Label aDatL = aDGTTool->AddDatum();
aDat = XCAFDoc_Datum::Set(aDatL);
aDGTTool->SetDatum(aDTShapeLabels, aDatL);
aDatObj->SetName(theDat->Identification());
aDatObj->SetPosition(thePositionCounter);
if (!theXCAFModifiers.IsEmpty())
aDatObj->SetModifiers(theXCAFModifiers);
if (theXCAFModifWithVal != XCAFDimTolObjects_DatumModifWithValue_None)
aDatObj->SetModifierWithValue(theXCAFModifWithVal, theModifValue);
aDGTTool->SetDatumToGeomTol(aDatL, theGDTL);
aDatObj->IsDatumTarget(Standard_True);
aDatObj->SetDatumTargetNumber(aDT->TargetId()->IntegerValue());
readAnnotation(aTR, aDT, aDatObj);
aDat->SetObject(aDatObj);
isExistDatumTarget = Standard_True;
}
}
if (aShapeLabels.Length() > 0 || !isExistDatumTarget) {
// Create object for datum
TDF_Label aDatL = aDGTTool->AddDatum();
aDat = XCAFDoc_Datum::Set(aDatL);
aDGTTool->SetDatum(aShapeLabels, aDatL);
aDatObj->SetName(theDat->Identification());
aDatObj->SetPosition(thePositionCounter);
if (!theXCAFModifiers.IsEmpty())
aDatObj->SetModifiers(theXCAFModifiers);
if (theXCAFModifWithVal != XCAFDimTolObjects_DatumModifWithValue_None)
aDatObj->SetModifierWithValue(theXCAFModifWithVal, theModifValue);
aDGTTool->SetDatumToGeomTol(aDatL, theGDTL);
if (aDatObj->GetPresentation().IsNull()) {
// Try find annotation connected to datum entity (not right case, according recommended practices)
readAnnotation(aTR, theDat, aDatObj);
}
aDat->SetObject(aDatObj);
}
return Standard_True;
}
@@ -2504,8 +2573,6 @@ static Standard_Boolean readDatumsAP242(const Handle(Standard_Transient)& theEnt
const Handle(TDocStd_Document)& theDoc,
const Handle(XSControl_WorkSession)& theWS)
{
Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool( theDoc->Main() );
Handle(XCAFDoc_DimTolTool) aDGTTool = XCAFDoc_DocumentTool::DimTolTool( theDoc->Main() );
const Handle(XSControl_TransferReader) &aTR = theWS->TransferReader();
const Handle(Transfer_TransientProcess) &aTP = aTR->TransientProcess();
const Interface_Graph& aGraph = aTP->Graph();
@@ -2645,55 +2712,6 @@ static Standard_Boolean readDatumsAP242(const Handle(Standard_Transient)& theEnt
return Standard_True;
}
//=======================================================================
//function : collectShapeAspect
//purpose :
//=======================================================================
static void collectShapeAspect(const Handle(StepRepr_ShapeAspect)& theSA,
const Handle(XSControl_WorkSession)& theWS,
NCollection_Sequence<Handle(StepRepr_ShapeAspect)>& theSAs)
{
if (theSA.IsNull())
return;
Handle(XSControl_TransferReader) aTR = theWS->TransferReader();
Handle(Transfer_TransientProcess) aTP = aTR->TransientProcess();
const Interface_Graph& aGraph = aTP->Graph();
// Retrieve Shape_Aspect, connected to Representation_Item from Derived_Shape_Aspect
if (theSA->IsKind(STANDARD_TYPE(StepRepr_DerivedShapeAspect))) {
Interface_EntityIterator anIter = aGraph.Sharings(theSA);
Handle(StepRepr_ShapeAspectDerivingRelationship) aSADR = NULL;
for (; aSADR.IsNull() && anIter.More(); anIter.Next()) {
aSADR = Handle(StepRepr_ShapeAspectDerivingRelationship)::DownCast(anIter.Value());
}
if (!aSADR.IsNull())
collectShapeAspect(aSADR->RelatedShapeAspect(), theWS, theSAs);
}
else if (theSA->IsKind(STANDARD_TYPE(StepDimTol_DatumFeature))) {
theSAs.Append(theSA);
return;
}
else {
// Find all children Shape_Aspect
Standard_Boolean isSimple = Standard_True;
Interface_EntityIterator anIter = aGraph.Sharings(theSA);
for (; anIter.More(); anIter.Next()) {
if (anIter.Value()->IsKind(STANDARD_TYPE(StepRepr_ShapeAspectRelationship)) &&
!anIter.Value()->IsKind(STANDARD_TYPE(StepShape_DimensionalLocation))) {
Handle(StepRepr_ShapeAspectRelationship) aSAR =
Handle(StepRepr_ShapeAspectRelationship)::DownCast(anIter.Value());
if (aSAR->RelatingShapeAspect() == theSA) {
collectShapeAspect(aSAR->RelatedShapeAspect(), theWS, theSAs);
isSimple = Standard_False;
}
}
}
// If not Composite_Shape_Aspect (or subtype) append to sequence.
if (isSimple)
theSAs.Append(theSA);
}
}
//=======================================================================
//function : createGeomTolObjectInXCAF
//purpose :

View File

@@ -241,6 +241,7 @@
static NCollection_Vector<Handle(StepVisual_AnnotationPlane)> gdtAnnotationPlanes;
static Handle(StepVisual_DraughtingModel) gdtPresentationDM;
static Handle(StepVisual_HArray1OfPresentationStyleAssignment) gdtPrsCurveStyle;
static Handle(StepRepr_ProductDefinitionShape) gdtCommonPDS;
// added by skl 15.01.2004 for D&GT writing
//#include <StepRepr_CompoundItemDefinition.hxx>
@@ -2490,7 +2491,7 @@ static void WritePresentation(const Handle(XSControl_WorkSession) &WS,
// in case of multiple features association)
//=======================================================================
static Handle(StepDimTol_Datum) WriteDatumAP242(const Handle(XSControl_WorkSession) &WS,
const TDF_Label theShapeL,
const TDF_LabelSequence theShapeL,
const TDF_Label theDatumL,
const Standard_Boolean isFirstDTarget,
const Handle(StepDimTol_Datum) theWrittenDatum)
@@ -2505,31 +2506,51 @@ static Handle(StepDimTol_Datum) WriteDatumAP242(const Handle(XSControl_WorkSessi
Interface_Graph aGraph = aHGraph->Graph();
Handle(StepRepr_ShapeAspect) aSA;
Handle(StepAP242_GeometricItemSpecificUsage) aGISU;
// Link with datum feature
Handle(StepRepr_ProductDefinitionShape) aPDS;
Handle(StepRepr_RepresentationContext) aRC;
Handle(Standard_Transient) anEnt;
TopoDS_Shape aShape;
TopLoc_Location aLoc;
TColStd_SequenceOfTransient aSeqRI;
Handle(StepRepr_ProductDefinitionShape) aPDS;
NCollection_Sequence<Handle(StepRepr_ShapeAspect)> aSASeq;
Handle(StepAP242_GeometricItemSpecificUsage) aGISU;
Standard_Integer aSANum = 0, aGISUNum = 0;
// Link with datum feature
for (Standard_Integer i = 1; i <= theShapeL.Length(); i++) {
Handle(Standard_Transient) anEnt;
TopoDS_Shape aShape;
TopLoc_Location aLoc;
TColStd_SequenceOfTransient aSeqRI;
aShape = XCAFDoc_ShapeTool::GetShape(theShapeL);
FindEntities( FP, aShape, aLoc, aSeqRI );
if ( aSeqRI.Length() <= 0 ) {
FP->Messenger() << "Warning: Cannot find RI for "<<aShape.TShape()->DynamicType()->Name()<<endl;
return NULL;
aShape = XCAFDoc_ShapeTool::GetShape(theShapeL.Value(i));
FindEntities(FP, aShape, aLoc, aSeqRI);
if (aSeqRI.Length() <= 0) {
FP->Messenger() << "Warning: Cannot find RI for " << aShape.TShape()->DynamicType()->Name() << endl;
continue;
}
anEnt = aSeqRI.Value(1);
aPDS = FindPDS(aGraph, anEnt, aRC);
if (aPDS.IsNull())
continue;
Handle(StepRepr_ShapeAspect) aCurrentSA = WriteShapeAspect(WS, theDatumL, aShape, aRC, aGISU);
if (aCurrentSA.IsNull())
continue;
aSASeq.Append(aCurrentSA);
aSANum = Model->Number(aCurrentSA);
aGISUNum = Model->Number(aGISU);
}
if (aPDS.IsNull()) {
// Workaround for datums without shape
aPDS = gdtCommonPDS;
Interface_EntityIterator aSDRIt = aGraph.Sharings(aPDS);
Handle(StepShape_ShapeDefinitionRepresentation) aSDR;
for (aSDRIt.Start(); aSDRIt.More() && aSDR.IsNull(); aSDRIt.Next())
aSDR = Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(aSDRIt.Value());
if (!aSDR.IsNull()) {
Handle(StepRepr_Representation) aRepr = aSDR->UsedRepresentation();
if (!aRepr.IsNull())
aRC = aRepr->ContextOfItems();
}
}
anEnt = aSeqRI.Value(1);
aPDS = FindPDS(aGraph, anEnt, aRC);
if (aPDS.IsNull())
return NULL;
aSA = WriteShapeAspect(WS, theDatumL, aShape, aRC, aGISU);
if (aSA.IsNull())
return NULL;
Standard_Integer aSANum = Model->Number(aSA);
Standard_Integer aGISUNum = Model->Number(aGISU);
// Find if datum has datum targets and get common datum attributes
Handle(XCAFDoc_Datum) aDatumAttr;
if (!theDatumL.FindAttribute(XCAFDoc_Datum::GetID(), aDatumAttr))
@@ -2549,14 +2570,34 @@ static Handle(StepDimTol_Datum) WriteDatumAP242(const Handle(XSControl_WorkSessi
// Simple datum
if (isSimpleDatum) {
Handle(StepDimTol_DatumFeature) aDF = new StepDimTol_DatumFeature();
aDF->Init(new TCollection_HAsciiString(), new TCollection_HAsciiString(), aSA->OfShape(), aSA->ProductDefinitional());
Model->ReplaceEntity(aSANum, aDF);
aSA = aDF;
StepAP242_ItemIdentifiedRepresentationUsageDefinition aDefinition;
aDefinition.SetValue(aDF);
aGISU->SetDefinition(aDefinition);
Model->ReplaceEntity(aGISUNum, aGISU);
if (aSASeq.Length() == 0) {
// Create empty datum with name and presentation only
Handle(StepDimTol_DatumFeature) aDF = new StepDimTol_DatumFeature();
aDF->Init(new TCollection_HAsciiString(), new TCollection_HAsciiString(), aPDS, StepData_LTrue);
aSA = aDF;
Model->AddWithRefs(aDF);
}
else if (aSASeq.Length() == 1) {
Handle(StepDimTol_DatumFeature) aDF = new StepDimTol_DatumFeature();
aDF->Init(new TCollection_HAsciiString(), new TCollection_HAsciiString(), aPDS, StepData_LTrue);
Model->ReplaceEntity(aSANum, aDF);
aSA = aDF;
StepAP242_ItemIdentifiedRepresentationUsageDefinition aDefinition;
aDefinition.SetValue(aDF);
aGISU->SetDefinition(aDefinition);
Model->ReplaceEntity(aGISUNum, aGISU);
}
else if (aSASeq.Length() > 1) {
Handle(StepRepr_CompShAspAndDatumFeatAndShAsp) aDF = new StepRepr_CompShAspAndDatumFeatAndShAsp();
aDF->Init(new TCollection_HAsciiString(), new TCollection_HAsciiString(), aPDS, StepData_LTrue);
for (Standard_Integer i = 1; i <= aSASeq.Length(); i++) {
Handle(StepRepr_ShapeAspectRelationship) aSAR = new StepRepr_ShapeAspectRelationship();
aSAR->Init(new TCollection_HAsciiString(), Standard_False, new TCollection_HAsciiString(), aDF, aSASeq.Value(i));
Model->AddWithRefs(aSAR);
}
aSA = aDF;
Model->AddWithRefs(aDF);
}
}
// Datum with datum targets
else {
@@ -2571,13 +2612,13 @@ static Handle(StepDimTol_Datum) WriteDatumAP242(const Handle(XSControl_WorkSessi
aGISUNum = Model->Number(anAreaGISU);
Handle(StepDimTol_DatumTarget) aDT = new StepDimTol_DatumTarget();
aDT->Init(new TCollection_HAsciiString(), new TCollection_HAsciiString("area"), anAreaSA->OfShape(),
anAreaSA->ProductDefinitional(), aTargetId);
StepData_LTrue, aTargetId);
Model->ReplaceEntity(aSANum, aDT);
StepAP242_ItemIdentifiedRepresentationUsageDefinition aDefinition;
aDefinition.SetValue(aDT);
anAreaGISU->SetDefinition(aDefinition);
Model->ReplaceEntity(aGISUNum, anAreaGISU);
}
}
else {
Handle(StepDimTol_PlacedDatumTargetFeature) aPDTF = new StepDimTol_PlacedDatumTargetFeature();
aPDTF->Init(new TCollection_HAsciiString(), STEPCAFControl_GDTProperty::GetDatumTargetName(aDatumType),
@@ -2589,59 +2630,76 @@ static Handle(StepDimTol_Datum) WriteDatumAP242(const Handle(XSControl_WorkSessi
StepRepr_CharacterizedDefinition aCDefinition;
aCDefinition.SetValue(aPDTF);
aPD->Init(new TCollection_HAsciiString(), Standard_False, NULL, aCDefinition);
Handle(StepShape_ShapeRepresentationWithParameters) aSRWP = new StepShape_ShapeRepresentationWithParameters();
// Common for all datum targets
StepBasic_Unit aUnit = GetUnit(aRC);
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) {
anItems = new StepRepr_HArray1OfRepresentationItem(1, 1);
}
else {
Handle(TCollection_HAsciiString) aTargetValueName;
if (aDatumType == XCAFDimTolObjects_DatumTargetType_Line) {
anItems = new StepRepr_HArray1OfRepresentationItem(1, 2);
aTargetValueName = new TCollection_HAsciiString("target length");
if (anObject->HasDatumTargetParams()) {
// write all parameters of datum target
Handle(StepShape_ShapeRepresentationWithParameters) aSRWP = new StepShape_ShapeRepresentationWithParameters();
// Common for all datum targets
StepBasic_Unit aUnit = GetUnit(aRC);
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) {
anItems = new StepRepr_HArray1OfRepresentationItem(1, 1);
}
else if (aDatumType == XCAFDimTolObjects_DatumTargetType_Rectangle) {
anItems = new StepRepr_HArray1OfRepresentationItem(1, 3);
aTargetValueName = new TCollection_HAsciiString("target length");
// Additional value
Handle(StepRepr_ReprItemAndMeasureWithUnit) aTargetValue = CreateDimValue(anObject->GetDatumTargetWidth(),
aUnit, new TCollection_HAsciiString("target width"), "POSITIVE_LENGTH_MEASURE", Standard_False);
anItems->SetValue(2, aTargetValue);
else {
Handle(TCollection_HAsciiString) aTargetValueName;
if (aDatumType == XCAFDimTolObjects_DatumTargetType_Line) {
anItems = new StepRepr_HArray1OfRepresentationItem(1, 2);
aTargetValueName = new TCollection_HAsciiString("target length");
}
else if (aDatumType == XCAFDimTolObjects_DatumTargetType_Rectangle) {
anItems = new StepRepr_HArray1OfRepresentationItem(1, 3);
aTargetValueName = new TCollection_HAsciiString("target length");
// Additional value
Handle(StepRepr_ReprItemAndMeasureWithUnit) aTargetValue = CreateDimValue(anObject->GetDatumTargetWidth(),
aUnit, new TCollection_HAsciiString("target width"), "POSITIVE_LENGTH_MEASURE", Standard_False);
anItems->SetValue(2, aTargetValue);
Model->AddWithRefs(aTargetValue);
}
else if (aDatumType == XCAFDimTolObjects_DatumTargetType_Circle) {
anItems = new StepRepr_HArray1OfRepresentationItem(1, 2);
aTargetValueName = new TCollection_HAsciiString("target diameter");
}
// Value
Handle(StepRepr_ReprItemAndMeasureWithUnit) aTargetValue = CreateDimValue(anObject->GetDatumTargetLength(),
aUnit, aTargetValueName, "POSITIVE_LENGTH_MEASURE", Standard_False);
anItems->SetValue(1, aTargetValue);
Model->AddWithRefs(aTargetValue);
}
else if (aDatumType == XCAFDimTolObjects_DatumTargetType_Circle) {
anItems = new StepRepr_HArray1OfRepresentationItem(1, 2);
aTargetValueName = new TCollection_HAsciiString("target diameter");
}
// Value
Handle(StepRepr_ReprItemAndMeasureWithUnit) aTargetValue= CreateDimValue(anObject->GetDatumTargetLength(),
aUnit, aTargetValueName, "POSITIVE_LENGTH_MEASURE", Standard_False);
anItems->SetValue(1, aTargetValue);
Model->AddWithRefs(aTargetValue);
anItems->SetValue(anItems->Length(), anA2P3D);
aSRWP->Init(new TCollection_HAsciiString(), anItems, aRC);
// Create and write auxiliary entities
Handle(StepShape_ShapeDefinitionRepresentation) aSDR = new StepShape_ShapeDefinitionRepresentation();
StepRepr_RepresentedDefinition aRDefinition;
aRDefinition.SetValue(aPD);
aSDR->Init(aRDefinition, aSRWP);
Model->AddWithRefs(aPD);
Model->AddWithRefs(aSRWP);
Model->AddWithRefs(aSDR);
}
anItems->SetValue(anItems->Length(), anA2P3D);
aSRWP->Init(new TCollection_HAsciiString(), anItems, aRC);
// Create and write auxiliary entities
Handle (StepShape_ShapeDefinitionRepresentation) aSDR = new StepShape_ShapeDefinitionRepresentation();
StepRepr_RepresentedDefinition aRDefinition;
aRDefinition.SetValue(aPD);
aSDR->Init(aRDefinition, aSRWP);
Model->AddWithRefs(aPD);
Model->AddWithRefs(aSRWP);
Model->AddWithRefs(aSDR);
}
// Link datum target to datum feature
Handle(StepRepr_FeatureForDatumTargetRelationship) aFFDTR = new StepRepr_FeatureForDatumTargetRelationship();
aFFDTR->Init(new TCollection_HAsciiString(), Standard_False, NULL, aDatumTarget, aSA);
Model->AddWithRefs(aFFDTR);
// if aSASeq.Length() == 0 nothing to do
if (aSASeq.Length() == 1) {
Handle(StepRepr_FeatureForDatumTargetRelationship) aFFDTR = new StepRepr_FeatureForDatumTargetRelationship();
aFFDTR->Init(new TCollection_HAsciiString(), Standard_False, NULL, aSASeq.Value(1), aDatumTarget);
Model->AddWithRefs(aFFDTR);
}
else if (aSASeq.Length() > 1) {
Handle(StepRepr_CompositeShapeAspect) aCompSA = new StepRepr_CompositeShapeAspect();
aCompSA->Init(new TCollection_HAsciiString(), new TCollection_HAsciiString(), aPDS, aSASeq.Value(1)->ProductDefinitional());
for (Standard_Integer i = 1; i <= aSASeq.Length(); i++) {
Handle(StepRepr_ShapeAspectRelationship) aSAR = new StepRepr_ShapeAspectRelationship();
aSAR->Init(new TCollection_HAsciiString(), Standard_False, new TCollection_HAsciiString(), aCompSA, aSASeq.Value(i));
Model->AddWithRefs(aSAR);
}
Handle(StepRepr_FeatureForDatumTargetRelationship) aFFDTR = new StepRepr_FeatureForDatumTargetRelationship();
aFFDTR->Init(new TCollection_HAsciiString(), Standard_False, NULL, aCompSA, aDatumTarget);
Model->AddWithRefs(aFFDTR);
}
aSA = aDatumTarget;
}
@@ -2649,34 +2707,16 @@ static Handle(StepDimTol_Datum) WriteDatumAP242(const Handle(XSControl_WorkSessi
Handle(StepDimTol_Datum) aDatum = theWrittenDatum;
if (isFirstDTarget) {
aDatum = new StepDimTol_Datum();
aDatum->Init(new TCollection_HAsciiString(), new TCollection_HAsciiString(), aPDS, StepData_LTrue, anIdentifier);
aDatum->Init(new TCollection_HAsciiString(), new TCollection_HAsciiString(), aPDS, StepData_LFalse, anIdentifier);
Model->AddWithRefs(aDatum);
}
// Shape_Aspect_Relationship
Handle(StepRepr_ShapeAspectRelationship) aSAR = new StepRepr_ShapeAspectRelationship();
aSAR->Init(new TCollection_HAsciiString(), Standard_False, NULL, aSA, aDatum);
Model->AddWithRefs(aSAR);
// Auxiliary entities
// Property_Definition
Handle(StepRepr_PropertyDefinition) aPD = new StepRepr_PropertyDefinition();
Handle(TCollection_HAsciiString) aPDName = new TCollection_HAsciiString("Datum Feature Symbol ");
aPDName = aPDName->Cat(anIdentifier)->Cat(aTargetId);
StepRepr_CharacterizedDefinition aCD;
aCD.SetValue(aSA);
aPD->Init(aPDName, Standard_False, NULL, aCD);
Model->AddWithRefs(aPD);
// Shape_Representation
Handle(StepShape_ShapeRepresentation) aShapeRepr = new StepShape_ShapeRepresentation();
aShapeRepr->Init(aPDName, aGISU->IdentifiedItem(), aRC);
Model->AddWithRefs(aShapeRepr);
// Shape_Definition_Representation
Handle (StepShape_ShapeDefinitionRepresentation) aSDR = new StepShape_ShapeDefinitionRepresentation();
StepRepr_RepresentedDefinition aRDefinition;
aRDefinition.SetValue(aPD);
aSDR->Init(aRDefinition, aShapeRepr);
Model->AddWithRefs(aSDR);
if (!aSA.IsNull()) {
Handle(StepRepr_ShapeAspectRelationship) aSAR = new StepRepr_ShapeAspectRelationship();
aSAR->Init(new TCollection_HAsciiString(), Standard_False, NULL, aSA, aDatum);
Model->AddWithRefs(aSAR);
}
//Annotation plane and Presentation
WritePresentation(WS, anObject->GetPresentation(), anObject->GetPresentationName(), anObject->GetPlane(), anObject->GetPointTextAttach(), aSA);
@@ -3733,6 +3773,9 @@ Standard_Boolean STEPCAFControl_Writer::WriteDGTsAP242 (const Handle(XSControl_W
Handle(StepRepr_RepresentationItem) anItem = NULL;
gdtPrsCurveStyle = new StepVisual_HArray1OfPresentationStyleAssignment(1, 1);
gdtPrsCurveStyle->SetValue(1, aStyles.MakeColorPSA(anItem, aCurvColor, aCurvColor));
Interface_EntityIterator aModelIter = aModel->Entities();
for (; aModelIter.More() && gdtCommonPDS.IsNull(); aModelIter.Next())
gdtCommonPDS = Handle(StepRepr_ProductDefinitionShape)::DownCast(aModelIter.Value());
TDF_LabelSequence aDGTLabels;
STEPConstruct_DataMapOfAsciiStringTransient aDatumMap;
@@ -3746,10 +3789,8 @@ Standard_Boolean STEPCAFControl_Writer::WriteDGTsAP242 (const Handle(XSControl_W
TColStd_MapOfAsciiString aNameIdMap;
for(Standard_Integer i = 1; i <= aDGTLabels.Length(); i++) {
TDF_Label aDatumL = aDGTLabels.Value(i);
TDF_LabelSequence aShapeL;
TDF_LabelSequence aNullSeq;
if(!DGTTool->GetRefShapeLabel(aDatumL, aShapeL, aNullSeq))
continue;
TDF_LabelSequence aShapeL, aNullSeq;
DGTTool->GetRefShapeLabel(aDatumL, aShapeL, aNullSeq);
Handle(XCAFDoc_Datum) aDatumAttr;
aDatumL.FindAttribute(XCAFDoc_Datum::GetID(), aDatumAttr);
Handle(XCAFDimTolObjects_DatumObject) anObject = aDatumAttr->GetObject();
@@ -3759,7 +3800,7 @@ Standard_Boolean STEPCAFControl_Writer::WriteDGTsAP242 (const Handle(XSControl_W
continue;
Handle(Standard_Transient) aWrittenDatum;
Standard_Boolean isFirstDT = !aDatumMap.Find(aDatumName, aWrittenDatum);
Handle(StepDimTol_Datum) aDatum = WriteDatumAP242(WS, aShapeL.First(), aDatumL, isFirstDT,
Handle(StepDimTol_Datum) aDatum = WriteDatumAP242(WS, aShapeL, aDatumL, isFirstDT,
Handle(StepDimTol_Datum)::DownCast (aWrittenDatum));
// Add created Datum into Map
aDatumMap.Bind(aDatumName, aDatum);