프로젝트

일반

사용자정보

개정판 b9e9f4c8

IDb9e9f4c8fa22a309d0c0abb32636a8fb40cefff7
상위 ca6cd684
하위 a9e55483, 2a4872ec

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

dev issue #000 : equip 모델링 수정 / EndBreak 모델링 부분 수정 - 수정더 필요

Change-Id: Idfe1e2911febc21819b097ce1c73256e702a9dac

차이점 보기:

DTI_PID/SPPIDConverter/AutoModeling.cs
55 55
            {
56 56
                // Equipment Modeling
57 57
                foreach (Equipment equipment in document.Equipments)
58
                    SymbolModeling(equipment as Symbol, null, null);
58
                {
59
                    EquipmentModeling(equipment);
60
                }
61
                    
59 62
                
60 63
                // LineRun Symbol Modeling
61 64
                foreach (LineNumber lineNumber in document.LINENUMBERS)
......
88 91
                // LineNumber Modeling
89 92
                foreach (var item in document.LINENUMBERS)
90 93
                    LineNumberModeling(item);
91
                
94

  
92 95
                // LineRun Line Join
93 96
                foreach (LineNumber lineNumber in document.LINENUMBERS)
94 97
                    foreach (LineRun run in lineNumber.RUNS)
......
353 356
            if (targetSymbol != null && !string.IsNullOrEmpty(targetSymbol.SPPID.RepresentationId))
354 357
            {
355 358
                LMSymbol _TargetItem = dataSource.GetSymbol(targetSymbol.SPPID.RepresentationId);
359

  
360
                Ingr.RAD2D.Symbol2d symbol2d = radApp.ActiveDocument.ActiveSheet.DrawingObjects[_TargetItem.get_GraphicOID().ToString()];
361
                double x1 = 0;
362
                double x2 = 0;
363
                double y1 = 0;
364
                double y2 = 0;
365
                symbol2d.Range(out x1, out y1, out x2, out y2);
366

  
367
                if (y2 < y)
368
                    y = y2;
369
                else if (y1 > y)
370
                    y = y1;
371

  
372
                if (x2 < x)
373
                    x = x2;
374
                else if (x1 > x)
375
                    x = x1;
376

  
356 377
                _LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle, TargetItem: _TargetItem);
357 378
                ReleaseCOMObjects(_TargetItem);
358 379
            }
......
386 407
            ReleaseCOMObjects(_LMSymbol);
387 408
        }
388 409

  
410
        private void EquipmentModeling(Equipment equipment)
411
        {
412
            if (!string.IsNullOrEmpty(equipment.SPPID.RepresentationId))
413
                return;
414

  
415
            LMSymbol _LMSymbol = null;
416
            LMSymbol targetItem = null;
417
            string mappingPath = equipment.SPPID.MAPPINGNAME;
418
            double x = equipment.SPPID.ORIGINAL_X;
419
            double y = equipment.SPPID.ORIGINAL_Y;
420
            int mirror = 0;
421
            double angle = equipment.ANGLE;
422

  
423
            Connector connector = equipment.CONNECTORS.Find(conn => !string.IsNullOrEmpty(conn.CONNECTEDITEM) && conn.CONNECTEDITEM != "None");
424
            if (connector != null)
425
            {
426
                Equipment connEquipment = SPPIDUtil.FindObjectByUID(document, connector.CONNECTEDITEM) as Equipment;
427
                if (connEquipment != null)
428
                {
429
                    if (string.IsNullOrEmpty(connEquipment.SPPID.RepresentationId))
430
                        EquipmentModeling(connEquipment);
431

  
432
                    if (!string.IsNullOrEmpty(connEquipment.SPPID.RepresentationId))
433
                    {
434
                        targetItem = dataSource.GetSymbol(connEquipment.SPPID.RepresentationId);
435
                        if (targetItem != null)
436
                        {
437
                            _LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle, TargetItem: targetItem);
438
                        }
439
                        else
440
                        {
441
                            _LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle);
442
                        }
443
                    }
444
                    else
445
                    {
446
                        _LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle);
447
                    }
448
                }
449
                else
450
                {
451
                    _LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle);
452
                }
453
            }
454
            else
455
            {
456
                _LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle);
457
            }
458

  
459
            if (_LMSymbol != null)
460
            {
461
                _LMSymbol.Commit();
462
                equipment.SPPID.RepresentationId = _LMSymbol.AsLMRepresentation().Id;
463
                ReleaseCOMObjects(_LMSymbol);
464
            }
465

  
466
            if (targetItem != null)
467
            {
468
                ReleaseCOMObjects(targetItem);
469
            }
470
            
471
            //if (equipment.CONNECTORS)
472
            //{
473

  
474
            //}
475

  
476
            //if (targetSymbol != null && !string.IsNullOrEmpty(targetSymbol.SPPID.RepresentationId))
477
            //{
478
            //    LMSymbol _TargetItem = dataSource.GetSymbol(targetSymbol.SPPID.RepresentationId);
479
            //    _LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle, TargetItem: _TargetItem);
480
            //    ReleaseCOMObjects(_TargetItem);
481
            //}
482
            //else if (prevSymbol != null)
483
            //{
484
            //    LMSymbol _PrevSymbol = dataSource.GetSymbol(prevSymbol.SPPID.RepresentationId);
485
            //    SlopeType slopeType = SPPIDUtil.CalcSlope(x, y, prevSymbol.SPPID.ORIGINAL_X, prevSymbol.SPPID.ORIGINAL_Y);
486
            //    double prevX = _PrevSymbol.get_XCoordinate();
487
            //    double prevY = _PrevSymbol.get_YCoordinate();
488
            //    if (slopeType == SlopeType.HORIZONTAL)
489
            //        y = prevY;
490
            //    else if (slopeType == SlopeType.VERTICAL)
491
            //        x = prevX;
492
            //    _LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle);
493
            //}
494
            //else
495
            //{
496
            //    _LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle);
497
            //}
498

  
499

  
500
            //if (_LMSymbol != null)
501
            //{
502
            //    _LMSymbol.Commit();
503
            //    symbol.SPPID.RepresentationId = _LMSymbol.AsLMRepresentation().Id;
504

  
505
            //    foreach (var item in symbol.ChildSymbols)
506
            //        CreateChildSymbol(item, _LMSymbol);
507
            //}
508

  
509
            ReleaseCOMObjects(_LMSymbol);
510
        }
511

  
389 512
        private void CreateChildSymbol(ChildSymbol childSymbol, LMSymbol parentSymbol)
390 513
        {
391 514
            Ingr.RAD2D.Symbol2d symbol2d = radApp.ActiveDocument.ActiveSheet.DrawingObjects[parentSymbol.get_GraphicOID().ToString()];
......
860 983
                Dictionary<LMConnector, List<double[]>> connectorVertices = GetPipeRunVertices(ownerLine.SPPID.ModelItemId);
861 984

  
862 985
                LMConnector connectedLMConnector = FindTargetLMConnectorByPoint(connectorVertices, endBreak.SPPID.ORIGINAL_X, endBreak.SPPID.ORIGINAL_Y);
986
                
863 987
                if (connectedLMConnector != null)
864 988
                {
865 989
                    Array array = new double[] { 0, endBreak.SPPID.ORIGINAL_X, endBreak.SPPID.ORIGINAL_Y };
866 990
                    _LmLabelPersist = _placement.PIDPlaceLabel(endBreak.SPPID.MAPPINGNAME, ref array, Rotation: 0, LabeledItem: connectedLMConnector.AsLMRepresentation(), IsLeaderVisible: true);
867
                    ReleaseCOMObjects(connectedLMConnector);
868 991
                }
869 992

  
870 993
                if (_LmLabelPersist != null)
......
872 995
                    _LmLabelPersist.Commit();
873 996
                    ReleaseCOMObjects(_LmLabelPersist);
874 997
                }
998
                else
999
                {
1000
                    
1001
                }
1002

  
875 1003
                foreach (var item in connectorVertices)
876 1004
                    ReleaseCOMObjects(item.Key);
877 1005
            }
......
882 1010

  
883 1011
                LMConnector targetLMConnector = null;
884 1012
                double distance = double.MaxValue;
1013

  
885 1014
                foreach (LMConnector connector in _LMSymbol.Avoid1Connectors)
886 1015
                {
887 1016
                    if (connector.get_ItemStatus() == "Active")
......
898 1027
                            double y = 0;
899 1028
                            lineStringGeometry.GetVertex(i + 1, ref x, ref y);
900 1029

  
901
                            double result = SPPIDUtil.CalcPointToPointdDistance(x, y, ownerSymbol.SPPID.ORIGINAL_X, ownerSymbol.SPPID.ORIGINAL_Y);
1030
                            double result = SPPIDUtil.CalcPointToPointdDistance(x, y, endBreak.SPPID.ORIGINAL_X, endBreak.SPPID.ORIGINAL_Y);
902 1031
                            if (result < distance)
903 1032
                            {
904 1033
                                targetLMConnector = connector;
......
910 1039

  
911 1040
                foreach (LMConnector connector in _LMSymbol.Avoid2Connectors)
912 1041
                {
913
                    dynamic OID = connector.get_GraphicOID();
914
                    DependencyObject drawingObject = radApp.ActiveDocument.ActiveSheet.DrawingObjects[OID];
915
                    Ingr.RAD2D.LineStringGeometry2d lineStringGeometry = drawingObject.GetGeometry() as Ingr.RAD2D.LineStringGeometry2d;
916
                    int verticesCount = lineStringGeometry.VertexCount;
917
                    double[] vertices = null;
918
                    lineStringGeometry.GetVertices(ref verticesCount, ref vertices);
919
                    for (int i = 0; i < verticesCount; i++)
1042
                    if (connector.get_ItemStatus() == "Active")
920 1043
                    {
921
                        double x = 0;
922
                        double y = 0;
923
                        lineStringGeometry.GetVertex(i + 1, ref x, ref y);
924

  
925
                        double result = SPPIDUtil.CalcPointToPointdDistance(x, y, ownerSymbol.SPPID.ORIGINAL_X, ownerSymbol.SPPID.ORIGINAL_Y);
926
                        if (result < distance)
1044
                        dynamic OID = connector.get_GraphicOID();
1045
                        DependencyObject drawingObject = radApp.ActiveDocument.ActiveSheet.DrawingObjects[OID];
1046
                        Ingr.RAD2D.LineStringGeometry2d lineStringGeometry = drawingObject.GetGeometry() as Ingr.RAD2D.LineStringGeometry2d;
1047
                        int verticesCount = lineStringGeometry.VertexCount;
1048
                        double[] vertices = null;
1049
                        lineStringGeometry.GetVertices(ref verticesCount, ref vertices);
1050
                        for (int i = 0; i < verticesCount; i++)
927 1051
                        {
928
                            targetLMConnector = connector;
929
                            distance = result;
1052
                            double x = 0;
1053
                            double y = 0;
1054
                            lineStringGeometry.GetVertex(i + 1, ref x, ref y);
1055

  
1056
                            double result = SPPIDUtil.CalcPointToPointdDistance(x, y, endBreak.SPPID.ORIGINAL_X, endBreak.SPPID.ORIGINAL_Y);
1057
                            if (result < distance)
1058
                            {
1059
                                targetLMConnector = connector;
1060
                                distance = result;
1061
                            }
930 1062
                        }
931 1063
                    }
932 1064
                }
......
941 1073
                        _LmLabelPersist.Commit();
942 1074
                        ReleaseCOMObjects(_LmLabelPersist);
943 1075
                    }
1076
                    else
1077
                    {
1078
                        bool isZeroLength = Convert.ToBoolean(targetLMConnector.get_IsZeroLength());
1079
                        if (isZeroLength)
1080
                        {
1081
                            dynamic OID = targetLMConnector.get_GraphicOID();
1082
                            DependencyObject drawingObject = radApp.ActiveDocument.ActiveSheet.DrawingObjects[OID];
1083
                            Ingr.RAD2D.LineStringGeometry2d lineStringGeometry = drawingObject.GetGeometry() as Ingr.RAD2D.LineStringGeometry2d;
1084
                            int verticesCount = lineStringGeometry.VertexCount;
1085
                            double[] vertices = null;
1086
                            lineStringGeometry.GetVertices(ref verticesCount, ref vertices);
1087
                            List<double[]> list = new List<double[]>();
1088
                            for (int i = 0; i < verticesCount; i++)
1089
                            {
1090
                                double x = 0;
1091
                                double y = 0;
1092
                                lineStringGeometry.GetVertex(i + 1, ref x, ref y);
1093
                                list.Add(new double[] { x, y });
1094
                            }
1095

  
1096
                            PlaceRunInputs placeRunInputs = new PlaceRunInputs();
1097
                            placeRunInputs.AddSymbolTarget(targetLMConnector.ConnectItem1SymbolObject, list[0][0], list[0][1]);
1098
                            placeRunInputs.AddSymbolTarget(targetLMConnector.ConnectItem2SymbolObject, list[0][0], list[0][1]);
1099
                            _LMAItem _LMAItem = _placement.PIDCreateItem(@"\Piping\Routing\Process Lines\Primary Piping.sym");
1100

  
1101
                            _placement.PIDRemovePlacement(targetLMConnector.AsLMRepresentation());
1102
                            LMConnector _lMConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs);
1103

  
1104
                            array = new double[] { 0, list[0][0], list[0][1] };
1105
                            _LmLabelPersist = _placement.PIDPlaceLabel(endBreak.SPPID.MAPPINGNAME, ref array, Rotation: 0, LabeledItem: _lMConnector.AsLMRepresentation(), IsLeaderVisible: true);
1106
                            if (_LmLabelPersist != null)
1107
                            {
1108
                                _LmLabelPersist.Commit();
1109
                            }
1110
                            else
1111
                            {
1112

  
1113
                            }
1114
                        }
1115
                    }
944 1116
                }
1117
                
945 1118
                ReleaseCOMObjects(_LMSymbol);
946 1119
            }
947 1120
        }

내보내기 Unified diff

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