/// <summary>
        /// 从node节点出发不经过parent节点的最长路径
        /// </summary>
        /// <param name="parent">node的上一访问节点</param>
        /// <param name="node">node几点</param>
        /// <param name="pipes">从node节点出发不经过parent节点的最长路径的距离</param>
        /// <returns>最长路径的大小</returns>
        public double GetPipeLineLength(PipeLine parent, PipeLine node, out List <PipeLine> pipes)
        {
            pipes = new List <PipeLine>();
            if (node.HeadConnectedObject == null)
            {
                pipes.Add(node);
                return(node.CalculateLength());
            }
            if (node.TailConnectedObject == null)
            {
                pipes.Add(node);
                return(node.CalculateLength());
            }
            if (node.IsVisit == false)
            {
                node.IsVisit = true;
                ReadOnlyCollection <PipeLine> children = null;
                if (node.HeadConnectedObject.ConnectedPipes.Contains(parent) == true)
                {
                    children = node.TailConnectedObject.ConnectedPipes;
                }
                if (node.TailConnectedObject.ConnectedPipes.Contains(parent) == true)
                {
                    children = node.HeadConnectedObject.ConnectedPipes;
                }
                double max = 0;

                foreach (var item in children)
                {
                    if (item != node)
                    {
                        List <PipeLine> lines;
                        double          v = GetPipeLineLength(node, item, out lines);
                        if (v > max)
                        {
                            pipes = lines;
                            max   = v;
                        }
                    }
                }
                pipes.Add(node);
                max         += node.CalculateLength();
                node.IsVisit = false;
                return(max);
            }
            return(0);
        }
示例#2
0
        public PipeLine GenerateFromSimpleJoint(SimplePipeJoint pipeJoint, Point3d ePoint, double width)
        {
            //

            this.CenterPoint = pipeJoint.CenterPoint;
            PipeLine pipeline1 = pipeJoint.GetConnectedPipeLine(0);
            PipeLine pipeline2 = pipeJoint.GetConnectedPipeLine(1);
            Point3d  p1        = CenterPoint + (pipeline1.Point(0) - CenterPoint).GetNormal() * Length;
            Point3d  p2        = CenterPoint + (pipeline2.Point(0) - CenterPoint).GetNormal() * Length;
            Point3d  p3        = CenterPoint + (ePoint - CenterPoint).GetNormal() * Length;

            if (pipeline1.HeadConnectedObject == pipeJoint)
            {
                pipeline1.HeadConnectedObject = this;
                pipeline1.UpdateStartPoint(p1);
            }
            if (pipeline1.TailConnectedObject == pipeJoint)
            {
                pipeline1.TailConnectedObject = this;
                pipeline1.UpdateEndPoint(p1);
            }
            if (pipeline2.HeadConnectedObject == pipeJoint)
            {
                pipeline2.HeadConnectedObject = this;
                pipeline2.UpdateStartPoint(p2);
            }
            if (pipeline2.TailConnectedObject == pipeJoint)
            {
                pipeline2.TailConnectedObject = this;
                pipeline2.UpdateEndPoint(p2);
            }
            PipeLine        pipeline3 = new PipeLine(p3, ePoint, false, OwnSolution, true);
            List <PipeLine> lists     = new List <PipeLine>();

            lists.Add(pipeline1);
            lists.Add(pipeline2);
            lists.Add(pipeline3);
            this.SetPipeLines(lists);
            this.GenerateFromConnectedPipes();
            pipeJoint.RemoveEntity();
            return(pipeline3);
        }
        /// <summary>
        /// 将要删除管道
        /// 删除管道的时候要对其相邻的结头进行处理
        /// </summary>
        /// <param name="id"></param>
        /// <returns>同上</returns>
        public bool WillDeletePipeLine(ObjectId id)
        {
            if (this.PipeLines.ContainsKey(id))
            {
                //

                PipeLine pLine = this.PipeLines[id];
                this.CurrentLineStyle = pLine.Style;
                this.PipeLines.Remove(id);
                if (pLine.HeadConnectedObject is SimplePipeJoint)
                {
                    SimplePipeJoint jo = (SimplePipeJoint)pLine.HeadConnectedObject;
                    foreach (var item in jo.ConnectedPipes)
                    {
                        item.RemoveJoint(jo);
                    }
                    jo.RemoveEntity();
                }
                else if (pLine.HeadConnectedObject is MultiPipeJoint)
                {
                    MultiPipeJoint jo = (MultiPipeJoint)pLine.HeadConnectedObject;
                    jo.DownGrade(pLine);
                }
                if (pLine.TailConnectedObject is SimplePipeJoint)
                {
                    SimplePipeJoint jo = (SimplePipeJoint)pLine.TailConnectedObject;
                    foreach (var item in jo.ConnectedPipes)
                    {
                        item.RemoveJoint(jo);
                    }
                    jo.RemoveEntity();
                }
                else if (pLine.TailConnectedObject is MultiPipeJoint)
                {
                    MultiPipeJoint jo = (MultiPipeJoint)pLine.TailConnectedObject;
                    jo.DownGrade(pLine);
                }
                return(true);
            }
            return(false);
        }
示例#4
0
 public BaseModel DownGrade(PipeLine line)
 {
     //
     if (this.ConnectedPipes.Contains(line))
     {
         this.RemovePipeLine(line);
         if (this.ConnectedPipes.Count == 2)
         {
             //退化成SimpleJoint 或者 PipeLine
             PipeLine line1 = this.ConnectedPipes[0];
             PipeLine line2 = this.ConnectedPipes[1];
             //退化成新的PipeLine
             if (line1.PipeLineCrossTest(line2) == PipeLine.CrossType.ParallelNoConnect)
             {
                 Point3d   p1, p2;
                 PipeJoint co1, co2;
                 if ((line1.Point(0) - this.CenterPoint).Length > (line1.Point(1) - this.CenterPoint).Length)
                 {
                     p1  = line1.Point(0);
                     co1 = line1.HeadConnectedObject;
                 }
                 else
                 {
                     p1  = line1.Point(1);
                     co1 = line1.TailConnectedObject;
                 }
                 if ((line2.Point(0) - this.CenterPoint).Length > (line2.Point(1) - this.CenterPoint).Length)
                 {
                     p2  = line2.Point(0);
                     co2 = line2.HeadConnectedObject;
                 }
                 else
                 {
                     p2  = line2.Point(1);
                     co2 = line2.TailConnectedObject;
                 }
                 PipeLine pLine = new PipeLine(p1, p2, OwnSolution, true);
                 line1.Delete();
                 line2.Delete();
                 pLine.HeadConnectedObject = co1;
                 if (co1 != null)
                 {
                     co1.RemovePipeLine(line1);
                     co1.AddPipeLine(pLine);
                 }
                 pLine.TailConnectedObject = co2;
                 if (co2 != null)
                 {
                     co2.RemovePipeLine(line2);
                     co2.AddPipeLine(pLine);
                 }
                 this.RemoveEntity();
             }
             else
             {
                 Point3d p1, p2, p3, p4;
                 bool    ht1, ht2; // head or tail, true for head, false for tail
                 if ((line1.Point(0) - this.CenterPoint).Length > (line1.Point(1) - this.CenterPoint).Length)
                 {
                     p1  = line1.Point(0);
                     p3  = line1.Point(1);
                     ht1 = false;
                 }
                 else
                 {
                     p1  = line1.Point(1);
                     p3  = line1.Point(0);
                     ht1 = true;
                 }
                 if ((line2.Point(0) - this.CenterPoint).Length > (line2.Point(1) - this.CenterPoint).Length)
                 {
                     p2  = line2.Point(0);
                     p4  = line2.Point(1);
                     ht2 = false;
                 }
                 else
                 {
                     p2  = line2.Point(1);
                     p4  = line2.Point(0);
                     ht2 = true;
                 }
                 Point3d         intersect       = Utility.Intersect(p1, p3 - p1, p2, p4 - p2);
                 SimplePipeJoint simplePipeJoint = new SimplePipeJoint(p1, intersect, p2, PipeLine.GetScale() / 2, OwnSolution, true);
                 Point3d         p5 = simplePipeJoint.CalculateLastMlineEndPoint();
                 Point3d         p6 = simplePipeJoint.CalculateMlineStartPoint();
                 if (ht1)
                 {
                     line1.UpdateStartPoint(p5);
                     line1.HeadConnectedObject = simplePipeJoint;
                 }
                 else
                 {
                     line1.UpdateEndPoint(p5);
                     line1.TailConnectedObject = simplePipeJoint;
                 }
                 if (ht2)
                 {
                     line2.UpdateStartPoint(p6);
                     line2.HeadConnectedObject = simplePipeJoint;
                 }
                 else
                 {
                     line2.UpdateEndPoint(p6);
                     line2.TailConnectedObject = simplePipeJoint;
                 }
                 simplePipeJoint.AddPipeLine(line1);
                 simplePipeJoint.AddPipeLine(line2);
                 this.RemoveEntity();
             }
         }
         else
         {
             this.GenerateFromConnectedPipes();
         }
     }
     return(null);
 }
示例#5
0
 public void RemovePipeLine(PipeLine line)
 {
     this._ConnectedPipes.Remove(line);
     this.Save();
 }
示例#6
0
 public void AddPipeLine(PipeLine line)
 {
     _ConnectedPipes.Add(line);
     this.Save();
 }
示例#7
0
        public List <Point3d> GenerateFromCrossPipe(PipeLine line, Point3d sPoint, Point3d ePoint, double width)
        {
            List <Point3d> res = new List <Point3d>();
            //计算与mline的交点
            Point3d  sm = line.Point(0);
            Point3d  em = line.Point(1);
            Vector3d v1 = (em - sm).GetNormal();
            Vector3d n1 = v1.RotateBy(0.5 * Math.PI, Vector3d.ZAxis);
            Point3d  p1 = sm + line.Width * n1;
            Point3d  p2 = em + line.Width * n1;
            Point3d  p3 = sm - line.Width * n1;
            Point3d  p4 = em - line.Width * n1;

            Point3d  centerPoint = Utils.Utility.CrossPoint(sm, em, sPoint, ePoint);
            Vector3d v2          = (ePoint - sPoint).GetNormal();
            double   len1        = line.Width / Math.Abs(v2.DotProduct(n1));
            Point3d  p5          = centerPoint + v2 * len1;
            double   cos1        = v2.DotProduct(v1);
            double   sin1        = Math.Sqrt(1 - cos1 * cos1);
            Point3d  p6          = p5 - v1 * (width / sin1);
            Point3d  p7          = p5 + v1 * (width / sin1);
            int      sign;

            if (v2.CrossProduct(v1).Z > 0)
            {
                sign = 1;
            }
            else
            {
                sign = -1;
            }
            Point3d p8 = (centerPoint - Length * v1) - n1 * width * sign;
            Point3d p9 = (centerPoint + Length * v1) - n1 * width * sign;

            Point3d e1  = centerPoint - Length * v1;
            Point3d e2  = centerPoint + Length * v1;
            Point3d p10 = e1 + (e1 - p8);
            Point3d p11 = e2 + (e2 - p9);

            Point3d p13 = centerPoint + Length * v2;

            Vector3d n2  = v2.RotateBy(sign * 0.5 * Math.PI, Vector3d.ZAxis);
            Point3d  p14 = p13 - n2 * width;
            Point3d  p15 = p13 + n2 * width;

            pline.AddVertexAt(0, Utils.Utility.Point3DTo2D(p8), 0, 0, 0);
            pline.AddVertexAt(1, Utils.Utility.Point3DTo2D(p6), 0, 0, 0);
            pline.AddVertexAt(2, Utils.Utility.Point3DTo2D(p14), 0, 0, 0);
            pline.AddVertexAt(3, Utils.Utility.Point3DTo2D(p15), 0, 0, 0);
            pline.AddVertexAt(4, Utils.Utility.Point3DTo2D(p7), 0, 0, 0);
            pline.AddVertexAt(5, Utils.Utility.Point3DTo2D(p9), 0, 0, 0);
            pline.AddVertexAt(6, Utils.Utility.Point3DTo2D(p11), 0, 0, 0);
            pline.AddVertexAt(7, Utils.Utility.Point3DTo2D(p10), 0, 0, 0);
            pline.AddVertexAt(8, Utils.Utility.Point3DTo2D(p8), 0, 0, 0);

            Line l1 = new Line(e1, centerPoint);
            Line l2 = new Line(e2, centerPoint);
            Line l3 = new Line(p13, centerPoint);

            lines.Add(l1);
            lines.Add(l2);
            lines.Add(l3);

            SaveEntity();

            res.Add(e1);
            res.Add(e2);
            res.Add(p13);
            CenterPoint = centerPoint;
            return(res);
        }
示例#8
0
        public CrossType PipeLineCrossTest(PipeLine line)
        {
            if (this.Style != line.Style)
            {
                return(CrossType.CrossNone);
            }
            Point3d s  = mline.VertexAt(0);
            Point3d e  = mline.VertexAt(1);
            Point3d s1 = line.mline.VertexAt(0);
            Point3d e1 = line.mline.VertexAt(1);
            //
            Vector3d v1 = s - e;
            Vector3d v2 = e1 - s1;
            Vector3d v3 = e1 - e;

            //Inner product
            double cos1 = Math.Abs(v1.DotProduct(v2)) / (v1.Length * v2.Length);

            if (cos1 > 0.999)
            {
                //
                if (((s - e1).Length < 0.5 * GetLineScale() && (e - s1).Length > 2 * GetLineScale() || (s - s1).Length < 0.5 * GetLineScale() && (e - e1).Length > 2 * GetLineScale()) && this.HeadConnectedObject == null)
                {
                    return(CrossType.ParallelHead);
                }
                else if (((e - s1).Length < 0.5 * GetLineScale() && (e - e1).Length > 2 * GetLineScale() || (e - e1).Length < 0.5 * GetLineScale() && (e - s1).Length > 2 * GetLineScale()) && this.TailConnectedObject == null)
                {
                    return(CrossType.ParallelTail);
                }
                return(CrossType.ParallelNoConnect);
            }

            double CrossProduct = v1.X * v2.Y - v1.Y * v2.X;//cross value
            double lambda       = 1 / CrossProduct * (v2.Y * v3.X - v2.X * v3.Y);
            double tao          = 1 / CrossProduct * (-v1.Y * v3.X + v1.X * v3.Y);

            //接近与端点的地方也认为是不相交
            if (lambda <= 1 && ((lambda - 1) * v1).Length < GetLineScale() && this.HeadConnectedObject == null)
            {
                return(CrossType.NonParallelHead);
            }
            else if (lambda >= 0 && (lambda * v1).Length < GetLineScale() && this.TailConnectedObject == null)
            {
                return(CrossType.NonParallelTail);
            }
            if (v1.Length * lambda < GetLineScale() || v1.Length * (lambda - 1) > GetLineScale())
            {
                return(CrossType.CrossNone);
            }
            else if ((lambda >= 0 && lambda <= 1 && (lambda * v1).Length > 2 * GetLineScale()) || (lambda >= 0 && lambda <= 1 && ((lambda - 1) * v1).Length > 2 * GetLineScale()))
            {
                //相交位置为管道附近
                if (tao * v2.Length > -0.5 * GetLineScale() && tao * v2.Length < 0.5 * GetLineScale())
                {
                    return(CrossType.CrossTail);
                }
                else if (tao * v2.Length > v2.Length - 0.5 * GetLineScale() && tao * v2.Length < v2.Length + 0.5 * GetLineScale())
                {
                    return(CrossType.CrossHead);
                }
                else if (tao > 0 && tao < 1)
                {
                    return(CrossType.CrossOver);
                }
            }
            //
            return(CrossType.CrossNone);
        }
 //管道总长度
 public double GetTotalPipeLengthOfModel(BaseModel model, out List <PipeLine> lines)
 {
     if (model is SubStation || model is HeatProducer)
     {
         List <PipeLine> connectedpipes = SearchConnected(model);
         List <PipeLine> pipes          = new List <PipeLine>();
         foreach (var item in connectedpipes)
         {
             if (model is HeatProducer)
             {
                 pipes.Add(item);
             }
             else if (model is SubStation)
             {
                 if (item.Style == PipeLineStyle.AnyConnectedBuilding)
                 {
                     pipes.Add(item);
                 }
             }
         }
         double           total = 0;
         Stack <PipeLine> st    = new Stack <PipeLine>();
         foreach (var item in pipes)
         {
             st.Push(item);
         }
         Dictionary <ObjectId, PipeLine> allLines = new Dictionary <ObjectId, PipeLine>();
         while (st.Count != 0)
         {
             PipeLine pl = st.Pop();
             if (!allLines.ContainsKey(pl.BaseObjectId))
             {
                 allLines.Add(pl.BaseObjectId, pl);
                 if (pl.HeadConnectedObject != null)
                 {
                     foreach (var item in pl.HeadConnectedObject.ConnectedPipes)
                     {
                         if (!allLines.ContainsKey(item.BaseObjectId))
                         {
                             st.Push(item);
                         }
                     }
                 }
                 if (pl.TailConnectedObject != null)
                 {
                     foreach (var item in pl.TailConnectedObject.ConnectedPipes)
                     {
                         if (!allLines.ContainsKey(item.BaseObjectId))
                         {
                             st.Push(item);
                         }
                     }
                 }
             }
         }
         List <PipeLine> ConnectedLines = new List <PipeLine>();
         foreach (var item in allLines)
         {
             ConnectedLines.Add(item.Value);
             total += item.Value.CalculateLength();
         }
         lines = ConnectedLines;
         //
         if (model is HeatProducer)
         {
             HeatProducer heatProducer = (HeatProducer)model;
             if (heatProducer.OwnSlaveDistrict != null)
             {
                 foreach (var item in heatProducer.OwnSlaveDistrict.SubStations)
                 {
                     List <PipeLine> ls;
                     total += item.OwnSolution.GetTotalPipeLengthOfModel(item, out ls);
                     lines.AddRange(ls);
                 }
             }
         }
         return(total);
     }
     lines = new List <PipeLine>();
     return(0);
 }
        /// <summary>
        /// 管道相交测试
        /// </summary>
        /// <param name="pipeLine">测试管道</param>
        /// <param name="isFirst">相交测试是一个递归的过程,在一层递归里面PipeLine并没有被实际创建,而是在测试结束后才创建,下面的递归
        /// 层,测试的管道都是已经被创建了的</param>
        /// <returns></returns>
        public Point3d?PipeLineCrossTest(PipeLine pipeLine)
        {
            Point3d?res;
            Dictionary <ObjectId, PipeLine> copyPipelines = new Dictionary <ObjectId, PipeLine>();

            foreach (var item in PipeLines)
            {
                copyPipelines.Add(item.Key, item.Value);
            }

            //和管道测试相交
            foreach (var item in copyPipelines)
            {
                PipeLine cItem = (PipeLine)item.Value;
                if (cItem == pipeLine)
                {
                    continue;
                }
                PipeLine.CrossType type = cItem.PipeLineCrossTest(pipeLine);
                if (type == PipeLine.CrossType.CrossNone)
                {
                    continue;
                }
                else if (type == PipeLine.CrossType.ParallelHead)
                {
                    Point3d p1 = pipeLine.Point(0);
                    Point3d p2 = pipeLine.Point(1);
                    Point3d p3;
                    bool    result = false;
                    if ((p1 - cItem.Point(0)).Length < (p2 - cItem.Point(0)).Length)
                    {
                        result = false;
                        p3     = p2;
                    }
                    else
                    {
                        result = true;
                        p3     = p1;
                    }
                    Vector3d v  = cItem.Point(0) - cItem.Point(1);
                    Vector3d v1 = p3 - cItem.Point(0);
                    Point3d  p  = cItem.Point(0) + v1.DotProduct(v.GetNormal()) * v.GetNormal();
                    //
                    pipeLine = new PipeLine(p, cItem.Point(1), false, this);
                    pipeLine.TailConnectedObject = cItem.TailConnectedObject;
                    if (pipeLine.TailConnectedObject != null)
                    {
                        pipeLine.TailConnectedObject.RemovePipeLine(cItem);
                        pipeLine.TailConnectedObject.AddPipeLine(pipeLine);
                    }
                    cItem.Delete();
                    //递归调用

                    res = PipeLineCrossTest(pipeLine);
                    if (result)
                    {
                        return(null);
                    }
                    else
                    {
                        return(res);
                    }
                }
                else if (type == PipeLine.CrossType.ParallelTail)
                {
                    Point3d p1 = pipeLine.Point(0);
                    Point3d p2 = pipeLine.Point(1);
                    Point3d p3;
                    bool    result;
                    if ((p1 - cItem.Point(1)).Length < (p2 - cItem.Point(1)).Length)
                    {
                        result = false;
                        p3     = p2;
                    }
                    else
                    {
                        result = true;
                        p3     = p1;
                    }
                    Vector3d v  = cItem.Point(1) - cItem.Point(0);
                    Vector3d v1 = p3 - cItem.Point(1);
                    Point3d  p  = cItem.Point(1) + v1.DotProduct(v.GetNormal()) * v.GetNormal();
                    //
                    pipeLine = new PipeLine(cItem.Point(0), p, false, this);
                    pipeLine.HeadConnectedObject = cItem.HeadConnectedObject;
                    if (pipeLine.HeadConnectedObject != null)
                    {
                        pipeLine.HeadConnectedObject.RemovePipeLine(cItem);
                        pipeLine.HeadConnectedObject.AddPipeLine(pipeLine);
                    }
                    cItem.Delete();
                    //递归调用
                    res = PipeLineCrossTest(pipeLine);
                    if (result)
                    {
                        return(null);
                    }
                    else
                    {
                        return(res);
                    }
                }
                else if (type == PipeLine.CrossType.NonParallelHead)
                {
                    Point3d p1 = pipeLine.Point(0);
                    Point3d p2 = pipeLine.Point(1);
                    Point3d p3;
                    bool    result;
                    if ((p1 - cItem.Point(0)).Length < (p2 - cItem.Point(0)).Length)
                    {
                        result = false;
                        p3     = p2;
                    }
                    else
                    {
                        result = true;
                        p3     = p1;
                    }
                    SimplePipeJoint simplePipeJoint = new SimplePipeJoint(cItem.Point(1), cItem.Point(0), p3, PipeLine.GetScale() / 2, this, true);
                    cItem.UpdateStartPoint(simplePipeJoint.CalculateLastMlineEndPoint());
                    Point3d startPoint = simplePipeJoint.CalculateMlineStartPoint();
                    simplePipeJoint.AddPipeLine(cItem);
                    PipeLine newLine = new PipeLine(p3, startPoint, false, this);
                    simplePipeJoint.AddPipeLine(newLine);
                    cItem.HeadConnectedObject   = simplePipeJoint;
                    newLine.TailConnectedObject = simplePipeJoint;
                    if (pipeLine.HeadConnectedObject != null)
                    {
                        pipeLine.HeadConnectedObject.RemovePipeLine(pipeLine);
                        pipeLine.HeadConnectedObject.AddPipeLine(newLine);
                        newLine.HeadConnectedObject = pipeLine.HeadConnectedObject;
                    }
                    //递归调用
                    res = PipeLineCrossTest(newLine);
                    if (result)
                    {
                        return(null);
                    }
                    else
                    {
                        return(res);
                    }
                }
                else if (type == PipeLine.CrossType.NonParallelTail)
                {
                    Point3d p1 = pipeLine.Point(0);
                    Point3d p2 = pipeLine.Point(1);
                    Point3d p3;
                    bool    result;
                    if ((p1 - cItem.Point(1)).Length < (p2 - cItem.Point(1)).Length)
                    {
                        result = false;
                        p3     = p2;
                    }
                    else
                    {
                        result = true;
                        p3     = p1;
                    }
                    SimplePipeJoint simplePipeJoint = new SimplePipeJoint(cItem.Point(0), cItem.Point(1), p3, PipeLine.GetScale() / 2, this, true);
                    cItem.UpdateEndPoint(simplePipeJoint.CalculateLastMlineEndPoint());
                    cItem.TailConnectedObject = simplePipeJoint;
                    Point3d startPoint = simplePipeJoint.CalculateMlineStartPoint();
                    simplePipeJoint.AddPipeLine(cItem);
                    PipeLine newLine = new PipeLine(startPoint, p3, false, this);
                    simplePipeJoint.AddPipeLine(newLine);
                    newLine.HeadConnectedObject = simplePipeJoint;
                    if (pipeLine.TailConnectedObject != null)
                    {
                        pipeLine.TailConnectedObject.RemovePipeLine(pipeLine);
                        pipeLine.TailConnectedObject.AddPipeLine(newLine);
                        newLine.TailConnectedObject = pipeLine.TailConnectedObject;
                    }
                    res = PipeLineCrossTest(newLine);
                    if (result)
                    {
                        return(null);
                    }
                    else
                    {
                        return(res);
                    }
                }
                else if (type == PipeLine.CrossType.CrossHead)
                {
                    MultiPipeJoint mj = new MultiPipeJoint(this, true);
                    List <Point3d> ps = mj.GenerateFromCrossPipe(cItem, pipeLine.Point(0), pipeLine.Point(1), PipeLine.GetScale() / 2);
                    PipeLine       p1 = new PipeLine(cItem.Point(0), ps[0], this, true);
                    PipeLine       p2 = new PipeLine(ps[1], cItem.Point(1), this, true);
                    //
                    if (cItem.HeadConnectedObject != null)
                    {
                        cItem.HeadConnectedObject.RemovePipeLine(cItem);
                        cItem.HeadConnectedObject.AddPipeLine(p1);
                    }
                    if (cItem.TailConnectedObject != null)
                    {
                        cItem.TailConnectedObject.RemovePipeLine(cItem);
                        cItem.TailConnectedObject.AddPipeLine(p2);
                    }
                    p1.HeadConnectedObject = cItem.HeadConnectedObject;
                    p1.TailConnectedObject = mj;
                    p2.HeadConnectedObject = mj;
                    p2.TailConnectedObject = cItem.TailConnectedObject;

                    Point3d startPoint = ps[2];
                    cItem.Delete();

                    PipeLine pLine = new PipeLine(startPoint, pipeLine.Point(1), false, this);
                    pLine.HeadConnectedObject = mj;
                    if (pipeLine.TailConnectedObject != null)
                    {
                        pipeLine.TailConnectedObject.RemovePipeLine(pipeLine);
                        pipeLine.TailConnectedObject.AddPipeLine(pLine);
                        pLine.TailConnectedObject = pipeLine.TailConnectedObject;
                    }
                    mj.AddPipeLine(p1);
                    mj.AddPipeLine(p2);
                    mj.AddPipeLine(pLine);

                    res = PipeLineCrossTest(pLine);
                    return(res);
                }
                else if (type == PipeLine.CrossType.CrossTail)
                {
                    //
                    MultiPipeJoint mj = new MultiPipeJoint(this, true);
                    List <Point3d> ps = mj.GenerateFromCrossPipe(cItem, pipeLine.Point(1), pipeLine.Point(0), PipeLine.GetScale() / 2);
                    PipeLine       p1 = new PipeLine(cItem.Point(0), ps[0], this, true);
                    PipeLine       p2 = new PipeLine(ps[1], cItem.Point(1), this, true);
                    //
                    if (cItem.HeadConnectedObject != null)
                    {
                        cItem.HeadConnectedObject.RemovePipeLine(cItem);
                        cItem.HeadConnectedObject.AddPipeLine(p1);
                    }
                    if (cItem.TailConnectedObject != null)
                    {
                        cItem.TailConnectedObject.RemovePipeLine(cItem);
                        cItem.TailConnectedObject.AddPipeLine(p2);
                    }
                    p1.HeadConnectedObject = cItem.HeadConnectedObject;
                    p1.TailConnectedObject = mj;
                    p2.HeadConnectedObject = mj;
                    p2.TailConnectedObject = cItem.TailConnectedObject;
                    Point3d startPoint = ps[2];
                    cItem.Delete();
                    PipeLine pLine = new PipeLine(pipeLine.Point(0), startPoint, false, this);
                    pLine.TailConnectedObject = mj;
                    if (pipeLine.HeadConnectedObject != null)
                    {
                        pipeLine.HeadConnectedObject.RemovePipeLine(pipeLine);
                        pipeLine.HeadConnectedObject.AddPipeLine(pLine);
                        pLine.HeadConnectedObject = pipeLine.HeadConnectedObject;
                    }
                    mj.AddPipeLine(p1);
                    mj.AddPipeLine(p2);
                    mj.AddPipeLine(pLine);
                    PipeLineCrossTest(pLine);
                    return(mj.CenterPoint);
                }
                else if (type == PipeLine.CrossType.CrossOver)
                {
                    MultiPipeJoint mj = new MultiPipeJoint(this, true);
                    List <Point3d> ps = mj.GenerateFromCrossPipe(cItem, pipeLine.Point(1), pipeLine.Point(0), PipeLine.GetScale() / 2);
                    PipeLine       p1 = new PipeLine(cItem.Point(0), ps[0], this, true);
                    PipeLine       p2 = new PipeLine(ps[1], cItem.Point(1), this, true);
                    if (cItem.HeadConnectedObject != null)
                    {
                        cItem.HeadConnectedObject.RemovePipeLine(cItem);
                        cItem.HeadConnectedObject.AddPipeLine(p1);
                    }
                    if (cItem.TailConnectedObject != null)
                    {
                        cItem.TailConnectedObject.RemovePipeLine(cItem);
                        cItem.TailConnectedObject.AddPipeLine(p2);
                    }

                    p1.HeadConnectedObject = cItem.HeadConnectedObject;
                    p1.TailConnectedObject = mj;
                    p2.HeadConnectedObject = mj;
                    p2.TailConnectedObject = cItem.TailConnectedObject;

                    Point3d startPoint = ps[2];
                    cItem.Delete();

                    PipeLine pLine = new PipeLine(pipeLine.Point(0), startPoint, false, this);
                    pLine.TailConnectedObject = mj;
                    if (pipeLine.HeadConnectedObject != null)
                    {
                        pipeLine.HeadConnectedObject.RemovePipeLine(pipeLine);
                        pipeLine.HeadConnectedObject.AddPipeLine(pLine);
                        pLine.HeadConnectedObject = pipeLine.HeadConnectedObject;
                    }
                    mj.AddPipeLine(p1);
                    mj.AddPipeLine(p2);
                    mj.AddPipeLine(pLine);
                    PipeLineCrossTest(pLine);
                    //插入新的点
                    PipeLine se = mj.UpdateMultiJoint(pipeLine.Point(1));
                    se.HeadConnectedObject = mj;
                    if (pipeLine.TailConnectedObject != null)
                    {
                        pipeLine.TailConnectedObject.RemovePipeLine(pipeLine);
                        pipeLine.TailConnectedObject.AddPipeLine(se);
                        se.TailConnectedObject = pipeLine.TailConnectedObject;
                    }
                    res = PipeLineCrossTest(se);
                    return(res);
                }
            }
            foreach (var item in SimplePipeJoints)
            {
                SimplePipeJoint pItem = (SimplePipeJoint)item.Value;
                if (pItem.PointInJoint(pipeLine.Point(0)) && !pItem.ConnectedPipes.Contains(pipeLine))
                {
                    MultiPipeJoint mpj = new MultiPipeJoint(this, true);
                    PipeLine       ps  = mpj.GenerateFromSimpleJoint(pItem, pipeLine.Point(1), PipeLine.GetScale() / 2);
                    ps.HeadConnectedObject = mpj;
                    res = PipeLineCrossTest(ps);
                    return(res);
                }
                if (pItem.PointInJoint(pipeLine.Point(1)) && !pItem.ConnectedPipes.Contains(pipeLine))
                {
                    MultiPipeJoint mpj = new MultiPipeJoint(this, true);
                    PipeLine       ps  = mpj.GenerateFromSimpleJoint(pItem, pipeLine.Point(0), PipeLine.GetScale() / 2);
                    ps.TailConnectedObject = mpj;
                    res = PipeLineCrossTest(ps);
                    return(null);
                }
            }
            foreach (var item in MultiPipeJoints)
            {
                MultiPipeJoint pItem = (MultiPipeJoint)item.Value;
                if (pItem.PointInJoint(pipeLine.Point(0)) && !pItem.ConnectedPipes.Contains(pipeLine))
                {
                    PipeLine se = pItem.UpdateMultiJoint(pipeLine.Point(1));
                    se.HeadConnectedObject = pItem;
                    res = PipeLineCrossTest(se);
                    return(res);
                }
                if (pItem.PointInJoint(pipeLine.Point(1)) && !pItem.ConnectedPipes.Contains(pipeLine))
                {
                    PipeLine se = pItem.UpdateMultiJoint(pipeLine.Point(0));
                    se.HeadConnectedObject = pItem;
                    res = PipeLineCrossTest(se);
                    return(null);
                }
            }
            pipeLine.SaveEntity();
            return(pipeLine.Point(1));
        }