프로젝트

일반

사용자정보

개정판 ac1b02f3

IDac1b02f32a48a60632af128360fb3161fbd89766
상위 70ed289d
하위 b2ff5ff4

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

Feature: 엔터티 비교 기능 및 Tolerance, 색상 설정 기능 추가

Change-Id: I97dd6fb154ebffa28e932bcc7c035f43701b2a9d

차이점 보기:

ID2.Manager/ID2.Manager/Controls/Verification.cs
21 21
        readonly Informations informations = Informations.Instance;
22 22
        readonly string IniFilePath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), 
23 23
            Application.ProductName, $"{Application.ProductName}.ini");
24
        private static readonly Color NOT_MODIFIED_COLOR = Color.FromArgb(44, 44, 44);
24

  
25
        private static Color EqualColor = Color.FromArgb(44, 44, 44);
26
        private static Color DiffColor = Color.Yellow;
27
        private static double Tolerance = 0;
25 28

  
26 29
        public Verification()
27 30
        {
......
31 34
            this.Load += Verification_Load;
32 35
            this.radGridViewDocument.SelectionChanged += RadGridViewDocument_SelectionChanged;
33 36
            this.radBrowseEditorAVEVAPIDFolder.ValueChanged += RadBrowseEditorAVEVAPIDFolder_ValueChanged;
37
            this.radSpinEditorTolerance.ValueChanged += RadSpinEditorTolerance_ValueChanged;
38
            this.radColorBoxEqualColor.ValueChanged += RadColorBoxEqualColor_ValueChanged;
39
            this.radColorBoxDiffColor.ValueChanged += RadColorBoxDiffColor_ValueChanged;
34 40

  
35 41
            #region Camera Sync
36 42
            this.designAutoCAD.ActiveViewport.Rotate.Enabled = false;
......
50 56
            #endregion
51 57
        }
52 58

  
59
        /// <summary>
60
        /// 서로 다른 엔터티의 색상을 설정한다.
61
        /// </summary>
62
        /// <param name="sender"></param>
63
        /// <param name="e"></param>
64
        private void RadColorBoxDiffColor_ValueChanged(object sender, EventArgs e)
65
        {
66
            Verification.DiffColor = this.radColorBoxDiffColor.Value;
67
            string color = $"{Verification.DiffColor.R},{Verification.DiffColor.G},{Verification.DiffColor.B}";
68
            Classes.ID2Helper.IniWriteValue(IniFilePath, "Verification", "DiffColor", color);
69
        }
70

  
71
        /// <summary>
72
        /// 동일한 엔터티의 색상을 설정한다.
73
        /// </summary>
74
        /// <param name="sender"></param>
75
        /// <param name="e"></param>
76
        private void RadColorBoxEqualColor_ValueChanged(object sender, EventArgs e)
77
        {
78
            Verification.EqualColor = this.radColorBoxEqualColor.Value;
79
            string color = $"{Verification.EqualColor.R},{Verification.EqualColor.G},{Verification.EqualColor.B}";
80
            Classes.ID2Helper.IniWriteValue(IniFilePath, "Verification", "EqualColor", color);
81
        }
82

  
83
        private void RadSpinEditorTolerance_ValueChanged(object sender, EventArgs e)
84
        {
85
            string AVEVAPIDFolder = this.radBrowseEditorAVEVAPIDFolder.Value;
86
            if (System.IO.Directory.Exists(AVEVAPIDFolder))
87
            {
88
                Classes.ID2Helper.IniWriteValue(IniFilePath, "Verification", "Tolerance", this.radSpinEditorTolerance.Value.ToString());
89
            }
90
        }
91

  
53 92
        private void RadBrowseEditorAVEVAPIDFolder_ValueChanged(object sender, EventArgs e)
54 93
        {
55 94
            string AVEVAPIDFolder = this.radBrowseEditorAVEVAPIDFolder.Value;
......
63 102
        {
64 103
            string AVEVAPIDFolder = Classes.ID2Helper.IniReadValue(IniFilePath, "Path", "AVEVA P&ID Folder");
65 104
            if (!string.IsNullOrEmpty(AVEVAPIDFolder)) this.radBrowseEditorAVEVAPIDFolder.Value = AVEVAPIDFolder;
105

  
106
            string Toler = Classes.ID2Helper.IniReadValue(IniFilePath, "Verification", "Tolerance");
107
            if (!string.IsNullOrEmpty(Toler)) this.radSpinEditorTolerance.Value = Convert.ToDecimal(Toler);
108

  
109
            string _EqualColor = Classes.ID2Helper.IniReadValue(IniFilePath, "Verification", "EqualColor");
110
            if (!string.IsNullOrEmpty(_EqualColor))
111
            {
112
                var tokens = _EqualColor.Split(',');
113
                if (tokens.Length == 3)
114
                {
115
                    this.radColorBoxEqualColor.Value =
116
                         Color.FromArgb(Convert.ToInt32(tokens[0]), Convert.ToInt32(tokens[1]), Convert.ToInt32(tokens[2]));
117
                }
118
            }
119

  
120
            string _DiffColor = Classes.ID2Helper.IniReadValue(IniFilePath, "Verification", "DiffColor");
121
            if (!string.IsNullOrEmpty(_DiffColor))
122
            {
123
                var tokens = _DiffColor.Split(',');
124
                if (tokens.Length == 3)
125
                {
126
                    this.radColorBoxDiffColor.Value =
127
                        Color.FromArgb(Convert.ToInt32(tokens[0]), Convert.ToInt32(tokens[1]), Convert.ToInt32(tokens[2]));
128
                }
129
            }
66 130
        }
67 131

  
68
        public void ColorEntities(Design design, EntityList list)
132
        /// <summary>
133
        /// 엔터티들의 색상을 바꾼다.
134
        /// </summary>
135
        /// <param name="design"></param>
136
        /// <param name="list"></param>
137
        public void ColorEntities(Design design, EntityList list, Color color)
69 138
        {
70 139
            foreach (Entity ent in list)
71 140
            {
72
                if (ent is BlockReference blkref)
141
                ColorEntity(design, ent, color);
142
            }
143
        }
144

  
145
        /// <summary>
146
        /// 엔터티의 색상을 변경한다.
147
        /// </summary>
148
        /// <param name="design"></param>
149
        /// <param name="entity"></param>
150
        /// <param name="color"></param>
151
        private void ColorEntity(Design design, Entity entity, Color color)
152
        {
153
            if (entity is BlockReference blkref)
154
            {
155
                blkref.Color = color;
156
                blkref.ColorMethod = colorMethodType.byEntity;
157
                var blk = design.Blocks.FirstOrDefault(x => x.Name == blkref.BlockName);
158
                if (blk != null)
73 159
                {
74
                    var blk = design.Blocks.FirstOrDefault(x => x.Name == blkref.BlockName);
75
                    if(blk != null)
160
                    ColorEntities(design, blk.Entities, color);
161
                    foreach(var attr in blkref.Attributes.Values)
76 162
                    {
77
                        foreach(Entity _ent in blk.Entities)
78
                        {
79
                            _ent.Color = NOT_MODIFIED_COLOR;
80
                            _ent.ColorMethod = colorMethodType.byEntity;
81
                        }
163
                        attr.Color = color;
164
                        attr.ColorMethod = colorMethodType.byEntity;
82 165
                    }
83 166
                }
84
                else
85
                {
86
                    ent.Color = NOT_MODIFIED_COLOR;
87
                    ent.ColorMethod = colorMethodType.byEntity;
88
                }
167
            }
168
            else
169
            {
170
                entity.Color = color;
171
                entity.ColorMethod = colorMethodType.byEntity;
89 172
            }
90 173
        }
91 174

  
......
100 183
                    ra.DoWork();
101 184
                    ra.AddToScene(this.designAutoCAD);
102 185

  
103
                    ///Entity[] toAdd = this.designAutoCAD.Entities.Explode();
104
                    ///this.designAutoCAD.Entities.AddRange(toAdd, NOT_MODIFIED_COLOR);
105
                    ColorEntities(this.designAutoCAD, this.designAutoCAD.Entities);
186
                    ColorEntities(this.designAutoCAD, this.designAutoCAD.Entities, Verification.EqualColor);
106 187

  
107 188
                    // Sets the view as Top
108 189
                    this.designAutoCAD.SetView(viewType.Top);
......
120 201
                    ra.DoWork();
121 202
                    ra.AddToScene(this.designAVEVA);
122 203

  
123
                    ///Entity[] toAdd = this.designAVEVA.Entities.Explode();
124
                    ///this.designAVEVA.Entities.AddRange(toAdd, NOT_MODIFIED_COLOR);
125
                    ColorEntities(this.designAVEVA, this.designAVEVA.Entities);
204
                    ColorEntities(this.designAVEVA, this.designAVEVA.Entities, Verification.EqualColor);
126 205

  
127 206
                    this.designAVEVA.SetView(viewType.Top);
128 207
                    this.designAVEVA.ZoomFit();
......
148 227

  
149 228
                if(System.IO.File.Exists(dwgFilePath) && System.IO.File.Exists(AVEVAPIDFilePath))
150 229
                {
151
                    CompareAndMark(this.designAutoCAD.Entities, this.designAVEVA.Entities);
230
                    CompareAndMark(this.designAutoCAD, this.designAutoCAD.Entities, this.designAVEVA, this.designAVEVA.Entities);
152 231
                }
153 232
            }
154 233
        }
......
159 238
            this.radGridViewDocument.DataSource = new BindingList<ID2.Manager.Data.Models.Documents>(docs);
160 239
        }
161 240

  
162
        private void CompareAndMark(IList<Entity> entList1, IList<Entity> entList2)
241
        /// <summary>
242
        /// 주어진 두 엔터티 리스트를 비교하여 틀린 엔터티의 색상을 Yellow로 변경한다.
243
        /// </summary>
244
        /// <param name="entList1"></param>
245
        /// <param name="entList2"></param>
246
        private void CompareAndMark(Design design1, IList<Entity> entList1, Design design2, IList<Entity> entList2)
163 247
        {
164 248
            bool[] equalEntitiesInV2 = new bool[entList2.Count];
165 249

  
......
174 258
                    {
175 259
                        Entity entVp2 = entList2[j];
176 260

  
177
                        if (!equalEntitiesInV2[j] && entVp1.GetType() == entVp2.GetType() && CompareIfEqual(entVp1, entVp2))
261
                        if (!equalEntitiesInV2[j] && entVp1.GetType() == entVp2.GetType() && 
262
                            CompareIfEqual(this.designAutoCAD, entVp1, this.designAVEVA, entVp2))
178 263
                        {
179 264
                            equalEntitiesInV2[j] = true;
180 265
                            foundEqual = true;
......
183 268
                    }
184 269
                    if (!foundEqual)
185 270
                    {
186
                        entList1[i].Color = Color.Yellow;
187
                        entList1[i].ColorMethod = colorMethodType.byEntity;
271
                        ColorEntity(design1, entList1[i], Verification.DiffColor);
188 272
                    }
189 273
                }
190 274

  
......
192 276
                {
193 277
                    if (!equalEntitiesInV2[j])
194 278
                    {
195
                        entList2[j].Color = Color.Yellow;
196
                        entList2[j].ColorMethod = colorMethodType.byEntity;
279
                        ColorEntity(design2, entList2[j], Verification.DiffColor);
197 280
                    }
198 281
                }
199 282
            }
......
203 286
            }
204 287
        }
205 288

  
206
        private bool CompareIfEqual(Entity entVp1, Entity entVp2)
289
        /// <summary>
290
        /// 주어진 두 엔터티를 비교한다.
291
        /// </summary>
292
        /// <param name="entVp1"></param>
293
        /// <param name="entVp2"></param>
294
        /// <returns></returns>
295
        private bool CompareIfEqual(Design design1, Entity entVp1, Design design2, Entity entVp2)
207 296
        {
208 297
            bool areEqualAttributes = AreEqualAttributes(entVp1, entVp2);
209
            bool areEqual = AreEqual(entVp1, entVp2);
298
            bool areEqual = AreEqual(design1, entVp1, design2, entVp2);
210 299

  
211 300
            return areEqualAttributes && areEqual;
212 301
        }
......
216 305
            return AreGEntityEqual(entVp1, entVp2);
217 306
        }
218 307

  
219
        private bool AreEqual(Entity ent1, Entity ent2)
308
        private bool AreEqual(Design design1, Entity ent1, Design design2, Entity ent2)
220 309
        {
221
            if (ent1 is CompositeCurve)
310
            if (ent1 is CompositeCurve cc1 && ent2 is CompositeCurve cc2)
222 311
            {
223
                CompositeCurve cc1 = (CompositeCurve)ent1;
224
                CompositeCurve cc2 = (CompositeCurve)ent2;
225

  
226 312
                if (cc1.CurveList.Count == cc2.CurveList.Count)
227 313
                {
228 314
                    int equalCurvesInListCount = 0;
......
232 318
                        {
233 319
                            if (entC.GetType() == entC2.GetType())
234 320
                            {
235
                                if (entC is Entity && entC2 is Entity && CompareIfEqual(entC as Entity, entC2 as Entity))
321
                                if (entC is Entity && entC2 is Entity && CompareIfEqual(design1, entC as Entity, design2, entC2 as Entity))
236 322
                                {
237 323
                                    equalCurvesInListCount++;
238 324
                                    break;
......
252 338
                    }
253 339
                }
254 340
            }
255
            else if (ent1 is LinearPath)
341
            else if (ent1 is LinearPath lp1 && ent2 is LinearPath lp2)
256 342
            {
257
                LinearPath lp1 = (LinearPath)ent1;
258
                LinearPath lp2 = (LinearPath)ent2;
259

  
260 343
                if (lp1.Vertices.Length == lp2.Vertices.Length)
261 344
                {
262 345
                    for (int i = 0; i < lp1.Vertices.Length; i++)
263 346
                    {
264
                        if (!(lp1.Vertices[i] == lp2.Vertices[i]))
347
                        if (lp1.Vertices[i].DistanceTo(lp2.Vertices[i]) > Verification.Tolerance)
265 348
                            return false;
266 349
                    }
350

  
267 351
                    return true;
268 352
                }
269 353
            }
270

  
271
            else if (ent1 is PlanarEntity)
354
            else if (ent1 is PlanarEntity pe1 && ent2 is PlanarEntity pe2)
272 355
            {
273
                PlanarEntity pe1 = (PlanarEntity)ent1;
274
                PlanarEntity pe2 = (PlanarEntity)ent2;
275
                if (
276
                    pe1.Plane.AxisZ == pe2.Plane.AxisZ &&
277
                    pe1.Plane.AxisX == pe2.Plane.AxisX
278
                    )
356
                if ( pe1.Plane.AxisZ == pe2.Plane.AxisZ && pe1.Plane.AxisX == pe2.Plane.AxisX )
279 357
                {
280
                    if (ent1 is Arc)
358
                    if (ent1 is Arc arc1 && ent2 is Arc arc2)
281 359
                    {
282
                        Arc arc1 = (Arc)ent1;
283
                        Arc arc2 = (Arc)ent2;
284

  
285 360
                        if (
286
                            arc1.Center == arc2.Center &&
287
                            arc1.Radius == arc2.Radius &&
288
                            arc1.Domain.Min == arc2.Domain.Min &&
289
                            arc1.Domain.Max == arc2.Domain.Max
361
                            arc1.Center.DistanceTo(arc2.Center) <= Verification.Tolerance &&
362
                            Math.Abs(arc1.Radius - arc2.Radius) <= Verification.Tolerance &&
363
                            Math.Abs(arc1.Domain.Min - arc2.Domain.Min) <= Verification.Tolerance &&
364
                            Math.Abs(arc1.Domain.Max - arc2.Domain.Max) <= Verification.Tolerance
290 365
                            )
291 366
                        {
292 367
                            return true;
293 368
                        }
294 369
                    }
295
                    else if (ent1 is Circle)
370
                    else if (ent1 is Circle c1 && ent2 is Circle c2)
296 371
                    {
297
                        Circle c1 = (Circle)ent1;
298
                        Circle c2 = (Circle)ent2;
299

  
300 372
                        if (
301
                            c1.Center == c2.Center &&
302
                            c1.Radius == c2.Radius
373
                            c1.Center.DistanceTo(c2.Center) <= Verification.Tolerance &&
374
                            Math.Abs(c1.Radius - c2.Radius) <= Verification.Tolerance
303 375
                            )
304 376
                        {
305 377
                            return true;
306 378
                        }
307 379
                    }
308
                    else if (ent1 is EllipticalArc)
380
                    else if (ent1 is EllipticalArc e1 && ent2 is EllipticalArc e2)
309 381
                    {
310
                        EllipticalArc e1 = (EllipticalArc)ent1;
311
                        EllipticalArc e2 = (EllipticalArc)ent2;
312

  
313 382
                        if (
314
                            e1.Center == e2.Center &&
315
                            e1.RadiusX == e2.RadiusX &&
316
                            e1.RadiusY == e2.RadiusY &&
317
                            e1.Domain.Low == e2.Domain.Low &&
318
                            e1.Domain.High == e2.Domain.High
383
                            e1.Center.DistanceTo(e2.Center) <= Verification.Tolerance &&
384
                            Math.Abs(e1.RadiusX - e2.RadiusX) <= Verification.Tolerance &&
385
                            Math.Abs(e1.RadiusY - e2.RadiusY) <= Verification.Tolerance &&
386
                            Math.Abs(e1.Domain.Low - e2.Domain.Low) <= Verification.Tolerance &&
387
                            Math.Abs(e1.Domain.High - e2.Domain.High) <= Verification.Tolerance
319 388
                        )
320 389
                        {
321 390
                            return true;
322 391
                        }
323 392
                    }
324
                    else if (ent1 is Ellipse)
393
                    else if (ent1 is Ellipse el1 && ent2 is Ellipse el2)
325 394
                    {
326
                        Ellipse e1 = (Ellipse)ent1;
327
                        Ellipse e2 = (Ellipse)ent2;
328

  
329 395
                        if (
330
                            e1.Center == e2.Center &&
331
                            e1.RadiusX == e2.RadiusX &&
332
                            e1.RadiusY == e2.RadiusY
396
                            el1.Center.DistanceTo(el2.Center) <= Verification.Tolerance &&
397
                            Math.Abs(el1.RadiusX - el2.RadiusX) <= Verification.Tolerance &&
398
                            Math.Abs(el1.RadiusY - el2.RadiusY) <= Verification.Tolerance
333 399
                        )
334 400
                        {
335 401
                            return true;
......
338 404

  
339 405
                    else if (ent1 is Text)
340 406
                    {
341
                        if (ent1 is Dimension)
407
                        if (ent1 is Dimension dim1 && ent2 is Dimension dim2)
342 408
                        {
343
                            Dimension dim1 = (Dimension)ent1;
344
                            Dimension dim2 = (Dimension)ent2;
345

  
346 409
                            if (
347
                                dim1.InsertionPoint == dim2.InsertionPoint &&
348
                                dim1.DimLinePosition == dim2.DimLinePosition
410
                                dim1.InsertionPoint.DistanceTo(dim2.InsertionPoint) <= Verification.Tolerance &&
411
                                dim1.DimLinePosition.DistanceTo(dim2.DimLinePosition) <= Verification.Tolerance
349 412
                                )
350 413
                            {
351

  
352
                                if (ent1 is AngularDim)
414
                                if (ent1 is AngularDim ad1 && ent2 is AngularDim ad2)
353 415
                                {
354
                                    AngularDim ad1 = (AngularDim)ent1;
355
                                    AngularDim ad2 = (AngularDim)ent2;
356

  
357 416
                                    if (
358
                                        ad1.ExtLine1 == ad2.ExtLine1 &&
359
                                        ad1.ExtLine2 == ad2.ExtLine2 &&
360
                                        ad1.StartAngle == ad2.StartAngle &&
361
                                        ad1.EndAngle == ad2.EndAngle &&
362
                                        ad1.Radius == ad2.Radius
417
                                        ad1.ExtLine1.DistanceTo(ad2.ExtLine1) <= Verification.Tolerance &&
418
                                        ad1.ExtLine2.DistanceTo(ad2.ExtLine2) <= Verification.Tolerance &&
419
                                        Math.Abs(ad1.StartAngle - ad2.StartAngle) <= Verification.Tolerance &&
420
                                        Math.Abs(ad1.EndAngle - ad2.EndAngle) <= Verification.Tolerance &&
421
                                        Math.Abs(ad1.Radius - ad2.Radius) <= Verification.Tolerance
363 422
                                        )
364 423
                                    {
365 424
                                        return true;
366 425
                                    }
367 426
                                }
368
                                else if (ent1 is LinearDim)
427
                                else if (ent1 is LinearDim ld1 && ent2 is LinearDim ld2)
369 428
                                {
370
                                    LinearDim ld1 = (LinearDim)ent1;
371
                                    LinearDim ld2 = (LinearDim)ent2;
372

  
373 429
                                    if (
374
                                        ld1.ExtLine1 == ld2.ExtLine1 &&
375
                                        ld1.ExtLine2 == ld2.ExtLine2
430
                                        ld1.ExtLine1.DistanceTo(ld2.ExtLine1) <= Verification.Tolerance &&
431
                                        ld1.ExtLine2.DistanceTo(ld2.ExtLine2) <= Verification.Tolerance
376 432
                                        )
377 433
                                    {
378 434
                                        return true;
379 435
                                    }
380 436
                                }
381
                                else if (ent1 is DiametricDim)
437
                                else if (ent1 is DiametricDim dd1 && ent2 is DiametricDim dd2)
382 438
                                {
383
                                    DiametricDim dd1 = (DiametricDim)ent1;
384
                                    DiametricDim dd2 = (DiametricDim)ent2;
385

  
386 439
                                    if (
387
                                        dd1.Distance == dd2.Distance &&
388
                                        dd1.Radius == dd2.Radius &&
389
                                        dd1.CenterMarkSize == dd2.CenterMarkSize
440
                                        Math.Abs(dd1.Distance - dd2.Distance) <= Verification.Tolerance &&
441
                                        Math.Abs(dd1.Radius - dd2.Radius) <= Verification.Tolerance &&
442
                                        Math.Abs(dd1.CenterMarkSize - dd2.CenterMarkSize) <= Verification.Tolerance
390 443
                                    )
391 444
                                    {
392 445
                                        return true;
393 446
                                    }
394 447
                                }
395
                                else if (ent1 is RadialDim)
448
                                else if (ent1 is RadialDim rd1 && ent2 is RadialDim rd2)
396 449
                                {
397
                                    RadialDim rd1 = (RadialDim)ent1;
398
                                    RadialDim rd2 = (RadialDim)ent2;
399

  
400 450
                                    if (
401
                                        rd1.Radius == rd2.Radius &&
402
                                        rd1.CenterMarkSize == rd2.CenterMarkSize
451
                                        Math.Abs(rd1.Radius - rd2.Radius) <= Verification.Tolerance &&
452
                                        Math.Abs(rd1.CenterMarkSize - rd2.CenterMarkSize) <= Verification.Tolerance
403 453
                                    )
404 454
                                    {
405 455
                                        return true;
406 456
                                    }
407 457
                                }
408
                                else if (ent1 is OrdinateDim)
458
                                else if (ent1 is OrdinateDim od1 && ent2 is OrdinateDim od2)
409 459
                                {
410
                                    OrdinateDim od1 = (OrdinateDim)ent1;
411
                                    OrdinateDim od2 = (OrdinateDim)ent2;
412

  
413 460
                                    if (
414
                                        od1.DefiningPoint == od2.DefiningPoint &&
415
                                        od1.Origin == od2.Origin &&
416
                                        od1.LeaderEndPoint == od2.LeaderEndPoint
461
                                        od1.DefiningPoint.DistanceTo(od2.DefiningPoint) <= Verification.Tolerance &&
462
                                        od1.Origin.DistanceTo(od2.Origin) <= Verification.Tolerance &&
463
                                        od1.LeaderEndPoint.DistanceTo(od2.LeaderEndPoint) <= Verification.Tolerance
417 464
                                    )
418 465
                                    {
419 466
                                        return true;
......
427 474
                            }
428 475
                        }
429 476

  
430
                        else if (ent1 is devDept.Eyeshot.Entities.Attribute)
477
                        else if (ent1 is devDept.Eyeshot.Entities.Attribute att1 && ent2 is devDept.Eyeshot.Entities.Attribute att2)
431 478
                        {
432
                            devDept.Eyeshot.Entities.Attribute att1 = (devDept.Eyeshot.Entities.Attribute)ent1;
433
                            devDept.Eyeshot.Entities.Attribute att2 = (devDept.Eyeshot.Entities.Attribute)ent2;
434

  
435 479
                            if (
436 480
                                att1.Value == att2.Value &&
437
                                att1.InsertionPoint == att2.InsertionPoint
481
                                att1.InsertionPoint.DistanceTo(att2.InsertionPoint) <= Verification.Tolerance
438 482
                                )
439 483
                            {
440 484
                                return true;
441 485
                            }
442 486
                        }
443

  
444 487
                        else
445 488
                        {
446 489
                            Text tx1 = (Text)ent1;
447 490
                            Text tx2 = (Text)ent2;
448 491

  
449 492
                            if (
450
                                tx1.InsertionPoint == tx2.InsertionPoint &&
493
                                tx1.InsertionPoint.DistanceTo(tx2.InsertionPoint) <= Verification.Tolerance &&
451 494
                                tx1.TextString == tx2.TextString &&
452 495
                                tx1.StyleName == tx2.StyleName &&
453
                                tx1.WidthFactor == tx2.WidthFactor &&
454
                                tx1.Height == tx2.Height
496
                                Math.Abs(tx1.WidthFactor - tx2.WidthFactor) <= Verification.Tolerance &&
497
                                Math.Abs(tx1.Height - tx2.Height) <= Verification.Tolerance
455 498
                                )
456 499
                            {
457 500
                                return true;
......
466 509
                    }
467 510
                }
468 511
            }
469

  
470
            else if (ent1 is Line)
512
            else if (ent1 is Line line1 && ent2 is Line line2)
471 513
            {
472
                Line line1 = (Line)ent1;
473
                Line line2 = (Line)ent2;
474

  
475 514
                if (
476
                    line1.StartPoint == line2.StartPoint &&
477
                    line1.EndPoint == line2.EndPoint
515
                    line1.StartPoint.DistanceTo(line2.StartPoint) <= Verification.Tolerance &&
516
                    line1.EndPoint.DistanceTo(line2.EndPoint) <= Verification.Tolerance
478 517
                )
479 518
                {
480 519
                    return true;
481 520
                }
482 521
            }
483

  
484
            else if (ent1 is devDept.Eyeshot.Entities.Point)
522
            else if (ent1 is devDept.Eyeshot.Entities.Point point1 && ent2 is devDept.Eyeshot.Entities.Point point2)
485 523
            {
486
                devDept.Eyeshot.Entities.Point point1 = (devDept.Eyeshot.Entities.Point)ent1;
487
                devDept.Eyeshot.Entities.Point point2 = (devDept.Eyeshot.Entities.Point)ent2;
488

  
489
                if (
490
                    point1.Position == point2.Position
491
                )
524
                if (point1.Position.DistanceTo(point2.Position) <= Verification.Tolerance)
492 525
                {
493 526
                    return true;
494 527
                }
495 528
            }
496

  
497
#if NURBS
498
            else if (ent1 is Curve)
529
            else if (ent1 is Curve cu1 && ent2 is Curve cu2)
499 530
            {
500
                Curve cu1 = (Curve)ent1;
501
                Curve cu2 = (Curve)ent2;
502

  
503 531
                if (
504 532
                    cu1.ControlPoints.Length == cu2.ControlPoints.Length &&
505 533
                    cu1.KnotVector.Length == cu2.KnotVector.Length &&
......
508 536
                {
509 537
                    for (int k = 0; k < cu1.ControlPoints.Length; k++)
510 538
                    {
511
                        if (cu1.ControlPoints[k] != cu2.ControlPoints[k])
539
                        if (cu1.ControlPoints[k].DistanceTo(cu2.ControlPoints[k]) > Verification.Tolerance)
512 540
                        {
513 541
                            return false;
514 542
                        }
......
525 553
                    return true;
526 554
                }
527 555
            }
528
#endif
556
            else if(ent1 is Mesh m1 && ent2 is Mesh m2 && m1.Vertices.Count() == m2.Vertices.Count())
557
            {
558
                for(int i = 0;i < m1.Vertices.Count();++i)
559
                {
560
                    if (m1.Vertices[i].DistanceTo(m2.Vertices[i]) > Verification.Tolerance) return false;
561
                }
562

  
563
                return true;
564
            }
565
            else if (ent1 is BlockReference blkref1 && ent2 is BlockReference blkref2)
566
            {
567
                int equalCurvesInEntityList = 0;
529 568

  
569
                var entitites1 = blkref1.GetEntities(design1.Blocks);
570
                var entitites2 = blkref2.GetEntities(design2.Blocks);
571
                foreach (var entC in entitites1)
572
                {
573
                    foreach (var entC2 in entitites2)
574
                    {
575
                        if (entC.GetType() == entC2.GetType())
576
                        {
577
                            if (entC is Entity && entC2 is Entity && CompareIfEqual(design1, entC as Entity, design2, entC2 as Entity))
578
                            {
579
                                equalCurvesInEntityList++;
580
                                break;
581
                            }
582
                        }
583
                    }
584
                }
585

  
586
                if (entitites1.Count == equalCurvesInEntityList)
587
                {
588
                    return true;
589
                }
590
            }
530 591
            else
531 592
            {
532 593
                Console.Write("Type " + ent1.GetType() + " not implemented.");
533
                return true;
594
                return false;
534 595
            }
596

  
535 597
            return false;
536 598
        }
537 599

  
538 600
        private bool AreGEntityEqual(GEntity ent1, GEntity ent2)
539 601
        {
540
            if (ent1 is GCompositeCurve)
602
            if (ent1 is GCompositeCurve cc1 && ent2 is GCompositeCurve cc2)
541 603
            {
542
                GCompositeCurve cc1 = (GCompositeCurve)ent1;
543
                GCompositeCurve cc2 = (GCompositeCurve)ent2;
544

  
545 604
                if (cc1.CurveList.Count == cc2.CurveList.Count)
546 605
                {
547 606
                    int equalCurvesInListCount = 0;
......
566 625
                    }
567 626
                }
568 627
            }
569
            else if (ent1 is GLinearPath)
628
            else if (ent1 is GLinearPath lp1 && ent2 is GLinearPath lp2)
570 629
            {
571
                GLinearPath lp1 = (GLinearPath)ent1;
572
                GLinearPath lp2 = (GLinearPath)ent2;
573

  
574 630
                if (lp1.Vertices.Length == lp2.Vertices.Length)
575 631
                {
576 632
                    for (int i = 0; i < lp1.Vertices.Length; i++)
577 633
                    {
578
                        if (!(lp1.Vertices[i] == lp2.Vertices[i]))
634
                        if (lp1.Vertices[i].DistanceTo(lp2.Vertices[i]) > Verification.Tolerance)
579 635
                            return false;
580 636
                    }
581 637
                    return true;
582 638
                }
583 639
            }
584 640

  
585
            else if (ent1 is GPlanarEntity)
641
            else if (ent1 is GPlanarEntity pe1 && ent2 is GPlanarEntity pe2)
586 642
            {
587
                GPlanarEntity pe1 = (GPlanarEntity)ent1;
588
                GPlanarEntity pe2 = (GPlanarEntity)ent2;
589 643
                if (
590 644
                    pe1.Plane.AxisZ == pe2.Plane.AxisZ &&
591 645
                    pe1.Plane.AxisX == pe2.Plane.AxisX
592 646
                    )
593 647
                {
594
                    if (ent1 is GArc)
648
                    if (ent1 is GArc arc1 && ent2 is GArc arc2)
595 649
                    {
596
                        GArc arc1 = (GArc)ent1;
597
                        GArc arc2 = (GArc)ent2;
598

  
599 650
                        if (
600
                            arc1.Center == arc2.Center &&
601
                            arc1.Radius == arc2.Radius &&
602
                            arc1.Domain.Min == arc2.Domain.Min &&
603
                            arc1.Domain.Max == arc2.Domain.Max
651
                            arc1.Center.DistanceTo(arc2.Center) <= Verification.Tolerance &&
652
                            Math.Abs(arc1.Radius - arc2.Radius) <= Verification.Tolerance &&
653
                            Math.Abs(arc1.Domain.Min - arc2.Domain.Min) <= Verification.Tolerance &&
654
                            Math.Abs(arc1.Domain.Max - arc2.Domain.Max) <= Verification.Tolerance
604 655
                            )
605 656
                        {
606 657
                            return true;
607 658
                        }
608 659
                    }
609
                    else if (ent1 is GCircle)
660
                    else if (ent1 is GCircle c1 && ent2 is GCircle c2)
610 661
                    {
611
                        GCircle c1 = (GCircle)ent1;
612
                        GCircle c2 = (GCircle)ent2;
613

  
614
                        if ( c1.Center == c2.Center && c1.Radius == c2.Radius )
662
                        if (c1.Center.DistanceTo(c2.Center) <= Verification.Tolerance && 
663
                            Math.Abs(c1.Radius - c2.Radius) <= Verification.Tolerance)
615 664
                        {
616 665
                            return true;
617 666
                        }
618 667
                    }
619
                    else if (ent1 is GEllipticalArc)
668
                    else if (ent1 is GEllipticalArc e1 && ent2 is GEllipticalArc e2)
620 669
                    {
621
                        GEllipticalArc e1 = (GEllipticalArc)ent1;
622
                        GEllipticalArc e2 = (GEllipticalArc)ent2;
623

  
624 670
                        if (
625
                            e1.Center == e2.Center &&
626
                            e1.RadiusX == e2.RadiusX &&
627
                            e1.RadiusY == e2.RadiusY &&
628
                            e1.Domain.Low == e2.Domain.Low &&
629
                            e1.Domain.High == e2.Domain.High
671
                            e1.Center.DistanceTo(e2.Center) <= Verification.Tolerance &&
672
                            Math.Abs(e1.RadiusX - e2.RadiusX) <= Verification.Tolerance &&
673
                            Math.Abs(e1.RadiusY - e2.RadiusY) <= Verification.Tolerance &&
674
                            Math.Abs(e1.Domain.Low - e2.Domain.Low) <= Verification.Tolerance &&
675
                            Math.Abs(e1.Domain.High - e2.Domain.High) <= Verification.Tolerance
630 676
                        )
631 677
                        {
632 678
                            return true;
633 679
                        }
634 680
                    }
635
                    else if (ent1 is GEllipse)
681
                    else if (ent1 is GEllipse el1 && ent2 is GEllipse el2)
636 682
                    {
637
                        GEllipse e1 = (GEllipse)ent1;
638
                        GEllipse e2 = (GEllipse)ent2;
639

  
640 683
                        if (
641
                            e1.Center == e2.Center &&
642
                            e1.RadiusX == e2.RadiusX &&
643
                            e1.RadiusY == e2.RadiusY
684
                            el1.Center.DistanceTo(el2.Center) <= Verification.Tolerance &&
685
                            Math.Abs(el1.RadiusX - el2.RadiusX) <= Verification.Tolerance &&
686
                            Math.Abs(el1.RadiusY - el2.RadiusY) <= Verification.Tolerance
644 687
                        )
645 688
                        {
646 689
                            return true;
......
654 697
                }
655 698
            }
656 699

  
657
            else if (ent1 is GLine)
700
            else if (ent1 is GLine line1 && ent2 is GLine line2)
658 701
            {
659
                GLine line1 = (GLine)ent1;
660
                GLine line2 = (GLine)ent2;
661

  
662
                if ( line1.StartPoint == line2.StartPoint && line1.EndPoint == line2.EndPoint
702
                if (line1.StartPoint.DistanceTo(line2.StartPoint) <= Verification.Tolerance && 
703
                    line1.EndPoint.DistanceTo(line2.EndPoint) <= Verification.Tolerance
663 704
                )
664 705
                {
665 706
                    return true;

내보내기 Unified diff

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