From: ika Date: Wed, 9 Mar 2016 11:25:17 +0000 (+0300) Subject: 0027235: Export GDT: Annotation plane and Presentation. X-Git-Tag: V7_0_winwerth~116 X-Git-Url: http://git.dev.opencascade.org/gitweb/?p=occt.git;a=commitdiff_plain;h=b0cef6061a34dfbfd74065c86f029bd651cc2ae2 0027235: Export GDT: Annotation plane and Presentation. Implement Null_Style STEP type. Implement export of annotation planes and presentation as tessellated geometry. Add tests. --- diff --git a/src/QABugs/QABugs_20.cxx b/src/QABugs/QABugs_20.cxx index f9b2e2bd41..9e619f1567 100644 --- a/src/QABugs/QABugs_20.cxx +++ b/src/QABugs/QABugs_20.cxx @@ -35,6 +35,19 @@ #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include //======================================================================= //function : SurfaceGenOCC26675_1 //purpose : Generates a surface for intersect (in corresponding @@ -1418,6 +1431,90 @@ static Standard_Integer OCC27021(Draw_Interpretor& theDI, return 0; } +//======================================================================= +//function : OCC27235 +//purpose : check presentation in GDT document +//======================================================================= +static Standard_Integer OCC27235 (Draw_Interpretor& theDI, Standard_Integer n, const char** a) +{ + if (n < 2) { + theDI<<"Use: OCC27235 Doc"; + return 1; + } + + Handle(TDocStd_Document) Doc; + DDocStd::GetDocument(a[1], Doc); + if ( Doc.IsNull() ) { theDI << a[1] << " is not a document\n"; return 1; } + Handle(XCAFDoc_DimTolTool) aDimTolTool= XCAFDoc_DocumentTool::DimTolTool(Doc->Main()); + Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); + TopoDS_Compound aPresentations; + BRep_Builder B; + B.MakeCompound(aPresentations); + + TDF_LabelSequence aLabels; + aShapeTool->GetShapes(aLabels); + for ( Standard_Integer i=1; i <= aLabels.Length(); i++ ) + { + aShapeTool->GetSubShapes(aLabels.Value(i), aLabels); + } + + TDF_LabelSequence aGDTs; + aDimTolTool->GetDimensionLabels(aGDTs); + for (Standard_Integer i = 1; i <= aGDTs.Length(); i++) { + Handle(XCAFDoc_Dimension) aDimAttr; + if (!aGDTs.Value(i).FindAttribute(XCAFDoc_Dimension::GetID(),aDimAttr)) + continue; + Handle(XCAFDimTolObjects_DimensionObject) anObject = aDimAttr->GetObject(); + if (anObject.IsNull()) + continue; + TopoDS_Shape aShape = anObject->GetPresentation(); + if (!aShape.IsNull()) + B.Add(aPresentations, aShape); + } + + aGDTs.Clear(); + aDimTolTool->GetGeomToleranceLabels(aGDTs); + for (Standard_Integer i = 1; i <= aGDTs.Length(); i++) { + Handle(XCAFDoc_GeomTolerance) aGTAttr; + if (!aGDTs.Value(i).FindAttribute(XCAFDoc_GeomTolerance::GetID(),aGTAttr)) + continue; + Handle(XCAFDimTolObjects_GeomToleranceObject) anObject = aGTAttr->GetObject(); + if (anObject.IsNull()) + continue; + TopoDS_Shape aShape = anObject->GetPresentation(); + if (!aShape.IsNull()) + B.Add(aPresentations, aShape); + } + + for ( Standard_Integer i=1; i <= aLabels.Length(); i++ ) + { + TDF_LabelSequence aDatL; + if(aDimTolTool->GetRefDatumLabel(aLabels.Value(i), aDatL)) + { + for(Standard_Integer j = aDatL.Lower(); j <= aDatL.Upper(); j++) + { + Handle(XCAFDoc_Datum) aDat; + if(!aDatL.Value(j).FindAttribute(XCAFDoc_Datum::GetID(), aDat)) + continue; + Handle(XCAFDimTolObjects_DatumObject) anObject = aDat->GetObject(); + if (anObject.IsNull()) + continue; + TopoDS_Shape aShape = anObject->GetPresentation(); + if (!aShape.IsNull()) + B.Add(aPresentations, aShape); + } + } + } + + GProp_GProps aG; + BRepGProp::LinearProperties(aPresentations, aG); + gp_Pnt aPnt = aG.CentreOfMass(); + theDI << "Centre of mass: " << aPnt.X() << " " << aPnt.Y() << " " << aPnt.Z() << "\n"; + theDI << "Mass: " << aG.Mass() << "\n"; + + return 0; +} + void QABugs::Commands_20(Draw_Interpretor& theCommands) { const char *group = "QABugs"; @@ -1425,6 +1522,7 @@ void QABugs::Commands_20(Draw_Interpretor& theCommands) { theCommands.Add ("OCC26675_1", "OCC26675_1 result", __FILE__, SurfaceGenOCC26675_1, group); theCommands.Add ("OCC24836", "OCC24836", __FILE__, OCC24836, group); theCommands.Add("OCC27021", "OCC27021", __FILE__, OCC27021, group); + theCommands.Add("OCC27235", "OCC27235", __FILE__, OCC27235, group); return; } diff --git a/src/RWStepAP214/RWStepAP214_GeneralModule.cxx b/src/RWStepAP214/RWStepAP214_GeneralModule.cxx index 07ef03fe04..b7baa69d10 100644 --- a/src/RWStepAP214/RWStepAP214_GeneralModule.cxx +++ b/src/RWStepAP214/RWStepAP214_GeneralModule.cxx @@ -5076,6 +5076,13 @@ void RWStepAP214_GeneralModule::FillSharedCase(const Standard_Integer CN, tool.Share(anent,iter); } break; + case 710: + { + DeclareAndCast(StepVisual_TessellatedCurveSet,anent,ent); + RWStepVisual_RWTessellatedCurveSet tool; + tool.Share(anent,iter); + } + break; default : break; } } diff --git a/src/RWStepAP214/RWStepAP214_ReadWriteModule.cxx b/src/RWStepAP214/RWStepAP214_ReadWriteModule.cxx index 718eb4a9a6..06a620805e 100644 --- a/src/RWStepAP214/RWStepAP214_ReadWriteModule.cxx +++ b/src/RWStepAP214/RWStepAP214_ReadWriteModule.cxx @@ -14090,7 +14090,7 @@ void RWStepAP214_ReadWriteModule::WriteStep(const Standard_Integer CN, break; case 711: { - DeclareAndCast(StepVisual_CoordinatesList,anent,ent); + DeclareAndCast(StepVisual_CoordinatesList,anent,ent); RWStepVisual_RWCoordinatesList tool; tool.WriteStep(SW,anent); diff --git a/src/RWStepVisual/RWStepVisual_RWPresentationStyleAssignment.cxx b/src/RWStepVisual/RWStepVisual_RWPresentationStyleAssignment.cxx index a18767d10f..76a200f056 100644 --- a/src/RWStepVisual/RWStepVisual_RWPresentationStyleAssignment.cxx +++ b/src/RWStepVisual/RWStepVisual_RWPresentationStyleAssignment.cxx @@ -15,8 +15,10 @@ #include #include #include +#include #include #include +#include #include #include #include @@ -37,18 +39,28 @@ void RWStepVisual_RWPresentationStyleAssignment::ReadStep // --- own field : styles --- - Handle(StepVisual_HArray1OfPresentationStyleSelect) aStyles; - StepVisual_PresentationStyleSelect aStylesItem; - Standard_Integer nsub1; - if (data->ReadSubList (num,1,"styles",ach,nsub1)) { - Standard_Integer nb1 = data->NbParams(nsub1); - aStyles = new StepVisual_HArray1OfPresentationStyleSelect (1, nb1); - for (Standard_Integer i1 = 1; i1 <= nb1; i1 ++) { - //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed - if (data->ReadEntity (nsub1,i1,"styles",ach,aStylesItem)) - aStyles->SetValue(i1,aStylesItem); - } - } + Handle(StepVisual_HArray1OfPresentationStyleSelect) aStyles; + StepVisual_PresentationStyleSelect aStylesItem; + Standard_Integer nsub1; + if (data->ReadSubList (num,1,"styles",ach,nsub1)) { + Standard_Integer nb1 = data->NbParams(nsub1); + aStyles = new StepVisual_HArray1OfPresentationStyleSelect (1, nb1); + for (Standard_Integer i1 = 1; i1 <= nb1; i1 ++) { + Interface_ParamType aType = data->ParamType(nsub1, i1); + if (aType == Interface_ParamIdent) { + data->ReadEntity (nsub1,i1,"styles",ach,aStylesItem); + } + else { + Handle(StepData_SelectMember) aMember; + data->ReadMember(nsub1, i1, "null_style", ach, aMember); + Standard_CString anEnumText = aMember->EnumText(); + Handle(StepVisual_NullStyleMember) aNullStyle = new StepVisual_NullStyleMember(); + aNullStyle->SetEnumText(0, anEnumText); + aStylesItem.SetValue(aNullStyle); + } + aStyles->SetValue(i1,aStylesItem); + } + } //--- Initialisation of the read entity --- @@ -65,9 +77,16 @@ void RWStepVisual_RWPresentationStyleAssignment::WriteStep // --- own field : styles --- SW.OpenSub(); - for (Standard_Integer i1 = 1; i1 <= ent->NbStyles(); i1 ++) { - SW.Send(ent->StylesValue(i1).Value()); - } + for (Standard_Integer i1 = 1; i1 <= ent->NbStyles(); i1 ++) { + StepVisual_PresentationStyleSelect aStyle = ent->StylesValue(i1); + if (aStyle.Value()->IsKind(STANDARD_TYPE(StepVisual_NullStyleMember))) { + SW.OpenTypedSub("NULL_STYLE"); + SW.SendEnum(".NULL."); + SW.CloseSub(); + } + else + SW.Send(aStyle.Value()); + } SW.CloseSub(); } diff --git a/src/RWStepVisual/RWStepVisual_RWPresentationStyleByContext.cxx b/src/RWStepVisual/RWStepVisual_RWPresentationStyleByContext.cxx index 576367c22d..69eb7cad8f 100644 --- a/src/RWStepVisual/RWStepVisual_RWPresentationStyleByContext.cxx +++ b/src/RWStepVisual/RWStepVisual_RWPresentationStyleByContext.cxx @@ -15,9 +15,11 @@ #include #include #include +#include #include #include #include +#include #include #include #include @@ -38,18 +40,28 @@ void RWStepVisual_RWPresentationStyleByContext::ReadStep // --- inherited field : styles --- - Handle(StepVisual_HArray1OfPresentationStyleSelect) aStyles; - StepVisual_PresentationStyleSelect aStylesItem; - Standard_Integer nsub1; - if (data->ReadSubList (num,1,"styles",ach,nsub1)) { - Standard_Integer nb1 = data->NbParams(nsub1); - aStyles = new StepVisual_HArray1OfPresentationStyleSelect (1, nb1); - for (Standard_Integer i1 = 1; i1 <= nb1; i1 ++) { - //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed - if (data->ReadEntity (nsub1,i1,"styles",ach,aStylesItem)) - aStyles->SetValue(i1,aStylesItem); - } - } + Handle(StepVisual_HArray1OfPresentationStyleSelect) aStyles; + StepVisual_PresentationStyleSelect aStylesItem; + Standard_Integer nsub1; + if (data->ReadSubList (num,1,"styles",ach,nsub1)) { + Standard_Integer nb1 = data->NbParams(nsub1); + aStyles = new StepVisual_HArray1OfPresentationStyleSelect (1, nb1); + for (Standard_Integer i1 = 1; i1 <= nb1; i1 ++) { + Interface_ParamType aType = data->ParamType(nsub1, i1); + if (aType == Interface_ParamIdent) { + data->ReadEntity (nsub1,i1,"styles",ach,aStylesItem); + } + else { + Handle(StepData_SelectMember) aMember; + data->ReadMember(nsub1, i1, "null_style", ach, aMember); + Standard_CString anEnumText = aMember->EnumText(); + Handle(StepVisual_NullStyleMember) aNullStyle = new StepVisual_NullStyleMember(); + aNullStyle->SetEnumText(0, anEnumText); + aStylesItem.SetValue(aNullStyle); + } + aStyles->SetValue(i1,aStylesItem); + } + } // --- own field : styleContext --- @@ -72,9 +84,16 @@ void RWStepVisual_RWPresentationStyleByContext::WriteStep // --- inherited field styles --- SW.OpenSub(); - for (Standard_Integer i1 = 1; i1 <= ent->NbStyles(); i1 ++) { - SW.Send(ent->StylesValue(i1).Value()); - } +for (Standard_Integer i1 = 1; i1 <= ent->NbStyles(); i1 ++) { + StepVisual_PresentationStyleSelect aStyle = ent->StylesValue(i1); + if (aStyle.Value()->IsKind(STANDARD_TYPE(StepVisual_NullStyleMember))) { + SW.OpenTypedSub("NULL_STYLE"); + SW.SendEnum(".NULL."); + SW.CloseSub(); + } + else + SW.Send(aStyle.Value()); + } SW.CloseSub(); // --- own field : styleContext --- diff --git a/src/RWStepVisual/RWStepVisual_RWTessellatedCurveSet.cxx b/src/RWStepVisual/RWStepVisual_RWTessellatedCurveSet.cxx index ec8326b8f8..520dfcc727 100644 --- a/src/RWStepVisual/RWStepVisual_RWTessellatedCurveSet.cxx +++ b/src/RWStepVisual/RWStepVisual_RWTessellatedCurveSet.cxx @@ -103,3 +103,15 @@ void RWStepVisual_RWTessellatedCurveSet::WriteStep } SW.CloseSub(); } + +//======================================================================= +//function : Share +//purpose : +//======================================================================= +void RWStepVisual_RWTessellatedCurveSet::Share (const Handle(StepVisual_TessellatedCurveSet) &ent, + Interface_EntityIterator& iter) const +{ + // Own filed : coordinates + iter.AddItem (ent->CoordList()); +} + diff --git a/src/RWStepVisual/RWStepVisual_RWTessellatedCurveSet.hxx b/src/RWStepVisual/RWStepVisual_RWTessellatedCurveSet.hxx index 5f1a01f9bc..0e3a982760 100644 --- a/src/RWStepVisual/RWStepVisual_RWTessellatedCurveSet.hxx +++ b/src/RWStepVisual/RWStepVisual_RWTessellatedCurveSet.hxx @@ -43,5 +43,7 @@ public: const Handle(StepVisual_TessellatedCurveSet)& ent) const; Standard_EXPORT void WriteStep (StepData_StepWriter& SW, const Handle(StepVisual_TessellatedCurveSet)& ent) const; + + Standard_EXPORT void Share (const Handle(StepVisual_TessellatedCurveSet) &ent, Interface_EntityIterator& iter) const; }; #endif // _RWStepVisual_RWTessellatedItem_HeaderFile diff --git a/src/RWStepVisual/RWStepVisual_RWTessellatedGeometricSet.cxx b/src/RWStepVisual/RWStepVisual_RWTessellatedGeometricSet.cxx index e1bfc63a07..04fa0918b6 100644 --- a/src/RWStepVisual/RWStepVisual_RWTessellatedGeometricSet.cxx +++ b/src/RWStepVisual/RWStepVisual_RWTessellatedGeometricSet.cxx @@ -48,11 +48,11 @@ void RWStepVisual_RWTessellatedGeometricSet::ReadStep Handle(TCollection_HAsciiString) aName; data->ReadString (num, 1, "name", ach, aName); - NCollection_Handle anItems; + NCollection_Handle anItems; Standard_Integer nsub2; if (data->ReadSubList (num,2,"items",ach,nsub2)) { Standard_Integer nb2 = data->NbParams(nsub2); - anItems = new StepVisual_Array1OfTessellaltedItem(1, nb2); + anItems = new StepVisual_Array1OfTessellatedItem(1, nb2); for (Standard_Integer i2 = 1; i2 <= nb2; i2 ++) { Handle(StepVisual_TessellatedItem) anItem;// = new StepVisual_TesselatedItem; if (data->ReadEntity (nsub2,i2,"item",ach,STANDARD_TYPE(StepVisual_TessellatedItem), anItem)) diff --git a/src/STEPCAFControl/STEPCAFControl_GDTProperty.cxx b/src/STEPCAFControl/STEPCAFControl_GDTProperty.cxx index e0087de036..1d4d0c4ae4 100644 --- a/src/STEPCAFControl/STEPCAFControl_GDTProperty.cxx +++ b/src/STEPCAFControl/STEPCAFControl_GDTProperty.cxx @@ -13,6 +13,11 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. +#include +#include +#include +#include +#include #include #include #include @@ -25,6 +30,11 @@ #include #include #include +#include +#include +#include +#include +#include #include #include @@ -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 aCurves = new StepVisual_VectorOfHSequenceOfInteger; + NCollection_Vector 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 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; +} diff --git a/src/STEPCAFControl/STEPCAFControl_GDTProperty.hxx b/src/STEPCAFControl/STEPCAFControl_GDTProperty.hxx index 552b90f559..09f433c988 100644 --- a/src/STEPCAFControl/STEPCAFControl_GDTProperty.hxx +++ b/src/STEPCAFControl/STEPCAFControl_GDTProperty.hxx @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -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 diff --git a/src/STEPCAFControl/STEPCAFControl_Reader.cxx b/src/STEPCAFControl/STEPCAFControl_Reader.cxx index 9065cb9cf7..abab08952a 100644 --- a/src/STEPCAFControl/STEPCAFControl_Reader.cxx +++ b/src/STEPCAFControl/STEPCAFControl_Reader.cxx @@ -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 aListItems = aTessSet->Items(); + NCollection_Handle 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++) diff --git a/src/STEPCAFControl/STEPCAFControl_Writer.cxx b/src/STEPCAFControl/STEPCAFControl_Writer.cxx index d502b2dfd8..7a053b1820 100644 --- a/src/STEPCAFControl/STEPCAFControl_Writer.cxx +++ b/src/STEPCAFControl/STEPCAFControl_Writer.cxx @@ -27,9 +27,11 @@ #include #include #include +#include #include #include #include +#include #include #include #include @@ -106,6 +108,7 @@ #include #include #include +#include #include #include #include @@ -153,7 +156,10 @@ #include #include #include +#include #include +#include +#include #include #include #include @@ -161,6 +167,7 @@ #include #include #include +#include #include #include #include @@ -168,6 +175,8 @@ #include #include #include +#include +#include #include #include #include @@ -232,6 +241,9 @@ enum DimensionalValueNumber { DimensionalValueNumber_Lower, DimensionalValueNumber_Upper }; +static NCollection_Vector gdtAnnotationPlanes; +static Handle(StepVisual_DraughtingModel) gdtPresentationDM; +static Handle(StepVisual_HArray1OfPresentationStyleAssignment) gdtPrsCurveStyle; // added by skl 15.01.2004 for D> writing //#include @@ -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; } diff --git a/src/StepDimTol/StepDimTol_SimpleDatumReferenceModifierMember.hxx b/src/StepDimTol/StepDimTol_SimpleDatumReferenceModifierMember.hxx index 243045a840..cba5948912 100644 --- a/src/StepDimTol/StepDimTol_SimpleDatumReferenceModifierMember.hxx +++ b/src/StepDimTol/StepDimTol_SimpleDatumReferenceModifierMember.hxx @@ -13,8 +13,8 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -#ifndef _StepVisual_MarkerMember_HeaderFile -#define _StepVisual_MarkerMember_HeaderFile +#ifndef _StepDimTol_SimpleDatumReferenceModifierMember_HeaderFile +#define _StepDimTol_SimpleDatumReferenceModifierMember_HeaderFile #include #include diff --git a/src/StepVisual/FILES b/src/StepVisual/FILES index 7368423c57..387555749a 100644 --- a/src/StepVisual/FILES +++ b/src/StepVisual/FILES @@ -124,6 +124,9 @@ StepVisual_MechanicalDesignGeometricPresentationArea.cxx StepVisual_MechanicalDesignGeometricPresentationArea.hxx StepVisual_MechanicalDesignGeometricPresentationRepresentation.cxx StepVisual_MechanicalDesignGeometricPresentationRepresentation.hxx +StepVisual_NullStyle.hxx +StepVisual_NullStyleMember.cxx +StepVisual_NullStyleMember.hxx StepVisual_OverRidingStyledItem.cxx StepVisual_OverRidingStyledItem.hxx StepVisual_PlanarBox.cxx diff --git a/src/StepVisual/StepVisual_NullStyle.hxx b/src/StepVisual/StepVisual_NullStyle.hxx new file mode 100644 index 0000000000..6eff163166 --- /dev/null +++ b/src/StepVisual/StepVisual_NullStyle.hxx @@ -0,0 +1,25 @@ +// Created on: 2016-03-09 +// Created by: Irina KRYLOVA +// Copyright (c) 2016 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef _StepVisual_NullStyle_HeaderFile +#define _StepVisual_NullStyle_HeaderFile + +#include + +enum StepVisual_NullStyle { + StepVisual_Null +}; + +#endif diff --git a/src/StepVisual/StepVisual_NullStyleMember.cxx b/src/StepVisual/StepVisual_NullStyleMember.cxx new file mode 100644 index 0000000000..36299706b0 --- /dev/null +++ b/src/StepVisual/StepVisual_NullStyleMember.cxx @@ -0,0 +1,72 @@ +// Created on: 2015-07-16 +// Created by: Irina KRYLOVA +// Copyright (c) 2015 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include +#include +#include + +IMPLEMENT_STANDARD_RTTIEXT(StepVisual_NullStyleMember,StepData_SelectInt) + +static StepData_EnumTool tool + (".NULL."); + +//======================================================================= +//function : StepVisual_NullStyleMember +//purpose : +//======================================================================= + +StepVisual_NullStyleMember::StepVisual_NullStyleMember () { } + +//======================================================================= +//function : EnumText +//purpose : +//======================================================================= + +Standard_CString StepVisual_NullStyleMember::EnumText () const +{ + return tool.Text(Int()).ToCString(); +} + +//======================================================================= +//function : SetEnumText +//purpose : +//======================================================================= + +void StepVisual_NullStyleMember::SetEnumText (const Standard_Integer /*theValue*/, + const Standard_CString theText) +{ + Standard_Integer aVal = tool.Value (theText); + if (aVal >= 0) SetInt (aVal); +} + +//======================================================================= +//function : SetValue +//purpose : +//======================================================================= + +void StepVisual_NullStyleMember::SetValue (const StepVisual_NullStyle theValue) +{ + SetInt ( Standard_Integer (theValue) ); +} + +//======================================================================= +//function : Value +//purpose : +//======================================================================= + +StepVisual_NullStyle StepVisual_NullStyleMember::Value () const +{ + return StepVisual_NullStyle (Int()); +} diff --git a/src/StepVisual/StepVisual_NullStyleMember.hxx b/src/StepVisual/StepVisual_NullStyleMember.hxx new file mode 100644 index 0000000000..d94b607b00 --- /dev/null +++ b/src/StepVisual/StepVisual_NullStyleMember.hxx @@ -0,0 +1,61 @@ +// Created on: 2016-03-09 +// Created by: Irina KRYLOVA +// Copyright (c) 2016 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef _StepVisual_NullStyleMember_HeaderFile +#define _StepVisual_NullStyleMember_HeaderFile + +#include +#include + +#include +#include +#include +#include +#include + +class StepVisual_NullStyleMember; +DEFINE_STANDARD_HANDLE(StepVisual_NullStyleMember, StepData_SelectInt) +//! Defines NullStyle as unique member of PresentationStyleSelect +//! Works with an EnumTool +class StepVisual_NullStyleMember : public StepData_SelectInt +{ + +public: + + Standard_EXPORT StepVisual_NullStyleMember(); + + virtual Standard_Boolean HasName() const Standard_OVERRIDE + { return Standard_True; } + + virtual Standard_CString Name() const Standard_OVERRIDE + { return "NULL_STYLE"; } + + virtual Standard_Boolean SetName(const Standard_CString /*theName*/) Standard_OVERRIDE + { return Standard_True; } + + Standard_Integer Kind() const Standard_OVERRIDE + {return 4;} + + Standard_EXPORT virtual Standard_CString EnumText() const Standard_OVERRIDE; + + Standard_EXPORT virtual void SetEnumText (const Standard_Integer theValue, const Standard_CString theText) Standard_OVERRIDE; + + Standard_EXPORT void SetValue (const StepVisual_NullStyle theValue) ; + + Standard_EXPORT StepVisual_NullStyle Value() const; + + DEFINE_STANDARD_RTTIEXT(StepVisual_NullStyleMember,StepData_SelectInt) +}; +#endif // _StepVisual_NullStyleMember_HeaderFile diff --git a/src/StepVisual/StepVisual_PresentationStyleSelect.cxx b/src/StepVisual/StepVisual_PresentationStyleSelect.cxx index 084516810a..3e67e19c3e 100644 --- a/src/StepVisual/StepVisual_PresentationStyleSelect.cxx +++ b/src/StepVisual/StepVisual_PresentationStyleSelect.cxx @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -32,6 +33,7 @@ Standard_Integer StepVisual_PresentationStyleSelect::CaseNum(const Handle(Standa // if (ent->IsKind(STANDARD_TYPE(StepVisual_SymbolStyle))) return 4; // if (ent->IsKind(STANDARD_TYPE(StepVisual_FillAreaStyle))) return 5; // if (ent->IsKind(STANDARD_TYPE(StepVisual_TextStyle))) return 6; + if (ent->IsKind(STANDARD_TYPE(StepVisual_NullStyleMember))) return 7; return 0; } @@ -45,6 +47,11 @@ Handle(StepVisual_CurveStyle) StepVisual_PresentationStyleSelect::CurveStyle () return GetCasted(StepVisual_CurveStyle,Value()); } +Handle(StepVisual_NullStyleMember) StepVisual_PresentationStyleSelect::NullStyle () const +{ + return GetCasted(StepVisual_NullStyleMember,Value()); +} + Handle(StepVisual_SurfaceStyleUsage) StepVisual_PresentationStyleSelect::SurfaceStyleUsage () const { return GetCasted(StepVisual_SurfaceStyleUsage,Value()); diff --git a/src/StepVisual/StepVisual_PresentationStyleSelect.hxx b/src/StepVisual/StepVisual_PresentationStyleSelect.hxx index cc42b586de..d8f5a3fab8 100644 --- a/src/StepVisual/StepVisual_PresentationStyleSelect.hxx +++ b/src/StepVisual/StepVisual_PresentationStyleSelect.hxx @@ -26,6 +26,7 @@ class Standard_Transient; class StepVisual_PointStyle; class StepVisual_CurveStyle; +class StepVisual_NullStyleMember; class StepVisual_SurfaceStyleUsage; @@ -47,6 +48,7 @@ public: //! 4 -> SymbolStyle //! 5 -> FillAreaStyle //! 6 -> TextStyle + //! 7 -> NullStyle //! 0 else Standard_EXPORT Standard_Integer CaseNum (const Handle(Standard_Transient)& ent) const; @@ -55,6 +57,9 @@ public: //! returns Value as a CurveStyle (Null if another type) Standard_EXPORT Handle(StepVisual_CurveStyle) CurveStyle() const; + + //! returns Value as a NullStyleMember (Null if another type) + Standard_EXPORT Handle(StepVisual_NullStyleMember) NullStyle() const; //! returns Value as a SurfaceStyleUsage (Null if another type) Standard_EXPORT Handle(StepVisual_SurfaceStyleUsage) SurfaceStyleUsage() const; diff --git a/src/StepVisual/StepVisual_TessellatedGeometricSet.cxx b/src/StepVisual/StepVisual_TessellatedGeometricSet.cxx index 48fc26fa2c..8cad96a91d 100644 --- a/src/StepVisual/StepVisual_TessellatedGeometricSet.cxx +++ b/src/StepVisual/StepVisual_TessellatedGeometricSet.cxx @@ -21,13 +21,13 @@ IMPLEMENT_STANDARD_RTTIEXT(StepVisual_TessellatedGeometricSet,StepGeom_Tessellat StepVisual_TessellatedGeometricSet::StepVisual_TessellatedGeometricSet () {} -void StepVisual_TessellatedGeometricSet::Init(const Handle(TCollection_HAsciiString)& theName, const NCollection_Handle& theItems) +void StepVisual_TessellatedGeometricSet::Init(const Handle(TCollection_HAsciiString)& theName, const NCollection_Handle& theItems) { StepRepr_RepresentationItem::Init(theName); myItems = theItems; } -NCollection_Handle StepVisual_TessellatedGeometricSet::Items() const +NCollection_Handle StepVisual_TessellatedGeometricSet::Items() const { return myItems; } diff --git a/src/StepVisual/StepVisual_TessellatedGeometricSet.hxx b/src/StepVisual/StepVisual_TessellatedGeometricSet.hxx index e7b98f6ef7..bc3e373336 100644 --- a/src/StepVisual/StepVisual_TessellatedGeometricSet.hxx +++ b/src/StepVisual/StepVisual_TessellatedGeometricSet.hxx @@ -26,10 +26,8 @@ class Standard_Transient; -typedef NCollection_Array1 StepVisual_Array1OfTessellaltedItem; -//typedef NCollection_Handle Handle(StepVisual_Array1OfTessellaltedItem); +typedef NCollection_Array1 StepVisual_Array1OfTessellatedItem; -//DEFINE_HARRAY1(StepVisual_HArray1OfTessellaltedItem, StepVisual_Array1OfTessellaltedItem) DEFINE_STANDARD_HANDLE(StepVisual_TessellatedGeometricSet, StepVisual_TessellatedItem) class StepVisual_TessellatedGeometricSet : public StepVisual_TessellatedItem { @@ -40,12 +38,12 @@ public: //! Returns a DraughtingCalloutElement select type Standard_EXPORT StepVisual_TessellatedGeometricSet(); - Standard_EXPORT void Init(const Handle(TCollection_HAsciiString)& theName, const NCollection_Handle& theItems); + Standard_EXPORT void Init(const Handle(TCollection_HAsciiString)& theName, const NCollection_Handle& theItems); - Standard_EXPORT NCollection_Handle Items() const; + Standard_EXPORT NCollection_Handle Items() const; private: - NCollection_Handle myItems; + NCollection_Handle myItems; public: diff --git a/tests/gdt/export/end b/tests/gdt/export/end index 3e27bb3dfe..3792789c61 100644 --- a/tests/gdt/export/end +++ b/tests/gdt/export/end @@ -166,7 +166,7 @@ if { $dump_file == 1 } { incr ref_Compare append err_compare_ref " Reference data - $refstr\n" append err_compare_ref " Current data - $curstr\n" - append err_compare_ref " Current data after writing - $curstr\n" + append err_compare_ref " Current data after writing - $cur2str\n" append err_compare_ref "--------------------------------------------------------------------\n" } } diff --git a/tests/gdt/grids.list b/tests/gdt/grids.list index b8a7c11da2..2d4b1d896b 100644 --- a/tests/gdt/grids.list +++ b/tests/gdt/grids.list @@ -2,3 +2,4 @@ 002 tolerances 003 import 004 export +005 presentation diff --git a/tests/gdt/presentation/A1 b/tests/gdt/presentation/A1 new file mode 100644 index 0000000000..97e3f96525 --- /dev/null +++ b/tests/gdt/presentation/A1 @@ -0,0 +1,8 @@ +# !!!! This file is generated automatically, do not edit manually! See end script +set filename bug26689_nist_ctc_01_asme1_ap242.stp + +set ref_data { +Centre of mass: 33.295841310232461 -56.047419205695817 -22.610629589474502 +Mass: 12142.750755797097 + +} diff --git a/tests/gdt/presentation/A2 b/tests/gdt/presentation/A2 new file mode 100644 index 0000000000..baebe917cc --- /dev/null +++ b/tests/gdt/presentation/A2 @@ -0,0 +1,8 @@ +# !!!! This file is generated automatically, do not edit manually! See end script +set filename bug26689_nist_ctc_02_asme1_ap242-2.stp + +set ref_data { +Centre of mass: -7.829938249111005 278.41260705890426 -84.730202273479279 +Mass: 54935.33694421465 + +} diff --git a/tests/gdt/presentation/A3 b/tests/gdt/presentation/A3 new file mode 100644 index 0000000000..e2b7162697 --- /dev/null +++ b/tests/gdt/presentation/A3 @@ -0,0 +1,8 @@ +# !!!! This file is generated automatically, do not edit manually! See end script +set filename bug26689_nist_ctc_04_asme1_ap242.stp + +set ref_data { +Centre of mass: 35.242126579745523 445.83237754232533 -68.402802262745169 +Mass: 9074.4079919607357 + +} diff --git a/tests/gdt/presentation/A4 b/tests/gdt/presentation/A4 new file mode 100644 index 0000000000..2f98748e03 --- /dev/null +++ b/tests/gdt/presentation/A4 @@ -0,0 +1,8 @@ +# !!!! This file is generated automatically, do not edit manually! See end script +set filename bug26689_nist_ctc_05_asme1_ap242-1.stp + +set ref_data { +Centre of mass: 64.344333389783159 73.02072510397285 59.833361341556298 +Mass: 12896.277087016462 + +} diff --git a/tests/gdt/presentation/begin b/tests/gdt/presentation/begin new file mode 100644 index 0000000000..f012867a66 --- /dev/null +++ b/tests/gdt/presentation/begin @@ -0,0 +1 @@ +pload QAcommands diff --git a/tests/gdt/presentation/end b/tests/gdt/presentation/end new file mode 100644 index 0000000000..26a1011860 --- /dev/null +++ b/tests/gdt/presentation/end @@ -0,0 +1,167 @@ +# Set flag dump_file to 1 in order to regenerate script files with actual data +# used as reference. In this mode all tests intentionaly report failure. +set dump_file 0 +######################################################################## +set mist 0; +# First +set x_First 0; set y_First 0; set z_First 0; +set mass_First 0; +# Second +set x_Second 0; set y_Second 0; set z_Second 0; +set mass_Second 0; +################################################################### +set ref_Compare 0 +set todo_msg "" +set todo_mask "puts \"TODO CR27235 ALL: " +set end_line "\" \n" +################################################################## + +# Read original file +if { [string length $filename] > 1} { + set path_file [locate_data_file $filename] + if { [catch { ReadStep D_First $path_file } catch_result] } { + set err_msg "Error: First - file was not read - exception " + puts $err_msg + append todo_msg $todo_mask $err_msg $end_line + set mist 1 + } +} else { + set mist 1 +} + +# Get information presentations +if { $mist < 1} { + puts "" + set xst [ OCC27235 D_First] + + if { [llength $xst] > 0 } { + regexp {Centre of mass+: +([-0-9.+eE]+) +([-0-9.+eE]+) +([-0-9.+eE]+)} $xst full x_First y_First z_First + regexp {Mass+: +([-0-9.+eE]+)} $xst full mass_First + } else { + puts " GDT information was NOT provided" + } +} + +if { $mist != 1 } { + puts "" + set result "" + append result [format $xst] +} + +# Writing file +if { $mist < 1} { + puts " " + puts "-----------------------------WRITING FILE ------------------------------" + if { [catch { WriteStep D_First $imagedir/${casename}_D_First.stp } catch_result] } { + set err_msg "Error: First - file was not written - exception" + puts $err_msg + append todo_msg $todo_mask $err_msg $end_line + set mist 1 + } + if { $mist < 1 } { + if { [catch { ReadStep D_Second $imagedir/${casename}_D_First.stp } catch_result] } { + set err_msg "Error: Second - file was not read - exception" + puts $err_msg + append todo_msg $todo_mask $err_msg $end_line + set mist 1 + } + } +} + +catch {[file delete $imagedir/${casename}_D_First.stp]} +if { [catch { Close D_First } catch_result] } { + set err_msg "Error : cannot close a document D_First - exception" + puts $err_msg +} + +# Get information about translation +if { $mist < 1} { + puts "" + set xst2 [ OCC27235 D_Second] + + if { [llength $xst] > 0 } { + regexp {Centre of mass+: +([-0-9.+eE]+) +([-0-9.+eE]+) +([-0-9.+eE]+)} $xst2 full x_Second y_Second z_Second + regexp {Mass+: +([-0-9.+eE]+)} $xst2 full mass_Second + } else { + puts " GDT information was NOT provided" + } + if { [catch { Close D_Second } catch_result] } { + set err_msg "Error : cannot close a document D_Second - exception" + puts $err_msg + } +} + +if { $mist != 1 } { + puts "" + set result2 "" + append result2 [format $xst2] +} + +set err_compare_ref "" +# Put reference data to the test script file if option "dump" is set +if { $dump_file == 1 } { + set fd_stream [open $dirname/$groupname/$gridname/$casename w] + puts $fd_stream "# !!!! This file is generated automatically, do not edit manually! See end script" + puts $fd_stream "set filename $filename" + if { $mist != 1 } { + puts $fd_stream "" + puts $fd_stream "set ref_data \{" + puts $fd_stream $result + puts $fd_stream "\}" + } + close $fd_stream +} elseif { $mist != 1 } { + puts "========================== Comparision with reference data ========" + puts "" + # Comparision of reference data with obtained result + set x_Ref 0; set y_Ref 0; set z_Ref 0; + set mass_Ref 0; + regexp {Centre of mass+: +([-0-9.+eE]+) +([-0-9.+eE]+) +([-0-9.+eE]+)} $ref_data full x_Ref y_Ref z_Ref + regexp {Mass+: +([-0-9.+eE]+)} $ref_data full mass_Ref + + if {[expr abs($x_Ref - $x_First)] > 1e-4 || [expr abs($x_Ref - $x_Second)] > 1e-4} { + incr ref_Compare + append err_compare_ref " Reference data - $x_Ref\n" + append err_compare_ref " Current data - $x_Second ($x_First)\n" + append err_compare_ref "--------------------------------------------------------------------\n" + } + + if {[expr abs($y_Ref - $y_First)] > 1e-4 || [expr abs($y_Ref - $y_Second)] > 1e-4} { + incr ref_Compare + append err_compare_ref " Reference data - $y_Ref\n" + append err_compare_ref " Current data - $y_Second ($y_First)\n" + append err_compare_ref "--------------------------------------------------------------------\n" + } + if {[expr abs($z_Ref - $z_First)] > 1e-4 || [expr abs($z_Ref - $z_Second)] > 1e-4} { + incr ref_Compare + append err_compare_ref " Reference data - $z_Ref\n" + append err_compare_ref " Current data - $z_Second ($z_First)\n" + append err_compare_ref "--------------------------------------------------------------------\n" + } + if {[expr abs($mass_Ref - $mass_First)] > 1e-4 || [expr abs($mass_Ref - $mass_Second)] > 1e-4} { + incr ref_Compare + append err_compare_ref " Reference data - $mass_Ref\n" + append err_compare_ref " Current data - $mass_Second ($mass_First)\n" + append err_compare_ref "--------------------------------------------------------------------\n" + } + } + +if { $dump_file != 0 } { + puts "Error : Running in regeneration mode, comparision was not performed!" + if { $mist != 1 } { + puts "Generation of test file $groupname/$gridname/$casename successful" + } else { + puts "Generation of reference data failed" + } +} else { + if { $ref_Compare > 0} { + puts "Error : $ref_Compare differences with reference data found :\n$err_compare_ref" + } else { + puts "Comparision of current result with reference data - OK\n" + } +} + +puts "--------------------------------------------------------------------" +puts "" + +puts "TEST COMPLETED"