Write information into STL file
- 创建STL对象
- 读取文本格式的STL文件
- 水印的嵌入与提取
- 读取二进制格式的STL文件
- 文件损坏处理及还原
This file is used to test the correctness of 'server.py' and 'solidKit.py'.
Use RSA to protect the STL file which contains watermark.
There are three funtions in this script:
generate_key(bits=200, privateFile: str = None, publicFile: str = None)
rsa_long_encrypt(pub_key: str, msg: bytes, saveFile: str = None, length=200)
rsa_long_decrypt(priv_key: str, msg: bytes, saveFile: str = None, length=256)The file contains mostly useful functions about this project, at least in my part.
There are two classes: Facet and Solid in this file.
The former records information about Facets like vertexs and normal vector. In addition, there is also a funtion called 'serialize', which is used for generating information.
The latter contains the solid attributes like this
self.name: str # solid name
self.file: str # STL file name
self.Facets: list # all facets
self.facetsID: dict # 面索引映射
self.vertex: np.array # Vertex coordinates
self.eigvec: np.array # 3-D feature vectors
self.PCA_vertex: np.array # Vertex in PCA spaceDisplay the current stereo in a normal or PCA perspective.
Binary balance tree is a good way to embed information in files.
Giving reference sequences (ref) according to the arrangement of triangular polygons in PCA space.
Convert the ref to cipher sequence (ord).
Decrypts the Ord cipher sequence using the ref sequence.
The end may have an extra 0, which needs to be truncated. Ord is the none expression to extract the watermark.
Rearrange triangular faces and write files according to the Ord sequence.