// Return index for vertex on edge
TqInt bloomenthal_polygonizer::VerticeId(Corner *c1, Corner *c2)
// c1->value and c2->value are presumed one on each side of the equipotential surface
{
	TqInt vid = m_Edges.GetValue(Edge(c1->l, c2->l));
	if(vid != -1)
	{
		// Has been previously computed, return saved index
		return vid;
	}

	// Compute index, save and return it
	CqVector3D p;
	Converge(c1->p, c2->p, c1->value, p);
	m_Vertices.push_back(p);
	m_Normals.push_back(normal(p));

	vid = m_Vertices.size() - 1;
	m_Edges.push_back(Edge(c1->l, c2->l, vid));

	return vid;
}
Esempio n. 2
0
// Using two points of differing signs, converge to zero crossing
vec3 TImplicitSurface::Converge(const vec3& p1, const vec3& p2, int depth) const
{
    return Converge(p1, p2, eval(p1), depth);
}
Esempio n. 3
0
Generate()
{
	static int rsflag = 1;	/* flag cleared after restart		*/

	STRUCTURE *temp;	/* for swapping population pointers	*/
	register int i;		/* for marking structures		*/

	if (Traceflag)
		printf("                    Gen %d\n",Gen);
	Trace("Generate entered");

	/* create a new population */

	if (Restartflag && rsflag)
	{
		/* this is a restart so read checkpoint file */
		Restart();
		rsflag = 0;	/* disable local restart flag. */
		Converge();
	}

	else if (Gen == 0)
		/* this is a fresh experiment */
	{
		Initialize();	/* form an initial population */
		Spin++;	
	}

	else
		/* form a new population from */
		/* the old one via genetic operators */
	{
		Select();
		Mutate();
		Crossover();
		if (Eliteflag)
			Elitist();
		if (Allflag)	/* mark structures for evaluation */
			for (i=0; i<Popsize; i++) New[i].Needs_evaluation = 1;
		Spin++;
	}

	/* evaluate the newly formed population */
	Evaluate();

	/* gather performance statistics */
	Measure();

	/* check termination condition for this experiment	*/
	Doneflag = Done();

	/* checkpoint if appropriate */
	if (Num_dumps && Dump_freq && Gen % Dump_freq == 0)
	{
		if (Num_dumps > 1)
		{
			sprintf(Dumpfile, "dump.%d", Curr_dump);
			Curr_dump = (Curr_dump + 1) % Num_dumps;
			Checkpoint(Dumpfile);
		}
		Checkpoint(Ckptfile);
	}
	else
	{
		if (Doneflag)
		{
			if (Lastflag)
				Checkpoint(Ckptfile);
			else
				if (Savesize)
					Printbest();
		}
	}


	/* swap pointers for next generation */
	temp = Old;
	Old = New;
	New = temp;

	/* update generation counter */
	Gen++;

	Trace("Generate completed");
}