Beispiel #1
0
void initializeCellSpace(int size) {
    auto cs = CellNodeSpace<DIMS>();
    cs.initWithOneCell(size);
    CHECK("Has only one cell", cs.countCells() == 1);
    auto bounds = cs.getBounds();
    CHECK("Is cube", bounds.isCube());
    CHECK("Has correct size", bounds.getSide() == 1<<size);
}
Beispiel #2
0
    void glSubImage(int level, Vector2i const &pos, Size const &size,
                    GLPixelFormat const &glFormat, void const *data, CubeFace face = PositiveX)
    {
        if(data) glPixelStorei(GL_UNPACK_ALIGNMENT, glFormat.rowAlignment);
        glTexSubImage2D(isCube()? glFace(face) : texTarget,
                        level, pos.x, pos.y, size.x, size.y,
                        glFormat.format, glFormat.type, data);

        LIBGUI_ASSERT_GL_OK();
    }
Beispiel #3
0
String Utils::GeoProperties(Geo * g) {
    char fd[65536];
    sprintf(fd,"#geometry\n");
    if (g->group) {
        sprintf(fd, "%sobj group ", fd);
        for(unsigned int j=0;j<g->objs.size();j++) sprintf(fd, "%s%s ", fd, g->objs[j]->name.c_str()); 
        sprintf(fd, "%s\n", fd); 
    } else if (g->copy) sprintf(fd, "%scopy %s %s\n",fd, g->Target->name.c_str(), g->Template->name.c_str()); 
    else if (P(g) && (P(g)->filepath.size() > 0)) sprintf(fd,"%sfile %s\n", fd,P(g)->filepath.c_str());
    else if (isSphere(g)) {
        sprintf(fd, "%sadd sphere\n", fd);
    } else if (isCube(g)) {
        sprintf(fd, "%sadd cube\n", fd);
    } else if (isGrid(g)) {
        Grid * grid = (Grid*)g;
        sprintf(fd, "%sadd grid %d %d %f %f %f\n", fd, grid->dx, grid->dz, grid->segmentSize, grid->tx, grid->tz);
    } else if (P(g) && !CV(g)) {
        P(g)->filepath = String(String("objects/objs/") + g->name + String(".obj"));
        P(g)->writeOBJ(P(g)->filepath);
        sprintf(fd,"%sfile %s\n", fd,P(g)->filepath.c_str());
    } else if (CV(g)) {
        sprintf(fd, "%sbegin draw\n", fd);
        for(unsigned int i=0;i<CV(g)->points.size();i++) {
            sprintf(fd, "%s%f %f %f\n", fd, CV(g)->points[i].x, CV(g)->points[i].y, CV(g)->points[i].z);
        }
        sprintf(fd, "%send\n", fd);
    } else sprintf(fd, "%sadd geo\n", fd);
    sprintf(fd,"%sname %s\n", fd,g->name.c_str());
    if (g->history.size() > 0) {
        for(unsigned int i=0;i<g->history.size();i++) {
            sprintf(fd, "%s%s\n", fd, g->history[i].c_str());
        }
    }
    if (g->child) {
        sprintf(fd, "%sobj child %s %s\n", fd, g->parent->name.c_str(), g->name.c_str());
    }
    sprintf(fd,"%sdiffuse %f %f %f %f\n", fd,g->diffuse[0], g->diffuse[1], g->diffuse[2], g->diffuse[3]);
    sprintf(fd,"%sspecular %f %f %f %f\n", fd,g->specular[0], g->specular[1], g->specular[2], g->specular[3]);
    sprintf(fd,"%sambient %f %f %f %f\n", fd,g->ambient[0], g->ambient[1], g->ambient[2], g->ambient[3]);
    sprintf(fd,"%sreflection %f %f %f\n", fd,g->reflection[0], g->reflection[1], g->reflection[2]);
    sprintf(fd,"%srefraction %f\n", fd,g->refractiveIndex);
    sprintf(fd,"%sshininess %f \n", fd, g->shininess[0]);
    sprintf(fd,"%semission %f %f %f %f\n", fd,g->emission[0], g->emission[1], g->emission[2], g->emission[3]);
    sprintf(fd,"%s%s\n", fd, (matrix(O(g))).c_str());
    if (g->tex) sprintf(fd,"%stexture %s\n", fd,g->tex->filepath.c_str());
    String f(fd);
    return f;
}
Beispiel #4
0
Datei: find.c Projekt: yumendy/OJ
int main(int argc, char const *argv[])
{
	int m, n, a, b, p, q, i, j, k, flag, cube[51], ls[100][2], seq[10], Case = 0;
	for (i = 0; i <= 50; ++i)
	{
		cube[i] = i * i * i;
		printf("%d\t", cube[i]);
	}

	while(scanf("%d%d",&n,&m) && (n != 0 || m != 0))
	{
		printf("Case %d:\n", Case++);
		flag = 0;
		for (p = 0; p <= m; p++)
		{
			for (q = 1; q <= m; q++)
			{
				a = cube[p] + cube[q];
				printf("%d\n", a);
				for (b = 1; b <= (2 * cube[m] - a) / n; ++b)
				{
					for (k = 1; k < n; ++k)
					{
						if (!isCube(cube,a + n * b))
						{
							break;
						}
						ls[flag++][0] = a;
						ls[flag - 1][1] = b;
					}
				}
			}
		}
		if (!flag)
		{
			printf("NONE\n");
		}
		else
		{
			qsort(ls,flag,sizeof(ls),cmp);
			for (i = 0; i < flag; ++i)
			{
				printf("%d %d\n", ls[0],ls[1]);
			}
		}
	}
	return 0;
}
Beispiel #5
0
    void glSubImage(int level, Rectanglei const &rect, Image const &image,
                    CubeFace face = PositiveX)
    {
        auto const &glFormat = image.glFormat();

        LIBGUI_GL.glPixelStorei(GL_UNPACK_ALIGNMENT,  GLint(glFormat.rowAlignment));
        LIBGUI_GL.glPixelStorei(GL_UNPACK_ROW_LENGTH, GLint(image.width()));

        int const bytesPerPixel = image.depth() / 8;

        LIBGUI_GL.glTexSubImage2D(isCube()? glFace(face) : texTarget,
                                  level, rect.left(), rect.top(), rect.width(), rect.height(),
                                  glFormat.format, glFormat.type,
                                  static_cast<dbyte const *>(image.bits()) +
                                  bytesPerPixel * rect.left() + image.stride() * rect.top());

        LIBGUI_GL.glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);

        LIBGUI_ASSERT_GL_OK();
    }
Beispiel #6
0
    void glImage(int level, Size const &size, GLPixelFormat const &glFormat,
                 void const *data, CubeFace face = PositiveX)
    {
        /// @todo GLES2: Check for the BGRA extension.

        // Choose suitable informal format.
        GLenum const internalFormat =
                (glFormat.format == GL_BGRA?          GL_RGBA :
                 glFormat.format == GL_DEPTH_STENCIL? GL_DEPTH24_STENCIL8 :
                                                      glFormat.format);

        /*qDebug() << "glTexImage2D:" << name << (isCube()? glFace(face) : texTarget)
                << level << internalFormat << size.x << size.y << 0
                << glFormat.format << glFormat.type << data;*/

        if(data) glPixelStorei(GL_UNPACK_ALIGNMENT, glFormat.rowAlignment);
        glTexImage2D(isCube()? glFace(face) : texTarget,
                     level, internalFormat, size.x, size.y, 0,
                     glFormat.format, glFormat.type, data);

        LIBGUI_ASSERT_GL_OK();
    }
VkImageCreateInfo makeImageCreateInfo (const Texture& texture, const VkFormat format, const VkImageUsageFlags usage, const VkImageCreateFlags flags)
{
	const VkSampleCountFlagBits samples = static_cast<VkSampleCountFlagBits>(texture.numSamples());	// integer and bit mask are aligned, so we can cast like this

	const VkImageCreateInfo imageParams =
	{
		VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,														// VkStructureType			sType;
		DE_NULL,																					// const void*				pNext;
		(isCube(texture) ? (VkImageCreateFlags)VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT : 0u) | flags,	// VkImageCreateFlags		flags;
		mapImageType(texture.type()),																// VkImageType				imageType;
		format,																						// VkFormat					format;
		makeExtent3D(texture.layerSize()),															// VkExtent3D				extent;
		1u,																							// deUint32					mipLevels;
		(deUint32)texture.numLayers(),																// deUint32					arrayLayers;
		samples,																					// VkSampleCountFlagBits	samples;
		VK_IMAGE_TILING_OPTIMAL,																	// VkImageTiling			tiling;
		usage,																						// VkImageUsageFlags		usage;
		VK_SHARING_MODE_EXCLUSIVE,																	// VkSharingMode			sharingMode;
		0u,																							// deUint32					queueFamilyIndexCount;
		DE_NULL,																					// const deUint32*			pQueueFamilyIndices;
		VK_IMAGE_LAYOUT_UNDEFINED,																	// VkImageLayout			initialLayout;
	};
	return imageParams;
}
Beispiel #8
0
int main()
{
    int N, K, i, j, m;
    unsigned long long int totalSum = 0, oldSum = 0, cubeCount=0;

    scanf ("%d %d", &N, &K);

    //unsigned long int grid[1001][1001];
    /* allocate 2D array */
    unsigned long int **grid = (unsigned long int **) malloc (N_SIZE_MAX * sizeof (unsigned long int *));

    for (i = 0; i < N_SIZE_MAX; i++)
        grid[i] = (unsigned long int *) malloc (N_SIZE_MAX * sizeof (unsigned long int));

    for (i = 0; i < N; i++)
        for (j = 0; j < N; j++)
            scanf ("%lu", &grid[i][j]);

    printf ("%lu K:%d\n", grid[2][1],K); //d

    totalSum=0;
    
    /* intial sum */
    for (i = 0; i < K; i++)
        for (j = 0; j < K; j++)
	{
            totalSum += grid[i][j];
	    printf("ts: %ld\n",totalSum);//d
	}

//    printf("sum: %llu\n",totalSum);//d
    
//    if(isCube(totalSum))
//	cubeCount++;
    
    oldSum=totalSum;		/* save the sum of (0,0) K-matrix */
    
    /* start from (0,0) */
    for (i = 0, j = 0; i < (N - K + 1); i++)
    {
        if (i > 0)
        {			/* calculate new row[0] value 
				   of K-matrix sum */
	    totalSum=oldSum;
	    
	    /* calculate by subtract and add */
            for (m = 0; m < K; m++)
            {
                totalSum -= grid[i - 1][m];
                totalSum += grid[i + K - 1][m];
            }

	    oldSum=totalSum;
        }
	printf("sum: %llu\n",totalSum);//d
	/* check if cube */
        if (isCube (totalSum))
            cubeCount++;

        for (j = 0; j < (N - K); j++)
        {
            /* subtract line and add */
            for (m = 0; m < K; m++)
            {
                totalSum -= grid[i + m][j];
                totalSum += grid[i + m][j + K];
            }
	    printf("sum: %llu\n",totalSum);//d
            /* check */
            if (isCube (totalSum))
                cubeCount++;
        }
    }

    printf("cubeCount: %llu\n",cubeCount);//d
    return 0;
}