@Override public void init(EList<FragmentSubstitution> fragmentSubstitutions) { fsMap = new HashMap<FragmentSubstitution, FragmentSubstitutionHolder>(); try { for (FragmentSubstitution fragment : fragmentSubstitutions) fsMap.put(fragment, new FragmentSubstitutionHolder(fragment)); // NOTE: the call of computeCopyBaseModel should be exactly here, // since FragmentSubstitutionHolder actually loads all resources as // a side effect // which we lately use to define 'base model' // computeCopyBaseModel(); if (detectIntersection) { placementCrossingFinder = new PlacementCrossingFinder(fsMap.values()); } else { context.getLogger().warn("IntersectionDetection mode is not set!"); } adjacentFinder = new AdjacentFinderImpl(new BasicEList<FragmentSubstitutionHolder>(fsMap.values())); adjacentResolver = new AdjacentResolverImpl(adjacentFinder); placementInReplacementFinder = new ReplacPlacCotainmentFinder(fsMap.values()); placementInReplacementResolver = new ReplacPlacCotainmentResolver(placementInReplacementFinder); } catch (BasicBVREngineException e) { throw new UnsupportedOperationException(e); } }
@Override public void subsitute(FragmentSubstitution fragmentSubstitution, boolean replace) throws ContainmentBVRModelException { FragmentSubstitutionHolder fragmentHolder = fsMap.get(fragmentSubstitution); if (fragmentHolder == null) { context .getLogger() .warn( "engine is not initialized with this fragment substitution " + fragmentSubstitution); return; } FragmentSubOperation subsOperation = new FragmentSubOperation(fragmentHolder); try { subsOperation.execute(replace); adjacentResolver.resolve(fragmentHolder); placementInReplacementResolver.resolve(fragmentHolder); } catch (BasicBVREngineException e) { throw new UnsupportedOperationException(e); } // this check seems to be invalid here since we may work with copies of // base and library models // which are not contained by any resource in the first place // subsOperation.checkConsistence(); }
@Override public void setLogger(Logger logger) { context.setLogger(logger); }
@Override public void setCopyBaseModelMap(HashMap<Resource, IResourceContentCopier> map) { context.setCopyBaseModelMap(map); }
@Override public HashMap<Resource, IResourceContentCopier> getCopiedBaseModels() { return context.getCopyBaseModelMap(); }