프로젝트

일반

사용자정보

개정판 56bc67e1

ID56bc67e170d916966c3d5c4b9cb38b0ad1d2eb31
상위 5e6ecf05
하위 13d5d6cf

gaqhf 이(가) 약 6년 전에 추가함

dev issue #000 : 두교차점 추가

Change-Id: I36330e571388d819068344896ab761a735b19a6c

차이점 보기:

DTI_PID/SPPIDConverter/AutoModeling.cs
396 396
                    else if (connItem != null && connItem.GetType() == typeof(Line))
397 397
                    {
398 398
                        connectorVertices1 = GetPipeRunVertices(((Line)connItem).SPPID.ModelItemId);
399
                        targetConnector1 = FindTargetLMConnector(connectorVertices1, line.SPPID.START_X, line.SPPID.START_Y);
399
                        targetConnector1 = FindTargetLMConnector(connectorVertices1, line.SPPID.START_X, line.SPPID.START_Y, line.SPPID.END_X, line.SPPID.END_Y);
400 400

  
401 401
                        if (targetConnector1 != null)
402 402
                            placeRunInputs.AddConnectorTarget(targetConnector1, line.SPPID.START_X, line.SPPID.START_Y);
......
427 427
                    else if (connItem != null && connItem.GetType() == typeof(Line))
428 428
                    {
429 429
                        connectorVertices2 = GetPipeRunVertices(((Line)connItem).SPPID.ModelItemId);
430
                        targetConnector2 = FindTargetLMConnector(connectorVertices2, line.SPPID.END_X, line.SPPID.END_Y);
430
                        targetConnector2 = FindTargetLMConnector(connectorVertices2, line.SPPID.END_X, line.SPPID.END_Y, line.SPPID.START_X, line.SPPID.START_Y);
431 431

  
432 432
                        if (targetConnector2 != null)
433 433
                            placeRunInputs.AddConnectorTarget(targetConnector2, line.SPPID.END_X, line.SPPID.END_Y);
......
502 502
            return connectorVertices;
503 503
        }
504 504

  
505
        private LMConnector FindTargetLMConnector(Dictionary<LMConnector, List<double[]>> connectorVertices, double x, double y)
505
        private LMConnector FindTargetLMConnector(Dictionary<LMConnector, List<double[]>> connectorVertices, double connX, double connY, double x2, double y2)
506 506
        {
507 507
            double length = double.MaxValue;
508 508
            LMConnector targetConnector = null;
......
519 519
                    double maxLineY = Math.Max(point1[1], point2[1]);
520 520
                    double minLineY = Math.Min(point1[1], point2[1]);
521 521

  
522
                    // 두직선의 교차점으로 구하면 될듯 그리고 교차점이 x y랑 제일 가까운것
523

  
524
                    if ((minLineX <= x && maxLineX >= x) ||
525
                        (minLineY <= y && maxLineY >= y))
522
                    // 두직선의 교차점
523
                    double[] crossingPoint = SPPIDUtil.CalcLineCrossingPoint(connX, connY, x2, y2, point1[0], point1[1], point2[0], point2[1]);
524
                    if (crossingPoint != null)
526 525
                    {
527
                        double result = SPPIDUtil.CalcLineToPointDistance(point1[0], point1[1], point2[0], point2[1], x, y);
528
                        if (length > result)
529
                        {
530
                            targetConnector = item.Key;
531
                            length = result;
532
                        }
526
                        
527

  
533 528
                    }
529

  
530

  
531
                    // 두직선의 교차점으로 구하면 될듯 그리고 교차점이 x y랑 제일 가까운것
532

  
533
                    //if ((minLineX <= x && maxLineX >= x) ||
534
                    //    (minLineY <= y && maxLineY >= y))
535
                    //{
536
                    //    double result = SPPIDUtil.CalcLineToPointDistance(point1[0], point1[1], point2[0], point2[1], connX, connY);
537
                    //    if (length > result)
538
                    //    {
539
                    //        targetConnector = item.Key;
540
                    //        length = result;
541
                    //    }
542
                    //}
534 543
                }
535 544
            }
536 545

  
DTI_PID/SPPIDConverter/ConverterForm.cs
515 515
        private void btnRun_Click(object sender, EventArgs e)
516 516
        {
517 517
#if DEBUG
518
            //SPPID_Document document = new SPPID_Document(@"Z:\HanKyouHo\temp\Isocynates\Temp\11111.xml");
519
            SPPID_Document document = new SPPID_Document(@"Z:\HanKyouHo\temp\Isocynates\Temp\zIsocynates-325_Page75.xml");
518
            SPPID_Document document = new SPPID_Document(@"Z:\HanKyouHo\temp\Isocynates\Temp\11111.xml");
519
            //SPPID_Document document = new SPPID_Document(@"Z:\HanKyouHo\temp\Isocynates\Temp\zIsocynates-325_Page75.xml");
520 520
            document.SymbolMappings = symbolMappings;
521 521
            document.LineMappings = lineMappings;
522 522
            document.LineNumberMappings = lineNumberMappings;
DTI_PID/SPPIDConverter/SPPIDConverter.csproj
5 5
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6 6
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7 7
    <ProjectGuid>{B6757E78-6B59-40A3-A7BB-E73E8F81B6C3}</ProjectGuid>
8
    <OutputType>Library</OutputType>
8
    <OutputType>WinExe</OutputType>
9 9
    <AppDesignerFolder>Properties</AppDesignerFolder>
10 10
    <RootNamespace>Converter.SPPID</RootNamespace>
11 11
    <AssemblyName>SPPIDConverter</AssemblyName>
DTI_PID/SPPIDConverter/Util/SPPIDUtil.cs
108 108
            calcX = Math.Truncate(calcX * 1000) / 1000;
109 109
            calcY = tempHeight - ((tempY * tempHeight) / tempDwgY);
110 110
            calcY = Math.Truncate(calcY * 1000) / 1000;
111
            dX = Convert.ToDouble(calcX);
112
            dY = Convert.ToDouble(calcY);
111
            dX = Math.Round(Convert.ToDouble(calcX), 10);
112
            dY = Math.Round(Convert.ToDouble(calcY), 10);
113 113
        }
114 114

  
115 115
        public static SlopeType CalcSlope(double x1, double y1, double x2, double y2)
......
151 151
            return distance;
152 152
        }
153 153

  
154
        public static double[] CalcLineCrossingPoint(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
155
        {
156
            x1 = Math.Round(x1, 10);
157
            x2 = Math.Round(x2, 10);
158
            x3 = Math.Round(x3, 10);
159
            x4 = Math.Round(x4, 10);
160

  
161
            y1 = Math.Round(y1, 10);
162
            y2 = Math.Round(y2, 10);
163
            y3 = Math.Round(y3, 10);
164
            y4 = Math.Round(y4, 10);
165

  
166
            double a1;
167
            double a2;
168
            double b1;
169
            double b2;
170

  
171
            if (x1 == x2)
172
                a1 = 0;
173
            else
174
                a1 = (y2 - y1) / (x2 - x1);
175
            if (x3 == x4)
176
                a2 = 0;
177
            else
178
                a2 = (y4 - y3) / (x4 - x3);
179

  
180
            b1 = -a1 * x1 + y1;
181
            b2 = -a2 * x3 + y3;
182

  
183
            if ((x1 == x2 && x3 == x4) ||
184
                (y1 == y2 && y3 == y4))
185
            {
186
                return null;
187
            }
188
            else if (x1 == x2)
189
            {
190
                return new double[] { x1, a2*x1 + b2 };
191
            }
192
            else if (x3 == x4)
193
            {
194
                return new double[] { x3, a1 * x3 + b1 };
195
            }
196
            else
197
            {
198
                return new double[] { -(b1 - b2) / (a1 - a2), a1 * (-(b1 - b2) / (a1 - a2) + b1) };
199
            }
200
        }
154 201
        #region
155 202
        public static bool IsBranchLine(string UID, Line connectedLine)
156 203
        {

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)