/// <inheritdoc /> public virtual bool RemoveVertex(TVertex vertex) { if (!ContainsVertex(vertex)) { return(false); } // Collect edges to remove var edgesToRemove = new EdgeList <TVertex, TEdge>(); foreach (TEdge outEdge in OutEdges(vertex)) { _vertexInEdges[outEdge.Target].Remove(outEdge); edgesToRemove.Add(outEdge); } foreach (TEdge inEdge in InEdges(vertex)) { // Might already have been removed if (_vertexOutEdges[inEdge.Source].Remove(inEdge)) { edgesToRemove.Add(inEdge); } } // Notify users if (EdgeRemoved != null) { foreach (TEdge edge in edgesToRemove) { OnEdgeRemoved(edge); } } _vertexOutEdges.Remove(vertex); _vertexInEdges.Remove(vertex); EdgeCount -= edgesToRemove.Count; OnVertexRemoved(vertex); return(true); }
// Add a new line into the simple layout struct, new vertices and a new edge public eOperationStatus AddEdge(PointF WorldFrom, PointF WorldTo, int Width, int Height) { if (MostRecentlySelectedLayer == null) { return(eOperationStatus.NoLayerSelected); } MostRecentlySelectedLayer.AddEdge(WorldFrom, WorldTo, Width, Height); #if false int nextindex = FindNextIndex(); Vertex vP1 = new Vertex(); vP1.Index = nextindex++; vP1.X = WorldFrom.X; vP1.Y = WorldFrom.Y; VertexList.Add(vP1); Vertex vP2 = new Vertex(); vP2.Index = nextindex++; vP2.X = WorldTo.X; vP2.Y = WorldTo.Y; VertexList.Add(vP2); // Now add a segment Edge oEdge = new Edge(); oEdge.Height = 30; oEdge.Width = 10; oEdge.p1 = vP1.Index; oEdge.p2 = vP2.Index; oEdge.ID = ""; oEdge.HoleGroupID = ""; EdgeList.Add(oEdge); #endif // redraw shapes DrawShapes(); return(eOperationStatus.OK); }
static void Main(string[] args) { int pathStart = 0, pathEnd = 0; EdgeList graph = LoadGraph("d:\\dump\\graph5.txt", ref pathStart, ref pathEnd); Console.WriteLine("Loaded graph:\n"); Console.WriteLine(graph.ToString()); Random rand = new Random(); int maxGenerations = 200; int minPopulationSize = 20, maxPopulationSize = 30; float mutationRate = rand.Next(10, 15) / 100.0f; int reportEvery = 10; GeneticSolver solver = new GeneticSolver(maxGenerations, minPopulationSize, maxPopulationSize, mutationRate, graph, pathStart, pathEnd, reportEvery); solver.Solve(); Console.ReadLine(); }
/// <inheritdoc /> public int RemoveEdgeIf(EdgePredicate <TVertex, TEdge> predicate) { if (predicate is null) { throw new ArgumentNullException(nameof(predicate)); } var edgesToRemove = new EdgeList <TVertex, TEdge>(); edgesToRemove.AddRange(Edges.Where(edge => predicate(edge))); foreach (TEdge edge in edgesToRemove) { OnEdgeRemoved(edge); _vertexEdges[edge.Source].Remove(edge); } EdgeCount -= edgesToRemove.Count; return(edgesToRemove.Count); }
/// <summary> /// Initializes a new instance of the <see cref="BidirectionalAdapterGraph{TVertex,TEdge}"/> class. /// </summary> /// <param name="baseGraph">Wrapped graph.</param> /// <exception cref="T:System.ArgumentNullException"><paramref name="baseGraph"/> is <see langword="null"/>.</exception> public BidirectionalAdapterGraph([NotNull] IVertexAndEdgeListGraph <TVertex, TEdge> baseGraph) { _baseGraph = baseGraph ?? throw new ArgumentNullException(nameof(baseGraph)); _inEdges = new Dictionary <TVertex, EdgeList <TVertex, TEdge> >(_baseGraph.VertexCount); foreach (TEdge edge in _baseGraph.Edges) { if (!_inEdges.TryGetValue(edge.Target, out EdgeList <TVertex, TEdge> edgeList)) { edgeList = new EdgeList <TVertex, TEdge>(); _inEdges.Add(edge.Target, edgeList); } edgeList.Add(edge); } // Add vertices that has no in edges foreach (TVertex vertex in _baseGraph.Vertices.Except(_inEdges.Keys.ToArray())) { _inEdges.Add(vertex, new EdgeList <TVertex, TEdge>()); } }
/// <inheritdoc /> public void ClearInEdges(TVertex vertex) { if (vertex == null) { throw new ArgumentNullException(nameof(vertex)); } if (_vertexInEdges.TryGetValue(vertex, out IEdgeList <TVertex, TEdge> inEdges)) { _vertexInEdges[vertex] = new EdgeList <TVertex, TEdge>(); foreach (TEdge inEdge in inEdges) { _vertexOutEdges[inEdge.Source].Remove(inEdge); } EdgeCount -= inEdges.Count; Debug.Assert(EdgeCount >= 0); NotifyEdgesRemoved(inEdges); inEdges.Clear(); } }
static void Main(string[] args) { int colorsCount = 0; EdgeList graph = LoadGraph("d:\\dump\\graph2colors.txt", ref colorsCount); Console.WriteLine("Loaded graph:\n"); Console.WriteLine(graph.ToString()); Random rand = new Random(); int maxGenerations = 100; int minPopulationSize = 10, maxPopulationSize = 30; float mutationRate = rand.Next(5, 10) / 100.0f; int reportEvery = 1; GeneticSolver solver = new GeneticSolver(maxGenerations, minPopulationSize, maxPopulationSize, mutationRate, graph, colorsCount, reportEvery); solver.Solve(); Console.ReadLine(); }
public virtual bool RemoveVertex(TVertex v) { if (!this.ContainsVertex(v)) { return(false); } // collect edges to remove var edgesToRemove = new EdgeList <TVertex, TEdge>(); foreach (var outEdge in this.OutEdges(v)) { this.vertexInEdges[outEdge.Target].Remove(outEdge); edgesToRemove.Add(outEdge); } foreach (var inEdge in this.InEdges(v)) { // might already have been removed if (this.vertexOutEdges[inEdge.Source].Remove(inEdge)) { edgesToRemove.Add(inEdge); } } // notify users if (this.EdgeRemoved != null) { foreach (TEdge edge in edgesToRemove) { this.OnEdgeRemoved(edge); } } this.vertexOutEdges.Remove(v); this.vertexInEdges.Remove(v); this.edgeCount -= edgesToRemove.Count; this.OnVertexRemoved(v); return(true); }
/// <inheritdoc /> public int RemoveInEdgeIf(TVertex vertex, EdgePredicate <TVertex, TEdge> predicate) { if (predicate is null) { throw new ArgumentNullException(nameof(predicate)); } if (!_vertexInEdges.TryGetValue(vertex, out IEdgeList <TVertex, TEdge> inEdges)) { return(0); } var edgesToRemove = new EdgeList <TVertex, TEdge>(); edgesToRemove.AddRange(inEdges.Where(edge => predicate(edge))); foreach (TEdge edge in edgesToRemove) { RemoveEdge(edge); } return(edgesToRemove.Count); }
/// <summary> /// Tests the express where-clause specified in param 'clause' /// </summary> /// <param name="clause">The express clause to test</param> /// <returns>true if the clause is satisfied.</returns> public bool ValidateClause(IfcEdgeLoopClause clause) { var retVal = false; try { switch (clause) { case IfcEdgeLoopClause.WR1: retVal = Object.ReferenceEquals((EdgeList.ItemAt(0).EdgeStart), (EdgeList.ItemAt(Ne - 1).EdgeEnd)); break; case IfcEdgeLoopClause.WR2: retVal = Functions.IfcLoopHeadToTail(this); break; } } catch (Exception ex) { var log = Validation.ValidationLogging.CreateLogger <Xbim.Ifc2x3.TopologyResource.IfcEdgeLoop>(); log?.LogError(string.Format("Exception thrown evaluating where-clause 'IfcEdgeLoop.{0}' for #{1}.", clause, EntityLabel), ex); } return(retVal); }
public int RemoveOutEdgeIf(TVertex v, EdgePredicate <TVertex, TEdge> predicate) { var edges = this.vertexEdges[v]; var edgeToRemove = new EdgeList <TVertex, TEdge>(edges.Count); foreach (var edge in edges) { if (predicate(edge)) { edgeToRemove.Add(edge); } } foreach (var edge in edgeToRemove) { edges.Remove(edge); this.OnEdgeRemoved(edge); } this.edgeCount -= edgeToRemove.Count; return(edgeToRemove.Count); }
/* The channel alphabet is constructed from its connected processes */ public void ParseGraphHalfDuplex(EdgeList adj) { if (adj != null) { List <Tuple <string, int> > vertices = adj.GetVertices(); /* A list of processes and a list of channels */ NodeList = new List <Node>(); /* Go through the list, create and reuse where nessesary */ foreach (var process in vertices) { String sSyncTrace = GetSyncTraceFromIndex(process.Item2); Node node = null; if (!NodeList.Any(p => p.NodeId == process.Item1)) { Console.WriteLine(String.Format("Creating node {0}", process.Item1)); /* Add the new node to the list */ node = new Node(process.Item1); /* Add the node to the node list */ NodeList.Add(node); } else { Console.WriteLine(String.Format("Using node {0}", process.Item1)); /* Get the existing node */ node = NodeList.First(p => p.NodeId == process.Item1); } /* Add the event to the node */ Csp.Trace nodeTrace = new Csp.Trace() { ProcessId = node.NodeId, Name = sSyncTrace, synchronisation = true }; node.AddTxRxTrace(nodeTrace, Channel.enChannelType.Transceive); } } }
private static EdgeList LoadGraph(string filePath, ref int colorsCount) { Random rand = new Random(0); using (StreamReader sr = new StreamReader(filePath)) { string line = sr.ReadLine(); string[] parameters = line.Split(' '); int vCount = Int32.Parse(parameters[0]); colorsCount = Int32.Parse(parameters[1]); EdgeList result = new EdgeList(vCount); while ((line = sr.ReadLine()) != null) { parameters = line.Split('-'); int from = Int32.Parse(parameters[0]); int to = Int32.Parse(parameters[1]); int weight = rand.Next(1, 10); result.AddEdge(new Edge(from, to, weight)); } return(result); } }
/// <inheritdoc /> public int RemoveInEdgeIf(TVertex vertex, EdgePredicate <TVertex, TEdge> predicate) { if (vertex == null) { throw new ArgumentNullException(nameof(vertex)); } if (predicate is null) { throw new ArgumentNullException(nameof(predicate)); } var edgesToRemove = new EdgeList <TVertex, TEdge>(); edgesToRemove.AddRange(InEdges(vertex).Where(edge => predicate(edge))); foreach (TEdge edge in edgesToRemove) { RemoveEdge(edge); } return(edgesToRemove.Count); }
public eOperationStatus UnMergeMostRecentlySelectedHandle() { if (MostRecentlySelectedVertex == null) { return(eOperationStatus.NoVertexSelected); } // Delete this index. We'll replace all occurrences with new vertices for (int i = 0; i < VertexList.Count; i++) { Vertex v = VertexList.GetFrom(i); if (v.Index == MostRecentlySelectedVertex.Index) { VertexList.RemoveAt(i); break; } } /* * Now create new handles for each instance of the just deleted vertex */ for (int i = 0; i < EdgeList.Count; i++) { Edge oEdge = EdgeList.GetFrom(i); if (oEdge.p1 == MostRecentlySelectedVertex.Index) { Vertex v = NewVertex(MostRecentlySelectedVertex.X, MostRecentlySelectedVertex.Y); oEdge.p1 = v.Index; } if (oEdge.p2 == MostRecentlySelectedVertex.Index) { Vertex v = NewVertex(MostRecentlySelectedVertex.X, MostRecentlySelectedVertex.Y); oEdge.p2 = v.Index; } } return(eOperationStatus.OK); }
public int RemoveEdgeIf(EdgePredicate <TVertex, TEdge> predicate) { var edges = new EdgeList <TVertex, TEdge>(); foreach (var edge in this.Edges) { if (predicate(edge)) { edges.Add(edge); } } foreach (var edge in edges) { this.OnEdgeRemoved(edge); this.vertexEdges[edge.Source].Remove(edge); } this.edgeCount -= edges.Count; return(edges.Count); }
public int RemoveEdgeIf(EdgePredicate <TVertex, TEdge> predicate) { GraphContracts.AssumeNotNull(predicate, "predicate"); EdgeList edges = new EdgeList(); foreach (TEdge edge in this.Edges) { if (predicate(edge)) { edges.Add(edge); } } foreach (TEdge edge in edges) { this.RemoveEdge(edge); } GraphContracts.Assert(this.edgeCount >= 0); return(edges.Count); }
public OverlayOp(Geometry g0, Geometry g1) : base(g0, g1) { if (g0 == null) { throw new ArgumentNullException("g0"); } if (g1 == null) { throw new ArgumentNullException("g1"); } ptLocator = new PointLocator(); edgeList = new EdgeList(); resultPolyList = new GeometryList(); resultLineList = new GeometryList(); resultPointList = new GeometryList(); graph = new PlanarGraph(new OverlayNodeFactory()); // Use factory of primary geometry. // Note that this does NOT handle mixed-precision arguments // where the second arg has greater precision than the first. geomFact = g0.Factory; }
/// <summary> /// Calculates shortest paths between all vertices in the specified graph. /// </summary> /// <param name="graph">The graph on which shortest paths will be calculated.</param> /// <returns>A graph that's updated with the calculated shortest paths.</returns> private void CalculateShortestPaths() { VertexList <Vertex> unvisited = (_graph != null) ? _graph.GetVertices() : null; if (unvisited != null && unvisited.Count > 0) { VertexList <Vertex> visited = new VertexList <Vertex>(); Vertex currentVertex = unvisited[0]; currentVertex.Distance = 0; while (unvisited.Count > 0) { visited.Add(currentVertex); unvisited.Remove(currentVertex); EdgeList <Vertex> neighbors = _graph.GetNeighbors(currentVertex); foreach (Edge <Vertex> neighbor in neighbors) { Vertex neighborVertex = neighbor.Destination; if (visited.Contains(neighborVertex)) { continue; } else { int distance = currentVertex.Distance + neighbor.Weight; if (distance < neighborVertex.Distance) { neighborVertex.Distance = distance; neighborVertex.Previous = currentVertex; } } } currentVertex = GetShortestVertex(currentVertex, unvisited); } } _calculated = true; }
/// <summary> /// insert new edge to the list /// </summary> public void Insert(Edge e) { if (EdgeList.Count == 0) { EdgeList.Add(e); } else if (EdgeList [EdgeList.Count - 1].CompareTo(e) <= 0) { EdgeList.Add(e); } else if (EdgeList [0].CompareTo(e) >= 0) { EdgeList.Insert(0, e); } else { int index = EdgeList.BinarySearch(e); if (index < 0) { index = ~index; } EdgeList.Insert(index, e); } }
public bool TryGetPath( TVertex source, TVertex target, out IEnumerable <TEdge> path) { Contract.Requires(source != null); Contract.Requires(target != null); if (source.Equals(target)) { path = null; return(false); } #if DEBUG && !SILVERLIGHT var set = new HashSet <TVertex>(); set.Add(source); set.Add(target); #endif var edges = new EdgeList <TVertex, TEdge>(); var todo = new Stack <SEquatableEdge <TVertex> >(); todo.Push(new SEquatableEdge <TVertex>(source, target)); while (todo.Count > 0) { var current = todo.Pop(); Contract.Assert(!current.Source.Equals(current.Target)); VertexData data; if (this.data.TryGetValue(current, out data)) { TEdge edge; if (data.TryGetEdge(out edge)) { edges.Add(edge); } else { TVertex intermediate; if (data.TryGetPredecessor(out intermediate)) { #if DEBUG && !SILVERLIGHT Contract.Assert(set.Add(intermediate)); #endif todo.Push(new SEquatableEdge <TVertex>(intermediate, current.Target)); todo.Push(new SEquatableEdge <TVertex>(current.Source, intermediate)); } else { Contract.Assert(false); path = null; return(false); } } } else { // no path found path = null; return(false); } } Contract.Assert(todo.Count == 0); Contract.Assert(edges.Count > 0); path = edges.ToArray(); return(true); }
public eOperationStatus DeleteCurrentEdge() { // delete the most recently selected edge, Edge oEdgeToDelete = null; if (MostRecentlySelectedEdge == null) { return(eOperationStatus.NoEdgeSelected); } int IndexOfEdgeToDelete = -1; for (int i = 0; i < EdgeList.Count; i++) { oEdgeToDelete = EdgeList.GetFrom(i); if (oEdgeToDelete == MostRecentlySelectedEdge) { IndexOfEdgeToDelete = i; break; } } if (IndexOfEdgeToDelete == -1) { return(eOperationStatus.NoEdgeSelected); } /* * When deleting an edge we have to account for the vertices. Each of the vertices may be shared or not. * If a vertex isn't shared we delete it as well */ int p1ReferenceCount = 0; int p2ReferenceCount = 0; for (int i = 0; i < EdgeList.Count; i++) { Edge e = EdgeList.GetFrom(i); // Note that this will include the edge we are deleting. that's fine, we account for that if (e.p1 == oEdgeToDelete.p1) { p1ReferenceCount++; } if (e.p2 == oEdgeToDelete.p1) { p1ReferenceCount++; } if (e.p1 == oEdgeToDelete.p2) { p2ReferenceCount++; } if (e.p2 == oEdgeToDelete.p2) { p2ReferenceCount++; } } /* * If either of the reference counts are 1 that means that only the edge to be deleted contained it, * and we can delete that vertex */ if (p1ReferenceCount == 1) { for (int i = 0; i < VertexList.Count; i++) { Vertex v = VertexList.GetFrom(i); if (v.Index == oEdgeToDelete.p1) { VertexList.RemoveAt(i); break; } } } if (p2ReferenceCount == 1) { for (int i = 0; i < VertexList.Count; i++) { Vertex v = VertexList.GetFrom(i); if (v.Index == oEdgeToDelete.p2) { VertexList.RemoveAt(i); break; } } } // Now delete the edge EdgeList.RemoveAt(IndexOfEdgeToDelete); // clear the most recently selected edge and vertex, in case it was on this edge MostRecentlySelectedEdge = null; MostRecentlySelectedVertex = null; CurrentlySelectedEdge = null; CurrentlySelectedVertex = null; return(eOperationStatus.OK); }
protected override string BuildStringSTEP(ReleaseVersion release) { return(base.BuildStringSTEP(release) + ",(#" + string.Join(",#", EdgeList.Select(x => x.StepId.ToString())) + ")"); }
bool Check() { int FC = FaceList.Count; int KC = EdgeCurveList.Count; int EC = VertexList.Count; int CT = EC - KC + FC - 2; // Euler if (CT == 0) { int ED = EdgeList.Count; if (ED == 2 * KC) { /* Ok*/ } else {// return false; } } else { // return false; for (int i = 0; i < EdgeCurveList.Count; i++) { Edge[] Edges = EdgeCurveList[i].Tag as Edge[]; if (Edges != null) { if ((Edges[0] == null) || (Edges[1] == null)) { } else { if (EdgeList.IndexOf(Edges[0]) == -1) { } if (EdgeList.IndexOf(Edges[1]) == -1) { } } } if (EdgeCurveList[i].A.dist(EdgeCurveList[i].B) < 0.0001) { } } } if (!CheckEdges()) { } ; // return false; for (int i = 0; i < FaceList.Count; i++) { Face F = FaceList[i]; for (int j = 0; j < F.Bounds.Count; j++) { EdgeLoop EL = F.Bounds[j]; for (int k = 0; k < EL.Count; k++) { Edge E = EL[k]; int OutLoop = -1; if ((E.SameSense) && ( (E.EdgeCurve.A.dist(E.EdgeStart.Value) > 0.0001) || (E.EdgeCurve.B.dist(E.EdgeEnd.Value) > 0.0001))) { return(false); } if ((!E.SameSense) && ( (E.EdgeCurve.B.dist(E.EdgeStart.Value) > 0.0001) || (E.EdgeCurve.A.dist(E.EdgeEnd.Value) > 0.0001))) { return(false); } Face FF = null; if (E.EdgeCurve.Neighbors[0] == null) { return(false); } if (E.EdgeCurve is Line3D) { Line3D Curve3d = E.EdgeCurve as Line3D; xyz _A = F.Surface.Base.Relativ(Curve3d.A); xyz _B = F.Surface.Base.Relativ(Curve3d.B); if (System.Math.Abs(_A.z) > 0.001) { return(false); } double g = F.Surface.Base.BaseX.length(); double h = F.Surface.Base.BaseY.length(); xyz AA = F.Surface.Base.Absolut(_A); xyz BB = F.Surface.Base.Absolut(_B); if (AA.dist(Curve3d.A) > 0.001) { return(false); } } if (E.EdgeCurve.Neighbors[0] == E.EdgeCurve.Neighbors[1]) { return(false); } if (!FaceList.Contains(E.EdgeCurve.Neighbors[0])) { } if (!FaceList.Contains(E.EdgeCurve.Neighbors[1])) { return(false); } double d = Face.GetDualEdge(F, j, k + 0.01, ref OutLoop, ref FF); } } } return(true); }
/// <summary> /// activates a <b>CatMull</b> division. /// </summary> public void CatMull() { for (int i = 0; i < VertexList.Count; i++) { Vertex3d V = VertexList[i]; V.Tag = new SubDivisionDescriptor(); } for (int i = 0; i < FaceList.Count; i++) { Face F = FaceList[i]; F.DrawRelativToSurfaceBase = false; int n = 0; for (int j = 0; j < F.Bounds.Count; j++) { xyz subDivCenter = new xyz(0, 0, 0); EdgeLoop EL = F.Bounds[j]; for (int k = 0; k < EL.Count; k++) { n++; Edge E = EL[k]; subDivCenter = subDivCenter + E.EdgeStart.Value; } F.Tag = subDivCenter * (1f / (float)EL.Count); } } for (int i = 0; i < FaceList.Count; i++) { Face F = FaceList[i]; int n = 0; for (int j = 0; j < F.Bounds.Count; j++) { EdgeLoop EL = F.Bounds[j]; for (int k = 0; k < EL.Count; k++) { n++; Edge E = EL[k]; Face Neighbor = null; if (E.SameSense) { Neighbor = E.EdgeCurve.Neighbors[1] as Face; } else { Neighbor = E.EdgeCurve.Neighbors[0] as Face; } E.Tag = ((xyz)(E.EdgeCurve.Neighbors[1] as Face).Tag + (xyz)(E.EdgeCurve.Neighbors[0] as Face).Tag + E.EdgeStart.Value + E.EdgeEnd.Value) * (1f / 4f); // Mittelwert der Facepunkte und der Anfangs und Endpunkte im Tag speichern // E.Tag = ((xyz)F.Tag + (xyz)Neighbor.Tag + E.EdgeStart.Value + E.EdgeEnd.Value) * 0.25; // // den Descriptor im Vertex E.EdgeEnd.Tag updaten SubDivisionDescriptor SDD = E.EdgeEnd.Tag as SubDivisionDescriptor; SDD.Edges.Add(E); SDD.Faces.Add(F); } } } // Update Vertixlist xyz Q = new xyz(0, 0, 0); xyz R = new xyz(0, 0, 0); for (int i = 0; i < VertexList.Count; i++) { Vertex3d V = VertexList[i]; SubDivisionDescriptor SDV = V.Tag as SubDivisionDescriptor; int n = SDV.Faces.Count; if (n == 0) { return; } Q = new xyz(0, 0, 0); R = new xyz(0, 0, 0); for (int j = 0; j < SDV.Faces.Count; j++) { Q = (xyz)SDV.Faces[j].Tag + Q; } Q = Q * (1f / (float)SDV.Faces.Count); for (int j = 0; j < SDV.Edges.Count; j++) { R = (xyz)SDV.Edges[j].Tag + R; } R = R * (1f / (float)SDV.Edges.Count); xyz S = V.Value; V.Value = (Q + R * 2 + S * (n - 3)) * (1f / (float)n); } // Kanten Ersetzen for (int i = 0; i < FaceList.Count; i++) { Face F = FaceList[i]; for (int j = 0; j < F.Bounds.Count; j++) { EdgeLoop EL = F.Bounds[j]; for (int k = 0; k < EL.Count; k++) { Edge E = EL[k]; if (E.SameSense) { E.EdgeCurve.A = E.EdgeStart.Value; E.EdgeCurve.B = E.EdgeEnd.Value; } } } } // Kanten Ersetzen for (int i = 0; i < FaceList.Count; i++) { Face F = FaceList[i]; for (int j = 0; j < F.Bounds.Count; j++) { EdgeLoop EL = F.Bounds[j]; for (int k = 0; k < EL.Count; k++) { Edge E = EL[k]; if (E.SameSense) { Vertex3d V = new Vertex3d((xyz)E.Tag); insertVertexToSameSenseEdge(F, j, k, V); k++; } } } } FaceList Temp = new FaceList(); for (int i = 0; i < FaceList.Count; i++) { Face F = FaceList[i]; for (int x = 0; x < F.Bounds.Count; x++) { EdgeLoop EL = F.Bounds[x]; Edge E2 = null; Vertex3d V1 = new Vertex3d(); V1.Value = (xyz)F.Tag; VertexList.Add(V1); Vertex3d V4 = null; Vertex3d V2 = null; int startIndex = 1; if (EL[0].EdgeStart.Tag == null) // StartPunkt ist eingefügt { startIndex = 0; } int id = startIndex; int counter = 0; Edge First = null; Edge Last = null; while (id >= 0) { counter++; EdgeLoop newEl = new EdgeLoop(); V2 = EL[id].EdgeStart; if (id + 1 < EL.Count) { V4 = EL[id + 1].EdgeEnd; } else { V4 = EL[0].EdgeEnd; } Face newF = new Face(); newF.Parent = F.Parent; Temp.Add(newF); EdgeLoop ELF = new EdgeLoop(); List <xyz> Pt = new List <xyz>(); newF.Surface = new PlaneSurface(V1.Value, V2.Value, V4.Value); // newF.Surface = new PlaneSurface(V1.Value, V2.Value, V4.Value); Edge EA = new Edge(); ELF.Add(EA); EdgeList.Add(EA); EA.EdgeStart = V1; EA.EdgeEnd = V2; if (Last == null) { EA.EdgeCurve = new Line3D(V1.Value, V2.Value); Pt.Add(V1.Value); EdgeCurveList.Add(EA.EdgeCurve); EA.EdgeCurve.Neighbors = new Face[2]; EA.SameSense = true; EA.EdgeCurve.Neighbors[0] = newF; if (id == startIndex) { First = EA; } } else { EA.EdgeStart = Last.EdgeEnd; Pt.Add(EA.EdgeStart.Value); EA.EdgeEnd = Last.EdgeStart; EA.EdgeCurve = Last.EdgeCurve; EA.EdgeCurve.Neighbors[1] = newF; EA.SameSense = false; } newF.Bounds.Add(ELF); E2 = EL[id]; if (E2.SameSense) { E2.EdgeCurve.Neighbors[0] = newF; } else { E2.EdgeCurve.Neighbors[1] = newF; } Pt.Add(E2.EdgeStart.Value); ELF.Add(E2); Edge E3 = null; if (id + 1 < EL.Count) { E3 = EL[id + 1]; } else { E3 = EL[0]; } Pt.Add(E3.EdgeStart.Value); if (E3.SameSense) { E3.EdgeCurve.Neighbors[0] = newF; } else { E3.EdgeCurve.Neighbors[1] = newF; } ELF.Add(E3); Edge EE = new Edge(); EdgeList.Add(EE); EE.EdgeStart = V4; EE.EdgeEnd = V1; ELF.Add(EE); Pt.Add(V4.Value); if (counter < 4) { EE.EdgeCurve = new Line3D(EE.EdgeStart.Value, EE.EdgeEnd.Value); EdgeCurveList.Add(EE.EdgeCurve); EE.EdgeCurve.Neighbors = new Face[2]; EE.EdgeCurve.Neighbors[0] = newF; EE.SameSense = true; } else { EE.EdgeCurve = First.EdgeCurve; EE.EdgeStart = First.EdgeEnd; EE.EdgeEnd = First.EdgeStart; EE.EdgeCurve.Neighbors[1] = newF; EE.SameSense = false; } Last = EE; id++; id++; // newF.Surface = new SmoothPlane(Pt[0],Pt[1],Pt[2],Pt[3], new xyz(1, 0, 0), new xyz(1, 0, 0), new xyz(1, 0, 0), new xyz(1, 0, 0)); // newF.Surface = new SmoothPlane(Pt[0], Pt[1], Pt[2], Pt[3], (Pt[0] - Pt[1]) & (Pt[0] - Pt[3]), (Pt[1] - Pt[0]) & (Pt[1] - Pt[2]), (Pt[2] - Pt[1]) & (Pt[3] - Pt[1]), (Pt[0] - Pt[3]) & (Pt[2] - Pt[3])); if (id + 1 > EL.Count) { break; } // newF.Surface = new PlaneSurface(V1.Value, V2.Value, V4.Value); } } } FaceList = Temp; for (int i = 0; i < FaceList.Count; i++) { Face F = FaceList[i]; F.Surface.BoundedCurves = new Loca(); List <xyz> P = new List <xyz>(); xyz P1 = new xyz(0, 0, 0); xyz P2 = new xyz(0, 0, 0); xyz P3 = new xyz(0, 0, 0); xyz P4 = new xyz(0, 0, 0); for (int k = 0; k < F.Bounds.Count; k++) { CurveArray CA = new CurveArray(); F.Surface.BoundedCurves.Add(CA); for (int l = 0; l < F.Bounds[k].Count; l++) { Edge E = F.Bounds[k][l]; CA.Add(new Line(F.Surface.ProjectPoint(E.EdgeStart.Value), F.Surface.ProjectPoint(E.EdgeEnd.Value))); if (l < 4) { P.Add(E.EdgeStart.Value); } } if (i == 3) { List <Edge> L1 = new List <Edge>(); for (int j = 0; j < 3; j++) { for (int m = 0; m < FaceList[j].Bounds.Count; m++) { xyz A = new xyz(0, 0, 0); for (int h = 0; h < FaceList[j].Bounds[m].Count; h++) { Edge E = FaceList[j].Bounds[m][h]; L1.Add(E); } } } for (int h = 0; h < L1.Count; h++) { for (int m = 0; m < L1.Count; m++) { if ((L1[h].EdgeStart.Value.dist(L1[m].EdgeStart.Value) < 0.001) && (h != m)) { } } } } } xyz n = ((P[2] - P[0]) & (P[1] - P[0])); xyz m1 = ((P[3] - P[0]) & (P[2] - P[0])); Loca L = F.Surface.BoundedCurves; if (i / 2 * 2 == i) { F.Surface = new SmoothPlane(P[0], P[1], P[2], P[3], n); } else { F.Surface = new SmoothPlane(P[0], P[1], P[2], P[3], m1); } F.Surface.BoundedCurves = L; // (P[1] - P[0]) & (P[1] - P[2]), (P[2] - P[1]) & (P[2] - P[3]), (P[3] - P[0]) & (P[3] - P[2])); F.DrawRelativToSurfaceBase = false; } }
private static List<List<string>> GetStraight(MatrixWithHeaders matrixWithHeaders) { Dictionary<object, IEnumerable<IEdge<object>>> vertexEdges = new Dictionary<object, IEnumerable<IEdge<object>>>(); BidirectionalGraph<object, IEdge<object>> graph = Graph.AdjacentyMatrixToGraph(matrixWithHeaders) as BidirectionalGraph<object, IEdge<object>>; List<List<string>> straight = new List<List<string>>(); EdgeList<string, Edge<string>> candidates = new EdgeList<string, Edge<string>>(); var matrix = matrixWithHeaders.Matrix; var headers = matrixWithHeaders.Headers; var vertexes = graph.Vertices; foreach (var item in vertexes) { var inEdges = graph.InEdges(item); var outEdges = graph.OutEdges(item); if (inEdges.Count() == 1 && outEdges.Count() == 1) { candidates.Add(new Edge<string>(inEdges.ElementAt(0).Source.ToString(), inEdges.ElementAt(0).Target.ToString())); candidates.Add(new Edge<string>(outEdges.ElementAt(0).Source.ToString(), outEdges.ElementAt(0).Target.ToString())); } } for (int x = candidates.Count() - 1; x > 0; x--) { if (candidates[x - 1].Source == candidates[x].Source && candidates[x - 1].Target == candidates[x].Target) { candidates.RemoveAt(x); } } for (int x = 0; x < candidates.Count; x++) { for (int y = x + 1; y < candidates.Count; y++) { IEdge<object> edge = null; graph.TryGetEdge(candidates[x].Source, candidates[y].Target, out edge); if (edge != null) { var existItems = candidates.Select(z => z.Source == edge.Source.ToString() && z.Target == edge.Target.ToString()).ToList(); bool exist = false; foreach (var item in existItems) { exist = exist || item; } if (exist == false) { List<string> tempList = new List<string>(); for (int z = x; z <= y; z++) { if (tempList.Contains(candidates[z].Source) == false) { tempList.Add(candidates[z].Source); } if (tempList.Contains(candidates[z].Target) == false) { tempList.Add(candidates[z].Target); } } straight.Add(tempList); } } } } return straight; }
public eOperationStatus DeleteSelectedVertex() { if (MostRecentlySelectedLayer == null) { return(eOperationStatus.NoLayerSelected); } // If there is not a most recently selected handle return eOperationStatus sts = MostRecentlySelectedLayer.DeleteSelectedVertex(); if (sts != eOperationStatus.OK) { return(sts); } #if false if (MostRecentlySelectedVertex == null) { return(eOperationStatus.NoVertexSelected); } /* * This vertex must have exactly two different edges coming into it */ int ReferenceCount = 0; List <Edge> ConnectingEdgeList = new List <Edge>(); for (int i = 0; i < EdgeList.Count; i++) { Edge oEdge = EdgeList.GetFrom(i); if (oEdge.p1 == MostRecentlySelectedVertex.Index) { ReferenceCount++; ConnectingEdgeList.Add(oEdge); } if (oEdge.p2 == MostRecentlySelectedVertex.Index) { ReferenceCount++; ConnectingEdgeList.Add(oEdge); } } if (ReferenceCount != 2) { return(eOperationStatus.MustBeTwoConnectingEdgesForOperation); } // Get the from and to points of the remade edge int NewP1 = -1; int NewP2 = -1; Edge oEdge0 = ConnectingEdgeList.GetFrom(0); if (oEdge0.p1 == MostRecentlySelectedVertex.Index) { NewP1 = oEdge0.p2; } else { NewP1 = oEdge0.p1; } Edge oEdge1 = ConnectingEdgeList.GetFrom(1); if (oEdge1.p2 == MostRecentlySelectedVertex.Index) { NewP2 = oEdge1.p1; } else { NewP2 = oEdge1.p2; } // Replace the p1 and p2 in the 0th edge and delete the 1th edge. We know that the current handle // will be redundant so we can delete it. oEdge0.p1 = NewP1; oEdge0.p2 = NewP2; // delete the current handle, it the one we're removing for (int i = 0; i < VertexList.Count; i++) { Vertex v = VertexList.GetFrom(i); if (v.Index == MostRecentlySelectedVertex.Index) { VertexList.RemoveAt(i); break; } } // Delete the 1th edge. for (int i = 0; i < EdgeList.Count; i++) { Edge e = EdgeList.GetFrom(i); if (e == oEdge1) { EdgeList.RemoveAt(i); break; } } #endif // trigger redraw DrawShapes(); return(eOperationStatus.OK); }
public void Clear() { VertexList.Clear(); EdgeSolution.Clear(); EdgeList.Clear(); }
private void FortunesAlgorithm() { Site newSite, bottomSite, topSite, tempSite; Vertex v, vertex; Vector2f newIntStar = Vector2f.zero; LR leftRight; Halfedge lbnd, rbnd, llbnd, rrbnd, bisector; Edge edge; Rectf dataBounds = sites.GetSitesBounds(); int sqrtSitesNb = (int)Math.Sqrt(sites.Count() + 4); HalfedgePriorityQueue heap = new HalfedgePriorityQueue(dataBounds.y, dataBounds.height, sqrtSitesNb); EdgeList edgeList = new EdgeList(dataBounds.x, dataBounds.width, sqrtSitesNb); List <Halfedge> halfEdges = new List <Halfedge>(); List <Vertex> vertices = new List <Vertex>(); Site bottomMostSite = sites.Next(); newSite = sites.Next(); while (true) { if (!heap.Empty()) { newIntStar = heap.Min(); } if (newSite != null && (heap.Empty() || CompareByYThenX(newSite, newIntStar) < 0)) { // New site is smallest //Debug.Log("smallest: new site " + newSite); // Step 8: lbnd = edgeList.EdgeListLeftNeighbor(newSite.Coord); // The halfedge just to the left of newSite //UnityEngine.Debug.Log("lbnd: " + lbnd); rbnd = lbnd.edgeListRightNeighbor; // The halfedge just to the right //UnityEngine.Debug.Log("rbnd: " + rbnd); bottomSite = RightRegion(lbnd, bottomMostSite); // This is the same as leftRegion(rbnd) // This Site determines the region containing the new site //UnityEngine.Debug.Log("new Site is in region of existing site: " + bottomSite); // Step 9 edge = Edge.CreateBisectingEdge(bottomSite, newSite); //UnityEngine.Debug.Log("new edge: " + edge); edges.Add(edge); bisector = Halfedge.Create(edge, LR.LEFT); halfEdges.Add(bisector); // Inserting two halfedges into edgelist constitutes Step 10: // Insert bisector to the right of lbnd: edgeList.Insert(lbnd, bisector); // First half of Step 11: if ((vertex = Vertex.Intersect(lbnd, bisector)) != null) { vertices.Add(vertex); heap.Remove(lbnd); lbnd.vertex = vertex; lbnd.ystar = vertex.y + newSite.Dist(vertex); heap.Insert(lbnd); } lbnd = bisector; bisector = Halfedge.Create(edge, LR.RIGHT); halfEdges.Add(bisector); // Second halfedge for Step 10:: // Insert bisector to the right of lbnd: edgeList.Insert(lbnd, bisector); // Second half of Step 11: if ((vertex = Vertex.Intersect(bisector, rbnd)) != null) { vertices.Add(vertex); bisector.vertex = vertex; bisector.ystar = vertex.y + newSite.Dist(vertex); heap.Insert(bisector); } newSite = sites.Next(); } else if (!heap.Empty()) { // Intersection is smallest lbnd = heap.ExtractMin(); llbnd = lbnd.edgeListLeftNeighbor; rbnd = lbnd.edgeListRightNeighbor; rrbnd = rbnd.edgeListRightNeighbor; bottomSite = LeftRegion(lbnd, bottomMostSite); topSite = RightRegion(rbnd, bottomMostSite); // These three sites define a Delaunay triangle // (not actually using these for anything...) // triangles.Add(new Triangle(bottomSite, topSite, RightRegion(lbnd, bottomMostSite))); v = lbnd.vertex; v.SetIndex(); lbnd.edge.SetVertex(lbnd.leftRight, v); rbnd.edge.SetVertex(rbnd.leftRight, v); edgeList.Remove(lbnd); heap.Remove(rbnd); edgeList.Remove(rbnd); leftRight = LR.LEFT; if (bottomSite.y > topSite.y) { tempSite = bottomSite; bottomSite = topSite; topSite = tempSite; leftRight = LR.RIGHT; } edge = Edge.CreateBisectingEdge(bottomSite, topSite); edges.Add(edge); bisector = Halfedge.Create(edge, leftRight); halfEdges.Add(bisector); edgeList.Insert(llbnd, bisector); edge.SetVertex(LR.Other(leftRight), v); if ((vertex = Vertex.Intersect(llbnd, bisector)) != null) { vertices.Add(vertex); heap.Remove(llbnd); llbnd.vertex = vertex; llbnd.ystar = vertex.y + bottomSite.Dist(vertex); heap.Insert(llbnd); } if ((vertex = Vertex.Intersect(bisector, rrbnd)) != null) { vertices.Add(vertex); bisector.vertex = vertex; bisector.ystar = vertex.y + bottomSite.Dist(vertex); heap.Insert(bisector); } } else { break; } } // Heap should be empty now heap.Dispose(); edgeList.Dispose(); foreach (Halfedge halfedge in halfEdges) { halfedge.ReallyDispose(); } halfEdges.Clear(); // we need the vertices to clip the edges foreach (Edge e in edges) { e.ClipVertices(plotBounds); } // But we don't actually ever use them again! foreach (Vertex ve in vertices) { ve.Dispose(); } vertices.Clear(); }
private void fortunesAlgorithm() { Site newSite, bottomSite, topSite, tempSite; Vertex v, vertex; Vector2 newintstar; LR leftRight; Halfedge lbnd, rbnd, llbnd, rrbnd, bisector; Edge edge; Rect dataBounds = _sites.getSitesBounds(); int sqrt_nsites = (int)(Mathf.Sqrt(_sites.length + 4)); HalfedgePriorityQueue heap = new HalfedgePriorityQueue(dataBounds.y, dataBounds.height, sqrt_nsites); EdgeList edgeList = new EdgeList(dataBounds.x, dataBounds.width, sqrt_nsites); List<Halfedge> halfEdges = new List<Halfedge> (); List<Vertex> vertices = new List<Vertex>(); Site bottomMostSite = _sites.next(); newSite = _sites.next(); for (;;) { if (heap.empty() == false) { newintstar = heap.min(); } if (newSite != null && (heap.empty() || compareByYThenX(newSite, newintstar) < 0)) { /* new site is smallest */ //trace("smallest: new site " + newSite); // Step 8: lbnd = edgeList.edgelistLeftNeighbor(newSite.Coord); // the Halfedge just to the left of newSite //trace("lbnd: " + lbnd); rbnd = lbnd.edgeListRightNeighbor; // the Halfedge just to the right //trace("rbnd: " + rbnd); bottomSite = rightRegion(lbnd,bottomMostSite); // this is the same as leftRegion(rbnd) // this Site determines the region containing the new site //trace("new Site is in region of existing site: " + bottomSite); // Step 9: edge = Edge.createBisectingEdge(bottomSite, newSite); //trace("new edge: " + edge); _edges.Add(edge); bisector = Halfedge.create(edge, LR.LEFT); halfEdges.Add(bisector); // inserting two Halfedges into edgeList constitutes Step 10: // insert bisector to the right of lbnd: edgeList.insert(lbnd, bisector); // first half of Step 11: if ((vertex = Vertex.intersect(lbnd, bisector)) != null) { vertices.Add(vertex); heap.remove(lbnd); lbnd.vertex = vertex; lbnd.ystar = vertex.y + newSite.dist(vertex); heap.insert(lbnd); } lbnd = bisector; bisector = Halfedge.create(edge, LR.RIGHT); halfEdges.Add(bisector); // second Halfedge for Step 10: // insert bisector to the right of lbnd: edgeList.insert(lbnd, bisector); // second half of Step 11: if ((vertex = Vertex.intersect(bisector, rbnd)) != null) { vertices.Add(vertex); bisector.vertex = vertex; bisector.ystar = vertex.y + newSite.dist(vertex); heap.insert(bisector); } newSite = _sites.next(); } else if (heap.empty() == false) { /* intersection is smallest */ lbnd = heap.extractMin(); llbnd = lbnd.edgeListLeftNeighbor; rbnd = lbnd.edgeListRightNeighbor; rrbnd = rbnd.edgeListRightNeighbor; bottomSite = leftRegion(lbnd,bottomMostSite); topSite = rightRegion(rbnd,bottomMostSite); // these three sites define a Delaunay triangle // (not actually using these for anything...) //_triangles.push(new Triangle(bottomSite, topSite, rightRegion(lbnd))); v = lbnd.vertex; v.setIndex(); lbnd.edge.setVertex(lbnd.leftRight, v); rbnd.edge.setVertex(rbnd.leftRight, v); edgeList.remove(lbnd); heap.remove(rbnd); edgeList.remove(rbnd); leftRight = LR.LEFT; if (bottomSite.y > topSite.y) { tempSite = bottomSite; bottomSite = topSite; topSite = tempSite; leftRight = LR.RIGHT; } edge = Edge.createBisectingEdge(bottomSite, topSite); _edges.Add(edge); bisector = Halfedge.create(edge, leftRight); halfEdges.Add(bisector); edgeList.insert(llbnd, bisector); edge.setVertex(LR.other(leftRight), v); if ((vertex = Vertex.intersect(llbnd, bisector)) != null) { vertices.Add(vertex); heap.remove(llbnd); llbnd.vertex = vertex; llbnd.ystar = vertex.y + bottomSite.dist(vertex); heap.insert(llbnd); } if ((vertex = Vertex.intersect(bisector, rrbnd)) != null) { vertices.Add(vertex); bisector.vertex = vertex; bisector.ystar = vertex.y + bottomSite.dist(vertex); heap.insert(bisector); } } else { break; } } // heap should be empty now heap.dispose(); edgeList.dispose(); // foreach (Halfedge halfEdge in halfEdges) // { // halfEdge.reallyDispose(); // } halfEdges.Clear();// = 0; // we need the vertices to clip the edges foreach (Edge edge1 in _edges) { edge1.clipVertices(_plotBounds); } // but we don't actually ever use them again! // foreach (vertex in vertices) // { // vertex.dispose(); // } vertices.Clear();// = 0; }
/// <summary> /// overrides the <see cref="Solid.Refresh()"/> method. /// </summary> public override void Refresh() { VertexList.Clear(); EdgeList.Clear(); FaceList.Clear(); EdgeCurveList.Clear(); Vertex3d A = new Vertex3d(xyz.Null); Vertex3d B = new Vertex3d(new xyz(Size.x, 0, 0)); Vertex3d C = new Vertex3d(new xyz(Size.x, Size.y, 0)); Vertex3d D = new Vertex3d(new xyz(0, Size.y, 0)); Vertex3d E = new Vertex3d(A.Value + new xyz(0, 0, Size.z)); Vertex3d F = new Vertex3d(B.Value + new xyz(0, 0, Size.z)); Vertex3d G = new Vertex3d(C.Value + new xyz(0, 0, Size.z)); Vertex3d H = new Vertex3d(D.Value + new xyz(0, 0, Size.z)); VertexList.Add(A); VertexList.Add(B); VertexList.Add(C); VertexList.Add(D); VertexList.Add(E); VertexList.Add(F); VertexList.Add(G); VertexList.Add(H); Vertex3dArray_2 Border = new Vertex3dArray_2(); Vertex3dArray VA = new Vertex3dArray(); Border.Add(VA); Face Face = null; VA.Clear(); VA.Add(A); VA.Add(B); VA.Add(C); VA.Add(D); Face = Face.SolidPlane(this, Border); // FaceList.Add(Face); VA.Clear(); VA.Add(A); VA.Add(E); VA.Add(F); VA.Add(B); Face = Face.SolidPlane(this, Border); // FaceList.Add(Face); VA.Clear(); VA.Add(B); VA.Add(F); VA.Add(G); VA.Add(C); Face = Face.SolidPlane(this, Border); // FaceList.Add(Face); VA.Clear(); VA.Add(C); VA.Add(G); VA.Add(H); VA.Add(D); Face = Face.SolidPlane(this, Border); // FaceList.Add(Face); VA.Clear(); VA.Add(D); VA.Add(H); VA.Add(E); VA.Add(A); Face = Face.SolidPlane(this, Border); // FaceList.Add(Face); VA.Clear(); VA.Add(H); VA.Add(G); VA.Add(F); VA.Add(E); Face = Face.SolidPlane(this, Border); //for (int i = 0; i < FaceList.Count; i++) //{ // FaceList[i].DrawRelativToSurfaceBase = false; // FaceList[i].Refresh(); //} }
/// <summary> /// overrides the <see cref="Solid.Refresh"/> method and creates the extruder from the base <see cref="Loxy"/> and the <see cref="Height"/>. /// </summary> public override void Refresh() { if (Polygon.Count == 0) { return; } this.VertexList.Clear(); this.EdgeCurveList.Clear(); this.FaceList.Clear(); List <List <Vertex3d> > DownVertices = new List <List <Vertex3d> >(); List <List <Vertex3d> > UpVertices = new List <List <Vertex3d> >(); List <List <Curve3D> > VertCurves = new List <List <Curve3D> >(); List <List <Curve3D> > DownCurves = new List <List <Curve3D> >(); List <List <Curve3D> > UpCurves = new List <List <Curve3D> >(); List <List <PlaneSurface> > PlaneSurfaces = new List <List <PlaneSurface> >(); for (int i = 0; i < _Polygon.Count; i++) { DownVertices.Add(new List <Vertex3d>()); UpVertices.Add(new List <Vertex3d>()); VertCurves.Add(new List <Curve3D>()); DownCurves.Add(new List <Curve3D>()); UpCurves.Add(new List <Curve3D>()); PlaneSurfaces.Add(new List <PlaneSurface>()); for (int j = 0; j < _Polygon[i].Count; j++) { if (_Polygon[i][0].dist(_Polygon[i][_Polygon[i].Count - 1]) < 0.00001) { _Polygon[i].RemoveAt(_Polygon[i].Count - 1); } } for (int j = 0; j < _Polygon[i].Count; j++) { Vertex3d V = new Vertex3d(new xyz(_Polygon[i][j].x, _Polygon[i][j].y, 0)); VertexList.Add(V); DownVertices[i].Add(V); Curve3D C = null; if (j < _Polygon[i].Count - 1) { C = new Line3D(new xyz(_Polygon[i][j].x, _Polygon[i][j].y, 0), new xyz(_Polygon[i][j + 1].x, _Polygon[i][j + 1].y, 0)); } else { C = new Line3D(new xyz(_Polygon[i][j].x, _Polygon[i][j].y, 0), new xyz(_Polygon[i][0].x, _Polygon[i][0].y, 0)); } DownCurves[i].Add(C); if (!EdgeCurveList.Contains(C)) { this.EdgeCurveList.Add(C); } if (j < _Polygon[i].Count - 1) { C = new Line3D(new xyz(_Polygon[i][j].x, _Polygon[i][j].y, Height), new xyz(_Polygon[i][j + 1].x, _Polygon[i][j + 1].y, Height)); } else { C = new Line3D(new xyz(_Polygon[i][j].x, _Polygon[i][j].y, Height), new xyz(_Polygon[i][0].x, _Polygon[i][0].y, Height)); } UpCurves[i].Add(C); if (!EdgeCurveList.Contains(C)) { EdgeCurveList.Add(C); } V = new Vertex3d(new xyz(_Polygon[i][j].x, _Polygon[i][j].y, Height)); UpVertices[i].Add(V); VertexList.Add(V); C = new Line3D(new xyz(_Polygon[i][j].x, _Polygon[i][j].y, 0), new xyz(_Polygon[i][j].x, _Polygon[i][j].y, Height)); VertCurves[i].Add(C); if (!EdgeCurveList.Contains(C)) { EdgeCurveList.Add(C); } if (j < _Polygon[i].Count - 1) { PlaneSurfaces[i].Add(new PlaneSurface(new xyz(_Polygon[i][j].x, _Polygon[i][j].y, 0), new xyz(_Polygon[i][j + 1].x, _Polygon[i][j + 1].y, 0), new xyz(_Polygon[i][j + 1].x, _Polygon[i][j + 1].y, Height) )); } else { PlaneSurfaces[i].Add(new PlaneSurface(new xyz(_Polygon[i][j].x, _Polygon[i][j].y, 0), new xyz(_Polygon[i][0].x, _Polygon[i][0].y, 0), new xyz(_Polygon[i][0].x, _Polygon[i][0].y, Height) )); } } } for (int i = 0; i < _Polygon.Count; i++) { for (int j = 0; j < _Polygon[i].Count; j++) { Face Face = new Face(); FaceList.Add(Face); Face.Surface = PlaneSurfaces[i][j]; Face.Bounds = new Bounds(); EdgeLoop Loop = new EdgeLoop(); Face.Bounds.Add(Loop); // Von unten nach oben Edge E = new Edge(); EdgeList.Add(E); E.EdgeStart = DownVertices[i][j]; E.EdgeEnd = UpVertices[i][j]; E.EdgeCurve = VertCurves[i][j]; E.SameSense = true; if (j > 0) { VertCurves[i][j].Neighbors[1] = Face; } else { VertCurves[i][0].Neighbors = new Face[2]; VertCurves[i][j].Neighbors[1] = Face; } Loop.Add(E); // Oben E = new Edge(); EdgeList.Add(E); E.SameSense = true; E.EdgeStart = UpVertices[i][j]; if (j < _Polygon[i].Count - 1) { E.EdgeEnd = UpVertices[i][j + 1]; } else { E.EdgeEnd = UpVertices[i][0]; } E.EdgeCurve = UpCurves[i][j]; E.EdgeCurve.Neighbors = new Face[2]; E.EdgeCurve.Neighbors[0] = Face; Loop.Add(E); // Rechts nach unten E = new Edge(); EdgeList.Add(E); int n = j + 1; if (n == _Polygon[i].Count) { n = 0; } E.EdgeStart = UpVertices[i][n]; E.EdgeEnd = DownVertices[i][n]; E.EdgeCurve = VertCurves[i][n]; if (j < _Polygon[i].Count - 1) { E.EdgeCurve.Neighbors = new Face[2]; } E.EdgeCurve.Neighbors[0] = Face; E.SameSense = false; Loop.Add(E); // unten nach links E = new Edge(); EdgeList.Add(E); if (j < _Polygon[i].Count - 1) { E.EdgeStart = DownVertices[i][j + 1]; } else { E.EdgeStart = DownVertices[i][0]; } E.EdgeEnd = DownVertices[i][j]; E.EdgeCurve = DownCurves[i][j]; E.EdgeCurve.Neighbors = new Face[2]; E.EdgeCurve.Neighbors[0] = Face; E.SameSense = false; Loop.Add(E); } } // Boden Face _Face = new Face(); FaceList.Add(_Face); // Face.Surface = PlaneSurfaces[i][j]; _Face.Bounds = new Bounds(); _Face.Surface = new PlaneSurface(DownVertices[0][0].Value, DownVertices[0][2].Value, DownVertices[0][1].Value); for (int i = 0; i < _Polygon.Count; i++) { EdgeLoop Loop = new EdgeLoop(); _Face.Bounds.Add(Loop); for (int j = 0; j < _Polygon[i].Count; j++) { // Von unten nach oben Edge E = new Edge(); EdgeList.Add(E); E.EdgeStart = DownVertices[i][j]; if (j + 1 < _Polygon[i].Count) { E.EdgeEnd = DownVertices[i][j + 1]; } else { E.EdgeEnd = DownVertices[i][0]; } E.EdgeCurve = DownCurves[i][j]; E.SameSense = true; E.EdgeCurve.Neighbors[1] = _Face; Loop.Add(E); } } // Deckel _Face = new Face(); FaceList.Add(_Face); // Face.Surface = PlaneSurfaces[i][j]; _Face.Bounds = new Bounds(); _Face.Surface = new PlaneSurface(UpVertices[0][0].Value, UpVertices[0][1].Value, UpVertices[0][2].Value); for (int i = 0; i < _Polygon.Count; i++) { EdgeLoop Loop = new EdgeLoop(); _Face.Bounds.Add(Loop); for (int j = _Polygon[i].Count - 1; j >= 0; j--) { Edge E = new Edge(); EdgeList.Add(E); E.EdgeEnd = UpVertices[i][j]; if (j + 1 < _Polygon[i].Count) { E.EdgeStart = UpVertices[i][j + 1]; } else { E.EdgeStart = UpVertices[i][0]; } E.EdgeCurve = UpCurves[i][j]; E.SameSense = false; E.EdgeCurve.Neighbors[1] = _Face; Loop.Add(E); } } this.NewParamCurves(); }
public EdgeListIterator(EdgeList list) { }