mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +03:00
0031825: Data Exchange, STEP - NULL dereference while re-exporting model with empty Datum description
Fix adding name and description of the datum
This commit is contained in:
parent
1b9cb073b9
commit
692decba26
@ -2527,7 +2527,7 @@ Standard_Boolean STEPCAFControl_Reader::setDatumToXCAF(const Handle(StepDimTol_D
|
|||||||
|
|
||||||
// Create datum target object
|
// Create datum target object
|
||||||
if (isValidDT) {
|
if (isValidDT) {
|
||||||
TDF_Label aDatL = aDGTTool->AddDatum();
|
TDF_Label aDatL = aDGTTool->AddDatum(theDat->Name(), theDat->Description(), theDat->Identification());
|
||||||
myGDTMap.Bind(aDT, aDatL);
|
myGDTMap.Bind(aDT, aDatL);
|
||||||
aDGTTool->Lock(aDatL);
|
aDGTTool->Lock(aDatL);
|
||||||
aDat = XCAFDoc_Datum::Set(aDatL);
|
aDat = XCAFDoc_Datum::Set(aDatL);
|
||||||
@ -2549,7 +2549,7 @@ Standard_Boolean STEPCAFControl_Reader::setDatumToXCAF(const Handle(StepDimTol_D
|
|||||||
|
|
||||||
if (aShapeLabels.Length() > 0 || !isExistDatumTarget) {
|
if (aShapeLabels.Length() > 0 || !isExistDatumTarget) {
|
||||||
// Create object for datum
|
// Create object for datum
|
||||||
TDF_Label aDatL = aDGTTool->AddDatum();
|
TDF_Label aDatL = aDGTTool->AddDatum(theDat->Name(), theDat->Description(), theDat->Identification());
|
||||||
myGDTMap.Bind(theDat, aDatL);
|
myGDTMap.Bind(theDat, aDatL);
|
||||||
// bind datum label with all reference datum_feature entities
|
// bind datum label with all reference datum_feature entities
|
||||||
for (Standard_Integer i = 1; i <= aSAs.Length(); i++) {
|
for (Standard_Integer i = 1; i <= aSAs.Length(); i++) {
|
||||||
|
@ -3466,8 +3466,12 @@ Standard_Boolean STEPCAFControl_Writer::WriteDGTs (const Handle(XSControl_WorkSe
|
|||||||
Handle(XCAFDoc_Datum) DatumAttr;
|
Handle(XCAFDoc_Datum) DatumAttr;
|
||||||
if(!DatumL.FindAttribute(XCAFDoc_Datum::GetID(),DatumAttr)) continue;
|
if(!DatumL.FindAttribute(XCAFDoc_Datum::GetID(),DatumAttr)) continue;
|
||||||
Handle(TCollection_HAsciiString) aName = DatumAttr->GetName();
|
Handle(TCollection_HAsciiString) aName = DatumAttr->GetName();
|
||||||
Handle(TCollection_HAsciiString) aDescription = DatumAttr->GetDescription();
|
|
||||||
Handle(TCollection_HAsciiString) anIdentification = DatumAttr->GetIdentification();
|
Handle(TCollection_HAsciiString) anIdentification = DatumAttr->GetIdentification();
|
||||||
|
Handle(TCollection_HAsciiString) aDescription = DatumAttr->GetDescription();
|
||||||
|
if (aDescription.IsNull())
|
||||||
|
{
|
||||||
|
aDescription = new TCollection_HAsciiString();
|
||||||
|
}
|
||||||
Handle(StepDimTol_DatumFeature) DF = new StepDimTol_DatumFeature;
|
Handle(StepDimTol_DatumFeature) DF = new StepDimTol_DatumFeature;
|
||||||
Handle(StepDimTol_Datum) aDatum = new StepDimTol_Datum;
|
Handle(StepDimTol_Datum) aDatum = new StepDimTol_Datum;
|
||||||
DF->Init(aName, new TCollection_HAsciiString, PDS, StepData_LTrue);
|
DF->Init(aName, new TCollection_HAsciiString, PDS, StepData_LTrue);
|
||||||
|
40
tests/bugs/step/bug31825
Normal file
40
tests/bugs/step/bug31825
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
puts "================"
|
||||||
|
puts "0031825: Data Exchange, STEP - NULL dereference while re-exporting model with empty Datum description"
|
||||||
|
puts "================"
|
||||||
|
puts ""
|
||||||
|
|
||||||
|
pload OCAF
|
||||||
|
param write.step.schema AP242DIS
|
||||||
|
catch { Close D_First }
|
||||||
|
catch { Close D_Sec }
|
||||||
|
|
||||||
|
# Read file
|
||||||
|
set Path ${imagedir}/${casename}.stp
|
||||||
|
ReadStep D_First [locate_data_file bug26689_nist_ctc_04_asme1_ap242.stp]
|
||||||
|
set baseDGTDump [XDumpNbDGTs D_First f]
|
||||||
|
|
||||||
|
WriteStep D_First $Path
|
||||||
|
ReadStep D_Sec $Path
|
||||||
|
file delete $Path
|
||||||
|
set newDGTDump [XDumpNbDGTs D_Sec f]
|
||||||
|
XGetOneShape res D_Sec
|
||||||
|
|
||||||
|
# Checking
|
||||||
|
checkshape res
|
||||||
|
checknbshapes res -face 518 -wire 623 -compound 1
|
||||||
|
|
||||||
|
set isOK 1
|
||||||
|
set nb_ref [llength $newDGTDump]
|
||||||
|
for { set i 0 } { $i < $nb_ref } { incr i } {
|
||||||
|
set refstr [lindex $baseDGTDump $i]
|
||||||
|
set curstr [lindex $newDGTDump $i]
|
||||||
|
if {[string equal $refstr $curstr] == 0} {
|
||||||
|
set isOK 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if {$isOK == 0} {
|
||||||
|
puts "Error: wrong export DGT and PMI"
|
||||||
|
}
|
||||||
|
|
||||||
|
# set default parameter
|
||||||
|
param write.step.schema AP214IS
|
Loading…
x
Reference in New Issue
Block a user