Subversion Repositories gelsvn

Rev

Rev 39 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 39 Rev 59
Line 74... Line 74...
74
	}
74
	}
75
 
75
 
76
	// Energy functionals
76
	// Energy functionals
77
	namespace
77
	namespace
78
	{
78
	{
79
		class EnergyFun
-
 
80
		{
-
 
81
		public:
-
 
82
			virtual double delta_energy(HalfEdgeIter) const = 0;
-
 
83
			virtual double energy(HalfEdgeIter) const {return 0;}
-
 
84
		};
-
 
85
 
79
 
86
 
80
 
87
		class ValencyEnergy: public EnergyFun
81
		class ValencyEnergy: public EnergyFun
88
		{
82
		{
89
		public:
83
		public:
Line 542... Line 536...
542
			for(VertexCirculator vc(vi); !vc.end(); ++vc)
536
			for(VertexCirculator vc(vi); !vc.end(); ++vc)
543
				{
537
				{
544
					add_to_queue(Q, vc.get_halfedge(), efun);
538
					add_to_queue(Q, vc.get_halfedge(), efun);
545
				}
539
				}
546
		}
540
		}
-
 
541
	}
547
 
542
 
548
		void priority_queue_optimization(Manifold& m, const EnergyFun& efun)
543
	void priority_queue_optimization(Manifold& m, const EnergyFun& efun)
549
		{
544
	{
550
			priority_queue<PQElem> Q;
545
		priority_queue<PQElem> Q;
551
			{
546
		{
Line 577... Line 572...
577
				}
572
			}
578
		}
573
	}
579
 
574
 
580
		void simulated_annealing_optimization(Manifold& m, 
575
	void simulated_annealing_optimization(Manifold& m, 
581
																					const EnergyFun& efun,
576
																				const EnergyFun& efun,
582
																					int max_iter=10000)
577
																				int max_iter)
583
		{
578
	{
584
			srand(0);
579
		srand(0);
585
			int swaps;
580
		int swaps;
586
			int iter = 0;
581
		int iter = 0;
587
			double T = 1;
582
		double T = 1;
Line 645... Line 640...
645
						T *= 0.9;
640
					T *= 0.9;
646
				}
641
			}
647
			while(++iter < max_iter && swaps);
642
		while(++iter < max_iter && swaps);
648
			cout << "Iterations "  << iter << endl; 
643
		cout << "Iterations "  << iter << endl; 
649
		}
644
	}
650
	}
645
	
651
 
646
 
652
	void minimize_dihedral_angle(Manifold& m, 
647
	void minimize_dihedral_angle(Manifold& m, 
653
															 int iter,
648
															 int iter,
654
															 bool anneal, 
649
															 bool anneal, 
655
															 bool alpha,
650
															 bool alpha,