日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

LMD文件格式解析

發(fā)布時間:2024/3/24 编程问答 42 豆豆
生活随笔 收集整理的這篇文章主要介紹了 LMD文件格式解析 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

LMD格式是二進制保存方式,所以解析文件必須要分析文件內(nèi)容的結(jié)構(gòu)體,先看文件中定義的這些宏,然后我們再用二進制軟件打開文件,數(shù)里面的碼的位置是不是和描述的一致。

//-------------- 基本類型定義?---------------

#define LMD_BLOCK_END 0

#define LMD_BYTE ?????1 // + unsigned 8-bit value

#define LMD_SHORT ???2 // + signed 16bit integer

#define LMD_INT ??????3 // + signed 32 bit integer

#define LMD_LONG ?????4 // + signed 64bit Integer

#define LMD_FLOAT ????5 // + 32bit real

#define LMD_DOUBLE ???6 // + 64bit real

#define LMD_SSTRING ??7 // + 0-terminated single-byte string

#define LMD_DSTRING ??8 // + 0-terminated double-byte string

(unicode)

#define LMD_BINARY1 ??9 // + 1byte(=n) + (n/8)bytes; ?(n==no.of

bits,round up)

#define LMD_BINARY4 ??10 // + 4bytes(=n) + (n/8)bytes;

(n==no.of bits,round up)

//-------------- 擴展類型定義?---------------

#define LMD_TYPE_DEF 11 // + byte(=new-type) + int (=parameter_

size)

//-------------- 擴展類型?-------------------------

//- All commands from 12 to 127 are reserved for extended types

//- All extended types have a fixed length (command + param

eter_size)

//-------------- 預定義擴展類型 ---------------

#define LMD_MOVE ???????12 ?// + float(=x) + float(=y)

#define LMD_DRAW ???????13 ?// + float(=x) + float(=y)

#define LMD_CIRCLE ?????14 ?// + float(=x) + float(=y) + float

(=r; r>0 CCW)

future

#define LMD_DRILL ??????15 ?// + float(=x) + float(=y)

#define LMD_TOOL_SELECT 16 ?// + int(=iTool)

#define LMD_ARC ????????17 ?// + float(cx)+float(cy)+float(ex)

+float(ey)+float(r)

// draw arc 0..+-355 degree.

// If start and end points are the same,

// draw a 360 degree circle

// ********* 擴展型掃描頭 *********

// scanner head has its window (box), defined by points

// (-xmax,-ymax) and (xmax,ymax).

// Origin of the head is at (0,0)

// Position of the head is the point at which the origin (0,0)

is placed

#define LMD_HEAD_BOX ???18 ?// + float(=xmax) + float(=ymax)

#define LMD_HEAD_POS ???19 ?// + float(=x) + float(=y)

#define LMD_HEAD_NONE ??20 ?// head position undefined, do not

use head

// ??-------------- 預定義塊類型?-------------------

#define LMD_TOOL ????128

// ??+ LMD_INT iTool for use in LMD_TOOL_SELECT

// ??+ LMD_BYTE for mode: 0:draw, 1=flash 2=flash+draw

// ??+ LMD_FLOAT: width

// ??+ LMD_SSTRING: tool-name

#define LMD_PHASE_HEADER ??129

// ??+ LMD_SSTRING: phase-name

// ??+ LMD_SSTRING: layer-name

#define LMD_PHASE ???130

// ??+ LMD_PHASE_HEADER()

// ??+ LMD_TOOL ?{ LMD_TOOL }

// ??+ { LMD_TOOL_SELECT() { LMD_DRILL() | path }

// ??path ::= LMD_MOVE() { [LMD_CIRCLE()] LMD_DRAW() };

//Please note that this structure may change in future ver

sions.

2,查看了這些定義之后,我們大致可以分析出來,這個結(jié)構(gòu)體的雛形。

LMD_begin

????????Phase_Begin

????????????????Layer_Begin

????????????????????????TOOL_Select

????????????????????????HEAD_Box

????????????????????????HEAD_POS

????????????????????????LMD_MOVE

????????????????????????LMD_DRAW

????????????????????????LMD_ARC

????????????????????????。。。

????????Layer_End

????????Phase_End????????

????????....

LMD_End

3,我們需要用二進制查看軟件,打開LMD格式的文件,這樣方便我們驗證

?

1,首先,我們找到了 82 ,81 ,對應的是LMD_PHASELMD_PHASE_HEADER,然后后面接的一串字符串,

#define LMD_PHASE_HEADER ??129

// ??+ LMD_SSTRING: phase-name

// ??+ LMD_SSTRING: layer-name

明文中已經(jīng)解析出來為MillingTop,TopLayer

2,后面我們找到80,對應LMD_TOOL,

#define LMD_TOOL ????128

// ??+ LMD_INT iTool for use in LMD_TOOL_SELECT

// ??+ LMD_BYTE for mode: 0:draw, 1=flash 2=flash+draw

// ??+ LMD_FLOAT: width

// ??+ LMD_SSTRING: tool-name

Tool后面會跟一些參數(shù)。我們可以解析出來,但是最后LMD_SSTRING,這個是不固定的,所以必須解析到下一個特征,才能判斷這個參數(shù)是多長。

  • 我們找到Tool_select -->10(16進制,后面我們都會用16進制),后面跟著4個字節(jié),然后轉(zhuǎn)成int類型(01 00 00 00)
  • 然后找到12,對應的是LMD_HEAD_BOX,后面跟著兩個float,我們數(shù)8個字節(jié)
  • (C1,72,04,3c,34,12,21,3c),分別轉(zhuǎn)成float,對應XY坐標值

  • 然后找到13,對應LMD_HEAD_POS,也是一樣,讀取8個字節(jié),
  • 然后找到0c,對應LMC_MOVE,這里就是數(shù)據(jù)的開始了,表示跳轉(zhuǎn)到某個位置。讀出XY坐標
  • 然后到0d,對應LMD_DRAW,畫一條直線。
  • 接下來繼續(xù)找到0c,11(LMD_ARC),ARC對應的參數(shù)是20個字節(jié)
  • 然后找到11,又數(shù)20字節(jié),到了00(LMD_BLOCK_END)。

    ?

  • 然后又到了 82,81,又和之前步驟1的解析類似了,中間又到了數(shù)據(jù)層,然后提取數(shù)據(jù)。
  • 最后結(jié)尾是00。
  • 到此,我們基本能提取出LMD格式里的數(shù)據(jù)了。
  • 分析LMD文件需要請留郵箱地址。

    ?

    總結(jié)

    以上是生活随笔為你收集整理的LMD文件格式解析的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。