1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-24 13:50:49 +03:00

Compare commits

..

1 Commits

Author SHA1 Message Date
dpasukhi
0252e6edb0 0033327: Data Exchange, IGES Import - SubfigureDef can't read string
Fixed problem with texted types
Added checking for null string for subfigure via XCAF transferring
2023-03-09 23:29:45 +00:00
6 changed files with 63 additions and 46 deletions

View File

@@ -322,7 +322,8 @@ Standard_Boolean IGESCAFControl_Reader::Transfer (const Handle(TDocStd_Document)
//Checks that current entity is a subfigure //Checks that current entity is a subfigure
Handle(IGESBasic_SubfigureDef) aSubfigure = Handle(IGESBasic_SubfigureDef)::DownCast (ent); Handle(IGESBasic_SubfigureDef) aSubfigure = Handle(IGESBasic_SubfigureDef)::DownCast (ent);
if (GetNameMode() && !aSubfigure.IsNull() && STool->Search (S, L, Standard_True, Standard_True)) if (GetNameMode() && !aSubfigure.IsNull() && !aSubfigure->Name().IsNull() &&
STool->Search(S, L, Standard_True, Standard_True))
{ {
//In this case we attach subfigure name to the label, instead of default "COMPOUND" //In this case we attach subfigure name to the label, instead of default "COMPOUND"
Handle(TCollection_HAsciiString) aName = aSubfigure->Name(); Handle(TCollection_HAsciiString) aName = aSubfigure->Name();

View File

@@ -635,32 +635,53 @@ Standard_Boolean IGESData_ParamReader::ReadXYZ
//function : ReadText //function : ReadText
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Boolean IGESData_ParamReader::ReadText(const IGESData_ParamCursor& thePC,
Standard_Boolean IGESData_ParamReader::ReadText const Message_Msg& theMsg,
(const IGESData_ParamCursor& PC, const Message_Msg& amsg, Handle(TCollection_HAsciiString)& theVal)
Handle(TCollection_HAsciiString)& val)
{ {
if (!PrepareRead(PC,Standard_False)) return Standard_False; if (!PrepareRead(thePC, Standard_False))
const Interface_FileParameter& FP = theparams->Value(theindex+thebase); {
if (FP.ParamType() != Interface_ParamText) { return Standard_False;
if (FP.ParamType() == Interface_ParamVoid) { }
val = new TCollection_HAsciiString(""); const Interface_FileParameter& aFP = theparams->Value(theindex + thebase);
if (aFP.ParamType() != Interface_ParamText)
{
theVal = new TCollection_HAsciiString("");
if (aFP.ParamType() == Interface_ParamVoid)
{
return Standard_True; return Standard_True;
} }
SendFail (amsg); SendFail(theMsg);
return Standard_False; return Standard_False;
} }
Handle(TCollection_HAsciiString) tval = new TCollection_HAsciiString (FP.CValue()); const Handle(TCollection_HAsciiString) aBaseValue = new TCollection_HAsciiString(aFP.CValue());
Standard_Integer lnt = tval->Length(); const Standard_Integer aBaseLength = aBaseValue->Length();
Standard_Integer lnh = tval->Location(1,'H',1,lnt); const Standard_Integer aSymbolLocation = aBaseValue->Location(1, 'H', 1, aBaseLength);
if (lnh <= 1 || lnh >= lnt) { if (aSymbolLocation <= 1 || aSymbolLocation > aBaseLength)
SendFail (amsg); {
theVal = new TCollection_HAsciiString("");
SendFail(theMsg);
return Standard_False; return Standard_False;
} else {
Standard_Integer hol = atoi (tval->SubString(1,lnh-1)->ToCString());
if (hol != (lnt-lnh)) SendWarning (amsg);
} }
val = new TCollection_HAsciiString(tval->SubString(lnh+1,lnt)->ToCString()); const TCollection_AsciiString aSpecialSubString = aBaseValue->String().SubString(1, aSymbolLocation - 1);
if (!aSpecialSubString.IsIntegerValue())
{
theVal = new TCollection_HAsciiString("");
SendFail(theMsg);
return Standard_False;
}
Standard_Integer aResLength = aSpecialSubString.IntegerValue();
if (aResLength != (aBaseLength - aSymbolLocation))
{
SendWarning(theMsg);
aResLength = aBaseLength - aSymbolLocation;
}
TCollection_AsciiString aResString;
if (aResLength > 0)
{
aResString = aBaseValue->String().SubString(aSymbolLocation + 1, aBaseLength);
}
theVal = new TCollection_HAsciiString(aResString);
return Standard_True; return Standard_True;
} }

View File

@@ -200,7 +200,7 @@ public:
//! For Message //! For Message
Standard_EXPORT Standard_Boolean ReadXYZ (const IGESData_ParamCursor& PC, const Standard_CString mess, gp_XYZ& val); Standard_EXPORT Standard_Boolean ReadXYZ (const IGESData_ParamCursor& PC, const Standard_CString mess, gp_XYZ& val);
Standard_EXPORT Standard_Boolean ReadText (const IGESData_ParamCursor& PC, const Message_Msg& amsg, Handle(TCollection_HAsciiString)& val); Standard_EXPORT Standard_Boolean ReadText (const IGESData_ParamCursor& thePC, const Message_Msg& theMsg, Handle(TCollection_HAsciiString)& theVal);
//! Reads a Text value from parameter "num", as a String from //! Reads a Text value from parameter "num", as a String from
//! Collection, that is, Hollerith text without leading "nnnH" //! Collection, that is, Hollerith text without leading "nnnH"

View File

@@ -4692,16 +4692,9 @@ void collectRepresentationItems(const Interface_Graph& theGraph,
const Handle(StepShape_ShapeRepresentation)& theRepresentation, const Handle(StepShape_ShapeRepresentation)& theRepresentation,
NCollection_Sequence<Handle(StepRepr_RepresentationItem)>& theItems) NCollection_Sequence<Handle(StepRepr_RepresentationItem)>& theItems)
{ {
for (StepRepr_HArray1OfRepresentationItem::Iterator anIter(theRepresentation->Items()->Array1()); Handle(StepRepr_HArray1OfRepresentationItem) aReprItems = theRepresentation->Items();
anIter.More(); anIter.Next()) for (Standard_Integer itemIt = aReprItems->Lower(); itemIt <= aReprItems->Upper(); itemIt++)
{ theItems.Append(aReprItems->Value(itemIt));
const Handle(StepRepr_RepresentationItem)& anReprItem = anIter.Value();
if (anReprItem.IsNull())
{
continue;
}
theItems.Append(anReprItem);
}
Interface_EntityIterator entIt = theGraph.TypedSharings(theRepresentation, STANDARD_TYPE(StepRepr_RepresentationRelationship)); Interface_EntityIterator entIt = theGraph.TypedSharings(theRepresentation, STANDARD_TYPE(StepRepr_RepresentationRelationship));
for (entIt.Start(); entIt.More(); entIt.Next()) for (entIt.Start(); entIt.More(); entIt.Next())

16
tests/bugs/iges/bug33327 Normal file
View File

@@ -0,0 +1,16 @@
puts "============"
puts "0033327: Data Exchange, IGES Import - SubfigureDef can't read string"
puts "============"
pload DCAF
Close D -silent
ReadIges D [locate_data_file "bug33327.igs"]
vclear
vinit View1
XDisplay -dispMode 1 D
vfit
vdump "$imagedir/${casename}_src.png"
Close D

View File

@@ -1,14 +0,0 @@
puts "===================================="
puts "0033331: Data Exchange, Step Import - Unsupported Representation Items"
puts "===================================="
puts ""
pload DCAF
catch {Close D}
param "read.stepcaf.subshapes.name" 1
ReadStep D [locate_data_file bug33331.stp]
param "read.stepcaf.subshapes.name" 0
Close D