프로젝트

일반

사용자정보

개정판 9e781a4e

ID9e781a4ea614fce526b81433955cfa02033d7325
상위 2b0fba39
하위 fd18e5cc, 0ba38320

조봉훈이(가) 일년 이상 전에 추가함

Fix Match Up/Down Stream. Change the drawing order.

Change-Id: I38a2bdbea3795ca79331d4c1d8c9a0a43685660b

차이점 보기:

DTI_PID/SPPIDConverter/AutoModeling.cs
23 23
using Newtonsoft.Json;
24 24
using DevExpress.XtraSplashScreen;
25 25
using System.IO;
26
using LMAutomationUtil;
26 27

  
27 28
namespace Converter.SPPID
28 29
{
......
106 107
                    Log.Write("Start Modeling");
107 108
                    SplashScreenManager.ShowForm(typeof(SPPIDSplashScreen), true, true);
108 109
                    SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetParent, (IntPtr)radApp.HWnd);
109
                    SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllStepCount, 26);
110
                    SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllStepCount, 24);
110 111
                    SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetDocumentName, DocumentLabelText);
111 112

  
112 113
                    // VendorPackage Modeling
......
367 368
        private void RunLineModeling()
368 369
        {
369 370
            List<Line> AllLine = document.LINES.ToList();
370
            List<Line> stepLast_Line = document.LINES.FindAll(x => x.CONNECTORS.FindAll(y => y.ConnectedObject != null
371
                                                                                     && y.ConnectedObject.GetType() == typeof(Symbol)).Count == 2
372
                                                                                     && !SPPIDUtil.IsBranchedLine(document, x));
373
            List<Line> step1_Line = AllLine.FindAll(x => !stepLast_Line.Contains(x));
374 371

  
375
            SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllProgress, step1_Line.Count);
376
            SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Line Modeling - 1");
372
            SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllProgress, AllLine.Count);
373
            SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Line Modeling");
377 374

  
378
            SetPriorityLine(step1_Line);
379
            while (step1_Line.Count > 0)
375
            SetPriorityLine(AllLine);
376
            while (AllLine.Count > 0)
380 377
            {
381 378
                try
382 379
                {
383
                    Line item = step1_Line[0];
380
                    Line item = AllLine[0];
384 381
                    if (!string.IsNullOrEmpty(item.SPPID.ModelItemId) || BranchLines.Contains(item) || document.VentDrainLine.Contains(item))
385 382
                    {
386
                        step1_Line.Remove(item);
383
                        AllLine.Remove(item);
387 384
                    }
388 385
                    else
389 386
                    {
390 387
                        NewLineModeling(item);
391
                        step1_Line.Remove(item);
388
                        AllLine.Remove(item);
392 389
                        if (string.IsNullOrEmpty(item.SPPID.ModelItemId))
393 390
                        {
394
                            step1_Line.Add(item);
391
                            AllLine.Add(item);
395 392
                        }
396 393
                    }
397
                    if (!step1_Line.Contains(item))
394
                    if (!AllLine.Contains(item) && !this.BranchLines.Contains(item))
398 395
                        SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.UpProgress, null);
399 396
                }
400 397
                catch (Exception ex)
401 398
                {
402 399
                    Log.Write("Error in NewLineModeling");
403
                    Log.Write("UID : " + step1_Line[0].UID);
400
                    Log.Write("UID : " + AllLine[0].UID);
404 401
                    Log.Write(ex.Message);
405 402
                    Log.Write(ex.StackTrace);
406
                    step1_Line.Remove(step1_Line[0]);
403
                    AllLine.Remove(AllLine[0]);
407 404
                }
408 405
            }
409 406

  
410
            SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllProgress, BranchLines.Count);
411
            SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Line Modeling - 2");
412
            int branchCount = BranchLines.Count;
413 407
            SortBranchLines();
414 408
            while (BranchLines.Count > 0)
415 409
            {
......
441 435
                    BranchLines.Remove(BranchLines[0]);
442 436
                }
443 437
            }
444

  
445
            SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllProgress, stepLast_Line.Count);
446
            SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Line Modeling - 3");
447
            while (stepLast_Line.Count > 0)
448
            {
449
                try
450
                {
451
                    Line item = stepLast_Line[0];
452
                    if (!string.IsNullOrEmpty(item.SPPID.ModelItemId) || BranchLines.Contains(item) || document.VentDrainLine.Contains(item))
453
                    {
454
                        stepLast_Line.Remove(item);
455
                    }
456
                    else
457
                    {
458
                        NewLineModeling(item);
459
                        stepLast_Line.Remove(item);
460
                        if (string.IsNullOrEmpty(item.SPPID.ModelItemId))
461
                        {
462
                            stepLast_Line.Add(item);
463
                        }
464
                    }
465
                    if (!stepLast_Line.Contains(item))
466
                        SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.UpProgress, null);
467
                }
468
                catch (Exception ex)
469
                {
470
                    Log.Write("Error in NewLineModeling");
471
                    Log.Write("UID : " + stepLast_Line[0].UID);
472
                    Log.Write(ex.Message);
473
                    Log.Write(ex.StackTrace);
474
                    stepLast_Line.Remove(stepLast_Line[0]);
475
                }
476
            }
477 438
        }
478 439
        private void RunVentDrainModeling()
479 440
        {
......
846 807
                    Log.Write(ex.Message);
847 808
                    Log.Write(ex.StackTrace);
848 809
                }
849

  
850
            SetFlowAllLine();
851 810
        }
852 811
        private void RunSpecBreakModeling()
853 812
        {
......
1272 1231
                }
1273 1232
                SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.UpProgress, null);
1274 1233
            }
1234

  
1235
            SetFlowAllLine();
1275 1236
        }
1276 1237
        /// <summary>
1277 1238
        /// 도면 생성 메서드
......
2659 2620
            if (!BranchLines.Contains(line))
2660 2621
                LineCoordinateCorrection(group);
2661 2622

  
2623
            Line prevLine = null;
2624
            if (group[0].CONNECTORS[0].ConnectedObject != null)
2625
            {
2626
                if (group[0].CONNECTORS[0].ConnectedObject.GetType() == typeof(Symbol))
2627
                {
2628
                    prevLine = SPPIDUtil.FindOtherLine(group[0], (Symbol)group[0].CONNECTORS[0].ConnectedObject, 0);
2629
                }
2630
                else if (group[0].CONNECTORS[0].ConnectedObject.GetType() == typeof(Line))
2631
                {
2632
                    prevLine = group[0].CONNECTORS[0].ConnectedObject as Line;
2633
                }
2634
            }
2635

  
2662 2636
            for (int i = 0; i < group.Count; i++)
2663 2637
            {
2664 2638
                string targetModelItemId = null;
2665 2639
                var currentLine = group[i];
2666 2640

  
2667
                if (!isBranchModeling && SPPIDUtil.IsBranchLine(currentLine))
2641
                if (!isBranchModeling && 
2642
                    (prevLine != null && string.IsNullOrWhiteSpace(prevLine.SPPID.ModelItemId) ||
2643
                     SPPIDUtil.IsBranchStartLine(currentLine)))
2668 2644
                {
2669 2645
                    for (int j = i; j < group.Count; j++)
2670 2646
                    {
2671
                        var brachLine = group[j];
2647
                        var brachLine = group[j];                        
2672 2648
                        if (!BranchLines.Contains(brachLine))
2673 2649
                            BranchLines.Add(brachLine);
2674 2650
                    }
2675 2651
                    break;
2676 2652
                }
2677
                if (currentLine.CONNECTORS[0].ConnectedObject != null
2678
                    && currentLine.CONNECTORS[0].ConnectedObject.GetType() == typeof(Line)
2679
                    && string.IsNullOrEmpty(((Line)currentLine.CONNECTORS[0].ConnectedObject).SPPID.ModelItemId)
2680
                    && currentLine.TRYCOUNT < 100)
2653
                if (currentLine.CONNECTORS[0].ConnectedObject != null &&
2654
                    ((currentLine.CONNECTORS[0].ConnectedObject.GetType() == typeof(Line) &&
2655
                      string.IsNullOrEmpty(((Line)currentLine.CONNECTORS[0].ConnectedObject).SPPID.ModelItemId)) ||
2656
                     (prevLine != null && string.IsNullOrWhiteSpace(prevLine.SPPID.ModelItemId))) &&
2657
                     currentLine.TRYCOUNT < 100)
2681 2658
                {
2682 2659
                    currentLine.TRYCOUNT++;
2683 2660
                    break;
......
2687 2664
                if (currentLine.SlopeType != SlopeType.HORIZONTAL && currentLine.SlopeType != SlopeType.VERTICAL)
2688 2665
                    diagonal = true;
2689 2666
                _LMAItem lMAItem = _placement.PIDCreateItem(currentLine.SPPID.MAPPINGNAME);
2690
                if (currentLine.SPPID.MAPPINGNAME != @"\Piping\Routing\Process Lines\Secondary Piping.sym")
2691
                {
2692
                    currentLine.SPPID.MAPPINGNAME = currentLine.SPPID.MAPPINGNAME;
2693
                }
2667

  
2694 2668
                LMSymbol lMSymbolStart = null;
2695 2669
                LMSymbol lMSymbolEnd = null;
2696 2670
                PlaceRunInputs placeRunInputs = new PlaceRunInputs();
......
2710 2684
                            lMSymbolStart = GetTargetSymbol(targetSymbol, currentLine);
2711 2685
                            if (lMSymbolStart != null)
2712 2686
                            {
2713
                                foreach (LMConnector item in lMSymbolStart.Connect1Connectors)
2714
                                {
2715
                                    LMModelItem modelItem = dataSource.GetModelItem(item.ModelItemID);
2716
                                    string symbolPath = GetSPPIDFileName(modelItem);
2717
                                    if (currentLine.SPPID.MAPPINGNAME == symbolPath && item.Attributes["ItemStatus"].get_Value() == "Active" && item.Attributes["IsZeroLength"].get_Value() == "True")
2718
                                    {
2719
                                        targetModelItemId = item.ModelItemID;
2720
                                        break;
2721
                                    }
2722
                                }
2723 2687
                                foreach (LMConnector item in lMSymbolStart.Connect2Connectors)
2724 2688
                                {
2725 2689
                                    LMModelItem modelItem = dataSource.GetModelItem(item.ModelItemID);
......
2731 2695
                                    }
2732 2696
                                }
2733 2697

  
2734
                                if (targetModelItemId != null)
2735
                                {
2736
                                    placeRunInputs.AddPoint(x, y);
2737
                                }
2738
                                else
2739
                                {
2740
                                    placeRunInputs.AddSymbolTarget(lMSymbolStart, x, y, diagonal);
2741
                                }
2698
                                placeRunInputs.AddSymbolTarget(lMSymbolStart, x, y, diagonal);
2742 2699
                            }
2743 2700
                            else
2744 2701
                                placeRunInputs.AddPoint(x, y);
......
2747 2704
                        {
2748 2705
                            lMSymbolEnd = GetTargetSymbol(targetSymbol, currentLine);
2749 2706
                            if (lMSymbolEnd != null)
2707
                            {   
2750 2708
                                placeRunInputs.AddSymbolTarget(lMSymbolEnd, x, y, diagonal);
2709
                            }
2751 2710
                            else
2752 2711
                                placeRunInputs.AddPoint(x, y);
2753 2712
                        }
......
2777 2736
                            if (currentLine.CONNECTORS.IndexOf(connector) == 0)
2778 2737
                            {
2779 2738
                                index += 0.01;
2780
                                if (currentLine.SlopeType == SlopeType.HORIZONTAL)
2739
                                if (currentLine.SlopeType == SlopeType.HORIZONTAL &&
2740
                                    SPPIDUtil.IsNearValue(targetLine.SPPID.END_Y, currentLine.SPPID.START_Y)) 
2741
                                {
2781 2742
                                    placeRunInputs.AddPoint(x, -0.1 - index);
2782
                                else if (currentLine.SlopeType == SlopeType.VERTICAL)
2743
                                }
2744
                                else if (currentLine.SlopeType == SlopeType.VERTICAL &&
2745
                                    SPPIDUtil.IsNearValue(targetLine.SPPID.END_X, currentLine.SPPID.START_X))
2746
                                {
2783 2747
                                    placeRunInputs.AddPoint(-0.1 - index, y);
2784
                                else
2748
                                }
2749
                                else if (currentLine.SlopeType == SlopeType.Slope || currentLine.SlopeType == SlopeType.None)
2785 2750
                                {
2786 2751
                                    Line nextLine = currentLine.CONNECTORS[0].ConnectedObject as Line;
2787 2752
                                    if (SPPIDUtil.CalcAngle(nextLine.SPPID.START_X, nextLine.SPPID.START_Y, nextLine.SPPID.END_X, nextLine.SPPID.END_Y) < 45)
......
2793 2758

  
2794 2759
                            placeRunInputs.AddPoint(x, y);
2795 2760

  
2796
                            if (currentLine.CONNECTORS.IndexOf(connector) == 1)
2761
                            if (currentLine.CONNECTORS.IndexOf(connector) == 1 && targetLine.CONNECTORS[0].ConnectedObject != null && targetLine.CONNECTORS[0].ConnectedObject == currentLine)
2797 2762
                            {
2798 2763
                                index += 0.01;
2799
                                if (currentLine.SlopeType == SlopeType.HORIZONTAL)
2764
                                if (currentLine.SlopeType == SlopeType.HORIZONTAL   )
2800 2765
                                    placeRunInputs.AddPoint(x, -0.1 - index);
2801 2766
                                else if (currentLine.SlopeType == SlopeType.VERTICAL)
2802 2767
                                    placeRunInputs.AddPoint(-0.1 - index, y);
......
2821 2786
                    lMConnector.Commit();
2822 2787
                    if (!string.IsNullOrWhiteSpace(targetModelItemId))
2823 2788
                    {
2824
                        LMModelItem modelItem1 = dataSource.GetModelItem(targetModelItemId);
2825
                        LMModelItem modelItem2 = dataSource.GetModelItem(lMConnector.ModelItemID);
2826
                        _LMAItem item1 = modelItem1.AsLMAItem();
2827
                        _LMAItem item2 = modelItem2.AsLMAItem();
2828
                        _placement.PIDJoinRuns(item1, item2);
2829
                        item1.Commit();
2830
                        item2.Commit();
2831
                        ReleaseCOMObjects(item1);
2832
                        ReleaseCOMObjects(item2);
2833
                        ReleaseCOMObjects(modelItem1);
2834
                        ReleaseCOMObjects(modelItem2);
2789
                        string survivorId = string.Empty;
2790
                        JoinRun(targetModelItemId, lMConnector.ModelItemID, ref survivorId);
2791
                        currentLine.SPPID.ModelItemId = survivorId;
2792
                        //LMModelItem modelItem1 = dataSource.GetModelItem(targetModelItemId);
2793
                        //LMModelItem modelItem2 = dataSource.GetModelItem(lMConnector.ModelItemID);
2794
                        //_LMAItem item1 = modelItem1.AsLMAItem();
2795
                        //_LMAItem item2 = modelItem2.AsLMAItem();
2796
                        //_placement.PIDJoinRuns(item1, item2);
2797
                        //item1.Commit();
2798
                        //item2.Commit();
2799
                        //ReleaseCOMObjects(item1);
2800
                        //ReleaseCOMObjects(item2);
2801
                        //ReleaseCOMObjects(modelItem1);
2802
                        //ReleaseCOMObjects(modelItem2);
2803
                    }
2804
                    else
2805
                    {
2806
                        currentLine.SPPID.ModelItemId = lMConnector.ModelItemID;
2835 2807
                    }
2836

  
2837
                    currentLine.SPPID.ModelItemId = lMConnector.ModelItemID;
2838 2808

  
2839 2809
                    bool bRemodelingStart = false;
2840 2810
                    if (lMSymbolStart != null)
......
2846 2816
                    if (bRemodelingStart || bRemodelingEnd)
2847 2817
                        ReModelingLine(currentLine, lMConnector, lMSymbolStart, lMSymbolEnd, bRemodelingStart, bRemodelingEnd);
2848 2818

  
2819
                    SetFlowUpstream(lMConnector.ModelItemID);
2849 2820
                    FlowMarkModeling(currentLine);
2850 2821

  
2851
                    SetFlowUpstream(lMConnector.ModelItemID);
2852 2822
                    ReleaseCOMObjects(lMConnector);
2853 2823
                }
2854 2824
                else if (!isBranchModeling)
......
3364 3334
            ReleaseCOMObjects(modelItem);
3365 3335
        }
3366 3336

  
3337
        private void SetFlowAllLine()
3338
        {
3339
            LMConnectors connectors = GetConnectors();
3340
            foreach (LMConnector connector in connectors)
3341
            {
3342
                LMModelItem modelItem = connector.ModelItemObject;
3343
                if (modelItem.get_ItemStatus() == "Active" && modelItem.get_ItemTypeName().ToString() == "PipeRun")
3344
                {
3345
                    string changePipeRunType = GetPipeRunTypeByItem(modelItem);
3346
                    if (!string.IsNullOrWhiteSpace(changePipeRunType))
3347
                    {
3348
                        SetPipeRunType(connector.ModelItemID, changePipeRunType);
3349
                    }
3350
                    else if (connector.Attributes["IsZeroLength"].get_Value() == "True")
3351
                    {
3352
                        List<string> itemIdList_1 = FindConnModelItemIdList(connector.ModelItemID, connector.ModelItemID);
3353
                        List<string> itemIdList_2 = new List<string>();
3354
                        foreach (string id in itemIdList_1)
3355
                        {
3356
                            changePipeRunType = GetPipeRunTypeById(id);
3357
                            if (!string.IsNullOrWhiteSpace(changePipeRunType))
3358
                                break;
3359

  
3360
                            List<string> tempItemIdList  = FindConnModelItemIdList(id, connector.ModelItemID);
3361
                            foreach (string tempId in tempItemIdList)
3362
                            {
3363
                                if (!itemIdList_1.Contains(tempId) && !itemIdList_2.Contains(tempId))
3364
                                {
3365
                                    itemIdList_2.Add(tempId);
3366
                                }
3367
                            }
3368
                        }
3369
                        if (string.IsNullOrWhiteSpace(changePipeRunType))
3370
                        {
3371
                            foreach (string id in itemIdList_2)
3372
                            {
3373
                                changePipeRunType = GetPipeRunTypeById(id);
3374
                                if (!string.IsNullOrWhiteSpace(changePipeRunType))
3375
                                    break;
3376
                            }
3377
                        }
3378
                        if (!string.IsNullOrWhiteSpace(changePipeRunType))
3379
                        {
3380
                            SetPipeRunType(connector.ModelItemID, changePipeRunType);
3381
                        }
3382
                    }
3383
                    if (string.IsNullOrWhiteSpace(changePipeRunType))
3384
                    {
3385
                        changePipeRunType = "Piping, secondary";
3386
                        SetPipeRunType(connector.ModelItemID, changePipeRunType);
3387
                    }
3388
                    SetFlowUpstream(connector.ModelItemID);
3389
                    ReleaseCOMObjects(connector);
3390
                }
3391
                ReleaseCOMObjects(modelItem);
3392
            }
3393
            ReleaseCOMObjects(connectors);
3394

  
3395
            List<string> FindConnModelItemIdList (string modelItemID, string orgPipeRunModelId)
3396
            {
3397
                List<string> modelItemIdList = new List<string>();
3398
                LMModelItem modelItem = dataSource.GetModelItem(modelItemID);
3399
                _LMAItem lMAItem = modelItem.AsLMAItem();
3400
                _LMTracey lMTracey = new LMTracey();
3401
                foreach (_LMConnectionObject item in lMTracey.TopoConnections(lMAItem))
3402
                {
3403
                    if (item.mItem.Id != orgPipeRunModelId)
3404
                    {
3405
                        modelItemIdList.Add(item.mItem.Id);
3406
                    }
3407
                }
3408
                ReleaseCOMObjects(lMTracey);
3409
                ReleaseCOMObjects(lMAItem);
3410
                ReleaseCOMObjects(modelItem);
3411

  
3412
                return modelItemIdList;
3413
            }
3414
            string GetPipeRunTypeById(string modelItemID)
3415
            {
3416
                string pipeRunType = string.Empty;
3417

  
3418
                LMModelItem findModelItem = dataSource.GetModelItem(modelItemID);
3419
                if (findModelItem != null && findModelItem.get_ItemStatus() == "Active" && findModelItem.get_ItemTypeName().ToString() == "PipeRun")
3420
                {
3421
                    pipeRunType = GetPipeRunTypeByItem(findModelItem);
3422
                }
3423
                ReleaseCOMObjects(findModelItem);
3424

  
3425
                return pipeRunType;
3426
            }
3427
            string GetPipeRunTypeByItem(LMModelItem findModelItem)
3428
            {
3429
                string pipeRunType = string.Empty;
3430
                Line line = document.LINES.Find(f => f.SPPID.ModelItemId == findModelItem.Id);
3431
                if (line != null)
3432
                {
3433
                    string name = Path.GetFileNameWithoutExtension(line.SPPID.MAPPINGNAME).Split(' ')[0].ToLower();
3434
                    pipeRunType = string.Format("Piping, {0}", name);
3435
                    return pipeRunType;
3436
                }
3437

  
3438
                return pipeRunType;
3439
            }
3440
        }
3441
        
3367 3442
        private void SetFlowUpstream(dynamic modelItemID)
3368 3443
        {
3369 3444
            LMModelItem modelItem = dataSource.GetModelItem(modelItemID);
......
3376 3451
                ReleaseCOMObjects(modelItem);
3377 3452
            }
3378 3453
        }
3379
        private void SetFlowAllLine(string modelItemID = "")
3454
        private void SetPipeRunType(string modelItemID, string changePipeRunType)
3380 3455
        {
3381
            List<Line> lineList = null;
3382
            if (!string.IsNullOrWhiteSpace(modelItemID))
3383
            {
3384
                lineList = document.LINES.FindAll(z => z.SPPID.ModelItemId == modelItemID).ToList();
3385
            }
3386
            else
3387
            {
3388
                lineList = document.LINES;
3389
            }
3390
            foreach (var line in lineList)
3456
            LMModelItem modelItem = dataSource.GetModelItem(modelItemID);
3457
            _LMAItem item = modelItem.AsLMAItem();
3458

  
3459
            bool isChange = false;
3460
            ISPClientData3.ISPItem ispItem = item.ISPItem;
3461
            foreach (ISPClientData3.ISPAttribute attrib in ispItem.get_Attributes())
3391 3462
            {
3392
                foreach (var repId in line.SPPID.Representations)
3463
                if (attrib.AttName == "PipeRunType")
3393 3464
                {
3394
                    LMConnector _connector = dataSource.GetConnector(repId);
3395
                    if (_connector != null && _connector.get_ItemStatus() == "Active")
3396
                    {
3397
                        if (line.SPPID.ModelItemId != _connector.ModelItemID)
3398
                        {
3399
                            line.SPPID.ModelItemId = _connector.ModelItemID;
3400
                            line.SPPID.Representations = GetRepresentations(line.SPPID.ModelItemId);
3401
                        }
3402
                    }
3403
                    SetFlowUpstream(_connector.ModelItemID);
3404
                    ReleaseCOMObjects(_connector);
3465
                    attrib.Value = changePipeRunType;
3466
                    isChange = true;
3405 3467
                }
3406 3468
            }
3469
            if (isChange)
3470
            {
3471
                ispItem.Commit();
3472
            }
3473
            ReleaseCOMObjects(ispItem);
3474
            ReleaseCOMObjects(item);
3475
            ReleaseCOMObjects(modelItem);
3407 3476
        }
3408 3477
        /// <summary>
3409 3478
        /// Remodeling 과정에서 생긴 불필요한 Connector 제거
......
3666 3735
                newConnector.Commit();
3667 3736
                ZeroLengthSymbolToSymbolModelItemID.Add(newConnector.ModelItemID);
3668 3737
                SetFlowUpstream(newConnector.ModelItemID);
3738
                SetFlowUpstream(oldModelItemId);
3669 3739
                ReleaseCOMObjects(connector);
3670

  
3671
                SetFlowAllLine(oldModelItemId);
3672 3740
            }
3673 3741

  
3674 3742
            return newConnector;
......
4491 4559
        {
4492 4560
            try
4493 4561
            {
4562
                string pipeRunType1 = string.Empty;
4563
                string pipeRunType2 = string.Empty;
4494 4564
                LMModelItem modelItem1 = dataSource.GetModelItem(modelId1);
4495 4565
                LMConnector connector1 = GetLMConnectorFirst(modelId1);
4496 4566
                List<double[]> vertices1 = null;
......
4502 4572
                }
4503 4573
                _LMAItem item1 = modelItem1.AsLMAItem();
4504 4574
                ReleaseCOMObjects(connector1);
4505
                connector1 = null;
4506 4575

  
4507 4576
                LMModelItem modelItem2 = dataSource.GetModelItem(modelId2);
4508 4577
                LMConnector connector2 = GetLMConnectorFirst(modelId2);
......
4515 4584
                }
4516 4585
                _LMAItem item2 = modelItem2.AsLMAItem();
4517 4586
                ReleaseCOMObjects(connector2);
4518
                connector2 = null;
4519

  
4520 4587

  
4521 4588
                ISPClientData3.ISPItem ispItem1 = item1.ISPItem;
4522
                ISPClientData3.ISPItemType ispItemType1 = ispItem1.get_ItemType();
4523 4589
                foreach (ISPClientData3.ISPAttribute attrib in ispItem1.get_Attributes())
4524 4590
                {
4525 4591
                    if (attrib.AttName == "PipeRunType")
4526 4592
                    {
4527
                        string aa = attrib.Value;
4593
                        pipeRunType1 = attrib.Value;
4594
                        break;
4528 4595
                    }
4529 4596
                }
4530

  
4597
                ReleaseCOMObjects(ispItem1);
4531 4598

  
4532 4599
                ISPClientData3.ISPItem ispItem2 = item2.ISPItem;
4533
                ISPClientData3.ISPItemType ispItemType2 = ispItem2.get_ItemType();
4534 4600
                foreach (ISPClientData3.ISPAttribute attrib in ispItem2.get_Attributes())
4535 4601
                {
4536 4602
                    if (attrib.AttName == "PipeRunType")
4537 4603
                    {
4538
                        string aa = attrib.Value;
4604
                        pipeRunType2 = attrib.Value;
4605
                        break;
4539 4606
                    }
4540 4607
                }
4541

  
4608
                ReleaseCOMObjects(ispItem2);
4542 4609

  
4543 4610
                // item2가 item1으로 조인
4544 4611
                _placement.PIDJoinRuns(ref item1, ref item2);
......
4592 4659
                        line.SPPID.ModelItemId = afterID;
4593 4660
                }
4594 4661

  
4662
                if (survivorId != null)
4663
                {
4664
                    string changePipeRunType = pipeRunType1.Length >= pipeRunType2.Length ? pipeRunType1 : pipeRunType2;
4665
                    SetPipeRunType(survivorId, changePipeRunType);
4666
                }
4667

  
4595 4668
                ReleaseCOMObjects(modelItem1);
4596 4669
                ReleaseCOMObjects(item1);
4597 4670
                ReleaseCOMObjects(modelItem2);
......
4603 4676
                Log.Write(ex.Message + "\r\n" + ex.StackTrace);
4604 4677
            }
4605 4678
        }
4679
        
4606 4680
        private bool IsModelingEndBreak(Symbol symbol1, Symbol symbol2)
4607 4681
        {
4608 4682
            bool result = false;
......
6855 6929
            DataTable symbolTable = document.SymbolTable;
6856 6930
            // List에 순서대로 쌓는다.
6857 6931
            List<Symbol> symbols = new List<Symbol>();
6932
            List<Symbol> symbolsOther = new List<Symbol>();
6933
            List<Symbol> symbolsEnd = new List<Symbol>();
6858 6934

  
6859 6935
            // Angle Valve 부터
6860 6936
            foreach (var symbol in document.SYMBOLS.FindAll(x => x.CONNECTORS.FindAll(y => y.Index == 0).Count == 2))
......
6883 6959

  
6884 6960
                    if ((slopeType1 == SlopeType.VERTICAL && slopeType2 == SlopeType.HORIZONTAL) ||
6885 6961
                        (slopeType2 == SlopeType.VERTICAL && slopeType1 == SlopeType.HORIZONTAL))
6962
                    {
6886 6963
                        symbols.Add(symbol);
6964
                    }
6887 6965
                }
6888 6966
            }
6889 6967

  
6890
            List<Symbol> tempSymbols = new List<Symbol>();
6968
            symbolsEnd = document.SYMBOLS.FindAll(f => f.NAME.ToUpper().Contains("BLIND") && f.CONNECTORS.FindAll(y => y.Index == 0).Count == 1);
6969

  
6891 6970
            // Conn 갯수 기준
6892 6971
            foreach (var item in document.SYMBOLS)
6893 6972
            {
6894
                if (!symbols.Contains(item))
6895
                    tempSymbols.Add(item);
6973
                if (!symbols.Contains(item) && !symbolsEnd.Contains(item))
6974
                    symbolsEnd.Add(item);
6896 6975
            }
6897
            tempSymbols.Sort(SPPIDUtil.SortSymbolPriority);
6898
            symbols.AddRange(tempSymbols);
6976
            symbolsOther.Sort(SPPIDUtil.SortSymbolPriority);
6977
            symbols.AddRange(symbolsOther);
6978
            symbols.AddRange(symbolsEnd);
6899 6979

  
6900 6980
            return symbols;
6901 6981
        }
......
6906 6986

  
6907 6987
            int SortLinePriority(Line a, Line b)
6908 6988
            {
6909
                int childRetval = CompareChild(a, b);
6910
                if (childRetval != 0)
6989
                int entRetval = CompareEnd(a, b);
6990
                if (entRetval != 0)
6911 6991
                {
6912
                    return childRetval;
6992
                    return entRetval;
6913 6993
                }
6914 6994
                else
6915
                { 
6916
                    // Branch 없는것부터
6917
                    int branchRetval = CompareBranchLine(a, b);
6918
                    if (branchRetval != 0)
6995
                {
6996
                    // line 길이
6997
                    int lengthRetval = CompareLength(a, b);
6998
                    if (lengthRetval != 0)
6919 6999
                    {
6920
                        return branchRetval;
7000
                        return lengthRetval;
6921 7001
                    }
6922 7002
                    else
6923 7003
                    {
6924
                        // 아이템 연결 갯수(심볼, Line이면서 Not Branch)
6925
                        int connItemRetval = CompareConnItem(a, b);
6926
                        if (connItemRetval != 0)
7004
                        int childRetval = CompareChild(a, b);
7005
                        if (childRetval != 0)
6927 7006
                        {
6928
                            return connItemRetval;
7007
                            return childRetval;
6929 7008
                        }
6930 7009
                        else
6931 7010
                        {
6932
                            // line 길이
6933
                            int lengthRetval = CompareLength(a, b);
6934
                            if (lengthRetval != 0)
7011
                            // Branch 없는것부터
7012
                            int branchRetval = CompareBranchLine(a, b);
7013
                            if (branchRetval != 0)
6935 7014
                            {
6936
                                return lengthRetval;
7015
                                return branchRetval;
6937 7016
                            }
6938 7017
                            else
6939 7018
                            {
6940
                                // Symbol 연결 갯수
6941
                                int connSymbolRetval = CompareConnSymbol(a, b);
6942
                                if (connSymbolRetval != 0)
7019
                                // 아이템 연결 갯수(심볼, Line이면서 Not Branch)
7020
                                int connItemRetval = CompareConnItem(a, b);
7021
                                if (connItemRetval != 0)
6943 7022
                                {
6944
                                    return connSymbolRetval;
7023
                                    return connItemRetval;
6945 7024
                                }
6946 7025
                                else
6947 7026
                                {
6948
                                    // ConnectedItem이 없는것
6949
                                    int noneConnRetval = CompareNoneConn(a, b);
6950
                                    if (noneConnRetval != 0)
7027
                                    // Symbol 연결 갯수
7028
                                    int connSymbolRetval = CompareConnSymbol(a, b);
7029
                                    if (connSymbolRetval != 0)
6951 7030
                                    {
6952
                                        return noneConnRetval;
7031
                                        return connSymbolRetval;
6953 7032
                                    }
6954 7033
                                    else
6955 7034
                                    {
6956

  
7035
                                        // ConnectedItem이 없는것
7036
                                        int noneConnRetval = CompareNoneConn(a, b);
7037
                                        if (noneConnRetval != 0)
7038
                                        {
7039
                                            return noneConnRetval;
7040
                                        }                                        
6957 7041
                                    }
6958 7042
                                }
6959 7043
                            }
......
6964 7048
                return 0;
6965 7049
            }
6966 7050

  
7051
            int CompareEnd(Line a, Line b)
7052
            {
7053
                int valueA = 0;
7054
                int valueB = 0;
7055
                if (a.CONNECTORS[0].ConnectedObject == null)
7056
                {
7057
                    valueA = 1;
7058
                }
7059
                else if (a.CONNECTORS[0].ConnectedObject != null && a.CONNECTORS[0].ConnectedObject.GetType() == typeof(Symbol) && SPPIDUtil.FindOtherLine(a, (Symbol)a.CONNECTORS[0].ConnectedObject, 0) == null)
7060
                {
7061
                    valueA = 2;
7062
                }
7063

  
7064
                if (b.CONNECTORS[0].ConnectedObject == null)
7065
                {
7066
                    valueB = 1;
7067
                }
7068
                else if (b.CONNECTORS[0].ConnectedObject != null && b.CONNECTORS[0].ConnectedObject.GetType() == typeof(Symbol) && SPPIDUtil.FindOtherLine(b, (Symbol)b.CONNECTORS[0].ConnectedObject, 0) == null)
7069
                {
7070
                    valueB = 2;
7071
                }
7072

  
7073
                // 오름차순
7074
                return valueB.CompareTo(valueA);
7075
            }
7076

  
6967 7077
            int CompareChild(Line a, Line b)
6968 7078
            {
6969 7079
                int countA = a.CONNECTORS.Count(x => x.ConnectedObject != null && x.ConnectedObject.GetType() == typeof(Line) && x.ConnectedObject == b);
......
7099 7209

  
7100 7210
        private void SortBranchLines()
7101 7211
        {
7102
            BranchLines.Sort(SortBranchLine);
7212
            this.BranchLines.Sort(SortBranchLine);
7213

  
7214
            List<Line> newLineList = new List<Line>();
7215
            foreach (Line line in this.BranchLines)
7216
            {
7217
                CheckBranch(line);
7218
            }
7219
            this.BranchLines = newLineList.ToList();
7103 7220

  
7104 7221
            int SortBranchLine(Line a, Line b)
7105 7222
            {
......
7157 7274
                // 내림차순
7158 7275
                return countA.CompareTo(countB);
7159 7276
            }
7277

  
7278
            void CheckBranch(Line checkLine)
7279
            {
7280
                if (!newLineList.Contains(checkLine))
7281
                {
7282
                    newLineList.Add(checkLine);
7283
                }
7284
                List<Line> otherLineList = document.LINES.Where(w => (checkLine.CONNECTORS[1].ConnectedObject == null || w != checkLine.CONNECTORS[1].ConnectedObject) &&
7285
                                                          w.CONNECTORS[0].ConnectedObject != null &&
7286
                                                          w.CONNECTORS[0].ConnectedObject.GetType() == typeof(Line) &&
7287
                                                          w.CONNECTORS[0].ConnectedObject == checkLine).ToList();
7288

  
7289
                if (otherLineList != null)
7290
                {
7291
                    foreach (Line otherLine in otherLineList)
7292
                    {
7293
                        int otherIndex = newLineList.IndexOf(checkLine) + 1;
7294
                        if (newLineList.Contains(otherLine))
7295
                        {
7296
                            int currentIndex = newLineList.IndexOf(otherLine);
7297
                            if (currentIndex < otherIndex)
7298
                            {
7299
                                otherIndex--;
7300
                            }
7301
                            newLineList.Remove(otherLine);
7302
                        }
7303

  
7304
                        if (otherLine != null)
7305
                        {
7306
                            newLineList.Insert(otherIndex, otherLine);
7307
                            CheckBranch(otherLine);
7308
                        }
7309
                    }
7310
                }
7311

  
7312
                Line backLine = null;
7313
                if (checkLine.CONNECTORS.Count >= 2 &&
7314
                    checkLine.CONNECTORS[1].ConnectedObject != null)
7315
                {
7316
                    if (checkLine.CONNECTORS[1].ConnectedObject.GetType() == typeof(Line))
7317
                    {
7318
                        backLine = checkLine.CONNECTORS[1].ConnectedObject as Line;
7319
                        if (backLine != null && !this.BranchLines.Contains(backLine))
7320
                        {
7321
                            backLine = null;
7322
                        }
7323
                    }
7324
                    else if (checkLine.CONNECTORS[1].ConnectedObject.GetType() == typeof(Symbol))
7325
                    {
7326
                        Symbol symbol = checkLine.CONNECTORS[1].ConnectedObject as Symbol;
7327
                        backLine = SPPIDUtil.FindOtherLine(checkLine, symbol, 1);
7328
                        if (backLine != null && !this.BranchLines.Contains(backLine))
7329
                        {
7330
                            backLine = null;
7331
                        }
7332
                    }
7333
                }
7334

  
7335
                if (backLine != null)
7336
                {
7337
                    int backIndex = newLineList.IndexOf(checkLine) + 1;
7338
                    if (newLineList.Contains(backLine))
7339
                    {
7340
                        int currentIndex = newLineList.IndexOf(backLine);
7341
                        if (currentIndex < backIndex)
7342
                        {
7343
                            backIndex--;
7344
                        }
7345
                        newLineList.Remove(backLine);
7346
                    }
7347

  
7348
                    if (backLine != null)
7349
                    {
7350
                        newLineList.Insert(backIndex, backLine);
7351
                        CheckBranch(backLine);
7352
                    }
7353
                }
7354
            }
7160 7355
        }
7161 7356

  
7162 7357
        private string GetSPPIDFileName(LMModelItem modelItem)
......
7251 7446
        }
7252 7447
    }
7253 7448
}
7449

  

내보내기 Unified diff

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