MCPcopy Create free account
hub / github.com/LiangliangNan/PolyFit / do_read

Method do_read

code/model/map_serializer_obj.cpp:81–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79}
80
81bool MapSerializer_obj::do_read(std::istream& input, AbstractMapBuilder& builder) {
82 MapFacetAttribute<Color> color_ ;
83 LineInputStream in(input) ;
84 MapBuilder* concrete_builder = dynamic_cast<MapBuilder*>(&builder) ;
85
86 builder.begin_surface() ;
87 while(!in.eof()) {
88 in.get_line() ;
89
90 std::string keyword ;
91 in >> keyword ;
92
93 if(keyword == "v") {
94 vec3 p ;
95 in >> p ;
96 builder.add_vertex(p) ;
97 } else if(keyword == "vt") {
98 vec2 q ;
99 in >> q ;
100 //builder.add_tex_vertex(q) ;
101 } else if(keyword == "f") {
102 builder.begin_facet() ;
103 while(!in.eol()) {
104 std::string s ;
105 in >> s ;
106 if(s.length() > 0) {
107 std::istringstream v_input(s) ;
108 int index ;
109 v_input >> index ;
110 builder.add_vertex_to_facet(index - 1) ;
111 char c ;
112 v_input >> c ;
113 if(c == '/') {
114 v_input >> index ;
115 //builder.set_corner_tex_vertex(index - 1) ;
116 }
117 }
118 }
119 builder.end_facet() ;
120 if(color_.is_bound() && concrete_builder != nil) {
121 color_[concrete_builder->current_facet()] = current_material_ ;
122 }
123 } else if(keyword == "#") {
124 std::string second_keyword ;
125 in >> second_keyword ;
126 if(second_keyword == "anchor") {
127 int index ;
128 in >> index ;
129 builder.lock_vertex(index - 1) ;
130 }
131 } else if(keyword == "mtllib") {
132 std::string mtl_lib_filename ;
133 in >> mtl_lib_filename ;
134 mtl_lib_filename = current_directory_ + "/" + mtl_lib_filename ;
135 std::ifstream mtl_lib_in(mtl_lib_filename.c_str()) ;
136 if(mtl_lib_in) {
137 Logger::out("MapSerializer_obj") << "using material lib: " << mtl_lib_filename << std::endl ;
138 read_mtl_lib(mtl_lib_in) ;

Callers

nothing calls this directly

Calls 15

warnFunction · 0.85
find_halfedge_betweenFunction · 0.85
begin_surfaceMethod · 0.80
eofMethod · 0.80
get_lineMethod · 0.80
add_vertexMethod · 0.80
begin_facetMethod · 0.80
eolMethod · 0.80
add_vertex_to_facetMethod · 0.80
end_facetMethod · 0.80
current_facetMethod · 0.80

Tested by

no test coverage detected