162
164
// read and check file type marker
163
165
std::string fileType;
164
166
iStream >> fileType;
165
if (fileType != "LSMGeometry") { // wrong file type -> bail out
166
throw runtime_error("Unrecognised file type " + fileType + " expected LSMGeometry.");
167
size_t ftl=std::min(fileType.size(),size_t(4));
168
std::string fileTypeHead=fileType.substr(0,ftl);
169
if ((fileType != "LSMGeometry") && (fileTypeHead!="ESyS")) { // wrong file type -> bail out
170
throw runtime_error("Unrecognised file type " + fileType + " expected LSMGeometry or ESyS-Particle.");
169
173
// read and check version number
170
174
iStream >> impl.m_version;
171
if((impl.m_version != 1.1f) && (impl.m_version != 1.2f)){
175
if((fileType=="LSMGeometry") && ((impl.m_version != 1.1f) && (impl.m_version != 1.2f))){
172
176
std::stringstream msg;
174
178
<< "Can only read version 1.1 or 1.2 geometry files, this is version "
175
179
<< impl.m_version;
176
// throw std::runtime_error(msg.str().c_str());
177
impl.m_version=1.2; // temporary hack
180
throw std::runtime_error(msg.str().c_str());
181
} else if (fileTypeHead=="ESyS") {
182
impl.m_version=1.2f; // temporary hack
180
185
// read boundary box
340
353
m_pImpl->m_bBoxMin = min;
341
354
m_pImpl->m_bBoxMax = max;
358
check if a model with the geometry described in the GeoInfo given in the argument
359
can be loaded into a pre-existing model
361
\param gi the new geometry info
363
bool GeometryInfo::isCompatible(const GeometryInfo& gi) const
367
// check if circular dimensions agree
368
res=res && (m_pImpl->m_periodicDimensions[0]==gi.m_pImpl->m_periodicDimensions[0])
369
&& (m_pImpl->m_periodicDimensions[1]==gi.m_pImpl->m_periodicDimensions[1])
370
&& (m_pImpl->m_periodicDimensions[2]==gi.m_pImpl->m_periodicDimensions[2]);
371
// check if min/max in circular dimensions agree and
372
// if new (argument) bounding box fits into old bbx in the non-circular dimensions
374
if(m_pImpl->m_periodicDimensions[0]) {
375
res = res && (m_pImpl->m_bBoxMin[0]==gi.m_pImpl->m_bBoxMin[0])
376
&& (m_pImpl->m_bBoxMax[0]==gi.m_pImpl->m_bBoxMax[0]);
378
res = res && (m_pImpl->m_bBoxMin[0]<=gi.m_pImpl->m_bBoxMin[0])
379
&& (m_pImpl->m_bBoxMax[0]>=gi.m_pImpl->m_bBoxMax[0]);
382
if(m_pImpl->m_periodicDimensions[1]) {
383
res = res && (m_pImpl->m_bBoxMin[1]==gi.m_pImpl->m_bBoxMin[1])
384
&& (m_pImpl->m_bBoxMax[1]==gi.m_pImpl->m_bBoxMax[1]);
386
res = res && (m_pImpl->m_bBoxMin[1]<=gi.m_pImpl->m_bBoxMin[1])
387
&& (m_pImpl->m_bBoxMax[1]>=gi.m_pImpl->m_bBoxMax[1]);
390
if(m_pImpl->m_periodicDimensions[2]) {
391
res = res && (m_pImpl->m_bBoxMin[2]==gi.m_pImpl->m_bBoxMin[2])
392
&& (m_pImpl->m_bBoxMax[2]==gi.m_pImpl->m_bBoxMax[2]);
394
res = res && (m_pImpl->m_bBoxMin[2]<=gi.m_pImpl->m_bBoxMin[2])
395
&& (m_pImpl->m_bBoxMax[2]>=gi.m_pImpl->m_bBoxMax[2]);
403
Check if the geometrical dimensions in two GeometryInfo objects are identical
405
\param gi the new geometry info
407
bool GeometryInfo::isIdenticalGeometry(const GeometryInfo& gi) const
411
// check if circular dimensions agree
412
res=res && (m_pImpl->m_periodicDimensions[0]==gi.m_pImpl->m_periodicDimensions[0])
413
&& (m_pImpl->m_periodicDimensions[1]==gi.m_pImpl->m_periodicDimensions[1])
414
&& (m_pImpl->m_periodicDimensions[2]==gi.m_pImpl->m_periodicDimensions[2]);
415
// check if dimensions agree
417
res = res && (m_pImpl->m_bBoxMin[0]==gi.m_pImpl->m_bBoxMin[0])
418
&& (m_pImpl->m_bBoxMax[0]==gi.m_pImpl->m_bBoxMax[0]);
420
res = res && (m_pImpl->m_bBoxMin[1]==gi.m_pImpl->m_bBoxMin[1])
421
&& (m_pImpl->m_bBoxMax[1]==gi.m_pImpl->m_bBoxMax[1]);
423
res = res && (m_pImpl->m_bBoxMin[2]==gi.m_pImpl->m_bBoxMin[2])
424
&& (m_pImpl->m_bBoxMax[2]==gi.m_pImpl->m_bBoxMax[2]);
344
430
std::ostream &operator<<(std::ostream &oStream, const GeometryInfo &geoInfo)
346
432
geoInfo.write(oStream);