Ejemplo n.º 1
0
void Scene_c3t3_item::draw_triangle(const Kernel::Point_3& pa,
  const Kernel::Point_3& pb,
  const Kernel::Point_3& pc, bool /* is_cut */) const {

  #undef darker
  Kernel::Vector_3 n = cross_product(pb - pa, pc - pa);
  n = n / CGAL::sqrt(n*n);


  for (int i = 0; i<3; i++)
  {
    normals.push_back(n.x());
    normals.push_back(n.y());
    normals.push_back(n.z());
  }
  positions_poly.push_back(pa.x());
  positions_poly.push_back(pa.y());
  positions_poly.push_back(pa.z());

  positions_poly.push_back(pb.x());
  positions_poly.push_back(pb.y());
  positions_poly.push_back(pb.z());

  positions_poly.push_back(pc.x());
  positions_poly.push_back(pc.y());
  positions_poly.push_back(pc.z());



}
Ejemplo n.º 2
0
void Scene_combinatorial_map_item::direct_draw() const {
  typedef Combinatorial_map_3::One_dart_per_cell_const_range<3> Volume_dart_range;
  typedef Combinatorial_map_3::One_dart_per_incident_cell_const_range<2,3> Facet_in_volume_drange;
  typedef Combinatorial_map_3::Dart_of_orbit_const_range<1> Dart_in_facet_range;
  Volume_dart_range dart_per_volume_range = combinatorial_map().one_dart_per_cell<3>();
  
  std::size_t index = 0;
  for (Volume_dart_range::const_iterator vit=dart_per_volume_range.begin();vit!=dart_per_volume_range.end();++vit)
  {
    if (++index!=volume_to_display && volume_to_display!=0) continue;
    Facet_in_volume_drange facet_range=combinatorial_map().one_dart_per_incident_cell<2,3>(vit);
    
    for(Facet_in_volume_drange::const_iterator fit=facet_range.begin();fit!=facet_range.end();++fit){
      Dart_in_facet_range vertices=combinatorial_map().darts_of_orbit<1>(fit);
      Kernel::Vector_3 normal = compute_face_normal(fit);
      
      ::glBegin(GL_POLYGON);  
      ::glNormal3d(normal.x(),normal.y(),normal.z());
    
      for (Dart_in_facet_range::const_iterator pit=vertices.begin();pit!=vertices.end();++pit ){
        const Kernel::Point_3& p= pit->attribute<0>()->point();
        ::glVertex3d(p.x(),p.y(),p.z());
      }      
      ::glEnd(); 
    }
  }
}
Ejemplo n.º 3
0
  void addTriangle(Kernel::Point_3 pa, Kernel::Point_3 pb, Kernel::Point_3 pc, CGAL::Color color)
  {
    Kernel::Vector_3 n = cross_product(pb - pa, pc - pa);
    n = n / CGAL::sqrt(n*n);


    for (int i = 0; i<3; i++)
    {
      normals->push_back(n.x());
      normals->push_back(n.y());
      normals->push_back(n.z());
    }
    vertices->push_back(pa.x());
    vertices->push_back(pa.y());
    vertices->push_back(pa.z());

    vertices->push_back(pb.x());
    vertices->push_back(pb.y());
    vertices->push_back(pb.z());

    vertices->push_back(pc.x());
    vertices->push_back(pc.y());
    vertices->push_back(pc.z());

    edges->push_back(pa.x());
    edges->push_back(pa.y());
    edges->push_back(pa.z());

    edges->push_back(pb.x());
    edges->push_back(pb.y());
    edges->push_back(pb.z());

    edges->push_back(pb.x());
    edges->push_back(pb.y());
    edges->push_back(pb.z());

    edges->push_back(pc.x());
    edges->push_back(pc.y());
    edges->push_back(pc.z());

    edges->push_back(pc.x());
    edges->push_back(pc.y());
    edges->push_back(pc.z());

    edges->push_back(pa.x());
    edges->push_back(pa.y());
    edges->push_back(pa.z());

    for(int i=0; i<3; i++)
    {
      colors->push_back((float)color.red()/255);
      colors->push_back((float)color.green()/255);
      colors->push_back((float)color.blue()/255);
    }
  }
Ejemplo n.º 4
0
void Scene_combinatorial_map_item::compute_elements(void) const{

    positions_facets.resize(0);
    normals.resize(0);
    positions_lines.resize(0);
    positions_points.resize(0);

    //Facets
    {
    std::size_t index = 0;
    int voltreated = combinatorial_map().get_new_mark();
    int facetreated = combinatorial_map().get_new_mark();
    Combinatorial_map_3::Dart_const_range::const_iterator
            darts_it=combinatorial_map().darts().begin(), darts_end=combinatorial_map().darts().end();
    for( ; darts_it!=darts_end; ++darts_it)
    {
        if ( !combinatorial_map().is_marked(darts_it,voltreated) )
        {
            ++index;
            //iterate over all the darts of the volume
            Combinatorial_map_3::Dart_of_cell_const_range<3>::const_iterator
                    vol_it=combinatorial_map().darts_of_cell<3>(darts_it).begin(),
                    vol_end=combinatorial_map().darts_of_cell<3>(darts_it).end();
            if ( volume_to_display!=0 && index!=volume_to_display )
            {
                //only mark darts if the volume is not the one to display
                for ( ;vol_it!=vol_end; ++vol_it )
                {
                    combinatorial_map().mark(vol_it,facetreated);
                    combinatorial_map().mark(vol_it, voltreated);
                }
            }
            else
            {
                for ( ;vol_it!=vol_end; ++vol_it )
                {
                    if ( !combinatorial_map().is_marked(vol_it,facetreated) )
                    {
                        Kernel::Vector_3 normal = compute_face_normal(vol_it);
                        for(int i=0; i<3; i++)
                        {
                            normals.push_back(normal.x());
                            normals.push_back(normal.y());
                            normals.push_back(normal.z());
                        }

                        //iterate over all darts of facets
                        for ( Combinatorial_map_3::Dart_of_orbit_const_range<1>::const_iterator
                              face_it=combinatorial_map().darts_of_orbit<1>(vol_it).begin(),
                              face_end=combinatorial_map().darts_of_orbit<1>(vol_it).end();
                              face_it!=face_end; ++face_it)
                        {
                            const Kernel::Point_3& p= face_it->attribute<0>()->point();
                            positions_facets.push_back(p.x());
                            positions_facets.push_back(p.y());
                            positions_facets.push_back(p.z());
                            combinatorial_map().mark(face_it,facetreated);
                            combinatorial_map().mark(face_it, voltreated);
                        }
                    }
                }
            }
            if ( index==volume_to_display ) break;
        }
    }
    //mark remaining darts to have an O(1) free_mark
    for( ;  darts_it!=darts_end; ++darts_it)
    {
        combinatorial_map().mark(darts_it, facetreated);
        combinatorial_map().mark(darts_it, voltreated);
    }

    combinatorial_map().free_mark(facetreated);
    combinatorial_map().free_mark(voltreated);
    }

    //edges
    {

        typedef Combinatorial_map_3::One_dart_per_cell_const_range<1> Edge_darts;
        Edge_darts darts=combinatorial_map().one_dart_per_cell<1>();
        for (Edge_darts::const_iterator dit=darts.begin();dit!=darts.end();++dit){
            CGAL_assertion(!dit->is_free(1));
            const Kernel::Point_3& a = dit->attribute<0>()->point();
            const Kernel::Point_3& b = dit->beta(1)->attribute<0>()->point();
            positions_lines.push_back(a.x());
            positions_lines.push_back(a.y());
            positions_lines.push_back(a.z());

            positions_lines.push_back(b.x());
            positions_lines.push_back(b.y());
            positions_lines.push_back(b.z());

        }
    }

    //points
    {
        typedef Combinatorial_map_3::Attribute_const_range<0>::type Point_range;
        const Point_range& points=combinatorial_map().attributes<0>();
        for(Point_range::const_iterator pit=boost::next(points.begin());pit!=points.end();++pit){
            const Kernel::Point_3& p=pit->point();
            positions_points.push_back(p.x());
            positions_points.push_back(p.y());
            positions_points.push_back(p.z());
        }

    }

}
void Scene_polyhedron_selection_item::compute_elements()
{
    positions_facets.clear();
    positions_lines.clear();
    positions_points.clear();
    normals.clear();
    //The facets
    {


        for(Selection_set_facet::iterator
            it = selected_facets.begin(),
            end = selected_facets.end();
            it != end; ++it)
        {
            const Kernel::Vector_3 n =
                    CGAL::Polygon_mesh_processing::compute_face_normal(*it, *this->poly_item->polyhedron());

            normals.push_back(n.x());
            normals.push_back(n.y());
            normals.push_back(n.z());

            normals.push_back(n.x());
            normals.push_back(n.y());
            normals.push_back(n.z());

            normals.push_back(n.x());
            normals.push_back(n.y());
            normals.push_back(n.z());


            Polyhedron::Halfedge_around_facet_circulator
                    he = (*it)->facet_begin(),
                    cend = he;

            CGAL_For_all(he,cend)
            {
                const Kernel::Point_3& p = he->vertex()->point();
                positions_facets.push_back(p.x());
                positions_facets.push_back(p.y());
                positions_facets.push_back(p.z());
            }
        }
    }

    //The Lines
    {

        for(Selection_set_edge::iterator it = selected_edges.begin(); it != selected_edges.end(); ++it) {
            const Kernel::Point_3& a = (it->halfedge())->vertex()->point();
            const Kernel::Point_3& b = (it->halfedge())->opposite()->vertex()->point();
            positions_lines.push_back(a.x());
            positions_lines.push_back(a.y());
            positions_lines.push_back(a.z());

            positions_lines.push_back(b.x());
            positions_lines.push_back(b.y());
            positions_lines.push_back(b.z());
        }

    }

    //The points
    {
        for(Selection_set_vertex::iterator
            it = selected_vertices.begin(),
            end = selected_vertices.end();
            it != end; ++it)
        {
            const Kernel::Point_3& p = (*it)->point();
            positions_points.push_back(p.x());
            positions_points.push_back(p.y());
            positions_points.push_back(p.z());
        }
    }
}