@Override public void insertAttributes(int start, Point pt, int semantics, int validSize) { if (m_bReadonly) throw new GeometryException("invalid_call"); int comp = VertexDescription.getComponentCount(semantics); System.arraycopy(m_buffer, start, m_buffer, start + comp, validSize - start); for (int c = 0; c < comp; c++) { m_buffer[start + c] = (int) pt.getAttributeAsDbl(semantics, c); } }
/** * Returns value of the given vertex attribute's ordinate. The ordinate is always 0 because * integer attributes always have one component. * * @param semantics The attribute semantics. * @param ordinate The attribute's ordinate. For example, the y coordinate of the NORMAL has * ordinate of 1. * @return The ordinate value truncated to a 32 bit integer value. */ public int getAttributeAsInt(int semantics, int ordinate) { if (isEmptyImpl()) throw new GeometryException("This operation was performed on an Empty Geometry."); int ncomps = VertexDescription.getComponentCount(semantics); if (ordinate >= ncomps) throw new IndexOutOfBoundsException(); int attributeIndex = m_description.getAttributeIndex(semantics); if (attributeIndex >= 0) return (int) m_attributes[m_description._getPointAttributeOffset(attributeIndex) + ordinate]; else return (int) VertexDescription.getDefaultValue(semantics); }
/** * Sets the value of the attribute. * * @param semantics The attribute semantics. * @param ordinate The ordinate of the attribute. * @param value Is the array to write values to. The attribute type and the number of elements * must match the persistence type, as well as the number of components of the attribute. */ public void setAttribute(int semantics, int ordinate, double value) { _touch(); int ncomps = VertexDescription.getComponentCount(semantics); if (ncomps < ordinate) throw new IndexOutOfBoundsException(); int attributeIndex = m_description.getAttributeIndex(semantics); if (attributeIndex < 0) { addAttribute(semantics); attributeIndex = m_description.getAttributeIndex(semantics); } if (m_attributes == null) _setToDefault(); m_attributes[m_description._getPointAttributeOffset(attributeIndex) + ordinate] = value; }
@Override void _beforeDropAttributeImpl(int semantics) { _touch(); if (m_attributes == null) return; // _ASSERT(semantics != enum_value2(VertexDescription, Semantics, // POSITION)); int attributeIndex = m_description.getAttributeIndex(semantics); int offset = m_description._getPointAttributeOffset(attributeIndex); int comps = VertexDescription.getComponentCount(semantics); int totalCompsOld = m_description._getTotalComponents(); if (totalCompsOld > comps) { for (int i = offset + comps; i < totalCompsOld; i++) m_attributes[i - comps] = m_attributes[i]; } }
@Override void _afterAddAttributeImpl(int semantics) { _touch(); if (m_attributes == null) return; int attributeIndex = m_description.getAttributeIndex(semantics); int offset = m_description._getPointAttributeOffset(attributeIndex); int comps = VertexDescription.getComponentCount(semantics); int totalComps = m_description._getTotalComponents(); resizeAttributes(totalComps); for (int i = totalComps - 1; i >= offset + comps; i--) m_attributes[i] = m_attributes[i - comps]; double dv = VertexDescription.getDefaultValue(semantics); for (int i = 0; i < comps; i++) m_attributes[offset + i] = dv; }