public void TrainDrawingInfoClassLineVertexesPropertyGetMethodOnlyReturnsDistinctVertexesWhereVertexObjectsAreSharedBetweenLines() { TrainDrawingInfo testObject = new TrainDrawingInfo(); int vertexCount = _rnd.Next(10) + 1; int lineCount = _rnd.Next(10) + vertexCount; VertexInformation[] vertexSource = new VertexInformation[vertexCount]; bool[] vertexesUsed = new bool[vertexCount]; for (int i = 0; i < vertexCount; ++i) { vertexSource[i] = GetVertexInformation(testObject); } for (int i = 0; i < lineCount; ++i) { int firstIndex = _rnd.Next(vertexCount); int secondIndex = _rnd.Next(vertexCount); testObject.Lines.Add(new LineCoordinates(vertexSource[firstIndex], vertexSource[secondIndex])); vertexesUsed[firstIndex] = true; vertexesUsed[secondIndex] = true; } List <VertexInformation> vertexList = vertexSource.Where((v, i) => vertexesUsed[i]).ToList(); List <VertexInformation> testOutput = testObject.LineVertexes.ToList(); Assert.AreEqual(vertexList.Count, testOutput.Count); foreach (VertexInformation vi in testOutput) { Assert.IsTrue(vertexList.Contains(vi)); vertexList.Remove(vi); } }
private void DrawLine( Graphics graphics, Pen trainPen, VertexInformation v0, VertexInformation v1, float leftLimit, float rightLimit, float topLimit, float bottomLimit, List <Tuple <float, float> > controlHandleCoordinates) { float xc0 = CoordinateHelper.Stretch(leftLimit, rightLimit, v0.X); float yc0 = CoordinateHelper.Stretch(topLimit, bottomLimit, 1 - v0.Y); float xc1 = CoordinateHelper.Stretch(leftLimit, rightLimit, v1.X); float yc1 = CoordinateHelper.Stretch(topLimit, bottomLimit, 1 - v1.Y); AddCoordinate(v0, xc0, yc0); AddCoordinate(v1, xc1, yc1); graphics.DrawLine(trainPen, new PointF(xc0, yc0), new PointF(xc1, yc1)); if (controlHandleCoordinates != null && v0.Train == Model.SelectedTrain) { controlHandleCoordinates.Add(new Tuple <float, float>(xc0, yc0)); controlHandleCoordinates.Add(new Tuple <float, float>(xc1, yc1)); } }
internal ServiceVertexInformation(VertexInformation myVertexInformation) { VertexTypeIDField = myVertexInformation.VertexTypeID; VertexIDField = myVertexInformation.VertexID; VertexRevisionIDField = myVertexInformation.VertexRevisionID; VertexEditionNameField = myVertexInformation.VertexEditionName ?? String.Empty; }
public void IEnumerableExtensionsClassEarlierThanMethodReturnsCorrectNumberOfItems() { int listLen = _rnd.Next(100) + 2; List <VertexInformation> rawData = new List <VertexInformation>(listLen); List <VertexInformation> sortedData = new List <VertexInformation>(listLen); for (int i = 0; i < listLen; ++i) { VertexInformation vi = new VertexInformation(new TrainDrawingInfo(), new TimeOfDay(_rnd.Next(86400)), (ArrivalDepartureOptions)(_rnd.Next(3) + 1), _rnd.NextDouble(), _rnd.NextDouble()); rawData.Add(vi); sortedData.Add(vi); } sortedData.Sort(new VertexInformationTimeBasedComparer()); int cutIdx = _rnd.Next(rawData.Count); VertexInformation cut = sortedData[cutIdx]; // If our randomly-selected cut item has the same time value as another in the list, then its index does not actually give us the correct number of items // that will be in the output. cutIdx = sortedData.FindLastIndex(vi => vi.Time == cut.Time); List <VertexInformation> testOutput = rawData.EarlierThan(cut).ToList(); Assert.AreEqual(cutIdx + 1, testOutput.Count); }
public void StoreBinaryProperty( IVertexStore myStore, VertexInformation myVertex, String myName, String myComment, bool myIsUserDefined, Int64 myCreationDate, VertexInformation myDefiningType, SecurityToken mySecurity, Int64 myTransaction) { Store( myStore, myVertex, myComment, myCreationDate, new Dictionary <Tuple <long, long>, VertexInformation> { { _EdgeAttributeDotDefiningType, myDefiningType }, }, null, new Dictionary <long, IComparable> { { (long)AttributeDefinitions.AttributeDotName, myName }, { (long)AttributeDefinitions.AttributeDotIsUserDefined, myIsUserDefined }, }, null, mySecurity, myTransaction); }
public IVertex StoreBasicType( IVertexStore myStore, VertexInformation myVertex, String myName, bool myIsUserDefined, String myComment, Int64 myCreationDate, SecurityToken mySecurity, Int64 myTransaction) { return(Store( myStore, myVertex, myComment, myCreationDate, null, null, new Dictionary <long, IComparable> { { (long)AttributeDefinitions.BaseTypeDotName, myName }, { (long)AttributeDefinitions.BaseTypeDotIsUserDefined, myIsUserDefined }, { (long)AttributeDefinitions.BaseTypeDotIsAbstract, false }, { (long)AttributeDefinitions.BaseTypeDotIsSealed, true }, //{ (long) AttributeDefinitions.Behaviour, null }, }, null, mySecurity, myTransaction)); }
public void LineCoordinatesClassGetIndexOfLongestLineMethodReturnsCorrectValueIfThereAreMultipleNonNullItemsInList() { int count = _rnd.Next(20) + 2; double[] lengths = new double[count]; for (int i = 0; i < count; ++i) { lengths[i] = _rnd.NextDouble() * 120; } int answer = lengths.MaxIndex(); List <LineCoordinates> testInput = new List <LineCoordinates>(count); for (int i = 0; i < count; ++i) { VertexInformation startVertex = new VertexInformation(new TrainDrawingInfo(), _rnd.NextTimeOfDay(), _rnd.NextArrivalDepartureOptions(), _rnd.NextDouble() * 200, _rnd.NextDouble() * 200); double theta = _rnd.NextDouble() * Math.PI * 2; VertexInformation endVertex = new VertexInformation(new TrainDrawingInfo(), _rnd.NextTimeOfDay(), _rnd.NextArrivalDepartureOptions(), startVertex.X + lengths[i] * Math.Cos(theta), startVertex.Y + lengths[i] * Math.Sin(theta)); testInput.Add(new LineCoordinates(startVertex, endVertex)); } int testOutput = LineCoordinates.GetIndexOfLongestLine(testInput); Assert.AreEqual(answer, testOutput); }
public void AddForwardEdgeToNode(LevelKey levelKey, VertexInformation myVertexInformation, EdgeKey forwardDirection, VertexInformation destination, IComparable edgeWeight) { lock (_Content) { if (_Content.ContainsKey(levelKey)) { //the level exists if (_Content[levelKey].Nodes.ContainsKey(myVertexInformation)) { //Node exists _Content[levelKey].Nodes[myVertexInformation].AddForwardEdge(forwardDirection, destination, edgeWeight); } else { //Node does not exist throw new ExpressionGraphInternalException("The node does not exist in this LevelKey."); } } else { //LevelKey does not exist throw new ExpressionGraphInternalException("The LevelKey does not exist in this ExpressionLevel."); } } }
// TODO: Render with effect /// <summary>Compute a bounding sphere for this mesh</summary> public float ComputeBoundingSphere(out Vector3 center) { if (systemMemoryMesh == null) { throw new InvalidOperationException("There is no system memory mesh. Nothing to do here."); } // Get the object declaration int strideSize = VertexInformation.GetFormatSize(systemMemoryMesh.VertexFormat); // Lock the vertex buffer GraphicsStream data = null; try { data = systemMemoryMesh.LockVertexBuffer(LockFlags.ReadOnly); // Now compute the bounding sphere return(Geometry.ComputeBoundingSphere(data, systemMemoryMesh.NumberVertices, systemMemoryMesh.VertexFormat, out center)); } finally { // Make sure to unlock the vertex buffer if (data != null) { systemMemoryMesh.UnlockVertexBuffer(); } } }
public void IEnumerableExtensionsClassLaterThanMethodReturnsCorrectItems() { int listLen = _rnd.Next(100) + 2; List <VertexInformation> rawData = new List <VertexInformation>(listLen); List <VertexInformation> sortedData = new List <VertexInformation>(listLen); for (int i = 0; i < listLen; ++i) { VertexInformation vi = new VertexInformation(new TrainDrawingInfo(), new TimeOfDay(_rnd.Next(86400)), (ArrivalDepartureOptions)(_rnd.Next(3) + 1), _rnd.NextDouble(), _rnd.NextDouble()); rawData.Add(vi); sortedData.Add(vi); } sortedData.Sort(new VertexInformationTimeBasedComparer()); int cutIdx = _rnd.Next(rawData.Count); VertexInformation cut = sortedData[cutIdx]; List <VertexInformation> testOutput = rawData.LaterThan(cut).ToList(); foreach (VertexInformation filtered in testOutput) { Assert.IsTrue(filtered.Time >= cut.Time); Assert.IsTrue(rawData.Contains(filtered)); rawData.Remove(filtered); } foreach (VertexInformation unfiltered in rawData) { Assert.IsTrue(unfiltered.Time < cut.Time); } }
private static void CleanLowerLevel(LevelKey myLevelKey, IExpressionGraph myGraph, IGraphDB myGraphDB, SecurityToken mySecurityToken, Int64 myTransactionToken) { if (myLevelKey.Level > 0) { var previousLevelKey = myLevelKey.GetPredecessorLevel(myGraphDB, mySecurityToken, myTransactionToken); HashSet <VertexInformation> toBeDeletedNodes = new HashSet <VertexInformation>(); foreach (var aLowerDBO in myGraph.Select(previousLevelKey, null, false)) { if (aLowerDBO.HasOutgoingEdge(myLevelKey.LastEdge.AttributeID)) { foreach (var aVertex in aLowerDBO.GetOutgoingEdge(myLevelKey.LastEdge.AttributeID).GetTargetVertices()) { //took the vertextype id of the levelkey, because it is possible that the vertextypeid of the vertex is something inheritated VertexInformation node = new VertexInformation(aVertex.VertexTypeID, aVertex.VertexID); if (!myGraph.GetLevel(myLevelKey.Level).ExpressionLevels[myLevelKey].Nodes.ContainsKey(node)) { //a reference occurred that is not in the higher level --> found a Zoidberg toBeDeletedNodes.Add(node); break; } } } } foreach (var aToBeDeletedNode in toBeDeletedNodes) { myGraph.GetLevel(previousLevelKey.Level).RemoveNode(previousLevelKey, aToBeDeletedNode); } } }
/// <summary> /// /// </summary> /// <param name="myStore"></param> /// <param name="myVertexID"></param> /// <param name="myVertexTypeID"></param> /// <param name="myEdition"></param> /// <param name="myComment"></param> /// <param name="myEdges"></param> /// <param name="myStructuredProperties"></param> /// <param name="myUnstructuredProperties"></param> private IVertex Store( IVertexStore myStore, VertexInformation mySource, String myComment, Int64 myCreationDate, IDictionary <Tuple <Int64, Int64>, VertexInformation> mySingleEdges, IDictionary <Tuple <Int64, Int64>, IEnumerable <VertexInformation> > myHyperEdges, IDictionary <Int64, IComparable> myStructuredProperties, IDictionary <String, Object> myUnstructuredProperties, SecurityToken mySecurity, Int64 myTransaction) { VertexAddDefinition def = new VertexAddDefinition( mySource.VertexID, mySource.VertexTypeID, mySource.VertexEditionName, CreateHyperEdgeDefinitions(myHyperEdges, mySource, myCreationDate), CreateSingleEdgeDefinitions(mySingleEdges, mySource, myCreationDate), null, null, myComment, myCreationDate, myCreationDate, myStructuredProperties, myUnstructuredProperties); return(myStore.AddVertex(mySecurity, myTransaction, def)); }
/// <summary> /// Called once per frame, the call is the entry point for 3d rendering. This /// function sets up render states, clears the viewport, and renders the scene. /// </summary> protected override void Render() { //Clear the backbuffer to a black color device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0); //Begin the scene device.BeginScene(); device.VertexFormat = CustomVertex.PositionNormalColored.Format; // set the vertexbuffer stream source device.SetStreamSource(0, vertexBuffer, 0, VertexInformation.GetFormatSize(CustomVertex.PositionNormalColored.Format)); // set fill mode device.RenderState.FillMode = FillMode.Solid; // set the indices device.Indices = indexBuffer; //use the indices buffer device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, bufferSize * bufferSize, 0, vert_size / 3); // Output statistics drawingFont.DrawText(2, 1, System.Drawing.Color.Yellow, frameStats); drawingFont.DrawText(2, 20, System.Drawing.Color.Yellow, deviceStats); drawingFont.DrawText(2, 40, System.Drawing.Color.White, "Hit 'F' to generate new fractal."); device.EndScene(); }
private IEnumerable <SingleEdgeAddDefinition> CreateSingleEdgeDefinitions( IDictionary <Tuple <long, long>, VertexInformation> mySingleEdges, VertexInformation mySource, long myCreationDate) { if (mySingleEdges == null) { return(null); } List <SingleEdgeAddDefinition> result = new List <SingleEdgeAddDefinition>(mySingleEdges.Count); long edgeID; long edgeTypeID; foreach (var edge in mySingleEdges) { edgeID = edge.Key.Item1; edgeTypeID = edge.Key.Item2; result.Add( new SingleEdgeAddDefinition( edgeID, edgeTypeID, mySource, edge.Value, null, myCreationDate, myCreationDate, null, null)); } return(result); }
public void AddBackwardEdgesToNode(LevelKey myPath, VertexInformation myVertexInformation, EdgeKey backwardDestination, Dictionary <VertexInformation, IComparable> validUUIDs) { lock (_Content) { if (_Content.ContainsKey(myPath)) { //the level exists if (_Content[myPath].Nodes.ContainsKey(myVertexInformation)) { //Node exists _Content[myPath].Nodes[myVertexInformation].AddBackwardEdges(backwardDestination, validUUIDs); } else { //Node does not exist throw new ExpressionGraphInternalException("The node does not exist in this LevelKey."); } } else { //LevelKey does not exist throw new ExpressionGraphInternalException("The LevelKey does not exist in this ExpressionLevel."); } } }
private void DrawEnvironment() { /*if ( RteEnabled ) { * if ( envPolysIndices [0] == null ) { * for ( int i = 0 ; i < 6 ; i++ ) * CreatePoly ( out envPolysIndices [0], out envPolysVertices [0] ); * } * * lastTextureId = -1; * lastLightmapId = -1; * ibNeedSet = true; * bezierIbNeedSet = true; * * d3dDevice.SetTextureStageState ( 0, TextureStageStates.TextureCoordinateIndex, ( int ) TextureCoordinateIndex.PassThru ); * d3dDevice.SetTextureStageState ( 1, TextureStageStates.ColorOperation, ( int ) TextureOperation.Disable ); * d3dDevice.SetTransform ( TransformType.View , fpsCamera.ViewMatrix ); * d3dDevice.SetTransform ( TransformType.Projection, fpsCamera.ProjMatrix ); * * for ( int i = 0 ; i < 1 ; i++ ) { * d3dDevice.SetTransform ( TransformType.World, Matrix.Translation ( fpsCamera.Position + fpsCamera.Look * 5 + fpsCamera.Right * 2 - fpsCamera.Up ) ); * d3dDevice.DrawIndexedPrimitives ( PrimitiveType.TriangleList, 0, 0, 4, 0, 2 ); * } * }*/ if (RteEnabled) { using (Mesh teapot = Mesh.Sphere(d3dDevice, 2.0f, 16, 16)) { lastTextureId = -1; lastLightmapId = -1; d3dDevice.SetTexture(0, cubeTexture); d3dDevice.SetTextureStageState(0, TextureStageStates.TextureCoordinateIndex, ( int )TextureCoordinateIndex.SphereMap); d3dDevice.SetTextureStageState(0, TextureStageStates.ColorOperation, ( int )TextureOperation.SelectArg1); d3dDevice.SetTextureStageState(0, TextureStageStates.ColorArgument1, ( int )TextureArgument.TextureColor); /*d3dDevice.SetTextureStageState ( 0, TextureStageStates.TextureTransform, ( int ) TextureTransform.Count3 ); * d3dDevice.SamplerState [0].AddressU = TextureAddress.Clamp; * d3dDevice.SamplerState [0].AddressV = TextureAddress.Clamp; * d3dDevice.SamplerState [0].AddressW = TextureAddress.Clamp;*/ d3dDevice.SetTextureStageState(1, TextureStageStates.ColorOperation, ( int )TextureOperation.Disable); d3dDevice.Transform.World = Matrix.Scaling(10.0f, 10.0f, 10.0f) * Matrix.Translation(teapotPos); d3dDevice.Transform.View = fpsCamera.ViewMatrix; d3dDevice.Transform.Projection = fpsCamera.ProjMatrix; using (VertexBuffer vb = teapot.VertexBuffer) { using (IndexBuffer ib = teapot.IndexBuffer) { ibNeedSet = true; bezierIbNeedSet = true; d3dDevice.VertexFormat = teapot.VertexFormat; d3dDevice.SetStreamSource(0, vb, 0, VertexInformation.GetFormatSize(teapot.VertexFormat)); d3dDevice.Indices = ib; d3dDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, teapot.NumberVertices, 0, teapot.NumberFaces); //teapot.DrawSubset ( 0 ); } } } } }
public void LineCoordinatesClassConstructorSetsVertex2PropertyToValueOfSecondParameter() { VertexInformation testParam0 = new VertexInformation(new TrainDrawingInfo(), _rnd.NextTimeOfDay(), _rnd.NextArrivalDepartureOptions(), _rnd.NextDouble(), _rnd.NextDouble()); VertexInformation testParam1 = new VertexInformation(new TrainDrawingInfo(), _rnd.NextTimeOfDay(), _rnd.NextArrivalDepartureOptions(), _rnd.NextDouble(), _rnd.NextDouble()); LineCoordinates testOutput = new LineCoordinates(testParam0, testParam1); Assert.AreSame(testParam1, testOutput.Vertex2); }
public void VertexInformationTimeBasedComparerClassCompareMethodReturnsZeroIfFirstParameterHasNullTimePropertyAndSecondParameterIsNull() { VertexInformation testParam = GetVertexInformation(null); VertexInformationTimeBasedComparer testObject = new VertexInformationTimeBasedComparer(); int testOutput = testObject.Compare(testParam, null); Assert.AreEqual(0, testOutput); }
public IVertex StoreIndex( IVertexStore myStore, VertexInformation myVertex, String myName, String myComment, Int64 myCreationDate, String myIndexClass, //bool myIsSingleValue, bool myIsRange, bool myIsVersioned, bool myIsUserDefined, IDictionary <String, object> myOptions, VertexInformation myDefiningVertexType, VertexInformation?mySourceIndex, IList <VertexInformation> myIndexedProperties, SecurityToken mySecurity, Int64 myTransaction) { var props = new Dictionary <long, IComparable> { { (long)AttributeDefinitions.IndexDotName, myName }, { (long)AttributeDefinitions.IndexDotIsUserDefined, myIsUserDefined }, //{ (long) AttributeDefinitions.IndexDotIsSingleValue, myIsSingleValue}, { (long)AttributeDefinitions.IndexDotIsRange, myIsRange }, { (long)AttributeDefinitions.IndexDotIsVersioned, myIsVersioned }, }; var single = new Dictionary <Tuple <long, long>, VertexInformation> { { _EdgeIndexDotDefiningVertexType, myDefiningVertexType } }; if (myIndexClass != null) { props.Add((long)AttributeDefinitions.IndexDotIndexClass, myIndexClass); } if (mySourceIndex.HasValue) { single.Add(_EdgeIndexDotSource, mySourceIndex.Value); } return(Store( myStore, myVertex, myComment, myCreationDate, single, new Dictionary <Tuple <long, long>, IEnumerable <VertexInformation> > { { _EdgeIndexDotIndexedProperties, myIndexedProperties } }, props, myOptions, mySecurity, myTransaction)); }
public void VertexInformationTimeBasedComparerClassCompareMethodReturnsMinusOneIfTimePropertyOfFirstParameterIsBeforeTimePropertyOfSecondParameter() { VertexInformation testParam0 = GetVertexInformation(_rnd.NextTimeOfDayBefore(86398)); // make sure there are a couple of seconds left in the day VertexInformation testParam1 = GetVertexInformation(_rnd.NextTimeOfDayAfter(testParam0.Time)); VertexInformationTimeBasedComparer testObject = new VertexInformationTimeBasedComparer(); int testOutput = testObject.Compare(testParam0, testParam1); Assert.AreEqual(-1, testOutput); }
public void RemoveComplexConnection(LevelKey myLevelKey, VertexInformation myUUID) { lock (_lockObj) { if (_ComplexConnection.ContainsKey(myLevelKey)) { _ComplexConnection[myLevelKey].Remove(myUUID); } } }
public void VertexInformationTimeBasedComparerClassCompareMethodReturnsOneIfTimePropertyOfFirstParameterIsAfterTimePropertyOfSecondParameter() { VertexInformation testParam0 = GetVertexInformation(_rnd.NextTimeOfDayAfter(1)); VertexInformation testParam1 = GetVertexInformation(_rnd.NextTimeOfDayBefore(testParam0.Time)); VertexInformationTimeBasedComparer testObject = new VertexInformationTimeBasedComparer(); int testOutput = testObject.Compare(testParam0, testParam1); Assert.AreEqual(1, testOutput); }
public void VertexInformationTimeBasedComparerClassCompareMethodReturnsMinusOneIfFirstParameterHasNullTimePropertyAndSecondParameterIsNotNullAndHasNonNullTimeProperty() { VertexInformation testParam0 = GetVertexInformation(null); VertexInformation testParam1 = GetVertexInformation(_rnd.NextTimeOfDay()); VertexInformationTimeBasedComparer testObject = new VertexInformationTimeBasedComparer(); int testOutput = testObject.Compare(testParam0, testParam1); Assert.AreEqual(-1, testOutput); }
public void RemoveNode(LevelKey myLevelKey, VertexInformation myToBeRemovedVertex) { lock (_Content) { if (_Content.ContainsKey(myLevelKey)) { _Content[myLevelKey].Nodes.Remove(myToBeRemovedVertex); } } }
public void VertexInformationTimeBasedComparerClassCompareMethodReturnsZeroIfTImePropertyOfFirstParameterIsSameAsTimePropertyOfSecondParameter() { VertexInformation testParam0 = GetVertexInformation(_rnd.NextTimeOfDay()); VertexInformation testParam1 = GetVertexInformation(testParam0.Time); VertexInformationTimeBasedComparer testObject = new VertexInformationTimeBasedComparer(); int testOutput = testObject.Compare(testParam0, testParam1); Assert.AreEqual(0, testOutput); }
public void VertexInformationTimeBasedComparerClassCompareMethodReturnsZeroIfBothParametersHaveNullTimeProperty() { VertexInformation testParam0 = GetVertexInformation(null); VertexInformation testParam1 = GetVertexInformation(null); VertexInformationTimeBasedComparer testObject = new VertexInformationTimeBasedComparer(); int testOutput = testObject.Compare(testParam0, testParam1); Assert.AreEqual(0, testOutput); }
/// <summary> /// /// </summary> /// <param name="myEdges"></param> /// <param name="myVertexID"></param> /// <param name="myVertexTypeID"></param> /// <param name="myCreationDate"></param> /// <returns></returns> private IEnumerable <HyperEdgeAddDefinition> CreateHyperEdgeDefinitions( IDictionary <Tuple <Int64, Int64>, IEnumerable <VertexInformation> > myEdges, VertexInformation mySource, Int64 myCreationDate) { if (myEdges == null) { return(null); } List <HyperEdgeAddDefinition> result = new List <HyperEdgeAddDefinition>(myEdges.Count); long edgeID; long edgeTypeID; foreach (var edge in myEdges) { edgeID = edge.Key.Item1; edgeTypeID = edge.Key.Item2; var singleEdges = (edge.Value == null) ? null : edge.Value.Select((vertexInfo, pos) => new SingleEdgeAddDefinition( edgeID, edgeTypeID, mySource, vertexInfo, null, myCreationDate, myCreationDate, (edge.Value is IList <VertexInformation>) ? new Dictionary <long, IComparable> { { (long)AttributeDefinitions.OrderableEdgeDotOrder, pos }, } : null, null)).ToArray(); result.Add( new HyperEdgeAddDefinition( edgeID, edgeTypeID, mySource, singleEdges, null, myCreationDate, myCreationDate, null, null )); } return(result); }
/// <summary> /// The device exists, but may have just been Reset(). Resources in /// Pool.Default and any other device state that persists during /// rendering should be set here. Render states, matrices, textures, /// etc., that don't change during rendering can be set once here to /// avoid redundant state setting during Render() or FrameMove(). /// </summary> protected override void RestoreDeviceObjects(System.Object sender, System.EventArgs e) { // Restore mesh's local memory objects blendObject.RestoreDeviceObjects(device, null); // Get access to the mesh vertex and index buffers vertexBuffer = blendObject.LocalMesh.VertexBuffer; indexBuffer = blendObject.LocalMesh.IndexBuffer; numVertices = blendObject.LocalMesh.NumberVertices; numFaces = blendObject.LocalMesh.NumberFaces; if (BehaviorFlags.SoftwareVertexProcessing || Caps.VertexShaderVersion.Major >= 1) { // Setup the vertex declaration VertexElement[] decl = VertexInformation.DeclaratorFromFormat(BlendVertex.Format); declaration = new VertexDeclaration(device, decl); // Create vertex shader from a file try { shader = GraphicsUtility.CreateVertexShader(device, "blend.vsh"); } catch { SampleException d3de = new MediaNotFoundException(); HandleSampleException(d3de, ApplicationMessage.ApplicationMustExit); throw d3de; } } // Set miscellaneous render states renderState.ZBufferEnable = true; renderState.Ambient = System.Drawing.Color.FromArgb(0x00404040); // Set the projection matrix float fAspect = device.PresentationParameters.BackBufferWidth / (float)device.PresentationParameters.BackBufferHeight; device.Transform.Projection = Matrix.PerspectiveFovLH((float)Math.PI / 4, fAspect, 1.0f, 10000.0f); // Set the app view matrix for normal viewing Vector3 vEyePt = new Vector3(0.0f, -5.0f, -10.0f); Vector3 vLookatPt = new Vector3(0.0f, 0.0f, 0.0f); Vector3 vUpVec = new Vector3(0.0f, 1.0f, 0.0f); device.Transform.View = Matrix.LookAtLH(vEyePt, vLookatPt, vUpVec); // Create a directional light. (Use yellow light to distinguish from // vertex shader case.) GraphicsUtility.InitLight(device.Lights[0], LightType.Directional, -0.5f, -1.0f, 1.0f); device.Lights[0].Diffuse = System.Drawing.Color.Yellow; device.Lights[0].Commit(); device.Lights[0].Enabled = true; renderState.Lighting = true; }
public void RemoveBackwardEdge(EdgeKey myEdgeKey, VertexInformation myObjectUUID) { lock (_lockObj) { var destEdges = from e in _BackwardEdges where e.Key.VertexTypeID == myEdgeKey.VertexTypeID select e.Key; foreach (var be in destEdges) { _BackwardEdges[be].RemoveWhere(exprEdge => exprEdge.Destination == myObjectUUID); } } }
public void RemoveForwardEdge(EdgeKey myEdgeKey, VertexInformation myObjectUUID) { lock (_lockObj) { if (!_ForwardEdges.ContainsKey(myEdgeKey)) { return; } _ForwardEdges[myEdgeKey].RemoveWhere(exprEdge => exprEdge.Destination == myObjectUUID); } }
/// <summary> /// Creates a new single edge update definition /// </summary> /// <param name="myCommentUpdate">A comment for the graphelemen</param> /// <param name="myUpdatedStructuredProperties">The structured properties</param> /// <param name="myUpdatedUnstructuredProperties">The unstructured properties</param> /// <param name="myUpdatedVector">Defines the single edge that should be updated</param> public SingleEdgeUpdateDefinition( VertexInformation mySourceVertex, VertexInformation myTargetVertex, long myEdgeTypeID, String myCommentUpdate = null, StructuredPropertiesUpdate myUpdatedStructuredProperties = null, UnstructuredPropertiesUpdate myUpdatedUnstructuredProperties = null) : base(myCommentUpdate, myUpdatedStructuredProperties, myUpdatedUnstructuredProperties) { SourceVertex = mySourceVertex; TargetVertex = myTargetVertex; EdgeTypeID = myEdgeTypeID; }
/// <summary> /// Creates a new instance of SingleEdgeDeleteDefinition. /// </summary> /// <param name="mySourceVertex">The vertex where the edge begins.</param> /// <param name="myTargetVertex">The vertex where the edge ends.</param> public SingleEdgeDeleteDefinition(VertexInformation mySourceVertex, VertexInformation myTargetVertex) { SourceVertex = mySourceVertex; TargetVertex = myTargetVertex; }
TryCalculateVertexInformations ( IGraph oGraphClone, BackgroundWorker oBackgroundWorker, out Dictionary<IVertex, VertexInformation> oVertexInformations ) { Debug.Assert(oGraphClone != null); Debug.Assert(oBackgroundWorker != null); AssertValid(); Int32 iCalculationsCompleted = 0; IVertexCollection oVertices = oGraphClone.Vertices; Int32 iVertices = oVertices.Count; oVertexInformations = new Dictionary<IVertex, VertexInformation>(iVertices); foreach (IVertex oVertex in oVertices) { if ( CancellationPending(oBackgroundWorker, iCalculationsCompleted, iVertices, "Calculating vertex areas.") ) { return (false); } VertexDrawingHistory oVertexDrawingHistory; if ( !DrawerBase.TryGetVertexDrawingHistory(oVertex, out oVertexDrawingHistory) ) { Debug.Assert(false); } Geometry oBounds = oVertexDrawingHistory.GetBounds(); WpfGraphicsUtil.FreezeIfFreezable(oBounds); VertexInformation oVertexInformation = new VertexInformation(); oVertexInformation.Bounds = oBounds; oVertexInformation.Area = GetArea(oBounds); oVertexInformations.Add(oVertex, oVertexInformation); iCalculationsCompleted++; } return (true); }