프로젝트

일반

사용자정보

개정판 46197f18

ID46197f18531f549e305e68a197e63a31d9589f5f
상위 5cf7fb68
하위 a9f6ef3c

백흠경이(가) 일년 이상 전에 추가함

Fix: Compare 기능 개선(라인, 심볼 비교 기능 개선)

Change-Id: I04bc9661199bdfc337d1890bb0d556bca391720f

차이점 보기:

ID2.Manager/ID2.Manager/Controls/Verification.Designer.cs
525 525
            // radLabel4
526 526
            // 
527 527
            this.radLabel4.Anchor = System.Windows.Forms.AnchorStyles.Right;
528
            this.radLabel4.Location = new System.Drawing.Point(243, 3);
528
            this.radLabel4.Location = new System.Drawing.Point(265, 3);
529 529
            this.radLabel4.Name = "radLabel4";
530 530
            this.radLabel4.Size = new System.Drawing.Size(72, 18);
531 531
            this.radLabel4.TabIndex = 2;
......
537 537
            this.radColorBoxEqualColor.Dock = System.Windows.Forms.DockStyle.Fill;
538 538
            this.radColorBoxEqualColor.Location = new System.Drawing.Point(343, 3);
539 539
            this.radColorBoxEqualColor.Name = "radColorBoxEqualColor";
540
            this.radColorBoxEqualColor.Size = new System.Drawing.Size(114, 20);
540
            this.radColorBoxEqualColor.Size = new System.Drawing.Size(114, 18);
541 541
            this.radColorBoxEqualColor.TabIndex = 3;
542 542
            this.radColorBoxEqualColor.Value = System.Drawing.Color.FromArgb(((int)(((byte)(44)))), ((int)(((byte)(44)))), ((int)(((byte)(44)))));
543 543
            // 
......
553 553
            // radColorBoxDiffColor
554 554
            // 
555 555
            this.radColorBoxDiffColor.Dock = System.Windows.Forms.DockStyle.Fill;
556
            this.radColorBoxDiffColor.Location = new System.Drawing.Point(583, 3);
556
            this.radColorBoxDiffColor.Location = new System.Drawing.Point(563, 3);
557 557
            this.radColorBoxDiffColor.Name = "radColorBoxDiffColor";
558
            this.radColorBoxDiffColor.Size = new System.Drawing.Size(114, 20);
558
            this.radColorBoxDiffColor.Size = new System.Drawing.Size(114, 18);
559 559
            this.radColorBoxDiffColor.TabIndex = 5;
560 560
            this.radColorBoxDiffColor.Value = System.Drawing.Color.Yellow;
561 561
            // 
ID2.Manager/ID2.Manager/Controls/Verification.cs
41 41
            this.radColorBoxEqualColor.ValueChanged += RadColorBoxEqualColor_ValueChanged;
42 42
            this.radColorBoxDiffColor.ValueChanged += RadColorBoxDiffColor_ValueChanged;
43 43

  
44
            this.designAutoCAD.ActionMode = actionType.SelectVisibleByPickDynamic;
45
            this.designAutoCAD.Selection.ColorDynamic = Color.FromArgb(80, Color.OrangeRed);
46
            this.designAutoCAD.Selection.HaloInnerColor = Color.FromArgb(255, Color.OrangeRed);
47
            this.designAutoCAD.Selection.HaloOuterColor = Color.FromArgb(64, Color.OrangeRed);
48
            this.designAutoCAD.Selection.HaloWidthPolygons = 4;
49
            this.designAutoCAD.Selection.HaloWidthWires = 2;
50
            this.designAVEVA.ActionMode = actionType.SelectVisibleByPickDynamic;
51

  
44 52
            #region Camera Sync
45 53
            this.designAutoCAD.ActiveViewport.Rotate.Enabled = false;
46 54
            this.designAVEVA.ActiveViewport.Rotate.Enabled = false;
......
83 91
            Classes.ID2Helper.IniWriteValue(IniFilePath, "Verification", "EqualColor", color);
84 92
        }
85 93

  
94
        /// <summary>
95
        /// 수정한 Tolerance를 시스템에 반영한다.
96
        /// </summary>
97
        /// <param name="sender"></param>
98
        /// <param name="e"></param>
86 99
        private void RadSpinEditorTolerance_ValueChanged(object sender, EventArgs e)
87 100
        {
88 101
            string AVEVAPIDFolder = this.radBrowseEditorAVEVAPIDFolder.Value;
89 102
            if (System.IO.Directory.Exists(AVEVAPIDFolder))
90 103
            {
91
                Classes.ID2Helper.IniWriteValue(IniFilePath, "Verification", "Tolerance", this.radSpinEditorTolerance.Value.ToString());
104
                double toler = Convert.ToDouble(this.radSpinEditorTolerance.Value);
105
                Classes.ID2Helper.IniWriteValue(IniFilePath, "Verification", "Tolerance", toler.ToString());
106
                Verification.Tolerance = toler;
92 107
            }
93 108
        }
94 109

  
......
107 122
            if (!string.IsNullOrEmpty(AVEVAPIDFolder)) this.radBrowseEditorAVEVAPIDFolder.Value = AVEVAPIDFolder;
108 123

  
109 124
            string Toler = Classes.ID2Helper.IniReadValue(IniFilePath, "Verification", "Tolerance");
110
            if (!string.IsNullOrEmpty(Toler)) this.radSpinEditorTolerance.Value = Convert.ToDecimal(Toler);
125
            if (!string.IsNullOrEmpty(Toler))
126
            {
127
                this.radSpinEditorTolerance.Value = Convert.ToDecimal(Toler);
128
                Verification.Tolerance = Convert.ToDouble(this.radSpinEditorTolerance.Value);
129
            }
111 130

  
112 131
            string _EqualColor = Classes.ID2Helper.IniReadValue(IniFilePath, "Verification", "EqualColor");
113 132
            if (!string.IsNullOrEmpty(_EqualColor))
......
137 156
        /// </summary>
138 157
        /// <param name="design"></param>
139 158
        /// <param name="list"></param>
140
        public void ColorEntities(Design design, EntityList list, Color color)
159
        public void ColorEntities(Design design, EntityList list, Color color, colorMethodType colorMethod=colorMethodType.byEntity, bool ChangeBlkColor=true)
141 160
        {
142 161
            foreach (Entity ent in list)
143 162
            {
144
                ColorEntity(design, ent, color);
163
                ColorEntity(design, ent, color, colorMethod, ChangeBlkColor);
145 164
            }
146 165
        }
147 166

  
......
151 170
        /// <param name="design"></param>
152 171
        /// <param name="entity"></param>
153 172
        /// <param name="color"></param>
154
        private void ColorEntity(Design design, Entity entity, Color color)
173
        private void ColorEntity(Design design, Entity entity, Color color, colorMethodType colorMethod = colorMethodType.byEntity, 
174
            bool ChangeBlkColor = true)
155 175
        {
156 176
            if (entity is BlockReference blkref)
157 177
            {
158 178
                blkref.Color = color;
159
                blkref.ColorMethod = colorMethodType.byEntity;
160
                var blk = design.Blocks.FirstOrDefault(x => x.Name == blkref.BlockName);
161
                if (blk != null)
179
                blkref.ColorMethod = colorMethod;
180

  
181
                if (ChangeBlkColor)
162 182
                {
163
                    ColorEntities(design, blk.Entities, color);
164
                    foreach(var attr in blkref.Attributes.Values)
183
                    var blk = design.Blocks.FirstOrDefault(x => x.Name == blkref.BlockName);
184
                    if (blk != null)
165 185
                    {
166
                        attr.Color = color;
167
                        attr.ColorMethod = colorMethodType.byEntity;
186
                        ColorEntities(design, blk.Entities, color, colorMethodType.byParent);
187
                        foreach (var attr in blkref.Attributes.Values)
188
                        {
189
                            attr.Color = color;
190
                            attr.ColorMethod = colorMethodType.byParent;
191
                        }
168 192
                    }
169 193
                }
170 194
            }
171 195
            else
172 196
            {
173 197
                entity.Color = color;
174
                entity.ColorMethod = colorMethodType.byEntity;
198
                entity.ColorMethod = colorMethod;
175 199
            }
176 200
        }
177 201

  
202
        /// <summary>
203
        /// 도면을 선택했을때 두 도면을 비교한다.
204
        /// </summary>
205
        /// <param name="sender"></param>
206
        /// <param name="e"></param>
178 207
        private void RadGridViewDocument_SelectionChanged(object sender, EventArgs e)
179 208
        {
209
            /// AutoCAD P&ID 파일을 화면에 표시한다.
180 210
            void ShowAutoCADFile(string FilePath)
181 211
            {
182 212
                this.designAutoCAD.Clear();
......
186 216
                    ra.DoWork();
187 217
                    ra.AddToScene(this.designAutoCAD);
188 218

  
219
                    var AddEntities = new List<Entity>();
220
                    this.designAutoCAD.Entities.ForEach(x =>
221
                    {
222
                        if (x is LinearPath lp)
223
                        {
224
                            int count = Convert.ToInt32(lp.Vertices.Length);
225
                            for (int i = 0; i < count - 1; ++i)
226
                            {
227
                                AddEntities.Add(new devDept.Eyeshot.Entities.Line(lp.Vertices[i], lp.Vertices[i + 1])
228
                                {
229
                                    LayerName = lp.LayerName,
230
                                    LineWeight = lp.LineWeight,
231
                                    LineTypeMethod = colorMethodType.byEntity
232
                                });
233
                            }
234
                        }
235
                        /*
236
                        else if(x is BlockReference blkref && blkref.Attributes.Any())
237
                        {
238
                            var entities = blkref.Explode(this.designAutoCAD.Blocks).Where(y => y is devDept.Eyeshot.Entities.Text);
239
                        }
240
                        */
241
                    });
242
                    this.designAutoCAD.Entities.RemoveAll(x => x is LinearPath);
243
                    this.designAutoCAD.Entities.AddRange(AddEntities);
244

  
245
                    #region 브랜치가 생성되는 부분에서 라인을 분할
246
                    var queue = this.designAutoCAD.Entities.Where(x => x is Line).ToList();
247
                    while(queue.Any())
248
                    {
249
                        var line1 = queue.First() as Line;
250
                        var dir1 = line1.Direction;
251
                        dir1.Normalize();
252
                        queue.Remove(line1);
253
                        for(int i = 0;i < queue.Count;++i)
254
                        {
255
                            var line2 = queue.ElementAt(i) as Line;
256
                            var dir2 = line2.Direction;
257
                            dir2.Normalize();
258
                            if(devDept.Geometry.Vector3D.AreOrthogonal(dir1, dir2))
259
                            {
260
                                var intersects = line1.IntersectWith(line2);
261
                                if(intersects.Count() == 1)
262
                                {
263
                                    if(line1.StartPoint.DistanceTo(intersects[0]) > 0.1 && line1.EndPoint.DistanceTo(intersects[0]) > 0.1)
264
                                    {
265
                                        var split1 = new devDept.Eyeshot.Entities.Line(line1.StartPoint, intersects[0])
266
                                        {
267
                                            LayerName = line1.LayerName,
268
                                            LineWeight = line1.LineWeight,
269
                                            LineTypeMethod = colorMethodType.byEntity
270
                                        };
271
                                        var split2 = new devDept.Eyeshot.Entities.Line(intersects[0], line1.EndPoint)
272
                                        {
273
                                            LayerName = line1.LayerName,
274
                                            LineWeight = line1.LineWeight,
275
                                            LineTypeMethod = colorMethodType.byEntity
276
                                        };
277
                                        this.designAutoCAD.Entities.Add(split1);
278
                                        this.designAutoCAD.Entities.Add(split2);
279
                                        this.designAutoCAD.Entities.Remove(line1);
280

  
281
                                        queue.Add(split1);
282
                                        queue.Add(split2);
283

  
284
                                        break;
285
                                    }
286

  
287
                                    if (line2.StartPoint.DistanceTo(intersects[0]) > 0.1 && line2.EndPoint.DistanceTo(intersects[0]) > 0.1)
288
                                    {
289
                                        var split1 = new devDept.Eyeshot.Entities.Line(line2.StartPoint, intersects[0])
290
                                        {
291
                                            LayerName = line2.LayerName,
292
                                            LineWeight = line2.LineWeight,
293
                                            LineTypeMethod = colorMethodType.byEntity
294
                                        };
295
                                        var split2 = new devDept.Eyeshot.Entities.Line(intersects[0], line2.EndPoint)
296
                                        {
297
                                            LayerName = line2.LayerName,
298
                                            LineWeight = line2.LineWeight,
299
                                            LineTypeMethod = colorMethodType.byEntity
300
                                        };
301
                                        this.designAutoCAD.Entities.Add(split1);
302
                                        this.designAutoCAD.Entities.Add(split2);
303
                                        this.designAutoCAD.Entities.Remove(line2);
304

  
305
                                        queue.Remove(line2);
306
                                        queue.Add(split1);
307
                                        queue.Add(split2);
308
                                    }
309
                                }
310
                            }
311
                        }
312
                    }
313
                    #endregion
314

  
189 315
                    ColorEntities(this.designAutoCAD, this.designAutoCAD.Entities, Verification.EqualColor);
190 316

  
191 317
                    // Sets the view as Top
......
195 321
                }
196 322
            }
197 323

  
324
            /// AVEVA P&ID 파일을 화면에 표시한다.
198 325
            void ShowAVEVAPIDFile(string FilePath)
199 326
            {
200 327
                this.designAVEVA.Clear();
......
204 331
                    ra.DoWork();
205 332
                    ra.AddToScene(this.designAVEVA);
206 333

  
207
                    ColorEntities(this.designAVEVA, this.designAVEVA.Entities, Verification.EqualColor);
334
                    #region 멀티 라인들을 분할하여 추가한다.
335
                    var AddEntities = new List<Entity>();
336
                    this.designAVEVA.Entities.ForEach(x =>
337
                    {
338
                        if(x is Mesh mesh && (mesh.LayerName == "AS_PIPE" || mesh.LayerName == "AS_INST"))
339
                        {
340
                            int count = Convert.ToInt32(mesh.Vertices.Length * 0.5);
341
                            for (int i = 0;i < count - 1; ++i)
342
                            {
343
                                AddEntities.Add(new devDept.Eyeshot.Entities.Line(mesh.Vertices[i], mesh.Vertices[i + 1]) 
344
                                { 
345
                                    LayerName = mesh.LayerName,
346
                                    LineWeight = 3.0f,
347
                                    LineTypeMethod = colorMethodType.byEntity,
348
                                    Color = Verification.DiffColor,
349
                                    ColorMethod = colorMethodType.byEntity
350
                                });
351
                            }
352
                        }
353
                        else if (x is TabulatedSurface tf && (tf.LayerName == "AS_PIPE" || tf.LayerName == "AS_INST"))
354
                        {
355
                            int count = Convert.ToInt32(tf.ControlPoints.Length * 0.5);
356
                            for (int i = 0; i < count - 1; ++i)
357
                            {
358
                                AddEntities.Add(
359
                                    new devDept.Eyeshot.Entities.Line(
360
                                    new devDept.Geometry.Point3D(tf.ControlPoints[i, 0].X, tf.ControlPoints[i, 0].Y, 0),
361
                                    new devDept.Geometry.Point3D(tf.ControlPoints[i + 1, 0].X, tf.ControlPoints[i + 1, 0].Y, 0))
362
                                    {
363
                                        LayerName = tf.LayerName,
364
                                        LineWeight = 3.0f,
365
                                        LineTypeMethod = colorMethodType.byEntity,
366
                                        Color = Verification.DiffColor,
367
                                        ColorMethod = colorMethodType.byEntity
368
                                    }
369
                                );
370
                            }
371
                        }
372
                        else if (x is LinearPath lp)
373
                        {
374
                            int count = Convert.ToInt32(lp.Vertices.Length);
375
                            for (int i = 0; i < count - 1; ++i)
376
                            {
377
                                AddEntities.Add(new devDept.Eyeshot.Entities.Line(lp.Vertices[i], lp.Vertices[i + 1])
378
                                {
379
                                    LayerName = lp.LayerName,
380
                                    LineWeight = lp.LineWeight,
381
                                    LineTypeMethod = colorMethodType.byEntity
382
                                });
383
                            }
384
                        }
385
                    });
386
                    this.designAVEVA.Entities.RemoveAll(x => 
387
                    ((x is Mesh || x is TabulatedSurface) && (x.LayerName == "AS_PIPE" || x.LayerName == "AS_INST")) ||
388
                    (x is LinearPath));
389
                    this.designAVEVA.Entities.AddRange(AddEntities);
390
                    #endregion
391

  
392
                    ColorEntities(this.designAVEVA, this.designAVEVA.Entities, Verification.DiffColor);
393

  
394
                    #region 블럭 이름이 PSNODE, PENODE인 블럭은 보이지 않도록 한다.
395
                    this.designAVEVA.Entities.ForEach(x =>
396
                    {
397
                        if (x is BlockReference blkref && (blkref.BlockName == "PSNODE" || blkref.BlockName == "PENODE" || 
398
                        blkref.BlockName.StartsWith("ARROW")))
399
                            blkref.Visible = false;
400
                    });
401
                    #endregion
208 402

  
209 403
                    this.designAVEVA.SetView(viewType.Top);
210 404
                    this.designAVEVA.ZoomFit();
......
250 444
        /// <param name="entList2"></param>
251 445
        private void CompareAndMark(Design design1, IList<Entity> entList1, Design design2, IList<Entity> entList2)
252 446
        {
447
            int[] equalEntitiesInV1 = new int[entList2.Count];
253 448
            bool[] equalEntitiesInV2 = new bool[entList2.Count];
254 449

  
450
            /// 서로 검사 가능한 타입인지 확인한다.
451
            bool CheckType(Entity ent1, Entity ent2)
452
            {
453
                return ent1.GetType() == ent2.GetType() ||
454
                    (ent1.GetType() == typeof(devDept.Eyeshot.Entities.Text) && ent2.GetType() == typeof(devDept.Eyeshot.Entities.MultilineText)) ||
455
                    (ent1.GetType() == typeof(devDept.Eyeshot.Entities.MultilineText) && ent2.GetType() == typeof(devDept.Eyeshot.Entities.Text)) ||
456
                    (ent1.GetType() == typeof(devDept.Eyeshot.Entities.Line) && ent2.GetType() == typeof(devDept.Eyeshot.Entities.TabulatedSurface));
457
            }
458

  
255 459
            try
256 460
            {
257 461
                for (int i = 0; i < entList1.Count(); i++)
......
263 467
                    {
264 468
                        Entity entVp2 = entList2[j];
265 469

  
266
                        if (!equalEntitiesInV2[j] && entVp1.GetType() == entVp2.GetType() && 
470
                        if (!equalEntitiesInV2[j] && CheckType(entVp1, entVp2) && 
267 471
                            CompareIfEqual(this.designAutoCAD, entVp1, this.designAVEVA, entVp2))
268 472
                        {
473
                            equalEntitiesInV1[j] = i;
269 474
                            equalEntitiesInV2[j] = true;
270 475
                            foundEqual = true;
271 476
                            break;
......
273 478
                    }
274 479
                    if (!foundEqual)
275 480
                    {
276
                        ColorEntity(design1, entList1[i], Verification.DiffColor);
481
                        ColorEntity(design1, entList1[i], Verification.DiffColor, colorMethodType.byEntity, false);
277 482
                    }
278 483
                }
279 484

  
280 485
                for (int j = 0; j < entList2.Count; j++)
281 486
                {
282
                    if (!equalEntitiesInV2[j])
487
                    if (equalEntitiesInV2[j])
283 488
                    {
284
                        ColorEntity(design2, entList2[j], Verification.DiffColor);
489
                        ColorEntity(design2, entList2[j], Verification.EqualColor, colorMethodType.byEntity, false);
285 490
                    }
286 491
                }
287 492
            }
......
299 504
        /// <returns></returns>
300 505
        private bool CompareIfEqual(Design design1, Entity entVp1, Design design2, Entity entVp2)
301 506
        {
302
            bool areEqualAttributes = AreEqualAttributes(entVp1, entVp2);
303
            bool areEqual = AreEqual(design1, entVp1, design2, entVp2);
304

  
305
            return areEqualAttributes && areEqual;
507
            return AreEqual(design1, entVp1, design2, entVp2);
306 508
        }
307 509

  
308 510
        private bool CompareGEntityIfEqual(GEntity entVp1, GEntity entVp2)
......
310 512
            return AreGEntityEqual(entVp1, entVp2);
311 513
        }
312 514

  
515
        /// <summary>
516
        /// 그래픽적으로 두 엔터티가 유사한지 검사한다.
517
        /// </summary>
518
        /// <param name="design1"></param>
519
        /// <param name="ent1"></param>
520
        /// <param name="design2"></param>
521
        /// <param name="ent2"></param>
522
        /// <returns></returns>
313 523
        private bool AreEqual(Design design1, Entity ent1, Design design2, Entity ent2)
314 524
        {
315 525
            if (ent1 is CompositeCurve cc1 && ent2 is CompositeCurve cc2)
......
358 568
            }
359 569
            else if (ent1 is PlanarEntity pe1 && ent2 is PlanarEntity pe2)
360 570
            {
361
                if ( pe1.Plane.AxisZ == pe2.Plane.AxisZ && pe1.Plane.AxisX == pe2.Plane.AxisX )
571
                if (ent1 is Arc arc1 && ent2 is Arc arc2)
362 572
                {
363
                    if (ent1 is Arc arc1 && ent2 is Arc arc2)
573
                    if (
574
                        arc1.Center.DistanceTo(arc2.Center) <= Verification.Tolerance &&
575
                        Math.Abs(arc1.Radius - arc2.Radius) <= Verification.Tolerance &&
576
                        Math.Abs(arc1.Domain.Min - arc2.Domain.Min) <= Verification.Tolerance &&
577
                        Math.Abs(arc1.Domain.Max - arc2.Domain.Max) <= Verification.Tolerance
578
                        )
364 579
                    {
365
                        if (
366
                            arc1.Center.DistanceTo(arc2.Center) <= Verification.Tolerance &&
367
                            Math.Abs(arc1.Radius - arc2.Radius) <= Verification.Tolerance &&
368
                            Math.Abs(arc1.Domain.Min - arc2.Domain.Min) <= Verification.Tolerance &&
369
                            Math.Abs(arc1.Domain.Max - arc2.Domain.Max) <= Verification.Tolerance
370
                            )
371
                        {
372
                            return true;
373
                        }
580
                        return true;
374 581
                    }
375
                    else if (ent1 is Circle c1 && ent2 is Circle c2)
582
                }
583
                else if (ent1 is Circle c1 && ent2 is Circle c2)
584
                {
585
                    if (
586
                        c1.Center.DistanceTo(c2.Center) <= Verification.Tolerance &&
587
                        Math.Abs(c1.Radius - c2.Radius) <= Verification.Tolerance
588
                        )
376 589
                    {
377
                        if (
378
                            c1.Center.DistanceTo(c2.Center) <= Verification.Tolerance &&
379
                            Math.Abs(c1.Radius - c2.Radius) <= Verification.Tolerance
380
                            )
381
                        {
382
                            return true;
383
                        }
590
                        return true;
384 591
                    }
385
                    else if (ent1 is EllipticalArc e1 && ent2 is EllipticalArc e2)
592
                }
593
                else if (ent1 is EllipticalArc e1 && ent2 is EllipticalArc e2)
594
                {
595
                    if (
596
                        e1.Center.DistanceTo(e2.Center) <= Verification.Tolerance &&
597
                        Math.Abs(e1.RadiusX - e2.RadiusX) <= Verification.Tolerance &&
598
                        Math.Abs(e1.RadiusY - e2.RadiusY) <= Verification.Tolerance &&
599
                        Math.Abs(e1.Domain.Low - e2.Domain.Low) <= Verification.Tolerance &&
600
                        Math.Abs(e1.Domain.High - e2.Domain.High) <= Verification.Tolerance
601
                    )
386 602
                    {
387
                        if (
388
                            e1.Center.DistanceTo(e2.Center) <= Verification.Tolerance &&
389
                            Math.Abs(e1.RadiusX - e2.RadiusX) <= Verification.Tolerance &&
390
                            Math.Abs(e1.RadiusY - e2.RadiusY) <= Verification.Tolerance &&
391
                            Math.Abs(e1.Domain.Low - e2.Domain.Low) <= Verification.Tolerance &&
392
                            Math.Abs(e1.Domain.High - e2.Domain.High) <= Verification.Tolerance
393
                        )
394
                        {
395
                            return true;
396
                        }
603
                        return true;
397 604
                    }
398
                    else if (ent1 is Ellipse el1 && ent2 is Ellipse el2)
605
                }
606
                else if (ent1 is Ellipse el1 && ent2 is Ellipse el2)
607
                {
608
                    if (
609
                        el1.Center.DistanceTo(el2.Center) <= Verification.Tolerance &&
610
                        Math.Abs(el1.RadiusX - el2.RadiusX) <= Verification.Tolerance &&
611
                        Math.Abs(el1.RadiusY - el2.RadiusY) <= Verification.Tolerance
612
                    )
399 613
                    {
400
                        if (
401
                            el1.Center.DistanceTo(el2.Center) <= Verification.Tolerance &&
402
                            Math.Abs(el1.RadiusX - el2.RadiusX) <= Verification.Tolerance &&
403
                            Math.Abs(el1.RadiusY - el2.RadiusY) <= Verification.Tolerance
404
                        )
405
                        {
406
                            return true;
407
                        }
614
                        return true;
408 615
                    }
616
                }
409 617

  
410
                    else if (ent1 is Text)
618
                else if (ent1 is Text)
619
                {
620
                    if (ent1 is Dimension dim1 && ent2 is Dimension dim2)
411 621
                    {
412
                        if (ent1 is Dimension dim1 && ent2 is Dimension dim2)
622
                        if (
623
                            dim1.InsertionPoint.DistanceTo(dim2.InsertionPoint) <= Verification.Tolerance &&
624
                            dim1.DimLinePosition.DistanceTo(dim2.DimLinePosition) <= Verification.Tolerance
625
                            )
413 626
                        {
414
                            if (
415
                                dim1.InsertionPoint.DistanceTo(dim2.InsertionPoint) <= Verification.Tolerance &&
416
                                dim1.DimLinePosition.DistanceTo(dim2.DimLinePosition) <= Verification.Tolerance
417
                                )
627
                            if (ent1 is AngularDim ad1 && ent2 is AngularDim ad2)
418 628
                            {
419
                                if (ent1 is AngularDim ad1 && ent2 is AngularDim ad2)
420
                                {
421
                                    if (
422
                                        ad1.ExtLine1.DistanceTo(ad2.ExtLine1) <= Verification.Tolerance &&
423
                                        ad1.ExtLine2.DistanceTo(ad2.ExtLine2) <= Verification.Tolerance &&
424
                                        Math.Abs(ad1.StartAngle - ad2.StartAngle) <= Verification.Tolerance &&
425
                                        Math.Abs(ad1.EndAngle - ad2.EndAngle) <= Verification.Tolerance &&
426
                                        Math.Abs(ad1.Radius - ad2.Radius) <= Verification.Tolerance
427
                                        )
428
                                    {
429
                                        return true;
430
                                    }
431
                                }
432
                                else if (ent1 is LinearDim ld1 && ent2 is LinearDim ld2)
629
                                if (
630
                                    ad1.ExtLine1.DistanceTo(ad2.ExtLine1) <= Verification.Tolerance &&
631
                                    ad1.ExtLine2.DistanceTo(ad2.ExtLine2) <= Verification.Tolerance &&
632
                                    Math.Abs(ad1.StartAngle - ad2.StartAngle) <= Verification.Tolerance &&
633
                                    Math.Abs(ad1.EndAngle - ad2.EndAngle) <= Verification.Tolerance &&
634
                                    Math.Abs(ad1.Radius - ad2.Radius) <= Verification.Tolerance
635
                                    )
433 636
                                {
434
                                    if (
435
                                        ld1.ExtLine1.DistanceTo(ld2.ExtLine1) <= Verification.Tolerance &&
436
                                        ld1.ExtLine2.DistanceTo(ld2.ExtLine2) <= Verification.Tolerance
437
                                        )
438
                                    {
439
                                        return true;
440
                                    }
637
                                    return true;
441 638
                                }
442
                                else if (ent1 is DiametricDim dd1 && ent2 is DiametricDim dd2)
443
                                {
444
                                    if (
445
                                        Math.Abs(dd1.Distance - dd2.Distance) <= Verification.Tolerance &&
446
                                        Math.Abs(dd1.Radius - dd2.Radius) <= Verification.Tolerance &&
447
                                        Math.Abs(dd1.CenterMarkSize - dd2.CenterMarkSize) <= Verification.Tolerance
639
                            }
640
                            else if (ent1 is LinearDim ld1 && ent2 is LinearDim ld2)
641
                            {
642
                                if (
643
                                    ld1.ExtLine1.DistanceTo(ld2.ExtLine1) <= Verification.Tolerance &&
644
                                    ld1.ExtLine2.DistanceTo(ld2.ExtLine2) <= Verification.Tolerance
448 645
                                    )
449
                                    {
450
                                        return true;
451
                                    }
452
                                }
453
                                else if (ent1 is RadialDim rd1 && ent2 is RadialDim rd2)
454 646
                                {
455
                                    if (
456
                                        Math.Abs(rd1.Radius - rd2.Radius) <= Verification.Tolerance &&
457
                                        Math.Abs(rd1.CenterMarkSize - rd2.CenterMarkSize) <= Verification.Tolerance
458
                                    )
459
                                    {
460
                                        return true;
461
                                    }
647
                                    return true;
462 648
                                }
463
                                else if (ent1 is OrdinateDim od1 && ent2 is OrdinateDim od2)
649
                            }
650
                            else if (ent1 is DiametricDim dd1 && ent2 is DiametricDim dd2)
651
                            {
652
                                if (
653
                                    Math.Abs(dd1.Distance - dd2.Distance) <= Verification.Tolerance &&
654
                                    Math.Abs(dd1.Radius - dd2.Radius) <= Verification.Tolerance &&
655
                                    Math.Abs(dd1.CenterMarkSize - dd2.CenterMarkSize) <= Verification.Tolerance
656
                                )
464 657
                                {
465
                                    if (
466
                                        od1.DefiningPoint.DistanceTo(od2.DefiningPoint) <= Verification.Tolerance &&
467
                                        od1.Origin.DistanceTo(od2.Origin) <= Verification.Tolerance &&
468
                                        od1.LeaderEndPoint.DistanceTo(od2.LeaderEndPoint) <= Verification.Tolerance
469
                                    )
470
                                    {
471
                                        return true;
472
                                    }
658
                                    return true;
473 659
                                }
474
                                else
660
                            }
661
                            else if (ent1 is RadialDim rd1 && ent2 is RadialDim rd2)
662
                            {
663
                                if (
664
                                    Math.Abs(rd1.Radius - rd2.Radius) <= Verification.Tolerance &&
665
                                    Math.Abs(rd1.CenterMarkSize - rd2.CenterMarkSize) <= Verification.Tolerance
666
                                )
475 667
                                {
476
                                    Console.Write("Type " + ent1.GetType() + " not implemented.");
477 668
                                    return true;
478 669
                                }
479 670
                            }
480
                        }
481

  
482
                        else if (ent1 is devDept.Eyeshot.Entities.Attribute att1 && ent2 is devDept.Eyeshot.Entities.Attribute att2)
483
                        {
484
                            if (
485
                                att1.Value == att2.Value &&
486
                                att1.InsertionPoint.DistanceTo(att2.InsertionPoint) <= Verification.Tolerance
487
                                )
671
                            else if (ent1 is OrdinateDim od1 && ent2 is OrdinateDim od2)
488 672
                            {
489
                                return true;
490
                            }
491
                        }
492
                        else
493
                        {
494
                            Text tx1 = (Text)ent1;
495
                            Text tx2 = (Text)ent2;
496

  
497
                            if (
498
                                tx1.InsertionPoint.DistanceTo(tx2.InsertionPoint) <= Verification.Tolerance &&
499
                                tx1.TextString == tx2.TextString &&
500
                                tx1.StyleName == tx2.StyleName &&
501
                                Math.Abs(tx1.WidthFactor - tx2.WidthFactor) <= Verification.Tolerance &&
502
                                Math.Abs(tx1.Height - tx2.Height) <= Verification.Tolerance
673
                                if (
674
                                    od1.DefiningPoint.DistanceTo(od2.DefiningPoint) <= Verification.Tolerance &&
675
                                    od1.Origin.DistanceTo(od2.Origin) <= Verification.Tolerance &&
676
                                    od1.LeaderEndPoint.DistanceTo(od2.LeaderEndPoint) <= Verification.Tolerance
503 677
                                )
678
                                {
679
                                    return true;
680
                                }
681
                            }
682
                            else
504 683
                            {
684
                                Console.Write("Type " + ent1.GetType() + " not implemented.");
505 685
                                return true;
506 686
                            }
507 687
                        }
508 688
                    }
509 689

  
690
                    else if (ent1 is devDept.Eyeshot.Entities.Attribute att1 && ent2 is devDept.Eyeshot.Entities.Attribute att2)
691
                    {
692
                        if (
693
                            att1.Value == att2.Value &&
694
                            att1.InsertionPoint.DistanceTo(att2.InsertionPoint) <= Verification.Tolerance
695
                            )
696
                        {
697
                            return true;
698
                        }
699
                    }
510 700
                    else
511 701
                    {
512
                        Console.Write("Type " + ent1.GetType() + " not implemented.");
513
                        return true;
702
                        Text tx1 = (Text)ent1;
703
                        Text tx2 = (Text)ent2;
704

  
705
                        if (
706
                            tx1.InsertionPoint.DistanceTo(tx2.InsertionPoint) <= Verification.Tolerance &&
707
                            tx1.TextString.Trim() == tx2.TextString.Trim() &&
708
                            Math.Abs(tx1.WidthFactor - tx2.WidthFactor) <= Verification.Tolerance &&
709
                            Math.Abs(tx1.Height - tx2.Height) <= Verification.Tolerance
710
                            )
711
                        {
712
                            return true;
713
                        }
514 714
                    }
515 715
                }
516 716
            }
517 717
            else if (ent1 is Line line1 && ent2 is Line line2)
518 718
            {
719
                var dir1 = line1.Direction;
720
                dir1.Normalize();
721
                var dir2 = line2.Direction;
722
                dir2.Normalize();
723
                if (devDept.Geometry.Vector3D.AreParallel(dir1, dir2, 0.1) &&
724
                    Math.Abs(line1.Length() - line2.Length()) <= Verification.Tolerance &&
725
                    line1.MidPoint.DistanceTo(line2.MidPoint) <= Verification.Tolerance
726
                )
727
                {
728
                    return true;
729
                }
730
            }
731
            else if (ent1 is Line && ent2 is devDept.Eyeshot.Entities.TabulatedSurface lwpolyline && lwpolyline.ControlPoints.Length == 4)
732
            {
733
                line1 = ent1 as Line;
734
                var start = new devDept.Geometry.Point3D(lwpolyline.ControlPoints[0, 0].X, lwpolyline.ControlPoints[0, 0].Y, 0);
735
                var end = new devDept.Geometry.Point3D(lwpolyline.ControlPoints[1, 0].X, lwpolyline.ControlPoints[1, 0].Y, 0);
736
                var vec = new devDept.Geometry.Vector3D(start, end);
737
                vec.Normalize();
738
                var dir = line1.Direction.Clone() as devDept.Geometry.Vector3D;
739
                dir.Normalize();
740

  
519 741
                if (
520
                    line1.StartPoint.DistanceTo(line2.StartPoint) <= Verification.Tolerance &&
521
                    line1.EndPoint.DistanceTo(line2.EndPoint) <= Verification.Tolerance
742
                    devDept.Geometry.Vector3D.AreParallel(dir, vec) &&
743
                    line1.StartPoint.DistanceTo(start) <= Verification.Tolerance &&
744
                    line1.EndPoint.DistanceTo(end) <= Verification.Tolerance
522 745
                )
523 746
                {
524 747
                    return true;
......
558 781
                    return true;
559 782
                }
560 783
            }
561
            else if(ent1 is Mesh m1 && ent2 is Mesh m2 && m1.Vertices.Count() == m2.Vertices.Count())
784
            else if (ent1 is Mesh m1 && ent2 is Mesh m2 && m1.Vertices.Count() == m2.Vertices.Count())
562 785
            {
563
                for(int i = 0;i < m1.Vertices.Count();++i)
786
                for (int i = 0; i < m1.Vertices.Count(); ++i)
564 787
                {
565 788
                    if (m1.Vertices[i].DistanceTo(m2.Vertices[i]) > Verification.Tolerance) return false;
566 789
                }
......
571 794
            {
572 795
                int equalCurvesInEntityList = 0;
573 796

  
574
                var entitites1 = blkref1.GetEntities(design1.Blocks);
575
                var entitites2 = blkref2.GetEntities(design2.Blocks);
576
                foreach (var entC in entitites1)
797
                #region Point 제거 및 LinePath를 라인으로 분리
798
                var entities1 = blkref1.Explode(design1.Blocks).Where(x => x.LayerName != "AS_PORT" && !(x is devDept.Eyeshot.Entities.Point)).ToList();
799
                var coll1 = new List<Entity>();
800
                entities1.ForEach(x =>
577 801
                {
578
                    foreach (var entC2 in entitites2)
802
                    if (x is LinearPath lp)
803
                    {
804
                        for (int i = 0; i < lp.Vertices.Length - 1; ++i)
805
                        {
806
                            if (lp.Vertices[i].DistanceTo(lp.Vertices[i + 1]) < 0.1) continue;
807
                            coll1.Add(new Line(lp.Vertices[i], lp.Vertices[i + 1]));
808
                        }
809
                    }
810
                    else
811
                    {
812
                        coll1.Add(x);
813
                    }
814
                });
815
                #endregion
816

  
817
                #region Point 및 Nesting Block 제거 및 LinePath를 라인으로 분리
818
                var entities2 = blkref2.Explode(design2.Blocks).Where(x => 
819
                !(x is devDept.Eyeshot.Entities.BlockReference blkref && blkref.BlockName == "PORT") && !(x is devDept.Eyeshot.Entities.Point)).ToList();
820
                var coll2 = new List<Entity>();
821
                entities2.ForEach(x =>
822
                {
823
                    if (x is LinearPath lp)
824
                    {
825
                        for (int i = 0; i < lp.Vertices.Length - 1; ++i)
826
                        {
827
                            if (lp.Vertices[i].DistanceTo(lp.Vertices[i + 1]) < 0.1) continue;
828
                            coll2.Add(new Line(lp.Vertices[i], lp.Vertices[i + 1]));
829
                        }
830
                    }
831
                    else if (x is devDept.Eyeshot.Entities.Attribute attr)
832
                    {
833
                        if (!attr.Invisible) coll2.Add(attr);
834
                    }
835
                    else if (x.GetType().Name == "AttributeReferenceData")
836
                    {
837
                    }
838
                    else
839
                    {
840
                        coll2.Add(x);
841
                    }
842
                });
843
                #endregion
844

  
845
                if (coll1.Count != coll2.Count) return false;
846

  
847
                foreach (var entC in coll1)
848
                {
849
                    foreach (var entC2 in coll2)
579 850
                    {
580 851
                        if (entC.GetType() == entC2.GetType())
581 852
                        {
......
588 859
                    }
589 860
                }
590 861

  
591
                if (entitites1.Count == equalCurvesInEntityList)
862
                if (coll1.Count == equalCurvesInEntityList)
592 863
                {
593 864
                    return true;
594 865
                }
......
752 1023
            return false;
753 1024
        }
754 1025

  
755
        private bool AreEqualAttributes(Entity ent1, Entity ent2)
756
        {
757
            return 
758
                ent1.LayerName == ent2.LayerName &&
759
                ent1.GroupIndex == ent2.GroupIndex &&
760
                ent1.ColorMethod == ent2.ColorMethod &&
761
                ent1.Color == ent2.Color &&
762
                ent1.LineWeightMethod == ent2.LineWeightMethod &&
763
                ent1.LineWeight == ent2.LineWeight &&
764
                ent1.LineTypeMethod == ent2.LineTypeMethod &&
765
                ent1.LineTypeName == ent2.LineTypeName &&
766
                ent1.LineTypeScale == ent2.LineTypeScale &&
767
                ent1.MaterialName == ent2.MaterialName;
768
        }
769

  
770 1026
        #region Camera Sync
771 1027
        private void CameraChanged(object sender, devDept.Eyeshot.Workspace.CameraMoveEventArgs e)
772 1028
        {

내보내기 Unified diff

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