프로젝트

일반

사용자정보

개정판 238eb5d2

ID238eb5d2f1f3af865355089cd1d1490766404620
상위 63a112d9
하위 4c7a4484

gaqhf 이(가) 5년 이상 전에 추가함

dev issue #507 : remove flowdirection after

Change-Id: I632de1b20f8e001158036a13a2d35ac979c8f5d7

차이점 보기:

DTI_PID/SPPIDConverter/AutoModeling.cs
88 88
                    Log.Write("Start Modeling");
89 89
                    SplashScreenManager.ShowForm(typeof(SPPIDSplashScreen), true, true);
90 90
                    SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetParent, (IntPtr)radApp.HWnd);
91
                    SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllStepCount, 24);
91
                    SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllStepCount, 23);
92 92
                    SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetDocumentName, DocumentLabelText);
93 93

  
94 94
                    // VendorPackage Modeling
......
107 107
                    RunJoinRunForSameConnector();
108 108
                    // Join Run
109 109
                    RunJoinRun();
110
                    //// Check FlowDirection
111
                    //RunFlowDirection();
112 110
                    // EndBreak Modeling
113 111
                    RunEndBreakModeling();
114 112
                    // SpecBreak Modeling
......
711 709
                SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.UpProgress, null);
712 710
            }
713 711
        }
714
        private void RunFlowDirection()
715
        {
716
            SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllProgress, 
717
                document.LINES.Count + ZeroLengthModelItemID.Count + ZeroLengthModelItemIDReverse.Count + ZeroLengthSymbolToSymbolModelItemID.Count);
718
            SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Check Flow Direction");
719
            foreach (var line in document.LINES)
720
            {
721
                if (!string.IsNullOrEmpty(line.SPPID.ModelItemId))
722
                {
723
                    LMModelItem modelItem = dataSource.GetModelItem(line.SPPID.ModelItemId);
724
                    if (modelItem != null && modelItem.get_ItemStatus() == "Active")
725
                    {
726
                        LMAAttribute attribute = modelItem.Attributes["FlowDirection"];
727
                        if (attribute != null)
728
                        {
729
                            attribute.set_Value("End 1 is upstream (Inlet)");
730
                            modelItem.Commit();
731
                        }
732

  
733
                        SetFlowDirectionByLine(line.SPPID.ModelItemId);
734

  
735
                        ReleaseCOMObjects(modelItem);
736
                        modelItem = null;
737
                    }
738
                }
739

  
740
                SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.UpProgress, null);
741
            }
742
            foreach (var modelId in ZeroLengthModelItemID)
743
            {
744
                LMModelItem zeroLengthModelItem = dataSource.GetModelItem(modelId);
745
                LMAAttribute attribute = zeroLengthModelItem.Attributes["FlowDirection"];
746
                if (attribute != null && zeroLengthModelItem.get_ItemStatus() == "Active")
747
                {
748
                    attribute.set_Value("End 1 is upstream (Inlet)");
749
                    zeroLengthModelItem.Commit();
750
                }
751

  
752
                SetFlowDirectionByLine(modelId);
753

  
754
                ReleaseCOMObjects(zeroLengthModelItem);
755
                zeroLengthModelItem = null;
756

  
757
                SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.UpProgress, null);
758
            }
759
            foreach (var modelId in ZeroLengthModelItemIDReverse)
760
            {
761
                LMModelItem zeroLengthModelItem = dataSource.GetModelItem(modelId);
762
                LMAAttribute attribute = zeroLengthModelItem.Attributes["FlowDirection"];
763
                if (attribute != null && zeroLengthModelItem.get_ItemStatus() == "Active")
764
                {
765
                    attribute.set_Value("End 1 is downstream (Outlet)");
766
                    zeroLengthModelItem.Commit();
767
                }
768

  
769
                SetFlowDirectionByLine(modelId);
770

  
771
                ReleaseCOMObjects(zeroLengthModelItem);
772
                zeroLengthModelItem = null;
773

  
774
                SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.UpProgress, null);
775
            }
776
            foreach (var modelId in ZeroLengthSymbolToSymbolModelItemID)
777
            {
778
                SetFlowDirectionByLine(modelId);
779
                SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.UpProgress, null);
780
            }
781

  
782
            void SetFlowDirectionByLine(string lineModelItemID)
783
            {
784
                LMModelItem modelItem = dataSource.GetModelItem(lineModelItemID);
785
                if (modelItem != null && modelItem.get_ItemStatus() == "Active")
786
                {
787
                    LMAAttribute attribute = modelItem.Attributes["FlowDirection"];
788
                    if (attribute != null && !DBNull.Value.Equals(attribute.get_Value()))
789
                    {
790
                        string sFlowDirection = attribute.get_Value().ToString();
791
                        foreach (LMRepresentation rep in modelItem.Representations)
792
                        {
793
                            if (rep.Attributes["RepresentationType"].get_Value() == "Connector" && rep.Attributes["ItemStatus"].get_Value() == "Active")
794
                            {
795
                                LMConnector connector = dataSource.GetConnector(rep.Id);
796

  
797
                                foreach (LMRelationship relationship in connector.Relation1Relationships)
798
                                    SetSymbolFlowDirectionByRelationShip(relationship, connector, sFlowDirection);
799
                                foreach (LMRelationship relationship in connector.Relation2Relationships)
800
                                    SetSymbolFlowDirectionByRelationShip(relationship, connector, sFlowDirection);
801

  
802
                                ReleaseCOMObjects(connector);
803
                            }
804
                        }
805
                    }
806
                    ReleaseCOMObjects(modelItem);
807
                    modelItem = null;
808
                }
809

  
810
                void SetSymbolFlowDirectionByRelationShip(LMRelationship relationship, LMConnector connector, string sFlowDirection)
811
                {
812
                    // Item2가 Symbol
813
                    if (!DBNull.Value.Equals(relationship.Item1RepresentationID) && relationship.Item1RepresentationID == connector.Id &&
814
                        relationship.Item2RepresentationObject != null && relationship.Item2RepresentationObject.get_RepresentationType() == "Symbol")
815
                    {
816
                        int symbolIndex = Convert.ToInt32(relationship.get_Item2Location());
817
                        int lineIndex = Convert.ToInt32(relationship.get_Item1Location());
818
                        LMModelItem symbolModelItem = relationship.Item2RepresentationObject.ModelItemObject;
819

  
820
                        SetSymbolFlowDirection(lineIndex, symbolIndex, sFlowDirection, symbolModelItem);
821

  
822
                        symbolModelItem.Commit();
823
                        ReleaseCOMObjects(symbolModelItem);
824
                        symbolModelItem = null;
825
                    }
826
                    // Item1이 Symbol
827
                    else if (!DBNull.Value.Equals(relationship.Item2RepresentationID) && relationship.Item2RepresentationID == connector.Id &&
828
                            relationship.Item1RepresentationObject != null && relationship.Item1RepresentationObject.get_RepresentationType() == "Symbol")
829
                    {
830
                        int symbolIndex = Convert.ToInt32(relationship.get_Item1Location());
831
                        int lineIndex = Convert.ToInt32(relationship.get_Item2Location());
832
                        LMModelItem symbolModelItem = relationship.Item1RepresentationObject.ModelItemObject;
833

  
834
                        SetSymbolFlowDirection(lineIndex, symbolIndex, sFlowDirection, symbolModelItem);
835

  
836
                        symbolModelItem.Commit();
837
                        ReleaseCOMObjects(symbolModelItem);
838
                        symbolModelItem = null;
839
                    }
840
                }
841

  
842
                void SetSymbolFlowDirection(int lineIndex, int symbolIndex, string sFlowDirection, LMModelItem symbolModelItem)
843
                {
844
                    string attrName = "PipingPoint" + symbolIndex + ".FlowDirection";
845
                    LMAAttribute attribute = symbolModelItem.Attributes[attrName];
846
                    if (attribute != null)
847
                    {
848
                        if (lineIndex == 0 && sFlowDirection == "End 1 is upstream (Inlet)")
849
                            attribute.set_Value("End 1 is downstream (Outlet)");
850
                        else if (lineIndex == 0 && sFlowDirection == "End 1 is downstream (Outlet)")
851
                            attribute.set_Value("End 1 is upstream (Inlet)");
852
                        else if (lineIndex == 1 && sFlowDirection == "End 1 is upstream (Inlet)")
853
                            attribute.set_Value("End 1 is upstream (Inlet)");
854
                        else if (lineIndex == 1 && sFlowDirection == "End 1 is downstream (Outlet)")
855
                            attribute.set_Value("End 1 is downstream (Outlet)");
856
                    }
857
                }
858
            }
859
        }
860 712
        private void RunNoteModeling()
861 713
        {
862 714
            SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllProgress, document.SYMBOLS.Count);
......
3391 3243
                    beforeID = modelItem2.Id;
3392 3244
                    afterID = modelItem1.Id;
3393 3245
                    survivorId = afterID;
3394
                    //LMAAttribute attribute = modelItem1.Attributes["FlowDirection"];
3395

  
3396
                    //if (!IsSameConnector)
3397
                    //{
3398
                    //    if (!string.IsNullOrEmpty(graphicOID1))
3399
                    //    {
3400
                    //        List<double[]> survivorVertices = GetConnectorVertices(graphicOID1);
3401
                    //        if (vertices1[0][0] == survivorVertices[0][0] && vertices1[0][1] == survivorVertices[0][1])
3402
                    //        {
3403
                                
3404
                    //        }
3405
                    //        else if (vertices1[0][0] == survivorVertices[survivorVertices.Count - 1][0] && vertices1[0][1] == survivorVertices[survivorVertices.Count - 1][1])
3406
                    //        {
3407
                    //            if (attribute != null && DBNull.Value.Equals(attribute.get_Value()))
3408
                    //                attribute.set_Value("End 1 is upstream (Inlet)");
3409
                    //            else if (attribute != null && attribute.get_Value() == "End 1 is upstream (Inlet)")
3410
                    //                attribute.set_Value("End 1 is downstream (Outlet)");
3411
                    //            else if (attribute != null && attribute.get_Value() == "End 1 is downstream (Outlet)")
3412
                    //                attribute.set_Value("End 1 is upstream (Inlet)");
3413
                    //        }
3414
                    //    }
3415
                    //    else if (!string.IsNullOrEmpty(graphicOID2))
3416
                    //    {
3417
                    //        List<double[]> survivorVertices = GetConnectorVertices(graphicOID2);
3418
                    //        if (vertices2[0][0] == survivorVertices[0][0] && vertices2[0][1] == survivorVertices[0][1])
3419
                    //        {
3420

  
3421
                    //        }
3422
                    //        else if (vertices2[0][0] == survivorVertices[survivorVertices.Count - 1][0] && vertices2[0][1] == survivorVertices[survivorVertices.Count - 1][1])
3423
                    //        {
3424
                    //            if (attribute != null && DBNull.Value.Equals(attribute.get_Value()))
3425
                    //                attribute.set_Value("End 1 is upstream (Inlet)");
3426
                    //            else if (attribute != null && attribute.get_Value() == "End 1 is upstream (Inlet)")
3427
                    //                attribute.set_Value("End 1 is downstream (Outlet)");
3428
                    //            else if (attribute != null && attribute.get_Value() == "End 1 is downstream (Outlet)")
3429
                    //                attribute.set_Value("End 1 is upstream (Inlet)");
3430
                    //        }
3431
                    //    }
3432
                    //}
3433
                    //else
3434
                    //{
3435
                    //    if (attribute != null)
3436
                    //        attribute.set_Value("End 1 is upstream (Inlet)");
3437
                    //}
3438 3246
                }
3439 3247
                else if (modelItem1.get_ItemStatus() != "Active" && modelItem2.get_ItemStatus() == "Active")
3440 3248
                {
3441 3249
                    beforeID = modelItem1.Id;
3442 3250
                    afterID = modelItem2.Id;
3443 3251
                    survivorId = afterID;
3444
                    //LMAAttribute attribute = modelItem2.Attributes["FlowDirection"];
3445

  
3446
                    //if (!IsSameConnector)
3447
                    //{
3448
                    //    if (!string.IsNullOrEmpty(graphicOID2))
3449
                    //    {
3450
                    //        List<double[]> survivorVertices = GetConnectorVertices(graphicOID2);
3451
                    //        if (vertices2[0][0] == survivorVertices[0][0] && vertices2[0][1] == survivorVertices[0][1])
3452
                    //        {
3453

  
3454
                    //        }
3455
                    //        else if (vertices2[0][0] == survivorVertices[survivorVertices.Count - 1][0] && vertices2[0][1] == survivorVertices[survivorVertices.Count - 1][1])
3456
                    //        {
3457
                    //            if (attribute != null && DBNull.Value.Equals(attribute.get_Value()))
3458
                    //                attribute.set_Value("End 1 is upstream (Inlet)");
3459
                    //            else if (attribute != null && attribute.get_Value() == "End 1 is upstream (Inlet)")
3460
                    //                attribute.set_Value("End 1 is downstream (Outlet)");
3461
                    //            else if (attribute != null && attribute.get_Value() == "End 1 is downstream (Outlet)")
3462
                    //                attribute.set_Value("End 1 is upstream (Inlet)");
3463
                    //        }
3464
                    //    }
3465
                    //    else if (!string.IsNullOrEmpty(graphicOID1))
3466
                    //    {
3467
                    //        List<double[]> survivorVertices = GetConnectorVertices(graphicOID1);
3468
                    //        if (vertices1[0][0] == survivorVertices[0][0] && vertices1[0][1] == survivorVertices[0][1])
3469
                    //        {
3470

  
3471
                    //        }
3472
                    //        else if (vertices1[0][0] == survivorVertices[survivorVertices.Count - 1][0] && vertices1[0][1] == survivorVertices[survivorVertices.Count - 1][1])
3473
                    //        {
3474
                    //            if (attribute != null && DBNull.Value.Equals(attribute.get_Value()))
3475
                    //                attribute.set_Value("End 1 is upstream (Inlet)");
3476
                    //            else if (attribute != null && attribute.get_Value() == "End 1 is upstream (Inlet)")
3477
                    //                attribute.set_Value("End 1 is downstream (Outlet)");
3478
                    //            else if (attribute != null && attribute.get_Value() == "End 1 is downstream (Outlet)")
3479
                    //                attribute.set_Value("End 1 is upstream (Inlet)");
3480
                    //        }
3481
                    //    }
3482
                    //}
3483
                    //else
3484
                    //{
3485
                    //    if (attribute != null)
3486
                    //        attribute.set_Value("End 1 is upstream (Inlet)");
3487
                    //}
3488 3252
                }
3489 3253
                else if (modelItem1.get_ItemStatus() == "Active" && modelItem2.get_ItemStatus() == "Active")
3490 3254
                {
......
3495 3259
                        beforeID = modelItem1.Id;
3496 3260
                        afterID = modelItem2.Id;
3497 3261
                        survivorId = afterID;
3498
                        //LMAAttribute attribute = modelItem2.Attributes["FlowDirection"];
3499
                        //if (attribute != null)
3500
                        //    attribute.set_Value("End 1 is upstream (Inlet)");
3501 3262
                    }
3502 3263
                    else if (model2Cnt == 0)
3503 3264
                    {
3504 3265
                        beforeID = modelItem2.Id;
3505 3266
                        afterID = modelItem1.Id;
3506 3267
                        survivorId = afterID;
3507
                        //LMAAttribute attribute = modelItem1.Attributes["FlowDirection"];
3508
                        //if (attribute != null)
3509
                        //    attribute.set_Value("End 1 is upstream (Inlet)");
3510 3268
                    }
3511 3269
                    else
3512 3270
                        survivorId = null;

내보내기 Unified diff

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