void ZSparseObject::setVoxelValue(ZStack *stack) { #if defined(_USE_OPENVDB_2) #ifdef _DEBUG_2 stack->save(GET_TEST_DATA_DIR + "/test.tif"); #endif if (stack != NULL && stack->kind() == GREY) { int z0 = stack->getOffset().getZ(); int z1 = z0 + stack->depth() - 1; int y0 = stack->getOffset().getY(); int y1 = y0 + stack->height() - 1; int x0 = stack->getOffset().getX(); int x1 = x0 + stack->width() - 1; #ifdef _DEBUG_2 clear(); for (int y = y0; y <= y1; ++y) { addStripe(z0, y); addSegment(x0, x1); } #endif size_t area = stack->width() * stack->height(); uint8_t *array = stack->array8(); for (size_t i = 0; i < getStripeNumber(); ++i) { const ZObject3dStripe &stripe = getStripe(i); int y = stripe.getY(); int z = stripe.getZ(); if (IS_IN_CLOSE_RANGE(z, z0, z1) && IS_IN_CLOSE_RANGE(y, y0, y1)) { for (int j = 0; j < stripe.getSegmentNumber(); ++j) { int tx0 = imax2(x0, stripe.getSegmentStart(j)); int tx1 = imin2(x1, stripe.getSegmentEnd(j)); size_t offset = area * (z - z0) + stack->width() * (y - y0) + tx0 - x0; for (int x = tx0; x <= tx1; ++x) { m_voxelValueObject.setValue(x, y, z, array[offset++]); } } } } m_voxelValueObject.repack(); } #endif }
bool ZIntCuboid::containYZ(int y, int z) const { return IS_IN_CLOSE_RANGE(y, m_firstCorner.getY(), m_lastCorner.getY()) && IS_IN_CLOSE_RANGE(z, m_firstCorner.getZ(), m_lastCorner.getZ()); }