1차 완료
This commit is contained in:
@@ -107,6 +107,14 @@ namespace DwgExtractorManual.Models
|
||||
/// DWG <20><><EFBFBD>Ͽ<EFBFBD><CFBF><EFBFBD> <20>ؽ<EFBFBD>Ʈ <20><>ƼƼ<C6BC><C6BC><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ͽ<EFBFBD> Height <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>Բ<EFBFBD> <20><>ȯ<EFBFBD>մϴ<D5B4>.
|
||||
/// </summary>
|
||||
public List<TextEntityInfo> ExtractTextEntitiesWithHeight(string filePath)
|
||||
{
|
||||
return ExtractTextEntitiesWithHeightExcluding(filePath, new HashSet<ObjectId>());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DWG 파일에서 텍스트 엔터티들을 추출하되, 지정된 ObjectId들은 제외합니다.
|
||||
/// </summary>
|
||||
public List<TextEntityInfo> ExtractTextEntitiesWithHeightExcluding(string filePath, HashSet<ObjectId> excludeIds)
|
||||
{
|
||||
var attRefEntities = new List<TextEntityInfo>();
|
||||
var otherTextEntities = new List<TextEntityInfo>();
|
||||
@@ -137,15 +145,19 @@ namespace DwgExtractorManual.Models
|
||||
{
|
||||
if (attRef != null)
|
||||
{
|
||||
var textString = attRef.TextString == null ? "" : attRef.TextString;
|
||||
attRefEntities.Add(new TextEntityInfo
|
||||
// 일반 텍스트 추출시 height 3 이하 제외
|
||||
if (attRef.Height > 3)
|
||||
{
|
||||
Height = attRef.Height,
|
||||
Type = "AttRef",
|
||||
Layer = layerName,
|
||||
Tag = attRef.Tag,
|
||||
Text = textString,
|
||||
});
|
||||
var textString = attRef.TextString == null ? "" : attRef.TextString;
|
||||
attRefEntities.Add(new TextEntityInfo
|
||||
{
|
||||
Height = attRef.Height,
|
||||
Type = "AttRef",
|
||||
Layer = layerName,
|
||||
Tag = attRef.Tag,
|
||||
Text = textString,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -153,26 +165,42 @@ namespace DwgExtractorManual.Models
|
||||
// DBText ó<><C3B3>
|
||||
else if (ent is DBText dbText)
|
||||
{
|
||||
otherTextEntities.Add(new TextEntityInfo
|
||||
// <20>Ϲ<EFBFBD> <20>ؽ<EFBFBD>Ʈ <20><><EFBFBD><EFBFBD><EFBFBD> height 3 <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
// Note에서 사용된 텍스트 제외
|
||||
if (!excludeIds.Contains(entId))
|
||||
{
|
||||
Height = dbText.Height,
|
||||
Type = "DBText",
|
||||
Layer = layerName,
|
||||
Tag = "",
|
||||
Text = dbText.TextString
|
||||
});
|
||||
if (dbText.Height > 3)
|
||||
{
|
||||
otherTextEntities.Add(new TextEntityInfo
|
||||
{
|
||||
Height = dbText.Height,
|
||||
Type = "DBText",
|
||||
Layer = layerName,
|
||||
Tag = "",
|
||||
Text = dbText.TextString
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
// MText ó<><C3B3>
|
||||
else if (ent is MText mText)
|
||||
{
|
||||
otherTextEntities.Add(new TextEntityInfo
|
||||
// <20>Ϲ<EFBFBD> <20>ؽ<EFBFBD>Ʈ <20><><EFBFBD><EFBFBD><EFBFBD> height 3 <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
// Note에서 사용된 텍스트 제외
|
||||
if (!excludeIds.Contains(entId))
|
||||
{
|
||||
Height = mText.Height,
|
||||
Type = "MText",
|
||||
Layer = layerName,
|
||||
Tag = "",
|
||||
Text = mText.Contents
|
||||
});
|
||||
if (mText.Height > 3)
|
||||
{
|
||||
otherTextEntities.Add(new TextEntityInfo
|
||||
{
|
||||
Height = mText.Height,
|
||||
Type = "MText",
|
||||
Layer = layerName,
|
||||
Tag = "",
|
||||
Text = mText.Contents
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -404,6 +432,9 @@ namespace DwgExtractorManual.Models
|
||||
Debug.WriteLine($"[DEBUG] Skipping null noteText for ObjectId: {noteTextId}");
|
||||
continue;
|
||||
}
|
||||
|
||||
// Note 헤더 텍스트를 사용된 텍스트 ID에 추가
|
||||
result.UsedTextIds.Add(noteTextId);
|
||||
// 특정 노트만 테스트하기 위한 필터 (디버깅용)
|
||||
// if (noteText == null || !noteText.TextString.Contains("도로용지경계 기준 노트"))
|
||||
// {
|
||||
@@ -460,6 +491,12 @@ namespace DwgExtractorManual.Models
|
||||
// 테이블 외부의 일반 텍스트들을 좌표별로 정렬하여 그룹에 추가
|
||||
var sortedNonTableTexts = GetSortedNoteContents(tran, nonTableTextIds, database);
|
||||
currentNoteGroup.AddRange(sortedNonTableTexts);
|
||||
|
||||
// 박스 내부 텍스트들을 사용된 텍스트 ID에 추가
|
||||
foreach (var textId in nonTableTextIds)
|
||||
{
|
||||
result.UsedTextIds.Add(textId);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -509,6 +546,7 @@ namespace DwgExtractorManual.Models
|
||||
}
|
||||
|
||||
Debug.WriteLine($"[DEBUG] 최종 Note 엔티티 정렬 완료: {noteEntities.Count}개");
|
||||
Debug.WriteLine($"[DEBUG] Note에서 사용된 텍스트 ID 개수: {result.UsedTextIds.Count}개");
|
||||
|
||||
result.NoteEntities = noteEntities;
|
||||
result.IntersectionPoints = LastIntersectionPoints.Select(ip => new IntersectionPoint { Position = ip.Position, DirectionBits = ip.DirectionBits, Row = ip.Row, Column = ip.Column }).ToList();
|
||||
@@ -2146,7 +2184,7 @@ namespace DwgExtractorManual.Models
|
||||
|
||||
foreach (var cellBoundary in cellBoundaries)
|
||||
{
|
||||
var textsInCell = new List<string>();
|
||||
var textsInCell = new List<(string text, double y)>();
|
||||
|
||||
foreach (var textId in allTextIds)
|
||||
{
|
||||
@@ -2177,14 +2215,15 @@ namespace DwgExtractorManual.Models
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(textContent))
|
||||
{
|
||||
textsInCell.Add(textContent.Trim());
|
||||
Debug.WriteLine($"[CELL_TEXT] ✅ {cellBoundary.Label}에 텍스트 추가: '{textContent.Trim()}'");
|
||||
textsInCell.Add((textContent.Trim(), textPosition.Y));
|
||||
Debug.WriteLine($"[CELL_TEXT] ✅ {cellBoundary.Label}에 텍스트 추가: '{textContent.Trim()}' at Y={textPosition.Y:F1}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 셀 경계에 찾은 텍스트들을 콤마로 연결하여 저장
|
||||
cellBoundary.CellText = string.Join(", ", textsInCell);
|
||||
// Y값이 큰 것부터 정렬 (위에서 아래로)하여 콤마로 연결
|
||||
var sortedTexts = textsInCell.OrderByDescending(t => t.y).Select(t => t.text);
|
||||
cellBoundary.CellText = string.Join(", ", sortedTexts);
|
||||
Debug.WriteLine($"[CELL_TEXT] {cellBoundary.Label} 최종 텍스트: '{cellBoundary.CellText}'");
|
||||
}
|
||||
|
||||
@@ -2731,7 +2770,7 @@ namespace DwgExtractorManual.Models
|
||||
|
||||
foreach (var cell in cells)
|
||||
{
|
||||
var textsInCell = new List<string>();
|
||||
var textsInCell = new List<(string text, double y)>();
|
||||
foreach (var textId in textIds)
|
||||
{
|
||||
if (assignedIds.Contains(textId)) continue;
|
||||
@@ -2743,16 +2782,19 @@ namespace DwgExtractorManual.Models
|
||||
// Check if the text's alignment point is inside the cell
|
||||
if (IsPointInCell(dbText.Position, cell))
|
||||
{
|
||||
textsInCell.Add(dbText.TextString);
|
||||
cell.CellText = string.Join("\n", textsInCell);
|
||||
textsInCell.Add((dbText.TextString, dbText.Position.Y));
|
||||
assignedIds.Add(textId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(textsInCell.Any())
|
||||
|
||||
// Y값이 큰 것부터 정렬 (위에서 아래로)하여 텍스트 설정
|
||||
if (textsInCell.Any())
|
||||
{
|
||||
assignedTexts[cell] = textsInCell;
|
||||
var sortedTexts = textsInCell.OrderByDescending(t => t.y).Select(t => t.text);
|
||||
cell.CellText = string.Join("\n", sortedTexts);
|
||||
assignedTexts[cell] = textsInCell.Select(t => t.text).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2824,6 +2866,7 @@ namespace DwgExtractorManual.Models
|
||||
public List<IntersectionPoint> IntersectionPoints { get; set; } = new List<IntersectionPoint>();
|
||||
public List<(Teigha.Geometry.Point3d topLeft, Teigha.Geometry.Point3d bottomRight, string label)> DiagonalLines { get; set; } = new List<(Teigha.Geometry.Point3d, Teigha.Geometry.Point3d, string)>();
|
||||
public List<SegmentInfo> TableSegments { get; set; } = new List<SegmentInfo>();
|
||||
public HashSet<ObjectId> UsedTextIds { get; set; } = new HashSet<ObjectId>(); // Note에서 사용된 텍스트 ID들
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user