/** * @return The attributes by name */ @Value.Derived default SortedMap<SMFAttributeName, SMFAttribute> attributesByName() { SortedMap<SMFAttributeName, SMFAttribute> m = TreeMap.empty(); final List<SMFAttribute> ordered = this.attributesInOrder(); for (int index = 0; index < ordered.size(); ++index) { final SMFAttribute attr = ordered.get(index); if (m.containsKey(attr.name())) { final StringBuilder sb = new StringBuilder(128); sb.append("Duplicate attribute name."); sb.append(System.lineSeparator()); sb.append(" Attribute: "); sb.append(attr.name().value()); sb.append(System.lineSeparator()); throw new IllegalArgumentException(sb.toString()); } m = m.put(attr.name(), attr); } return m; }
@Override public void onDataAttributeStart( final SMFAttribute attribute) { final String name = attribute.name().value(); if (this.attributes_by_name.containsKey(name)) { final Attribute attr = this.attributes_by_name.get(name); this.packer = new SMFByteBufferPacker( this.array_update.getData(), attr.type, (int) attr.offset, this.vertex_size); } else { this.packer = null; } }
/** * @return The attributes by name */ @Value.Derived default SortedMap<SMFAttributeName, SMFAttribute> attributesByName() { SortedMap<SMFAttributeName, SMFAttribute> m = TreeMap.empty(); final List<SMFAttribute> ordered = this.attributesInOrder(); for (int index = 0; index < ordered.size(); ++index) { final SMFAttribute attr = ordered.get(index); if (m.containsKey(attr.name())) { final StringBuilder sb = new StringBuilder(128); sb.append("Duplicate attribute name."); sb.append(System.lineSeparator()); sb.append(" Attribute: "); sb.append(attr.name().value()); sb.append(System.lineSeparator()); throw new IllegalArgumentException(sb.toString()); } m = m.put(attr.name(), attr); } return m; }
final Option<SMFAttribute> attribute_opt = named.get(attribute.name()); if (attribute_opt.isDefined()) { if (!Objects.equals(attribute, attribute_opt.get())) { sb.append(System.lineSeparator()); sb.append(" Attribute: "); sb.append(attribute.name()); sb.append(System.lineSeparator()); throw new IllegalArgumentException(sb.toString()); sb.append(System.lineSeparator()); sb.append(" Attribute: "); sb.append(attribute.name()); sb.append(System.lineSeparator()); throw new IllegalArgumentException(sb.toString());
final Option<SMFAttribute> attribute_opt = named.get(attribute.name()); if (attribute_opt.isDefined()) { if (!Objects.equals(attribute, attribute_opt.get())) { sb.append(System.lineSeparator()); sb.append(" Attribute: "); sb.append(attribute.name()); sb.append(System.lineSeparator()); throw new IllegalArgumentException(sb.toString()); sb.append(System.lineSeparator()); sb.append(" Attribute: "); sb.append(attribute.name()); sb.append(System.lineSeparator()); throw new IllegalArgumentException(sb.toString());
sb.append(System.lineSeparator()); sb.append(" Attribute: "); sb.append(a.name().value()); sb.append(System.lineSeparator()); sb.append(" Attribute type: ");
sb.append(System.lineSeparator()); sb.append(" Attribute: "); sb.append(this.attribute_current.name().value()); sb.append(System.lineSeparator()); sb.append(" Remaining: "); if (Objects.equals(name, next.name())) { this.attribute_queue = this.attribute_queue.tail(); this.attribute_values_remaining = this.header.vertexCount(); String.format( "attribute \"%s\"", this.attribute_current.name().value())); this.writer.newLine(); return; sb.append(" Expected: "); if (!this.attribute_queue.isEmpty()) { sb.append(this.attribute_queue.head().name().value()); } else { sb.append("(no attribute expected)");
private void parseHeaderCheckUniqueAttributeNames() { final Collection<SMFAttributeName> names = new HashSet<>(this.attributes_list.size()); for (final SMFAttribute attribute : this.attributes_list) { final SMFAttributeName name = attribute.name(); if (names.contains(name)) { Invariants.checkInvariant( name, this.attribute_lines.containsKey(name), a_name -> "Attribute lines must contain " + a_name); this.failWithLineNumber( this.attribute_lines.get(name).get().intValue(), "Duplicate attribute name: " + name.value(), Optional.empty()); } names.add(name); } }
/** * @return The packed attributes by name */ @Value.Derived default SortedMap<SMFAttributeName, SMFByteBufferPackedAttribute> packedAttributesByName() { return this.packedAttributesByOffset() .map((offset, attr) -> Tuple.of(attr.attribute().name(), attr)); }
String.format( "attribute \"%s\" %s %s %s", attribute.name().value(), attribute.componentType().getName(), Long.toUnsignedString((long) attribute.componentCount()),
try { final SMFAttributeArrayType array = this.mesh.arrays().get(a.name()).get(); array.matchArray( av,
String.format( "An attribute '%s' with %d components of type %s with size %d", attr.name().value(), Integer.valueOf(attr.componentCount()), attr.componentType().getName(),
@Override public Optional<SMFParserEventsDataAttributeValuesType> onDataAttributeStart( final SMFAttribute attribute) { TreeMap<Integer, SMFByteBufferAttributePacker> packers = TreeMap.empty(); final SMFAttributeName name = attribute.name(); for (final Tuple2<Integer, SMFByteBufferPackingConfiguration> p : this.config) { final Integer id = p._1; final SMFByteBufferPackingConfiguration bc = p._2; final SortedMap<SMFAttributeName, SMFByteBufferPackedAttribute> by_name = bc.packedAttributesByName(); if (by_name.containsKey(name)) { final ByteBuffer b = this.attr_buffers.get(id).get(); final SMFByteBufferPackedAttribute pa = by_name.get(name).get(); final SMFByteBufferAttributePacker packer = new SMFByteBufferAttributePacker( this, b, bc, pa, this.header.vertexCount()); packers = packers.put(id, packer); } } this.attr_packers = packers; return Optional.of(this); }
s.serializeVertexDataNonInterleavedStart()) { for (final SMFAttribute attribute : header.attributesInOrder()) { final SMFAttributeName name = attribute.name(); try (final SMFSerializerDataAttributesValuesType sav = sv.serializeData(name)) {
case 4: { this.arrays = this.arrays.put( this.attribute_current.name(), SMFAttributeArrayIntegerSigned4.builder() .setValues(this.elements.map(x -> (Vector4L) x)) this.attribute_current.name(), SMFAttributeArrayIntegerSigned3.builder() .setValues(this.elements.map(x -> (Vector3L) x)) this.attribute_current.name(), SMFAttributeArrayIntegerSigned2.builder() .setValues(this.elements.map(x -> (Vector2L) x)) this.attribute_current.name(), SMFAttributeArrayIntegerSigned1.builder() .setValues(this.elements.map(x -> (Long) x)) case 4: { this.arrays = this.arrays.put( this.attribute_current.name(), SMFAttributeArrayIntegerUnsigned4.builder() .setValues(this.elements.map(x -> (Vector4L) x)) this.attribute_current.name(), SMFAttributeArrayIntegerUnsigned3.builder() .setValues(this.elements.map(x -> (Vector3L) x)) this.attribute_current.name(),
header.attributesInOrder().filter(a -> this.attributes.contains(a.name())); final Map<SMFAttributeName, SMFAttributeArrayType> new_arrays = m.arrays().filter(p -> this.attributes.contains(p._1));