/// <summary> /// Erstellt ein neues Informationsobjekt für ein 3D-Modell, das eine Kante darstellt. /// [base="pipe1", Angles3.Zero, new Vector3 (10,10,10)] /// </summary> public Pipe(IScreen screen, IGrid grid, Knot knot, Edge edge, Node node1, Node node2) : base(screen: screen) { UniqueKey = edge.ToString (); // Weise Knoten und Kante zu Knot = knot; Edge = edge; Grid = grid; // Berechne die beiden Positionen, zwischen denen die Kante gezeichnet wird PositionFrom = node1; PositionTo = node2; // Kanten sind verschiebbar und auswählbar IsMovable = true; IsSelectable = true; // Berechne die Drehung Rotation += RotationMap [Edge.Direction]; // Aktualisiere die Kategorie Coloring.OnColorChanged += UpdateCategory; IsSingleColored = true; incomplete = true; }
private void btnAddEge_Click(object sender, EventArgs e) { int initVertex = Convert.ToInt32(numInitVertex.Value); int finVertex = Convert.ToInt32(numFinalVertex.Value); string regularExpression = tbRegularExpression.Text; if(regularExpression == "") regularExpression = Convert.ToString(vertices.Find(vertex => vertex.Name == initVertex).EdgesNumber, 2); vertices.Find(vertex => vertex.Name == initVertex).IncreaseNumberOfEdges(); vertices.Find(vertex => vertex.Name == finVertex).IncreaseNumberOfEdges(); Edge newEdge = new Edge(initVertex, finVertex, regularExpression); tbEdges.AppendText(newEdge.ToString() + "\r\n"); edges.Add(newEdge); tbVertices.Clear(); tbRegularExpression.Clear(); foreach(Vertex vertex in vertices) { tbVertices.AppendText(vertex.ToString() + "\r\n"); } }
/// <summary> /// Erstellt ein neues Informationsobjekt für ein 3D-Modell, das einen Kantenübergang darstellt. /// [base="node1", Angles3.Zero, new Vector3 (1,1,1)] /// </summary> public Junction(IScreen screen, IGrid grid, Edge from, Edge to, Node node, int index) : base(screen) { UniqueKey = from.ToString () + to.ToString (); EdgeFrom = from; EdgeTo = to; Node = node; Grid = grid; Index = index; Position = node; incomplete = true; Coloring = new GradientColor (Color.Transparent, Color.Transparent); Coloring.OnColorChanged += UpdateCategory; }
public void RoundEdge(Edge edgeToRound, double radius, double extraDimension = defaultExtraDimension) { if (roundedEdges.ContainsKey(edgeToRound)) { return; } CsgObject newRound = null; double radiusBoxSize = radius + extraDimension; switch (edgeToRound) { case Edge.LeftFront: { double zSize = size.z + 2 * extraDimension; newRound = new Box(radiusBoxSize, radiusBoxSize, zSize); CsgObject frontTopCut = new Cylinder(radius, zSize + extraDimension * 2, Alignment.z); frontTopCut = new Align(frontTopCut, Face.Left | Face.Front, newRound, Face.Left | Face.Front, extraDimension, extraDimension, 0); newRound -= frontTopCut; newRound = new Align(newRound, Face.Left | Face.Front, GetEdgeOffset(Face.Left | Face.Front), -extraDimension, -extraDimension, 0); } break; case Edge.LeftBack: { double zSize = size.z + 2 * extraDimension; newRound = new Box(radiusBoxSize, radiusBoxSize, zSize); CsgObject BackTopCut = new Cylinder(radius, zSize + extraDimension * 2, Alignment.z); BackTopCut = new Align(BackTopCut, Face.Left | Face.Back, newRound, Face.Left | Face.Back, extraDimension, -extraDimension, 0); newRound -= BackTopCut; newRound = new Align(newRound, Face.Left | Face.Back, GetEdgeOffset(Face.Left | Face.Back), -extraDimension, extraDimension, 0); } break; case Edge.LeftTop: { double ySize = size.y + 2 * extraDimension; newRound = new Box(radiusBoxSize, ySize, radiusBoxSize); CsgObject frontTopCut = new Cylinder(radius, ySize + extraDimension * 2, Alignment.y); frontTopCut = new Align(frontTopCut, Face.Left | Face.Top, newRound, Face.Left | Face.Top, extraDimension, 0, -extraDimension); newRound -= frontTopCut; newRound = new Align(newRound, Face.Left | Face.Top, GetEdgeOffset(Face.Left | Face.Top), -extraDimension, 0, extraDimension); } break; case Edge.LeftBottom: { double ySize = size.y + 2 * extraDimension; newRound = new Box(radiusBoxSize, ySize, radiusBoxSize); CsgObject frontTopCut = new Cylinder(radius, ySize + extraDimension * 2, Alignment.y); frontTopCut = new Align(frontTopCut, Face.Left | Face.Bottom, newRound, Face.Left | Face.Bottom, extraDimension, 0, extraDimension); newRound -= frontTopCut; newRound = new Align(newRound, Face.Left | Face.Bottom, GetEdgeOffset(Face.Left | Face.Bottom), -extraDimension, 0, -extraDimension); } break; case Edge.RightFront: { double zSize = size.z + 2 * extraDimension; newRound = new Box(radiusBoxSize, radiusBoxSize, zSize); CsgObject frontTopCut = new Cylinder(radius, zSize + extraDimension * 2, Alignment.z); frontTopCut = new Align(frontTopCut, Face.Right | Face.Front, newRound, Face.Right | Face.Front, -extraDimension, extraDimension, 0); newRound -= frontTopCut; newRound = new Align(newRound, Face.Right | Face.Front, GetEdgeOffset(Face.Right | Face.Front), extraDimension, -extraDimension, 0); } break; case Edge.RightTop: { double ySize = size.y + 2 * extraDimension; newRound = new Box(radiusBoxSize, ySize, radiusBoxSize); CsgObject frontTopCut = new Cylinder(radius, ySize + extraDimension * 2, Alignment.y); frontTopCut = new Align(frontTopCut, Face.Right | Face.Top, newRound, Face.Right | Face.Top, -extraDimension, 0, -extraDimension); newRound -= frontTopCut; newRound = new Align(newRound, Face.Right | Face.Top, GetEdgeOffset(Face.Right | Face.Top), extraDimension, 0, extraDimension); } break; case Edge.RightBottom: { double ySize = size.y + 2 * extraDimension; newRound = new Box(radiusBoxSize, ySize, radiusBoxSize); CsgObject frontBottomCut = new Cylinder(radius, ySize + extraDimension * 2, Alignment.y); frontBottomCut = new Align(frontBottomCut, Face.Right | Face.Bottom, newRound, Face.Right | Face.Bottom, -extraDimension, 0, extraDimension); newRound -= frontBottomCut; newRound = new Align(newRound, Face.Right | Face.Bottom, GetEdgeOffset(Face.Right | Face.Bottom), extraDimension, 0, -extraDimension); } break; case Edge.RightBack: { double zSize = size.z + 2 * extraDimension; newRound = new Box(radiusBoxSize, radiusBoxSize, zSize); CsgObject BackTopCut = new Cylinder(radius, zSize + extraDimension * 2, Alignment.z); BackTopCut = new Align(BackTopCut, Face.Right | Face.Back, newRound, Face.Right | Face.Back, -extraDimension, -extraDimension, 0); newRound -= BackTopCut; newRound = new Align(newRound, Face.Right | Face.Back, GetEdgeOffset(Face.Right | Face.Back), extraDimension, extraDimension, 0); } break; case Edge.FrontTop: { double xSize = size.x + 2 * extraDimension; newRound = new Box(xSize, radiusBoxSize, radiusBoxSize); CsgObject frontTopCut = new Cylinder(radius, xSize + extraDimension * 2, Alignment.x); frontTopCut = new Align(frontTopCut, Face.Front | Face.Top, newRound, Face.Front | Face.Top, 0, extraDimension, -extraDimension); newRound -= frontTopCut; newRound = new Align(newRound, Face.Front | Face.Top, GetEdgeOffset(Face.Front | Face.Top), 0, -extraDimension, extraDimension); } break; case Edge.FrontBottom: { double xSize = size.x + 2 * extraDimension; newRound = new Box(xSize, radiusBoxSize, radiusBoxSize); CsgObject frontTopCut = new Cylinder(radius, xSize + extraDimension * 2, Alignment.x); frontTopCut = new Align(frontTopCut, Face.Front | Face.Bottom, newRound, Face.Front | Face.Bottom, 0, extraDimension, extraDimension); newRound -= frontTopCut; newRound = new Align(newRound, Face.Front | Face.Bottom, GetEdgeOffset(Face.Front | Face.Bottom), 0, -extraDimension, -extraDimension); } break; case Edge.BackBottom: { double xSize = size.x + 2 * extraDimension; newRound = new Box(xSize, radiusBoxSize, radiusBoxSize); CsgObject backBottomCut = new Cylinder(radius, xSize + extraDimension * 2, Alignment.x); backBottomCut = new Align(backBottomCut, Face.Back | Face.Bottom, newRound, Face.Back | Face.Bottom, 0, -extraDimension, extraDimension); newRound -= backBottomCut; newRound = new Align(newRound, Face.Back | Face.Bottom, GetEdgeOffset(Face.Back | Face.Bottom), 0, extraDimension, -extraDimension); } break; case Edge.BackTop: { double xSize = size.x + 2 * extraDimension; newRound = new Box(xSize, radiusBoxSize, radiusBoxSize); CsgObject backTopCut = new Cylinder(radius, xSize + extraDimension * 2, Alignment.x); backTopCut = new Align(backTopCut, Face.Back | Face.Top, newRound, Face.Back | Face.Top, 0, -extraDimension, -extraDimension); newRound -= backTopCut; newRound = new Align(newRound, Face.Back | Face.Top, GetEdgeOffset(Face.Back | Face.Top), 0, extraDimension, extraDimension); } break; default: throw new NotImplementedException("Don't know how to round " + edgeToRound.ToString()); } if (root is Box) { root = newRound; } else { root += newRound; } roundedEdges.Add(edgeToRound, radius); CheckCornersAndRoundIfNeeded(extraDimension); }
private static int GetBorderEdge(jQueryObject element, Edge edge) { if (Script.IsNullOrUndefined(element)) return 0; string value = element.GetCSS(string.Format("border-{0}-width", edge.ToString().ToLocaleLowerCase())); if (string.IsNullOrEmpty(value)) return 0; if (!value.EndsWith(Px)) return 0; return Int32.Parse(value); }
private void SyncEdge(Edge edge) { // Setup initial conditions. if (inner == null) return; int value = GetValue(edge); // Run the value through the modifier delegate. if (!Script.IsNullOrUndefined(onBeforeSync)) { value = onBeforeSync(edge, value); } // Apply the CSS. inner.CSS(edge.ToString().ToLowerCase(), value + Css.Px); }
public void TestToString() { Edge edge = new Edge(testNode1, testNode2); string expected = string.Format("[Source: {0}, Target: {1}]", this.testNode1, this.testNode2); string actual = edge.ToString(); Assert.AreEqual(expected, actual); }