@@ -1171,8 +1171,10 @@ Crystal* CreateCrystalFromCIF(CIF &cif,const bool verbose,const bool checkSymAsX
11711171 if (verbose) cout<<endl<<" Finally using spacegroup name:" <<bestsymbol<<endl;
11721172 pCryst->GetSpaceGroup ().ChangeSpaceGroup (bestsymbol);
11731173 }
1174+ // Try to set name from CIF. If that fails, the computed formula will be used at the end
11741175 if (pos->second .mName !=" " ) pCryst->SetName (pos->second .mName );
11751176 else if (pos->second .mFormula !=" " ) pCryst->SetName (pos->second .mFormula );
1177+
11761178 const float t1=chrono.seconds ();
11771179 (*fpObjCrystInformUser)((boost::format (" CIF: Create Crystal:%s(%s)(dt=%6.3fs)" )%pCryst->GetName () % pCryst->GetSpaceGroup ().GetName () % t1).str ());
11781180
@@ -1277,6 +1279,7 @@ Crystal* CreateCrystalFromCIF(CIF &cif,const bool verbose,const bool checkSymAsX
12771279 }
12781280 (*fpObjCrystInformUser)((boost::format (" CIF: finished connecting atoms (%u isolated atoms, %u molecules) (Crystal creation=%6.3fs total)" ) % ctat % ctmol % chrono.seconds ()).str ());
12791281 }
1282+ if (pCryst->GetName ()==" " ) pCryst->SetName (pCryst->GetFormula ());
12801283 }
12811284 return pCryst;
12821285}
@@ -1299,6 +1302,7 @@ PowderPattern* CreatePowderPatternFromCIF(CIF &cif)
12991302DiffractionDataSingleCrystal* CreateSingleCrystalDataFromCIF (CIF &cif, Crystal *pcryst)
13001303{
13011304 DiffractionDataSingleCrystal* pData=NULL ;
1305+ std::string name (" " );
13021306 for (map<string,CIFData>::iterator pos=cif.mvData .begin ();pos!=cif.mvData .end ();++pos)
13031307 {
13041308 if (pos->second .mH .numElements ()>0 )
@@ -1310,6 +1314,7 @@ DiffractionDataSingleCrystal* CreateSingleCrystalDataFromCIF(CIF &cif, Crystal *
13101314 { // Use last Crystal created
13111315 pcryst=&(gCrystalRegistry .GetObj (gCrystalRegistry .GetNb ()-1 ));
13121316 (*fpObjCrystInformUser)((boost::format (" CIF: Importing SINGLE CRYSTAL DIFFRACTION data: using last Crystal structure as corresponding crystal [%s]" ) % pcryst->GetName ().c_str ()).str ());
1317+ name = pcryst->GetName ();
13131318 }
13141319 else
13151320 {
@@ -1320,6 +1325,7 @@ DiffractionDataSingleCrystal* CreateSingleCrystalDataFromCIF(CIF &cif, Crystal *
13201325 }
13211326 pData=new DiffractionDataSingleCrystal (*pcryst);
13221327 pData->SetHklIobs (pos->second .mH ,pos->second .mK ,pos->second .mL ,pos->second .mIobs ,pos->second .mSigma );
1328+ if (pData->GetName ()==" " ) pData->SetName (name);
13231329 (*fpObjCrystInformUser)((boost::format (" CIF: Imported SINGLE CRYSTAL DIFFRACTION data, with %d reflections" ) % pData->GetNbRefl ()).str ());
13241330 }
13251331 }
0 commit comments