internal TupleSet ToTupleSet() { var ts = new TupleSet(); if (Tuples.Count > 0) { ts.Count = (uint)Tuples.Count; } ts.MaxRank = MaxRank; ts.SetDefinition = SetDefinition; if (SortType != SortValues.None) { ts.SortType = SortType; } if (QueryFailed) { ts.QueryFailed = QueryFailed; } if (Tuples.Count > 0) { foreach (var tt in Tuples) { ts.Append(tt.ToTuples()); } } if (HasSortByTuple) { ts.Append(SortByTuple.ToSortByTuple()); } return(ts); }
private void RecursivelySetAssociatedTupleSetnames(TupleSet ts) { if (ts.ParentSet != null) { string parentName = ts.ParentSet.Name; if (!parentName.Equals(ts.Name)) { List <string> association; if (!AssociatedTupleNames.TryGetValue(parentName, out association)) { association = new List <string>(); AssociatedTupleNames[parentName] = association; } if (!association.Contains(ts.Name)) { association.Add(ts.Name); } } } foreach (ITupleSetChild child in ts.Children.Values) { TupleSet childSet = child as TupleSet; if (childSet != null) { RecursivelySetAssociatedTupleSetnames(childSet); } } }
public static IEnumerator Apply(CoordRect rect, Terrain terrain, object dataBox, Func <float, bool> stop = null) { #if VEGETATION_STUDIO_PRO TupleSet <Color[][], int[], VegetationPackagePro> splatsTuple = (TupleSet <Color[][], int[], VegetationPackagePro>)dataBox; Color[][] colors = splatsTuple.item1; int[] maskGroupNums = splatsTuple.item2; VegetationPackagePro package = splatsTuple.item3; if (colors.Length == 0) { Purge(rect, terrain); yield break; } VegetationStudioTile vsTile = terrain.GetComponent <VegetationStudioTile>(); if (vsTile == null) { vsTile = terrain.gameObject.AddComponent <VegetationStudioTile>(); } Texture2D[] textures = WriteTextures(vsTile.lastUsedTextures, colors); //Rect terrainRect = new Rect(terrain.transform.position.x, terrain.transform.position.z, terrain.terrainData.size.x, terrain.terrainData.size.z); //SetTextures(terrainRect, textures, maskGroupNums, package); vsTile.lastUsedTextures = textures; vsTile.lastUsedMaskGroupNums = maskGroupNums; vsTile.lastUsedPackage = package; vsTile.masksApplied = false; yield return(null); #else yield return(null); #endif }
public void GetInto(TupleSet tupleSet) { tupleSet.SetByte(0, x); tupleSet.SetByte(1, y); tupleSet.SetByte(2, z); tupleSet.SetByte(3, w); }
internal TupleSet ToTupleSet() { TupleSet ts = new TupleSet(); if (this.Tuples.Count > 0) { ts.Count = (uint)this.Tuples.Count; } ts.MaxRank = this.MaxRank; ts.SetDefinition = this.SetDefinition; if (this.SortType != SortValues.None) { ts.SortType = this.SortType; } if (this.QueryFailed != false) { ts.QueryFailed = this.QueryFailed; } if (this.Tuples.Count > 0) { foreach (SLTuplesType tt in this.Tuples) { ts.Append(tt.ToTuples()); } } if (this.HasSortByTuple) { ts.Append(this.SortByTuple.ToSortByTuple()); } return(ts); }
internal void FromTupleSet(TupleSet ts) { this.SetAllNull(); if (ts.MaxRank != null) this.MaxRank = ts.MaxRank.Value; if (ts.SetDefinition != null) this.SetDefinition = ts.SetDefinition.Value; if (ts.SortType != null) this.SortType = ts.SortType.Value; if (ts.QueryFailed != null) this.QueryFailed = ts.QueryFailed.Value; SLTuplesType tt; using (OpenXmlReader oxr = OpenXmlReader.Create(ts)) { while (oxr.Read()) { if (oxr.ElementType == typeof(Tuples)) { tt = new SLTuplesType(); tt.FromTuples((Tuples)oxr.LoadCurrentElement()); this.Tuples.Add(tt); } else if (oxr.ElementType == typeof(SortByTuple)) { this.SortByTuple.FromSortByTuple((SortByTuple)oxr.LoadCurrentElement()); this.HasSortByTuple = true; } } } }
public void GetInto(TupleSet tupleSet) { tupleSet.SetFloat(0, x); tupleSet.SetFloat(1, y); tupleSet.SetFloat(2, z); tupleSet.SetFloat(3, w); }
public void Load(string service, string method, string query, CacheObjectType type) { Log.Debug($"Loading cache data for {service}::{method} of type {type}"); // if the cache already exists do not generate it again! if (this.Exists(service, method) == true) { return; } try { MySqlConnection connection = null; MySqlDataReader reader = Database.Query(ref connection, query); PyDataType cacheObject = null; using (connection) using (reader) { switch (type) { case CacheObjectType.Rowset: cacheObject = Rowset.FromMySqlDataReader(reader); break; case CacheObjectType.CRowset: cacheObject = CRowset.FromMySqlDataReader(reader); break; case CacheObjectType.TupleSet: cacheObject = TupleSet.FromMySqlDataReader(reader); break; case CacheObjectType.PackedRowList: cacheObject = PyPackedRowList.FromMySqlDataReader(reader); break; case CacheObjectType.IntIntDict: cacheObject = IntIntDictionary.FromMySqlDataReader(reader); break; case CacheObjectType.IndexRowset: cacheObject = IndexRowset.FromMySqlDataReader(reader, 0); break; } StoreCall(service, method, cacheObject, DateTime.UtcNow.ToFileTimeUtc()); } } catch (Exception) { Log.Error($"Cannot generate cache data for {service}::{method}"); throw; } }
public PyDataType GetMultiOwnersEx(PyList <PyInteger> ids) { MySqlConnection connection = null; MySqlDataReader reader = Database.PrepareQuery(ref connection, $"SELECT itemID as ownerID, itemName as ownerName, typeID FROM eveNames WHERE itemID IN ({PyString.Join(',', ids)})" ).ExecuteReader(); using (connection) using (reader) { return(TupleSet.FromMySqlDataReader(Database, reader)); } }
public PyDataType GetMultiAllianceShortNamesEx(PyList <PyInteger> ids) { MySqlConnection connection = null; MySqlDataReader reader = Database.PrepareQuery(ref connection, $"SELECT allianceID, shortName FROM alliance_shortnames WHERE allianceID IN ({PyString.Join(',', ids)}" ).ExecuteReader(); using (connection) using (reader) { return(TupleSet.FromMySqlDataReader(Database, reader)); } }
public PyDataType GetMultiLocationsEx(PyList <PyInteger> ids) { MySqlConnection connection = null; MySqlDataReader reader = Database.PrepareQuery(ref connection, $"SELECT itemID as locationID, itemName as locationName, x, y, z FROM invItems LEFT JOIN eveNames USING(itemID) LEFT JOIN invPositions USING (itemID) WHERE itemID IN ({PyString.Join(',', ids)})" ).ExecuteReader(); using (connection) using (reader) { return(TupleSet.FromMySqlDataReader(Database, reader)); } }
public PyDataType GetMultiGraphicsEx(PyList <PyInteger> ids) { MySqlConnection connection = null; MySqlDataReader reader = Database.PrepareQuery(ref connection, $"SELECT graphicID, url3D, urlWeb, icon, urlSound, explosionID FROM eveGraphics WHERE graphicID IN ({PyString.Join(',', ids)})" ).ExecuteReader(); using (connection) using (reader) { return(TupleSet.FromMySqlDataReader(Database, reader)); } }
/// <summary> /// Helper method that queries the cached object and converts it to the proper type to be stored /// </summary> /// <param name="query">The query to run</param> /// <param name="type">The type of object to store</param> /// <returns>The final object to be used by the cache</returns> private PyDataType QueryCacheObject(string query, CacheObjectType type) { MySqlConnection connection = null; MySqlDataReader reader = Database.Query(ref connection, query); using (connection) using (reader) { return(type switch { CacheObjectType.Rowset => Rowset.FromMySqlDataReader(Database, reader), CacheObjectType.CRowset => CRowset.FromMySqlDataReader(Database, reader), CacheObjectType.TupleSet => TupleSet.FromMySqlDataReader(Database, reader), CacheObjectType.PackedRowList => PyPackedRowList.FromMySqlDataReader(Database, reader), CacheObjectType.IntIntDict => IntIntDictionary.FromMySqlDataReader(reader), CacheObjectType.IndexRowset => IndexRowset.FromMySqlDataReader(Database, reader, 0), _ => null });
private void Load(string name, string query, CacheObjectType type) { Log.Debug($"Loading cache data for {name} of type {type}"); try { MySqlConnection connection = null; MySqlDataReader reader = Database.Query(ref connection, query); PyDataType cacheObject = null; using (connection) using (reader) { switch (type) { case CacheObjectType.Rowset: cacheObject = Rowset.FromMySqlDataReader(reader); break; case CacheObjectType.CRowset: cacheObject = CRowset.FromMySqlDataReader(reader); break; case CacheObjectType.TupleSet: cacheObject = TupleSet.FromMySqlDataReader(reader); break; case CacheObjectType.PackedRowList: cacheObject = PyPackedRowList.FromMySqlDataReader(reader); break; } Store(name, cacheObject, DateTime.Now.ToFileTimeUtc()); } } catch (Exception e) { Log.Error($"Cannot generate cache data for {name}"); throw; } }
internal void FromTupleSet(TupleSet ts) { this.SetAllNull(); if (ts.MaxRank != null) { this.MaxRank = ts.MaxRank.Value; } if (ts.SetDefinition != null) { this.SetDefinition = ts.SetDefinition.Value; } if (ts.SortType != null) { this.SortType = ts.SortType.Value; } if (ts.QueryFailed != null) { this.QueryFailed = ts.QueryFailed.Value; } SLTuplesType tt; using (OpenXmlReader oxr = OpenXmlReader.Create(ts)) { while (oxr.Read()) { if (oxr.ElementType == typeof(Tuples)) { tt = new SLTuplesType(); tt.FromTuples((Tuples)oxr.LoadCurrentElement()); this.Tuples.Add(tt); } else if (oxr.ElementType == typeof(SortByTuple)) { this.SortByTuple.FromSortByTuple((SortByTuple)oxr.LoadCurrentElement()); this.HasSortByTuple = true; } } } }
public IEnumerator Apply(MapMagic.CoordRect rect, Terrain terrain, object dataBox, Func <float, bool> stop = null) { var wrapper = terrain.gameObject.GetOrAddComponent <TerrainWrapper>(); var MMTerrainLayer = wrapper.GetLayer <MMTerrainLayer>(LayerName, false, true); MMTerrainLayer.Trees.Clear(); TupleSet <TreeInstance[], TreePrototype[]> treesTuple = (TupleSet <TreeInstance[], TreePrototype[]>)dataBox; var prototypeList = treesTuple.item2.ToList(); for (int i = 0; i < treesTuple.item1.Length; i++) { var treeInstance = treesTuple.item1[i]; var newTree = new MadMapsTreeInstance(treeInstance, prototypeList); MMTerrainLayer.Trees.Add(newTree); } global::MapMagic.MapMagic.OnApplyCompleted -= MapMagicIntegrationUtilities.MapMagicOnOnApplyCompleted; global::MapMagic.MapMagic.OnApplyCompleted += MapMagicIntegrationUtilities.MapMagicOnOnApplyCompleted; wrapper.SetDirtyAbove(MMTerrainLayer); yield return(null); }
public PyDataType GetMultiAllianceShortNamesEx(PyList ids) { string query = "SELECT allianceID, shortName FROM alliance_shortnames WHERE allianceID IN ("; Dictionary <string, object> parameters = new Dictionary <string, object>(); foreach (PyDataType id in ids) { parameters["@itemID" + parameters.Count.ToString("X")] = (int)(id as PyInteger); } // prepare the correct list of arguments query += String.Join(',', parameters.Keys) + ")"; MySqlConnection connection = null; MySqlDataReader reader = Database.PrepareQuery(ref connection, query, parameters); using (connection) using (reader) { return(TupleSet.FromMySqlDataReader(reader)); } }
public PyDataType GetMultiLocationsEx(PyList ids) { string query = "SELECT itemID as locationID, itemName as locationName, x, y, z FROM invItems LEFT JOIN eveNames USING(itemID) LEFT JOIN invPositions USING (itemID) WHERE itemID IN ("; Dictionary <string, object> parameters = new Dictionary <string, object>(); foreach (PyDataType id in ids) { parameters["@itemID" + parameters.Count.ToString("X")] = (int)(id as PyInteger); } // prepare the correct list of arguments query += String.Join(',', parameters.Keys) + ")"; MySqlConnection connection = null; MySqlDataReader reader = Database.PrepareQuery(ref connection, query, parameters); using (connection) using (reader) { return(TupleSet.FromMySqlDataReader(reader)); } }
public PyDataType GetMultiGraphicsEx(PyList ids) { string query = "SELECT graphicID, url3D, urlWeb, icon, urlSound, explosionID FROM eveGraphics WHERE graphicID IN ("; Dictionary <string, object> parameters = new Dictionary <string, object>(); foreach (PyDataType id in ids) { parameters["@graphicID" + parameters.Count.ToString("X")] = (int)(id as PyInteger); } // prepare the correct list of arguments query += String.Join(',', parameters.Keys) + ")"; MySqlConnection connection = null; MySqlDataReader reader = Database.PrepareQuery(ref connection, query, parameters); using (connection) using (reader) { return(TupleSet.FromMySqlDataReader(reader)); } }
protected void ProcessTupleset(TupleSet set) { RecursivelySetAssociatedTupleSetnames(set); List <MarkupProperty> markedupChildren = new List <MarkupProperty>(); set.GetAllMarkedupElements(ref markedupChildren); foreach (MarkupProperty mp in markedupChildren) { string keyNameString = keyMapName[InstanceUtils.BuildMergedContextKeyNameStringFromMarkupProperty(mp.contextRef, false)] as string; DataRow row = GetInstanceRow(mp); if (row != null) { string markupData = InstanceUtils.GetMassagedMarkup(mp.markupData); if ((bool)row[InstanceUtils._IsNestedTuple]) { InsertNestedTuple(row, mp.TupleSetName, keyNameString, markupData, level); } else { InsertRegularTuple(row, mp.TupleSetName, keyNameString, markupData, level); } if (!colsWithData.Contains(keyNameString)) { colsWithData.Add(keyNameString); } CascadeHasData(row, mp.TupleSetName); } } }
internal TupleSet ToTupleSet() { TupleSet ts = new TupleSet(); if (this.Tuples.Count > 0) ts.Count = (uint)this.Tuples.Count; ts.MaxRank = this.MaxRank; ts.SetDefinition = this.SetDefinition; if (this.SortType != SortValues.None) ts.SortType = this.SortType; if (this.QueryFailed != false) ts.QueryFailed = this.QueryFailed; if (this.Tuples.Count > 0) { foreach (SLTuplesType tt in this.Tuples) { ts.Append(tt.ToTuples()); } } if (this.HasSortByTuple) { ts.Append(this.SortByTuple.ToSortByTuple()); } return ts; }
public static void Process(MapMagic.CoordRect rect, Chunk.Results results, GeneratorsAsset gens, Chunk.Size terrainSize, Func <float, bool> stop = null) { if (stop != null && stop(0)) { return; } Noise noise = new Noise(12345, permutationCount: 128); //to pick objects based on biome List <TreeInstance> instancesList = new List <TreeInstance>(); List <TreePrototype> prototypesList = new List <TreePrototype>(); //find all of the biome masks - they will be used to determine object probability List <TupleSet <MadMapsTreeOutput, Matrix> > allGensMasks = new List <TupleSet <MadMapsTreeOutput, Matrix> >(); foreach (MadMapsTreeOutput gen in gens.GeneratorsOfType <MadMapsTreeOutput>(onlyEnabled: true, checkBiomes: true)) { Matrix biomeMask = null; if (gen.biome != null) { object biomeMaskObj = gen.biome.mask.GetObject(results); if (biomeMaskObj == null) { continue; //adding nothing if biome has no mask } biomeMask = (Matrix)biomeMaskObj; if (biomeMask == null) { continue; } if (biomeMask.IsEmpty()) { continue; //optimizing empty biomes } } allGensMasks.Add(new TupleSet <MadMapsTreeOutput, Matrix>(gen, biomeMask)); } int allGensMasksCount = allGensMasks.Count; //biome rect to find array pos faster MapMagic.CoordRect biomeRect = new MapMagic.CoordRect(); for (int g = 0; g < allGensMasksCount; g++) { if (allGensMasks[g].item2 != null) { biomeRect = allGensMasks[g].item2.rect; break; } } //prepare biome mask values stack to re-use it to find per-coord biome float[] biomeVals = new float[allGensMasksCount]; //+1 for not using any object at all //iterating all gens for (int g = 0; g < allGensMasksCount; g++) { MadMapsTreeOutput gen = allGensMasks[g].item1; //iterating in layers for (int b = 0; b < gen.baseLayers.Length; b++) { if (stop != null && stop(0)) { return; //checking stop before reading output } Layer layer = gen.baseLayers[b]; // if (layer.prefab == null) continue; //loading objects from input SpatialHash hash = (SpatialHash)gen.baseLayers[b].input.GetObject(results); if (hash == null) { continue; } //adding prototype // if (layer.prefab == null) continue; TreePrototype prototype = new TreePrototype() { prefab = layer.prefab, bendFactor = layer.bendFactor }; prototypesList.Add(prototype); int prototypeNum = prototypesList.Count - 1; //filling instances (no need to check/add key in multidict) foreach (SpatialObject obj in hash.AllObjs()) { //blend biomes - calling continue if improper biome if (biomeBlendType == BiomeBlendType.Sharp) { float biomeVal = 1; if (allGensMasks[g].item2 != null) { biomeVal = allGensMasks[g].item2[obj.pos]; } if (biomeVal < 0.5f) { continue; } } else if (biomeBlendType == BiomeBlendType.AdditiveRandom) { float biomeVal = 1; if (allGensMasks[g].item2 != null) { biomeVal = allGensMasks[g].item2[obj.pos]; } float rnd = noise.Random((int)obj.pos.x, (int)obj.pos.y); if (biomeVal > 0.5f) { rnd = 1 - rnd; } if (biomeVal < rnd) { continue; } } else if (biomeBlendType == BiomeBlendType.NormalizedRandom) { //filling biome masks values int pos = biomeRect.GetPos(obj.pos); for (int i = 0; i < allGensMasksCount; i++) { if (allGensMasks[i].item2 != null) { biomeVals[i] = allGensMasks[i].item2.array[pos]; } else { biomeVals[i] = 1; } } //calculate normalized sum float sum = 0; for (int i = 0; i < biomeVals.Length; i++) { sum += biomeVals[i]; } if (sum > 1) //note that if sum is <1 usedBiomeNum can exceed total number of biomes - it means that none object is used here { for (int i = 0; i < biomeVals.Length; i++) { biomeVals[i] = biomeVals[i] / sum; } } //finding used biome num float rnd = noise.Random((int)obj.pos.x, (int)obj.pos.y); int usedBiomeNum = biomeVals.Length; //none biome by default sum = 0; for (int i = 0; i < biomeVals.Length; i++) { sum += biomeVals[i]; if (sum > rnd) { usedBiomeNum = i; break; } } //disable object using biome mask if (usedBiomeNum != g) { continue; } } //scale mode is applied a bit later //flooring float terrainHeight = 0; if (layer.relativeHeight && results.heights != null) //if checbox enabled and heights exist (at least one height generator is in the graph) { terrainHeight = results.heights.GetInterpolated(obj.pos.x, obj.pos.y); } if (terrainHeight > 1) { terrainHeight = 1; } TreeInstance tree = new TreeInstance(); tree.position = new Vector3( (obj.pos.x - hash.offset.x) / hash.size, obj.height + terrainHeight, (obj.pos.y - hash.offset.y) / hash.size); tree.rotation = layer.rotate ? obj.rotation % 360 : 0; tree.widthScale = layer.widthScale ? obj.size : 1; tree.heightScale = layer.heightScale ? obj.size : 1; tree.prototypeIndex = prototypeNum; tree.color = layer.color; tree.lightmapColor = layer.color; if (biomeBlendType == BiomeBlendType.Scale) { float biomeVal = 1; if (allGensMasks[g].item2 != null) { biomeVal = allGensMasks[g].item2[obj.pos]; } if (biomeVal < 0.001f) { continue; } tree.widthScale *= biomeVal; tree.heightScale *= biomeVal; } instancesList.Add(tree); } } } //setting output if (stop != null && stop(0)) { return; } if (instancesList.Count == 0 && prototypesList.Count == 0) { return; //empty, process is caused by height change } TupleSet <TreeInstance[], TreePrototype[]> treesTuple = new TupleSet <TreeInstance[], TreePrototype[]>(instancesList.ToArray(), prototypesList.ToArray()); results.apply.CheckAdd(typeof(MadMapsTreeOutput), treesTuple, replace: true); }
public void GetInto(TupleSet tupleSet) { tupleSet.SetInteger(0, x); tupleSet.SetInteger(1, y); }
public static void Process(CoordRect rect, Chunk.Results results, GeneratorsAsset gens, Chunk.Size terrainSize, Func <float, bool> stop = null) { #if VEGETATION_STUDIO_PRO if (stop != null && stop(0)) { return; } //gathering prototypes and matrices lists List <Layer> prototypesList = new List <Layer>(); List <Matrix> matrices = new List <Matrix>(); List <Matrix> biomeMasks = new List <Matrix>(); VegetationPackagePro package = null; foreach (VSProMapsOutput gen in gens.GeneratorsOfType <VSProMapsOutput>(onlyEnabled: true, checkBiomes: true)) { //loading biome matrix Matrix biomeMask = null; if (gen.biome != null) { object biomeMaskObj = gen.biome.mask.GetObject(results); if (biomeMaskObj == null) { continue; //adding nothing if biome has no mask } biomeMask = (Matrix)biomeMaskObj; if (biomeMask == null) { continue; } if (biomeMask.IsEmpty()) { continue; //optimizing empty biomes } } for (int i = 0; i < gen.baseLayers.Length; i++) { //reading output directly Output output = gen.baseLayers[i].output; if (stop != null && stop(0)) { return; //checking stop before reading output } if (!results.results.ContainsKey(output)) { continue; } Matrix matrix = (Matrix)results.results[output]; matrix.Clamp01(); //adding to lists matrices.Add(matrix); biomeMasks.Add(gen.biome == null ? null : biomeMask); prototypesList.Add(gen.baseLayers[i]); package = gen.package; } } //optimizing matrices list if they are not used // for (int i = matrices.Count - 1; i >= 0; i--) // if (opacities[i] < 0.001f || matrices[i].IsEmpty() || (biomeMasks[i] != null && biomeMasks[i].IsEmpty())) // { prototypesList.RemoveAt(i); opacities.RemoveAt(i); matrices.RemoveAt(i); biomeMasks.RemoveAt(i); } int numLayers = matrices.Count; if (numLayers == 0) { results.apply.CheckAdd(typeof(VSProMapsOutput), new TupleSet <Color[][], int[], VegetationPackagePro>(new Color[0][], new int[0], package), replace: true); return; } int maxX = MapMagic.instance.resolution; int maxZ = MapMagic.instance.resolution; Dictionary <int, Color[]> grNumToColors = new Dictionary <int, Color[]>(); for (int i = 0; i < numLayers; i++) { int grNum = prototypesList[i].maskGroup; if (!grNumToColors.ContainsKey(grNum)) { grNumToColors.Add(grNum, new Color[maxX * maxZ]); } } //filling colors if (stop != null && stop(0)) { return; } float[] values = new float[numLayers]; //row, to avoid reading/writing 3d array (it is too slow) for (int x = 0; x < maxX; x++) { for (int z = 0; z < maxZ; z++) { int pos = rect.GetPos(x + rect.offset.x, z + rect.offset.z); float sum = 0; //getting values for (int i = 0; i < numLayers; i++) { float val = matrices[i].array[pos]; if (biomeMasks[i] != null) { val *= biomeMasks[i].array[pos]; //if mask is not assigned biome was ignored, so only main outs with mask==null left here } if (val < 0) { val = 0; } if (val > 1) { val = 1; } sum += val; //normalizing: calculating sum values[i] = val; } //normalizing for (int i = 0; i < numLayers; i++) { values[i] = values[i] / sum; } //setting color for (int i = 0; i < numLayers; i++) { Layer layer = prototypesList[i]; Color[] texColors = grNumToColors[layer.maskGroup]; int texturePos = z * maxX + x; float val = values[i]; switch (layer.textureChannel) { case 0: texColors[texturePos].r = val; break; case 1: texColors[texturePos].g = val; break; case 2: texColors[texturePos].b = val; break; case 3: texColors[texturePos].a = val; break; } } } } //creating arrays Color[][] colors = new Color[grNumToColors.Count][]; int[] maskGroupNums = new int[grNumToColors.Count]; int counter = 0; foreach (var kvp in grNumToColors) { maskGroupNums[counter] = kvp.Key; colors[counter] = kvp.Value; counter++; } //pushing to apply if (stop != null && stop(0)) { return; } TupleSet <Color[][], int[], VegetationPackagePro> mapsTuple = new TupleSet <Color[][], int[], VegetationPackagePro>(colors, maskGroupNums, package); results.apply.CheckAdd(typeof(VSProMapsOutput), mapsTuple, replace: true); #endif }
public IEnumerator Apply(MapMagic.CoordRect rect, Terrain terrain, object dataBox, Func <float, bool> stop = null) { TupleSet <float[, , ], SplatPrototypeWrapper[]> splatsTuple = (TupleSet <float[, , ], SplatPrototypeWrapper[]>)dataBox; float[,,] splats3D = splatsTuple.item1; SplatPrototypeWrapper[] prototypes = splatsTuple.item2; if (splats3D.GetLength(2) == 0) { Purge(rect, terrain); yield break; } //TerrainData data = terrain.terrainData; //setting resolution //int size = splats3D.GetLength(0); //if (data.alphamapResolution != size) data.alphamapResolution = size; //checking prototypes texture for (int i = 0; i < prototypes.Length; i++) { if (prototypes[i].Texture == null) { prototypes[i].Texture = defaultTex; } } yield return(null); //welding if (MapMagic.MapMagic.instance != null && MapMagic.MapMagic.instance.splatsWeldMargins != 0) { MapMagic.Coord coord = MapMagic.Coord.PickCell(rect.offset, MapMagic.MapMagic.instance.resolution); //Chunk chunk = MapMagic.MapMagic.instance.chunks[coord.x, coord.z]; Chunk neigPrevX = MapMagic.MapMagic.instance.chunks[coord.x - 1, coord.z]; if (neigPrevX != null && neigPrevX.worker.ready) { WeldTerrains.WeldSplatToPrevX(ref splats3D, neigPrevX.terrain, MapMagic.MapMagic.instance.splatsWeldMargins); } Chunk neigNextX = MapMagic.MapMagic.instance.chunks[coord.x + 1, coord.z]; if (neigNextX != null && neigNextX.worker.ready) { WeldTerrains.WeldSplatToNextX(ref splats3D, neigNextX.terrain, MapMagic.MapMagic.instance.splatsWeldMargins); } Chunk neigPrevZ = MapMagic.MapMagic.instance.chunks[coord.x, coord.z - 1]; if (neigPrevZ != null && neigPrevZ.worker.ready) { WeldTerrains.WeldSplatToPrevZ(ref splats3D, neigPrevZ.terrain, MapMagic.MapMagic.instance.splatsWeldMargins); } Chunk neigNextZ = MapMagic.MapMagic.instance.chunks[coord.x, coord.z + 1]; if (neigNextZ != null && neigNextZ.worker.ready) { WeldTerrains.WeldSplatToNextZ(ref splats3D, neigNextZ.terrain, MapMagic.MapMagic.instance.splatsWeldMargins); } } yield return(null); terrain.terrainData.splatPrototypes = new[] { new SplatPrototype() { texture = defaultTex } }; // To stop MapMagic purging what we're doing here alter on... var wrapper = terrain.gameObject.GetOrAddComponent <TerrainWrapper>(); var MMTerrainLayer = wrapper.GetLayer <MMTerrainLayer>(LayerName, false, true); MMTerrainLayer.SplatData.Clear(); var splatWidth = splats3D.GetLength(0); var splatHeight = splats3D.GetLength(1); if (terrain.terrainData.alphamapResolution != splatWidth) { Debug.Log("Set alphamapResolution to " + splatWidth); terrain.terrainData.alphamapResolution = splatWidth; } var data = new float[splatWidth, splatHeight]; for (int i = 0; i < prototypes.Length; i++) { var splatPrototypeWrapper = prototypes[i]; for (var u = 0; u < splatWidth; ++u) { for (var v = 0; v < splatHeight; ++v) { data[v, u] = splats3D[u, v, i]; } } MMTerrainLayer.SetSplatmap(splatPrototypeWrapper, 0, 0, data, splatWidth); } global::MapMagic.MapMagic.OnApplyCompleted -= MapMagicIntegrationUtilities.MapMagicOnOnApplyCompleted; global::MapMagic.MapMagic.OnApplyCompleted += MapMagicIntegrationUtilities.MapMagicOnOnApplyCompleted; wrapper.SetDirtyAbove(MMTerrainLayer); yield return(null); }
public void ReadICI_InstanceDoc() { string ICI_INSTANCE_FILE = TestCommon.FolderRoot + "ici-instance.xml"; ArrayList errors = new ArrayList(); bool ok = TryLoadInstanceDoc(ICI_INSTANCE_FILE, out errors); if (errors.Count > 0) { errors.Sort(); foreach (ParserMessage pm in errors) { if (pm.Level == TraceLevel.Error) { Console.WriteLine(pm.Message); } else { break; } } } Assert.IsTrue(ok, "try load returned false"); Assert.AreEqual(0, errors.Count); Assert.AreEqual(1, DocumentTupleList.Count, "wrong number of tuples returned"); TupleSet theSet = (TupleSet)DocumentTupleList[0]; List <MarkupProperty> allMarkups = new List <MarkupProperty>(); theSet.GetAllMarkedupElements(ref allMarkups); Assert.AreEqual(185, allMarkups.Count, "wrong number of marked up children"); MarkupProperty mp0 = allMarkups[0]; Assert.AreEqual("ici-rr_Heading", mp0.elementId, "element 0 wrong"); Assert.AreEqual("THE SECURITIES AND EXCHANGE COMMISSION HAS NOT APPROVED OR DISAPPROVED THE FUND'S SHARES OR DETERMINED WHETHER THIS PROSPECTUS IS ACCURATE OR COMPLETE. ANYONE WHO TELLS YOU OTHERWISE IS COMMITTING A CRIME.", mp0.markupData, "element 0 data wrong"); Assert.AreEqual("ici-rr:Prospectus", mp0.TupleParentList[2], "element 0 parent 0 wrong"); Assert.AreEqual("ici-rr:RiskReturn", mp0.TupleParentList[1], "element 0 parent 1 wrong"); Assert.AreEqual("ici-rr:IntroductionHeading", mp0.TupleParentList[0], "element 0 parent 2 wrong"); MarkupProperty mp1 = allMarkups[1]; Assert.AreEqual("ici-rr_Heading", mp1.elementId, "element 1 wrong"); Assert.AreEqual("RISK &RETURN SUMMARY", mp1.markupData, "element 1 data wrong"); Assert.AreEqual("ici-rr:Prospectus", mp1.TupleParentList[2], "element 0 parent 0 wrong"); Assert.AreEqual("ici-rr:RiskReturn", mp1.TupleParentList[1], "element 0 parent 1 wrong"); Assert.AreEqual("ici-rr:RiskReturnHeading", mp1.TupleParentList[0], "element 0 parent 2 wrong"); MarkupProperty mp4 = allMarkups[4]; Assert.AreEqual("ici-rr_Heading", mp4.elementId, "element 4 wrong"); Assert.AreEqual("PRINCIPAL INVESTMENT POLICIES AND STRATEGIES", mp4.markupData, "element 4 data wrong"); Assert.AreEqual("ici-rr:Prospectus", mp4.TupleParentList[3], "element 0 parent 0 wrong"); Assert.AreEqual("ici-rr:RiskReturn", mp4.TupleParentList[2], "element 0 parent 1 wrong"); Assert.AreEqual("ici-rr:StrategySection", mp4.TupleParentList[1], "element 4 parent 2 wrong"); Assert.AreEqual("ici-rr:StrategyHeading", mp4.TupleParentList[0], "element 4 parent 3 wrong"); MarkupProperty mp7 = allMarkups[7]; Assert.AreEqual("ici-rr_Paragraph", mp7.elementId, "element 7 wrong"); Assert.AreEqual("The fund's investments may include securities traded in the over-the-counter markets. The fund may invest up to 25% of its assets in the securities of a single issuer.", mp7.markupData, "element7 data wrong"); Assert.AreEqual("ici-rr:Prospectus", mp7.TupleParentList[3], "element 7 parent 0 wrong"); Assert.AreEqual("ici-rr:RiskReturn", mp7.TupleParentList[2], "element 7 parent 1 wrong"); Assert.AreEqual("ici-rr:StrategySection", mp7.TupleParentList[1], "element 7 parent 2 wrong"); Assert.AreEqual("ici-rr:StrategyNarrativeParagraph", mp7.TupleParentList[0], "element 7 parent 3 wrong"); foreach (ContextProperty cp in this.contexts) { foreach (Segment seg in cp.Segments) { Assert.IsNotNull(seg.DimensionInfo, "Dimension info should not be null"); Assert.AreEqual("ici-rr_RegistrantDimension", seg.DimensionInfo.dimensionId); Console.WriteLine(seg.ToString()); } } }
public HomeController(TupleSet set) { this.set = set; }
public void CreateFromXml() { string startXml = @"<?xml version=""1.0"" encoding=""utf-16""?> <!--Blah Blah Blah--> <!--Based on XBRL 2.1--> <!--Blah Blah Blah--> <xbrl xmlns=""http://www.xbrl.org/2003/instance"" xmlns:link=""http://www.xbrl.org/2003/linkbase"" xmlns:xlink=""http://www.w3.org/1999/xlink"" xmlns:usfr_pt=""http://www.xbrl.org/2003/usfr"" xmlns:iso4217=""http://www.xbrl.org/2003/iso4217""> <link:schemaRef xlink:type=""simple"" xlink:href=""test.xsd"" /> <!--Context Section--> <context id=""current_AsOf""> <entity> <identifier scheme=""http://www.rivetsoftware.com"">Rivet</identifier> </entity> <period> <instant>2003-12-31</instant> </period> </context> <!--Unit Section--> <unit id=""u1""> <!--Scale: 0--> <measure>iso4217:USD</measure> </unit> <unit id=""u2""> <!--Scale: 3--> <measure>iso4217:USD</measure> </unit> <!--Tuple Section--> <usfr_pt:tupleParent1> <!--Tuple Set Name: set1--> <!--Document address: Excel - Sheet1!$A$2--> <usfr_pt:element2 contextRef=""current_AsOf"" unitRef=""u2"" decimals=""10"">98765000</usfr_pt:element2> <!--Tuple Set Name: set1--> <!--Document address: Excel - Sheet1!$A$1--> <usfr_pt:element1 contextRef=""current_AsOf"" unitRef=""u1"" decimals=""10"">12345</usfr_pt:element1> </usfr_pt:tupleParent1> </xbrl>"; XmlDocument xDoc = new XmlDocument(); xDoc.LoadXml(startXml); XmlNamespaceManager theManager = new XmlNamespaceManager(xDoc.NameTable); theManager.AddNamespace("link2", "http://www.xbrl.org/2003/instance"); theManager.AddNamespace("usfr_pt", "http://www.xbrl.org/2003/usfr"); ContextProperty cp = new ContextProperty("current_AsOf"); cp.EntityValue = "Rivet"; cp.EntitySchema = "http://www.rivetsoftware.com"; cp.PeriodType = Element.PeriodType.instant; cp.PeriodStartDate = new DateTime(2003, 12, 31); ArrayList contexts = new ArrayList( ); contexts.Add(cp); UnitProperty up = new UnitProperty("u1", UnitProperty.UnitTypeCode.Standard); up.StandardMeasure.MeasureNamespace = "iso4217"; up.StandardMeasure.MeasureSchema = "http://www.xbrl.org/2003/iso4217"; up.StandardMeasure.MeasureValue = "USD"; ArrayList units = new ArrayList(); units.Add(up); UnitProperty up2 = new UnitProperty("u2", UnitProperty.UnitTypeCode.Standard); up2.StandardMeasure.MeasureNamespace = "iso4217"; up2.StandardMeasure.MeasureSchema = "http://www.xbrl.org/2003/iso4217"; up2.StandardMeasure.MeasureValue = "USD"; units.Add(up2); XmlNodeList elemList = xDoc.SelectNodes("//usfr_pt:tupleParent1", theManager); Assert.IsNotNull(elemList, "elem not found"); Assert.AreEqual(1, elemList.Count, "elem count is wrong"); TupleSet ts = null; ArrayList tupleMarkups; ArrayList errors = new ArrayList(); TupleSet.TryCreateFromXml(elemList[0], contexts, units, out ts, out tupleMarkups, ref errors); Assert.AreEqual(2, tupleMarkups.Count, "wrong number of elements returned"); Assert.AreEqual(2, ts.Children.Count, "wrong number of elements returned"); }
public static void Process(MapMagic.CoordRect rect, Chunk.Results results, GeneratorsAsset gens, Chunk.Size terrainSize, Func <float, bool> stop = null) { if (stop != null && stop(0)) { return; } //values to calculate density float pixelSize = terrainSize.pixelSize; float pixelSquare = pixelSize * pixelSize; //a random needed to convert float to int InstanceRandom rnd = new InstanceRandom(terrainSize.Seed(rect)); //calculating the totoal number of prototypes int prototypesNum = 0; foreach (MadMapsGrassOutput grassOut in gens.GeneratorsOfType <MadMapsGrassOutput>()) { prototypesNum += grassOut.baseLayers.Length; } //preparing results List <int[, ]> detailsList = new List <int[, ]>(); List <DetailPrototypeWrapper> prototypesList = new List <DetailPrototypeWrapper>(); //filling result foreach (MadMapsGrassOutput gen in gens.GeneratorsOfType <MadMapsGrassOutput>(onlyEnabled: true, checkBiomes: true)) { //loading biome matrix Matrix biomeMask = null; if (gen.biome != null) { object biomeMaskObj = gen.biome.mask.GetObject(results); if (biomeMaskObj == null) { continue; //adding nothing if biome has no mask } biomeMask = (Matrix)biomeMaskObj; if (biomeMask == null) { continue; } if (biomeMask.IsEmpty()) { continue; //optimizing empty biomes } } for (int i = 0; i < gen.baseLayers.Length; i++) { if (stop != null && stop(0)) { return; } //loading objects from input //Matrix matrix = (Matrix)gen.baseLayers[i].input.GetObject(chunk); //if (matrix == null) continue; //reading output directly Output output = gen.baseLayers[i].output; if (stop != null && stop(0)) { return; //checking stop before reading output } if (!results.results.ContainsKey(output)) { continue; } Matrix matrix = (Matrix)results.results[output]; //filling array int[,] detail = new int[matrix.rect.size.x, matrix.rect.size.z]; for (int x = 0; x < matrix.rect.size.x; x++) { for (int z = 0; z < matrix.rect.size.z; z++) { float val = matrix[x + matrix.rect.offset.x, z + matrix.rect.offset.z]; float biomeVal = 1; if (gen.biome != null) { if (biomeMask == null) { biomeVal = 0; } else { biomeVal = biomeMask[x + matrix.rect.offset.x, z + matrix.rect.offset.z]; } } detail[z, x] = rnd.RandomToInt(val * gen.baseLayers[i].density * pixelSquare * biomeVal); } } //adding to arrays detailsList.Add(detail); prototypesList.Add(gen.baseLayers[i].Wrapper); } } //pushing to apply if (stop != null && stop(0)) { return; } TupleSet <int[][, ], DetailPrototypeWrapper[]> grassTuple = new TupleSet <int[][, ], DetailPrototypeWrapper[]>(detailsList.ToArray(), prototypesList.ToArray()); results.apply.CheckAdd(typeof(MadMapsGrassOutput), grassTuple, replace: true); }
public void GetInto(TupleSet tupleSet) { tupleSet.SetDouble(0, x); tupleSet.SetDouble(1, y); tupleSet.SetDouble(2, z); }
public static void Process(MapMagic.CoordRect rect, Chunk.Results results, GeneratorsAsset gens, Chunk.Size terrainSize, Func <float, bool> stop = null) { if (stop != null && stop(0)) { return; } //gathering prototypes and matrices lists List <SplatPrototypeWrapper> prototypesList = new List <SplatPrototypeWrapper>(); List <float> opacities = new List <float>(); List <Matrix> matrices = new List <Matrix>(); List <Matrix> biomeMasks = new List <Matrix>(); foreach (MadMapsSplatOutput gen in gens.GeneratorsOfType <MadMapsSplatOutput>(onlyEnabled: true, checkBiomes: true)) { //loading biome matrix Matrix biomeMask = null; if (gen.biome != null) { object biomeMaskObj = gen.biome.mask.GetObject(results); if (biomeMaskObj == null) { continue; //adding nothing if biome has no mask } biomeMask = (Matrix)biomeMaskObj; if (biomeMask == null) { continue; } if (biomeMask.IsEmpty()) { continue; //optimizing empty biomes } } for (int i = 0; i < gen.baseLayers.Length; i++) { if (!gen.baseLayers[i].Wrapper) { continue; } //reading output directly Output output = gen.baseLayers[i].output; if (stop != null && stop(0)) { return; //checking stop before reading output } if (!results.results.ContainsKey(output)) { continue; } Matrix matrix = (Matrix)results.results[output]; matrix.Clamp01(); //adding to lists matrices.Add(matrix); biomeMasks.Add(gen.biome == null ? null : biomeMask); prototypesList.Add(gen.baseLayers[i].Wrapper); opacities.Add(gen.baseLayers[i].opacity); } } //optimizing matrices list if they are not used // for (int i = matrices.Count - 1; i >= 0; i--) // if (opacities[i] < 0.001f || matrices[i].IsEmpty() || (biomeMasks[i] != null && biomeMasks[i].IsEmpty())) // { prototypesList.RemoveAt(i); opacities.RemoveAt(i); matrices.RemoveAt(i); biomeMasks.RemoveAt(i); } //creating array float[,,] splats3D = new float[terrainSize.resolution, terrainSize.resolution, prototypesList.Count]; if (matrices.Count == 0) { results.apply.CheckAdd(typeof(MadMapsSplatOutput), new TupleSet <float[, , ], SplatPrototypeWrapper[]>(splats3D, new SplatPrototypeWrapper[0]), replace: true); return; } //filling array if (stop != null && stop(0)) { return; } int numLayers = matrices.Count; int maxX = splats3D.GetLength(0); int maxZ = splats3D.GetLength(1); //MapMagic.instance.resolution should not be used because of possible lods //MapMagic.CoordRect rect = matrices[0].rect; float[] values = new float[numLayers]; //row, to avoid reading/writing 3d array (it is too slow) for (int x = 0; x < maxX; x++) { for (int z = 0; z < maxZ; z++) { int pos = rect.GetPos(x + rect.offset.x, z + rect.offset.z); float sum = 0; //getting values for (int i = 0; i < numLayers; i++) { float val = matrices[i].array[pos]; if (biomeMasks[i] != null) { val *= biomeMasks[i].array[pos]; //if mask is not assigned biome was ignored, so only main outs with mask==null left here } if (val < 0) { val = 0; } if (val > 1) { val = 1; } sum += val; //normalizing: calculating sum values[i] = val; } //setting color for (int i = 0; i < numLayers; i++) { splats3D[z, x, i] = values[i] / sum; } } } //pushing to apply if (stop != null && stop(0)) { return; } TupleSet <float[, , ], SplatPrototypeWrapper[]> splatsTuple = new TupleSet <float[, , ], SplatPrototypeWrapper[]>(splats3D, prototypesList.ToArray()); results.apply.CheckAdd(typeof(MadMapsSplatOutput), splatsTuple, replace: true); }
private bool TryParseInlineXBRLDocument(ref ArrayList errors) { //add the inline prefix to the namespace manager... XmlElement root = xDoc.DocumentElement; Dictionary<string, string> namespaceused = new Dictionary<string, string>(); foreach (XmlAttribute attr in root.Attributes) { this.attributes.Add(attr.LocalName + "=" + attr.Value); if (attr.Value.ToLower().Equals(DocumentBase.INLINE_XBRL_URI.ToLower())) { inLineXBRLPrefix = attr.LocalName; } else if (attr.Value.ToLower().Equals(DocumentBase.XBRL_INSTANCE_URL.ToLower())) { xbrliPrefix = attr.LocalName; } namespaceused[attr.LocalName] = attr.Value; } theManager.AddNamespace(inLineXBRLPrefix, DocumentBase.INLINE_XBRL_URI); theManager.AddNamespace(xbrliPrefix, DocumentBase.XBRL_INSTANCE_URL); //first get the header region XmlNode xHeader = xDoc.SelectSingleNode("//"+inLineXBRLPrefix+":header", theManager); if (xHeader == null) { //failed to find the inline xbrl header..... Common.WriteError("XBRLParser.Error.NoInlineXBRLHeader", errors); return false; } //first get the schema nodes... // parse out the schemaRefs and keep them XmlNodeList schemaNodes = xHeader.SelectNodes("./" + inLineXBRLPrefix + ":references/link:schemaRef", theManager); if (schemaNodes == null) { Common.WriteError("XBRLParser.Error.NoSchemaRefs", errors); return false; } else { foreach (XmlNode schemaNode in schemaNodes) { this.schemaRefs.Add(schemaNode.Attributes[string.Format(DocumentBase.NAME_FORMAT, DocumentBase.XLINK_PREFIX, HREF)].Value); } } // parse out the contexts and make sure they're valid XmlNodeList contextNodes = xHeader.SelectNodes("./" + inLineXBRLPrefix + ":resources/link2:" + ContextProperty.CONTEXT, theManager); if (contextNodes != null) { foreach (XmlNode context in contextNodes) { ContextProperty cp = null; if (!ContextProperty.TryCreateFromXml(context, theManager, out cp, ref errors)) return false; int index = contexts.BinarySearch(cp); if (index < 0) { this.contexts.Insert(~index, cp); } else { Common.WriteError("XBRLParser.Error.DuplicateContextIdFound", errors); return false; } } } // parse out the units XmlNodeList unitNodes = xHeader.SelectNodes("./" + inLineXBRLPrefix + ":resources/link2:" + UnitProperty.UNIT, theManager); if (unitNodes != null) { foreach (XmlNode unit in unitNodes) { UnitProperty up = null; if (!UnitProperty.TryCreateFromXml(unit, theManager, out up, ref errors)) return false; int index = units.BinarySearch(up); if (index < 0) { this.units.Insert(~index, up); } else { Common.WriteError("XBRLParser.Error.DuplicateUnitIdFound", errors); return false; } } } //read the footnotes Dictionary<string, List<FootnoteProperty>> footnoteInfos = ReadFootnoteDataFromDoc(root, "//" + inLineXBRLPrefix + ":footnoteLink", false); this.mpIDs.Clear(); Dictionary<string, Dictionary<decimal, ITupleSetChild>> tupleMarkups = new Dictionary<string, Dictionary<decimal, ITupleSetChild>>(); ParseInLineXBRLElementInformation(root, "//" + inLineXBRLPrefix + ":nonFraction", true,namespaceused, tupleMarkups, footnoteInfos, ref errors); ParseInLineXBRLElementInformation(root, "//" + inLineXBRLPrefix + ":nonNumeric", false,namespaceused, tupleMarkups, footnoteInfos, ref errors); #region Tuple handling //handling only tuple with IDs for now.. as there is no example for how //tuples withput ids and nesting works correctly.... Dictionary<string, TupleSet> tupleSetById = new Dictionary<string, TupleSet>(); //List<XmlNode> tuplesWithoutIds = new List<XmlNode>(); //tuples can be linked either with tupleRef or as children of the tuple element... XmlNodeList tupleNodes = root.SelectNodes("//" + inLineXBRLPrefix + ":tuple", theManager); if (tupleNodes != null && tupleNodes.Count > 0) { #region get all tuples with ID foreach (XmlNode tn in tupleNodes) { XmlAttribute nameAttr = tn.Attributes[inLineXBRLPrefix+":name"]; if (nameAttr == null) { nameAttr = tn.Attributes["name"]; } if (nameAttr == null) { errors.Add("Failed to parse " + tn.OuterXml); continue; } if (tn.Attributes[inLineXBRLPrefix + ":tupleID"] == null) { //the elements are nested inside the tuples.... //continue; } else { TupleSet ts = new TupleSet(); ts.Name = tn.Attributes[inLineXBRLPrefix + ":tupleID"].Value; ts.TupleParentElementId = nameAttr.Value.Replace(':', '_'); tupleSetById[ts.Name] = ts; if (tn.Attributes[inLineXBRLPrefix + ":order"] != null && tn.Attributes[inLineXBRLPrefix + ":tupleRef"] != null) { decimal order = 0; if (decimal.TryParse(tn.Attributes[inLineXBRLPrefix + ":order"].Value, System.Globalization.NumberStyles.Any, null, out order)) { //we have a nested tuple....as the tuple has a reference to another tuple... string tupleId = tn.Attributes[inLineXBRLPrefix + ":tupleRef"].Value; Dictionary<decimal, ITupleSetChild> inner; if (!tupleMarkups.TryGetValue(tupleId, out inner)) { inner = new Dictionary<decimal, ITupleSetChild>(); tupleMarkups[tupleId] = inner; } inner[order] = ts; } } } } #endregion #region add children to the tuple sets.... foreach (KeyValuePair<string, TupleSet> kvp in tupleSetById) { TupleSet ts = kvp.Value; Dictionary<decimal, ITupleSetChild> children; if (tupleMarkups.TryGetValue(kvp.Key, out children)) { foreach (KeyValuePair<decimal, ITupleSetChild> kvp2 in children) { ts.Children.Add((float)kvp2.Key, kvp.Value); if (kvp.Value is TupleSet) { ((TupleSet)kvp.Value).ParentSet = ts; } } } } #endregion DocumentTupleList = new List<TupleSet>(); #region get the top level tuple sets... foreach (KeyValuePair<string, TupleSet> kvp in tupleSetById) { if (kvp.Value.ParentSet == null) { kvp.Value.UpdateMarkupsWithTupleSetInformation(kvp.Value, new List<string>()); DocumentTupleList.Add(kvp.Value); } } #endregion } #endregion return true; }