1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-06 18:26:22 +03:00

0025910: The material with 0-density causes errors during writing STEP files

- properly process 0-density material - create STEP density structures if and only if the density is > 0
- properly process 0-density material - create STEP density structures if and only if the density is > 0, but preserve the already mapped structures

Test-case for issue #25910
This commit is contained in:
drazmyslovich 2015-03-19 15:52:21 +03:00 committed by bugmaster
parent 9bd59d1c5b
commit 41e259eb8b
2 changed files with 56 additions and 29 deletions

View File

@ -2432,8 +2432,8 @@ Standard_Boolean STEPCAFControl_Writer::WriteMaterials (const Handle(XSControl_W
Standard_Real aDensity; Standard_Real aDensity;
Handle(TCollection_HAsciiString) aDensName; Handle(TCollection_HAsciiString) aDensName;
Handle(TCollection_HAsciiString) aDensValType; Handle(TCollection_HAsciiString) aDensValType;
Handle(StepRepr_Representation) RepDRI = new StepRepr_Representation; Handle(StepRepr_Representation) RepDRI;
Handle(StepRepr_Representation) RepMRI = new StepRepr_Representation; Handle(StepRepr_Representation) RepMRI;
if(MatTool->GetMaterial(MatL,aName,aDescription,aDensity,aDensName,aDensValType)) { if(MatTool->GetMaterial(MatL,aName,aDescription,aDensity,aDensName,aDensValType)) {
if(aName->Length()==0) continue; if(aName->Length()==0) continue;
TCollection_AsciiString aKey(aName->ToCString()); TCollection_AsciiString aKey(aName->ToCString());
@ -2449,6 +2449,7 @@ Standard_Boolean STEPCAFControl_Writer::WriteMaterials (const Handle(XSControl_W
DRI->Init(aName,aDescription); DRI->Init(aName,aDescription);
Handle(StepRepr_HArray1OfRepresentationItem) HARI = new StepRepr_HArray1OfRepresentationItem(1,1); Handle(StepRepr_HArray1OfRepresentationItem) HARI = new StepRepr_HArray1OfRepresentationItem(1,1);
HARI->SetValue(1,DRI); HARI->SetValue(1,DRI);
RepDRI = new StepRepr_Representation();
RepDRI->Init(new TCollection_HAsciiString("material name"),HARI,RC); RepDRI->Init(new TCollection_HAsciiString("material name"),HARI,RC);
Model->AddWithRefs(RepDRI); Model->AddWithRefs(RepDRI);
// write MRI // write MRI
@ -2479,6 +2480,7 @@ Standard_Boolean STEPCAFControl_Writer::WriteMaterials (const Handle(XSControl_W
MRI->Init(aDensName,MVM,aUnit); MRI->Init(aDensName,MVM,aUnit);
HARI = new StepRepr_HArray1OfRepresentationItem(1,1); HARI = new StepRepr_HArray1OfRepresentationItem(1,1);
HARI->SetValue(1,MRI); HARI->SetValue(1,MRI);
RepMRI = new StepRepr_Representation();
RepMRI->Init(new TCollection_HAsciiString("density"),HARI,RC); RepMRI->Init(new TCollection_HAsciiString("density"),HARI,RC);
Model->AddWithRefs(RepMRI); Model->AddWithRefs(RepMRI);
} }
@ -2487,7 +2489,9 @@ Standard_Boolean STEPCAFControl_Writer::WriteMaterials (const Handle(XSControl_W
if ( !RepMRI.IsNull() ) MapMRI.Bind (aKey, RepMRI); if ( !RepMRI.IsNull() ) MapMRI.Bind (aKey, RepMRI);
} }
} }
// write chain PDS---(DRI,MRI)
if( !RepDRI.IsNull() )
{
StepRepr_CharacterizedDefinition CD1; StepRepr_CharacterizedDefinition CD1;
CD1.SetValue(aProdDef); CD1.SetValue(aProdDef);
Handle(StepRepr_PropertyDefinition) PropD1 = new StepRepr_PropertyDefinition; Handle(StepRepr_PropertyDefinition) PropD1 = new StepRepr_PropertyDefinition;
@ -2500,6 +2504,9 @@ Standard_Boolean STEPCAFControl_Writer::WriteMaterials (const Handle(XSControl_W
new StepRepr_PropertyDefinitionRepresentation; new StepRepr_PropertyDefinitionRepresentation;
PDR1->Init(RD1,RepDRI); PDR1->Init(RD1,RepDRI);
Model->AddWithRefs(PDR1); Model->AddWithRefs(PDR1);
if( !RepMRI.IsNull() )
{
StepRepr_CharacterizedDefinition CD2; StepRepr_CharacterizedDefinition CD2;
CD2.SetValue (aProdDef); CD2.SetValue (aProdDef);
Handle (StepRepr_PropertyDefinition) PropD2 = new StepRepr_PropertyDefinition; Handle (StepRepr_PropertyDefinition) PropD2 = new StepRepr_PropertyDefinition;
@ -2514,6 +2521,8 @@ Standard_Boolean STEPCAFControl_Writer::WriteMaterials (const Handle(XSControl_W
Model->AddWithRefs (PDR2); Model->AddWithRefs (PDR2);
} }
} }
}
}
return Standard_True; return Standard_True;
} }

18
tests/bugs/xde/bug25910 Normal file
View File

@ -0,0 +1,18 @@
puts "========"
puts "OCC25910"
puts "========"
puts ""
#######################################################################
# The material with 0-density causes errors during writing STEP files
#######################################################################
pload DCAF
NewDocument D
box b 10 10 10
XSetMaterial D [XAddShape D b] Vacuum 0.
set bug_info [catch {WriteStep D $imagedir/OCC25910.stp}]
if {$bug_info != 0} {
puts "ERROR: OCC25910 is reproduced."
}