private DataTable getPivotedTable(DataTable table, CurveData <TXValue, TYValue> firstCurve) { const string tableNameSuffix = " Pivoted"; if (firstCurve == null) { return(new DataTable(tableNameSuffix)); } var pivoter = new Pivoter(); var dataFields = GetDataFields(firstCurve); var aggregate = new Aggregate <float, float> { Aggregation = floats => floats.FirstOrDefault(), Name = dataFields.Count == 1 ? dataFields[0] : string.Empty }; var pivotInfo = new PivotInfo(rowFields: GetRowFields(firstCurve), dataFields: dataFields, columnFields: new[] { PANE_CAPTION, CURVE_CAPTION }, aggregates: new[] { aggregate }); var pivotTable = pivoter.PivotData(table.DefaultView, pivotInfo); pivotTable.TableName += tableNameSuffix; //purge empty columns foreach (var column in getEmptyColumns(pivotTable)) { pivotTable.Columns.Remove(column); } PerformSpecificTransformationOnPivotedTable(pivotTable); return(pivotTable); }
public override string TeXChunk(PivotTable table) { var captionText = _builderRepository.ChunkFor(table.Caption); var pivoter = new Pivoter(); var pivotData = pivoter.PivotData(table.Data, table.PivotInfo); return(TableWriter.PivotTable(captionText, table.Label, pivotData.DefaultView, table.Data.Table, table.PivotInfo, table.TexTranslations, table.Converter, _builderRepository)); }
public void RunInUpdate(bool fromShape, PointMeshType shape, int pivotsPerUpdate, int pivotAnimationSteps, int numPoints, float scale, float radius) { this.pivotsPerUpdate = pivotsPerUpdate; this.pivotAnimationSteps = pivotAnimationSteps; running = true; ballRadius = radius; mesh = meshFilter.mesh; ball.transform.localScale = new Vector3(radius * 2, radius * 2, radius * 2); //generate a sphere of points for testing purposes if (fromShape) { cloud = new PointCloud <PointNormal>(numPoints); if (shape == PointMeshType.Sphere) { for (int i = 0; i < numPoints; i++) { var normal = new Vector3(UnityEngine.Random.value - 0.5f, UnityEngine.Random.value - 0.5f, UnityEngine.Random.value - 0.5f).normalized; var point = normal * scale; cloud.Add(new PointNormal(point.x, point.y, point.z, normal.x, normal.y, normal.z)); } } } else { cloud = new PointCloud <PointNormal>(mesh.vertexCount); var vertices = mesh.vertices; var normals = mesh.normals; for (int i = 0; i < mesh.vertexCount; i++) { Vector3 v = vertices[i]; Vector3 n = normals[i]; cloud.Add(new PointNormal(v.x, v.y, v.z, n.x, n.y, n.z)); } } GetComponent <VoxelRenderer>().SetFromPointCloud(cloud); pivoter = new Pivoter(cloud, ballRadius); f = new Front(); }
void RunBallPivot(float[] passes) { startTime = Time.realtimeSinceStartup; f = new Front(); ballRadius = passes[0]; pivoter = new Pivoter(cloud, ballRadius); Debug.Log("Pivoter initialized in: " + (Time.realtimeSinceStartup - startTime) + "s"); while (true) { Edge e; while ((e = f.GetActiveEdge()) != null) { Tuple <int, Triangle> t = pivoter.Pivot(e); if (t != null && (!pivoter.IsUsed(t.Item1) || f.InFront(t.Item1))) { preMesh.Add(t.Item2); f.JoinAndGlue(t, pivoter); } else { f.SetInactive(e); } } Triangle tri; if ((tri = pivoter.FindSeed()) != null) { preMesh.Add(tri); f.AddEdges(tri); } else { pivoter.FindSeed(); break; } } }
protected override void Context() { sut = new Pivoter(); }
internal void JoinAndGlue(Tuple <int, Triangle> tri, Pivoter pivoter) { //join and glue prototype //if (f.Contains(new Edge(e.First, p))) // Glue(new Edge(p, e.First), new Edge(e.First, p)); //if (f.Contains(new Edge(e.Second, p))) // Glue(new Edge(p, e.First), new Edge(p, e.First)); if (!pivoter.IsUsed(tri.Item1)) { for (int i = 0; i < 2; i++) { Edge e = tri.Item2.GetEdge(i); LinkedListNode <Edge> insertionPlace = front.AddBefore(pos, e); AddEdgePoints(insertionPlace); } RemoveEdgePoints(pos.Value); bool atEnd = false; var tmp = pos.Next; if (tmp == null) { tmp = pos.Previous; atEnd = true; } front.Remove(pos); //move iterator to first added edge if (!atEnd) { pos = tmp.Previous.Previous; } else { pos = tmp.Previous; } pivoter.SetUsed(tri.Item1); } else if (InFront(tri.Item1)) { int added = 0; for (int i = 0; i < 2; i++) { Edge e = tri.Item2.GetEdge(i); LinkedListNode <Edge> it = IsPresent(e); if (it != null) { RemoveEdgePoints(it.Value); front.Remove(it); } else { LinkedListNode <Edge> insertionPlace = front.AddBefore(pos, e); AddEdgePoints(insertionPlace); added--; } } var tmp = pos.Next; if (tmp == null) { tmp = pos.Previous; added++; } RemoveEdgePoints(pos.Value); front.Remove(pos); pos = tmp; if (added < 0) { while (added < 0) { pos = pos.Previous; added++; } } else { pos = front.First; } } else { SetInactive(pos.Value); } }