public void Size3D_IsConstructedProperly() { var result = new Size3D(123.45, 456.78, 789.99); TheResultingValue(result) .ShouldBe(123.45, 456.78, 789.99); }
public void Size3D_EqualsObject() { var volume1 = new Size3D(123.45, 456.78, 789.99); var volume2 = new Size3D(123.45, 456.78, 789.99); TheResultingValue(volume1.Equals((Object)volume2)).ShouldBe(true); TheResultingValue(volume1.Equals("This is a test")).ShouldBe(false); }
public void Size3D_OpEquality() { var volume1 = new Size3D(123.45, 456.78, 789.99); var volume2 = new Size3D(123.45, 456.78, 789.99); var volume3 = new Size3D(123.45, 555, 789.99); var volume4 = new Size3D(222, 456.78, 789.99); var volume5 = new Size3D(123.45, 456.78, 999); TheResultingValue(volume1 == volume2).ShouldBe(true); TheResultingValue(volume1 == volume3).ShouldBe(false); TheResultingValue(volume1 == volume4).ShouldBe(false); TheResultingValue(volume1 == volume5).ShouldBe(false); }
public VolumeHeaderData(IList<IDicomAttributeProvider> sourceSops, Size3D arrayDimensions, Vector3D voxelSpacing, Vector3D volumePositionPatient, Matrix3D volumeOrientationPatient, int bitsAllocated, int bitsStored, bool isSigned, int paddingValue, double rescaleSlope, double rescaleIntercept, RescaleUnits rescaleUnits, string laterality = null) { Platform.CheckForNullReference(sourceSops, "sourceSops"); Platform.CheckTrue(sourceSops.Count > 0, "At least one sourceSop is required"); Platform.CheckForNullReference(arrayDimensions, "arrayDimensions"); Platform.CheckForNullReference(voxelSpacing, "voxelSpacing"); Platform.CheckForNullReference(volumePositionPatient, "originPatient"); Platform.CheckForNullReference(volumeOrientationPatient, "orientationPatient"); _volumeOrientationPatient = volumeOrientationPatient; var firstSop = sourceSops[0]; ArrayDimensions = arrayDimensions; VoxelSpacing = voxelSpacing; VolumePositionPatient = volumePositionPatient; VolumeOrientationPatientX = volumeOrientationPatient.GetRow(0); VolumeOrientationPatientY = volumeOrientationPatient.GetRow(1); VolumeOrientationPatientZ = volumeOrientationPatient.GetRow(2); Modality = firstSop[DicomTags.Modality].ToString(); SourceStudyInstanceUid = firstSop[DicomTags.StudyInstanceUid].ToString(); SourceSeriesInstanceUid = firstSop[DicomTags.SeriesInstanceUid].ToString(); FrameOfReferenceUid = firstSop[DicomTags.FrameOfReferenceUid].ToString(); BitsPerVoxel = bitsAllocated; Signed = isSigned; PaddingValue = paddingValue; RescaleSlope = rescaleSlope; RescaleIntercept = rescaleIntercept; RescaleUnits = rescaleUnits ?? RescaleUnits.None; Laterality = laterality ?? string.Empty; VolumeSize = new Vector3D(ArrayDimensions.Width*VoxelSpacing.X, ArrayDimensions.Height*VoxelSpacing.Y, ArrayDimensions.Depth*VoxelSpacing.Z); VolumeBounds = new Rectangle3D(new Vector3D(0, 0, 0), VolumeSize); VolumeCenter = 0.5f*VolumeBounds.Size; VolumeCenterPatient = ConvertToPatient(VolumeCenter); // populate the DICOM data set FillDataSet(_collection, sourceSops, bitsAllocated, bitsStored, isSigned, rescaleSlope, rescaleIntercept, laterality); }
public void Size3D_Volume_IsCalculatedCorrectly() { var volume1width = 123.45; var volume1height = 456.78; var volume1depth = 789.99; var volume1 = new Size3D(volume1width, volume1height, volume1depth); TheResultingValue(volume1.Volume).ShouldBe(volume1width * volume1height * volume1depth); var volume2width = 222.22; var volume2height = 555.55; var volume2depth = 999.99; var volume2 = new Size3D(volume2width, volume2height, volume2depth); TheResultingValue(volume2.Volume).ShouldBe(volume2width * volume2height * volume2depth); }
public Rect3D( Point3D location, Size3D size ) { if ( size.IsEmpty ) { this = s_empty; } else { this._x = location._x; this._y = location._y; this._z = location._z; this._sizeX = size._x; this._sizeY = size._y; this._sizeZ = size._z; } }
private Model3DGroup GetBack(Point3D point, Size3D size) { int amount = (int)SliderOfRibs.Value; Model3DGroup group = new Model3DGroup(); double widthBetween = (0.97 * size.X) / ((amount + 1)); Point3D p = new Point3D(PositionOfSeat.X, PositionOfSeat.Y + ((0.6 * size.Y) / 2), PositionOfSeat.Z + 0.1 * ChairLegsLenght); group.Children.Add(ModelOfRec(new Point3D(PositionOfSeat.X, PositionOfSeat.Y + (0.8 * size.Y / 2), PositionOfSeat.Z), new Size3D(ChairLegsWidth, 0.8 * size.Y, ChairLegsLenght))); group.Children.Add(ModelOfRec(new Point3D(PositionOfSeat.X + size.X, PositionOfSeat.Y + (0.8 * size.Y / 2), PositionOfSeat.Z), new Size3D(ChairLegsWidth, 0.8 * size.Y, ChairLegsLenght))); group.Children.Add(ModelOfRec(new Point3D(PositionOfSeat.X + size.X / 2, PositionOfSeat.Y + (0.7 * size.Y), PositionOfSeat.Z), new Size3D(size.X - ChairLegsWidth, 0.2 * size.Y, ChairLegsLenght))); for (int i = 1; i < amount + 1; i++) { group.Children.Add(ModelOfRec(new Point3D(p.X + i * widthBetween, p.Y, p.Z), new Size3D(0.8 * ChairLegsWidth, 0.6 * size.Y, 0.8 * ChairLegsLenght))); } return(group); }
public HDHifi(Point3D center, Size3D size, Brush blockTexture, Brush speakerTexture, BitmapImage speakerBlockTexture) { block = new ModelVisual3D(); block.Content = HDModelHelpers.CubeModel(center, size, blockTexture); center.Offset(-size.X * 1.5, 0, 0); leftSpeaker = new HDSpeaker(center, size, speakerTexture, speakerBlockTexture); center.Offset(3 * size.X, 0, 0); rightSpeaker = new HDSpeaker(center, size, speakerTexture, speakerBlockTexture); mPlayer = new MediaPlayer(); this.Children.Add(block); this.Children.Add(leftSpeaker); this.Children.Add(rightSpeaker); }
private void UpdateWireBox() { // Get local values Size3D heightMapSize = HeightMap1.Size; // First we have to get the position and size of the WireBoxVisual3 // It is not the same as the HeightMapVisual3D because we start and stop the axis on the whole part of the _minYValue and _maxYValue // For example if the function's min is 0.8 and its max is 0.9 we would show axis from -1 to +1. double axisMinY = Math.Floor(_minYValue); double axisMaxY = Math.Ceiling(_maxYValue); double dataValuesRange = _maxYValue - _minYValue; double heightMapYSize = heightMapSize.Y; // This is defined by the height slider // First get the center double centerY = ((_maxYValue + _minYValue) / 2) * heightMapYSize; // Now calculate for how much we extend the y size to go from _minYValue to axisMinY and from _maxYValue to axisMaxY double axisSizeY; if (dataValuesRange > 0) { axisSizeY = heightMapYSize * dataValuesRange + (heightMapYSize * Math.Abs(_minYValue - axisMinY)) + // extent for the axisMinY - _minYValue (heightMapYSize * Math.Abs(axisMaxY - _maxYValue)); // extent for the axisMaxY - _maxYValue } else { axisSizeY = 0; } // Update the position, size and ZAxis value range AxesBox.CenterPosition = new Point3D(0, centerY, 0); AxesBox.Size = new Size3D(100, axisSizeY, 100); AxesBox.SetAxisDataRange(AxesBoxVisual3D.AxisTypes.ZAxis, minimumValue: axisMinY, maximumValue: axisMaxY, majorTicksStep: 1, minorTicksStep: 0, snapMaximumValueToMajorTicks: true); // Create contour lines UpdateContourLines(); }
public static void InitializeReactor(int interiorX, int interiorY, int interiorZ) { interiorDims = new Size3D(interiorX, interiorY, interiorZ); blocks = new Block[interiorX + 2, interiorY + 2, interiorZ + 2]; for (int x = 0; x < interiorX + 2; x++) { for (int y = 0; y < interiorY + 2; y++) { for (int z = 0; z < interiorZ + 2; z++) { blocks[x, y, z] = new Block("Air", BlockTypes.Air, Palette.Textures["Air"], new Point3D(x, y, z)); } } } for (int y = 1; y < interiorY + 1; y++) { for (int z = 1; z < interiorZ + 1; z++) { blocks[0, y, z] = new Casing("Casing", null, new Point3D(0, y, z)); blocks[interiorX + 1, y, z] = new Casing("Casing", null, new Point3D(interiorX + 1, y, z)); } } for (int x = 1; x < interiorX + 1; x++) { for (int z = 1; z < interiorZ + 1; z++) { blocks[x, 0, z] = new Casing("Casing", null, new Point3D(x, 0, z)); blocks[x, interiorY + 1, z] = new Casing("Casing", null, new Point3D(x, interiorY + 1, z)); } } for (int y = 1; y < interiorY + 1; y++) { for (int x = 1; x < interiorX + 1; x++) { blocks[x, y, interiorZ + 1] = new Casing("Casing", null, new Point3D(x, y, interiorZ + 1)); blocks[x, y, 0] = new Casing("Casing", null, new Point3D(x, y, 0)); } } usedFuel = Palette.FuelPalette.Values.First(); UpdateStats(); ConstructLayers(); }
public static MockVolumeReference Create(Size3D arrayDimensions, Vector3D voxelSpacing, Vector3D volumePositionPatient, Matrix3D volumeOrientationPatient) { var dataSet = new DicomAttributeCollection(); dataSet[DicomTags.Modality].SetStringValue("SC"); dataSet[DicomTags.StudyInstanceUid].SetStringValue(DicomUid.GenerateUid().UID); dataSet[DicomTags.SeriesInstanceUid].SetStringValue(DicomUid.GenerateUid().UID); dataSet[DicomTags.FrameOfReferenceUid].SetStringValue(DicomUid.GenerateUid().UID); return(new MockVolumeReference(new VolumeHeaderData(new IDicomAttributeProvider[] { dataSet }, arrayDimensions, voxelSpacing, volumePositionPatient, volumeOrientationPatient, 16, 16, false, 0, 1.0, 0.0, RescaleUnits.None))); }
public Part() { Code = ""; Dimensions = new Size3D(0, 0, 0); Location = new Point3D(0, 0, 0); Color = Color.Empty; Stock = 0; Min_stock = 0; Selling_price = 0; visual_part = null; //MODIF??? //Dictionary that contains every suppliers //Dictionary that contains every structure //Dictionary that contains every Type }
private void CreateSceneObjects() { // We store bounding box and current visibility status into a FrustumVisibilityStatus struct. // This way the frustum checks are optimized because we do not need to convert from WPF positions to SharpDX Vector3. // Also accessing DependencyProperties (CenterPosition, Size) is very slow. // // Also the organization of all FrustumVisibilityStatus structs in one array will give us // very memory cache friendly organization of data. var frustumStatuses = new List <FrustumVisibilityStatus>(); var halfBoxSize = 5; var boxSize = new Size3D(halfBoxSize * 2, halfBoxSize * 2, halfBoxSize * 2); for (int x = 0; x < 10; x++) { for (int z = 0; z < 10; z++) { for (int y = 0; y < 4; y++) { var centerPosition = new Point3D(-200 + 40 * x, y * 40, -200 + 40 * z); var boxVisual3D = new Ab3d.Visuals.BoxVisual3D() { CenterPosition = centerPosition, Size = boxSize, Material = _fullyVisibleMaterial }; BoxesRootVisual3D.Children.Add(boxVisual3D); frustumStatuses.Add(new FrustumVisibilityStatus(boxVisual3D, new BoundingBox(new Vector3((float)centerPosition.X - halfBoxSize, (float)centerPosition.Y - halfBoxSize, (float)centerPosition.Z - halfBoxSize), new Vector3((float)centerPosition.X + halfBoxSize, (float)centerPosition.Y + halfBoxSize, (float)centerPosition.Z + halfBoxSize)))); } } } // Convert to array. This will allow use to change Visibility field with passing array item by ref. _frustumStatuses = frustumStatuses.ToArray(); Camera1.Refresh(); UpdateVisibleBoxes(); }
public HDSpeaker(Point3D center, Size3D size, Brush speakerTexture, BitmapImage blockTexture) { this.size = size; block = new ModelVisual3D(); speaker = new ModelVisual3D(); block.Content = HDModelHelpers.CubeModel(center, size, new BitmapImage(new Uri("Hubert_Drogosz/Resources/drewno.png", UriKind.Relative))); speaker.Content = HDModelHelpers.MemModel(new Point3D(center.X, center.Y + size.Y / 4, center.Z + size.Z / 2) , new Size3D(size.X / 2, size.Y / 4, size.Z / 4) , new SolidColorBrush(Colors.DarkGray)); speaker.Transform = new TranslateTransform3D(); dTimer = new DispatcherTimer(); dTimer.Interval = new TimeSpan(0, 0, 0, 0, 100); dTimer.Tick += dTimer_Tick; dTimer.Start(); this.Children.Add(speaker); this.Children.Add(block); }
private Model3DGroup ModelOfPara(Point3D p0, Size3D size, double leng) { Model3DGroup model = new Model3DGroup(); Point3D p1 = new Point3D(p0.X + size.X, p0.Y, p0.Z); Point3D p2 = new Point3D(p1.X, p1.Y + size.Y, p1.Z - leng); Point3D p3 = new Point3D(p0.X, p2.Y, p2.Z - leng); Point3D p4 = new Point3D(p0.X, p0.Y, p0.Z - size.Z); Point3D p5 = new Point3D(p1.X, p1.Y, p1.Z - size.Z); Point3D p6 = new Point3D(p2.X, p2.Y, p2.Z - size.Z - leng); Point3D p7 = new Point3D(p3.X, p3.Y, p3.Z - size.Z - leng); model.Children.Add(RectangleModel(p0, p1, p2, p3)); model.Children.Add(RectangleModel(p1, p5, p6, p2)); model.Children.Add(RectangleModel(p5, p4, p7, p6)); model.Children.Add(RectangleModel(p4, p0, p3, p7)); model.Children.Add(RectangleModel(p0, p4, p5, p1)); model.Children.Add(RectangleModel(p3, p2, p6, p7)); return(model); }
public Volume CreateVolume(int width, int height, int depth, bool signed) { DicomAttributeCollection dataset = CreateMockDataset(_name, width, height, signed); Size3D dimensions = new Size3D(width, height, depth); Vector3D spacing = new Vector3D(1, 1, 1); Vector3D originPatient = new Vector3D(0, 0, 0); Matrix orientationPatient = Matrix.GetIdentity(4); if (signed) { short[] data = CreateSignedArray(width, height, depth); return(new Volume(data, dimensions, spacing, originPatient, orientationPatient, dataset, short.MinValue)); } else { ushort[] data = CreateUnsignedArray(width, height, depth); return(new Volume(data, dimensions, spacing, originPatient, orientationPatient, dataset, ushort.MinValue)); } }
public static float ScaleWeight(Size3D currentBound, Size3D targetbound) { if (currentBound.X > targetbound.X || currentBound.Y > targetbound.Y || currentBound.Z > targetbound.Z) { var fx = targetbound.X / currentBound.X; var fy = targetbound.Y / currentBound.Y; var fz = targetbound.Z / currentBound.Z; return((float)Math.Min(fz, Math.Min(fx, fy))); } else { var fx = targetbound.X / currentBound.X; var fy = targetbound.Y / currentBound.Y; var fz = targetbound.Z / currentBound.Z; return((float)Math.Min(fz, Math.Min(fx, fy))); } }
/// <summary> /// Tries to find an existing texture, or create a new one if not found. /// </summary> /// <param name="dsState">Depth-stencil buffer texture to find or create</param> /// <param name="size">Size of the depth-stencil texture</param> /// <param name="samplesInX">Number of samples in the X direction, for MSAA</param> /// <param name="samplesInY">Number of samples in the Y direction, for MSAA</param> /// <param name="sizeHint">A hint indicating the minimum used size for the texture</param> /// <returns>The texture</returns> public Texture FindOrCreateTexture(RtDepthStencilState dsState, Size3D size, int samplesInX, int samplesInY, Size sizeHint) { ulong gpuVa = dsState.Address.Pack(); ulong address = _context.MemoryManager.Translate(gpuVa); if (address == MemoryManager.PteUnmapped) { return(null); } int gobBlocksInY = dsState.MemoryLayout.UnpackGobBlocksInY(); int gobBlocksInZ = dsState.MemoryLayout.UnpackGobBlocksInZ(); Target target = (samplesInX | samplesInY) != 1 ? Target.Texture2DMultisample : Target.Texture2D; FormatInfo formatInfo = dsState.Format.Convert(); TextureInfo info = new TextureInfo( address, gpuVa, size.Width, size.Height, size.Depth, 1, samplesInX, samplesInY, 0, false, gobBlocksInY, gobBlocksInZ, 1, target, formatInfo); Texture texture = FindOrCreateTexture(info, TextureSearchFlags.WithUpscale, dsState.LayerSize * 4, sizeHint); texture.SynchronizeMemory(); return(texture); }
public static Rect3D Scale(this Rect3D source, double factor) { if (source.IsEmpty) { return(source); } Size3D newSize = new Size3D(source.SizeX * factor, source.SizeY * factor, source.SizeZ * factor); return(new Rect3D { Size = newSize, Location = new Point3D ( source.X + ((source.SizeX - newSize.X) / 2.0), source.Y + ((source.SizeY - newSize.Y) / 2.0), source.Z + ((source.SizeZ - newSize.Z) / 2.0) ) }); }
private Model3DGroup Cube(Point3D origin, Size3D size) { Model3DGroup model = new Model3DGroup(); Point3D p0 = new Point3D(origin.X - size.X / 2, origin.Y - size.Y / 2, origin.Z + size.Z / 2); Point3D p1 = new Point3D(p0.X + size.X, p0.Y, p0.Z); Point3D p2 = new Point3D(p1.X, p1.Y + size.Y, p1.Z); Point3D p3 = new Point3D(p0.X, p2.Y, p2.Z); Point3D p4 = new Point3D(p0.X, p0.Y, p0.Z - size.Z); Point3D p5 = new Point3D(p1.X, p1.Y, p1.Z - size.Z); Point3D p6 = new Point3D(p2.X, p2.Y, p2.Z - size.Z); Point3D p7 = new Point3D(p3.X, p3.Y, p3.Z - size.Z); model.Children.Add(RectangleModel(p0, p1, p2, p3)); model.Children.Add(RectangleModel(p1, p5, p6, p2)); model.Children.Add(RectangleModel(p5, p4, p7, p6)); model.Children.Add(RectangleModel(p4, p0, p3, p7)); model.Children.Add(RectangleModel(p0, p4, p5, p1)); model.Children.Add(RectangleModel(p3, p2, p6, p7)); return(model); }
public static InstanceData[] CreateInstancesData(Point3D center, Size3D size, float modelScaleFactor, int xCount, int yCount, int zCount, bool useTransparency) { int totalCount = xCount * yCount * zCount; var instancedData = new InstanceData[totalCount]; float xStep = xCount <= 1 ? 0 : (float)(size.X / (xCount - 1)); float yStep = yCount <= 1 ? 0 : (float)(size.Y / (yCount - 1)); float zStep = zCount <= 1 ? 0 : (float)(size.Z / (zCount - 1)); int i = 0; for (int y = 0; y < yCount; y++) { float yPos = (float)(center.Y - (size.Y / 2.0) + (y * yStep)); for (int z = 0; z < zCount; z++) { float zPos = (float)(center.Z - (size.Z / 2.0) + (z * zStep)); for (int x = 0; x < xCount; x++) { float xPos = (float)(center.X - (size.X / 2.0) + (x * xStep)); instancedData[i].World = new SharpDX.Matrix(modelScaleFactor, 0, 0, 0, 0, modelScaleFactor, 0, 0, 0, 0, modelScaleFactor, 0, xPos, yPos, zPos, 1); // Start with yellow and move to white (multiplied by 1.4 so that white color appear before the top) instancedData[i].DiffuseColor = new SharpDX.Color4(red: 1.0f - (float)i / (float)totalCount, green: 1.0f, blue: 1.0f - (float)x / (float)xCount, alpha: 1.0f); i++; } } } return(instancedData); }
public SpiralScanArgs() { ScanCurve = new ObservableCollectionThreadSafe <Point3D>(); Target = 0; MaxCycles = 1; Gap = 10; Range = 100; MoveSpeed = 100; AspectRatio = new Size3D(1, 1, 1); Random r = new Random(); for (int x = 0; x < 100; x++) { for (int y = 0; y < 100; y++) { ScanCurve.Add(new Point3D(x, y, r.NextDouble())); } } }
protected VolumeData CreateVolume(bool signed, Modality modality, Vector3D voxelSpacing) { Vector3D originPatient = new Vector3D(0, 0, 0); Matrix orientationPatient = Matrix.GetIdentity(4); int width, height, depth; if (signed) { short[] data = CreateSignedArray(out width, out height, out depth, voxelSpacing); DicomAttributeCollection dataset = CreateMockDataset(_name, _studyInstanceUid, _frameOfReferenceUid, modality, width, height, true, new SizeF(voxelSpacing.X, voxelSpacing.Y)); Size3D dimensions = new Size3D(width, height, depth); return(new VolumeData(data, dimensions, voxelSpacing, originPatient, orientationPatient, dataset, short.MinValue)); } else { ushort[] data = CreateUnsignedArray(out width, out height, out depth, voxelSpacing); DicomAttributeCollection dataset = CreateMockDataset(_name, _studyInstanceUid, _frameOfReferenceUid, modality, width, height, false, new SizeF(voxelSpacing.X, voxelSpacing.Y)); Size3D dimensions = new Size3D(width, height, depth); return(new VolumeData(data, dimensions, voxelSpacing, originPatient, orientationPatient, dataset, ushort.MinValue)); } }
public Model3DGroup DrawCuboids(Point3D orgin, Size3D size) { Uri Metal = new Uri("Rafal_Rogoda/Resources/Metal.png", UriKind.Relative); orgin.Y = orgin.Y - 1; Model3DGroup cuboidmodel = new Model3DGroup(); Point3D TrzonOrgin = new Point3D(orgin.X, orgin.Y + 0.25, orgin.Z); Size3D Trzon = new Size3D(size.X / 2, size.Y - size.Y / 20, size.Z / 2); cuboidmodel.Children.Add(groupDrawCuboid(TrzonOrgin, Trzon, Metal)); Point3D PodstawaOrgin = new Point3D(orgin.X, orgin.Y - size.Y / 2 + 0.25, orgin.Z); Size3D Podstawa = new Size3D(size.X, size.Y / 20, size.Z); cuboidmodel.Children.Add(groupDrawCuboid(PodstawaOrgin, Podstawa, Metal)); return(cuboidmodel); }
/// <summary> /// Tries to find an existing texture, or create a new one if not found. /// </summary> /// <param name="dsState">Depth-stencil buffer texture to find or create</param> /// <param name="size">Size of the depth-stencil texture</param> /// <param name="samplesInX">Number of samples in the X direction, for MSAA</param> /// <param name="samplesInY">Number of samples in the Y direction, for MSAA</param> /// <returns>The texture</returns> public Texture FindOrCreateTexture(RtDepthStencilState dsState, Size3D size, int samplesInX, int samplesInY) { ulong address = _context.MemoryManager.Translate(dsState.Address.Pack()); if (address == MemoryManager.BadAddress) { return(null); } int gobBlocksInY = dsState.MemoryLayout.UnpackGobBlocksInY(); int gobBlocksInZ = dsState.MemoryLayout.UnpackGobBlocksInZ(); Target target = (samplesInX | samplesInY) != 1 ? Target.Texture2DMultisample : Target.Texture2D; FormatInfo formatInfo = dsState.Format.Convert(); TextureInfo info = new TextureInfo( address, size.Width, size.Height, size.Depth, 1, samplesInX, samplesInY, 0, false, gobBlocksInY, gobBlocksInZ, 1, target, formatInfo); Texture texture = FindOrCreateTexture(info); texture.SynchronizeMemory(); return(texture); }
public override void Initialize(Dictionary <string, object> settings) { Random rand = new Random(); if (rand.NextDouble() > 0.5) { Size = new Size3D(8, 2.2, 2.2); base.MaxCapasity = 82; base.CurrentAgentCount = rand.Next(82); } else { Size = new Size3D(4.5, 1.82, 1.5); base.MaxCapasity = 20; base.CurrentAgentCount = rand.Next(20); } _maxSpeed = 360 + (rand.NextDouble() - 0.7) * 100; InputFactor = 25; OutputFactor = 25; _acceleration = 0.2; _deceleration = 0.4; }
private Model3DGroup groupDrawCover(Point3D orgin, Size3D size, Uri col) { //duł klosza Point3D A1 = new Point3D((orgin.X) * 4, (orgin.Y + size.Y / 5), (orgin.Z - size.Z / 2) * 4); //A Point3D B1 = new Point3D((orgin.X + size.X / 2) * 4, (orgin.Y + size.Y / 5), (orgin.Z - size.Z / 4) * 4); //B Point3D C1 = new Point3D((orgin.X + size.X / 2) * 4, (orgin.Y + size.Y / 5), (orgin.Z + size.Z / 4) * 4); //C Point3D D1 = new Point3D((orgin.X) * 4, (orgin.Y + size.Y / 5), (orgin.Z + size.Z / 2) * 4); //D Point3D E1 = new Point3D((orgin.X - size.X / 2) * 4, (orgin.Y + size.Y / 5), (orgin.Z + size.Z / 4) * 4); //E Point3D F1 = new Point3D((orgin.X - size.X / 2) * 4, (orgin.Y + size.Y / 5), (orgin.Z - size.Z / 4) * 4); //F //góra klosza Point3D A2 = new Point3D((orgin.X) * 2, (orgin.Y + size.Y / 2), (orgin.Z - size.Z / 2) * 2); //A' Point3D B2 = new Point3D((orgin.X + size.X / 2) * 2, (orgin.Y + size.Y / 2), (orgin.Z - size.Z / 4) * 2); //B' Point3D C2 = new Point3D((orgin.X + size.X / 2) * 2, (orgin.Y + size.Y / 2), (orgin.Z + size.Z / 4) * 2); //C' Point3D D2 = new Point3D((orgin.X) * 2, (orgin.Y + size.Y / 2), (orgin.Z + size.Z / 2) * 2); //D' Point3D E2 = new Point3D((orgin.X - size.X / 2) * 2, (orgin.Y + size.Y / 2), (orgin.Z + size.Z / 4) * 2); //E' Point3D F2 = new Point3D((orgin.X - size.X / 2) * 2, (orgin.Y + size.Y / 2), (orgin.Z - size.Z / 4) * 2); //F' //GeometryModel3D model1 = meth.rectangleModel(A1, B1, B2, A2, col); GeometryModel3D model1 = meth.rectangleModel(A2, B2, B1, A1, col); GeometryModel3D model2 = meth.rectangleModel(B2, C2, C1, B1, col); GeometryModel3D model3 = meth.rectangleModel(C2, D2, D1, C1, col); GeometryModel3D model4 = meth.rectangleModel(D2, E2, E1, D1, col); GeometryModel3D model5 = meth.rectangleModel(E2, F2, F1, E1, col); GeometryModel3D model6 = meth.rectangleModel(F2, A2, A1, F1, col); Model3DGroup group = new Model3DGroup(); group.Children.Add(model1); //prawy tył group.Children.Add(model2); //prawa group.Children.Add(model3); //prawy przód group.Children.Add(model4); //lewy przód group.Children.Add(model5); //lewa group.Children.Add(model6); //lewa tył return(group); }
/// <summary> /// Tries to find an existing texture, or create a new one if not found. /// </summary> /// <param name="memoryManager">GPU memory manager where the texture is mapped</param> /// <param name="dsState">Depth-stencil buffer texture to find or create</param> /// <param name="size">Size of the depth-stencil texture</param> /// <param name="samplesInX">Number of samples in the X direction, for MSAA</param> /// <param name="samplesInY">Number of samples in the Y direction, for MSAA</param> /// <param name="sizeHint">A hint indicating the minimum used size for the texture</param> /// <returns>The texture</returns> public Texture FindOrCreateTexture( MemoryManager memoryManager, RtDepthStencilState dsState, Size3D size, int samplesInX, int samplesInY, Size sizeHint) { int gobBlocksInY = dsState.MemoryLayout.UnpackGobBlocksInY(); int gobBlocksInZ = dsState.MemoryLayout.UnpackGobBlocksInZ(); Target target = (samplesInX | samplesInY) != 1 ? Target.Texture2DMultisample : Target.Texture2D; FormatInfo formatInfo = dsState.Format.Convert(); TextureInfo info = new TextureInfo( dsState.Address.Pack(), size.Width, size.Height, size.Depth, 1, samplesInX, samplesInY, 0, false, gobBlocksInY, gobBlocksInZ, 1, target, formatInfo); Texture texture = FindOrCreateTexture(memoryManager, TextureSearchFlags.WithUpscale, info, dsState.LayerSize * 4, sizeHint); texture?.SynchronizeMemory(); return(texture); }
public static Model3DGroup CubeModel(Point3D center, Size3D size, BitmapImage texture) { Point3D a = new Point3D(center.X - (size.X / 2), center.Y - (size.Y / 2), center.Z + (size.Z / 2)); Point3D b = new Point3D(a.X + size.X, a.Y, a.Z); Point3D c = new Point3D(a.X + size.X, a.Y + size.Y, a.Z); Point3D d = new Point3D(a.X, a.Y + size.Y, a.Z); Point3D ap = new Point3D(a.X, a.Y, a.Z - size.Z); Point3D bp = new Point3D(b.X, b.Y, b.Z - size.Z); Point3D cp = new Point3D(c.X, c.Y, c.Z - size.Z); Point3D dp = new Point3D(d.X, d.Y, d.Z - size.Z); Model3DGroup group = new Model3DGroup(); group.Children.Add(RectangleModel(a, b, c, d, texture)); group.Children.Add(RectangleModel(b, bp, cp, c, texture)); group.Children.Add(RectangleModel(ap, dp, cp, bp, texture)); group.Children.Add(RectangleModel(a, d, dp, ap, texture)); group.Children.Add(RectangleModel(a, ap, bp, b, texture)); group.Children.Add(RectangleModel(d, c, cp, dp, texture)); return(group); }
public ResizeWindow(Hull hull) { InitializeComponent(); ResizeWindowData resizeData = (ResizeWindowData)this.FindResource("ResizeData"); if (resizeData != null) { bool proportional = resizeData.Proportional; // Need to turn off Proportional for initial setup resizeData.Proportional = false; Size3D size = hull.GetSize(); resizeData.Width = size.X * 2; // multiply by 2 because this is half-hull resizeData.Height = size.Y; resizeData.Length = size.Z; resizeData.Proportional = true; // Reset proportional resizeData.Proportional = proportional; } }
public static Rect3D Transform(this Matrix3D matrix, Rect3D bounds) { Point3D center = bounds.GetCenter(); Point3D corner = new Point3D( bounds.Location.X + bounds.SizeX, bounds.Location.Y + bounds.SizeY, bounds.Location.Z + bounds.SizeZ); Point3D transformedCenter = matrix.Transform(center); Point3D transformedLocation = matrix.Transform(bounds.Location); Point3D transformedCorner = matrix.Transform(corner); Size3D transformedSize = new Size3D( Abs(transformedCenter.X - transformedLocation.X) * 2.0, Abs(transformedCenter.Y - transformedLocation.Y) * 2.0, Abs(transformedCenter.Z - transformedLocation.Z) * 2.0); transformedLocation = new Point3D( transformedCenter.X - (transformedSize.X / 2.0), transformedCenter.Y - (transformedSize.Y / 2.0), transformedCenter.Z - (transformedSize.Z / 2.0)); return(new Rect3D(transformedLocation, transformedSize)); }
// <SnippetSize3DEqualityExample_csharp> private bool size3DEqualityExample() { // Checks if two Size3D structures are equal using the static Equals method. // Returns a Boolean. // Declaring Size3D structure without initializing x,y,z values Size3D size1 = new Size3D(); // Declaring Size3D structure and initializing x,y,z values Size3D size2 = new Size3D(5, 10, 15); Boolean areEqual; // Assigning values to size1 size1.X = 2; size1.Y = 4; size1.Z = 6; // checking for equality areEqual = Size3D.Equals(size1, size2); // areEqual is False return(areEqual); }
public ModelVisual3D GetCube(MaterialGroup materialGroup, Point3D point, Size3D size) { var farPoint = new Point3D(point.X - (size.X / 2), point.Y - (size.Y / 2), point.Z - (size.Z / 2)); var nearPoint = new Point3D(point.X + (size.X / 2), point.Y + (size.Y / 2), point.Z + (size.Z / 2)); var cube = new Model3DGroup(); var p0 = new Point3D(farPoint.X, farPoint.Y, farPoint.Z); var p1 = new Point3D(nearPoint.X, farPoint.Y, farPoint.Z); var p2 = new Point3D(nearPoint.X, farPoint.Y, nearPoint.Z); var p3 = new Point3D(farPoint.X, farPoint.Y, nearPoint.Z); var p4 = new Point3D(farPoint.X, nearPoint.Y, farPoint.Z); var p5 = new Point3D(nearPoint.X, nearPoint.Y, farPoint.Z); var p6 = new Point3D(nearPoint.X, nearPoint.Y, nearPoint.Z); var p7 = new Point3D(farPoint.X, nearPoint.Y, nearPoint.Z); //front side triangles cube.Children.Add(CreateTriangleModel(materialGroup, p3, p2, p6)); cube.Children.Add(CreateTriangleModel(materialGroup, p3, p6, p7)); //right side triangles cube.Children.Add(CreateTriangleModel(materialGroup, p2, p1, p5)); cube.Children.Add(CreateTriangleModel(materialGroup, p2, p5, p6)); //back side triangles cube.Children.Add(CreateTriangleModel(materialGroup, p1, p0, p4)); cube.Children.Add(CreateTriangleModel(materialGroup, p1, p4, p5)); //left side triangles cube.Children.Add(CreateTriangleModel(materialGroup, p0, p3, p7)); cube.Children.Add(CreateTriangleModel(materialGroup, p0, p7, p4)); //top side triangles cube.Children.Add(CreateTriangleModel(materialGroup, p7, p6, p5)); cube.Children.Add(CreateTriangleModel(materialGroup, p7, p5, p4)); //bottom side triangles cube.Children.Add(CreateTriangleModel(materialGroup, p2, p3, p0)); cube.Children.Add(CreateTriangleModel(materialGroup, p2, p0, p1)); var model = new ModelVisual3D(); model.Content = cube; return(model); }
public static WW3DModel GenerateCuboid(Size3D wdh, Vector3D offset, NormalDirection nd) { var points = new List <Point3D>(); points.Add(new Point3D(-wdh.X / 2 + offset.X, -wdh.Y / 2 + offset.Y, wdh.Z / 2 + offset.Z)); points.Add(new Point3D(-wdh.X / 2 + offset.X, -wdh.Y / 2 + offset.Y, -wdh.Z / 2 + offset.Z)); points.Add(new Point3D(wdh.X / 2 + offset.X, -wdh.Y / 2 + offset.Y, -wdh.Z / 2 + offset.Z)); points.Add(new Point3D(wdh.X / 2 + offset.X, -wdh.Y / 2 + offset.Y, wdh.Z / 2 + offset.Z)); points.Add(new Point3D(-wdh.X / 2 + offset.X, wdh.Y / 2 + offset.Y, wdh.Z / 2 + offset.Z)); points.Add(new Point3D(-wdh.X / 2 + offset.X, wdh.Y / 2 + offset.Y, -wdh.Z / 2 + offset.Z)); points.Add(new Point3D(wdh.X / 2 + offset.X, wdh.Y / 2 + offset.Y, -wdh.Z / 2 + offset.Z)); points.Add(new Point3D(wdh.X / 2 + offset.X, wdh.Y / 2 + offset.Y, wdh.Z / 2 + offset.Z)); int[] indices = null; switch (nd) { case NormalDirection.Outward: indices = new int[] { 5, 1, 0, 6, 2, 1, 7, 3, 2, 4, 0, 3, 1, 2, 3, 6, 5, 4, 4, 5, 0, 5, 6, 1, 6, 7, 2, 7, 4, 3, 0, 1, 3, 7, 6, 4 }; break; case NormalDirection.Inward: indices = new int[] { 0, 1, 5, 1, 2, 6, 2, 3, 7, 3, 0, 4, 3, 2, 1, 4, 5, 6, 0, 5, 4, 1, 6, 5, 2, 7, 6, 3, 4, 7, 3, 1, 0, 4, 6, 7 }; break; } return(new WW3DModel(points.ToArray(), indices)); }
private void AddMillionBlocks(int xCount, int zCount, Size3D blockSize, float pixelSize, Color4 pixelColor) { AdjustPixelSize(ref pixelSize, 0.5f); double totalSizeX = xCount * blockSize.X * 1.5; // multiply by 1.5 to add half blockSize margin between blocks double totalSizeZ = zCount * blockSize.Z * 1.5; double x = -(totalSizeX - blockSize.X) / 2; for (int ix = 0; ix < xCount; ix++) { double z = -(totalSizeZ - blockSize.Z) / 2; for (int iz = 0; iz < zCount; iz++) { var positionsArray = CreatePositionsArray(new Point3D(x, 0, z), blockSize, 100, 100, 100); ShowPositionsArray(positionsArray, pixelSize, pixelColor, new Point3D(x, 0, z), blockSize); z += 1.5 * blockSize.Z; } x += 1.5 * blockSize.X; } }
/// <summary> /// Initializes a new instance of the <see cref="Size3DResult"/> class. /// </summary> /// <param name="value">The value being examined.</param> internal Size3DResult(Size3D value) { this.value = value; }
///<exclude/> public bool Equals(Size3D other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; return other._L.Equals(_L) && other._W.Equals(_W) && other._H.Equals(_H); }
/// <summary> /// Initializes the <see cref="Volume"/> using the specified volume data. /// </summary> /// <remarks> /// Consider using <see cref="Volume.Create(IDisplaySet)"/> or one of its overloads to automatically construct and fill a <see cref="Volume"/> of the appropriate type. /// </remarks> public S8Volume(sbyte[] array, Size3D arrayDimensions, Vector3D voxelSpacing, Vector3D volumePositionPatient, Matrix3D volumeOrientationPatient, IList<IDicomAttributeProvider> dicomAttributeModel, int paddingValue) : this(array, new VolumeHeaderData(dicomAttributeModel, arrayDimensions, voxelSpacing, volumePositionPatient, volumeOrientationPatient, 8, 8, true, paddingValue, 1, 0, RescaleUnits.None), null, null) {}
private Volume(short[] dataInt16, ushort[] dataUInt16, Size3D dimensions, Vector3D spacing, Vector3D originPatient, Matrix orientationPatient, VolumeSopDataSourcePrototype sopDataSourcePrototype, int paddingValue, string sourceSeriesInstanceUid, int minVolumeValue, int maxVolumeValue) { Platform.CheckTrue(dataInt16 != null ^ dataUInt16 != null, "Exactly one of dataInt16 and dataUInt16 must be non-null."); _volumeDataInt16 = dataInt16; _volumeDataUInt16 = dataUInt16; _sourceSeriesInstanceUid = sourceSeriesInstanceUid; _minVolumeValue = minVolumeValue; _maxVolumeValue = maxVolumeValue; _arrayDimensions = dimensions; _voxelSpacing = spacing; _originPatient = originPatient; _orientationPatientMatrix = orientationPatient; _modelDicom = sopDataSourcePrototype; _paddingValue = paddingValue; // Generate a descriptive name for the volume PersonName patientName = new PersonName(sopDataSourcePrototype[DicomTags.PatientsName].ToString()); string patientId = sopDataSourcePrototype[DicomTags.PatientId].ToString(); string seriesDescription = sopDataSourcePrototype[DicomTags.SeriesDescription].ToString(); if (string.IsNullOrEmpty(seriesDescription)) _description = string.Format(SR.FormatVolumeLabel, patientName.FormattedName, patientId, seriesDescription); else _description = string.Format(SR.FormatVolumeLabelWithSeries, patientName.FormattedName, patientId, seriesDescription); }
/// <summary> /// Initializes the <see cref="Volume"/> using the specified volume data. /// </summary> /// <remarks> /// Consider using <see cref="Volume.Create(IDisplaySet)"/> or one of its overloads to automatically construct and fill a <see cref="Volume"/> of the appropriate type. /// </remarks> public U16Volume(ushort[] array, Size3D arrayDimensions, Vector3D voxelSpacing, Vector3D volumePositionPatient, Matrix3D volumeOrientationPatient, IDicomAttributeProvider attributeProvider, int paddingValue) : this(array, arrayDimensions, voxelSpacing, volumePositionPatient, volumeOrientationPatient, new[] {attributeProvider}, paddingValue, 1, 0, RescaleUnits.None) {}
public Volume(ushort[] data, Size3D dimensions, Vector3D spacing, Vector3D originPatient, Matrix orientationPatient, IDicomAttributeProvider attributeProvider, int paddingValue) : this(data, dimensions, spacing, originPatient, orientationPatient, attributeProvider, paddingValue, null) {}
public Volume CreateVolume(int width, int height, int depth, bool signed) { DicomAttributeCollection dataset = CreateMockDataset(_name, width, height, signed); Size3D dimensions = new Size3D(width, height, depth); Vector3D spacing = new Vector3D(1, 1, 1); Vector3D originPatient = new Vector3D(0, 0, 0); Matrix3D orientationPatient = Matrix3D.GetIdentity(); if (signed) { short[] data = CreateSignedArray(width, height, depth); return new S16Volume(data, dimensions, spacing, originPatient, orientationPatient, dataset, short.MinValue); } else { ushort[] data = CreateUnsignedArray(width, height, depth); return new U16Volume(data, dimensions, spacing, originPatient, orientationPatient, dataset, ushort.MinValue); } }
protected VolumeData CreateVolume(bool signed, Modality modality, Vector3D voxelSpacing) { Vector3D originPatient = new Vector3D(0, 0, 0); Matrix orientationPatient = Matrix.GetIdentity(4); int width, height, depth; if (signed) { short[] data = CreateSignedArray(out width, out height, out depth, voxelSpacing); DicomAttributeCollection dataset = CreateMockDataset(_name, _studyInstanceUid, _frameOfReferenceUid, modality, width, height, true, new SizeF(voxelSpacing.X, voxelSpacing.Y)); Size3D dimensions = new Size3D(width, height, depth); return new VolumeData(data, dimensions, voxelSpacing, originPatient, orientationPatient, dataset, short.MinValue); } else { ushort[] data = CreateUnsignedArray(out width, out height, out depth, voxelSpacing); DicomAttributeCollection dataset = CreateMockDataset(_name, _studyInstanceUid, _frameOfReferenceUid, modality, width, height, false, new SizeF(voxelSpacing.X, voxelSpacing.Y)); Size3D dimensions = new Size3D(width, height, depth); return new VolumeData(data, dimensions, voxelSpacing, originPatient, orientationPatient, dataset, ushort.MinValue); } }
/// <summary> /// Wraps the specified unit test result for evaluation. /// </summary> /// <param name="value">The value to wrap.</param> /// <returns>The wrapped value.</returns> protected static Size3DResult TheResultingValue(Size3D value) { return new Size3DResult(value); }
public void Size3D_Volume_IsCalculatedCorrectly() { var volume1width = 123.45; var volume1height = 456.78; var volume1depth = 789.99; var volume1 = new Size3D(volume1width, volume1height, volume1depth); TheResultingValue(volume1.Volume).ShouldBe(volume1width * volume1height * volume1depth); var volume2width = 222.22; var volume2height = 555.55; var volume2depth = 999.99; var volume2 = new Size3D(volume2width, volume2height, volume2depth); TheResultingValue(volume2.Volume).ShouldBe(volume2width * volume2height * volume2depth); }
/// <summary> /// Initializes the <see cref="Volume"/> using the specified volume data. /// </summary> /// <remarks> /// Consider using <see cref="Volume.Create(IDisplaySet)"/> or one of its overloads to automatically construct and fill a <see cref="Volume"/> of the appropriate type. /// </remarks> public U16Volume(ushort[] array, Size3D arrayDimensions, Vector3D voxelSpacing, Vector3D volumePositionPatient, Matrix3D volumeOrientationPatient, IList<IDicomAttributeProvider> dicomAttributeModel, int paddingValue, double rescaleSlope, double rescaleIntercept, RescaleUnits rescaleUnits) : this(array, new VolumeHeaderData(dicomAttributeModel, arrayDimensions, voxelSpacing, volumePositionPatient, volumeOrientationPatient, 16, 16, false, paddingValue, rescaleSlope, rescaleIntercept, rescaleUnits), null, null) {}
public void Size3D_SerializesToJson_WhenNullable() { var size = new Size3D(1.2, 2.3, 3.4); var json = JsonConvert.SerializeObject((Size3D?)size); TheResultingString(json).ShouldBe(@"{""width"":1.2,""height"":2.3,""depth"":3.4}"); }
public static MockVolumeReference Create(Size3D arrayDimensions, Vector3D voxelSpacing, Vector3D volumePositionPatient, Matrix3D volumeOrientationPatient) { var dataSet = new DicomAttributeCollection(); dataSet[DicomTags.Modality].SetStringValue("SC"); dataSet[DicomTags.StudyInstanceUid].SetStringValue(DicomUid.GenerateUid().UID); dataSet[DicomTags.SeriesInstanceUid].SetStringValue(DicomUid.GenerateUid().UID); dataSet[DicomTags.FrameOfReferenceUid].SetStringValue(DicomUid.GenerateUid().UID); return new MockVolumeReference(new VolumeHeaderData(new IDicomAttributeProvider[] {dataSet}, arrayDimensions, voxelSpacing, volumePositionPatient, volumeOrientationPatient, 16, 16, false, 0, 1.0, 0.0, RescaleUnits.None)); }
/// <summary> /// Constructs a <see cref="Volume"/> using a volume data array of unsigned 16-bit words. /// </summary> /// <remarks> /// Consider using one of the static helpers such as <see cref="Create(ClearCanvas.ImageViewer.IDisplaySet)"/> to construct and automatically fill a <see cref="Volume"/>. /// </remarks> public Volume(ushort[] data, Size3D dimensions, Vector3D spacing, Vector3D originPatient, Matrix orientationPatient, IDicomAttributeProvider dicomAttributeModel, int paddingValue, string sourceSeriesInstanceUid) : this(null, data, dimensions, spacing, originPatient, orientationPatient, VolumeSopDataSourcePrototype.Create(dicomAttributeModel, 16, 16, false), paddingValue, sourceSeriesInstanceUid, 0, 0) {}
/// <summary> /// Initializes the <see cref="Volume"/> using the specified volume data. /// </summary> /// <remarks> /// Consider using <see cref="Volume.Create(IDisplaySet)"/> or one of its overloads to automatically construct and fill a <see cref="Volume"/> of the appropriate type. /// </remarks> public U16Volume(ushort[] array, Size3D arrayDimensions, Vector3D voxelSpacing, Vector3D volumePositionPatient, Matrix3D volumeOrientationPatient, IDicomAttributeProvider attributeProvider, int paddingValue, double rescaleSlope, double rescaleIntercept, RescaleUnits rescaleUnits) : this(array, arrayDimensions, voxelSpacing, volumePositionPatient, volumeOrientationPatient, new[] {attributeProvider}, paddingValue, rescaleSlope, rescaleIntercept, rescaleUnits) {}