mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +03:00
0029362: Data Exchange - Crash during reading step file
Additional check for wires into searching of attached shapes, Fix Dimension value processing,
This commit is contained in:
parent
77cd443b99
commit
5b7f8e0a69
@ -124,7 +124,9 @@
|
|||||||
#include <StepRepr_RepresentationRelationship.hxx>
|
#include <StepRepr_RepresentationRelationship.hxx>
|
||||||
#include <StepRepr_RepresentedDefinition.hxx>
|
#include <StepRepr_RepresentedDefinition.hxx>
|
||||||
#include <StepRepr_ReprItemAndLengthMeasureWithUnit.hxx>
|
#include <StepRepr_ReprItemAndLengthMeasureWithUnit.hxx>
|
||||||
|
#include <StepRepr_ReprItemAndLengthMeasureWithUnitAndQRI.hxx>
|
||||||
#include <StepRepr_ReprItemAndPlaneAngleMeasureWithUnit.hxx>
|
#include <StepRepr_ReprItemAndPlaneAngleMeasureWithUnit.hxx>
|
||||||
|
#include <StepRepr_ReprItemAndPlaneAngleMeasureWithUnitAndQRI.hxx>
|
||||||
#include <StepRepr_SequenceOfRepresentationItem.hxx>
|
#include <StepRepr_SequenceOfRepresentationItem.hxx>
|
||||||
#include <StepRepr_ShapeAspect.hxx>
|
#include <StepRepr_ShapeAspect.hxx>
|
||||||
#include <StepRepr_ShapeAspectDerivingRelationship.hxx>
|
#include <StepRepr_ShapeAspectDerivingRelationship.hxx>
|
||||||
@ -3072,6 +3074,19 @@ TDF_Label STEPCAFControl_Reader::createGDTObjectInXCAF(const Handle(Standard_Tra
|
|||||||
{
|
{
|
||||||
TDF_Label aShL;
|
TDF_Label aShL;
|
||||||
aSTool->Search(aSh, aShL, Standard_True, Standard_True, Standard_True);
|
aSTool->Search(aSh, aShL, Standard_True, Standard_True, Standard_True);
|
||||||
|
if (aShL.IsNull() && aSh.ShapeType() == TopAbs_WIRE)
|
||||||
|
{
|
||||||
|
TopExp_Explorer ex(aSh, TopAbs_EDGE, TopAbs_SHAPE);
|
||||||
|
while (ex.More())
|
||||||
|
{
|
||||||
|
TDF_Label edgeL;
|
||||||
|
aSTool->Search(ex.Current(), edgeL, Standard_True, Standard_True, Standard_True);
|
||||||
|
if (!edgeL.IsNull())
|
||||||
|
aShLS1.Append(edgeL);
|
||||||
|
ex.Next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!aShL.IsNull())
|
||||||
aShLS1.Append(aShL);
|
aShLS1.Append(aShL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3090,6 +3105,19 @@ TDF_Label STEPCAFControl_Reader::createGDTObjectInXCAF(const Handle(Standard_Tra
|
|||||||
{
|
{
|
||||||
TDF_Label aShL;
|
TDF_Label aShL;
|
||||||
aSTool->Search(aSh, aShL, Standard_True, Standard_True, Standard_True);
|
aSTool->Search(aSh, aShL, Standard_True, Standard_True, Standard_True);
|
||||||
|
if (aShL.IsNull() && aSh.ShapeType() == TopAbs_WIRE)
|
||||||
|
{
|
||||||
|
TopExp_Explorer ex(aSh, TopAbs_EDGE, TopAbs_SHAPE);
|
||||||
|
while (ex.More())
|
||||||
|
{
|
||||||
|
TDF_Label edgeL;
|
||||||
|
aSTool->Search(ex.Current(), edgeL, Standard_True, Standard_True, Standard_True);
|
||||||
|
if (!edgeL.IsNull())
|
||||||
|
aShLS2.Append(edgeL);
|
||||||
|
ex.Next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!aShL.IsNull())
|
||||||
aShLS2.Append(aShL);
|
aShLS2.Append(aShL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3172,6 +3200,7 @@ static void setDimObjectToXCAF(const Handle(Standard_Transient)& theEnt,
|
|||||||
|
|
||||||
aDimObj = new XCAFDimTolObjects_DimensionObject();
|
aDimObj = new XCAFDimTolObjects_DimensionObject();
|
||||||
Standard_Real aDim1=-1.,aDim2=-1.,aDim3=-1.;
|
Standard_Real aDim1=-1.,aDim2=-1.,aDim3=-1.;
|
||||||
|
Standard_Boolean isPlusMinusTolerance = Standard_False;
|
||||||
Handle(StepShape_TypeQualifier) aTQ;
|
Handle(StepShape_TypeQualifier) aTQ;
|
||||||
Handle(StepShape_ValueFormatTypeQualifier) aVFTQ;
|
Handle(StepShape_ValueFormatTypeQualifier) aVFTQ;
|
||||||
Handle(StepShape_ToleranceValue) aTV;
|
Handle(StepShape_ToleranceValue) aTV;
|
||||||
@ -3205,79 +3234,65 @@ static void setDimObjectToXCAF(const Handle(Standard_Transient)& theEnt,
|
|||||||
Handle(StepRepr_RepresentationItem) aDRI = aHARI->Value(nr);
|
Handle(StepRepr_RepresentationItem) aDRI = aHARI->Value(nr);
|
||||||
if(aDRI.IsNull()) continue;
|
if(aDRI.IsNull()) continue;
|
||||||
|
|
||||||
if(aDRI->IsKind(STANDARD_TYPE(StepRepr_ReprItemAndLengthMeasureWithUnit))) {
|
if (aDRI->IsKind(STANDARD_TYPE(StepRepr_ReprItemAndMeasureWithUnit))) {
|
||||||
//get values
|
// simple value / range
|
||||||
Handle(StepRepr_ReprItemAndLengthMeasureWithUnit) aRILMWU =
|
Handle(StepRepr_ReprItemAndMeasureWithUnit) aMWU =
|
||||||
Handle(StepRepr_ReprItemAndLengthMeasureWithUnit)::DownCast(aDRI);
|
Handle(StepRepr_ReprItemAndMeasureWithUnit)::DownCast(aDRI);
|
||||||
Standard_Real aVal = aRILMWU->GetMeasureWithUnit()->ValueComponent();
|
Standard_Real aVal = aMWU->GetMeasureWithUnit()->ValueComponent();
|
||||||
StepBasic_Unit anUnit = aRILMWU->GetMeasureWithUnit()->UnitComponent();
|
StepBasic_Unit anUnit = aMWU->GetMeasureWithUnit()->UnitComponent();
|
||||||
Standard_Real aFact = 1.;
|
Standard_Real aFact = 1.;
|
||||||
if(anUnit.IsNull()) continue;
|
if (anUnit.IsNull())
|
||||||
if( !(anUnit.CaseNum(anUnit.Value())==1) ) continue;
|
continue;
|
||||||
|
if (!(anUnit.CaseNum(anUnit.Value()) == 1))
|
||||||
|
continue;
|
||||||
Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
|
Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
|
||||||
if(GetLengthConversionFactor(NU,aFact)) aVal=aVal*aFact;
|
if (aMWU->IsKind(STANDARD_TYPE(StepRepr_ReprItemAndLengthMeasureWithUnit))) {
|
||||||
if(aDim2 > 0)
|
if (GetLengthConversionFactor(NU, aFact))
|
||||||
{
|
aVal = aVal * aFact;
|
||||||
if(aDim1 > aDim2)
|
|
||||||
{
|
|
||||||
Standard_Real aTmp = aDim1;
|
|
||||||
aDim1 = aDim2;
|
|
||||||
aDim2 = aTmp;
|
|
||||||
}
|
|
||||||
if(aVal < aDim1)
|
|
||||||
aDim1 = aVal;
|
|
||||||
else if(aVal > aDim2)
|
|
||||||
aDim2 = aVal;
|
|
||||||
}
|
|
||||||
else if(aDim1 > 0)
|
|
||||||
{
|
|
||||||
if (aVal > aDim1)
|
|
||||||
aDim2 = aVal;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
aDim2 = aDim1;
|
|
||||||
aDim1 = aVal;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
if (aMWU->IsKind(STANDARD_TYPE(StepRepr_ReprItemAndPlaneAngleMeasureWithUnit))) {
|
||||||
|
if (GetAngleConversionFactor(NU, aFact))
|
||||||
|
aVal = aVal * aFact;
|
||||||
|
}
|
||||||
|
Handle(TCollection_HAsciiString) aName = aMWU->Name();
|
||||||
|
if (aName->Search("upper") > 0) // upper limit
|
||||||
|
aDim2 = aVal;
|
||||||
|
else // lower limit or simple nominal value
|
||||||
aDim1 = aVal;
|
aDim1 = aVal;
|
||||||
}
|
}
|
||||||
else if(aDRI->IsKind(STANDARD_TYPE(StepRepr_ReprItemAndPlaneAngleMeasureWithUnit))) {
|
else if (aDRI->IsKind(STANDARD_TYPE(StepRepr_ReprItemAndMeasureWithUnitAndQRI))) {
|
||||||
//get values
|
// value with qualifier (minimum/maximum/average)
|
||||||
Handle(StepRepr_ReprItemAndPlaneAngleMeasureWithUnit) aRIPAMWU =
|
Handle(StepRepr_ReprItemAndMeasureWithUnitAndQRI) aMWU =
|
||||||
Handle(StepRepr_ReprItemAndPlaneAngleMeasureWithUnit)::DownCast(aDRI);
|
Handle(StepRepr_ReprItemAndMeasureWithUnitAndQRI)::DownCast(aDRI);
|
||||||
Standard_Real aVal = aRIPAMWU->GetMeasureWithUnit()->ValueComponent();
|
Standard_Real aVal = aMWU->GetMeasureWithUnit()->ValueComponent();
|
||||||
StepBasic_Unit anUnit = aRIPAMWU->GetMeasureWithUnit()->UnitComponent();
|
StepBasic_Unit anUnit = aMWU->GetMeasureWithUnit()->UnitComponent();
|
||||||
Standard_Real aFact = 1.;
|
Standard_Real aFact = 1.;
|
||||||
if(anUnit.IsNull()) continue;
|
if(anUnit.IsNull())
|
||||||
if( !(anUnit.CaseNum(anUnit.Value())==1) ) continue;
|
continue;
|
||||||
|
if( !(anUnit.CaseNum(anUnit.Value()) == 1) )
|
||||||
|
continue;
|
||||||
Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
|
Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
|
||||||
if(GetAngleConversionFactor(NU,aFact)) aVal=aVal*aFact;
|
if (aMWU->IsKind(STANDARD_TYPE(StepRepr_ReprItemAndLengthMeasureWithUnitAndQRI))) {
|
||||||
if(aDim2 > 0)
|
if (GetLengthConversionFactor(NU, aFact))
|
||||||
{
|
aVal = aVal * aFact;
|
||||||
if(aDim1 > aDim2)
|
|
||||||
{
|
|
||||||
Standard_Real aTmp = aDim1;
|
|
||||||
aDim1 = aDim2;
|
|
||||||
aDim2 = aTmp;
|
|
||||||
}
|
|
||||||
if(aVal < aDim1)
|
|
||||||
aDim1 = aVal;
|
|
||||||
else if(aVal > aDim2)
|
|
||||||
aDim2 = aVal;
|
|
||||||
}
|
|
||||||
else if(aDim1 > 0)
|
|
||||||
{
|
|
||||||
if (aVal > aDim1)
|
|
||||||
aDim2 = aVal;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
aDim2 = aDim1;
|
|
||||||
aDim1 = aVal;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
if (aMWU->IsKind(STANDARD_TYPE(StepRepr_ReprItemAndPlaneAngleMeasureWithUnitAndQRI))) {
|
||||||
|
if (GetAngleConversionFactor(NU, aFact))
|
||||||
|
aVal = aVal * aFact;
|
||||||
|
}
|
||||||
|
Handle(StepShape_QualifiedRepresentationItem) aQRI = aMWU->GetQualifiedRepresentationItem();
|
||||||
|
if (aQRI->Qualifiers()->Length() == 0) {
|
||||||
aDim1 = aVal;
|
aDim1 = aVal;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Handle(StepShape_TypeQualifier) aValueType = aQRI->Qualifiers()->Value(1).TypeQualifier();
|
||||||
|
if (aValueType->Name()->String().IsEqual("minimum"))
|
||||||
|
aDim2 = aVal;
|
||||||
|
else if (aValueType->Name()->String().IsEqual("maximum"))
|
||||||
|
aDim3 = aVal;
|
||||||
|
else aDim1 = aVal;
|
||||||
}
|
}
|
||||||
else if(aDRI->IsKind(STANDARD_TYPE(StepShape_QualifiedRepresentationItem))) {
|
else if(aDRI->IsKind(STANDARD_TYPE(StepShape_QualifiedRepresentationItem))) {
|
||||||
//get qualifier
|
//get qualifier
|
||||||
@ -3307,6 +3322,7 @@ static void setDimObjectToXCAF(const Handle(Standard_Transient)& theEnt,
|
|||||||
}
|
}
|
||||||
else if (!aPMT.IsNull())
|
else if (!aPMT.IsNull())
|
||||||
{
|
{
|
||||||
|
isPlusMinusTolerance = Standard_True;
|
||||||
StepShape_ToleranceMethodDefinition aTMD = aPMT->Range();
|
StepShape_ToleranceMethodDefinition aTMD = aPMT->Range();
|
||||||
if(aPMT.IsNull()) continue;
|
if(aPMT.IsNull()) continue;
|
||||||
if(aTMD.CaseNumber() == 1)
|
if(aTMD.CaseNumber() == 1)
|
||||||
@ -3357,6 +3373,11 @@ static void setDimObjectToXCAF(const Handle(Standard_Transient)& theEnt,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
Handle(TColStd_HArray1OfReal) anArr = new TColStd_HArray1OfReal(1,3);
|
Handle(TColStd_HArray1OfReal) anArr = new TColStd_HArray1OfReal(1,3);
|
||||||
|
if (!isPlusMinusTolerance)
|
||||||
|
{
|
||||||
|
aDim2 = aDim1 - aDim2;
|
||||||
|
aDim3 = aDim3 - aDim1;
|
||||||
|
}
|
||||||
anArr->SetValue(1,aDim1);
|
anArr->SetValue(1,aDim1);
|
||||||
anArr->SetValue(2,aDim2);
|
anArr->SetValue(2,aDim2);
|
||||||
anArr->SetValue(3,aDim3);
|
anArr->SetValue(3,aDim3);
|
||||||
|
19
tests/gdt/export/C2
Normal file
19
tests/gdt/export/C2
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
# !!!! This file is generated automatically, do not edit manually! See end script
|
||||||
|
set filename bug29362_MMT200.stp
|
||||||
|
|
||||||
|
set ref_data {
|
||||||
|
|
||||||
|
NbOfDimensions : 2
|
||||||
|
NbOfDimensionalSize : 1
|
||||||
|
NbOfDimensionalLocation: 1
|
||||||
|
NbOfAngular : 0
|
||||||
|
NbOfWithPath : 0
|
||||||
|
NbOfCommonLabels : 0
|
||||||
|
NbOfTolerances : 0
|
||||||
|
NbOfGTWithModifiers : 0
|
||||||
|
NbOfGTWithMaxTolerance : 0
|
||||||
|
NbOfGTWithDatums : 0
|
||||||
|
NbOfDatumFeature : 0
|
||||||
|
NbOfAttachedDatum : 0
|
||||||
|
NbOfDatumTarget : 0
|
||||||
|
}
|
@ -2,7 +2,7 @@
|
|||||||
set filename bug27808_nist_ftc_09_asme1_ct5240_rd.stp
|
set filename bug27808_nist_ftc_09_asme1_ct5240_rd.stp
|
||||||
|
|
||||||
set ref_data {
|
set ref_data {
|
||||||
Centre of mass: -40.148168442038951 12.662743709548829 -20.675422904248919
|
Centre of mass: -39.98246176261911 12.596839170418153 -21.235634697624899
|
||||||
Mass: 33730.842652736828
|
Mass: 34084.671316201595
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
set filename bug27645_nist_ftc_09_asme1_ct5240_rd-1.stp
|
set filename bug27645_nist_ftc_09_asme1_ct5240_rd-1.stp
|
||||||
|
|
||||||
set ref_data {
|
set ref_data {
|
||||||
Centre of mass: -1019.7633667828792 321.63378807296516 -525.15615589604056
|
Centre of mass: -1015.5544287505505 319.95981300805124 -539.38551468015555
|
||||||
Mass: 856763.26313637081
|
Mass: 865750.50341424928
|
||||||
|
|
||||||
}
|
}
|
||||||
|
8
tests/gdt/presentation/C1
Normal file
8
tests/gdt/presentation/C1
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# !!!! This file is generated automatically, do not edit manually! See end script
|
||||||
|
set filename bug29362_MMT200.stp
|
||||||
|
|
||||||
|
set ref_data {
|
||||||
|
Centre of mass: 0 0 0
|
||||||
|
Mass: 0
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user