/** * Set the X and Y coordinate of the point. * * @param x * X coordinate of the point. * @param y * Y coordinate of the point. */ public void setXY(double x, double y) { _touch(); if (m_attributes == null) _setToDefault(); m_attributes[0] = x; m_attributes[1] = y; }
/** * Set the X and Y coordinate of the point. * * @param x * X coordinate of the point. * @param y * Y coordinate of the point. */ public void setXY(double x, double y) { _touch(); if (m_attributes == null) _setToDefault(); m_attributes[0] = x; m_attributes[1] = y; }
/** * 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; }
/** * Sets the XYZ coordinates of this point. * * @param pt * The point to create the XYZ coordinate from. */ public void setXYZ(Point3D pt) { _touch(); boolean bHasZ = hasAttribute(Semantics.Z); if (!bHasZ && !VertexDescription.isDefaultValue(Semantics.Z, pt.z)) {// add // Z // only // if // pt.z // is // not // a // default // value. addAttribute(Semantics.Z); bHasZ = true; } if (m_attributes == null) _setToDefault(); m_attributes[0] = pt.x; m_attributes[1] = pt.y; if (bHasZ) m_attributes[2] = pt.z; }
/** * Sets the XYZ coordinates of this point. * * @param pt * The point to create the XYZ coordinate from. */ public void setXYZ(Point3D pt) { _touch(); boolean bHasZ = hasAttribute(Semantics.Z); if (!bHasZ && !VertexDescription.isDefaultValue(Semantics.Z, pt.z)) {// add // Z // only // if // pt.z // is // not // a // default // value. addAttribute(Semantics.Z); bHasZ = true; } if (m_attributes == null) _setToDefault(); m_attributes[0] = pt.x; m_attributes[1] = pt.y; if (bHasZ) m_attributes[2] = pt.z; }
/** * 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 public Point getPoint(int index) { if (index < 0 || index >= m_pointCount) throw new IndexOutOfBoundsException(); _verifyAllStreams(); Point outPoint = new Point(); outPoint.assignVertexDescription(m_description); if (outPoint.isEmpty()) outPoint._setToDefault(); for (int attributeIndex = 0; attributeIndex < m_description .getAttributeCount(); attributeIndex++) { int semantics = m_description.getSemantics(attributeIndex); for (int icomp = 0, ncomp = VertexDescription .getComponentCount(semantics); icomp < ncomp; icomp++) { double v = m_vertexAttributes[attributeIndex].readAsDbl(ncomp * index + icomp); outPoint.setAttribute(semantics, icomp, v); } } return outPoint; }
@Override public Point getPoint(int index) { if (index < 0 || index >= m_pointCount) throw new IndexOutOfBoundsException(); _verifyAllStreams(); Point outPoint = new Point(); outPoint.assignVertexDescription(m_description); if (outPoint.isEmpty()) outPoint._setToDefault(); for (int attributeIndex = 0; attributeIndex < m_description .getAttributeCount(); attributeIndex++) { int semantics = m_description.getSemantics(attributeIndex); for (int icomp = 0, ncomp = VertexDescription .getComponentCount(semantics); icomp < ncomp; icomp++) { double v = m_vertexAttributes[attributeIndex].readAsDbl(ncomp * index + icomp); outPoint.setAttribute(semantics, icomp, v); } } return outPoint; }
private void _get(int endPoint, Point outPoint) { if (isEmptyImpl()) throw new GeometryException("empty geometry");// ._setToDefault(); outPoint.assignVertexDescription(m_description); if (outPoint.isEmptyImpl()) outPoint._setToDefault(); for (int attributeIndex = 0; attributeIndex < m_description .getAttributeCount(); attributeIndex++) { int semantics = m_description._getSemanticsImpl(attributeIndex); for (int icomp = 0, ncomp = VertexDescription .getComponentCount(semantics); icomp < ncomp; icomp++) { double v = _getAttributeAsDbl(endPoint, semantics, icomp); outPoint.setAttribute(semantics, icomp, v); } } }
private void _get(int endPoint, Point outPoint) { if (isEmptyImpl()) throw new GeometryException("empty geometry");// ._setToDefault(); outPoint.assignVertexDescription(m_description); if (outPoint.isEmptyImpl()) outPoint._setToDefault(); for (int attributeIndex = 0; attributeIndex < m_description .getAttributeCount(); attributeIndex++) { int semantics = m_description._getSemanticsImpl(attributeIndex); for (int icomp = 0, ncomp = VertexDescription .getComponentCount(semantics); icomp < ncomp; icomp++) { double v = _getAttributeAsDbl(endPoint, semantics, icomp); outPoint.setAttribute(semantics, icomp, v); } } }
@Override public void getPointByVal(int index, Point dst) { if (index < 0 || index >= m_pointCount) // TODO throw new GeometryException("index out of bounds"); // _ASSERT(!IsEmpty()); // _ASSERT(m_vertexAttributes != null); _verifyAllStreams(); Point outPoint = dst; outPoint.assignVertexDescription(m_description); if (outPoint.isEmpty()) outPoint._setToDefault(); for (int attributeIndex = 0; attributeIndex < m_description .getAttributeCount(); attributeIndex++) { // fix semantics int semantics = m_description._getSemanticsImpl(attributeIndex); // VertexDescription.getComponentCount(semantics); for (int icomp = 0, ncomp = VertexDescription .getComponentCount(semantics); icomp < ncomp; icomp++) { double v = m_vertexAttributes[attributeIndex].readAsDbl(ncomp * index + icomp); outPoint.setAttribute(semantics, icomp, v); } } }
@Override public void getPointByVal(int index, Point dst) { if (index < 0 || index >= m_pointCount) // TODO throw new GeometryException("index out of bounds"); // _ASSERT(!IsEmpty()); // _ASSERT(m_vertexAttributes != null); _verifyAllStreams(); Point outPoint = dst; outPoint.assignVertexDescription(m_description); if (outPoint.isEmpty()) outPoint._setToDefault(); for (int attributeIndex = 0; attributeIndex < m_description .getAttributeCount(); attributeIndex++) { // fix semantics int semantics = m_description._getSemanticsImpl(attributeIndex); // VertexDescription.getComponentCount(semantics); for (int icomp = 0, ncomp = VertexDescription .getComponentCount(semantics); icomp < ncomp; icomp++) { double v = m_vertexAttributes[attributeIndex].readAsDbl(ncomp * index + icomp); outPoint.setAttribute(semantics, icomp, v); } } }
void _interpolateTwoVertices(int vertex1, int vertex2, double f, Point outPoint) { if (vertex1 < 0 || vertex1 >= m_pointCount) throw new GeometryException("index out of bounds."); if (vertex2 < 0 || vertex2 >= m_pointCount) throw new GeometryException("index out of bounds."); // _ASSERT(!IsEmpty()); // _ASSERT(m_vertexAttributes != NULLPTR); _verifyAllStreams(); outPoint.assignVertexDescription(m_description); if (outPoint.isEmpty()) outPoint._setToDefault(); for (int attributeIndex = 0; attributeIndex < m_description .getAttributeCount(); attributeIndex++) { int semantics = m_description._getSemanticsImpl(attributeIndex); for (int icomp = 0, ncomp = VertexDescription .getComponentCount(semantics); icomp < ncomp; icomp++) { double v1 = m_vertexAttributes[attributeIndex].readAsDbl(ncomp * vertex1 + icomp); double v2 = m_vertexAttributes[attributeIndex].readAsDbl(ncomp * vertex2 + icomp); outPoint.setAttribute(semantics, icomp, MathUtils.lerp(v1, v2, f)); } } }
void _interpolateTwoVertices(int vertex1, int vertex2, double f, Point outPoint) { if (vertex1 < 0 || vertex1 >= m_pointCount) throw new GeometryException("index out of bounds."); if (vertex2 < 0 || vertex2 >= m_pointCount) throw new GeometryException("index out of bounds."); // _ASSERT(!IsEmpty()); // _ASSERT(m_vertexAttributes != NULLPTR); _verifyAllStreams(); outPoint.assignVertexDescription(m_description); if (outPoint.isEmpty()) outPoint._setToDefault(); for (int attributeIndex = 0; attributeIndex < m_description .getAttributeCount(); attributeIndex++) { int semantics = m_description._getSemanticsImpl(attributeIndex); for (int icomp = 0, ncomp = VertexDescription .getComponentCount(semantics); icomp < ncomp; icomp++) { double v1 = m_vertexAttributes[attributeIndex].readAsDbl(ncomp * vertex1 + icomp); double v2 = m_vertexAttributes[attributeIndex].readAsDbl(ncomp * vertex2 + icomp); outPoint.setAttribute(semantics, icomp, MathUtils.lerp(v1, v2, f)); } } }