examples/triangle/triangle.cpp
author Dmitriy Morozov <morozov@cs.duke.edu>
Thu, 21 Dec 2006 13:37:23 -0500
changeset 6 40adcff7b468
parent 5 ee9052408c40
child 9 4ed0ecccba8c
permissions -rw-r--r--
Removed missing tests/test-realtype from tests/SConscript

#include "filtration.h"
#include "simplex.h"
#include <vector>
#include <iostream>

typedef 		SimplexWithValue<int> 			Simplex;
typedef			Filtration<Simplex>				TriangleFiltration;

void fillTriangleSimplices(TriangleFiltration& f)
{
	typedef std::vector<int> VertexVector;
	VertexVector vertices(4);
	vertices[0] = 0; vertices[1] = 1; vertices[2] = 2; 
	vertices[3] = 0;
		
	VertexVector::const_iterator bg = vertices.begin();
	VertexVector::const_iterator end = vertices.end();
	f.append(Simplex(bg,     bg + 1, 0));				// 0 = A
	f.append(Simplex(bg + 1, bg + 2, 1));				// 1 = B
	f.append(Simplex(bg + 2, bg + 3, 2));				// 2 = C
	f.append(Simplex(bg,     bg + 2, 2.5));				// AB
	f.append(Simplex(bg + 1, bg + 3, 2.9));				// BC
	f.append(Simplex(bg + 2, end, 3.5));				// CA
	f.append(Simplex(bg,     bg + 3, 5));				// ABC
}

int main()
{
#ifdef CWDEBUG
	dionysus::debug::init();

	Debug(dc::filtration.on());
	Debug(dc::cycle.off());
	Debug(dc::vineyard.on());
	Debug(dc::transpositions.on());
#endif

	Evaluator<Simplex> e;
	TriangleFiltration::Vineyard v(&e);
	TriangleFiltration tf(&v);
	fillTriangleSimplices(tf);
	
	tf.fill_simplex_index_map();
	tf.pair_simplices(tf.begin(), tf.end());
	v.start_vines(tf.begin(), tf.end());
	
	std::cout << "Filtration size: " << tf.size() << std::endl;
	std::cout << tf << std::endl;

#if 1
	Simplex BC; BC.add(1); BC.add(2);
	Simplex AB; AB.add(0); AB.add(1);
	std::cout << BC << std::endl;
	std::cout << *tf.get_index(BC) << std::endl;
	tf.transpose(tf.get_index(BC));
	std::cout << tf;
	std::cout << AB << std::endl;
	std::cout << *tf.get_index(AB) << std::endl;
	tf.transpose(tf.get_index(AB));
	std::cout << tf;
#endif
}