Blender V4.3
blender::io::ply Namespace Reference

Classes

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

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_F (PLYImportTest, PLYImportCube)
 
 TEST_F (PLYImportTest, PLYImportWireframeCube)
 
 TEST_F (PLYImportTest, PlyImportBinaryDataStartsWithLF)
 
 TEST_F (PLYImportTest, PLYImportBunny)
 
 TEST_F (PLYImportTest, PlyImportManySmallHoles)
 
 TEST_F (PLYImportTest, PlyImportColorNotFull)
 
 TEST_F (PLYImportTest, PlyImportCustomDataElements)
 
 TEST_F (PLYImportTest, PlyImportDoubleXYZ)
 
 TEST_F (PLYImportTest, PlyImportFaceIndicesNotFirstProp)
 
 TEST_F (PLYImportTest, PlyImportFaceIndicesPrecededByList)
 
 TEST_F (PLYImportTest, PlyImportFaceUVsColors)
 
 TEST_F (PLYImportTest, PlyImportFacesFirst)
 
 TEST_F (PLYImportTest, PlyImportFloatFormats)
 
 TEST_F (PLYImportTest, PlyImportPositionNotFull)
 
 TEST_F (PLYImportTest, PlyImportTristrips)
 
 TEST_F (PLYImportTest, PlyImportTypeAliases)
 
 TEST_F (PLYImportTest, PlyImportVertexCompOrder)
 

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()

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

◆ exporter_main()

◆ find_or_add_attribute()

static 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 >
static T blender::io::ply::get_binary_value ( PlyDataTypes type,
const uint8_t *& r_ptr )
static

◆ get_index()

static 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 640 of file ply_import_data.cc.

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

Referenced by blender::io::ply::PLYImportTest::import_and_check(), and read_ply_to_mesh().

◆ importer_main() [1/2]

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

Definition at line 209 of file ply_import.cc.

References 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()

static 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()

static 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 314 of file ply_export_load_plydata.cc.

References blender::Vector< T, InlineBufferCapacity, Allocator >::append(), blender::Vector< T, InlineBufferCapacity, Allocator >::append_n_times(), blender::Vector< T, InlineBufferCapacity, Allocator >::append_unchecked(), PLYExportParams::apply_modifiers, BASE_SELECTED, BKE_id_free(), BKE_mesh_wrapper_ensure_mdata(), BKE_object_get_evaluated_mesh(), BKE_object_get_pre_modified_mesh(), BLI_assert, blender::bke::LooseGeomCache::count, DEG_get_evaluated_object(), 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, PLYExportParams::forward_axis, generate_vertex_map(), PLYExportParams::global_scale, int, 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(), mul_m3_v3(), mul_m4_v3(), mul_v3_fl(), normalize_v3(), OB_MESH, PLY_VERTEX_COLOR_NONE, PLY_VERTEX_COLOR_SRGB, blender::bke::Point, pos, blender::Vector< T, InlineBufferCapacity, Allocator >::reserve(), set_world_axes_transform(), blender::Vector< T, InlineBufferCapacity, Allocator >::size(), size(), 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()

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

Definition at line 37 of file ply_import.cc.

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

Referenced by read_header().

◆ parse_row_ascii()

static const char * blender::io::ply::parse_row_ascii ( PlyReadBuffer & file,
Vector< float > & r_values )
static

◆ parse_row_binary()

◆ parse_word()

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

Definition at line 50 of file ply_import.cc.

References len, and str.

Referenced by read_header().

◆ read()

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

Definition at line 113 of file io_ply_exporter_test.cc.

Referenced by read_temp_file_in_vectorchar().

◆ read_header()

◆ read_list_count()

◆ read_ply_to_mesh()

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

◆ read_temp_file_in_string()

static 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()

static 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()

static 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()

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

Definition at line 619 of file ply_import_data.cc.

References ASCII, BINARY_BE, skip_property(), and blender::io::ply::PlyHeader::type.

Referenced by import_ply_data().

◆ skip_property()

◆ skip_space()

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

Definition at line 61 of file ply_import.cc.

References blender::Span< T >::drop_front(), and str.

Referenced by read_header().

◆ TEST_F() [1/31]

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

◆ TEST_F() [2/31]

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

◆ TEST_F() [3/31]

◆ TEST_F() [4/31]

◆ TEST_F() [5/31]

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

◆ TEST_F() [6/31]

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

◆ TEST_F() [7/31]

◆ TEST_F() [8/31]

◆ TEST_F() [9/31]

◆ TEST_F() [10/31]

◆ TEST_F() [11/31]

◆ TEST_F() [12/31]

◆ TEST_F() [13/31]

◆ TEST_F() [14/31]

◆ TEST_F() [15/31]

blender::io::ply::TEST_F ( PLYImportTest ,
PlyImportBinaryDataStartsWithLF  )

Definition at line 116 of file io_ply_importer_test.cc.

◆ TEST_F() [16/31]

blender::io::ply::TEST_F ( PLYImportTest ,
PLYImportBunny  )

Definition at line 123 of file io_ply_importer_test.cc.

◆ TEST_F() [17/31]

blender::io::ply::TEST_F ( PLYImportTest ,
PlyImportColorNotFull  )

Definition at line 152 of file io_ply_importer_test.cc.

◆ TEST_F() [18/31]

blender::io::ply::TEST_F ( PLYImportTest ,
PLYImportCube  )

Definition at line 93 of file io_ply_importer_test.cc.

◆ TEST_F() [19/31]

blender::io::ply::TEST_F ( PLYImportTest ,
PlyImportCustomDataElements  )

Definition at line 159 of file io_ply_importer_test.cc.

◆ TEST_F() [20/31]

blender::io::ply::TEST_F ( PLYImportTest ,
PlyImportDoubleXYZ  )

Definition at line 175 of file io_ply_importer_test.cc.

◆ TEST_F() [21/31]

blender::io::ply::TEST_F ( PLYImportTest ,
PlyImportFaceIndicesNotFirstProp  )

Definition at line 192 of file io_ply_importer_test.cc.

◆ TEST_F() [22/31]

blender::io::ply::TEST_F ( PLYImportTest ,
PlyImportFaceIndicesPrecededByList  )

Definition at line 199 of file io_ply_importer_test.cc.

◆ TEST_F() [23/31]

blender::io::ply::TEST_F ( PLYImportTest ,
PlyImportFacesFirst  )

Definition at line 213 of file io_ply_importer_test.cc.

◆ TEST_F() [24/31]

blender::io::ply::TEST_F ( PLYImportTest ,
PlyImportFaceUVsColors  )

Definition at line 206 of file io_ply_importer_test.cc.

◆ TEST_F() [25/31]

blender::io::ply::TEST_F ( PLYImportTest ,
PlyImportFloatFormats  )

Definition at line 230 of file io_ply_importer_test.cc.

◆ TEST_F() [26/31]

blender::io::ply::TEST_F ( PLYImportTest ,
PlyImportManySmallHoles  )

Definition at line 136 of file io_ply_importer_test.cc.

◆ TEST_F() [27/31]

blender::io::ply::TEST_F ( PLYImportTest ,
PlyImportPositionNotFull  )

Definition at line 247 of file io_ply_importer_test.cc.

◆ TEST_F() [28/31]

blender::io::ply::TEST_F ( PLYImportTest ,
PlyImportTristrips  )

Definition at line 254 of file io_ply_importer_test.cc.

◆ TEST_F() [29/31]

blender::io::ply::TEST_F ( PLYImportTest ,
PlyImportTypeAliases  )

Definition at line 261 of file io_ply_importer_test.cc.

◆ TEST_F() [30/31]

blender::io::ply::TEST_F ( PLYImportTest ,
PlyImportVertexCompOrder  )

Definition at line 279 of file io_ply_importer_test.cc.

◆ TEST_F() [31/31]

blender::io::ply::TEST_F ( PLYImportTest ,
PLYImportWireframeCube  )

Definition at line 109 of file io_ply_importer_test.cc.

◆ type_from_string()

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

Definition at line 68 of file ply_import.cc.

References CHAR, blender::Span< T >::data(), DOUBLE, ELEM, FLOAT, 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}
draw_view in_light_buf[] float
#define UINT_MAX
Definition hash_md5.cc:44

Definition at line 102 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().