개정판 63a112d9
dev issue #507 : remove flowdirection
Change-Id: Ib9f08abadd2d4bf0e090f594c85835f625be0617
DTI_PID/SPPIDConverter/AutoModeling.cs | ||
---|---|---|
107 | 107 |
RunJoinRunForSameConnector(); |
108 | 108 |
// Join Run |
109 | 109 |
RunJoinRun(); |
110 |
// Check FlowDirection |
|
111 |
RunFlowDirection(); |
|
110 |
//// Check FlowDirection
|
|
111 |
//RunFlowDirection();
|
|
112 | 112 |
// EndBreak Modeling |
113 | 113 |
RunEndBreakModeling(); |
114 | 114 |
// SpecBreak Modeling |
... | ... | |
2319 | 2319 |
LineNumberModelingOnlyOne(groupLine); |
2320 | 2320 |
|
2321 | 2321 |
ReleaseCOMObjects(_lMConnector); |
2322 |
|
|
2323 |
LMModelItem modelItem = dataSource.GetModelItem(groupLine.SPPID.ModelItemId); |
|
2324 |
if (modelItem != null) |
|
2325 |
{ |
|
2326 |
LMAAttribute attribute = modelItem.Attributes["FlowDirection"]; |
|
2327 |
attribute.set_Value("End 1 is upstream (Inlet)"); |
|
2328 |
modelItem.Commit(); |
|
2329 |
} |
|
2330 |
ReleaseCOMObjects(modelItem); |
|
2331 |
modelItem = null; |
|
2322 | 2332 |
} |
2323 | 2333 |
else if (!isBranchModeling) |
2324 | 2334 |
{ |
... | ... | |
3343 | 3353 |
try |
3344 | 3354 |
{ |
3345 | 3355 |
LMModelItem modelItem1 = dataSource.GetModelItem(modelId1); |
3356 |
LMConnector connector1 = GetLMConnectorFirst(modelId1); |
|
3357 |
List<double[]> vertices1 = null; |
|
3358 |
string graphicOID1 = string.Empty; |
|
3359 |
if (connector1 != null) |
|
3360 |
{ |
|
3361 |
vertices1 = GetConnectorVertices(connector1); |
|
3362 |
graphicOID1 = connector1.get_GraphicOID(); |
|
3363 |
} |
|
3346 | 3364 |
_LMAItem item1 = modelItem1.AsLMAItem(); |
3365 |
ReleaseCOMObjects(connector1); |
|
3366 |
connector1 = null; |
|
3367 |
|
|
3347 | 3368 |
LMModelItem modelItem2 = dataSource.GetModelItem(modelId2); |
3369 |
LMConnector connector2 = GetLMConnectorFirst(modelId2); |
|
3370 |
List<double[]> vertices2 = null; |
|
3371 |
string graphicOID2 = string.Empty; |
|
3372 |
if (connector2 != null) |
|
3373 |
{ |
|
3374 |
vertices2 = GetConnectorVertices(connector2); |
|
3375 |
graphicOID2 = connector2.get_GraphicOID(); |
|
3376 |
} |
|
3348 | 3377 |
_LMAItem item2 = modelItem2.AsLMAItem(); |
3378 |
ReleaseCOMObjects(connector2); |
|
3379 |
connector2 = null; |
|
3349 | 3380 |
|
3350 | 3381 |
// item2가 item1으로 조인 |
3351 | 3382 |
_placement.PIDJoinRuns(ref item1, ref item2); |
... | ... | |
3360 | 3391 |
beforeID = modelItem2.Id; |
3361 | 3392 |
afterID = modelItem1.Id; |
3362 | 3393 |
survivorId = afterID; |
3363 |
LMAAttribute attribute = modelItem1.Attributes["FlowDirection"]; |
|
3364 |
if (attribute != null) |
|
3365 |
attribute.set_Value("End 1 is upstream (Inlet)"); |
|
3394 |
//LMAAttribute attribute = modelItem1.Attributes["FlowDirection"]; |
|
3395 |
|
|
3396 |
//if (!IsSameConnector) |
|
3397 |
//{ |
|
3398 |
// if (!string.IsNullOrEmpty(graphicOID1)) |
|
3399 |
// { |
|
3400 |
// List<double[]> survivorVertices = GetConnectorVertices(graphicOID1); |
|
3401 |
// if (vertices1[0][0] == survivorVertices[0][0] && vertices1[0][1] == survivorVertices[0][1]) |
|
3402 |
// { |
|
3403 |
|
|
3404 |
// } |
|
3405 |
// else if (vertices1[0][0] == survivorVertices[survivorVertices.Count - 1][0] && vertices1[0][1] == survivorVertices[survivorVertices.Count - 1][1]) |
|
3406 |
// { |
|
3407 |
// if (attribute != null && DBNull.Value.Equals(attribute.get_Value())) |
|
3408 |
// attribute.set_Value("End 1 is upstream (Inlet)"); |
|
3409 |
// else if (attribute != null && attribute.get_Value() == "End 1 is upstream (Inlet)") |
|
3410 |
// attribute.set_Value("End 1 is downstream (Outlet)"); |
|
3411 |
// else if (attribute != null && attribute.get_Value() == "End 1 is downstream (Outlet)") |
|
3412 |
// attribute.set_Value("End 1 is upstream (Inlet)"); |
|
3413 |
// } |
|
3414 |
// } |
|
3415 |
// else if (!string.IsNullOrEmpty(graphicOID2)) |
|
3416 |
// { |
|
3417 |
// List<double[]> survivorVertices = GetConnectorVertices(graphicOID2); |
|
3418 |
// if (vertices2[0][0] == survivorVertices[0][0] && vertices2[0][1] == survivorVertices[0][1]) |
|
3419 |
// { |
|
3420 |
|
|
3421 |
// } |
|
3422 |
// else if (vertices2[0][0] == survivorVertices[survivorVertices.Count - 1][0] && vertices2[0][1] == survivorVertices[survivorVertices.Count - 1][1]) |
|
3423 |
// { |
|
3424 |
// if (attribute != null && DBNull.Value.Equals(attribute.get_Value())) |
|
3425 |
// attribute.set_Value("End 1 is upstream (Inlet)"); |
|
3426 |
// else if (attribute != null && attribute.get_Value() == "End 1 is upstream (Inlet)") |
|
3427 |
// attribute.set_Value("End 1 is downstream (Outlet)"); |
|
3428 |
// else if (attribute != null && attribute.get_Value() == "End 1 is downstream (Outlet)") |
|
3429 |
// attribute.set_Value("End 1 is upstream (Inlet)"); |
|
3430 |
// } |
|
3431 |
// } |
|
3432 |
//} |
|
3433 |
//else |
|
3434 |
//{ |
|
3435 |
// if (attribute != null) |
|
3436 |
// attribute.set_Value("End 1 is upstream (Inlet)"); |
|
3437 |
//} |
|
3366 | 3438 |
} |
3367 | 3439 |
else if (modelItem1.get_ItemStatus() != "Active" && modelItem2.get_ItemStatus() == "Active") |
3368 | 3440 |
{ |
3369 | 3441 |
beforeID = modelItem1.Id; |
3370 | 3442 |
afterID = modelItem2.Id; |
3371 | 3443 |
survivorId = afterID; |
3372 |
LMAAttribute attribute = modelItem2.Attributes["FlowDirection"]; |
|
3373 |
if (attribute != null) |
|
3374 |
attribute.set_Value("End 1 is upstream (Inlet)"); |
|
3444 |
//LMAAttribute attribute = modelItem2.Attributes["FlowDirection"]; |
|
3445 |
|
|
3446 |
//if (!IsSameConnector) |
|
3447 |
//{ |
|
3448 |
// if (!string.IsNullOrEmpty(graphicOID2)) |
|
3449 |
// { |
|
3450 |
// List<double[]> survivorVertices = GetConnectorVertices(graphicOID2); |
|
3451 |
// if (vertices2[0][0] == survivorVertices[0][0] && vertices2[0][1] == survivorVertices[0][1]) |
|
3452 |
// { |
|
3453 |
|
|
3454 |
// } |
|
3455 |
// else if (vertices2[0][0] == survivorVertices[survivorVertices.Count - 1][0] && vertices2[0][1] == survivorVertices[survivorVertices.Count - 1][1]) |
|
3456 |
// { |
|
3457 |
// if (attribute != null && DBNull.Value.Equals(attribute.get_Value())) |
|
3458 |
// attribute.set_Value("End 1 is upstream (Inlet)"); |
|
3459 |
// else if (attribute != null && attribute.get_Value() == "End 1 is upstream (Inlet)") |
|
3460 |
// attribute.set_Value("End 1 is downstream (Outlet)"); |
|
3461 |
// else if (attribute != null && attribute.get_Value() == "End 1 is downstream (Outlet)") |
|
3462 |
// attribute.set_Value("End 1 is upstream (Inlet)"); |
|
3463 |
// } |
|
3464 |
// } |
|
3465 |
// else if (!string.IsNullOrEmpty(graphicOID1)) |
|
3466 |
// { |
|
3467 |
// List<double[]> survivorVertices = GetConnectorVertices(graphicOID1); |
|
3468 |
// if (vertices1[0][0] == survivorVertices[0][0] && vertices1[0][1] == survivorVertices[0][1]) |
|
3469 |
// { |
|
3470 |
|
|
3471 |
// } |
|
3472 |
// else if (vertices1[0][0] == survivorVertices[survivorVertices.Count - 1][0] && vertices1[0][1] == survivorVertices[survivorVertices.Count - 1][1]) |
|
3473 |
// { |
|
3474 |
// if (attribute != null && DBNull.Value.Equals(attribute.get_Value())) |
|
3475 |
// attribute.set_Value("End 1 is upstream (Inlet)"); |
|
3476 |
// else if (attribute != null && attribute.get_Value() == "End 1 is upstream (Inlet)") |
|
3477 |
// attribute.set_Value("End 1 is downstream (Outlet)"); |
|
3478 |
// else if (attribute != null && attribute.get_Value() == "End 1 is downstream (Outlet)") |
|
3479 |
// attribute.set_Value("End 1 is upstream (Inlet)"); |
|
3480 |
// } |
|
3481 |
// } |
|
3482 |
//} |
|
3483 |
//else |
|
3484 |
//{ |
|
3485 |
// if (attribute != null) |
|
3486 |
// attribute.set_Value("End 1 is upstream (Inlet)"); |
|
3487 |
//} |
|
3375 | 3488 |
} |
3376 | 3489 |
else if (modelItem1.get_ItemStatus() == "Active" && modelItem2.get_ItemStatus() == "Active") |
3377 | 3490 |
{ |
... | ... | |
3382 | 3495 |
beforeID = modelItem1.Id; |
3383 | 3496 |
afterID = modelItem2.Id; |
3384 | 3497 |
survivorId = afterID; |
3385 |
LMAAttribute attribute = modelItem2.Attributes["FlowDirection"]; |
|
3386 |
if (attribute != null) |
|
3387 |
attribute.set_Value("End 1 is upstream (Inlet)"); |
|
3498 |
//LMAAttribute attribute = modelItem2.Attributes["FlowDirection"];
|
|
3499 |
//if (attribute != null)
|
|
3500 |
// attribute.set_Value("End 1 is upstream (Inlet)");
|
|
3388 | 3501 |
} |
3389 | 3502 |
else if (model2Cnt == 0) |
3390 | 3503 |
{ |
3391 | 3504 |
beforeID = modelItem2.Id; |
3392 | 3505 |
afterID = modelItem1.Id; |
3393 | 3506 |
survivorId = afterID; |
3394 |
LMAAttribute attribute = modelItem1.Attributes["FlowDirection"]; |
|
3395 |
if (attribute != null) |
|
3396 |
attribute.set_Value("End 1 is upstream (Inlet)"); |
|
3507 |
//LMAAttribute attribute = modelItem1.Attributes["FlowDirection"];
|
|
3508 |
//if (attribute != null)
|
|
3509 |
// attribute.set_Value("End 1 is upstream (Inlet)");
|
|
3397 | 3510 |
} |
3398 | 3511 |
else |
3399 | 3512 |
survivorId = null; |
... | ... | |
3419 | 3532 |
catch (Exception ex) |
3420 | 3533 |
{ |
3421 | 3534 |
Log.Write("Join Error"); |
3422 |
Log.Write(ex.Message); |
|
3535 |
Log.Write(ex.Message + "\r\n" + ex.StackTrace);
|
|
3423 | 3536 |
} |
3424 | 3537 |
} |
3425 | 3538 |
|
... | ... | |
3584 | 3697 |
return vertices; |
3585 | 3698 |
} |
3586 | 3699 |
|
3700 |
private List<double[]> GetConnectorVertices(dynamic graphicOID) |
|
3701 |
{ |
|
3702 |
List<double[]> vertices = null; |
|
3703 |
DependencyObject drawingObject = radApp.ActiveDocument.ActiveSheet.DrawingObjects[graphicOID]; |
|
3704 |
if (drawingObject != null) |
|
3705 |
{ |
|
3706 |
vertices = new List<double[]>(); |
|
3707 |
Ingr.RAD2D.LineStringGeometry2d lineStringGeometry = drawingObject.GetGeometry() as Ingr.RAD2D.LineStringGeometry2d; |
|
3708 |
int verticesCount = lineStringGeometry.VertexCount; |
|
3709 |
double[] value = null; |
|
3710 |
lineStringGeometry.GetVertices(ref verticesCount, ref value); |
|
3711 |
for (int i = 0; i < verticesCount; i++) |
|
3712 |
{ |
|
3713 |
double x = 0; |
|
3714 |
double y = 0; |
|
3715 |
lineStringGeometry.GetVertex(i + 1, ref x, ref y); |
|
3716 |
vertices.Add(new double[] { x, y }); |
|
3717 |
} |
|
3718 |
} |
|
3719 |
return vertices; |
|
3720 |
} |
|
3587 | 3721 |
/// <summary> |
3588 | 3722 |
/// 좌표로 PipeRun의 Connector중에 어느 Connector에 가까운지/붙을지 가져오는 메서드 - 조건에 안맞아서 못찾을시 제일 가까운 점으로 가져오는 방식 |
3589 | 3723 |
/// </summary> |
... | ... | |
3937 | 4071 |
return result; |
3938 | 4072 |
} |
3939 | 4073 |
|
4074 |
private LMConnector GetLMConnectorFirst(string modelItemID) |
|
4075 |
{ |
|
4076 |
LMConnector result = null; |
|
4077 |
LMModelItem modelItem = dataSource.GetModelItem(modelItemID); |
|
4078 |
|
|
4079 |
if (modelItem != null) |
|
4080 |
{ |
|
4081 |
foreach (LMRepresentation rep in modelItem.Representations) |
|
4082 |
{ |
|
4083 |
if (rep.Attributes["RepresentationType"].get_Value() == "Connector" && |
|
4084 |
rep.Attributes["ItemStatus"].get_Value() == "Active") |
|
4085 |
{ |
|
4086 |
LMConnector connector = dataSource.GetConnector(rep.Id); |
|
4087 |
if (!Convert.ToBoolean(connector.get_IsZeroLength())) |
|
4088 |
{ |
|
4089 |
result = connector; |
|
4090 |
break; |
|
4091 |
} |
|
4092 |
else |
|
4093 |
{ |
|
4094 |
ReleaseCOMObjects(connector); |
|
4095 |
connector = null; |
|
4096 |
} |
|
4097 |
} |
|
4098 |
} |
|
4099 |
ReleaseCOMObjects(modelItem); |
|
4100 |
modelItem = null; |
|
4101 |
} |
|
4102 |
|
|
4103 |
return result; |
|
4104 |
} |
|
4105 |
|
|
3940 | 4106 |
private int GetConnectorCount(string modelItemID) |
3941 | 4107 |
{ |
3942 | 4108 |
LMModelItem modelItem = dataSource.GetModelItem(modelItemID); |
... | ... | |
5290 | 5456 |
if (modelItemIds.Count == 1) |
5291 | 5457 |
{ |
5292 | 5458 |
string joinModelItemId = modelItemIds[0]; |
5293 |
JoinRun(joinModelItemId, modelItemId, ref survivorId); |
|
5459 |
JoinRun(joinModelItemId, modelItemId, ref survivorId, false);
|
|
5294 | 5460 |
if (survivorId != null) |
5295 | 5461 |
break; |
5296 | 5462 |
} |
... | ... | |
5302 | 5468 |
if (modelItemIds.Count == 1) |
5303 | 5469 |
{ |
5304 | 5470 |
string joinModelItemId = modelItemIds[0]; |
5305 |
JoinRun(joinModelItemId, modelItemId, ref survivorId); |
|
5471 |
JoinRun(joinModelItemId, modelItemId, ref survivorId, false);
|
|
5306 | 5472 |
if (survivorId != null) |
5307 | 5473 |
break; |
5308 | 5474 |
} |
내보내기 Unified diff