39 const size_t keyword_len = keyword.
size();
40 if (
str.size() < keyword_len) {
43 if (memcmp(
str.data(), keyword.
data(), keyword_len) != 0) {
46 str =
str.drop_front(keyword_len);
63 while (!
str.is_empty() &&
str[0] <=
' ') {
71 if (
ELEM(input,
"uchar",
"uint8")) {
74 if (
ELEM(input,
"char",
"int8")) {
77 if (
ELEM(input,
"ushort",
"uint16")) {
80 if (
ELEM(input,
"short",
"int16")) {
83 if (
ELEM(input,
"uint",
"uint32")) {
86 if (
ELEM(input,
"int",
"int32")) {
89 if (
ELEM(input,
"float",
"float32")) {
92 if (
ELEM(input,
"double",
"float64")) {
101 line = file.read_line();
102 if (
StringRef(line.data(), line.size()) !=
"ply") {
103 return "Invalid PLY header.";
107 line = file.read_line();
126 element.name = std::string(word.
data(), word.
size());
129 element.count = std::stoi(std::string(word.
data(), word.
size()));
143 property.name = std::string(word.
data(), word.
size());
144 r_header.
elements.last().properties.append(property);
149 else if (line.is_empty() || (line.first() >=
'0' && line.first() <=
'9') ||
153 return "No end_header.";
171 if (err !=
nullptr) {
172 fprintf(stderr,
"PLY Importer: %s: %s\n", ob_name, err);
179 if (data ==
nullptr) {
180 fprintf(stderr,
"PLY Importer: failed importing %s, unknown error\n", ob_name);
184 if (!data->error.empty()) {
185 fprintf(stderr,
"PLY Importer: failed importing %s: %s\n", ob_name, data->error.c_str());
189 if (data->vertices.is_empty()) {
190 fprintf(stderr,
"PLY Importer: file %s contains no vertices\n", ob_name);
230 if (mesh ==
nullptr) {
239 obj->
data = mesh_in_main;
250 global_scale /= scene->unit.scale_length;
252 float scale_vec[3] = {global_scale, global_scale, global_scale};
253 float obmat3x3[3][3];
255 float obmat4x4[4][4];
bool BKE_collection_object_add(Main *bmain, Collection *collection, Object *ob)
Scene * CTX_data_scene(const bContext *C)
Main * CTX_data_main(const bContext *C)
ViewLayer * CTX_data_view_layer(const bContext *C)
LayerCollection * BKE_layer_collection_get_active(ViewLayer *view_layer)
void BKE_view_layer_synced_ensure(const Scene *scene, ViewLayer *view_layer)
void BKE_view_layer_base_deselect_all(const Scene *scene, ViewLayer *view_layer)
Base * BKE_view_layer_base_find(ViewLayer *view_layer, Object *ob)
void BKE_view_layer_base_select_and_set_active(ViewLayer *view_layer, Base *selbase)
void BKE_mesh_nomain_to_mesh(Mesh *mesh_src, Mesh *mesh_dst, Object *ob)
Mesh * BKE_mesh_add(Main *bmain, const char *name)
General operations, lookup, etc. for blender objects.
void BKE_object_apply_mat4(Object *ob, const float mat[4][4], bool use_compat, bool use_parent)
Object * BKE_object_add_only_object(Main *bmain, int type, const char *name) ATTR_RETURNS_NONNULL
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_report(ReportList *reports, eReportType type, const char *message)
void unit_m3(float m[3][3])
void unit_m4(float m[4][4])
void copy_m4_m3(float m1[4][4], const float m2[3][3])
void rescale_m4(float mat[4][4], const float scale[3])
bool mat3_from_axis_conversion(int src_forward, int src_up, int dst_forward, int dst_up, float r_mat[3][3])
bool bool BLI_path_extension_strip(char *path) ATTR_NONNULL(1)
void void void const char * BLI_path_basename(const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
#define STRNCPY(dst, src)
void DEG_id_tag_update(ID *id, unsigned int flags)
void DEG_id_tag_update_ex(Main *bmain, ID *id, unsigned int flags)
void DEG_relations_tag_update(Main *bmain)
Object groups, one object can be in many groups at once.
Object is a sort of wrapper for general info.
ATTR_WARN_UNUSED_RESULT const void * element
constexpr Span drop_front(int64_t n) const
constexpr const T * data() const
constexpr int64_t size() const
constexpr int64_t size() const
constexpr const char * data() const
static PlyDataTypes type_from_string(Span< char > word)
static void skip_space(Span< char > &str)
void importer_main(bContext *C, const PLYImportParams &import_params)
std::unique_ptr< PlyData > import_ply_data(PlyReadBuffer &file, PlyHeader &header)
static Mesh * read_ply_to_mesh(const PLYImportParams &import_params, const char *ob_name)
static Span< char > parse_word(Span< char > &str)
static bool parse_keyword(Span< char > &str, StringRef keyword)
Mesh * convert_ply_to_mesh(PlyData &data, const PLYImportParams ¶ms)
const char * read_header(PlyReadBuffer &file, PlyHeader &r_header)
Mesh * import_mesh(const PLYImportParams &import_params)
struct Collection * collection