mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-16 10:08:36 +03:00
0031685: Data Exchange, STEPCAFControl_Reader - NULL dereference on translating PLACED_DATUM_TARGET_FEATURE
- Fix incorrect sharing DatumTargetType_Area - Add check for null object
This commit is contained in:
parent
8a39adb7d8
commit
14abc514ed
@ -2400,7 +2400,10 @@ Standard_Boolean STEPCAFControl_Reader::setDatumToXCAF(const Handle(StepDimTol_D
|
|||||||
Handle(XCAFDimTolObjects_DatumObject) aDatTargetObj = new XCAFDimTolObjects_DatumObject();
|
Handle(XCAFDimTolObjects_DatumObject) aDatTargetObj = new XCAFDimTolObjects_DatumObject();
|
||||||
XCAFDimTolObjects_DatumTargetType aType;
|
XCAFDimTolObjects_DatumTargetType aType;
|
||||||
if (!STEPCAFControl_GDTProperty::GetDatumTargetType(aDT->Description(), aType))
|
if (!STEPCAFControl_GDTProperty::GetDatumTargetType(aDT->Description(), aType))
|
||||||
|
{
|
||||||
|
aTP->AddWarning(aDT, "Unknown datum target type");
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
aDatTargetObj->SetDatumTargetType(aType);
|
aDatTargetObj->SetDatumTargetType(aType);
|
||||||
Standard_Boolean isValidDT = Standard_False;
|
Standard_Boolean isValidDT = Standard_False;
|
||||||
|
|
||||||
@ -2446,13 +2449,16 @@ Standard_Boolean STEPCAFControl_Reader::setDatumToXCAF(const Handle(StepDimTol_D
|
|||||||
|
|
||||||
if (aType == XCAFDimTolObjects_DatumTargetType_Area) {
|
if (aType == XCAFDimTolObjects_DatumTargetType_Area) {
|
||||||
// Area datum target
|
// Area datum target
|
||||||
Interface_EntityIterator anIterDTF = aGraph.Shareds(aDT);
|
if (aRelationship.IsNull())
|
||||||
|
continue;
|
||||||
|
Handle(StepRepr_ShapeAspect) aSA = aRelationship->RelatingShapeAspect();
|
||||||
|
Interface_EntityIterator aSAIter = aGraph.Sharings(aSA);
|
||||||
Handle(StepAP242_GeometricItemSpecificUsage) aGISU;
|
Handle(StepAP242_GeometricItemSpecificUsage) aGISU;
|
||||||
for (; anIterDTF.More() && aGISU.IsNull(); anIterDTF.Next()) {
|
for (; aSAIter.More() && aGISU.IsNull(); aSAIter.Next()) {
|
||||||
aGISU = Handle(StepAP242_GeometricItemSpecificUsage)::DownCast(anIterDTF.Value());
|
aGISU = Handle(StepAP242_GeometricItemSpecificUsage)::DownCast(aSAIter.Value());
|
||||||
}
|
}
|
||||||
Handle(StepRepr_RepresentationItem) anItem;
|
Handle(StepRepr_RepresentationItem) anItem;
|
||||||
if (aGISU->NbIdentifiedItem() > 0)
|
if (!aGISU.IsNull() && aGISU->NbIdentifiedItem() > 0)
|
||||||
anItem = aGISU->IdentifiedItemValue(1);
|
anItem = aGISU->IdentifiedItemValue(1);
|
||||||
if (anItem.IsNull())
|
if (anItem.IsNull())
|
||||||
continue;
|
continue;
|
||||||
|
44
tests/bugs/step/bug31685_1
Normal file
44
tests/bugs/step/bug31685_1
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
puts "==================================================="
|
||||||
|
puts " 0031685: Data Exchange, STEPCAFControl_Reader - NULL dereference on translating PLACED_DATUM_TARGET_FEATURE "
|
||||||
|
puts "==================================================="
|
||||||
|
puts ""
|
||||||
|
|
||||||
|
pload DCAF
|
||||||
|
|
||||||
|
# Read file
|
||||||
|
ReadStep D [locate_data_file bug31685_1.stp]
|
||||||
|
XGetOneShape res D
|
||||||
|
|
||||||
|
# Checking
|
||||||
|
checkshape res f
|
||||||
|
set dump [XDumpNbDGTs D f]
|
||||||
|
set info "
|
||||||
|
|
||||||
|
NbOfDimensions : 14
|
||||||
|
NbOfDimensionalSize : 7
|
||||||
|
NbOfDimensionalLocation: 0
|
||||||
|
NbOfAngular : 0
|
||||||
|
NbOfWithPath : 0
|
||||||
|
NbOfCommonLabels : 0
|
||||||
|
NbOfTolerances : 22
|
||||||
|
NbOfGTWithModifiers : 4
|
||||||
|
NbOfGTWithMaxTolerance : 0
|
||||||
|
NbOfGTWithDatums : 20
|
||||||
|
NbOfDatumFeature : 13
|
||||||
|
NbOfAttachedDatum : 70
|
||||||
|
NbOfDatumTarget : 57
|
||||||
|
"
|
||||||
|
set isOK 1;
|
||||||
|
set nb_ref [llength $dump]
|
||||||
|
for { set i 0 } { $i < $nb_ref } { incr i } {
|
||||||
|
set refstr [lindex $info $i]
|
||||||
|
set curstr [lindex $dump $i]
|
||||||
|
if {[string equal $refstr $curstr] == 0} {
|
||||||
|
set isOK 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if {$isOK == 0} {
|
||||||
|
puts "Error: wrong translate DGT"
|
||||||
|
}
|
||||||
|
|
||||||
|
Close D
|
44
tests/bugs/step/bug31685_2
Normal file
44
tests/bugs/step/bug31685_2
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
puts "==================================================="
|
||||||
|
puts " 0031685: Data Exchange, STEPCAFControl_Reader - NULL dereference on translating PLACED_DATUM_TARGET_FEATURE "
|
||||||
|
puts "==================================================="
|
||||||
|
puts ""
|
||||||
|
|
||||||
|
pload DCAF
|
||||||
|
|
||||||
|
# Read file
|
||||||
|
ReadStep D [locate_data_file bug31685_2.stp]
|
||||||
|
XGetOneShape res D
|
||||||
|
|
||||||
|
# Checking
|
||||||
|
checkshape res f
|
||||||
|
set dump [XDumpNbDGTs D f]
|
||||||
|
set info "
|
||||||
|
|
||||||
|
NbOfDimensions : 52
|
||||||
|
NbOfDimensionalSize : 17
|
||||||
|
NbOfDimensionalLocation: 4
|
||||||
|
NbOfAngular : 0
|
||||||
|
NbOfWithPath : 0
|
||||||
|
NbOfCommonLabels : 1
|
||||||
|
NbOfTolerances : 26
|
||||||
|
NbOfGTWithModifiers : 3
|
||||||
|
NbOfGTWithMaxTolerance : 0
|
||||||
|
NbOfGTWithDatums : 23
|
||||||
|
NbOfDatumFeature : 16
|
||||||
|
NbOfAttachedDatum : 72
|
||||||
|
NbOfDatumTarget : 1
|
||||||
|
"
|
||||||
|
set isOK 1;
|
||||||
|
set nb_ref [llength $dump]
|
||||||
|
for { set i 0 } { $i < $nb_ref } { incr i } {
|
||||||
|
set refstr [lindex $info $i]
|
||||||
|
set curstr [lindex $dump $i]
|
||||||
|
if {[string equal $refstr $curstr] == 0} {
|
||||||
|
set isOK 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if {$isOK == 0} {
|
||||||
|
puts "Error: wrong translate DGT"
|
||||||
|
}
|
||||||
|
|
||||||
|
Close D
|
44
tests/bugs/step/bug31685_3
Normal file
44
tests/bugs/step/bug31685_3
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
puts "==================================================="
|
||||||
|
puts " 0031685: Data Exchange, STEPCAFControl_Reader - NULL dereference on translating PLACED_DATUM_TARGET_FEATURE "
|
||||||
|
puts "==================================================="
|
||||||
|
puts ""
|
||||||
|
|
||||||
|
pload DCAF
|
||||||
|
|
||||||
|
# Read file
|
||||||
|
ReadStep D [locate_data_file bug31685_3.stp]
|
||||||
|
XGetOneShape res D
|
||||||
|
|
||||||
|
# Checking
|
||||||
|
checkshape res f
|
||||||
|
set dump [XDumpNbDGTs D f]
|
||||||
|
set info "
|
||||||
|
|
||||||
|
NbOfDimensions : 60
|
||||||
|
NbOfDimensionalSize : 20
|
||||||
|
NbOfDimensionalLocation: 2
|
||||||
|
NbOfAngular : 0
|
||||||
|
NbOfWithPath : 0
|
||||||
|
NbOfCommonLabels : 1
|
||||||
|
NbOfTolerances : 38
|
||||||
|
NbOfGTWithModifiers : 3
|
||||||
|
NbOfGTWithMaxTolerance : 0
|
||||||
|
NbOfGTWithDatums : 35
|
||||||
|
NbOfDatumFeature : 15
|
||||||
|
NbOfAttachedDatum : 109
|
||||||
|
NbOfDatumTarget : 4
|
||||||
|
"
|
||||||
|
set isOK 1;
|
||||||
|
set nb_ref [llength $dump]
|
||||||
|
for { set i 0 } { $i < $nb_ref } { incr i } {
|
||||||
|
set refstr [lindex $info $i]
|
||||||
|
set curstr [lindex $dump $i]
|
||||||
|
if {[string equal $refstr $curstr] == 0} {
|
||||||
|
set isOK 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if {$isOK == 0} {
|
||||||
|
puts "Error: wrong translate DGT"
|
||||||
|
}
|
||||||
|
|
||||||
|
Close D
|
Loading…
x
Reference in New Issue
Block a user