diff --git a/src/ITAGeo/Base.cpp b/src/ITAGeo/Base.cpp index 84f12b8a6ceae88398e2513a4f2c9e993e5ec7ed..5e927a70f5106b1bf371512aa0c4ee2043618e06 100644 --- a/src/ITAGeo/Base.cpp +++ b/src/ITAGeo/Base.cpp @@ -411,10 +411,12 @@ void ITAGeo::CMirrorImage::LoadFromJSONString( const std::string& sContent, std: v3MirrorNormal.SetValues( dMirrorNormal ); //Get and set the polygon index - iPolygonIndex = ( int ) jnRoot.at( "polygon_index" ).as_int(); + if( jnRoot.find( "polygon_index" ) != jnRoot.end() ) + iPolygonIndex = ( int ) jnRoot.at( "polygon_index" ).as_int(); //Get and set the order number - iOrder = ( int ) jnRoot.at( "order" ).as_int(); + if( jnRoot.find( "order" ) != jnRoot.end() ) + iOrder = ( int ) jnRoot.at( "order" ).as_int(); #endif } @@ -504,7 +506,8 @@ void ITAGeo::CSpecularReflection::LoadFromJSONString( const std::string& sConten CPropagationAnchor::LoadFromJSONString( sContent, pResourceManager ); - iPolygonID = jnRoot.at( "polygon_id" ).as_int(); + if( jnRoot.find("polygon_id") != jnRoot.end() ) + iPolygonID = jnRoot.at( "polygon_id" ).as_int(); #endif } @@ -810,8 +813,10 @@ void ITAGeo::CITADiffractionWedgeApertureBase::LoadFromJSONString( const std::st //Set the opposite wedge face normal v3OppositeWedgeFaceNormal.SetValues( dX, dY, dZ, dW ); - int iMainWedgeFaceID = jnRoot.at( "main_wedge_face_id" ).as_int(); - int iOppositeWedgeFaceID = jnRoot.at( "opposite_wedge_face_id" ).as_int(); + if( jnRoot.find("main_wedge_face_id") != jnRoot.end() ) + iMainWedgeFaceID = jnRoot.at( "main_wedge_face_id" ).as_int(); + if( jnRoot.find( "opposite_wedge_face_id" ) != jnRoot.end() ) + iOppositeWedgeFaceID = jnRoot.at( "opposite_wedge_face_id" ).as_int(); #endif }