::clear()
1030 | {
1031 | this->vertices.clear();
1032 | this->edges.clear();
1033 | this->faces.clear();
1034 | this->unhandledTriangles.clear();
1035 | this->unhandledTrianglesCount = 0;
1036 | }
1037 |
1038 | #endif//DCEL_Mesh_h
1039 |
--------------------------------------------------------------------------------
/source/rply/manual/manual.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
7 |
8 | RPly: ANSI C library for PLY file format input and output
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
30 |
31 |
32 |
33 |
34 | Introduction
35 |
36 | RPly is a library that lets applications read and write PLY files. The
37 | PLY file format is widely used to store geometric information, such as 3D
38 | models, but is general enough to be useful for other purposes.
39 |
40 |
41 | There are other libraries out there, of course. I tried using them and
42 | finally decided to write my own. I tried to write it in such a way that
43 | others won't have to do it again and again. Everything that made me unhappy
44 | about the existing libraries was eliminated from RPly.
45 |
46 | RPly is easy to use, well documented, small, free,
47 | open-source, ANSI C, efficient, and well tested. I will keep supporting it
48 | for a while because all my tools use the library for input/output. The highlights are:
49 |
50 | - A callback mechanism that makes PLY file input straightforward;
51 |
- Support for the full range of numeric formats though the user only
52 | deals with doubles;
53 |
- Binary (big and little endian) and text modes are fully supported;
54 |
- Input and output are buffered for efficiency;
55 |
- Available under the
56 | MIT license
57 | for added freedom.
58 |
59 |
60 |
61 | The format was developed at Stanford University
63 | for use with their 3D scanning projects. Greg Turk's PLY library, available
64 | from
65 | Georgia Institute of Technology, seems to be the standard reference
66 | to the PLY file format, although there are some variations out there.
67 |
68 |
69 | Whatever documentation and examples were found, were taken into
70 | consideration to create RPly. In theory, since RPly doesn't try to interpret
71 | the meaning of the data in a PLY file, it should be able to read any PLY file.
72 | In practice, the library works with all PLY files that I could find.
73 |
74 | Download
75 |
76 |
77 | Version 1.01 of RPly is available for download in source
78 | code from this link. Examples and documentation
79 | are packed inside the tar ball. Have fun!
80 |
81 |
82 |
83 | Copyright © 2003-2005 Diego Nehab. All rights reserved.
84 | Author: Diego Nehab
85 |
86 |
87 | What's new?
88 |
89 |
90 | The change for version 1.01 is the use of our own buffering code when
91 | reading ASCII files. Speedup factor of 5 in Linux, almost no change in
92 | Windows.
93 |
94 |
95 | RPly's idea of what a PLY file is
96 |
97 | A PLY file contains the description of one object. This object is
98 | composed by elements, each element type
99 | being composed by a group of properties. The PLY file
100 | format specifies a syntax for the description of element types and the
101 | properties that compose them, as well as comments and meta-information.
102 |
103 |
104 | The element type descriptions come in a header, which is followed by
105 | element instances. Element instances come grouped by their type, in the
106 | order of declaration. Each element instance is defined by the value
107 | of its properties. Properties values also appear in the order of their
108 | declaration. Here is a sample PLY file describing a triangle:
109 |
110 |
111 | ply
112 | format ascii 1.0
113 | comment this is a simple file
114 | obj_info any data, in one line of free form text
115 | element vertex 3
116 | property float x
117 | property float y
118 | property float z
119 | element face 1
120 | property list uchar int vertex_indices
121 | end_header
122 | -1 0 0
123 | 0 1 0
124 | 1 0 0
125 | 3 0 1 2
126 |
127 |
128 | The header goes from the first line to the line marked by
129 | end_header. The first line contains only ply\n and is
130 | used to detect whether a file is in PLY format or not. The second line
131 | specifies the format number (which is always 1.0) and the
132 | storage mode (ascii, binary_big_endian or
133 | binary_little_endian).
134 |
135 | Lines that start with comment are just comments, of course.
136 | Lines that start with obj_info contain meta-information about the
137 | object. Comments and obj_infos are optional and their
138 | relative order in the header is irrelevant.
139 |
140 | In the sample PLY file, the first element type is declared with name
141 | vertex, and on the same line we learn that there will be 3
142 | instances of this element type. The properties following describe what a
143 | vertex element looks like. Each vertex is declared to
144 | consist of 3 scalar properties, named x, y and
145 | z. Each scalar property is declared to be of type float.
146 |
147 |
148 | Scalar types can be any of the following: int8,
149 | uint8, int16, uint16, int32,
150 | uint32, float32, float64, char,
151 | uchar, short, ushort, int,
152 | uint, float, double. They consist of signed
153 | and unsigned integer types of sizes 8, 16 and 32 bits, as well as floating
154 | point types of 32 and 64bits.
155 |
156 |
Next, the face element type is declared, of which only 1
157 | instance will be given. This element consists of a list property,
158 | named vertex_indices. Lists are sequences on which the
159 | first value, the length, gives the number of remaining values. List properties are described by the scalar
160 | type of their length field and the scalar type of the remaining fields.
161 | In the case of vertex_indices, the length field
162 | is of type uchar and the remaining values are of type
163 | int.
164 |
165 | Following the header, come the elements, in the order they were
166 | declared in the header. First come the 3 elements of type vertex,
167 | each represented by the value of their properties x, y
168 | and z. Then comes the single face element, composed by a
169 | single list of type vertex_indices containing 3 values
170 | (0 1 2).
171 |
172 | How to read a file with RPly
173 |
174 | Most users that want to read a PLY file already know which elements and
175 | properties they are interested at. In the following example, we will
176 | implement a simple program that dumps the contents of a PLY file to the
177 | terminal, in a different, simpler format that only works for triangles.
178 |
179 |
180 | This simple format has a header that gives the number of vertices in the
181 | first line and the number of triangles in the second line. Following the
182 | header come the vertices, and finally the triangles. Here is the sample
183 | code for the program:
184 |
185 |
186 | #include <stdio.h>
187 | #include "rply.h"
188 |
189 | static int vertex_cb(p_ply_argument argument) {
190 | long eol;
191 | ply_get_argument_user_data(argument, NULL, &eol);
192 | printf("%g", ply_get_argument_value(argument));
193 | if (eol) printf("\n");
194 | else printf(" ");
195 | return 1;
196 | }
197 |
198 | static int face_cb(p_ply_argument argument) {
199 | long length, value_index;
200 | ply_get_argument_property(argument, NULL, &length, &value_index);
201 | switch (value_index) {
202 | case 0:
203 | case 1:
204 | printf("%g ", ply_get_argument_value(argument));
205 | break;
206 | case 2:
207 | printf("%g\n", ply_get_argument_value(argument));
208 | break;
209 | default:
210 | break;
211 | }
212 | return 1;
213 | }
214 |
215 | int main(void) {
216 | long nvertices, ntriangles;
217 | p_ply ply = ply_open("input.ply", NULL);
218 | if (!ply) return 1;
219 | if (!ply_read_header(ply)) return 1;
220 | nvertices = ply_set_read_cb(ply, "vertex", "x", vertex_cb, NULL, 0);
221 | ply_set_read_cb(ply, "vertex", "y", vertex_cb, NULL, 0);
222 | ply_set_read_cb(ply, "vertex", "z", vertex_cb, NULL, 1);
223 | ntriangles = ply_set_read_cb(ply, "face", "vertex_indices", face_cb, NULL, 0);
224 | printf("%ld\n%ld\n", nvertices, ntriangles);
225 | if (!ply_read(ply)) return 1;
226 | ply_close(ply);
227 | return 0;
228 | }
229 |
230 |
231 | RPly uses callbacks to pass data to an application. Independent callbacks
232 | can be associated with each property of each element. For scalar
233 | properties, the callback is invoked once for each instance. For list
234 | properties, the callback is invoked first with the number of
235 | entries in the instance, and then once for each of the data entries.
236 | This is exactly the order in which the data items appear in the
237 | file.
238 |
239 | To keep things simple, values are always passed as double,
240 | regardless of how they are stored in the file. From its parameters,
241 | callbacks can find out exactly which part of the file is being processed
242 | (including the real type of the value), plus access custom information
243 | provided by the user in the form of a pointer and an integer constant.
244 |
245 | In our example, we start with a call to ply_open to open a
246 | file for reading. Then we get RPly to parse it's header, with a call to
247 | ply_read_header. After the header is parsed, RPly knows which
248 | element types and properties are available. We then set callbacks for each
249 | of the vertex element properties and the face property
250 | (using ply_set_read_cb). Finally, we invoke the main RPly reading
251 | function, ply_read. This function reads all data in the file,
252 | passing the data to the appropriate callbacks. After all reading is done,
253 | we call ply_close to release any resources used by RPly.
254 |
255 | There are some details, of course. Ply_set_read_cb returns the
256 | number of instances of the target property (which is the same as the number
257 | of element instances). This is how the program obtains the number of
258 | vertices and faces in the file.
259 |
260 | RPly lets us associate one pointer and one integer to each
261 | callback. We are free to use either or both to link some context to our
262 | callbacks. Our example uses the integer placeholder to tell
263 | vertex_cb that it has to break the line after the z
264 | property (notice the last argument of ply_set_read_cb).
265 |
266 | Vertex_cb gets the user data and the property value from it's
267 | argument and prints accordingly. The face_cb callback is a bit
268 | more complicated because lists are more complicated. Since the
269 | simple file format only supports triangles, it only prints the first
270 | 3 list values, after which it breaks the line.
271 |
272 | The output of the program, as expected, is:
273 |
274 |
275 | 3
276 | 1
277 | -1 0 0
278 | 0 1 0
279 | 1 0 0
280 | 0 1 2
281 |
282 |
283 | Writing files with RPly
284 |
285 | The next example is somewhat more involved. We will create a program
286 | that converts our simple PLY file to binary mode. Besides showing how to
287 | write a PLY file, this example also illustrates the query functions. We
288 | do not know a priori which elements and properties, comments and obj_infos
289 | will be in the input file, so we need a way to find out. Although our simple
290 | program would work on any PLY file, a better version of this program is
291 | available from the RPly distribution. For simplicity, the simple version
292 | omits error messages and command line parameter processing.
293 |
294 | In practice, writing a file is even easier than reading one. First we
295 | create a file in binary mode, with a call to ply_create (notice
296 | the argument PLY_LITTLE_ENDIAN that gives the storage mode). Then,
297 | we define the elements using ply_add_element. After each element, we
298 | define its properties using ply_add_scalar_property or
299 | ply_add_list_property. When we are done with elements and
300 | properties, we add comments and obj_infos. We then write the header with
301 | ply_write_header and send all data items. The data items are sent
302 | one by one, with calls to ply_write, in the same order they
303 | are to appear in the file. Again, to simplify things, this function
304 | receives data as double and performs the needed conversion. Here
305 | is the code for the example:
306 |
307 |
308 | #include <stdio.h>
309 | #include "rply.h"
310 |
311 | static int callback(p_ply_argument argument) {
312 | void *pdata;
313 | /* just pass the value from the input file to the output file */
314 | ply_get_argument_user_data(argument, &pdata, NULL);
315 | ply_write((p_ply) pdata, ply_get_argument_value(argument));
316 | return 1;
317 | }
318 |
319 | static int setup_callbacks(p_ply iply, p_ply oply) {
320 | p_ply_element element = NULL;
321 | /* iterate over all elements in input file */
322 | while ((element = ply_get_next_element(iply, element))) {
323 | p_ply_property property = NULL;
324 | long ninstances = 0;
325 | const char *element_name;
326 | ply_get_element_info(element, &element_name, &ninstances);
327 | /* add this element to output file */
328 | if (!ply_add_element(oply, element_name, ninstances)) return 0;
329 | /* iterate over all properties of current element */
330 | while ((property = ply_get_next_property(element, property))) {
331 | const char *property_name;
332 | e_ply_type type, length_type, value_type;
333 | ply_get_property_info(property, &property_name, &type,
334 | &length_type, &value_type);
335 | /* setup input callback for this property */
336 | if (!ply_set_read_cb(iply, element_name, property_name, callback,
337 | oply, 0)) return 0;
338 | /* add this property to output file */
339 | if (!ply_add_property(oply, property_name, type, length_type,
340 | value_type)) return 0;
341 | }
342 | }
343 | return 1;
344 | }
345 |
346 | int main(void) {
347 | const char *value;
348 | p_ply iply, oply;
349 | iply = ply_open("input.ply", NULL);
350 | if (!iply) return 1;
351 | if (!ply_read_header(iply)) return 1;
352 | oply = ply_create("output.ply", PLY_LITTLE_ENDIAN, NULL);
353 | if (!oply) return 1;
354 | if (!setup_callbacks(iply, oply)) return 1;
355 | /* pass comments and obj_infos from input to output */
356 | value = NULL;
357 | while ((value = ply_get_next_comment(iply, value)))
358 | if (!ply_add_comment(oply, value)) return 1;
359 | value = NULL;
360 | while ((value = ply_get_next_obj_info(iply, value)))
361 | if (!ply_add_obj_info(oply, value)) return 1;;
362 | /* write output header */
363 | if (!ply_write_header(oply)) return 1;
364 | /* read input file generating callbacks that pass data to output file */
365 | if (!ply_read(iply)) return 1;
366 | /* close up, we are done */
367 | if (!ply_close(iply)) return 1;
368 | if (!ply_close(oply)) return 1;
369 | return 0;
370 | }
371 |
372 |
373 | RPly uses iterators to let the user loop over a PLY file header. A
374 | function is used to get the first item of a given class (element, property
375 | etc). Passing the last returned item to the same function produces the next
376 | item, until there are no more items. Examples of iterator use can be seen
377 | in the main function, which uses them to loop over comments and
378 | obj_infos, and in the setup_callbacks function, which loops over
379 | elements and properties.
380 |
381 | In the setup_callbacks function, for each element in the
382 | input, an equivalent element is defined in the output. For each property in
383 | each element, an equivalent property is defined in the output. Notice that
384 | the same callback is specified for all properties. It is given the output
385 | PLY handle as the context pointer. Each time it is called, it passes the
386 | received value to ply_write on the output handle. It is as simple
387 | as that.
388 |
389 | Reference Manual
390 |
391 |
392 |
393 |
394 | p_ply ply_open(const char *name, p_ply_error_cb error_cb)
395 |
396 |
397 |
398 | Opens a PLY file for reading, checks if it is a valid PLY file
399 | and returns a handle to it.
400 |
401 |
402 |
403 | Name is the file name, and error_cb is a function to
404 | be called when an error is found.
405 | If error_cb is NULL, the default
406 | error callback is used. It prints a message to the standard error stream.
407 |
408 |
409 |
410 | Returns a handle to the file or NULL on error.
411 |
412 |
413 |
414 | Note: Error_cb is of type void
415 | (*p_ply_error_cb)(const char *message)
416 |
417 |
418 |
419 |
420 |
423 |
424 |
425 | Reads and parses the header of a PLY file.
426 | After a call to this function, the query functions
427 | ply_get_next_element,
428 | ply_get_next_property,
429 | ply_get_next_comment, and
430 | ply_get_next_obj_info can be
431 | called. Callbacks can also be set with the
432 | ply_set_read_cb function.
433 |
434 |
435 |
436 | Ply is a handle returned by ply_open.
437 |
438 |
439 |
440 | Returns 1 in case of success, 0 otherwise.
441 |
442 |
443 |
444 |
445 |
446 | long ply_set_read_cb(
447 | p_ply ply,
448 | const char *element_name,
449 | const char *property_name,
450 | p_ply_read_cb read_cb,
451 | void *pdata,
452 | long idata
453 | )
454 |
455 |
456 |
457 | Sets up the callback to be invoked when the value of a property is read.
458 |
459 |
460 |
461 | Ply is a handle returned by ply_open.
462 | Element_name and property_name are the names of the
463 | element and property of interest. Read_cb is the callback
464 | function. Pdata and idata are user data to be passed to
465 | the callback function.
466 |
467 |
468 |
469 | Returns the number of instances of the element of interest.
470 |
471 |
472 |
473 | Note: Read_cb is of type
474 | int (*p_ply_read_cb)(p_ply_argument argument).
475 | The callback should return 1 to continue the reading process,
476 | or return 0 to abort.
477 |
478 |
479 |
480 |
481 | int ply_get_argument_element(
482 | p_ply_argument argument,
483 | p_ply_element *element,
484 | long *instance_index
485 | )
486 |
487 |
488 |
489 | Retrieves element information from the callback argument.
490 |
491 |
492 |
493 | Argument is the handle passed to the callback.
494 | Element receives a handle to the element
495 | originating the callback. Instance_index receives
496 | the index of the instance of the element
497 | being read. Element and instance_index can be NULL.
498 |
499 |
500 |
501 | Returns 1 in case of success, 0 otherwise.
502 |
503 |
504 |
505 | Note: further information can be obtained from element with a
506 | call to ply_get_element_info.
507 |
508 |
509 |
510 |
511 |
512 | int ply_get_argument_property(
513 | p_ply_argument argument,
514 | p_ply_property *property,
515 | long *length,
516 | long *value_index
517 | )
518 |
519 |
520 |
521 | Retrieves property information from the callback argument.
522 |
523 |
524 |
525 | Argument is the handle passed to the callback.
526 | Property receives a handle to the property
527 | originating the callback. Length receives the number
528 | of values in the list property (1 for scalar properties).
529 | Value_index receives the index of the current property entry (0 for
530 | scalar properties, -1 for the first value of a list property, the one that
531 | gives the number of entries). Property, length and
532 | value_index can be NULL.
533 |
534 |
535 |
536 | Returns 1 in case of success, 0 otherwise.
537 |
538 |
539 |
540 | Note: further information can be obtained from property with a
541 | call to ply_get_property_info.
542 |
543 |
544 |
545 |
546 |
547 | int ply_get_argument_user_data(p_ply_argument argument, void *pdata,
548 | long *idata)
549 |
550 |
551 |
552 | Retrieves the user data from the callback argument.
553 |
554 |
555 |
556 | Argument is the handle passed to the callback.
557 | Pdata receives the user data pointer.
558 | Idata receives the user data integer.
559 | Pdata and idata can be NULL.
560 |
561 |
562 |
563 | Returns 1 in case of success, 0 otherwise.
564 |
565 |
566 |
567 |
568 |
569 | double ply_get_argument_value(p_ply_argument argument)
570 |
571 |
572 |
573 | Retrieves the property value from the callback argument.
574 |
575 |
576 |
577 | Argument is the handle passed to the callback.
578 |
579 |
580 |
581 | Returns the property value.
582 |
583 |
584 |
585 |
586 |
587 | int ply_read(p_ply ply)
588 |
589 |
590 |
591 | Reads all data in file, calling appropriate callbacks.
592 |
593 |
594 |
595 | Ply is a handle returned by ply_open.
596 |
597 |
598 |
599 | Returns 1 in case of success, 0 otherwise.
600 |
601 |
602 |
603 |
604 |
605 | p_ply_element ply_get_next_element(p_ply ply, p_ply_element last)
606 |
607 |
608 |
609 | Iterates over all elements on the header of a PLY file.
610 |
611 |
612 |
613 | Ply is a handle returned by ply_open.
614 | Ply_read_header must have been called
615 | on the handle otherwise no elements will be found.
616 | Last is NULL to retrieve the first element, and an element to
617 | retrieve the next element.
618 |
619 |
620 |
621 | Returns the next element, or NULL if no more elements.
622 |
623 |
624 |
625 | Note: further information can be obtained from an element with a
626 | call to ply_get_element_info.
627 |
628 |
629 |
630 |
631 |
632 | p_ply_property ply_get_next_property(p_ply_element element, p_ply_property last)
633 |
634 |
635 |
636 | Iterates over all properties of an element.
637 |
638 |
639 |
640 | Element is an element handle.
641 | Last is NULL to retrieve the first property, and a property to
642 | retrieve the next property.
643 |
644 |
645 |
646 | Returns the next property, or NULL if no more properties.
647 |
648 |
649 |
650 | Note: further information can be obtained from a property with a
651 | call to ply_get_property_info.
652 |
653 |
654 |
655 |
656 |
659 |
660 |
661 | Iterates over all comments on the header of a PLY file.
662 |
663 |
664 |
665 | Ply is a handle returned by ply_open.
666 | Ply_read_header must have been called
667 | on the handle otherwise no comments will be found.
668 | Last is NULL to retrieve the first comment, and a comment to
669 | retrieve the next comment.
670 |
671 |
672 |
673 | Returns the next comment, or NULL if no more comments.
674 |
675 |
676 |
677 |
678 |
679 | const char *ply_get_next_obj_info(p_ply ply, const char *last)
680 |
681 |
682 |
683 | Iterates over all obj_infos on the header of a PLY file.
684 |
685 |
686 |
687 | Ply is a handle returned by ply_open.
688 | Ply_read_header must have been called
689 | on the handle otherwise no obj_infos will be found.
690 | Last is NULL to retrieve the first obj_info, and a obj_info to
691 | retrieve the next obj_info.
692 |
693 |
694 |
695 | Returns the next obj_info, or NULL if no more obj_infos.
696 |
697 |
698 |
699 |
700 |
701 | int ply_get_element_info(p_ply_element element, const char** name,
702 | long *ninstances)
703 |
704 |
705 |
706 | Retrieves information from an element handle.
707 |
708 |
709 |
710 | Element is the handle of the element of interest.
711 | Name receives the internal copy of the element name.
712 | Ninstances receives the number of instances of this element
713 | in the file. Both name and ninstances can be NULL.
714 |
715 |
716 |
717 | Returns 1 in case of success, 0 otherwise.
718 |
719 |
720 |
721 |
722 |
723 | int ply_get_property_info(
724 | p_ply_property property,
725 | const char** name,
726 | e_ply_type *type,
727 | e_ply_type *length_type,
728 | e_ply_type *value_type
729 | )
730 |
731 |
732 |
733 | Retrieves information from a property handle.
734 |
735 |
736 |
737 | Property is the handle of the property of interest.
738 | Name receives the internal copy of the property name.
739 | Type receives the property type.
740 | Length_type receives the scalar type of the first entry
741 | in a list property (the one that gives the number of entries).
742 | Value_type receives the scalar type of the remaining list entries.
743 | Name, type, length_type, and
744 | value_type can be NULL.
745 |
746 |
747 |
748 | Returns 1 in case of success, 0 otherwise.
749 |
750 |
751 |
752 | Note: Length_type and value_type can
753 | receive any of the constants for scalar types defined in
754 | e_ply_type. Type can, in addition, be PLY_LIST,
755 | in which case the property is a list property and the fields
756 | length_type and value_type become meaningful.
757 |
758 |
759 |
760 |
761 |
762 | p_ply ply_create(const char *name, e_ply_storage_mode storage_mode,
763 | p_ply_error_cb error_cb)
764 |
765 |
766 |
767 | Creates a PLY file for writing.
768 |
769 |
770 |
771 | Name is the file name, storage_mode is the file storage mode
772 | (PLY_ASCII, PLY_LITTLE_ENDIAN or PLY_BIG_ENDIAN). Error_cb is a function to be called when an error is found.
773 | If error_cb is NULL, the default
774 | error callback is used. It prints a message to the standard error stream.
775 |
776 |
777 |
778 | Returns a handle to the file or NULL on error.
779 |
780 |
781 |
782 | Note: Error_cb is of type void
783 | (*p_ply_error_cb)(const char *message)
784 |
785 |
786 |
787 |
788 |
789 | int ply_add_element(p_ply ply, const char *name, long ninstances)
790 |
791 |
792 |
793 | Adds a new element to the ply file.
794 |
795 |
796 |
797 | Ply is a handle returned by
798 | ply_create, name is the element
799 | name and ninstances is the number of instances of this element that
800 | will be written to the file.
801 |
802 |
803 |
804 | Returns 1 in case of success, 0 otherwise.
805 |
806 |
807 |
808 |
809 |
810 | int ply_add_property(
811 | p_ply ply,
812 | const char *name,
813 | e_ply_type type,
814 | e_ply_type length_type,
815 | e_ply_type value_type
816 | )
817 |
818 |
819 |
820 | Adds a new property to the last element added to the ply file.
821 |
822 |
823 |
824 | Ply is a handle returned by
825 | ply_create and name is the
826 | property name.
827 | Type is the property type.
828 | Length_type is the scalar type of the first entry
829 | in a list property (the one that gives the number of entries).
830 | Value_type is the scalar type of the remaining list entries.
831 | If type is not PLY_LIST, length_type and
832 | value_type are ignored.
833 |
834 |
835 |
836 | Returns 1 in case of success, 0 otherwise.
837 |
838 |
839 |
840 | Note: Length_type and value_type can
841 | be any of the constants for scalar types defined in
842 | e_ply_type. Type can, in addition, be PLY_LIST,
843 | in which case the property is a list property and the fields
844 | length_type and value_type become meaningful.
845 |
846 |
847 |
848 |
849 |
850 | int ply_add_list_property(
851 | p_ply ply,
852 | const char *name,
853 | e_ply_type length_type,
854 | e_ply_type value_type
855 | )
856 |
857 |
858 |
859 | Same as ply_add_property if
860 | type is PLY_LIST.
861 |
862 |
863 |
864 |
865 |
866 | int ply_add_scalar_property(p_ply ply, const char *name, e_ply_type type)
867 |
868 |
869 |
870 | Same as ply_add_property if
871 | type is not PLY_LIST.
872 |
873 |
874 |
875 |
876 |
879 |
880 |
881 | Adds a comment to a PLY file.
882 |
883 |
884 |
885 | Ply is a handle returned by
886 | ply_create and comment is the
887 | comment text.
888 |
889 |
890 |
891 | Returns 1 in case of success, 0 otherwise.
892 |
893 |
894 |
895 |
896 |
897 | int ply_add_obj_info(p_ply ply, const char *obj_info);
898 |
899 |
900 |
901 | Adds a obj_info to a PLY file.
902 |
903 |
904 |
905 | Ply is a handle returned by
906 | ply_create and obj_info is the
907 | obj_info text.
908 |
909 |
910 |
911 | Returns 1 in case of success, 0 otherwise.
912 |
913 |
914 |
915 |
916 |
919 |
920 |
921 | Writes the PLY file header to disk, after all elements, properties,
922 | comments and obj_infos have been added to the handle.
923 |
924 |
925 |
926 | Ply is a handle returned by
927 | ply_create and comment is the
928 | comment text.
929 |
930 |
931 |
932 | Returns 1 in case of success, 0 otherwise.
933 |
934 |
935 |
936 |
937 |
938 | int ply_write(p_ply ply, double value);
939 |
940 |
941 |
942 | Passes a value to be stored in the PLY file.
943 | Values must be passed in the order they will appear in the file.
944 |
945 |
946 |
947 | Ply is a handle returned by
948 | ply_create and value is the
949 | value to be stored. For simplicity, values are always passed as
950 | double and conversion is performed as needed.
951 |
952 |
953 |
954 | Returns 1 in case of success, 0 otherwise.
955 |
956 |
957 |
958 |
959 |
960 | int ply_close(p_ply ply);
961 |
962 |
963 |
964 | Closes the handle and ensures that all resources have been freed and data
965 | have been written.
966 |
967 |
968 |
969 | Ply is a handle returned by
970 | ply_create or by
971 | ply_open.
972 |
973 |
974 |
975 | Returns 1 in case of success, 0 otherwise.
976 |
977 |
978 |
979 |
980 |
991 |
992 |
993 |
994 |
--------------------------------------------------------------------------------