@@ -195,7 +195,7 @@ Severity STEPattribute::StrToVal( const char * s, InstMgr * instances, int addFi
195195** value <= SEVERITY_INPUT_ERROR is fatal read error
196196******************************************************************/
197197Severity STEPattribute::STEPread ( istream & in, InstMgr * instances, int addFileId,
198- const char * currSch ) {
198+ const char * currSch, bool strict ) {
199199
200200 // The attribute has been redefined by the attribute pointed
201201 // to by _redefAttr so write the redefined value.
@@ -239,6 +239,47 @@ Severity STEPattribute::STEPread( istream & in, InstMgr * instances, int addFile
239239 }
240240 if ( Nullable () ) {
241241 _error.severity ( SEVERITY_NULL );
242+ } else if ( !strict ) {
243+ std::string fillerValue;
244+ // we aren't in strict mode, so find out the type of the missing attribute and insert a suitable value.
245+ ErrorDescriptor err; // this will be discarded
246+ switch ( attrBaseType ) {
247+ case INTEGER_TYPE: {
248+ fillerValue = " '0'," ;
249+ ReadInteger ( *( ptr.i ), fillerValue.c_str (), &err, " ,)" );
250+ break ;
251+ }
252+ case REAL_TYPE: {
253+ fillerValue = " '0.0'," ;
254+ ReadReal ( *( ptr.r ), fillerValue.c_str (), &err, " ,)" );
255+ break ;
256+ }
257+ case NUMBER_TYPE: {
258+ fillerValue = " '0'," ;
259+ ReadNumber ( *( ptr.r ), fillerValue.c_str (), &err, " ,)" );
260+ break ;
261+ }
262+ case STRING_TYPE: {
263+ fillerValue = " ''," ;
264+ *(ptr.S ) = " ''" ;
265+ break ;
266+ }
267+ default : { // do not know what a good value would be for other types
268+ _error.severity ( SEVERITY_INCOMPLETE );
269+ _error.AppendToDetailMsg ( " missing and required\n " );
270+ return _error.severity ();
271+ }
272+ }
273+ if ( err.severity () <= SEVERITY_INCOMPLETE ) {
274+ _error.severity ( SEVERITY_BUG );
275+ _error.AppendToDetailMsg ( " Error in STEPattribute::STEPread()\n " );
276+ return _error.severity ();
277+ }
278+ // create a warning. SEVERITY_WARNING makes more sense to me, but is considered more severe than SEVERITY_INCOMPLETE
279+ _error.severity ( SEVERITY_USERMSG );
280+ _error.AppendToDetailMsg ( " missing and required. For compatibility, replacing with " );
281+ _error.AppendToDetailMsg ( fillerValue.substr ( 0 , fillerValue.length ()-1 ) );
282+ _error.AppendToDetailMsg ( " .\n " );
242283 } else {
243284 _error.severity ( SEVERITY_INCOMPLETE );
244285 _error.AppendToDetailMsg ( " missing and required\n " );
0 commit comments