Beispiel #1
0
static Surf *findSurf( q3_face *f ){
	FaceMap::const_iterator it=face_map.find( f );
	if( it!=face_map.end() ) return it->second;
	Surf *s=d_new Surf;
	s->texture=f->texture;
	s->lm_index=f->lm_index;
	face_map.insert( make_pair( f,s ) );
	t_surfs.push_back( s );
	return s;
}
Beispiel #2
0
  bool vtkPolyData_to_polygon_mesh(vtkPolyData* poly_data,
                                   TM& tmesh,
                                   VertexMap& vertex_map,
                                   FaceMap& face_map)
  {
    typedef typename boost::property_map<TM, CGAL::vertex_point_t>::type VPMap;
    typedef typename boost::property_map_value<TM, CGAL::vertex_point_t>::type Point_3;
    typedef typename boost::graph_traits<TM>::vertex_descriptor vertex_descriptor;
    typedef typename boost::graph_traits<TM>::face_descriptor   face_descriptor;

    VPMap vpmap = get(CGAL::vertex_point, tmesh);

    // get nb of points and cells
    vtkIdType nb_points = poly_data->GetNumberOfPoints();
    vtkIdType nb_cells = poly_data->GetNumberOfCells();

    //extract points
    for (vtkIdType i = 0; i<nb_points; ++i)
    {
      double coords[3];
      poly_data->GetPoint(i, coords);

      vertex_descriptor v = add_vertex(tmesh);
      put(vpmap, v, Point_3(coords[0], coords[1], coords[2]));
      vertex_map.insert(std::make_pair(i, v));
    }

    //extract cells
    for (vtkIdType i = 0; i<nb_cells; ++i)
    {
      vtkCell* cell_ptr = poly_data->GetCell(i);

      vtkIdType nb_vertices = cell_ptr->GetNumberOfPoints();
      if (nb_vertices != 3){
        std::cerr << "Error a cell with " << nb_vertices << " found\n";
        return false;
      }
      std::vector<vertex_descriptor> vr;
      vr.push_back(vertex_map[cell_ptr->GetPointId(0)]);
      vr.push_back(vertex_map[cell_ptr->GetPointId(1)]);
      vr.push_back(vertex_map[cell_ptr->GetPointId(2)]);

      face_descriptor f = CGAL::Euler::add_face(vr, tmesh);
      face_map.insert(std::make_pair(i, f));
    }
    return true;
  }