/** * Prints the immutable value {@code SMFHeader} with attribute values. * @return A string representation of the value */ @Override public String toString() { return "SMFHeader{" + "triangles=" + triangles + ", vertexCount=" + vertexCount + ", schemaIdentifier=" + schemaIdentifier + ", coordinateSystem=" + coordinateSystem + ", attributesInOrder=" + (attributesInOrder().toString()) + ", attributesByName=" + attributesByName + ", metaCount=" + metaCount + "}"; }
/** * Construct a new immutable {@code SMFHeader} instance. * @param triangles The value for the {@code triangles} attribute * @param vertexCount The value for the {@code vertexCount} attribute * @param schemaIdentifier The value for the {@code schemaIdentifier} attribute * @param coordinateSystem The value for the {@code coordinateSystem} attribute * @param attributesInOrder The value for the {@code attributesInOrder} attribute * @param metaCount The value for the {@code metaCount} attribute * @return An immutable SMFHeader instance */ public static SMFHeader of(SMFTriangles triangles, long vertexCount, SMFSchemaIdentifier schemaIdentifier, SMFCoordinateSystem coordinateSystem, List<SMFAttribute> attributesInOrder, long metaCount) { return validate(new SMFHeader(triangles, vertexCount, schemaIdentifier, coordinateSystem, attributesInOrder, metaCount)); }
public SMFHeader withAttributesInOrder(List<SMFAttribute> value) { List<SMFAttribute> newValue = attributesInOrder_from(value); if (this.attributesInOrder == newValue) return this; return validate(new SMFHeader(this, this.triangles, this.vertexCount, this.schemaIdentifier, this.coordinateSystem, newValue)); }
this.state.transition(SerializerState.STATE_HEADER); final List<SMFAttribute> attributes = in_header.attributesInOrder(); this.header = in_header; this.attribute_queue = Queue.ofAll(attributes); final SMFTriangles triangles = in_header.triangles(); this.triangle_values_remaining = triangles.triangleCount(); this.meta_values_remaining = in_header.metaCount(); this.header.schemaIdentifier(); if (schema_id.vendorID() != 0) { this.writer.append("schema "); String.format( "meta %s", Long.toUnsignedString(this.header.metaCount()))); this.writer.newLine(); String.format( "vertices %s", Long.toUnsignedString(this.header.vertexCount()))); this.writer.newLine(); this.writer.newLine(); this.writer.append(serializeAxes(this.header.coordinateSystem())); this.writer.newLine();
List.empty(), m.header().attributesByName(), this.source); if (!errors.isEmpty()) { return invalid(List.ofAll(errors)); orig_header.attributesInOrder(); final Map<SMFAttributeName, SMFAttribute> orig_by_name = orig_header.attributesByName(); final SMFAttribute orig_attrib = orig_by_name.get(this.source).get(); orig_ordered.remove(orig_attrib); final SMFHeader new_header = orig_header.withAttributesInOrder(new_ordered);
private static List<SMFErrorType> checkVerticesAndTriangles( final SMFHeader header, final SMFSchema schema, final List<SMFErrorType> errors) { List<SMFErrorType> error_accum = errors; if (schema.requireTriangles() == SMF_TRIANGLES_REQUIRED) { if (header.triangles().triangleCount() == 0L) { error_accum = error_accum.append(errorTrianglesRequiredButEmpty()); } } if (schema.requireVertices() == SMF_VERTICES_REQUIRED) { if (header.vertexCount() == 0L) { error_accum = error_accum.append(errorVerticesRequiredButEmpty()); } } return error_accum; }
final long vertices = m.header().vertexCount(); final Vector<Vector3L> triangles = m.triangles(); final OptionalInt optimize_opt = this.config.optimize(); if (errors.isEmpty()) { final SMFTriangles new_triangles = m.header().triangles().withTriangleIndexSizeBits(triangle_size); return Validation.valid( m.withHeader(m.header().withTriangles(new_triangles)));
this.configuration.mappings(); final Map<SMFAttributeName, SMFAttribute> received_attributes = in_header.attributesByName(); this.vertex_size, in_header.vertexCount()); this.index_type = determineIndexType( in_header.triangleIndexSizeBits());
private boolean isBodyDone() { final boolean ok_triangles = this.header.triangles().triangleCount() == this.parsed_triangles; final boolean attribute_size_ok = this.attributes_ok.size() == this.header.attributesByName().size(); final boolean attribute_all_done = this.attributes_ok.foldRight( Boolean.TRUE, (p, x) -> Boolean.valueOf(p._2.booleanValue() && x.booleanValue())).booleanValue(); this.log().trace( "triangles done: {}", Boolean.valueOf(ok_triangles)); this.log().trace( "attributes size: {}", Boolean.valueOf(attribute_size_ok)); this.log().trace( "attributes done: {}", Boolean.valueOf(attribute_all_done)); return ok_triangles && attribute_size_ok && attribute_all_done; }
this.header.attributesByName().get(name); if (attribute_opt.isDefined()) { final SMFAttribute attribute = attribute_opt.get(); while (parsed_vertices != this.header.vertexCount()) { final Optional<List<String>> line_opt = super.reader.line(); if (!line_opt.isPresent()) {
private void failMissedTriangles() { if (this.parsed_triangles != this.header.triangles().triangleCount()) { this.fail("Too few triangles specified", Optional.empty()); } }
if (Objects.equals(name, next.name())) { this.attribute_queue = this.attribute_queue.tail(); this.attribute_values_remaining = this.header.vertexCount(); this.attribute_current = next;
private void failMissedAttributes() { final Set<SMFAttributeName> names = this.header.attributesByName().keySet().diff( this.attributes_attempted.keySet()); if (!names.isEmpty()) { names.forEach( name -> this.fail( "No data specified for attribute: " + name.value(), Optional.empty())); } }
/** * Creates an immutable copy of a {@link SMFHeaderType} value. * Uses accessors to get values to initialize the new immutable instance. * If an instance is already immutable, it is returned as is. * @param instance The instance to copy * @return A copied immutable SMFHeader instance */ public static SMFHeader copyOf(SMFHeaderType instance) { if (instance instanceof SMFHeader) { return (SMFHeader) instance; } return SMFHeader.builder() .from(instance) .build(); }
m.header().schemaIdentifier(); if (received_opt.isPresent()) { final SMFSchemaIdentifier received = received_opt.get();
/** * Builds a new {@link SMFHeader SMFHeader}. * @return An immutable instance of SMFHeader * @throws java.lang.IllegalStateException if any required attributes are missing */ public SMFHeader build() { return SMFHeader.validate(new SMFHeader(this)); }
private static SMFHeader validate(SMFHeader instance) { instance.checkPreconditions(); return instance; }
private SMFHeader( SMFTriangles triangles, long vertexCount, SMFSchemaIdentifier schemaIdentifier, SMFCoordinateSystem coordinateSystem, List<SMFAttribute> attributesInOrder, long metaCount) { this.triangles = Objects.requireNonNull(triangles, "triangles"); this.vertexCount = vertexCount; this.schemaIdentifier = Objects.requireNonNull(schemaIdentifier, "schemaIdentifier"); this.coordinateSystem = Objects.requireNonNull(coordinateSystem, "coordinateSystem"); this.attributesInOrder = attributesInOrder_from(attributesInOrder); this.metaCount = metaCount; initShim.setVertexCount(this.vertexCount); initShim.setMetaCount(this.metaCount); this.attributesByName = initShim.attributesByName(); this.initShim = null; }
m.header().attributesByName(); Seq<SMFProcessingError> errors = List.empty(); errors = checkAttributeExists(errors, by_name, this.attribute); original.withComponentSizeBits(this.size); final List<SMFAttribute> ordered = header.attributesInOrder().replace(original, resampled); final SMFHeader new_header = header.withAttributesInOrder(ordered); return valid( SMFMemoryMesh.builder()
final SMFTriangles triangles = this.header.triangles(); Math.multiplyExact( (long) buffer_config.vertexSizeOctets(), this.header.vertexCount());