void mitk::PointSetIndexToWorldTransformFilter::GenerateData()
{
  mitk::PointSet::ConstPointer input  = this->GetInput();
  mitk::PointSet::Pointer output  = this->GetOutput();

  typedef std::vector<mitk::Point3D> PointContainer;
  PointContainer points;
  int pointNo = 0;

  while(pointNo!= input->GetSize())
  {
    mitk::Point3D current = input->GetPoint(pointNo);
    points.push_back(current);
    pointNo++;
  }
  output->GetGeometry()->SetIdentity();
  PointContainer::iterator pointsIter = points.begin();

  pointNo = 0;
  while(pointsIter != points.end())
  {
    output->SetPoint(pointNo,(*pointsIter));
    pointNo++;
    pointsIter++;
  }

}
int main(int argc, char** argv) 
{
	// Read in the point set and compute its Delaunay triangulation
	std::istream& in = std::cin;
	int ambient_d, homology_d;	
	in >> ambient_d >> homology_d;
	
	std::cout << "Ambient dimension: " << ambient_d << std::endl;
	std::cout << "Will compute PD up to dimension: " << homology_d << std::endl;
	
	// Read points
	PointContainer points;
	while(in)
	{
		Point p(ambient_d);
		for (int i = 0; i < ambient_d; ++i)
			in >> p[i];
		points.push_back(p);
	}
	std::cout << "Points read: " << points.size() << std::endl;
   
	// Compute Cech values
	CechFiltration cf;
	{										// resource acquisition is initialization
		SimplexVector	sv;
		int num_simplices = 0;
		for (int i = 0; i <= homology_d + 1; ++i)
			num_simplices += choose(points.size(), i+1);
		sv.reserve(num_simplices);
		std::cout << "Reserved SimplexVector of size: " << num_simplices << std::endl;

		for (int i = 0; i <= homology_d + 1; ++i)
			add_simplices(sv, i, points);
		std::cout << "Size of SimplexVector: " << sv.size() << std::endl;
			
		std::sort(sv.begin(), sv.end(), DimensionValueComparison());
		
		for (SimplexVector::const_iterator cur = sv.begin(); cur != sv.end(); ++cur)
			cf.append(*cur);
	}

	// Compute persistence
	cf.fill_simplex_index_map();
	cf.pair_simplices(cf.begin(), cf.end());
	std::cout << "Simplices paired" << std::endl;

	for (CechFiltration::Index i = cf.begin(); i != cf.end(); ++i)
		if (i->is_paired())
		{
			if (i->sign())
				std::cout << i->dimension() << " " << i->get_value() << " " << i->pair()->get_value() << std::endl;
		} //else std::cout << i->value() << std::endl;

}
示例#3
0
PointContainer knn(const PointContainer& container, const Point& data, int k)
{
  std::map<float, Point> point_map;
  for(PointContainer::const_iterator it = container.begin(); it != container.end(); ++it)
  {
    point_map[euclidian(data, *it)] = *it;
  }

  PointContainer result;
  std::map<float, Point>::const_iterator it = point_map.begin();
  for(int i = 0; i < k; ++i)
  {
    result.push_back(it->second);
    ++it;
  }
  return result;
}
示例#4
0
PointContainer generate(long size)
{
  PointContainer data;

  boost::mt19937 engine(static_cast<long unsigned int>(clock()));
  boost::normal_distribution<double> generator;
  boost::variate_generator<boost::mt19937, boost::normal_distribution<double> > binded(engine, generator);

  for(long i = 0; i < size; ++i)
  {
    Point point;
    for(long j = 0; j < POINTSIZE; ++j)
    {
      point.push_back(binded());
    }
    data.push_back(point);
  }

  return data;
}