1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 package org.apache.commons.geometry.io.euclidean.threed.stl; 18 19 import java.util.List; 20 21 import org.apache.commons.geometry.euclidean.threed.Vector3D; 22 import org.apache.commons.geometry.io.euclidean.threed.SimpleFacetDefinition; 23 24 /** Facet definition class that provides access to the 2-byte attribute value 25 * stored with each triangle in the binary STL format. 26 */ 27 public class BinaryStlFacetDefinition extends SimpleFacetDefinition { 28 29 /** Attribute value for the facet (2 bytes). */ 30 private final int attributeValue; 31 32 /** Construct a new instance. 33 * @param vertices facet vertices 34 * @param normal facet normal 35 * @param attributeValue 2-byte attribute value 36 */ 37 public BinaryStlFacetDefinition(final List<Vector3D> vertices, final Vector3D normal, 38 final int attributeValue) { 39 super(vertices, normal); 40 this.attributeValue = attributeValue; 41 } 42 43 /** Get the 2-byte attribute value (known as the "attribute byte count") stored at the end of the STL 44 * facet definition binary representation. This value is typically set to zero but non-standard implementations 45 * may choose to store other values here. 46 * 47 * <p>The bytes are stored with the first byte in the upper portion (bits 8-15) of the int and the second byte 48 * in the lower portion (bits 0-7).</p> 49 * @return 2-byte attribute value for the facet 50 */ 51 public int getAttributeValue() { 52 return attributeValue; 53 } 54 }