Beispiel #1
0
 public Relation(Element e1, Element e2,int x,int y)
 {
     this.e1 = e1;
     this.e2 = e2;
     this.coordinate.X = x;
     this.coordinate.Y = y;
 }
Beispiel #2
0
 public Relation(Relation r,Element e1,int x,int y)
 {
     this.e1 = e1;
     this.r1 = r;
     this.coordinate.X = x;
     this.coordinate.Y = y;
 }
Beispiel #3
0
 public bool getOut(Element e)
 {
     if (e.Type != this.my_element.Type) return false;
     //double result = activationFunction(compareElements(this.my_element, e)); //убрать сигмоиду НАХУЙ
     //double result = compareElements(this.my_element, e);
     //if (result < 20)
     //    return true;
     //else
     //    return false;
     return isMyElement(e);
 }
Beispiel #4
0
 public int AgentExist(Element e)
 {
     int result = 0;
     foreach (Agent a in agents)
     {
         if (a.getOut(e))
             return result;
         result++;
     }
     return -1;
 }
        private void button3_Click(object sender, EventArgs e)
        {
            Skeleton sk = current_skelet_loaded;

            Classes.Element calculatedElement = calcAtributesOfElement(sk, listBox1.SelectedIndex);

            textBox1.Text  = calculatedElement.Type.ToString();
            textBox2.Text  = calculatedElement.Curvature.ToString();
            textBox3.Text  = calculatedElement.EndPoint.X.ToString();
            textBox9.Text  = calculatedElement.EndPoint.Y.ToString();
            textBox5.Text  = calculatedElement.BeginPoint.X.ToString();
            textBox10.Text = calculatedElement.BeginPoint.Y.ToString();
            textBox4.Text  = calculatedElement.Length.ToString();
            textBox6.Text  = Classes.Element.struct_size.ToString();
        }
Beispiel #6
0
 public bool checkElement(Element e1, Element e2)
 {
     if (this.e1 == null && this.e2 == null) return false;
     if (this.e1.Equals(e1) && e2 == null)
     {
         end_flag = true;
         return true;
     }
     if (this.e1.Equals(e1))
         if (this.e2.Equals(e2))
         {
             end_flag = true;
             return true;
         }
     return false;
 }
 public ViewProperties_Form(Classes.Element el)
 {
     InitializeComponent();
     this.el             = el;
     this.textBox1.Text  = this.el.Type.ToString();
     this.textBox2.Text  = this.el.Curvature.ToString();
     this.textBox3.Text  = this.el.EndPoint.X.ToString();
     this.textBox9.Text  = this.el.EndPoint.Y.ToString();
     this.textBox5.Text  = this.el.BeginPoint.X.ToString();
     this.textBox10.Text = this.el.BeginPoint.Y.ToString();
     this.textBox4.Text  = this.el.Length.ToString();
     this.textBox6.Text  = this.el.Struct_Size.ToString();
     this.textBox7.Text  = this.el.Coordinate.X.ToString();
     this.textBox8.Text  = this.el.Coordinate.Y.ToString();
     if (this.el.Bitmap != null)
     {
         ibReader.Image   = new Image <Gray, byte>(this.el.Bitmap);
         ibReader.Visible = true;
     }
 }
 public ViewProperties_Form(Classes.Element el)
 {
     InitializeComponent();
     this.el = el;
     this.textBox1.Text = this.el.Type.ToString();
     this.textBox2.Text = this.el.Curvature.ToString();
     this.textBox3.Text = this.el.EndPoint.X.ToString();
     this.textBox9.Text = this.el.EndPoint.Y.ToString();
     this.textBox5.Text = this.el.BeginPoint.X.ToString();
     this.textBox10.Text = this.el.BeginPoint.Y.ToString();
     this.textBox4.Text = this.el.Length.ToString();
     this.textBox6.Text = this.el.Struct_Size.ToString();
     this.textBox7.Text = this.el.Coordinate.X.ToString();
     this.textBox8.Text = this.el.Coordinate.Y.ToString();
     if (this.el.Bitmap != null)
     {
         ibReader.Image = new Image<Gray, byte>(this.el.Bitmap);
         ibReader.Visible = true;
     }
 }
Beispiel #9
0
 public void SetElementParametrs(int number,Element e)
 {
     ms.SetElementParametrs(number,e);
 }
Beispiel #10
0
 public string getResult(List<Element> input)
 {
     Element[] input_elements = new Element[input.Count];
     for (int i = 0; i < input.Count; i++)
     {
         input_elements[i] = input[i];
     }
     return ms.getOut(input_elements);
 }
Beispiel #11
0
 public int checkAgentExist(Element e)
 {
     return ms.AgentExist(e);
 }
Beispiel #12
0
 public void AddElement(Element el)
 {
     ms.AddTemplate(el);
 }
Beispiel #13
0
 public bool checkRelation(Relation r, Element e)
 {
     if (this.r1 == null || this.e1 == null) return false;
     if (this.r1.Equals(r))
         if (this.e1.Equals(e))
         {
             end_flag = true;
             return true;
         }
     return false;
 }
Beispiel #14
0
 public Agent(Element e, int sensors_count)
 {
     this.my_element = e;
     this.sensors_count = sensors_count;
 }
Beispiel #15
0
 private bool isMyElement(Element e)
 {
     return ComparePoints(my_element.BeginPoint, e.BeginPoint) &&
         ComparePoints(my_element.EndPoint, e.EndPoint) &&
         CompareLength(my_element.Length, e.Length) &&
         CompareCurvature (my_element.Curvature, e.Curvature);
 }
Beispiel #16
0
        public string getOut(Element[] input)
        {
            this.input = input;
            List<Element> agentsLayerOut = new List<Element>();
            for (int i = 0; i < input.Length; i++)
            {
                for (int j = 0; j < agents.Count; j++)
                {
                    if (agents[j].getOut(input[i]))
                    {
                        agentsLayerOut.Add(agents[j].getSpecializationElement());
                        break;
                    }
                }
            }

            if (agentsLayerOut.Count != input.Length) return CheckResult(input);

            Relation relation_buffer = null;
            int elements_counter = 0;
            char result = '-';
            int k = 0;

            // вообще не уверен в этом алгоритме
            while (result == '-' && k < relations.Count)
            {
                if (relation_buffer == null)
                {
                    try
                    {
                        if (relations[k].checkElement(agentsLayerOut[elements_counter], agentsLayerOut[elements_counter + 1]))
                        {
                            relation_buffer = relations[k]; // клонировать?
                            elements_counter += 2;
                            if ((result = relations[k].checkChar()) == '-')
                                k = 0;
                        }
                    }
                    catch (Exception e)
                    {
                        if (relations[k].checkElement(agentsLayerOut[elements_counter], null))
                        {
                            relation_buffer = relations[k]; // клонировать?
                            elements_counter += 2;
                            if ((result = relations[k].checkChar()) == '-')
                                k = 0;
                        }
                    }
                }
                else
                {
                    if (relations[k].checkRelation(relation_buffer, agentsLayerOut[elements_counter]))
                    {
                        relation_buffer = relations[k]; // клонировать?
                        elements_counter++;
                        if ((result = relations[k].checkChar()) == '-')
                            k = 0;
                    }
                }
                k++;
            }
            return result.ToString();
        }
Beispiel #17
0
 public bool checkResult(Element e)
 {
     return isMyElement(e);
 }
Beispiel #18
0
 public void setInputElement(Element e)
 {
     this.input_element = e;
 }
Beispiel #19
0
 public void AddTemplate(Element e)
 {
     templates.Add(e); // клонировать?
     agents.Add(new Agent(e, e.Struct_Size));
 }
Beispiel #20
0
        private string CheckResult(Element[] input)
        {
            string result = "-1";

            List<Element> agentsLayerOut = new List<Element>();
            for (int i = 0; i < input.Length; i++)
            {
                for (int j = 0; j < agents.Count; j++)
                {
                    if (agents[j].checkResult(input[i]))
                    {
                        agentsLayerOut.Add(agents[j].getSpecializationElement());
                    }
                }
            }

            List<Relation> possibleRelations = new List<Relation>();

            for (int i = 0; i < agentsLayerOut.Count; i++)
            {
                for (int j = 0; j < agentsLayerOut.Count; j++)
                {
                    if (i != j)
                    {
                        for (int k = 0; k < relations.Count; k++)
                        {
                            if (!relations[k].itRel())
                            {
                                if (relations[k].checkElement(agentsLayerOut[i], agentsLayerOut[j]))
                                {
                                    possibleRelations.Add(relations[k]);
                                }
                            }
                        }
                    }
                }
            }

            for (int i = 0; i < possibleRelations.Count; i++)
            {
                result = FindRelations(possibleRelations[i], agentsLayerOut).ToString();
                if (!result.Equals("-1") && !result.Equals("-1"))
                    return result;
            }

            return result;
        }
Beispiel #21
0
 public void SetElementParametrs(int number, Element e)
 {
     templates[number].BeginPoint = e.BeginPoint;
     templates[number].EndPoint = e.EndPoint;
     templates[number].Curvature = e.Curvature;
     templates[number].Type = e.Type;
     templates[number].Length = e.Length;
     templates[number].Struct_Size = e.Struct_Size;
 }
Beispiel #22
0
        private double compareElements(Element e1, Element e2)
        {
            double beginVectorLength = calcVectorLength(e1.BeginPoint, e2.BeginPoint);
            double endVectorLength = calcVectorLength(e1.EndPoint, e2.EndPoint);
            double lengthDifference = calcLengthDifference(e1.Length, e2.Length);
            double curvatureDifference = calcCurvatureDifference(e1.Curvature, e2.Curvature);

            return 0.5 * Math.Sqrt(beginVectorLength * beginVectorLength + endVectorLength * endVectorLength +
                lengthDifference * lengthDifference +
                curvatureDifference * curvatureDifference);
        }