Blender V5.0
blender::io::ply Namespace Reference

Classes

struct  uv_vertex_key
class  FileBuffer
class  FileBufferAscii
class  FileBufferBinary
class  PlyReadBuffer
struct  PlyCustomAttribute
struct  PlyData
struct  PlyProperty
struct  PlyElement
struct  PlyHeader
class  PLYExportTest
class  PLYExportPLYDataTest

Enumerations

enum  PlyDataTypes {
  NONE , CHAR , UCHAR , SHORT ,
  USHORT , INT , UINT , FLOAT ,
  DOUBLE , PLY_TYPE_COUNT
}
enum  PlyFormatType { ASCII , BINARY_LE , BINARY_BE }

Functions

void exporter_main (bContext *C, const PLYExportParams &export_params)
void write_vertices (FileBuffer &buffer, const PlyData &ply_data)
void write_faces (FileBuffer &buffer, const PlyData &ply_data)
void write_edges (FileBuffer &buffer, const PlyData &ply_data)
void write_header (FileBuffer &buffer, const PlyData &ply_data, const PLYExportParams &export_params)
static Meshdo_triangulation (const Mesh *mesh, bool force_triangulation)
static void set_world_axes_transform (const Object &object, const eIOAxis forward, const eIOAxis up, float r_world_and_axes_transform[4][4], float r_world_and_axes_normal_transform[3][3])
static void generate_vertex_map (const Mesh *mesh, const PLYExportParams &export_params, Vector< int > &r_ply_to_vertex, Vector< int > &r_vertex_to_ply, Vector< int > &r_loop_to_ply, Vector< float2 > &r_uvs)
static floatfind_or_add_attribute (const StringRef name, int64_t size, uint32_t vertex_offset, Vector< PlyCustomAttribute > &r_attributes)
static void load_custom_attributes (const Mesh *mesh, const Span< int > ply_to_vertex, uint32_t vertex_offset, Vector< PlyCustomAttribute > &r_attributes)
void load_plydata (PlyData &plyData, Depsgraph *depsgraph, const PLYExportParams &export_params)
static bool parse_keyword (Span< char > &str, StringRef keyword)
static Span< char > parse_word (Span< char > &str)
static void skip_space (Span< char > &str)
static PlyDataTypes type_from_string (Span< char > word)
const char * read_header (PlyReadBuffer &file, PlyHeader &r_header)
static Meshread_ply_to_mesh (const PLYImportParams &import_params, const char *ob_name)
Meshimport_mesh (const PLYImportParams &import_params)
void importer_main (bContext *C, const PLYImportParams &import_params)
void importer_main (Main *bmain, Scene *scene, ViewLayer *view_layer, const PLYImportParams &import_params)
static int get_index (const PlyElement &element, StringRef property)
static const char * parse_row_ascii (PlyReadBuffer &file, Vector< float > &r_values)
template<typename T>
static T get_binary_value (PlyDataTypes type, const uint8_t *&r_ptr)
static const char * parse_row_binary (PlyReadBuffer &file, const PlyHeader &header, const PlyElement &element, Vector< uint8_t > &r_scratch, Vector< float > &r_values)
static const char * load_vertex_element (PlyReadBuffer &file, const PlyHeader &header, const PlyElement &element, PlyData *data)
static uint32_t read_list_count (PlyReadBuffer &file, const PlyProperty &prop, Vector< uint8_t > &scratch, bool big_endian)
static void skip_property (PlyReadBuffer &file, const PlyProperty &prop, Vector< uint8_t > &scratch, bool big_endian)
static const char * load_face_element (PlyReadBuffer &file, const PlyHeader &header, const PlyElement &element, PlyData *data)
static const char * load_tristrips_element (PlyReadBuffer &file, const PlyHeader &header, const PlyElement &element, PlyData *data)
static const char * load_edge_element (PlyReadBuffer &file, const PlyHeader &header, const PlyElement &element, PlyData *data)
static const char * skip_element (PlyReadBuffer &file, const PlyHeader &header, const PlyElement &element)
std::unique_ptr< PlyDataimport_ply_data (PlyReadBuffer &file, PlyHeader &header)
Meshconvert_ply_to_mesh (PlyData &data, const PLYImportParams &params)
static std::unique_ptr< PlyDataload_cube (PLYExportParams &params)
static std::string read_temp_file_in_string (const std::string &file_path)
static char read (std::ifstream &file)
static std::vector< char > read_temp_file_in_vectorchar (const std::string &file_path)
 TEST_F (PLYExportTest, WriteHeaderAscii)
 TEST_F (PLYExportTest, WriteHeaderBinary)
 TEST_F (PLYExportTest, WriteVerticesAscii)
 TEST_F (PLYExportTest, WriteVerticesBinary)
 TEST_F (PLYExportTest, WriteFacesAscii)
 TEST_F (PLYExportTest, WriteFacesBinary)
 TEST_F (PLYExportTest, WriteVertexNormalsAscii)
 TEST_F (PLYExportTest, WriteVertexNormalsBinary)
 TEST_F (PLYExportPLYDataTest, CubeLoadPLYData)
 TEST_F (PLYExportPLYDataTest, CubeLoadPLYDataUV)
 TEST_F (PLYExportPLYDataTest, CubeLooseEdgesLoadPLYData)
 TEST_F (PLYExportPLYDataTest, CubeLooseEdgesLoadPLYDataUV)
 TEST_F (PLYExportPLYDataTest, CubesVertexAttrs)
 TEST_F (PLYExportPLYDataTest, SuzanneLoadPLYDataUV)
 TEST (ply_import, BufferRefillTest)

Variables

static const int data_type_size [] = {0, 1, 1, 2, 2, 4, 4, 4, 8}
static const float data_type_normalizer []
const char *const temp_file_path = "output\xc4\x84\xd0\x96.ply"

Enumeration Type Documentation

◆ PlyDataTypes

Enumerator
NONE 
CHAR 
UCHAR 
SHORT 
USHORT 
INT 
UINT 
FLOAT 
DOUBLE 
PLY_TYPE_COUNT 

Definition at line 20 of file ply_data.hh.

◆ PlyFormatType

Enumerator
ASCII 
BINARY_LE 
BINARY_BE 

Definition at line 40 of file ply_data.hh.

Function Documentation

◆ convert_ply_to_mesh()

◆ do_triangulation()

Mesh * blender::io::ply::do_triangulation ( const Mesh * mesh,
bool force_triangulation )
static

◆ exporter_main()

◆ find_or_add_attribute()

float * blender::io::ply::find_or_add_attribute ( const StringRef name,
int64_t size,
uint32_t vertex_offset,
Vector< PlyCustomAttribute > & r_attributes )
static

◆ generate_vertex_map()

◆ get_binary_value()

template<typename T>
T blender::io::ply::get_binary_value ( PlyDataTypes type,
const uint8_t *& r_ptr )
static

◆ get_index()

int blender::io::ply::get_index ( const PlyElement & element,
StringRef property )
static

◆ import_mesh()

Mesh * blender::io::ply::import_mesh ( const PLYImportParams & import_params)

◆ import_ply_data()

std::unique_ptr< PlyData > blender::io::ply::import_ply_data ( PlyReadBuffer & file,
PlyHeader & header )

Loads the information from a PLY file to a PlyData data-structure.

Parameters
fileThe PLY file that was opened.
headerThe information in the PLY header.
Returns
The PlyData data-structure that can be used for conversion to a Mesh.

Definition at line 644 of file ply_import_data.cc.

References data, element, blender::io::ply::PlyHeader::elements, error(), load_edge_element(), load_face_element(), load_tristrips_element(), load_vertex_element(), and skip_element().

Referenced by read_ply_to_mesh(), and TEST().

◆ importer_main() [1/2]

void blender::io::ply::importer_main ( bContext * C,
const PLYImportParams & import_params )

Definition at line 211 of file ply_import.cc.

References C, CTX_data_main(), CTX_data_scene(), CTX_data_view_layer(), and importer_main().

Referenced by importer_main(), and PLY_import().

◆ importer_main() [2/2]

◆ load_cube()

std::unique_ptr< PlyData > blender::io::ply::load_cube ( PLYExportParams & params)
static

Definition at line 62 of file io_ply_exporter_test.cc.

References params.

Referenced by TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().

◆ load_custom_attributes()

◆ load_edge_element()

const char * blender::io::ply::load_edge_element ( PlyReadBuffer & file,
const PlyHeader & header,
const PlyElement & element,
PlyData * data )
static

◆ load_face_element()

◆ load_plydata()

void blender::io::ply::load_plydata ( PlyData & plyData,
Depsgraph * depsgraph,
const PLYExportParams & export_params )

Definition at line 326 of file ply_export_load_plydata.cc.

References Mesh::active_color_attribute, Vector< T, InlineBufferCapacity, Allocator >::append(), blender::Vector< T, InlineBufferCapacity, Allocator >::append_n_times(), Vector< T, InlineBufferCapacity, Allocator >::append_unchecked(), PLYExportParams::apply_modifiers, Geometry::attributes, BASE_SELECTED, BKE_id_free(), BKE_mesh_wrapper_ensure_mdata(), BKE_object_get_evaluated_mesh(), BKE_object_get_pre_modified_mesh(), BLI_assert, Mesh::corners_num, blender::bke::LooseGeomCache::count, blender::io::ply::PlyCustomAttribute::data, DEG_get_evaluated(), DEG_ITER_OBJECT_FLAG_DUPLI, DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY, DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET, DEG_ITER_OBJECT_FLAG_VISIBLE, DEG_OBJECT_ITER_BEGIN, DEG_OBJECT_ITER_END, DEGObjectIterSettings::depsgraph, depsgraph, do_triangulation(), blender::io::ply::PlyData::edges, PLYExportParams::export_attributes, PLYExportParams::export_normals, PLYExportParams::export_selected_objects, PLYExportParams::export_triangulated_mesh, blender::io::ply::PlyData::face_sizes, blender::io::ply::PlyData::face_vertices, faces, Mesh::faces_num, DEGObjectIterSettings::flags, PLYExportParams::forward_axis, generate_vertex_map(), PLYExportParams::global_scale, i, blender::VArrayCommon< T >::is_empty(), blender::Vector< T, InlineBufferCapacity, Allocator >::is_empty(), blender::bke::LooseGeomCache::is_loose_bits, linearrgb_to_srgb_v4(), load_custom_attributes(), blender::bke::AttributeAccessor::lookup_or_default(), mul_m3_v3(), mul_m4_v3(), mul_v3_fl(), name, None, normalize_v3(), OB_MESH, blender::bke::Point, pos, Vector< T, InlineBufferCapacity, Allocator >::reserve(), Vector< T, InlineBufferCapacity, Allocator >::resize(), set_world_axes_transform(), blender::IndexRange::size(), blender::Span< T >::size(), blender::Vector< T, InlineBufferCapacity, Allocator >::size(), size(), Vector< T, InlineBufferCapacity, Allocator >::size(), sRGB, PLYExportParams::up_axis, blender::io::ply::PlyData::uv_coordinates, blender::io::ply::PlyData::vertex_colors, PLYExportParams::vertex_colors, blender::io::ply::PlyData::vertex_custom_attr, blender::io::ply::PlyData::vertex_normals, and blender::io::ply::PlyData::vertices.

Referenced by exporter_main(), and blender::io::ply::PLYExportPLYDataTest::load_ply_data_from_blendfile().

◆ load_tristrips_element()

◆ load_vertex_element()

◆ parse_keyword()

bool blender::io::ply::parse_keyword ( Span< char > & str,
StringRef keyword )
static

Definition at line 39 of file ply_import.cc.

References blender::StringRefBase::data(), blender::StringRefBase::size(), and str.

Referenced by read_header().

◆ parse_row_ascii()

◆ parse_row_binary()

◆ parse_word()

Span< char > blender::io::ply::parse_word ( Span< char > & str)
static

Definition at line 52 of file ply_import.cc.

References len, and str.

Referenced by read_header().

◆ read()

char blender::io::ply::read ( std::ifstream & file)
static

Definition at line 113 of file io_ply_exporter_test.cc.

◆ read_header()

◆ read_list_count()

◆ read_ply_to_mesh()

Mesh * blender::io::ply::read_ply_to_mesh ( const PLYImportParams & import_params,
const char * ob_name )
static

◆ read_temp_file_in_string()

std::string blender::io::ply::read_temp_file_in_string ( const std::string & file_path)
static

Definition at line 101 of file io_ply_exporter_test.cc.

References BLI_file_read_text_as_mem(), and MEM_freeN().

Referenced by TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().

◆ read_temp_file_in_vectorchar()

std::vector< char > blender::io::ply::read_temp_file_in_vectorchar ( const std::string & file_path)
static

Definition at line 120 of file io_ply_exporter_test.cc.

References read.

Referenced by TEST_F(), TEST_F(), and TEST_F().

◆ set_world_axes_transform()

void blender::io::ply::set_world_axes_transform ( const Object & object,
const eIOAxis forward,
const eIOAxis up,
float r_world_and_axes_transform[4][4],
float r_world_and_axes_normal_transform[3][3] )
static

◆ skip_element()

const char * blender::io::ply::skip_element ( PlyReadBuffer & file,
const PlyHeader & header,
const PlyElement & element )
static

◆ skip_property()

◆ skip_space()

void blender::io::ply::skip_space ( Span< char > & str)
static

Definition at line 63 of file ply_import.cc.

References str.

Referenced by read_header().

◆ TEST()

blender::io::ply::TEST ( ply_import ,
BufferRefillTest  )

Definition at line 23 of file io_ply_importer_test.cc.

References CLOG_ERROR, import_ply_data(), LOG, read_header(), and SEP_STR.

◆ TEST_F() [1/14]

blender::io::ply::TEST_F ( PLYExportPLYDataTest ,
CubeLoadPLYData  )

◆ TEST_F() [2/14]

blender::io::ply::TEST_F ( PLYExportPLYDataTest ,
CubeLoadPLYDataUV  )

◆ TEST_F() [3/14]

◆ TEST_F() [4/14]

◆ TEST_F() [5/14]

blender::io::ply::TEST_F ( PLYExportPLYDataTest ,
CubesVertexAttrs  )

◆ TEST_F() [6/14]

blender::io::ply::TEST_F ( PLYExportPLYDataTest ,
SuzanneLoadPLYDataUV  )

◆ TEST_F() [7/14]

◆ TEST_F() [8/14]

◆ TEST_F() [9/14]

◆ TEST_F() [10/14]

◆ TEST_F() [11/14]

◆ TEST_F() [12/14]

◆ TEST_F() [13/14]

◆ TEST_F() [14/14]

◆ type_from_string()

PlyDataTypes blender::io::ply::type_from_string ( Span< char > word)
static

Definition at line 70 of file ply_import.cc.

References CHAR, blender::Span< T >::data(), DOUBLE, ELEM, FLOAT, input, INT, NONE, SHORT, blender::Span< T >::size(), UCHAR, UINT, and USHORT.

Referenced by read_header().

◆ write_edges()

void blender::io::ply::write_edges ( FileBuffer & buffer,
const PlyData & ply_data )

◆ write_faces()

◆ write_header()

◆ write_vertices()

Variable Documentation

◆ data_type_normalizer

const float blender::io::ply::data_type_normalizer[]
static
Initial value:
= {
1.0f, 127.0f, 255.0f, 32767.0f, 65535.0f, float(INT_MAX), float(UINT_MAX), 1.0f, 1.0f}
nullptr float
#define UINT_MAX
Definition hash_md5.cc:44

Definition at line 105 of file ply_import_data.cc.

Referenced by load_vertex_element().

◆ data_type_size

const int blender::io::ply::data_type_size[] = {0, 1, 1, 2, 2, 4, 4, 4, 8}
static

◆ temp_file_path

const char* const blender::io::ply::temp_file_path = "output\xc4\x84\xd0\x96.ply"

Definition at line 99 of file io_ply_exporter_test.cc.

Referenced by TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().