예제 #1
0
        public bool  RedactPrism(PointF[] ArrayVert_In, float n_R, float n_G, float n_B, string namePrism)
        {
            PointF Tmp_Dot = new PointF();

            for (int i = 0; i != ArrayVert_In.Length; i++)
            {
                if (i == ArrayVert_In.Length - 1)
                {
                    Tmp_Dot = ArrayVert_In[0];
                }
                else
                {
                    Tmp_Dot = ArrayVert_In[i + 1];
                }

                if (!CanCreate(ArrayVert_In[i], Tmp_Dot, namePrism))
                {
                    return(false);
                }
            }
            OpticObject tmp = ListOpticObject.Find(delegate(OpticObject Curent)
            {
                if (Curent is PrismObject)
                {
                    return(((PrismObject)Curent).Name == namePrism);
                }
                return(false);
            }
                                                   );

            ((PrismObject)tmp).RedactPrism(ArrayVert_In, n_R, n_G, n_B);
            ReceiverObject.ChangeRays(ListOpticObject, LightReceiver);
            return(true);
        }
예제 #2
0
        public void ChangeRays(List <OpticObject> ListOpticObject, Receiver LightReceiver)
        {
            OpticObject[] tmp_array = new OpticObject[ListOpticObject.Count];
            Array.Copy(ListOpticObject.ToArray(), tmp_array, tmp_array.Length);
            int tmp = tmp_array.Length, index = ListOpticObject.Count;

            RefractRayList.Clear();
            tmpRefractRayList.Clear();

            foreach (Ray Ray_index in RayList)
            {
                Ray_index.ReCreate();

                do
                {
                    if (!Ray_index.FindNearest(ListOpticObject, ref index))
                    {
                        break;
                    }
                } while (true);
            }
            index = ListOpticObject.Count;
            foreach (Ray index_ray in tmpRefractRayList)
            {
                RefractRayList.Add(index_ray);
            }
            tmpRefractRayList.Clear();


            do
            {
                foreach (Ray Ray_index in RefractRayList)
                {
                    do
                    {
                        if (!Ray_index.FindNearest(ListOpticObject, ref index))
                        {
                            break;
                        }
                    } while (true);
                }
                if (tmpRefractRayList.Count == 0)
                {
                    break;
                }
                foreach (Ray index_ray in tmpRefractRayList)
                {
                    RefractRayList.Add(index_ray);
                }
                tmpRefractRayList.Clear();
            }while(true);
            foreach (Ray Ray_index in RefractRayList)
            {
                Ray_index.ReceiverRay(LightReceiver);
            }
            foreach (Ray Ray_index in RayList)
            {
                Ray_index.ReceiverRay(LightReceiver);
            }
        }
예제 #3
0
        public bool Invalidate(OpticObject OpticObjec_in)
        {
            PointF tmp = new PointF(), tmp2 = new PointF();

            if (OpticObjec_in is Mirror)
            {
                if (((Mirror)OpticObjec_in).Invalidate(PointRay[PointRay.Length - 2], PointRay[PointRay.Length - 1], ref tmp, ref tmp2))
                {
                    Array.Resize <PointF>(ref PointRay, PointRay.Length + 1);
                    PointRay[PointRay.Length - 1] = new PointF();
                    PointRay[PointRay.Length - 2] = new PointF();
                    PointRay[PointRay.Length - 1] = tmp2;
                    PointRay[PointRay.Length - 2] = tmp;
                    return(true);
                }
            }
            else if (OpticObjec_in is PrismObject)
            {
                if (((PrismObject)OpticObjec_in).Invalidate(PointRay[PointRay.Length - 2], PointRay[PointRay.Length - 1], ref tmp, ColorRay))
                {
                    PointRay[PointRay.Length - 1]   = new PointF();
                    PointRay[PointRay.Length - 1].X = tmp.X;
                    PointRay[PointRay.Length - 1].Y = tmp.Y;

                    return(true);
                }
            }

            return(false);
        }
예제 #4
0
        public bool FindNearest(List <OpticObject> OpticObjecList_in, ref int index)
        {
            PointF      tmp = new PointF();
            OpticObject obj = null;
            int         j = -1;
            double      dist = 0, dist_min = 0;

            for (int i = 0; i != OpticObjecList_in.Count; i++)
            {
                if (OpticObjecList_in[i] is Mirror)
                {
                    double corner = 0;
                    if (index != i)
                    {
                        corner = ((Mirror)OpticObjecList_in[i]).Crossing(PointRay[PointRay.Length - 2], PointRay[PointRay.Length - 1], ref tmp);
                    }
                    if ((corner != 0) && ((Math.Round(PointRay[PointRay.Length - 2].X) != Math.Round(tmp.X)) || (Math.Round(PointRay[PointRay.Length - 2].Y) != Math.Round(tmp.Y))))
                    {
                        dist = Math.Sqrt(Math.Pow(tmp.X - PointRay[PointRay.Length - 2].X, 2) + Math.Pow(tmp.Y - PointRay[PointRay.Length - 2].Y, 2));
                    }
                }
                else if (OpticObjecList_in[i] is PrismObject)
                {
                    double corner = 0;
                    if (index != i)
                    {
                        corner = ((PrismObject)OpticObjecList_in[i]).FindCrossing(PointRay[PointRay.Length - 2], PointRay[PointRay.Length - 1], ref tmp, ref j);
                    }
                    if ((corner != 0) && ((Math.Round(PointRay[PointRay.Length - 2].X) != Math.Round(tmp.X)) || (Math.Round(PointRay[PointRay.Length - 2].Y) != Math.Round(tmp.Y))))
                    {
                        dist = Math.Sqrt(Math.Pow(tmp.X - PointRay[PointRay.Length - 2].X, 2) + Math.Pow(tmp.Y - PointRay[PointRay.Length - 2].Y, 2));
                    }
                }
                if (((dist_min == 0) || (dist < dist_min)) && (dist != 0))
                {
                    dist_min = dist;
                    obj      = OpticObjecList_in[i];
                    index    = i;
                }
            }
            if (obj != null)
            {
                return(Invalidate(obj));
            }

            index = OpticObjecList_in.Count;
            return(false);
        }
예제 #5
0
        public bool ChangeMirror(PointF Begin, PointF End, string index)
        {
            OpticObject tmp = ListOpticObject.Find(delegate(OpticObject Curent)
            {
                if (Curent is Mirror)
                {
                    return(((Mirror)Curent).Name == index);
                }
                return(false);
            });

            if (((Mirror)tmp).Change(Begin, End, ListOpticObject))
            {
                ReceiverObject.ChangeRays(ListOpticObject, LightReceiver);
                return(true);
            }

            return(false);
        }
예제 #6
0
        public void DeleteObject(string index)
        {
            OpticObject tmp = ListOpticObject.Find(delegate(OpticObject Curent)
            {
                if (Curent is Mirror)
                {
                    return(((Mirror)Curent).Name == index);
                }
                if (Curent is PrismObject)
                {
                    return(((PrismObject)Curent).Name == index);
                }
                return(false);
            }
                                                   );

            ListOpticObject.Remove(tmp);
            ReceiverObject.ChangeRays(ListOpticObject, LightReceiver);
        }
예제 #7
0
        public PointF[] FindPrism(string index, ref float [] RGB_Coef)
        {
            OpticObject tmp = ListOpticObject.Find(delegate(OpticObject Curent)
            {
                if (Curent is Mirror)
                {
                    return(((Mirror)Curent).Name == index);
                }
                return(((PrismObject)Curent).Name == index);
            }
                                                   );

            if (tmp is PrismObject)
            {
                RGB_Coef[0] = ((PrismObject)tmp).GetRedCoef;
                RGB_Coef[1] = ((PrismObject)tmp).GetGreenCoef;
                RGB_Coef[2] = ((PrismObject)tmp).GetBlueCoef;
                return(((PrismObject)tmp).ArrayPrism);
            }
            return(null);
        }
예제 #8
0
        public PointF[] FindMirror(string index)
        {
            PointF[]    ArrayDots = null;
            OpticObject tmp       = ListOpticObject.Find(delegate(OpticObject Curent)
            {
                if (Curent is Mirror)
                {
                    return(((Mirror)Curent).Name == index);
                }
                return(((PrismObject)Curent).Name == index);
            }
                                                         );

            if (tmp is Mirror)
            {
                ArrayDots = new PointF[2] {
                    ((Mirror)tmp).GetBegin, ((Mirror)tmp).GetEnd
                };
            }

            return(ArrayDots);
        }