int main()
{
  std::vector<Point> points;
  points.push_back(Point(0,0));
  points.push_back(Point(1,0));
  points.push_back(Point(0,1));
  points.push_back(Point(4,10));
  points.push_back(Point(2,2));
  points.push_back(Point(-1,0));

  
  Delaunay T;
  T.insert( boost::make_transform_iterator(points.begin(),Auto_count()),
            boost::make_transform_iterator(points.end(),  Auto_count() )  );

  CGAL_assertion( T.number_of_vertices() == 6 );
  
  // check that the info was correctly set.
  Delaunay::Finite_vertices_iterator vit;
  for (vit = T.finite_vertices_begin(); vit != T.finite_vertices_end(); ++vit)
    if( points[ vit->info() ] != vit->point() ){
      std::cerr << "Error different info" << std::endl;
      exit(EXIT_FAILURE);
    }
  std::cout << "OK" << std::endl;
  
  return 0;
}
예제 #2
0
파일: B2.cpp 프로젝트: piotrmwojcik/AA
void addNearest(Delaunay &T)
{
      Delaunay::Finite_vertices_iterator vit;

    for (vit = T.finite_vertices_begin(); vit != T.finite_vertices_end();++vit)
    {
    
        Delaunay::Vertex_circulator vit2, done;
        std::vector <Vertex_handle> L;
        vit2 = vit->incident_vertices();
        done = vit2;
        do {
            if (T.is_infinite(vit2)) continue;
            std::stringstream ss1, ss2;
            int a, b;

            ss1 << vit->info();
            ss2 << vit2->info();


            ss1 >> a; ss2 >> b;

            if (b == a) continue;

           G[a].push_back(b);

        } while (++vit2 != done);


    }

}
예제 #3
0
void SparseVectorField::triangulate()
{
  Delaunay dt;
  Delaunay::Finite_edges_iterator eIter;
  Delaunay::Finite_faces_iterator fIter;
  vector< Point >::const_iterator fpIter;
  int i;
  map< Delaunay::Vertex_handle, int > V;
  map< Point, int > Vi;
  Delaunay::Finite_vertices_iterator vIter;
  
  dt.insert(startPoints_.begin(), startPoints_.end());
  
  // Map each vertex to its index.
  for(int i = 0; i < startPoints_.size(); i++)
    Vi[startPoints_[i]] = i;
  
  // Map vertices in the Delaunay triangulation to the original vertices.
  for(vIter = dt.finite_vertices_begin(); vIter != dt.finite_vertices_end(); vIter++)
    V[vIter] = Vi[Point(vIter->point().x(), vIter->point().y())];
  
  // Retrieve vertex indices from the vertex map.
  for(fIter = dt.finite_faces_begin(); fIter != dt.finite_faces_end(); fIter++)
  {
    Delaunay::Face f = *fIter;
    
    triIndices_.push_back(V[f.vertex(0)]);
    triIndices_.push_back(V[f.vertex(1)]);
    triIndices_.push_back(V[f.vertex(2)]);
  }
  
  triangulationValid_ = true;
}
void
MainWindow::on_actionSavePoints_triggered()
{
  QString fileName = QFileDialog::getSaveFileName(this,
						  tr("Save points"),
						  ".");
  if(! fileName.isEmpty()){
    std::ofstream ofs(qPrintable(fileName));
    for(Delaunay::Finite_vertices_iterator 
          vit = dt.finite_vertices_begin(),
          end = dt.finite_vertices_end();
        vit!= end; ++vit)
    {
      ofs << vit->point() << std::endl;
    }
  }
}
void Foam::conformalVoronoiMesh::cellSizeMeshOverlapsBackground() const
{
    const cellShapeControlMesh& cellSizeMesh =
        cellShapeControl_.shapeControlMesh();

    DynamicList<Foam::point> pts(number_of_vertices());

    for
    (
        Delaunay::Finite_vertices_iterator vit = finite_vertices_begin();
        vit != finite_vertices_end();
        ++vit
    )
    {
        if (vit->internalOrBoundaryPoint() && !vit->referred())
        {
            pts.append(topoint(vit->point()));
        }
    }

    boundBox bb(pts);

    boundBox cellSizeMeshBb = cellSizeMesh.bounds();

    bool fullyContained = true;

    if (!cellSizeMeshBb.contains(bb))
    {
        Pout<< "Triangulation not fully contained in cell size mesh."
            << endl;

        Pout<< "Cell Size Mesh Bounds = " << cellSizeMesh.bounds() << endl;
        Pout<< "foamyHexMesh Bounds         = " << bb << endl;

        fullyContained = false;
    }

    reduce(fullyContained, andOp<unsigned int>());

    Info<< "Triangulation is "
        << (fullyContained ? "fully" : "not fully")
        << " contained in the cell size mesh"
        << endl;
}