decGeometry receives the start element of a geometry and decodes all its children and appends the decoded geometry to the specified slice.
(start xml.StartElement, lg *LibraryGeometries)
| 261 | // decodes all its children and appends the decoded geometry |
| 262 | // to the specified slice. |
| 263 | func (d *Decoder) decGeometry(start xml.StartElement, lg *LibraryGeometries) error { |
| 264 | |
| 265 | // Get geometry id and name attributes |
| 266 | geom := &Geometry{} |
| 267 | geom.Id = findAttrib(start, "id").Value |
| 268 | geom.Name = findAttrib(start, "name").Value |
| 269 | lg.Geometry = append(lg.Geometry, geom) |
| 270 | |
| 271 | // Decodes geometry children |
| 272 | for { |
| 273 | // Get next child |
| 274 | child, _, err := d.decNextChild(start) |
| 275 | if err != nil || child.Name.Local == "" { |
| 276 | return err |
| 277 | } |
| 278 | // Decode mesh |
| 279 | if child.Name.Local == "mesh" { |
| 280 | err = d.decMesh(child, geom) |
| 281 | if err != nil { |
| 282 | return err |
| 283 | } |
| 284 | continue |
| 285 | } |
| 286 | } |
| 287 | } |
| 288 | |
| 289 | // decMesh decodes the mesh from the specified geometry |
| 290 | func (d *Decoder) decMesh(start xml.StartElement, geom *Geometry) error { |
no test coverage detected