- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试创建一个包含以下 header 的二进制 PLY 文件:
ply
format binary_little_endian 1.0
element vertex 43000
property float x
property float y
property float z
property float nx
property float ny
property float nz
property uchar red
property uchar green
property uchar blue
end_header
我有以下重载函数可以写成二进制(用另一个例子验证):
inline void write_fbin(std::ofstream &out, float val) {
out.write(reinterpret_cast<char*>(&val), sizeof(float));
}
inline void write_fbin(std::ofstream &out, unsigned char val) {
out.write(reinterpret_cast<char*>(&val), sizeof(unsigned char));
}
我写的顶点信息如下:
write_fbin(ofstr, static_cast<float>(point.x));
write_fbin(ofstr, static_cast<float>(point.y));
write_fbin(ofstr, static_cast<float>(point.z));
write_fbin(ofstr, static_cast<float>(point.n_x));
write_fbin(ofstr, static_cast<float>(point.n_y));
write_fbin(ofstr, static_cast<float>(point.n_z));
write_fbin(ofstr, static_cast<unsigned char>(point.r));
write_fbin(ofstr, static_cast<unsigned char>(point.g));
write_fbin(ofstr, static_cast<unsigned char>(point.b));
point
是类型的结构
struct DensePoint {
float x, y, z;
float n_x, n_y, n_z;
unsigned char r, g, b;
};
这不起作用并生成无效的层文件。但是,如果我使用相同的代码(更改 header )来生成 ASCII 版本,
ofstr
<< point.x << ' '
<< point.y << ' '
<< point.z << ' '
<< point.n_x << ' '
<< point.n_y << ' '
<< point.n_z << ' '
<< static_cast<int>(point.r) << ' '
<< static_cast<int>(point.g) << ' '
<< static_cast<int>(point.b) <<
'\n';
这非常有效。有什么问题吗?
也许我需要在二进制格式的每个顶点末尾引入一个换行符?
最佳答案
当将二进制数据写入/读取似乎与预期格式不匹配的文件时,可能是操作系统级别的字符转换将某些字节组合替换为其他字节组合(es 0x0C 变为 0x0C 0x0A ).
您很可能以文本模式(C++ 流的默认设置)打开文件,而该文件本应是二进制文件,以使操作系统行为保持中立。
关于c++如何以二进制格式输出ply文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27906681/
在 ms sql 2008 中编写一些存储过程时,当我输入一些变量名称时,我注意到 PLI 被突出显示为关键字。 有谁知道 PLI 的用途是什么? 最佳答案 您可以在 MSDN 上查看此类信息: 请参
我想使用 plyr 的并行功能函数内封装。 我原以为导出在函数体内创建的对象的正确方法(在本例中,对象是 df_2 )如下 # rm(list=ls()) library(plyr) library(
我是 3D 重建的新手,我有点云。我把它写在 .ply 文件上。但是当我按下它文件时 Meshlab 为我提供了一个 Error 。请找到以下内容,meshlab 可以允许打开该文件 Unespec
我正在使用一个简单的 .txt 文件测试层,其中包含:value = 0.4。解析器按预期工作,但是当我向该文件添加第二行时,出现错误: 错误:解析“LexToken(VALUE_KEY,'value
全部, 我正在用 python PLY 编写一个非常简单的解析器。它大部分完成了这项工作,但对于许多输入行,我从yacc收到语法错误。这是词法分析器和解析器代码,稍作修改以方便测试: tokens =
有没有办法对层词法分析器规则进行特殊处理? t_IDENT = r'[a-zA-Z_][0-9a-zA-Z_]*' t_OPERATOR = r'[<>=/*+-]+' t_DEFINE
我正在 python 中使用 PLY 构建解析器,当我运行解析器时,它会创建 3 个文件:parsetab.py、lextam.py 和 parse.out 如何才能不创建这些文件?有一个参数可以做到
我试图四处寻找这个问题的答案,但似乎找不到。我正在尝试使用 PLY 在 Python 中编写一个解析器作为一种编造的语言。我的 BNF 的简化版本如下所示: statement-list -> sta
我正在使用 Python 和 PLY 来解析类似 LISP 的 S 表达式,并且在解析函数调用时可以有零个或多个参数。我怎样才能将它放入 yacc 代码中。到目前为止,这是我的功能: def p_EX
所以我在 Ply 上编写了一个语法来识别基本的 C 语句,例如变量声明或 while 语句。现在,我想要做的是能够连接所有标记,然后打印它或让它在树上传播,如下所示: def p_whileStm
我正在尝试创建一个将我的脚本作为输入的解释器。我在编写正则表达式时遇到了一些问题。定义的标记之一是将所有字符串视为标记。 import ply.lex as lex import ply.yacc a
我想使用Python的PLY分析大量文本,其大小可能达到 1GB。 是否可以让 PLY 读取文本并将其解析为流,这样我就不必将整个内容加载到内存中?我想逐行检查文本,并让 PLY 对其进行分析。那可能
我正在尝试使用PLY lex / yacc解析PDF,而我却遇到了有关yacc解析规则的问题,该规则控制NUMBER标记,数组和indirect_references。 相关资料来源: def p_v
简而言之,我们如何区分使用了哪个规则 - 例子:- ''' p : a b | c | d '''所以假设我们需要为不同的规则编写不同的代码。那么有什么优雅的方法可以做到这一点。手册中给出的一种方法是
我在 PLY 中使用一个相当简单的解析器,我的规则之一采用以下形式: def p_things(p): ''' things : thing things things : t
我正在尝试构建一个 .PLY 解析器,以将存储为 .ply 文件的 3d 模型加载到半边数据结构网格中。 抱歉问了这么大的问题,我很冗长,我想确保我列出了所有的细节。因此,我将立即重申我的最终目标,以
我正在进入 .ply 文件的世界。我已经阅读了一些关于它们的内容,但是关于它们的格式的文档似乎与我的文件中的内容不太一致。我一直在尝试理解这篇文章 here,但我运气不佳。 这是我的 .ply 文件的
出于某种目的,我需要读取带有嵌入纹理的 PLY 文件(斯坦福三角格式)。我看到了 PLY 文件的几个规范,但找不到指定纹理映射语法的单个来源。似乎有很多库可以读取 PLY 文件,但大多数库似乎不支持纹
我使用 ply 作为我的 lex 解析器。我的规范如下: t_WHILE = r'while' t_THEN = r'then' t_ID = r'[a-zA-Z_][a-zA-Z0-9_]*'
我使用 ply 解析数据.我尝试使用空格作为词素的一部分。这里有一个简化的例子: from ply.lex import lex from ply.yacc import yacc tokens =
我是一名优秀的程序员,十分优秀!