private void failMissedTriangles() { if (this.parsed_triangles != this.header.triangles().triangleCount()) { this.fail("Too few triangles specified", Optional.empty()); } }
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.attribute_queue = Queue.ofAll(attributes); final SMFTriangles triangles = in_header.triangles(); this.triangle_values_remaining = triangles.triangleCount(); this.meta_values_remaining = in_header.metaCount(); String.format( "triangles %s %s", Long.toUnsignedString(triangles.triangleCount()), Long.toUnsignedString(triangles.triangleIndexSizeBits()))); this.writer.newLine();
final SMFTriangles triangles = this.header.triangles(); if (Long.compareUnsigned(triangles.triangleCount(), 0L) > 0) { final long size_tri = Math.multiplyExact( Integer.toUnsignedLong(triangles.triangleSizeOctets()), triangles.triangleCount()); this.tri_buffer, triangles.triangleIndexSizeBits(), triangles.triangleCount()); } else { LOG.debug("triangle packing requested, but no triangles are available");
while (this.parsed_triangles != this.header.triangles().triangleCount()) { final Optional<List<String>> line_opt = super.reader.line(); if (!line_opt.isPresent()) {
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; }
@Override public void onFinish() { if (this.errors.isEmpty()) { Invariants.checkInvariantI( this.attr_buffers.size(), this.attr_buffers.size() == this.config.size(), x -> "Must have correct number of buffers"); final SMFByteBufferPackedMesh.Builder mb = SMFByteBufferPackedMesh.builder(); for (final Tuple2<Integer, ByteBuffer> p : this.attr_buffers) { mb.addAttributeSets(SMFByteBufferPackedAttributeSet.of( p._1.intValue(), this.config.get(p._1).get(), p._2)); } if (this.tri_buffer != null) { final SMFTriangles triangles = this.header.triangles(); mb.setTriangles(SMFByteBufferPackedTriangles.of( this.tri_buffer, triangles.triangleCount(), Math.toIntExact(triangles.triangleIndexSizeBits()))); } mb.setHeader(this.header); this.mesh = mb.build(); } }
/** * Check preconditions for the type. */ @Value.Check default void checkPreconditions() { { final long tri_lsize = (long) this.triangles().size(); final long tri_hcount = this.header().triangles().triangleCount(); Preconditions.checkPreconditionL( tri_lsize, tri_lsize == tri_hcount, x -> "Triangle list size must match header count"); } { this.arrays().forEach(p -> { final long array_lsize = (long) p._2.size(); final long array_hcount = this.header().vertexCount(); Preconditions.checkPreconditionL( array_lsize, array_lsize == array_hcount, x -> "Attribute array size must match header count"); }); } } }