Пример #1
0
 public CADEdge(CADData src, CADData dst)
 {
     Type = CADDataType.Edge;
     Src = src;
     Dst = dst;
     ConstraintPairs = new List<Tuple<Datum, Datum>>();            
     Name = "Edge";
 }
Пример #2
0
 public CADEdge(CADData src, CADData dst)
 {
     Type            = CADDataType.Edge;
     Src             = src;
     Dst             = dst;
     ConstraintPairs = new List <Tuple <Datum, Datum> >();
     Name            = "Edge";
 }
Пример #3
0
        private bool FindEdges(string my_component_id,
                               int degree_in,
                               List <string> closedComponents,
                               List <DataRep.CADEdge> openEdges)
        {
            bool status;
            List <DataRep.CADEdge> newOpenEdges    = new List <DataRep.CADEdge>();
            List <DataRep.CADEdge> found_edges_set = new List <DataRep.CADEdge>();

            int totalDegrees = 0;

            foreach (var item in openEdges)
            {
                string srcID = item.Src.Id, dstID = item.Dst.Id;
                if (my_component_id == srcID && closedComponents.Contains(dstID))
                {
                    // Reverse Src and Dst in CEdge
                    DataRep.CADData tmpCADData = item.Src;
                    string          tmpPort = item.SrcPortID, tmpPortName = item.SrcPortName;
                    item.Src         = item.Dst;
                    item.SrcPortID   = item.DstPortID;
                    item.SrcPortName = item.DstPortName;
                    item.Dst         = tmpCADData;
                    item.DstPortID   = tmpPort;
                    item.DstPortName = tmpPortName;
                    // end

                    totalDegrees += item.DegreeFreedom;
                    found_edges_set.Add(item);
                }
                else if (my_component_id == dstID && closedComponents.Contains(srcID))
                {
                    totalDegrees += item.DegreeFreedom;
                    found_edges_set.Add(item);
                }
                else
                {
                    newOpenEdges.Add(item);
                }
            }

            if (totalDegrees < degree_in)
            {
                foreach (var item in found_edges_set)
                {
                    newOpenEdges.Add(item);             // insert edges back into newOpenEdges
                }
                status = false;
            }
            else
            {
                debugMessages.Add(my_component_id + " - DOF(" + totalDegrees + ")\n");
                foreach (var item in found_edges_set)
                {
                    debugMessages.Add("		Source: "+ item.Src.Id + " Dst: " + item.Dst.Id + "\n");
                }

                closedComponents.Add(my_component_id);
                status = true;
            }

            openEdges.RemoveRange(0, openEdges.Count());
            openEdges.AddRange(newOpenEdges);

            return(status);

            /*
             * bool status;
             * List<DataRep.CADEdge> newOpenEdges = new List<DataRep.CADEdge>();
             * List<DataRep.CADEdge> found_edges_set = new List<DataRep.CADEdge>();
             *
             * int totalDegrees = 0;
             *
             * foreach (var item in openEdges)
             * {
             *  string srcID = item.Src.Id, dstID = item.Dst.Id;
             *  if (my_component_id == srcID && closedComponents.Contains(dstID))
             *  {
             *      // Reverse Src and Dst in CEdge
             *      DataRep.CADData tmpCADData = item.Src;
             *      string tmpPort = item.SrcPortID;
             *      item.Src = item.Dst;
             *      item.SrcPortID = item.DstPortID;
             *      item.Dst = tmpCADData;
             *      item.DstPortID = tmpPort;
             *      // end
             *
             *      totalDegrees += item.DegreeFreedom;
             *      found_edges_set.Add(item);
             *  }
             *  else if (my_component_id == dstID && closedComponents.Contains(srcID))
             *  {
             *      totalDegrees += item.DegreeFreedom;
             *      found_edges_set.Add(item);
             *  }
             *  else
             *      newOpenEdges.Add(item);
             * }
             *
             * if (totalDegrees < degree_in)
             * {
             *  foreach (var item in found_edges_set)
             *      newOpenEdges.Add(item);		// insert edges back into newOpenEdges
             *  status = false;
             * }
             * else
             * {
             *  debugMessages.Add(my_component_id + " - DOF(" + totalDegrees + ")\n");
             *          foreach (var item in found_edges_set)
             *      debugMessages.Add("		Source: " + item.Src.Id + " Dst: " + item.Dst.Id + "\n");
             *
             *  closedComponents.Add(my_component_id);
             *  status = true;
             * }
             *
             * openEdges.RemoveRange(0, openEdges.Count());
             * openEdges.AddRange(newOpenEdges);
             *
             * return status;
             */
        }