我正在为我的机器人编写用于 2D 导航的路径跟踪应用程序,路径包含在 DWG 文件中。例如,假设 DWG 文件包含一个 2x2 平方米的正方形。
我想打开 DWG 文件,找出线条并获取一些坐标用作我的机器人的航点。
目前,找到一种从 DWG 文件中读取坐标的方法对我来说是完美的。我看到有一些允许处理 DWG 文件的开源库,例如libredwg或libDWG,但我不明白它们是否可以用于我的目的。
你能帮我吗?
编辑:我发现libopencad可用于我的应用程序,我测试了示例应用程序,它输出如下内容:
Layers count: 1
1. Layer 0 contains 8 geometries
|---------Line---------|
Start Position: 62.5852 -36.5942 0
End Position: -62.5852 -36.5942 0
Entity color: #ffffffff
|---------Line---------|
Start Position: 62.5852 -36.5942 0
End Position: 62.5852 36.5942 0
Entity color: #ffffffff
|---------Line---------|
Start Position: 62.5852 36.5942 0
End Position: -62.5852 36.5942 0
Entity color: #ffffffff
|---------Line---------|
Start Position: -62.5852 -36.5942 0
End Position: -62.5852 36.5942 0
Entity color: #ffffffff
|---------Line---------|
Start Position: 62.5852 -76.4212 0
End Position: -62.5852 -76.4212 0
Entity color: #ffffffff
|---------Line---------|
Start Position: 62.5852 -76.4212 0
End Position: 62.5852 -61.4214 0
Entity color: #ffffffff
|---------Line---------|
Start Position: 62.5852 -61.4214 0
End Position: -62.5852 -61.4214 0
Entity color: #ffffffff
|---------Line---------|
Start Position: -62.5852 -76.4212 0
End Position: -62.5852 -61.4214 0
Entity color: #ffffffff
对于包含两个正方形的示例 DWG 文件:
问题是:如何将第一个矩形的坐标与第二个矩形分开?