mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-16 10:08:36 +03:00
0030362: Data Exchange - Writing dimensions with inches produced invalid file.
Writing dimensions into STEP files in inches not produce invalid references between STEP entities.
This commit is contained in:
parent
5fe14d0fac
commit
5290fb106f
@ -34,6 +34,8 @@
|
|||||||
#include <StepAP214_Protocol.hxx>
|
#include <StepAP214_Protocol.hxx>
|
||||||
#include <StepAP242_DraughtingModelItemAssociation.hxx>
|
#include <StepAP242_DraughtingModelItemAssociation.hxx>
|
||||||
#include <StepAP242_GeometricItemSpecificUsage.hxx>
|
#include <StepAP242_GeometricItemSpecificUsage.hxx>
|
||||||
|
#include <StepBasic_ConversionBasedUnitAndLengthUnit.hxx>
|
||||||
|
#include <StepBasic_ConversionBasedUnitAndPlaneAngleUnit.hxx>
|
||||||
#include <StepBasic_DerivedUnit.hxx>
|
#include <StepBasic_DerivedUnit.hxx>
|
||||||
#include <StepBasic_DerivedUnitElement.hxx>
|
#include <StepBasic_DerivedUnitElement.hxx>
|
||||||
#include <StepBasic_HArray1OfDerivedUnitElement.hxx>
|
#include <StepBasic_HArray1OfDerivedUnitElement.hxx>
|
||||||
@ -2179,62 +2181,65 @@ static StepBasic_Unit GetUnit(const Handle(StepRepr_RepresentationContext)& theR
|
|||||||
const Standard_Boolean isAngle = Standard_False)
|
const Standard_Boolean isAngle = Standard_False)
|
||||||
{
|
{
|
||||||
StepBasic_Unit aUnit;
|
StepBasic_Unit aUnit;
|
||||||
|
Handle(StepBasic_NamedUnit) aCurrentUnit;
|
||||||
if (isAngle) {
|
if (isAngle) {
|
||||||
Handle(StepBasic_SiUnitAndPlaneAngleUnit) aSiPAU;
|
|
||||||
Handle(StepGeom_GeometricRepresentationContextAndGlobalUnitAssignedContext) aCtx =
|
Handle(StepGeom_GeometricRepresentationContextAndGlobalUnitAssignedContext) aCtx =
|
||||||
Handle(StepGeom_GeometricRepresentationContextAndGlobalUnitAssignedContext)::DownCast(theRC);
|
Handle(StepGeom_GeometricRepresentationContextAndGlobalUnitAssignedContext)::DownCast(theRC);
|
||||||
if(!aCtx.IsNull()) {
|
if(!aCtx.IsNull()) {
|
||||||
for(Standard_Integer j = 1; j <= aCtx->NbUnits(); j++) {
|
for(Standard_Integer j = 1; j <= aCtx->NbUnits(); j++) {
|
||||||
if(aCtx->UnitsValue(j)->IsKind(STANDARD_TYPE(StepBasic_SiUnitAndPlaneAngleUnit))) {
|
if (aCtx->UnitsValue(j)->IsKind(STANDARD_TYPE(StepBasic_SiUnitAndPlaneAngleUnit)) ||
|
||||||
aSiPAU = Handle(StepBasic_SiUnitAndPlaneAngleUnit)::DownCast(aCtx->UnitsValue(j));
|
aCtx->UnitsValue(j)->IsKind(STANDARD_TYPE(StepBasic_ConversionBasedUnitAndPlaneAngleUnit))) {
|
||||||
|
aCurrentUnit = aCtx->UnitsValue(j);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(aSiPAU.IsNull()) {
|
if (aCurrentUnit.IsNull()) {
|
||||||
Handle(StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx) aCtx1 =
|
Handle(StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx) aCtx1 =
|
||||||
Handle(StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx)::DownCast(theRC);
|
Handle(StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx)::DownCast(theRC);
|
||||||
if(!aCtx1.IsNull()) {
|
if(!aCtx1.IsNull()) {
|
||||||
for(Standard_Integer j = 1; j <= aCtx1->NbUnits(); j++) {
|
for(Standard_Integer j = 1; j <= aCtx1->NbUnits(); j++) {
|
||||||
if(aCtx1->UnitsValue(j)->IsKind(STANDARD_TYPE(StepBasic_SiUnitAndPlaneAngleUnit))) {
|
if (aCtx1->UnitsValue(j)->IsKind(STANDARD_TYPE(StepBasic_SiUnitAndPlaneAngleUnit)) ||
|
||||||
aSiPAU = Handle(StepBasic_SiUnitAndPlaneAngleUnit)::DownCast(aCtx1->UnitsValue(j));
|
aCtx1->UnitsValue(j)->IsKind(STANDARD_TYPE(StepBasic_ConversionBasedUnitAndPlaneAngleUnit))) {
|
||||||
|
aCurrentUnit = aCtx1->UnitsValue(j);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(aSiPAU.IsNull())
|
if (aCurrentUnit.IsNull())
|
||||||
aSiPAU = new StepBasic_SiUnitAndPlaneAngleUnit;
|
aCurrentUnit = new StepBasic_SiUnitAndPlaneAngleUnit;
|
||||||
aUnit.SetValue(aSiPAU);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Handle(StepBasic_SiUnitAndLengthUnit) aSiLU;
|
|
||||||
Handle(StepGeom_GeometricRepresentationContextAndGlobalUnitAssignedContext) aCtx =
|
Handle(StepGeom_GeometricRepresentationContextAndGlobalUnitAssignedContext) aCtx =
|
||||||
Handle(StepGeom_GeometricRepresentationContextAndGlobalUnitAssignedContext)::DownCast(theRC);
|
Handle(StepGeom_GeometricRepresentationContextAndGlobalUnitAssignedContext)::DownCast(theRC);
|
||||||
if(!aCtx.IsNull()) {
|
if(!aCtx.IsNull()) {
|
||||||
for(Standard_Integer j = 1; j <= aCtx->NbUnits(); j++) {
|
for(Standard_Integer j = 1; j <= aCtx->NbUnits(); j++) {
|
||||||
if(aCtx->UnitsValue(j)->IsKind(STANDARD_TYPE(StepBasic_SiUnitAndLengthUnit))) {
|
if (aCtx->UnitsValue(j)->IsKind(STANDARD_TYPE(StepBasic_SiUnitAndLengthUnit)) ||
|
||||||
aSiLU = Handle(StepBasic_SiUnitAndLengthUnit)::DownCast(aCtx->UnitsValue(j));
|
aCtx->UnitsValue(j)->IsKind(STANDARD_TYPE(StepBasic_ConversionBasedUnitAndLengthUnit))) {
|
||||||
|
aCurrentUnit = aCtx->UnitsValue(j);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(aSiLU.IsNull()) {
|
if (aCurrentUnit.IsNull()) {
|
||||||
Handle(StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx) aCtx1 =
|
Handle(StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx) aCtx1 =
|
||||||
Handle(StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx)::DownCast(theRC);
|
Handle(StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx)::DownCast(theRC);
|
||||||
if(!aCtx1.IsNull()) {
|
if(!aCtx1.IsNull()) {
|
||||||
for(Standard_Integer j = 1; j <= aCtx1->NbUnits(); j++) {
|
for(Standard_Integer j = 1; j <= aCtx1->NbUnits(); j++) {
|
||||||
if(aCtx1->UnitsValue(j)->IsKind(STANDARD_TYPE(StepBasic_SiUnitAndLengthUnit))) {
|
if (aCtx1->UnitsValue(j)->IsKind(STANDARD_TYPE(StepBasic_SiUnitAndLengthUnit)) ||
|
||||||
aSiLU = Handle(StepBasic_SiUnitAndLengthUnit)::DownCast(aCtx1->UnitsValue(j));
|
aCtx1->UnitsValue(j)->IsKind(STANDARD_TYPE(StepBasic_ConversionBasedUnitAndLengthUnit))) {
|
||||||
|
aCurrentUnit = aCtx1->UnitsValue(j);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(aSiLU.IsNull())
|
if (aCurrentUnit.IsNull())
|
||||||
aSiLU = new StepBasic_SiUnitAndLengthUnit;
|
aCurrentUnit = new StepBasic_SiUnitAndLengthUnit;
|
||||||
aUnit.SetValue(aSiLU);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
aUnit.SetValue(aCurrentUnit);
|
||||||
return aUnit;
|
return aUnit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3524,33 +3529,7 @@ Standard_Boolean STEPCAFControl_Writer::WriteDGTs (const Handle(XSControl_WorkSe
|
|||||||
Model->AddWithRefs(SDR);
|
Model->AddWithRefs(SDR);
|
||||||
// define aUnit for creation LengthMeasureWithUnit (common for all)
|
// define aUnit for creation LengthMeasureWithUnit (common for all)
|
||||||
StepBasic_Unit aUnit;
|
StepBasic_Unit aUnit;
|
||||||
Handle(StepBasic_SiUnitAndLengthUnit) SLU;
|
aUnit = GetUnit(RC);
|
||||||
Handle(StepGeom_GeometricRepresentationContextAndGlobalUnitAssignedContext) Ctx =
|
|
||||||
Handle(StepGeom_GeometricRepresentationContextAndGlobalUnitAssignedContext)::DownCast(RC);
|
|
||||||
if(!Ctx.IsNull()) {
|
|
||||||
for(Standard_Integer j=1; j<=Ctx->NbUnits(); j++) {
|
|
||||||
if(Ctx->UnitsValue(j)->IsKind(STANDARD_TYPE(StepBasic_SiUnitAndLengthUnit))) {
|
|
||||||
SLU = Handle(StepBasic_SiUnitAndLengthUnit)::DownCast(Ctx->UnitsValue(j));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(SLU.IsNull()) {
|
|
||||||
Handle(StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx) Ctx1 =
|
|
||||||
Handle(StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx)::DownCast(RC);
|
|
||||||
if(!Ctx1.IsNull()) {
|
|
||||||
for(Standard_Integer j=1; j<=Ctx1->NbUnits(); j++) {
|
|
||||||
if(Ctx1->UnitsValue(j)->IsKind(STANDARD_TYPE(StepBasic_SiUnitAndLengthUnit))) {
|
|
||||||
SLU = Handle(StepBasic_SiUnitAndLengthUnit)::DownCast(Ctx1->UnitsValue(j));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(SLU.IsNull()) {
|
|
||||||
SLU = new StepBasic_SiUnitAndLengthUnit;
|
|
||||||
}
|
|
||||||
aUnit.SetValue(SLU);
|
|
||||||
|
|
||||||
// specific part of writing D> entities
|
// specific part of writing D> entities
|
||||||
if(kind<20) { //dimension
|
if(kind<20) { //dimension
|
||||||
|
21
tests/bugs/step/bug30362
Normal file
21
tests/bugs/step/bug30362
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
puts "=========="
|
||||||
|
puts "OCC30362"
|
||||||
|
puts "=========="
|
||||||
|
puts ""
|
||||||
|
#########################################################
|
||||||
|
# Writing dimensions with inches produced invalid file
|
||||||
|
#########################################################
|
||||||
|
|
||||||
|
pload DCAF
|
||||||
|
|
||||||
|
ReadStep D [locate_data_file bug26689_nist_ctc_01_asme1_ap242.stp]
|
||||||
|
param write.step.unit 1
|
||||||
|
param write.step.schema 5
|
||||||
|
WriteStep D $imagedir/${casename}.stp
|
||||||
|
|
||||||
|
Close D
|
||||||
|
file delete $imagedir/${casename}.stp
|
||||||
|
|
||||||
|
# return default values
|
||||||
|
param write.step.unit 2
|
||||||
|
param write.step.schema 4
|
Loading…
x
Reference in New Issue
Block a user