inline
void
SlicedCurvilinear<ScalarParam,dimensionParam,ValueScalarParam>::setGrid(
	const typename SlicedCurvilinear<ScalarParam,dimensionParam,ValueScalarParam>::Index& sNumVertices,
	const typename SlicedCurvilinear<ScalarParam,dimensionParam,ValueScalarParam>::Point* sVertexPositions)
	{
	/* Resize the vertex array: */
	numVertices=sNumVertices;
	grid.resize(numVertices);
	
	initStructure();
	
	/* Resize all value slices: */
	for(int sliceIndex=0;sliceIndex<numSlices;++sliceIndex)
		slices[sliceIndex].resize(numVertices);
	
	/* Copy source vertex positions, if present: */
	if(sVertexPositions!=0)
		{
		/* Copy all grid vertex positions: */
		size_t totalNumVertices=numVertices.calcIncrement(-1);
		Point* vPtr=grid.getArray();
		for(size_t i=0;i<totalNumVertices;++i)
			vPtr[i]=sVertexPositions[i];
		
		/* Finalize grid structure: */
		finalizeGrid();
		}
	}
inline
SlicedCurvilinear<ScalarParam,dimensionParam,ValueScalarParam>::SlicedCurvilinear(
	const typename SlicedCurvilinear<ScalarParam,dimensionParam,ValueScalarParam>::Index& sNumVertices,
	int sNumSlices,
	const typename SlicedCurvilinear<ScalarParam,dimensionParam,ValueScalarParam>::Point* sVertexPositions)
	:numVertices(sNumVertices),
	 grid(numVertices),
	 numSlices(sNumSlices),slices(new ValueArray[numSlices]),
	 locatorEpsilon(Scalar(1.0e-4))
	{
	initStructure();
	
	/* Resize all value slices: */
	for(int sliceIndex=0;sliceIndex<numSlices;++sliceIndex)
		slices[sliceIndex].resize(numVertices);
	
	/* Copy source vertex positions, if present: */
	if(sVertexPositions!=0)
		{
		/* Copy all grid vertex positions: */
		int totalNumVertices=grid.getNumElements();
		Point* vPtr=grid.getArray();
		for(int i=0;i<totalNumVertices;++i)
			vPtr[i]=sVertexPositions[i];
		
		/* Finalize grid structure: */
		finalizeGrid();
		}
	}
Ejemplo n.º 3
0
// Test case: TestLookUp:1
// This test calls lookUp() for the condition where 
// the query has an OR operator. 
int TestLookUp1() {
  START_TEST_CASE;
  INVERTED_INDEX* testIndex = NULL;

  int wordHash;
  int wordHash2;
  testIndex = initStructure(testIndex);

  wordHash = hash1("dog") % MAX_NUMBER_OF_SLOTS;
  DocumentNode* docNode = NULL;
  docNode = newDocNode(docNode, 15, 1);

  WordNode* wordNode = NULL;
  wordNode = newWordNode(wordNode, docNode, "dog");
  testIndex->hash[wordHash] = wordNode;


  wordHash2 = hash1("cat") % MAX_NUMBER_OF_SLOTS;
  DocumentNode* docNode2 = NULL;
  docNode2 = newDocNode(docNode2, 20, 2);

  WordNode* wordNode2 = NULL;
  wordNode2 = newWordNode(wordNode2, docNode2, "cat");

  testIndex->hash[wordHash2] = wordNode2;

  char query[1000] = "dog OR cat";
  sanitize(query);

  char* temp[1000];
  BZERO(temp, 1000);

  char* queryList[2];
  BZERO(queryList, 2);

  curateWords(queryList, query);
  SHOULD_BE(strcmp(queryList[0],"dog") == 0);
  SHOULD_BE(strcmp(queryList[1],"OR") == 0);
  SHOULD_BE(strcmp(queryList[2],"cat") == 0);

  DocumentNode* saved[1000];
  BZERO(saved, 1000);
  lookUp(saved, queryList, testIndex);

  SHOULD_BE(saved[0]->document_id == docNode->document_id);
  SHOULD_BE(saved[0]->page_word_frequency == docNode->page_word_frequency);
  SHOULD_BE(saved[1]->document_id == docNode2->document_id);
  SHOULD_BE(saved[1]->page_word_frequency == docNode2->page_word_frequency);
  
  cleanUpList(saved);
  cleanUpQueryList(queryList);
  BZERO(saved, 1000);

  cleanUpIndex(testIndex);

  END_TEST_CASE;
}
Ejemplo n.º 4
0
BoxGrid::BoxGrid(const Mesh & mesh,const int res,string filename)
{
	initRes(res);
	if(exists(filename))
		initFromFile(filename);
	else
		initVoxels(mesh,res);
	initStructure();
	compute();
}
Ejemplo n.º 5
0
// Test case: TestStructure:1
// This test case calls initStructure() and checks to make sure 
// search engine can initialize the basic inverted index structure
int TestStructure1(){
  START_TEST_CASE;
  LOG("Initializing INVERTED INDEX structure");

  indexReload = initStructure(indexReload);
  SHOULD_BE(indexReload != NULL);

  cleanUpIndex(indexReload);
  END_TEST_CASE;
}
Ejemplo n.º 6
0
void main(int argc, char **argv)
{
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
	glutInitWindowPosition(10,10);
	glutInitWindowSize(512,512);

	glutCreateWindow("LinePrimitives Demo");
	glutDisplayFunc(renderScene);
	glutIdleFunc(renderScene);

	glutReshapeFunc(changeSize);

	glutKeyboardFunc(processNormalKeys);
	glutMouseFunc(processMouse);
	glutMotionFunc(processMouseActiveMotion);

	glEnable(GL_DEPTH_FUNC);

	if (glewInit() == GLEW_OK)
	{
		if (!GLEW_ARB_multitexture)
			return;

		// load shader
		lineShader = new CShader();
		lineShader->InitShaders("VertexShader.glsl", "FragmentShader.glsl");

		lineShader->TurnOn();
		profile = lineShader->GetVariable("profile");
		texture = lineShader->GetVariable("texture");
		haloColor = lineShader->GetVariable("haloColor");

		lineShader->TurnOff();

		initStructure();
		initTextures();

		glutMainLoop();

		lineShader->Release();
		delete lineShader;
	}
	else
	{
		printf("This sucks.");
	}
}
Ejemplo n.º 7
0
TwoTrapezoids::TwoTrapezoids(double xrot,double yrot,double zrot):Polyhedron(xrot,yrot,zrot,vertexNum)
{
    initStructure();
    initAtts();
    setValues();
}
Ejemplo n.º 8
0
TwoTrapezoids::TwoTrapezoids():Polyhedron(vertexNum)
{
    initStructure();
    initAtts();
    setValues();
}
Ejemplo n.º 9
0
sSuperStruct createSfs(char* name, int16_t taille){
	sSuperStruct sfs;
	sfs=initStructure(name, taille);

	return sfs;
}
Ejemplo n.º 10
0
// Test case: TestLookUp:5
// This test calls lookUp() for the condition where 
// the query has both AND and OR
int TestLookUp5() {
  START_TEST_CASE;
  INVERTED_INDEX* testIndex = NULL;

  int wordHash;
  int wordHash2;
  int wordHash3;
  int wordHash4;
  testIndex = initStructure(testIndex);

  wordHash = hash1("dog") % MAX_NUMBER_OF_SLOTS;
  DocumentNode* docNode = NULL;
  docNode = newDocNode(docNode, 15, 1);

  WordNode* wordNode = NULL;
  wordNode = newWordNode(wordNode, docNode, "dog");
  testIndex->hash[wordHash] = wordNode;


  wordHash2 = hash1("cat") % MAX_NUMBER_OF_SLOTS;
  DocumentNode* docNode2 = NULL;
  docNode2 = newDocNode(docNode2, 15, 2);

  WordNode* wordNode2 = NULL;
  wordNode2 = newWordNode(wordNode2, docNode2, "cat");

  testIndex->hash[wordHash2] = wordNode2;

  wordHash3 = hash1("mouse") % MAX_NUMBER_OF_SLOTS;
  DocumentNode* docNode3 = NULL;
  docNode3 = newDocNode(docNode3, 23, 2);

  WordNode* wordNode3 = NULL;
  wordNode3 = newWordNode(wordNode3, docNode3, "mouse");

  testIndex->hash[wordHash3] = wordNode3;

  wordHash4 = hash1("lion") % MAX_NUMBER_OF_SLOTS;
  DocumentNode* docNode4 = NULL;
  docNode4 = newDocNode(docNode4, 23, 2);

  WordNode* wordNode4 = NULL;
  wordNode4 = newWordNode(wordNode4, docNode4, "lion");

  testIndex->hash[wordHash4] = wordNode4;

  char query[1000] = "dog cat OR mouse lion";
  sanitize(query);

  char* temp[1000];
  BZERO(temp, 1000);

  char* queryList[1000];
  BZERO(queryList, 1000);

  curateWords(queryList, query);

  DocumentNode* saved[1000];
  BZERO(saved, 1000);
  lookUp(saved, queryList, testIndex);

  SHOULD_BE(saved[0]->document_id == docNode->document_id);
  SHOULD_BE(saved[0]->page_word_frequency == 3);
  SHOULD_BE(saved[1]->document_id == docNode3->document_id);
  SHOULD_BE(saved[1]->page_word_frequency == 4);
  
  cleanUpList(saved);
  cleanUpQueryList(queryList);
  BZERO(saved, 1000);

  cleanUpIndex(testIndex);

  END_TEST_CASE;
}
Ejemplo n.º 11
0
void create(){
  indexReload = initStructure(indexReload);
  LOG("Initializing INVERTED INDEX structure");
}