Beispiel #1
0
 private void BrightnessBarChanged()
 {
     Transformation transform = new Transformation();
     transform.type = TransformationType.BRIGHTNESS_CHANGE;
     transform.argument = getNormalizedBrightnessLevel();
     TransformImage(transform);
 }
Beispiel #2
0
        private void CalculateImageAndTransformationMatrix(string fileName)
        {
            var zipFile = new Ionic.Zip.ZipFile(fileName);
              var mapSize = new Size();
              Transformation = new Transformation();

              // get entry for kml file and image file
              KmlDocument kmlDocument = null;
              foreach (var entry in zipFile)
              {
            if (entry.FileName == entry.LocalFileName && Path.GetExtension(entry.FileName) == ".kml")
            {
              using (var kmlStream = new MemoryStream())
              {
            entry.Extract(kmlStream);
            kmlStream.Position = 0;
            kmlDocument = new KmlDocument(kmlStream);
              }
              break;
            }
              }

              if (kmlDocument != null)
              {
            // we have got a kml document, get map image file stream from it
            foreach (var entry in zipFile)
            {
              if (entry.FileName == kmlDocument.ImageFileName)
              {
            ImageStream = new MemoryStream();
            entry.Extract(ImageStream);
            ImageStream.Position = 0;
            // check if image is QR jpeg
            var ed = QuickRouteJpegExtensionData.FromStream(ImageStream);
            if(ed != null)
            {
              // get transformation matrix from QR jpeg metadata
              Transformation = ed.Sessions.CalculateAverageTransformation();
              ImageStream.Position = 0;
              return;
            }
            else
            {
              // it is not, use normal image bounds
              ImageStream.Position = 0;
              mapSize = Image.FromStream(ImageStream).Size; // need to get image object to get image size
            }
            ImageStream.Position = 0;
            break;
              }
            }
              }

              if (kmlDocument != null && ImageStream != null)
              {
            // finally, calculate the transformation
            Transformation = new Transformation(kmlDocument.LongLatBox, mapSize);
              }
        }
Beispiel #3
0
        public MeshNode(string label, NsNode parent, double[,] initTransform)
            : this(label, parent)
        {
            for (int i = 0; i < 3; i++)
                    initTransform[i, 3] *= 1000;

               m_T = new Transformation(initTransform);
        }
        public void CloudinaryImage_WithEffect_AddsEffect()
        {
            var transformation = new Transformation(30, 90);
            transformation.Effect = "sepia";

            string url = Url.CloudinaryImage("effected", transformation).ToString();
            Assert.AreEqual("http://res.cloudinary.com/test/image/upload/w_30,h_90,e_sepia/effected.jpg", url);
        }
        public void CloudinaryImage_WithAutoAngle_AddsPosition()
        {
            var transformation = new Transformation(240, 240) {Angle = Angle.Auto};

            string url = Url.CloudinaryImage("angled", transformation).ToString();

            Assert.AreEqual("http://res.cloudinary.com/test/image/upload/w_240,h_240,a_auto/angled.jpg", url);
        }
        public void CloudinaryImage_WithFixedCroppingPositionSet_AddPosition()
        {
            var transformation = new Transformation(240, 240) { Crop = CropMode.Crop };
            transformation.SetFixedCroppingPosition(350, 510);

            string url = Url.CloudinaryImage("cropme", transformation).ToString();

            Assert.AreEqual("http://res.cloudinary.com/test/image/upload/w_240,h_240,x_350,y_510,c_crop/cropme.jpg", url);
        }
Beispiel #7
0
        public void TestBaseTransformationChain()
        {
            // should support base transformation

            Transformation transformation = new Transformation().X(100).Y(100).Crop("fill").Chain().Crop("crop").Width(100);
            string uri = api.UrlImgUp.Transform(transformation).BuildUrl("test");
            Assert.AreEqual("100", transformation.HtmlWidth);
            Assert.AreEqual("http://res.cloudinary.com/testcloud/image/upload/c_fill,x_100,y_100/c_crop,w_100/test", uri);
        }
Beispiel #8
0
        public void CanInsertCollectionOfItemsToScene()
        {
            var map = new Map();
            var transformation = new Transformation(500, 500);
            var transformation2 = new Transformation(100, 100);

            map.Insert("grass", new List<Transformation> { transformation, transformation2 });

            Assert.AreEqual(map.Scene["grass"].Count, 2);
        }
Beispiel #9
0
 public void TestBackground()
 {
     // should support background
     Transformation transformation = new Transformation().Background("red");
     String result = api.UrlImgUp.Transform(transformation).BuildUrl("test");
     Assert.AreEqual("http://res.cloudinary.com/testcloud/image/upload/b_red/test", result);
     transformation = new Transformation().Background("#112233");
     result = api.UrlImgUp.Transform(transformation).BuildUrl("test");
     Assert.AreEqual("http://res.cloudinary.com/testcloud/image/upload/b_rgb:112233/test", result);
 }
Beispiel #10
0
 public void TestAngle()
 {
     // should support angle
     Transformation transformation = new Transformation().Angle(12);
     String result = m_api.UrlImgUp.Transform(transformation).BuildUrl("test");
     Assert.AreEqual(m_defaultImgUpPath + "a_12/test", result);
     transformation = new Transformation().Angle("exif", "12");
     result = m_api.UrlImgUp.Transform(transformation).BuildUrl("test");
     Assert.AreEqual(m_defaultImgUpPath + "a_exif.12/test", result);
 }
Beispiel #11
0
 public void TestBackground()
 {
     // should support background
     Transformation transformation = new Transformation().Background("red");
     String result = m_api.UrlImgUp.Transform(transformation).BuildUrl("test");
     Assert.AreEqual(m_defaultImgUpPath + "b_red/test", result);
     transformation = new Transformation().Background("#112233");
     result = m_api.UrlImgUp.Transform(transformation).BuildUrl("test");
     Assert.AreEqual(m_defaultImgUpPath + "b_rgb:112233/test", result);
 }
 public void EndIf()
 {
     Transformation transformation = new Transformation().IfCondition("w_lt_200").Crop("fill").Height(120).Width(80).Effect("sharpen")
         .Chain().Effect("brightness", 50)
         .Chain().Effect("shadow").Color("red")
         .EndIf();
     string sTransform = transformation.ToString();
     Assert.IsTrue(sTransform.EndsWith("if_end"), "should include the if_end as the last parameter in its component");
     Assert.AreEqual("if_w_lt_200/c_fill,e_sharpen,h_120,w_80/e_brightness:50/co_red,e_shadow/if_end", sTransform, "should be proper transformation string");
 }
Beispiel #13
0
        public void CanInsertItemToScene()
        {
            var map = new Map();

            var transformation = new Transformation(500, 500);

            map.Insert("grass", transformation);

            Assert.AreEqual(map.Scene["grass"].First().Translation, transformation.Translation);
        }
Beispiel #14
0
 public void TestAngle()
 {
     // should support angle
     Transformation transformation = new Transformation().Angle(12);
     String result = api.UrlImgUp.Transform(transformation).BuildUrl("test");
     Assert.AreEqual("http://res.cloudinary.com/testcloud/image/upload/a_12/test", result);
     transformation = new Transformation().Angle("exif", "12");
     result = api.UrlImgUp.Transform(transformation).BuildUrl("test");
     Assert.AreEqual("http://res.cloudinary.com/testcloud/image/upload/a_exif.12/test", result);
 }
Beispiel #15
0
        public Trees(Game game, ContentManager content, GraphicsDeviceManager graphics)
            : base(game)
        {
            this.content = content;
            camera = Game.Services.GetService(typeof(ChaseCamera)) as ChaseCamera;
            terrain = Game.Services.GetService(typeof(Terrain)) as Terrain;
            this.graphics = graphics;

            transformation = new Transformation();
            transformation.Scale = new Vector3(TREE_SCALE);
        }
        public void CloudinaryImage_WithDefaultImageSpecified_AddsDefaultImageToUrl()
        {
            var transformation = new Transformation(240, 240)
                                     {
                                         DefaultImage = "sample.jpg"
                                     };

            string url = Url.CloudinaryImage("face", transformation).ToString();

            Assert.AreEqual("http://res.cloudinary.com/test/image/upload/w_240,h_240,d_sample.jpg/face.jpg", url);
        }
        public void EndIf2()
        {
            Transformation transformation = new Transformation().IfCondition().Width("gt", 100).And().Width("lt", 200).Then().Width(50).Crop("scale").EndIf();
            Assert.AreEqual("if_w_gt_100_and_w_lt_200/c_scale,w_50/if_end", transformation.ToString(), "should serialize to 'if_end'");

            transformation = new Transformation().IfCondition().Width("gt", 100).And().Width("lt", 200).Then().Width(50).Crop("scale").EndIf();
            Assert.AreEqual("if_w_gt_100_and_w_lt_200/c_scale,w_50/if_end", transformation.ToString(), "force the if clause to be chained");

            transformation = new Transformation().IfCondition().Width("gt", 100).And().Width("lt", 200).Then().Width(50).Crop("scale").IfElse().Width(100).Crop("crop").EndIf();
            Assert.AreEqual("if_w_gt_100_and_w_lt_200/c_scale,w_50/if_else/c_crop,w_100/if_end", transformation.ToString(), "force the if_else clause to be chained");
        }
        public void ToCloudinary_WithTwoTransformations_CombinesThem()
        {
            var first = new Transformation(20, 40) { Angle = new Angle(40)};
            var second = new TransformationBase
                             {
                                 Effect = "sepia"
                             };

            var chained = new ChainedTransformation(first, second);

            Assert.AreEqual("w_20,h_40,a_40/e_sepia", chained.ToCloudinary());
        }
Beispiel #19
0
        public MeshTestScene(int width, int height)
        {
            Width = width;
            Height = height;

            rasterizer = new Rasterizer(Width, Height);
            inputStateService = new InputStateService();
            transformation = new Transformation();

            currentWavefrontObjectFilePath = "Models\\woman1.obj";

            InitScene(currentWavefrontObjectFilePath);
        }
Beispiel #20
0
        public AnimatedModel(Game game)
            : base(game)
        {
            // Animation
            enableAnimationLoop = true;
            animationSpeed = 1.0f;
            activeAnimationKeyframe = 0;
            activeAnimationTime = TimeSpan.Zero;

            transformation = new Transformation();

            isInitialized = false;
        }
Beispiel #21
0
        private Parameter _parameter; // калибруемый параметр

        #endregion Fields

        #region Constructors

        public AddTransformationForm(SGT.SgtApplication _app)
        {
            app = _app;
            app.Commutator.onUpdated +=new CommutatorEventHandler(Converter_OnComplete);

            InitializeComponent();

            transformation = new Transformation();

            transformation.OnInsert += new Transformation.TConditionEventHandle(transformation_OnInsert);
            transformation.OnEdit += new Transformation.TConditionEventHandle(transformation_OnEdit);
            transformation.OnRemove += new Transformation.TConditionEventHandle(transformation_OnRemove);

            transformation.OnClear += new EventHandler(transformation_OnClear);
            transformation.OnError += new Transformation.ErrorEventHandle(transformation_OnError);

            transformation.OnExist += new Transformation.TConditionEventHandle(transformation_OnExist);

            Transformation.TCondition t1 = new Transformation.TCondition();
            Transformation.TCondition t2 = new Transformation.TCondition();

            t1.Result = 0;
            t1.Signal = 0;

            t2.Result = 65535;
            t2.Signal = 65535;

            transformation.Insert(t1);
            transformation.Insert(t2);

            first = new Argument();
            second = new Argument();

            calibrationGraphic.CalculateScale();
            t_inserter = new InsertToText(InserterText);

            /*
            media = new Media();

            media.Args[0].Index = 0;
            media.Args[1].Index = 1;

            med = new Float[2];
            for (int i = 0; i < med.Length; i++)
            {
                med[i] = new Float();
            }
             */
        }
        public void GetFormat_WithTwoTransformations_ReturnsFirstFormat()
        {
            var first = new TransformationBase()
                            {
                                Format = "gif"
                            };

            var second = new Transformation(20, 30)
                             {
                                 Format = "png"
                             };

            var chained = new ChainedTransformation(first, second);

            Assert.That(chained.GetFormat() == "gif");
        }
        public void CloudinaryImage_WithChainedTransformation_Chains()
        {
            var first = new Transformation(35, 99)
                            {
                                Radius = 4,
                                Format = "png"
                            };
            var second = new TransformationBase()
                             {
                                 Angle = new Angle(45)
                             };

            var chained = new ChainedTransformation(first, second);

            string url = Url.CloudinaryImage("chained", chained).ToString();

            Assert.AreEqual("http://res.cloudinary.com/test/image/upload/w_35,h_99,r_4/a_45/chained.png", url);
        }
Beispiel #24
0
        // all of the contacts where second's edges intersect first's body
        // handles all cordinate transformation from each body to the world
        private IEnumerable<Contact> ContactsOnFirst(IBody first, IBody second)
        {
            IEdgeIntersector firstShape = first.CollisionShape;
            IEdgeIntersector secondShape = second.CollisionShape;
            Transform firstTransform = first.Dynamics.Transform;
            Transform secondTransform = second.Dynamics.Transform;
            var secondToFirst = new Transformation(secondTransform, firstTransform);

            if (IntersectStrats.HasStrategy(firstShape, secondShape))
            {
                return IntersectStrats.EnactStrategy(firstShape, secondShape, secondToFirst.Reverse()).Select(i => new Contact(i, first, second));
            }

            // general case             
            return
                // everything is converted to the firsts local transform coords
                secondShape.Edges.SelectMany(secondEdge => firstShape.FindIntersections(secondToFirst.TransformEdge(secondEdge)) 
                .Select(i => new Contact(firstTransform.ToWorldSpace(i), first, second))); // then to world coords
        }
        public void ChainedConditions()
        {
            Transformation transformation = new Transformation().IfCondition().AspectRatio("gt", "3:4").Then().Width(100).Crop("scale");
            Assert.AreEqual("if_ar_gt_3:4,c_scale,w_100", transformation.ToString(), "passing an operator and a value adds a condition");

            transformation = new Transformation().IfCondition().AspectRatio("gt", "3:4").And().Width("gt", 100).Then().Width(50).Crop("scale");
            Assert.AreEqual("if_ar_gt_3:4_and_w_gt_100,c_scale,w_50", transformation.ToString(), "should chaining condition with `and`");

            transformation = new Transformation().IfCondition().AspectRatio("gt", "3:4").And().Width("gt", 100).Or().Width("gt", 200).Then().Width(50).Crop("scale");
            Assert.AreEqual("if_ar_gt_3:4_and_w_gt_100_or_w_gt_200,c_scale,w_50", transformation.ToString(), "should chain conditions with `or`");

            transformation = new Transformation().IfCondition().AspectRatio(">", "3:4").And().Width("<=", 100).Or().Width("gt", 200).Then().Width(50).Crop("scale");
            Assert.AreEqual("if_ar_gt_3:4_and_w_lte_100_or_w_gt_200,c_scale,w_50", transformation.ToString(), "should translate operators");

            transformation = new Transformation().IfCondition().AspectRatio(">", "3:4").And().Width("<=", 100).Or().Width(">", 200).Then().Width(50).Crop("scale");
            Assert.AreEqual("if_ar_gt_3:4_and_w_lte_100_or_w_gt_200,c_scale,w_50", transformation.ToString(), "should translate operators");

            transformation = new Transformation().IfCondition().AspectRatio(">=", "3:4").And().PageCount(">=", 100).Or().PageCount("!=", 0).Then().Width(50).Crop("scale");
            Assert.AreEqual("if_ar_gte_3:4_and_pc_gte_100_or_pc_ne_0,c_scale,w_50", transformation.ToString(), "should translate operators");
        }
Beispiel #26
0
			/// <summary>Creates a new transformation, based upon an initial transformation, plus secondary yaw pitch and roll values</summary>
			/// <param name="Transformation">The initial transformation</param>
			/// <param name="Yaw">The yaw to apply</param>
			/// <param name="Pitch">The pitch to apply</param>
			/// <param name="Roll">The roll to apply</param>
			internal Transformation(Transformation Transformation, double Yaw, double Pitch, double Roll)
			{
				double sx = Transformation.X.X, sy = Transformation.X.Y, sz = Transformation.X.Z;
				double ux = Transformation.Y.X, uy = Transformation.Y.Y, uz = Transformation.Y.Z;
				double dx = Transformation.Z.X, dy = Transformation.Z.Y, dz = Transformation.Z.Z;
				double cosYaw = Math.Cos(Yaw);
				double sinYaw = Math.Sin(Yaw);
				double cosPitch = Math.Cos(-Pitch);
				double sinPitch = Math.Sin(-Pitch);
				double cosRoll = Math.Cos(Roll);
				double sinRoll = Math.Sin(Roll);
				Rotate(ref sx, ref sy, ref sz, ux, uy, uz, cosYaw, sinYaw);
				Rotate(ref dx, ref dy, ref dz, ux, uy, uz, cosYaw, sinYaw);
				Rotate(ref ux, ref uy, ref uz, sx, sy, sz, cosPitch, sinPitch);
				Rotate(ref dx, ref dy, ref dz, sx, sy, sz, cosPitch, sinPitch);
				Rotate(ref sx, ref sy, ref sz, dx, dy, dz, cosRoll, sinRoll);
				Rotate(ref ux, ref uy, ref uz, dx, dy, dz, cosRoll, sinRoll);
				this.X = new Vector3(sx, sy, sz);
				this.Y = new Vector3(ux, uy, uz);
				this.Z = new Vector3(dx, dy, dz);
			}
Beispiel #27
0
        /// <summary>
        /// Get the observations or data values for an economic data series. Corresponds to http://api.stlouisfed.org/fred/series/observations
        /// </summary>
        /// <param name="seriesId">The id for a series.</param>
        /// <param name="fileType">The type of file to send.</param>
        /// <param name="filename">The where to save the file.</param>
        /// <param name="observationStart">The start of the observation period.</param>
        /// <param name="observationEnd">The end of the observation period.</param>
        /// <param name="realtimeStart">The start of the real-time period.</param>
        /// <param name="realtimeEnd">The end of the real-time period.</param>
        /// <param name="vintageDates">A comma separated string of YYYY-MM-DD formatted dates in history (e.g. 2000-01-01,2005-02-24).
        ///  Vintage dates are used to download data as it existed on these specified dates in history. Vintage dates can be 
        ///  specified instead of a real-time period using realtime_start and realtime_end.
        ///
        /// Sometimes it may be useful to enter a vintage date that is not a date when the data values were revised. 
        /// For instance you may want to know the latest available revisions on 2001-09-11 (World Trade Center and 
        /// Pentagon attacks) or as of a Federal Open Market Committee (FOMC) meeting date. Entering a vintage date is 
        /// also useful to compare series on different releases with different release dates.</param>
        /// <param name="limit">The maximum number of results to return. An integer between 1 and 100000, optional, default: 100000</param>
        /// <param name="offset">non-negative integer, optional, default: 0</param>
        /// <param name="order">Sort results is ascending or descending observation_date order.</param>
        /// <param name="transformation">Type of data value transformation.</param>
        /// <param name="frequency">An optional parameter that indicates a lower frequency to aggregate values to. 
        /// The FRED frequency aggregation feature converts higher frequency data series into lower frequency data series 
        /// (e.g. converts a monthly data series into an annual data series). In FRED, the highest frequency data is daily, 
        /// and the lowest frequency data is annual. There are 3 aggregation methods available- average, sum, and end of period.</param>
        /// <param name="method">A key that indicates the aggregation method used for frequency aggregation.</param>
        /// <param name="outputType">Output type:
        /// 1. Observations by Real-Time Period
        /// 2. Observations by Vintage Date, All Observations
        /// 3. Observations by Vintage Date, New and Revised Observations Only
        /// 4.  Observations, Initial Release Only
        /// </param>
        /// <returns>Observations or data values for an economic data series.</returns>
        public void GetSeriesObservationsFile(string seriesId, FileType fileType, string filename,
            DateTime observationStart,
            DateTime observationEnd,
            DateTime realtimeStart,
            DateTime realtimeEnd,
            IEnumerable<DateTime> vintageDates, int limit = 100000,
            int offset = 0, SortOrder order = SortOrder.Ascending,
            Transformation transformation = Transformation.None,
            Frequency frequency = Frequency.None,
            AggregationMethod method = AggregationMethod.Average,
            OutputType outputType = OutputType.RealTime)
        {
            var extension = GetExtension(filename);

            if (fileType != FileType.Xml && fileType != FileType.Json && !extension.Equals(".zip", StringComparison.OrdinalIgnoreCase))
            {
                filename += ".zip";
            }

            GetSeriesObservationsStreamAsync(seriesId, fileType, new FileStream(filename, FileMode.Create), observationStart, observationEnd,
                realtimeStart, realtimeEnd, vintageDates, limit, offset, order, transformation, frequency, method, outputType).RunSynchronously();
        }
        public void IfElse()
        {
            List<Transformation> transformations = new List<Transformation>()
            {
                new Transformation().IfCondition("w_lt_200").Crop("fill").Height(120).Width(80),
                new Transformation().IfElse().Crop("fill").Height(90).Width(100)
            };
            var transformation = new Transformation(transformations);
            var sTransform = transformation.ToString();
            Assert.AreEqual("if_w_lt_200,c_fill,h_120,w_80/if_else,c_fill,h_90,w_100", sTransform, "should support if_else with transformation parameters");

            transformations = new List<Transformation>()
            {
                new Transformation().IfCondition("w_lt_200"),
                new Transformation().Crop("fill").Height(120).Width(80),
                new Transformation().IfElse(),
                new Transformation().Crop("fill").Height(90).Width(100)
            };
            transformation = new Transformation(transformations);
            sTransform = transformation.ToString();
            Assert.IsTrue(sTransform.Contains("/if_else/"), "if_else should be without any transformation parameters");
            Assert.AreEqual("if_w_lt_200/c_fill,h_120,w_80/if_else/c_fill,h_90,w_100", sTransform, "should be proper transformation string");
        }
 public UnitaryGateModel(int minimumSize, bool resizable, QuantumGateSymbol symbol, Transformation transformation) : base(minimumSize, resizable, true, false, symbol, transformation)
 {
 }
        public void SnapAToB(object A, object B, Transformation transformationB, List <Transformation> outTransformations)
        {
            SnapPoint PointA = (SnapPoint)A;
            SnapPoint PointB = (SnapPoint)B;

            if (Math.Abs(Vector3.Dot(PointA.Up, PointA.Normal)) > 0.001f)
            {
                throw new InvalidOperationException();
            }
            if (Math.Abs(Vector3.Dot(PointB.Up, PointB.Normal)) > 0.001f)
            {
                throw new InvalidOperationException();
            }

            var newPoint = new SnapPoint();

            newPoint.ClockwiseWinding = PointB.ClockwiseWinding;
            newPoint.Position         = Vector3.Transform(PointB.Position, transformationB.CreateMatrix());
            newPoint.Normal           = Vector3.Transform(PointB.Normal, transformationB.Rotation);
            newPoint.Up = Vector3.Transform(PointB.Up, transformationB.Rotation);

            PointB = newPoint;

            if (PointA.ClockwiseWinding == PointB.ClockwiseWinding)
            {
                return;
            }

            Vector3 sNormal             = PointA.Normal;
            Vector3 tNormal             = PointB.Normal;
            float   normalRotationAngle = (float)Math.Acos((Vector3.Dot(sNormal, tNormal))) + MathHelper.Pi;
            Vector3 normalRotationAxis  = Vector3.Normalize(Vector3.Cross(sNormal, tNormal));

            if (Math.Abs(Vector3.Dot(sNormal, tNormal)) > 0.999)
            {
                normalRotationAxis = PointB.Up * (-1);
            }

            Quaternion normalRotation = Quaternion.CreateFromAxisAngle(normalRotationAxis, normalRotationAngle);

            Vector3 sUp             = Vector3.Transform(PointA.Up, normalRotation);
            Vector3 tUp             = PointB.Up;
            float   upRotationAngle = (float)Math.Acos((Vector3.Dot(sUp, tUp)));

            Vector3 upRotationAxis;

            if (Math.Abs(Vector3.Dot(sUp, tUp)) > 0.999)
            {
                upRotationAxis = PointB.Normal * (-1);
            }
            else
            {
                upRotationAxis = Vector3.Normalize(Vector3.Cross(sUp, tUp));
            }

            if (Math.Abs(Vector3.Dot(upRotationAxis, tNormal)) < 0.999f)
            {
                throw new InvalidOperationException();
            }

            Quaternion upRotationMatrix = Quaternion.CreateFromAxisAngle(upRotationAxis, upRotationAngle);
            Quaternion Rotation         = upRotationMatrix * normalRotation;

            Vector3 translation = PointB.Position - Vector3.Transform(PointA.Position, Rotation);

            Quaternion     RotQuat        = Rotation;
            Transformation transformation = new Transformation(new Vector3(1, 1, 1), RotQuat, translation);


            //TODO: SCALING NOT SUPPORTED: transformation.Scaling *= transformationB.Scaling;

            /*transformation.Rotation = transformation.Rotation * transformationB.Rotation;
             * transformation.Translation += transformationB.Translation;*/


            outTransformations.Add(transformation);
        }
Beispiel #31
0
 public abstract Transformation InverseTransform(Transformation transformation);
Beispiel #32
0
        /// <summary>Applies world data to create a transformed model</summary>
        public void ApplyData(StaticObject Prototype, Vector3 Position, Transformation BaseTransformation, Transformation AuxTransformation, bool AccurateObjectDisposal, double AccurateObjectDisposalZOffset, double startingDistance, double endingDistance, double BlockLength, double TrackPosition, double Brightness, double ViewingDistance)
        {
            if (Prototype == null)
            {
                return;
            }
            StartingDistance = float.MaxValue;
            EndingDistance   = float.MinValue;
            Mesh.Vertices    = new VertexTemplate[Prototype.Mesh.Vertices.Length];
            // vertices
            for (int j = 0; j < Prototype.Mesh.Vertices.Length; j++)
            {
                if (Prototype.Mesh.Vertices[j] is ColoredVertex)
                {
                    Mesh.Vertices[j] = new ColoredVertex((ColoredVertex)Prototype.Mesh.Vertices[j]);
                }
                else
                {
                    Mesh.Vertices[j] = new Vertex((Vertex)Prototype.Mesh.Vertices[j]);
                }

                if (AccurateObjectDisposal)
                {
                    Mesh.Vertices[j].Coordinates.Rotate(AuxTransformation);
                    if (Mesh.Vertices[j].Coordinates.Z < StartingDistance)
                    {
                        StartingDistance = (float)Mesh.Vertices[j].Coordinates.Z;
                    }

                    if (Mesh.Vertices[j].Coordinates.Z > EndingDistance)
                    {
                        EndingDistance = (float)Mesh.Vertices[j].Coordinates.Z;
                    }

                    Mesh.Vertices[j].Coordinates = Prototype.Mesh.Vertices[j].Coordinates;
                }

                Mesh.Vertices[j].Coordinates.Rotate(AuxTransformation);
                Mesh.Vertices[j].Coordinates.Rotate(BaseTransformation);
                Mesh.Vertices[j].Coordinates += Position;
            }

            if (AccurateObjectDisposal)
            {
                StartingDistance += (float)AccurateObjectDisposalZOffset;
                EndingDistance   += (float)AccurateObjectDisposalZOffset;
            }

            // faces
            Mesh.Faces = new MeshFace[Prototype.Mesh.Faces.Length];
            for (int j = 0; j < Prototype.Mesh.Faces.Length; j++)
            {
                Mesh.Faces[j].Flags    = Prototype.Mesh.Faces[j].Flags;
                Mesh.Faces[j].Material = Prototype.Mesh.Faces[j].Material;
                Mesh.Faces[j].Vertices = new MeshFaceVertex[Prototype.Mesh.Faces[j].Vertices.Length];
                for (int k = 0; k < Prototype.Mesh.Faces[j].Vertices.Length; k++)
                {
                    Mesh.Faces[j].Vertices[k] = Prototype.Mesh.Faces[j].Vertices[k];
                    if (Mesh.Faces[j].Vertices[k].Normal.NormSquared() != 0.0)
                    {
                        Mesh.Faces[j].Vertices[k].Normal.Rotate(AuxTransformation);
                        Mesh.Faces[j].Vertices[k].Normal.Rotate(BaseTransformation);
                    }
                }
            }

            // materials
            Mesh.Materials = new MeshMaterial[Prototype.Mesh.Materials.Length];
            for (int j = 0; j < Prototype.Mesh.Materials.Length; j++)
            {
                Mesh.Materials[j]        = Prototype.Mesh.Materials[j];
                Mesh.Materials[j].Color *= Brightness;
            }

            const double minBlockLength = 20.0;

            if (BlockLength < minBlockLength)
            {
                BlockLength = BlockLength * System.Math.Ceiling(minBlockLength / BlockLength);
            }

            if (AccurateObjectDisposal)
            {
                StartingDistance += (float)TrackPosition;
                EndingDistance   += (float)TrackPosition;
                double z = BlockLength * System.Math.Floor(TrackPosition / BlockLength);
                startingDistance = System.Math.Min(z - BlockLength, (double)StartingDistance);
                endingDistance   = System.Math.Max(z + 2.0 * BlockLength, (double)EndingDistance);
                StartingDistance = (float)(BlockLength * System.Math.Floor(startingDistance / BlockLength));
                EndingDistance   = (float)(BlockLength * System.Math.Ceiling(endingDistance / BlockLength));
            }
            else
            {
                StartingDistance = (float)startingDistance;
                EndingDistance   = (float)endingDistance;
            }
        }
Beispiel #33
0
 public void QueryMacro(Transformation transformation) => UseRegexAnalysis(transformation, "{\\?.*|{%.*querystring", ReportTerms.IssueDescriptions.QueryMacro);
 public Builder withTransformation(Transformation transformation)
 {
     this.representationItem.transformation = transformation;
     return(this);
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="UploadPresetParams"/> class with result object.
        /// </summary>
        /// <param name="preset">The preset returned from API.</param>
        public UploadPresetParams(GetUploadPresetResult preset)
        {
            Name     = preset.Name;
            Unsigned = preset.Unsigned;

            if (preset.Settings == null)
            {
                return;
            }

            DisallowPublicId = preset.Settings.DisallowPublicId;
            Backup           = preset.Settings.Backup;
            Type             = preset.Settings.Type;

            if (preset.Settings.Tags != null)
            {
                if (preset.Settings.Tags.Type == JTokenType.String)
                {
                    Tags = preset.Settings.Tags.ToString();
                }
                else if (preset.Settings.Tags.Type == JTokenType.Array)
                {
                    Tags = string.Join(",", preset.Settings.Tags.Values <string>().ToArray());
                }
            }

            Invalidate              = preset.Settings.Invalidate;
            UseFilename             = preset.Settings.UseFilename;
            UniqueFilename          = preset.Settings.UniqueFilename;
            DiscardOriginalFilename = preset.Settings.DiscardOriginalFilename;
            NotificationUrl         = preset.Settings.NotificationUrl;
            Proxy      = preset.Settings.Proxy;
            Folder     = preset.Settings.Folder;
            Overwrite  = preset.Settings.Overwrite;
            RawConvert = preset.Settings.RawConvert;

            if (preset.Settings.Context != null)
            {
                Context = new StringDictionary();
                foreach (JProperty prop in preset.Settings.Context)
                {
                    Context.Add(prop.Name, prop.Value.ToString());
                }
            }

            if (preset.Settings.AllowedFormats != null)
            {
                if (preset.Settings.AllowedFormats.Type == JTokenType.String)
                {
                    AllowedFormats = preset.Settings.AllowedFormats.ToString().Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                }
                else if (preset.Settings.AllowedFormats.Type == JTokenType.Array)
                {
                    AllowedFormats = preset.Settings.AllowedFormats.Select(t => t.ToString()).ToArray();
                }
            }

            Moderation = preset.Settings.Moderation;
            Format     = preset.Settings.Format;

            if (preset.Settings.Transformation != null)
            {
                if (preset.Settings.Transformation.Type == JTokenType.String)
                {
                    Transformation = preset.Settings.Transformation.ToString();
                }
                else if (preset.Settings.Transformation.Type == JTokenType.Array)
                {
                    var dict = new Dictionary <string, object>();
                    foreach (JObject obj in preset.Settings.Transformation)
                    {
                        foreach (var prop in obj)
                        {
                            dict.Add(prop.Key, prop.Value.ToString());
                        }
                    }

                    Transformation = new Transformation(dict);
                }
            }

            if (preset.Settings.EagerTransforms != null)
            {
                EagerTransforms = new List <object>();
                foreach (JToken token in preset.Settings.EagerTransforms)
                {
                    if (token.Type == JTokenType.String)
                    {
                        EagerTransforms.Add(token.ToString());
                    }
                    else if (token.Type == JTokenType.Array)
                    {
                        var dict = new Dictionary <string, object>();
                        foreach (JObject obj in token)
                        {
                            foreach (var prop in obj)
                            {
                                dict.Add(prop.Key, prop.Value.ToString());
                            }
                        }

                        EagerTransforms.Add(new Transformation(dict));
                    }
                }
            }

            Exif            = preset.Settings.Exif;
            Colors          = preset.Settings.Colors;
            Faces           = preset.Settings.Faces;
            QualityAnalysis = preset.Settings.QualityAnalysis;

            if (preset.Settings.FaceCoordinates != null)
            {
                if (preset.Settings.FaceCoordinates.Type == JTokenType.String)
                {
                    FaceCoordinates = preset.Settings.FaceCoordinates.ToString();
                }
                else if (preset.Settings.FaceCoordinates.Type == JTokenType.Array)
                {
                    var fc = new List <Rectangle>();
                    foreach (JToken token in preset.Settings.FaceCoordinates)
                    {
                        fc.Add(new Rectangle(token[0].Value <int>(), token[1].Value <int>(), token[2].Value <int>(), token[3].Value <int>()));
                    }
                }
            }

            ImageMetadata        = preset.Settings.ImageMetadata;
            EagerAsync           = preset.Settings.EagerAsync;
            EagerNotificationUrl = preset.Settings.EagerNotificationUrl;
            Categorization       = preset.Settings.Categorization;
            AutoTagging          = preset.Settings.AutoTagging;
            Detection            = preset.Settings.Detection;
            SimilaritySearch     = preset.Settings.SimilaritySearch;
            Ocr  = preset.Settings.Ocr;
            Live = preset.Settings.Live;
        }
Beispiel #36
0
        public static Cartesian2DPoints Reflect(this Cartesian2DPoints figure, LineType lineType)
        {
            var result = (Cartesian2DPoints)Transformation.Reflect(figure.Points, lineType);

            return(result);
        }
Beispiel #37
0
        public static Cartesian2DPoints Rotate(this Cartesian2DPoints figure, DegreeType degreeType)
        {
            var result = (Cartesian2DPoints)Transformation.Rotate(figure.Points, degreeType);

            return(result);
        }
Beispiel #38
0
        public void RenderBasicScene()
        {
            Sphere floor = new Sphere();

            floor.Transform         = Transformation.Scaling(10, 0.01, 10);
            floor.Material          = new Material();
            floor.Material.Color    = new Color(1, 0.9, 0.9);
            floor.Material.Specular = 0;

            Sphere left_wall = new Sphere();

            left_wall.Transform = Transformation.Translation(0, 0, 5) *
                                  Transformation.Rotation_y(-Math.PI / 4) *
                                  Transformation.Rotation_x(Math.PI / 2) *
                                  Transformation.Scaling(10, 0.01, 10);
            left_wall.Material = floor.Material;

            Sphere right_wall = new Sphere();

            right_wall.Transform = Transformation.Translation(0, 0, 5) *
                                   Transformation.Rotation_y(Math.PI / 4) *
                                   Transformation.Rotation_x(Math.PI / 2) *
                                   Transformation.Scaling(10, 0.01, 10);
            right_wall.Material = floor.Material;

            Sphere middle = new Sphere();

            middle.Transform         = Transformation.Translation(-0.5, 1, 0.5);
            middle.Material          = new Material();
            middle.Material.Color    = new Color(0.1, 1, 0.5);
            middle.Material.Diffuse  = 0.7;
            middle.Material.Specular = 0.3;

            Sphere right = new Sphere();

            right.Transform         = Transformation.Translation(1.5, 0.5, -0.5) * Transformation.Scaling(0.5, 0.5, 0.5);
            right.Material          = new Material();
            right.Material.Color    = new Color(0.5, 1, 0.1);
            right.Material.Diffuse  = 0.7;
            right.Material.Specular = 0.3;

            Sphere left = new Sphere();

            left.Transform         = Transformation.Translation(-1.5, 0.33, -0.75) * Transformation.Scaling(0.33, 0.33, 0.33);
            left.Material          = new Material();
            left.Material.Color    = new Color(1, 0.8, 0.1);
            left.Material.Diffuse  = 0.7;
            left.Material.Specular = 0.3;

            World world = new World();

            world.Shapes = new List <Shape> {
                left, right, middle, floor, left_wall, right_wall
            };
            world.Lights = new List <ILight> {
                new PointLight(new Point(-10, 10, -10), new Color(1, 1, 1))
            };

            Camera camera = new Camera(200, 120, Math.PI / 3);

            camera.Transform = Transformation.ViewTransform(new Point(0, 1.5, -5),
                                                            new Point(0, 1, 0),
                                                            new Vector(0, 1, 0));

            Canvas canvas = camera.Render(world);


            string filename = imagePath.ToString() + "FirstBasicScene.ppm";

            if (File.Exists(filename))
            {
                File.Delete(filename);
            }
            FileStream   stream = File.OpenWrite(filename);
            StreamWriter writer = new StreamWriter(stream);

            PpmWriter.WriteCanvasToPpm(writer, canvas);
            writer.Close();
        }
Beispiel #39
0
        public static Cartesian2DPoints Translate(this Cartesian2DPoints figure, DisplacementVector displacementVector)
        {
            var result = (Cartesian2DPoints)Transformation.Translate(figure.Points, displacementVector.TopHorizontal, displacementVector.BottomVertical);

            return(result);
        }
Beispiel #40
0
            public ScriptInput(Transformation transformation)
            {
                DefaultCollections = new HashSet <string>(transformation.Collections, StringComparer.OrdinalIgnoreCase);

                if (string.IsNullOrWhiteSpace(transformation.Script))
                {
                    return;
                }

                if (transformation.IsEmptyScript == false)
                {
                    Transformation = new PatchRequest(transformation.Script, PatchRequestType.RavenEtl);
                }

                if (transformation.Counters.CollectionToLoadBehaviorFunction != null)
                {
                    _collectionToLoadCounterBehaviorFunction = transformation.Counters.CollectionToLoadBehaviorFunction;
                }

                if (transformation.TimeSeries.CollectionToLoadBehaviorFunction != null)
                {
                    _collectionToLoadTimeSeriesBehaviorFunction = transformation.TimeSeries.CollectionToLoadBehaviorFunction;
                }

                if (transformation.CollectionToDeleteDocumentsBehaviorFunction != null)
                {
                    _collectionToDeleteDocumentBehaviorFunction = transformation.CollectionToDeleteDocumentsBehaviorFunction;
                }

                if (HasLoadCounterBehaviors || HasDeleteDocumentsBehaviors || HasLoadTimeSeriesBehaviors)
                {
                    BehaviorFunctions = new PatchRequest(transformation.Script, PatchRequestType.EtlBehaviorFunctions);
                }

                if (transformation.IsEmptyScript == false)
                {
                    LoadToCollections = transformation.GetCollectionsFromScript();
                }

                foreach (var collection in LoadToCollections)
                {
                    IdPrefixForCollection[collection] = DocumentConventions.DefaultTransformCollectionNameToDocumentIdPrefix(collection);
                }

                if (transformation.Collections == null)
                {
                    return;
                }

                _collectionNameComparisons = new Dictionary <string, Dictionary <string, bool> >(transformation.Collections.Count);

                foreach (var sourceCollection in transformation.Collections)
                {
                    _collectionNameComparisons[sourceCollection] = new Dictionary <string, bool>(transformation.Collections.Count);

                    foreach (var loadToCollection in LoadToCollections)
                    {
                        _collectionNameComparisons[sourceCollection][loadToCollection] = string.Compare(sourceCollection, loadToCollection, StringComparison.OrdinalIgnoreCase) == 0;
                    }
                }
            }
Beispiel #41
0
        public int CreateStaticObject(StaticObject Prototype, Vector3 Position, Transformation AuxTransformation, Matrix4D Rotate, Matrix4D Translate, bool AccurateObjectDisposal, double AccurateObjectDisposalZOffset, double StartingDistance, double EndingDistance, double BlockLength, double TrackPosition, double Brightness)
        {
            if (Prototype == null)
            {
                return(-1);
            }

            float startingDistance = float.MaxValue;
            float endingDistance   = float.MinValue;

            if (AccurateObjectDisposal)
            {
                foreach (VertexTemplate vertex in Prototype.Mesh.Vertices)
                {
                    OpenBveApi.Math.Vector3 Coordinates = vertex.Coordinates;
                    Coordinates.Rotate(AuxTransformation);

                    if (Coordinates.Z < StartingDistance)
                    {
                        startingDistance = (float)Coordinates.Z;
                    }

                    if (Coordinates.Z > EndingDistance)
                    {
                        endingDistance = (float)Coordinates.Z;
                    }
                }

                startingDistance += (float)AccurateObjectDisposalZOffset;
                endingDistance   += (float)AccurateObjectDisposalZOffset;
            }

            const double minBlockLength = 20.0;

            if (BlockLength < minBlockLength)
            {
                BlockLength *= Math.Ceiling(minBlockLength / BlockLength);
            }

            if (AccurateObjectDisposal)
            {
                startingDistance += (float)TrackPosition;
                endingDistance   += (float)TrackPosition;
                double z = BlockLength * Math.Floor(TrackPosition / BlockLength);
                StartingDistance = Math.Min(z - BlockLength, startingDistance);
                EndingDistance   = Math.Max(z + 2.0 * BlockLength, endingDistance);
                startingDistance = (float)(BlockLength * Math.Floor(StartingDistance / BlockLength));
                endingDistance   = (float)(BlockLength * Math.Ceiling(EndingDistance / BlockLength));
            }
            else
            {
                startingDistance = (float)StartingDistance;
                endingDistance   = (float)EndingDistance;
            }

            StaticObjectStates.Add(new ObjectState
            {
                Prototype        = Prototype,
                Translation      = Translate,
                Rotate           = Rotate,
                Brightness       = Brightness,
                StartingDistance = startingDistance,
                EndingDistance   = endingDistance
            });

            foreach (MeshFace face in Prototype.Mesh.Faces)
            {
                switch (face.Flags & MeshFace.FaceTypeMask)
                {
                case MeshFace.FaceTypeTriangles:
                    InfoTotalTriangles++;
                    break;

                case MeshFace.FaceTypeTriangleStrip:
                    InfoTotalTriangleStrip++;
                    break;

                case MeshFace.FaceTypeQuads:
                    InfoTotalQuads++;
                    break;

                case MeshFace.FaceTypeQuadStrip:
                    InfoTotalQuadStrip++;
                    break;

                case MeshFace.FaceTypePolygon:
                    InfoTotalPolygon++;
                    break;
                }
            }

            return(StaticObjectStates.Count - 1);
        }
 public void SnapBToA(object A, object B, Transformation transformationA, List <Transformation> outTransformations)
 {
     throw new NotImplementedException();
 }
Beispiel #43
0
        protected override void OnLoad(EventArgs e)
        {
            _treeModify = false;

            testLayer = viewportLayout1.Layers.Add("testLayer", Color.Red);
            int testLayer1 = viewportLayout1.Layers.Add("onPlane", Color.Blue);

            spatialLayer = viewportLayout1.Layers.Add("spatialLayer", Color.Green);

            viewportLayout1.Layers[0].Name = "Default";
            //viewportLayout1.Layers[0].Color = Color.Gray;

            //viewportLayout1.Layers[spatialLayer].Visible = true;
            //viewportLayout1.Layers[0].Visible = false;

            //DatabaseIfc db = new DatabaseIfc("C:\\devdept\\IFC Model.ifc");
            //DatabaseIfc db = new DatabaseIfc("C:\\devdept\\IFC\\Martti_Ahtisaaren_RAK.ifc");                //gym exception
            //DatabaseIfc db = new DatabaseIfc("C:\\devDept\\IFC\\MOD-Padrão\\MOD-Padrão.ifc");
            //DatabaseIfc db = new DatabaseIfc("C:\\devDept\\IFC\\IFC Data\\Blueberry031105_Complete_optimized.ifc");
            //DatabaseIfc db = new DatabaseIfc("C:\\devDept\\IFC\\IFC Data\\Clinic_Handover_WithProperty3.ifc");      //Gym exception
            //DatabaseIfc db = new DatabaseIfc("C:\\devDept\\IFC\\IFC Data\\Duplex_A_20110907.ifc");
            //DatabaseIfc db = new DatabaseIfc("C:\\devDept\\IFC\\IFC Data\\NER-38d.ifc");
            //DatabaseIfc db = new DatabaseIfc("C:\\devDept\\IFC\\IFC Data\\NHS Office.ifc");
            //DatabaseIfc db = new DatabaseIfc("C:\\devDept\\IFC\\IFC Data\\Office_A_20110811.ifc");
            //DatabaseIfc db = new DatabaseIfc("C:\\devDept\\IFC\\IFC Data\\porur duplex.ifc");
            //DatabaseIfc db = new DatabaseIfc("C:\\devDept\\IFC\\IFC Data\\c_rvt8_Townhouse.ifc");

            //DatabaseIfc db = new DatabaseIfc("C:\\devDept\\IFC\\IFC Samples\\01 Fire Protection.ifc");
            DatabaseIfc db = new DatabaseIfc("C:\\devDept\\IFC\\IFC Samples\\ArchiCAD IFC Buildsoft.ifc");
            //DatabaseIfc db = new DatabaseIfc("C:\\devDept\\IFC\\IFC Samples\\Clinic_S_20110715_optimized.ifc");

            IfcProject project = db.Project;

            List <IfcBuildingElement> ifcBuildingElement = project.Extract <IfcBuildingElement>();

            List <IfcSpatialElement> ifcSpatialElement = project.Extract <IfcSpatialElement>();

            List <IfcDistributionElement> ifcDistributionElement = project.Extract <IfcDistributionElement>();

            //List<IfcRoot> ifcRoot = project.Extract<IfcRoot>();

            foreach (IfcSpatialElement ifcElement in ifcSpatialElement)  //ifcmesh
            {
                Entity eyeElement = null;

                Transformation elementTrs = new Transformation(1);

                if (ifcElement.Placement != null)
                {
                    elementTrs = Conversion.getPlacementTransformtion(ifcElement.Placement);
                }
                if (ifcElement.Representation != null)
                {
                    eyeElement = Conversion.getEntityFromIfcProductRepresentation(ifcElement.Representation, viewportLayout1, elementTrs);
                }
                if (eyeElement != null)
                {
                    eyeElement.TransformBy(elementTrs);

                    if (eyeElement is BlockReference)
                    {
                        UtilityIfc.loadProperties((IfcBlockReference)eyeElement, ifcElement);
                    }
                    else
                    {
                        IfcMesh ifcMesh;

                        Mesh eyeElementMesh;

                        if (eyeElement is Solid)
                        {
                            Solid eyeElementSolid = (Solid)eyeElement;

                            eyeElementMesh = eyeElementSolid.ConvertToMesh();
                        }
                        else
                        {
                            eyeElementMesh = (Mesh)eyeElement;
                        }
                        Color           color = eyeElementMesh.Color;
                        colorMethodType cmt   = eyeElementMesh.ColorMethod;

                        ifcMesh = new IfcMesh(eyeElementMesh.Vertices, eyeElementMesh.Triangles);

                        ifcMesh.Color       = color;
                        ifcMesh.ColorMethod = cmt;

                        UtilityIfc.loadProperties(ifcMesh, ifcElement);

                        eyeElement = ifcMesh;
                    }
                    viewportLayout1.Entities.Add(eyeElement, spatialLayer);
                }
            }

            foreach (IfcBuildingElement ifcElement in ifcBuildingElement)
            {
                if (ifcElement.GlobalId.StartsWith("3LHl4aR6j6bfwjDqKa2Mh9") && /**/ ifcElement.Decomposes == null)
                {
                    Entity eyeElement = Conversion.getEntityFromIfcElement(ifcElement, viewportLayout1);

                    if (eyeElement != null)
                    {
                        viewportLayout1.Entities.Add(eyeElement, 0);
                    }
                }
            }

            foreach (IfcDistributionElement ifcElement in ifcDistributionElement)
            {
                if (/*ifcElement.GlobalId.StartsWith("2O_tcxRRn1gegwp_L0mkmi") &&/**/ ifcElement.Decomposes == null)
                {
                    Entity eyeElement = Conversion.getEntityFromIfcElement(ifcElement, viewportLayout1);

                    if (eyeElement != null)
                    {
                        viewportLayout1.Entities.Add(eyeElement, 0);
                    }
                }
            }

            debug += Conversion.Debug;

            Debug.WriteLine(debug);

            TreeViewManager.PopulateTree(modelTree, viewportLayout1.Entities.ToList(), viewportLayout1.Blocks);

            viewportLayout1.ZoomFit();
        }
Beispiel #44
0
 /// <summary>
 /// Creates a transformation or replaces an already existing transformation
 /// under an existing streaming job.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='transformation'>
 /// The definition of the transformation that will be used to create a new
 /// transformation or replace the existing one under the streaming job.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group. The name is case insensitive.
 /// </param>
 /// <param name='jobName'>
 /// The name of the streaming job.
 /// </param>
 /// <param name='transformationName'>
 /// The name of the transformation.
 /// </param>
 /// <param name='ifMatch'>
 /// The ETag of the transformation. Omit this value to always overwrite the
 /// current transformation. Specify the last-seen ETag value to prevent
 /// accidentally overwriting concurrent changes.
 /// </param>
 /// <param name='ifNoneMatch'>
 /// Set to '*' to allow a new transformation to be created, but to prevent
 /// updating an existing transformation. Other values will result in a 412
 /// Pre-condition Failed response.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <Transformation> CreateOrReplaceAsync(this ITransformationsOperations operations, Transformation transformation, string resourceGroupName, string jobName, string transformationName, string ifMatch = default(string), string ifNoneMatch = default(string), CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.CreateOrReplaceWithHttpMessagesAsync(transformation, resourceGroupName, jobName, transformationName, ifMatch, ifNoneMatch, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Beispiel #45
0
 public abstract Transformation Transform(Transformation transformation);
Beispiel #46
0
        public IProjectionController <Transformation> ProjectFrom(IView view, Transformation transformationOnView)
        {
            ProjectionGraph graph = BuildProjectionGraph();

            return(new ProjectionBuilder <Transformation>(graph.GetViewVertex(view), transformationOnView, new TransformationProjectionVisitor(), graph));
        }
Beispiel #47
0
        public void TestShouldSortDefinedVariable()
        {
            var t = new Transformation().Variable("$second", 1).Variable("$first", 2);

            Assert.AreEqual("$first_2,$second_1", t.ToString());
        }
Beispiel #48
0
 internal static int CreateStaticObject(StaticObject Prototype, Vector3 Position, Transformation BaseTransformation, Transformation AuxTransformation, bool AccurateObjectDisposal, double StartingDistance, double EndingDistance, double BlockLength, double TrackPosition)
 {
     return(CreateStaticObject(Prototype, Position, BaseTransformation, AuxTransformation, AccurateObjectDisposal, 0.0, StartingDistance, EndingDistance, BlockLength, TrackPosition, 1.0));
 }
Beispiel #49
0
        internal static int CreateStaticObject(StaticObject Prototype, Vector3 Position, Transformation BaseTransformation, Transformation AuxTransformation, bool AccurateObjectDisposal, double AccurateObjectDisposalZOffset, double StartingDistance, double EndingDistance, double BlockLength, double TrackPosition, double Brightness)
        {
            if (Prototype == null)
            {
                return(-1);
            }
            int a = ObjectsUsed;

            if (a >= Objects.Length)
            {
                Array.Resize <StaticObject>(ref Objects, Objects.Length << 1);
            }
            Objects[a] = new StaticObject();
            Objects[a].ApplyData(Prototype, Position, BaseTransformation, AuxTransformation, AccurateObjectDisposal, AccurateObjectDisposalZOffset, StartingDistance, EndingDistance, BlockLength, TrackPosition, Brightness);
            for (int i = 0; i < Prototype.Mesh.Faces.Length; i++)
            {
                switch (Prototype.Mesh.Faces[i].Flags & MeshFace.FaceTypeMask)
                {
                case MeshFace.FaceTypeTriangles:
                    Game.InfoTotalTriangles++;
                    break;

                case MeshFace.FaceTypeTriangleStrip:
                    Game.InfoTotalTriangleStrip++;
                    break;

                case MeshFace.FaceTypeQuads:
                    Game.InfoTotalQuads++;
                    break;

                case MeshFace.FaceTypeQuadStrip:
                    Game.InfoTotalQuadStrip++;
                    break;

                case MeshFace.FaceTypePolygon:
                    Game.InfoTotalPolygon++;
                    break;
                }
            }
            ObjectsUsed++;
            return(a);
        }
Beispiel #50
0
        internal pChannelTab(string name, object tag, Vector2 position, float depth, bool flip, bool skinnable, Transformation hoverEffect, bool canClose)
            : base(name, tag, position, depth, flip, skinnable, hoverEffect)
        {
            this.canClose = canClose;

            if (canClose)
            {
                closeButton = new pSprite(TextureManager.Load(@"selection-tab-close", SkinSource.Osu), Fields.TopLeft, Origins.TopLeft, Clocks.Game, position, depth + 0.0002f, true, new Color(255, 255, 255, 1));
                closeButton.OriginPosition = new Vector2(-49, 8);
                closeButton.Tag            = this;
                SpriteCollection.Add(closeButton);

                closeButtonOver = new pSprite(TextureManager.Load(@"selection-tab-close", SkinSource.Osu), Fields.TopLeft, Origins.TopLeft, Clocks.Game, position, depth + 0.0002f, true, new Color(255, 255, 255, 1));
                closeButtonOver.OriginPosition = new Vector2(-49, 8);
                closeButtonOver.HandleInput    = true;
                closeButtonOver.OnClick       += closeButton_OnClick;
                closeButtonOver.Tag            = this;
                closeButtonOver.HoverPriority  = -10;
                closeButtonOver.OnHover       += delegate { closeButtonOver.Alpha = tabBackground.Alpha * 1; closeButtonOver.InitialColour = Color.White; };
                closeButtonOver.OnHoverLost   += delegate { closeButtonOver.Alpha = tabBackground.Alpha * 0.01f; closeButtonOver.InitialColour = new Color(255, 255, 255, 1); };
                SpriteCollection.Add(closeButtonOver);

                tabBackground.OnHover     += tabBackground_OnHover;
                tabBackground.OnHoverLost += tabBackground_OnHoverLost;
            }
        }
Beispiel #51
0
        /// <inheritdoc/>
        public override void CreateObject(Vector3 Position, Transformation WorldTransformation, Transformation LocalTransformation,
                                          int SectionIndex, double StartingDistance, double EndingDistance,
                                          double TrackPosition, double Brightness, bool DuplicateMaterials = false)
        {
            bool[] free    = new bool[Objects.Length];
            bool   anyfree = false;
            bool   allfree = true;

            for (int i = 0; i < Objects.Length; i++)
            {
                free[i] = Objects[i].IsFreeOfFunctions();
                if (free[i])
                {
                    anyfree = true;
                }
                else
                {
                    allfree = false;
                }
            }
            if (anyfree && !allfree && Objects.Length > 1)
            {
                //Optimise a little: If *all* are free of functions, this can safely be converted into a static object without regard to below
                if (LocalTransformation.X != Vector3.Right || LocalTransformation.Y != Vector3.Down || LocalTransformation.Z != Vector3.Forward)
                {
                    //HACK:
                    //An animated object containing a mix of functions and non-functions and using yaw, pitch or roll must not be converted into a mix
                    //of animated and static objects, as this causes rounding differences....
                    anyfree = false;
                }
            }
            if (anyfree)
            {
                for (int i = 0; i < Objects.Length; i++)
                {
                    if (Objects[i].States.Length != 0)
                    {
                        if (free[i])
                        {
                            Matrix4D transformationMatrix = (Matrix4D) new Transformation(LocalTransformation, WorldTransformation);
                            Matrix4D mat = Matrix4D.Identity;
                            mat *= Objects[i].States[0].Translation;
                            mat *= transformationMatrix;
                            double zOffset = Objects[i].States[0].Translation.ExtractTranslation().Z * -1.0;                                     //To calculate the Z-offset within the object, we want the untransformed co-ordinates, not the world co-ordinates

                            currentHost.CreateStaticObject(Objects[i].States[0].Prototype, LocalTransformation, mat, Matrix4D.CreateTranslation(Position.X, Position.Y, -Position.Z), zOffset, StartingDistance, EndingDistance, TrackPosition, Brightness);
                        }
                        else
                        {
                            Objects[i].CreateObject(Position, WorldTransformation, LocalTransformation, SectionIndex, TrackPosition, Brightness);
                        }
                    }
                }
            }
            else
            {
                for (int i = 0; i < Objects.Length; i++)
                {
                    if (Objects[i].States.Length != 0)
                    {
                        Objects[i].CreateObject(Position, WorldTransformation, LocalTransformation, SectionIndex, TrackPosition, Brightness);
                    }
                }
            }
            if (this.Sounds == null)
            {
                return;
            }
            for (int i = 0; i < Sounds.Length; i++)
            {
                if (this.Sounds[i] == null)
                {
                    continue;
                }
                (Sounds[i] as WorldSound)?.CreateSound(Position + Sounds[i].Position, WorldTransformation, LocalTransformation, SectionIndex, TrackPosition);
                (Sounds[i] as AnimatedWorldObjectStateSound)?.Create(Position, WorldTransformation, LocalTransformation, SectionIndex, TrackPosition, Brightness);
            }
        }
Beispiel #52
0
 /// <summary>Callback function to create the object within the world</summary>
 public override void CreateObject(Vector3 Position, Transformation BaseTransformation, Transformation AuxTransformation,
                                   int SectionIndex, double StartingDistance, double EndingDistance,
                                   double TrackPosition, double Brightness, bool DuplicateMaterials = false)
 {
     currentHost.CreateStaticObject(this, Position, BaseTransformation, AuxTransformation, 0.0, StartingDistance, EndingDistance, TrackPosition, Brightness);
 }
Beispiel #53
0
 /// <summary>
 /// Creates a transformation or replaces an already existing transformation
 /// under an existing streaming job.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='transformation'>
 /// The definition of the transformation that will be used to create a new
 /// transformation or replace the existing one under the streaming job.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group. The name is case insensitive.
 /// </param>
 /// <param name='jobName'>
 /// The name of the streaming job.
 /// </param>
 /// <param name='transformationName'>
 /// The name of the transformation.
 /// </param>
 /// <param name='ifMatch'>
 /// The ETag of the transformation. Omit this value to always overwrite the
 /// current transformation. Specify the last-seen ETag value to prevent
 /// accidentally overwriting concurrent changes.
 /// </param>
 /// <param name='ifNoneMatch'>
 /// Set to '*' to allow a new transformation to be created, but to prevent
 /// updating an existing transformation. Other values will result in a 412
 /// Pre-condition Failed response.
 /// </param>
 public static Transformation CreateOrReplace(this ITransformationsOperations operations, Transformation transformation, string resourceGroupName, string jobName, string transformationName, string ifMatch = default(string), string ifNoneMatch = default(string))
 {
     return(operations.CreateOrReplaceAsync(transformation, resourceGroupName, jobName, transformationName, ifMatch, ifNoneMatch).GetAwaiter().GetResult());
 }
 protected IterativeStream(StreamExecutionEnvironment environment, Transformation <T> transformation) : base(environment, transformation)
 {
 }
Beispiel #55
0
        public IProjectionController <Transformation> ProjectFrom(ISceneNode sceneNode, Transformation transformation)
        {
            ProjectionGraph graph = BuildProjectionGraph();

            return(new ProjectionBuilder <Transformation>(graph.GetSceneVertex(sceneNode), transformation, new TransformationProjectionVisitor(), graph));
        }
        // processes the camera frame
        private void ProcessCameraFrame(KinectInterop.SensorData sensorData, Capture capture)
        {
            // check for color & depth sync
            if (isSyncDepthAndColor && (capture.Color == null || capture.Depth == null))
            {
                return;
            }

            try
            {
                // color frame
                if (capture.Color != null && rawColorImage != null)
                {
                    //if (kinectPlayback != null)
                    //    WaitForPlaybackTimestamp("color", capture.Color.DeviceTimestamp.Ticks);

                    lock (colorFrameLock)
                    {
                        capture.Color.CopyBytesTo(rawColorImage, 0, 0, rawColorImage.Length);

                        rawColorTimestamp = (ulong)capture.Color.DeviceTimestamp.Ticks;
                        colorFrameNumber  = currentFrameNumber;
                        //Debug.Log("RawColorTimestamp: " + rawColorTimestamp);
                    }
                }

                // depth frame
                if (capture.Depth != null && rawDepthImage != null)
                {
                    //if (kinectPlayback != null)
                    //    WaitForPlaybackTimestamp("depth", capture.Depth.DeviceTimestamp.Ticks);

                    lock (depthFrameLock)
                    {
                        capture.Depth.CopyTo(rawDepthImage, 0, 0, rawDepthImage.Length);

                        rawDepthTimestamp = (ulong)capture.Depth.DeviceTimestamp.Ticks;
                        depthFrameNumber  = currentFrameNumber;
                        //Debug.Log("RawDepthTimestamp: " + rawDepthTimestamp);
                    }
                }

                // infrared frame
                if (capture.IR != null && rawInfraredImage != null)
                {
                    //if (kinectPlayback != null)
                    //    WaitForPlaybackTimestamp("ir", capture.IR.DeviceTimestamp.Ticks);

                    lock (infraredFrameLock)
                    {
                        capture.IR.CopyTo(rawInfraredImage, 0, 0, rawInfraredImage.Length);

                        rawInfraredTimestamp = (ulong)capture.IR.DeviceTimestamp.Ticks;
                        infraredFrameNumber  = currentFrameNumber;
                        //Debug.Log("RawInfraredTimestamp: " + rawInfraredTimestamp);
                    }
                }

                // transformation data frames
                if ((depth2ColorDataFrame != null || color2DepthDataFrame != null) && capture.Color != null && capture.Depth != null)
                {
                    if (coordMapperTransform == null)
                    {
                        coordMapperTransform = coordMapper.CreateTransformation();
                    }

                    if (depth2ColorDataFrame != null)
                    {
                        lock (depth2ColorFrameLock)
                        {
                            using (Image d2cColorData = coordMapperTransform.ColorImageToDepthCamera(capture))
                            {
                                d2cColorData.CopyTo <byte>(depth2ColorDataFrame, 0, 0, depth2ColorDataFrame.Length);
                                lastDepth2ColorFrameTime = (ulong)capture.Depth.DeviceTimestamp.Ticks;
                            }
                        }
                    }

                    if (color2DepthDataFrame != null)
                    {
                        lock (color2DepthFrameLock)
                        {
                            using (Image c2dDepthData = coordMapperTransform.DepthImageToColorCamera(capture))
                            {
                                c2dDepthData.CopyTo <ushort>(color2DepthDataFrame, 0, 0, color2DepthDataFrame.Length);
                                lastColor2DepthFrameTime = (ulong)capture.Color.DeviceTimestamp.Ticks;
                            }
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                Debug.LogException(ex);
            }
        }
Beispiel #57
0
 public void TestUrlClone()
 {
     // url should be cloneable
     Transformation t1 = new Transformation().Angle(12);
     Transformation t2 = new Transformation().Crop("fill");
     Url url1 = api.UrlImgUp.Transform(t1);
     Url url2 = url1.Clone().Action("go").Transform(t2);
     string result1 = url1.BuildUrl("test");
     string result2 = url2.BuildUrl("test");
     Assert.AreEqual("http://res.cloudinary.com/testcloud/image/upload/a_12/test", result1);
     Assert.AreEqual("http://res.cloudinary.com/testcloud/image/go/c_fill/test", result2);
 }
Beispiel #58
0
 /// <summary>Creates a static object within the world of the host application, and returns the ObjectManager ID</summary>
 /// <param name="Prototype">The prototype (un-transformed) static object</param>
 /// <param name="AuxTransformation">The secondary rail transformation to apply NOTE: Only used for object disposal calcs</param>
 /// <param name="Rotate">The rotation matrix to apply</param>
 /// <param name="Translate">The translation matrix to apply</param>
 /// <param name="AccurateObjectDisposalZOffset">The offset for accurate Z-disposal</param>
 /// <param name="StartingDistance">The absolute route based starting distance for the object</param>
 /// <param name="EndingDistance">The absolute route based ending distance for the object</param>
 /// <param name="TrackPosition">The absolute route based track position</param>
 /// <param name="Brightness">The brightness value at this track position</param>
 /// <returns>The index to the created object, or -1 if this call fails</returns>
 public virtual int CreateStaticObject(StaticObject Prototype, Transformation AuxTransformation, Matrix4D Rotate, Matrix4D Translate, double AccurateObjectDisposalZOffset, double StartingDistance, double EndingDistance, double TrackPosition, double Brightness)
 {
     return(-1);
 }
Beispiel #59
0
 public void TestBorder()
 {
     // should support border
     Transformation transformation = new Transformation().Border(5, "black");
     String result = api.UrlImgUp.Transform(transformation).BuildUrl("test");
     Assert.AreEqual("http://res.cloudinary.com/testcloud/image/upload/bo_5px_solid_black/test", result);
     transformation = new Transformation().Border(5, "#ffaabbdd");
     result = api.UrlImgUp.Transform(transformation).BuildUrl("test");
     Assert.AreEqual("http://res.cloudinary.com/testcloud/image/upload/bo_5px_solid_rgb:ffaabbdd/test", result);
     transformation = new Transformation().Border("1px_solid_blue");
     result = api.UrlImgUp.Transform(transformation).BuildUrl("test");
     Assert.AreEqual("http://res.cloudinary.com/testcloud/image/upload/bo_1px_solid_blue/test", result);
 }
Beispiel #60
0
        internal bool CreateRailAligned(ObjectDictionary FreeObjects, Vector3 WorldPosition, Transformation RailTransformation, double StartingDistance, double EndingDistance)
        {
            if (Types.Length == 0)
            {
                return(false);
            }
            if (LastType > Types.Length - 1)
            {
                LastType = 0;
            }
            LastPlacement += Interval;
            double dz = LastPlacement - StartingDistance;

            WorldPosition += Position.X * RailTransformation.X + Position.Y * RailTransformation.Y + dz * RailTransformation.Z;
            UnifiedObject obj;

            FreeObjects.TryGetValue(Types[LastType], out obj);
            if (obj != null)
            {
                obj.CreateObject(WorldPosition, RailTransformation, new Transformation(), StartingDistance, EndingDistance, LastPlacement);
            }

            if (Types.Length > 1)
            {
                LastType++;
            }

            return(true);
        }