/** Generate a temporary file name of format: * TempPrefix_<#> * where <#> is based on the current number of temporary file names * that have been requested. */ FileName GenTempName() { // Could also set this to 0, but setting it to size is a better guarantee // that the name will be free. unsigned int tmpidx = TempFileNames_.size(); FileName temp( TempPrefix_ + integerToString(tmpidx) ); while (tmpidx < maxtmpidx_ && Exists(temp)) { tmpidx++; temp = FileName( TempPrefix_ + integerToString(tmpidx) ); } if (tmpidx >= maxtmpidx_) { mprinterr("Internal Error: Too many temporary files. Remove files named '%s*'\n", TempPrefix_.c_str()); return FileName(); } return temp; }
void test_aliases(const NameList &elements) { int count = elements.size(); OUTPUT << "\n\nTesting Element Topology Aliases...\n"; for (int i=0; i < count; i++) { Ioss::ElementTopology *el_top = Ioss::ElementTopology::factory(elements[i]); if (el_top->name() == elements[i]) { OUTPUT << "Element: " << std::setw(20) << elements[i] << "(" << el_top->master_element_name() << ") has the following aliases:\n\t"; for (int j=0; j < count; j++) { if (i != j && el_top->is_alias(elements[j])) { OUTPUT << elements[j] << ", "; } } OUTPUT << std::endl; } } }
void LinkedScene::writeAttribute( const Name &name, const Object *attribute, double time ) { if ( m_readOnly ) { throw Exception( "No write access to scene file!" ); } if ( name == linkAttribute ) { bool firstTime = !m_mainScene->hasAttribute( fileNameLinkAttribute ); if ( firstTime ) { // if it's the first time, we better check if this level already has objects, tags or children // and raise exceptions to prevent weird configurations... if ( m_mainScene->hasObject() ) { throw Exception( "Links to external scenes cannot be created on locations where there's already an object saved!" ); } NameList names; m_mainScene->childNames( names ); if ( names.size() ) { throw Exception( "Links to external scenes cannot be created on locations where there are already child locations!" ); } } // we are creating a link! const CompoundData *d = runTimeCast< const CompoundData >(attribute); if ( !d ) { throw Exception( "SceneInterface:link attribute must be of type CompoundData!" ); } // open the linked scene int linkDepth; ConstDoubleDataPtr timeData = d->member< const DoubleData >( g_time ); const StringData *fileName = d->member< const StringData >( g_fileName ); const InternedStringVectorData *sceneRoot = d->member< const InternedStringVectorData >( g_root ); ConstSceneInterfacePtr linkedScene = expandLink( fileName, sceneRoot, linkDepth ); if ( !linkedScene ) { throw Exception( "Trying to store a broken link!" ); } // get the bounds of the linked scene const SampledSceneInterface *sampledScene = runTimeCast< const SampledSceneInterface >(linkedScene.get()); if ( sampledScene && !timeData ) { // When there's no time remapping we get all the bounding box samples from the linked scene, using the same time. if ( firstTime ) { size_t bounds = sampledScene->numBoundSamples(); for ( size_t b = 0; b < bounds; b++ ) { m_mainScene->writeBound( sampledScene->readBoundAtSample(b), sampledScene->boundSampleTime(b) ); } } } else { /// we store just the current bounding box if ( timeData ) { m_mainScene->writeBound( linkedScene->readBound(timeData->readable()), time ); } else { m_mainScene->writeBound( linkedScene->readBound(time), time ); } } if ( firstTime ) { // save the tags from the linked file to the current location so it gets propagated to the root. NameList tags; // Check if the position of the file we are trying to link to, has ancestor tags. // This situation is undesirable, as it will make LinkedScene return inconsistent ancestor tags before and after the link location. linkedScene->readTags(tags, SceneInterface::AncestorTag ); if ( tags.size() ) { std::string pathStr; SceneInterface::pathToString( sceneRoot->readable(), pathStr ); msg( Msg::Warning, "LinkedScene::writeAttribute", ( boost::format( "Detected ancestor tags while creating link to file %s at location %s." ) % fileName->readable() % pathStr ).str() ); } tags.clear(); /// copy all descendent and local tags as descendent tags (so we can distinguish from tags added in the LinkedScene) linkedScene->readTags(tags, SceneInterface::LocalTag|SceneInterface::DescendantTag ); static_cast< SceneCache *>(m_mainScene.get())->writeTags(tags, true); m_mainScene->writeAttribute( fileNameLinkAttribute, d->member< const StringData >( g_fileName ), time ); m_mainScene->writeAttribute( rootLinkAttribute, d->member< const InternedStringVectorData >( g_root ), time ); } /// we keep the information this level has a link, so we can prevent attempts to /// create children or save objects at this level. m_atLink = true; if( timeData ) { m_mainScene->writeAttribute( timeLinkAttribute, timeData, time ); } return; } m_mainScene->writeAttribute(name,attribute,time); }