BRL-CAD
obj_parser.cpp
Go to the documentation of this file.
1 /* O B J _ P A R S E R . C P P
2  * BRL-CAD
3  *
4  * Copyright (c) 2010-2014 United States Government as represented by
5  * the U.S. Army Research Laboratory.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License
9  * version 2.1 as published by the Free Software Foundation.
10  *
11  * This library is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this file; see the file named COPYING for more
18  * information.
19  */
20 /* This file implements the obj parser interface defined in obj_parser.h.
21  *
22  * Code that wants to use the interface should create a handle of type
23  * obj_parser_t and pass it to obj_parser_create() to initialize it.
24  *
25  * Parsing is done using the obj_parse() or obj_fparse() functions, which take
26  * an input, a parser handle, and an obj_contents_t to return the parsed file
27  * contents in. These functions are not thread-safe.
28  */
29 
30 #include "common.h"
31 #include "obj_parser.h"
32 #include "obj_parser_state.h"
33 
34 #include "obj_grammar_decls.h"
35 #include "obj_rules.h"
36 
37 #include <cerrno>
38 #include <cstdio>
39 #include <sstream>
40 #include <iostream>
41 
42 #include "bu/malloc.h"
43 #include "bu/log.h"
44 
45 extern int obj_parser_parse(yyscan_t);
46 
47 namespace cad {
48 namespace gcv {
49 namespace obj {
50 
51 
52 template<typename ObjContentsT>
53 static int set_stream(FILE *stream, basic_parser_state<ObjContentsT> &state)
54 {
55  typedef basic_parser_state<ObjContentsT> state_type;
56  typedef typename state_type::file_node file_node_type;
57  typedef typename state_type::string_type string_type;
58 
59  file_node_type node;
60  node.dir = ".";
61  node.lineno = 1;
62  node.file = stream;
63  state.file_stack.push_back(node);
64 
65  return 0;
66 }
67 
68 
69 template<typename ObjContentsT>
70 static int open_file(
73 {
74  typedef basic_parser_state<ObjContentsT> state_type;
75  typedef typename state_type::file_node file_node_type;
76  typedef typename state_type::string_type string_type;
77 
78  file_node_type node;
79  node.path = filename;
80  node.file = NULL;
81 
82  typename string_type::size_type loc = filename.find_last_of('/');
83 
84  if (loc == string_type::npos) {
85  node.dir = ".";
86  } else {
87  node.dir = filename.substr(0, loc);
88  }
89 
90  node.lineno = 1;
91 
92  FILE *file = fopen(filename.c_str(), "r");
93 
94  if (!file) {
95  return errno;
96  }
97 
98  node.file = file;
99  state.file_stack.push_back(node);
100 
101  return 0;
102 }
103 
104 
105 struct lex_sentry {
107 
108  ~lex_sentry(void) {
110  }
111 
113 };
114 
115 } /* namespace obj */
116 
118 
119 static void*
120 bu_malloc_wrapper(size_t size)
121 {
122  return bu_malloc(size, "alloc lemon parser object");
123 }
124 
125 static void
126 bu_free_wrapper(void *ptr)
127 {
128  return bu_free(ptr, "free lemon parser object");
129 }
130 
131 static void createParser(obj::parser_type *parser)
132 {
133  *parser = ParseAlloc(bu_malloc_wrapper);
134 }
135 
136 static void destroyParser(obj::parser_type *parser)
137 {
138  ParseFree(*parser, bu_free_wrapper);
139 }
140 
141 static void destroyScanner(yyscan_t *scanner)
142 {
143  struct extra_t *extra =
144  static_cast<struct extra_t*>(obj_parser_get_extra(*scanner));
145 
146  BU_PUT(extra, struct extra_t);
147  obj_parser_set_extra(*scanner, NULL);
148 
149  obj_parser_lex_destroy(*scanner);
150 }
151 
152 static void setScannerExtra(yyscan_t scanner, obj::objCombinedState *state)
153 {
154  struct extra_t *extra;
155 
156  BU_GET(extra, struct extra_t);
157  extra->state = static_cast<void*>(state);
158 
159  obj_parser_set_extra(scanner, static_cast<void*>(extra));
160 }
161 
163 {
164  int err = 0;
165 
166  try {
167  parser->p = new obj::objParser;
168  } catch (std::bad_alloc &) {
169  err = ENOMEM;
170  } catch (...) {
171  bu_bomb("unexpected error encountered\n");
172  }
173 
174  return err;
175 }
176 
177 
179 {
180  try {
181  delete static_cast<obj::objParser*>(parser.p);
182  parser.p = 0;
183  } catch(...) {
184  bu_bomb("unexpected error encountered\n");
185  }
186 }
187 
188 
189 int obj_parse(const char *filename, obj_parser_t parser,
190  obj_contents_t *contents)
191 {
192  using obj::objParser;
193  using obj::objFileContents;
194  using obj::objCombinedState;
195 
196  objParser *p = static_cast<objParser*>(parser.p);
197 
198  int err = 0;
199 
200  try {
201  std::auto_ptr<objFileContents> sentry(new objFileContents);
202 
203  objCombinedState state(p, sentry.get());
204 
205  if ((err =
206  obj::open_file(std::string(filename), state.parser_state))) {
207  return err;
208  }
209 
210  yyscan_t scanner;
211 
212  scanner = perplexFileScanner(state.parser_state.file_stack.back().file);
213  setScannerExtra(scanner, &state);
214 
215  state.parser = NULL;
216  createParser(&(state.parser));
217 
218  err = obj_parser_parse(scanner);
219 
220  p->last_error = state.parser_state.err.str();
221 
222  destroyParser(&(state.parser));
223  destroyScanner(&scanner);
224 
225  // FIXME: need to de-register the FILE* we created
226  // fclose(state.parser_state.file_stack.back().file);
227 
228  if (err == 2) {
229  return ENOMEM;
230  }
231 
232  if (err != 0) {
233  return -1;
234  }
235 
236  contents->p = sentry.release();
237  } catch(std::bad_alloc &) {
238  err = ENOMEM;
239  } catch(std::exception &ex) {
240  p->last_error = ex.what();
241  err = -1;
242  } catch(...) {
243  bu_bomb("unexpected error encountered\n");
244  }
245 
246  return err;
247 }
248 
249 
250 int obj_fparse(FILE *stream, obj_parser_t parser, obj_contents_t *contents)
251 {
252  using obj::objParser;
253  using obj::objFileContents;
254  using obj::objCombinedState;
255 
256  objParser *p = static_cast<objParser*>(parser.p);
257 
258  int err = 0;
259 
260  try {
261  std::auto_ptr<objFileContents> sentry(new objFileContents);
262 
263  objCombinedState state(p, sentry.get());
264 
265  if ((err = obj::set_stream(stream, state.parser_state))) {
266  return err;
267  }
268 
269  yyscan_t scanner;
270 
271  scanner = perplexFileScanner(state.parser_state.file_stack.back().file);
272  setScannerExtra(scanner, &state);
273 
274  state.parser = NULL;
275  createParser(&(state.parser));
276 
277  err = obj_parser_parse(scanner);
278 
279  p->last_error = state.parser_state.err.str();
280 
281  destroyParser(&(state.parser));
282  destroyScanner(&scanner);
283 
284  if (err == 2) {
285  return ENOMEM;
286  }
287 
288  if (err != 0) {
289  return -1;
290  }
291 
292  contents->p = sentry.release();
293  } catch(std::bad_alloc &) {
294  err = ENOMEM;
295  } catch(std::exception &ex) {
296  p->last_error = ex.what();
297  err = -1;
298  } catch(...) {
299  bu_bomb("unexpected error encountered\n");
300  }
301 
302  return err;
303 }
304 
305 
306 const char * obj_parse_error(obj_parser_t parser)
307 {
308  const char *err = 0;
309 
310  try {
311  obj::objParser *p = static_cast<obj::objParser*>(parser.p);
312 
313  if (!(p->last_error.empty())) {
314  err = p->last_error.c_str();
315  }
316  } catch (...) {
317  bu_bomb("unexpected error encountered\n");
318  }
319 
320  return err;
321 }
322 
323 
325 {
326  try {
327  delete static_cast<obj::objFileContents*>(contents.p);
328  contents.p = 0;
329  } catch(...) {
330  bu_bomb("unexpected error encountered\n");
331  }
332 
333  return 0;
334 }
335 
336 
337 size_t obj_vertices(obj_contents_t contents, const float (*val_arr[])[4])
338 {
339  try {
341  static_cast<obj::objFileContents*>(contents.p);
342 
343  // coerce vector<tuple<float, 4> > to size_t arr[][4]
344  if (val_arr && c->gvertices_list.size()) {
345  *val_arr = &(c->gvertices_list.front().v);
346  }
347 
348  return c->gvertices_list.size();
349  } catch(...) {
350  bu_bomb("unexpected error encountered\n");
351  }
352 
353  return 0;
354 }
355 
356 
357 size_t obj_texture_coord(obj_contents_t contents, const float (*val_arr[])[3])
358 {
359  try {
361  static_cast<obj::objFileContents*>(contents.p);
362 
363  // coerce vector<tuple<float, 3> > to size_t arr[][3]
364  if (val_arr && c->tvertices_list.size()) {
365  *val_arr = &(c->tvertices_list.front().v);
366  }
367 
368  return c->tvertices_list.size();
369  } catch(...) {
370  bu_bomb("unexpected error encountered\n");
371  }
372 
373  return 0;
374 }
375 
376 
377 size_t obj_normals(obj_contents_t contents, const float (*val_arr[])[3])
378 {
379  try {
381  static_cast<obj::objFileContents*>(contents.p);
382 
383  // coerce vector<tuple<float, 3> > to size_t arr[][3]
384  if (val_arr && c->nvertices_list.size()) {
385  *val_arr = &(c->nvertices_list.front().v);
386  }
387 
388  return c->nvertices_list.size();
389  } catch(...) {
390  bu_bomb("unexpected error encountered\n");
391  }
392 
393  return 0;
394 }
395 
396 
397 size_t obj_groups(obj_contents_t contents, const char * const (*val_arr[]))
398 {
399  try {
401  static_cast<obj::objFileContents*>(contents.p);
402 
403  if (val_arr && c->groupchar_set.size()) {
404  *val_arr = &(c->groupchar_set.front());
405  }
406 
407  return c->groupchar_set.size();
408  } catch(...) {
409  bu_bomb("unexpected error encountered\n");
410  }
411 
412  return 0;
413 }
414 
415 
417 {
418  try {
420  static_cast<obj::objFileContents*>(contents.p);
421 
422  return c->groupindex_set.size();
423  } catch(...) {
424  bu_bomb("unexpected error encountered\n");
425  }
426 
427  return 0;
428 }
429 
430 
431 size_t obj_groupset(obj_contents_t contents, size_t n,
432  const size_t (*index_arr[]))
433 {
434  try {
436  static_cast<obj::objFileContents*>(contents.p);
437 
438  if (index_arr && c->groupindex_set[n].size()) {
439  *index_arr = &(c->groupindex_set[n].front());
440  }
441 
442  return c->groupindex_set[n].size();
443  } catch(...) {
444  bu_bomb("unexpected error encountered\n");
445  }
446 
447  return 0;
448 }
449 
450 
451 size_t obj_objects(obj_contents_t contents, const char * const (*val_arr[]))
452 {
453  try {
455  static_cast<obj::objFileContents*>(contents.p);
456 
457  if (val_arr && c->objectchar_set.size()) {
458  *val_arr = &(c->objectchar_set.front());
459  }
460 
461  return c->objectchar_set.size();
462  } catch(...) {
463  bu_bomb("unexpected error encountered\n");
464  }
465 
466  return 0;
467 }
468 
469 
470 size_t obj_materials(obj_contents_t contents, const char * const (*val_arr[]))
471 {
472  try {
474  static_cast<obj::objFileContents*>(contents.p);
475 
476  if (val_arr && c->materialchar_set.size()) {
477  *val_arr = &(c->materialchar_set.front());
478  }
479 
480  return c->materialchar_set.size();
481  } catch(...) {
482  bu_bomb("unexpected error encountered\n");
483  }
484 
485  return 0;
486 }
487 
488 
490  const char * const (*val_arr[]))
491 {
492  try {
494  static_cast<obj::objFileContents*>(contents.p);
495 
496  if (val_arr && c->materiallibchar_set.size()) {
497  *val_arr = &(c->materiallibchar_set.front());
498  }
499 
500  return c->materiallibchar_set.size();
501  } catch(...) {
502  bu_bomb("unexpected error encountered\n");
503  }
504 
505  return 0;
506 }
507 
508 
510 {
511  try {
513  static_cast<obj::objFileContents*>(contents.p);
514 
515  return c->materiallibindex_set.size();
516  } catch(...) {
517  bu_bomb("unexpected error encountered\n");
518  }
519 
520  return 0;
521 }
522 
523 
524 size_t obj_materiallibset(obj_contents_t contents, size_t n, const size_t (*index_arr[]))
525 {
526  try {
528  static_cast<obj::objFileContents*>(contents.p);
529 
530  if (index_arr && c->materiallibindex_set[n].size()) {
531  *index_arr = &(c->materiallibindex_set[n].front());
532  }
533 
534  return c->materiallibindex_set[n].size();
535  } catch(...) {
536  bu_bomb("unexpected error encountered\n");
537  }
538 
539  return 0;
540 }
541 
542 
543 size_t obj_texmaps(obj_contents_t contents, const char * const (*val_arr[]))
544 {
545  try {
547  static_cast<obj::objFileContents*>(contents.p);
548 
549  if (val_arr && c->texmapchar_set.size()) {
550  *val_arr = &(c->texmapchar_set.front());
551  }
552 
553  return c->texmapchar_set.size();
554  } catch(...) {
555  bu_bomb("unexpected error encountered\n");
556  }
557 
558  return 0;
559 }
560 
561 
562 size_t obj_texmaplibs(obj_contents_t contents, const char * const (*val_arr[]))
563 {
564  try {
566  static_cast<obj::objFileContents*>(contents.p);
567 
568  if (val_arr && c->texmaplibchar_set.size()) {
569  *val_arr = &(c->texmaplibchar_set.front());
570  }
571 
572  return c->texmaplibchar_set.size();
573  } catch(...) {
574  bu_bomb("unexpected error encountered\n");
575  }
576 
577  return 0;
578 }
579 
580 
582 {
583  try {
585  static_cast<obj::objFileContents*>(contents.p);
586 
587  return c->texmaplibindex_set.size();
588  } catch(...) {
589  bu_bomb("unexpected error encountered\n");
590  }
591 
592  return 0;
593 }
594 
595 
596 size_t obj_texmaplibset(obj_contents_t contents, size_t n,
597  const size_t (*index_arr[]))
598 {
599  try {
601  static_cast<obj::objFileContents*>(contents.p);
602 
603  if (index_arr && c->texmaplibindex_set[n].size()) {
604  *index_arr = &(c->texmaplibindex_set[n].front());
605  }
606 
607  return c->texmaplibindex_set[n].size();
608  } catch(...) {
609  bu_bomb("unexpected error encountered\n");
610  }
611 
612  return 0;
613 }
614 
615 
616 size_t obj_shadow_objs(obj_contents_t contents, const char * const (*val_arr[]))
617 {
618  try {
620  static_cast<obj::objFileContents*>(contents.p);
621 
622  if (val_arr && c->shadow_objchar_set.size()) {
623  *val_arr = &(c->shadow_objchar_set.front());
624  }
625 
626  return c->shadow_objchar_set.size();
627  } catch(...) {
628  bu_bomb("unexpected error encountered\n");
629  }
630 
631  return 0;
632 }
633 
634 
635 size_t obj_trace_objs(obj_contents_t contents, const char * const (*val_arr[]))
636 {
637  try {
639  static_cast<obj::objFileContents*>(contents.p);
640 
641  if (val_arr && c->trace_objchar_set.size()) {
642  *val_arr = &(c->trace_objchar_set.front());
643  }
644 
645  return c->trace_objchar_set.size();
646  } catch(...) {
647  bu_bomb("unexpected error encountered\n");
648  }
649 
650  return 0;
651 }
652 
653 
655  const obj_polygonal_attributes_t (*attr_list[]))
656 {
657  try {
659  static_cast<obj::objFileContents*>(contents.p);
660 
661  if (attr_list && c->polyattributes_set.size()) {
662  *attr_list = &(c->polyattributes_set.front());
663  }
664 
665  return c->polyattributes_set.size();
666  } catch(...) {
667  bu_bomb("unexpected error encountered\n");
668  }
669 
670  return 0;
671 }
672 
673 
675  const size_t (*attindex_arr[]))
676 {
677  try {
679  static_cast<obj::objFileContents*>(contents.p);
680 
681  if (attindex_arr && c->point_v_attr_list.size()) {
682  *attindex_arr = &(c->point_v_attr_list.front());
683  }
684 
685  return c->point_v_attr_list.size();
686  } catch(...) {
687  bu_bomb("unexpected error encountered\n");
688  }
689 
690  return 0;
691 }
692 
693 
694 size_t obj_polygonal_v_point_vertices(obj_contents_t contents, size_t face,
695  const size_t (*index_arr[]))
696 {
697  try {
699  static_cast<obj::objFileContents*>(contents.p);
700 
701  if (index_arr && c->point_v_loclist[face].second) {
702  *index_arr = &(c->point_v_indexlist[c->point_v_loclist[face].first]);
703  }
704 
705  return c->point_v_loclist[face].second;
706  } catch(...) {
707  bu_bomb("unexpected error encountered\n");
708  }
709 
710  return 0;
711 }
712 
713 
715  const size_t (*attindex_arr[]))
716 {
717  try {
719  static_cast<obj::objFileContents*>(contents.p);
720 
721  if (attindex_arr && c->line_v_attr_list.size()) {
722  *attindex_arr = &(c->line_v_attr_list.front());
723  }
724 
725  return c->line_v_attr_list.size();
726  } catch(...) {
727  bu_bomb("unexpected error encountered\n");
728  }
729 
730  return 0;
731 }
732 
733 
734 size_t obj_polygonal_v_line_vertices(obj_contents_t contents, size_t face,
735  const size_t (*index_arr[]))
736 {
737  try {
739  static_cast<obj::objFileContents*>(contents.p);
740 
741  if (index_arr && c->line_v_loclist[face].second) {
742  *index_arr = &(c->line_v_indexlist[c->line_v_loclist[face].first]);
743  }
744 
745  return c->line_v_loclist[face].second;
746  } catch(...) {
747  bu_bomb("unexpected error encountered\n");
748  }
749 
750  return 0;
751 }
752 
753 
755  const size_t (*attindex_arr[]))
756 {
757  try {
759  static_cast<obj::objFileContents*>(contents.p);
760 
761  if (attindex_arr && c->line_tv_attr_list.size()) {
762  *attindex_arr = &(c->line_tv_attr_list.front());
763  }
764 
765  return c->line_tv_attr_list.size();
766  } catch(...) {
767  bu_bomb("unexpected error encountered\n");
768  }
769 
770  return 0;
771 }
772 
773 
774 size_t obj_polygonal_tv_line_vertices(obj_contents_t contents, size_t face,
775  const size_t (*index_arr[])[2])
776 {
777  try {
779  static_cast<obj::objFileContents*>(contents.p);
780 
781  // coerce vector<tuple<size_t, 2> > to size_t arr[][2]
782  if (index_arr && c->line_tv_loclist[face].second) {
783  *index_arr = &(c->line_tv_indexlist[c->line_tv_loclist[face].first].v);
784  }
785 
786  return c->line_tv_loclist[face].second;
787  } catch(...) {
788  bu_bomb("unexpected error encountered\n");
789  }
790 
791  return 0;
792 }
793 
794 
796  const size_t (*attindex_arr[]))
797 {
798  try {
800  static_cast<obj::objFileContents*>(contents.p);
801 
802  if (attindex_arr && c->polygonal_v_attr_list.size()) {
803  *attindex_arr = &(c->polygonal_v_attr_list.front());
804  }
805 
806  return c->polygonal_v_attr_list.size();
807  } catch(...) {
808  bu_bomb("unexpected error encountered\n");
809  }
810 
811  return 0;
812 }
813 
814 
815 size_t obj_polygonal_v_face_vertices(obj_contents_t contents, size_t face,
816  const size_t (*index_arr[]))
817 {
818  using obj::objFileContents;
819 
820  try {
821  objFileContents *c = static_cast<objFileContents*>(contents.p);
822 
823  size_t start = c->polygonal_v_loclist[face].first;
824  size_t length = c->polygonal_v_loclist[face].second;
825 
826  if (index_arr != NULL && length > 0) {
827  *index_arr = &(c->pologonal_v_indexlist[start]);
828  }
829 
830  return length;
831  } catch(...) {
832  bu_bomb("unexpected error encountered\n");
833  }
834 
835  return 0;
836 }
837 
838 
840  const size_t (*attindex_arr[]))
841 {
842  try {
844  static_cast<obj::objFileContents*>(contents.p);
845 
846  if (attindex_arr && c->polygonal_tv_attr_list.size()) {
847  *attindex_arr = &(c->polygonal_tv_attr_list.front());
848  }
849 
850  return c->polygonal_tv_attr_list.size();
851  } catch(...) {
852  bu_bomb("unexpected error encountered\n");
853  }
854 
855  return 0;
856 }
857 
858 
859 size_t obj_polygonal_tv_face_vertices(obj_contents_t contents, size_t face,
860  const size_t (*index_arr[])[2])
861 {
862  try {
864  static_cast<obj::objFileContents*>(contents.p);
865 
866  // coerce vector<tuple<size_t, 2> > to size_t arr[][2]
867  if (index_arr && c->polygonal_tv_loclist[face].second) {
868  *index_arr = &(c->pologonal_tv_indexlist[c->polygonal_tv_loclist[face].first].v);
869  }
870 
871  return c->polygonal_tv_loclist[face].second;
872 
873  } catch(...) {
874  bu_bomb("unexpected error encountered\n");
875  }
876 
877  return 0;
878 }
879 
880 
882  const size_t (*attindex_arr[]))
883 {
884  try {
886  static_cast<obj::objFileContents*>(contents.p);
887 
888  if (attindex_arr && c->polygonal_nv_attr_list.size()) {
889  *attindex_arr = &(c->polygonal_nv_attr_list.front());
890  }
891 
892  return c->polygonal_nv_attr_list.size();
893  } catch(...) {
894  bu_bomb("unexpected error encountered\n");
895  }
896 
897  return 0;
898 }
899 
900 
901 size_t obj_polygonal_nv_face_vertices(obj_contents_t contents, size_t face,
902  const size_t (*index_arr[])[2])
903 {
904  try {
906  static_cast<obj::objFileContents*>(contents.p);
907 
908  // coerce vector<tuple<size_t, 2> > to size_t arr[][2]
909  if (index_arr && c->polygonal_nv_loclist[face].second) {
910  *index_arr = &(c->pologonal_nv_indexlist[c->polygonal_nv_loclist[face].first].v);
911  }
912 
913  return c->polygonal_nv_loclist[face].second;
914  } catch(...) {
915  bu_bomb("unexpected error encountered\n");
916  }
917 
918  return 0;
919 }
920 
921 
923  const size_t (*attindex_arr[]))
924 {
925  try {
927  static_cast<obj::objFileContents*>(contents.p);
928 
929  if (attindex_arr && c->polygonal_tnv_attr_list.size()) {
930  *attindex_arr = &(c->polygonal_tnv_attr_list.front());
931  }
932 
933  return c->polygonal_tnv_attr_list.size();
934  } catch(...) {
935  bu_bomb("unexpected error encountered\n");
936  }
937 
938  return 0;
939 }
940 
941 
942 size_t obj_polygonal_tnv_face_vertices(obj_contents_t contents, size_t face,
943  const size_t (*index_arr[])[3])
944 {
945  try {
947  static_cast<obj::objFileContents*>(contents.p);
948 
949  // coerce vector<tuple<size_t, 3> > to size_t arr[][3]
950  if (index_arr && c->polygonal_tnv_loclist[face].second) {
951  *index_arr = &(c->pologonal_tnv_indexlist[c->polygonal_tnv_loclist[face].first].v);
952  }
953 
954  return c->polygonal_tnv_loclist[face].second;
955  } catch(...) {
956  bu_bomb("unexpected error encountered\n");
957  }
958 
959  return 0;
960 }
961 
963 
964 } /* namespace gcv */
965 } /* namespace cad */
966 
967 
968 /*
969  * Local Variables:
970  * mode: C++
971  * tab-width: 8
972  * indent-tabs-mode: t
973  * c-file-style: "stroustrup"
974  * End:
975  * ex: shiftwidth=4 tabstop=8
976  */
char filename[MAXLENGTH]
Definition: human.c:105
size_t obj_trace_objs(obj_contents_t contents, const char *const (*val_arr[]))
Definition: obj_parser.cpp:635
int obj_fparse(FILE *stream, obj_parser_t parser, obj_contents_t *contents)
Definition: obj_parser.cpp:250
size_t obj_num_groupsets(obj_contents_t contents)
Definition: obj_parser.cpp:416
size_t obj_texmaps(obj_contents_t contents, const char *const (*val_arr[]))
Definition: obj_parser.cpp:543
size_t obj_polygonal_tv_face_vertices(obj_contents_t contents, size_t face, const size_t(*index_arr[])[2])
Definition: obj_parser.cpp:859
void ParseFree(void *p, void(*freeProc)(void *))
if lu s
Definition: nmg_mod.c:3860
void * p
Definition: obj_parser.h:39
basic_parser_extra< float, char > objCombinedState
std::vector< file_node > file_stack
int obj_parse(const char *filename, obj_parser_t parser, obj_contents_t *contents)
Definition: obj_parser.cpp:189
Header file for the BRL-CAD common definitions.
size_t obj_normals(obj_contents_t contents, const float(*val_arr[])[3])
Definition: obj_parser.cpp:377
size_t obj_polygonal_v_point_vertices(obj_contents_t contents, size_t face, const size_t(*index_arr[]))
Definition: obj_parser.cpp:694
size_t obj_polygonal_tv_lines(obj_contents_t contents, const size_t(*attindex_arr[]))
Definition: obj_parser.cpp:754
size_t obj_polygonal_v_points(obj_contents_t contents, const size_t(*attindex_arr[]))
Definition: obj_parser.cpp:674
size_t obj_polygonal_v_lines(obj_contents_t contents, const size_t(*attindex_arr[]))
Definition: obj_parser.cpp:714
void obj_parser_set_extra(yyscan_t scanner, void *extra)
void obj_parser_destroy(obj_parser_t parser)
Definition: obj_parser.cpp:178
size_t obj_texmaplibs(obj_contents_t contents, const char *const (*val_arr[]))
Definition: obj_parser.cpp:562
void * bu_malloc(size_t siz, const char *str)
Definition: malloc.c:314
size_t obj_polygonal_tv_faces(obj_contents_t contents, const size_t(*attindex_arr[]))
Definition: obj_parser.cpp:839
void * ParseAlloc(void *(*mallocProc)(size_t))
size_t obj_groupset(obj_contents_t contents, size_t n, const size_t(*index_arr[]))
Definition: obj_parser.cpp:431
#define __BEGIN_DECLS
Definition: common.h:73
size_t obj_polygonal_v_line_vertices(obj_contents_t contents, size_t face, const size_t(*index_arr[]))
Definition: obj_parser.cpp:734
int obj_contents_destroy(obj_contents_t contents)
Definition: obj_parser.cpp:324
#define BU_GET(_ptr, _type)
Definition: malloc.h:201
const char * obj_parse_error(obj_parser_t parser)
Definition: obj_parser.cpp:306
size_t obj_num_texmaplibsets(obj_contents_t contents)
Definition: obj_parser.cpp:581
size_t obj_polygonal_tnv_face_vertices(obj_contents_t contents, size_t face, const size_t(*index_arr[])[3])
Definition: obj_parser.cpp:942
size_t obj_texmaplibset(obj_contents_t contents, size_t n, const size_t(*index_arr[]))
Definition: obj_parser.cpp:596
size_t obj_polygonal_tv_line_vertices(obj_contents_t contents, size_t face, const size_t(*index_arr[])[2])
Definition: obj_parser.cpp:774
#define BU_PUT(_ptr, _type)
Definition: malloc.h:215
void obj_parser_lex_destroy(yyscan_t scanner)
void * state
Definition: obj_rules.h:55
perplex_t yyscan_t
Definition: obj_rules.h:52
size_t obj_materials(obj_contents_t contents, const char *const (*val_arr[]))
Definition: obj_parser.cpp:470
size_t obj_groups(obj_contents_t contents, const char *const (*val_arr[]))
Definition: obj_parser.cpp:397
size_t obj_num_materiallibsets(obj_contents_t contents)
Definition: obj_parser.cpp:509
size_t obj_texture_coord(obj_contents_t contents, const float(*val_arr[])[3])
Definition: obj_parser.cpp:357
size_t obj_vertices(obj_contents_t contents, const float(*val_arr[])[4])
Definition: obj_parser.cpp:337
size_t obj_polygonal_nv_face_vertices(obj_contents_t contents, size_t face, const size_t(*index_arr[])[2])
Definition: obj_parser.cpp:901
size_t obj_polygonal_v_face_vertices(obj_contents_t contents, size_t face, const size_t(*index_arr[]))
Definition: obj_parser.cpp:815
int obj_parser_create(obj_parser_t *parser)
Definition: obj_parser.cpp:162
size_t obj_polygonal_tnv_faces(obj_contents_t contents, const size_t(*attindex_arr[]))
Definition: obj_parser.cpp:922
int obj_parser_parse(yyscan_t)
size_t obj_materiallibs(obj_contents_t contents, const char *const (*val_arr[]))
Definition: obj_parser.cpp:489
size_t obj_objects(obj_contents_t contents, const char *const (*val_arr[]))
Definition: obj_parser.cpp:451
#define __END_DECLS
Definition: common.h:74
void bu_free(void *ptr, const char *str)
Definition: malloc.c:328
size_t obj_polygonal_nv_faces(obj_contents_t contents, const size_t(*attindex_arr[]))
Definition: obj_parser.cpp:881
basic_obj_parser< char > objParser
size_t obj_materiallibset(obj_contents_t contents, size_t n, const size_t(*index_arr[]))
Definition: obj_parser.cpp:524
contents_type::string_type string_type
size_t obj_polygonal_attributes(obj_contents_t contents, const obj_polygonal_attributes_t(*attr_list[]))
Definition: obj_parser.cpp:654
size_t obj_polygonal_v_faces(obj_contents_t contents, const size_t(*attindex_arr[]))
Definition: obj_parser.cpp:795
size_t obj_shadow_objs(obj_contents_t contents, const char *const (*val_arr[]))
Definition: obj_parser.cpp:616
void bu_bomb(const char *str) _BU_ATTR_NORETURN
Definition: bomb.c:91
basic_obj_contents< float, char > objFileContents
void * obj_parser_get_extra(yyscan_t scanner)