QString Scene_c3t3_item::toolTip() const { return tr("<p><b>3D complex in a 3D triangulation</b></p>" "<p>Number of vertices: %1<br />" "Number of surface facets: %2<br />" "Number of volume tetrahedra: %3</p>") .arg(c3t3().triangulation().number_of_vertices()) .arg(c3t3().number_of_facets_in_complex()) .arg(c3t3().number_of_cells_in_complex()); }
void Scene_c3t3_item::export_facets_in_complex() { std::stringstream off_sstream; c3t3().output_facets_in_complex_to_off(off_sstream); std::string backup = off_sstream.str(); // Try to read .off in a polyhedron Scene_polyhedron_item* item = new Scene_polyhedron_item; if (!item->load(off_sstream)) { delete item; off_sstream.str(backup); // Try to read .off in a polygon soup Scene_polygon_soup_item* soup_item = new Scene_polygon_soup_item; if (!soup_item->load(off_sstream)) { delete soup_item; return; } soup_item->setName(QString("%1_%2").arg(this->name()).arg("facets")); last_known_scene->addItem(soup_item); } else{ item->setName(QString("%1_%2").arg(this->name()).arg("facets")); last_known_scene->addItem(item); } }
Bbox bbox() const { if(isEmpty()) return Bbox(); else { CGAL::Bbox_3 result = c3t3().triangulation().finite_vertices_begin()->point().bbox(); for(Tr::Finite_vertices_iterator vit = ++c3t3().triangulation().finite_vertices_begin(), end = c3t3().triangulation().finite_vertices_end(); vit != end; ++vit) { result = result + vit->point().bbox(); } return Bbox(result.xmin(), result.ymin(), result.zmin(), result.xmax(), result.ymax(), result.zmax()); } }
void Scene_c3t3_item::compute_bbox() const { if (isEmpty()) _bbox = Bbox(); else { CGAL::Bbox_3 result; for (Tr::Finite_vertices_iterator vit = ++c3t3().triangulation().finite_vertices_begin(), end = c3t3().triangulation().finite_vertices_end(); vit != end; ++vit) { if(vit->in_dimension() == -1) continue; result = result + vit->point().bbox(); } _bbox = Bbox(result.xmin(), result.ymin(), result.zmin(), result.xmax(), result.ymax(), result.zmax()); } }
QString Scene_c3t3_item::toolTip() const { int number_of_tets = 0; for (Tr::Finite_cells_iterator cit = c3t3().triangulation().finite_cells_begin(), end = c3t3().triangulation().finite_cells_end(); cit != end; ++cit) { if (c3t3().is_in_complex(cit)) ++number_of_tets; } return tr("<p><b>3D complex in a 3D triangulation</b></p>" "<p>Number of vertices: %1<br />" "Number of surface facets: %2<br />" "Number of volume tetrahedra: %3</p>") .arg(c3t3().triangulation().number_of_vertices()) .arg(c3t3().number_of_facets()) .arg(number_of_tets); }
void Scene_c3t3_item::compute_bbox() const { if (isEmpty()) _bbox = Bbox(); else { CGAL::Bbox_3 result = c3t3().cells_in_complex_begin()->vertex(0)->point().bbox(); for (C3t3::Cells_in_complex_iterator cit = ++c3t3().cells_in_complex_begin(), cend = c3t3().cells_in_complex_end(); cit != cend; ++cit) { result = result + cit->vertex(0)->point().bbox(); //only one vertex should be a satisfactory approximation } _bbox = Bbox(result.xmin(), result.ymin(), result.zmin(), result.xmax(), result.ymax(), result.zmax()); } }
void Scene_c3t3_item::build_histogram() { #ifdef CGAL_MESH_3_DEMO_BIGGER_HISTOGRAM_WITH_WHITE_BACKGROUNG // Create an histogram_ and display it const int height = 280; const int top_margin = 5; const int left_margin = 20; const int drawing_height = height - top_margin * 2; const int width = 804; const int cell_width = 4; const int text_margin = 3; const int text_height = 34; histogram_ = QPixmap(width, height + text_height); histogram_.fill(QColor(255, 255, 255)); #else // Create an histogram_ and display it const int height = 140; const int top_margin = 5; const int left_margin = 20; const int drawing_height = height - top_margin * 2; const int width = 402; const int cell_width = 2; const int text_margin = 3; const int text_height = 20; histogram_ = QPixmap(width, height + text_height); histogram_.fill(QColor(192, 192, 192)); #endif QPainter painter(&histogram_); painter.setPen(Qt::black); painter.setBrush(QColor(128, 128, 128)); //painter.setFont(QFont("Arial", 30)); // Build histogram_ data double min_value, max_value; std::vector<int> histo_data = create_histogram(c3t3(), min_value, max_value); // Get maximum value (to normalize) int max_size = 0; for (std::vector<int>::iterator it = histo_data.begin(), end = histo_data.end(); it != end; ++it) { max_size = (std::max)(max_size, *it); } // colored histogram int j = 0; // draw int i = left_margin; for (std::vector<int>::iterator it = histo_data.begin(), end = histo_data.end(); it != end; ++it, i += cell_width) { int line_height = static_cast<int>(std::ceil(static_cast<double>(drawing_height)* static_cast<double>(*it) / static_cast<double>(max_size)) + .5); painter.fillRect(i, drawing_height + top_margin - line_height, cell_width, line_height, get_histogram_color(j++)); } // draw bottom horizontal line painter.setPen(Qt::blue); painter.drawLine(QPoint(left_margin, drawing_height + top_margin), QPoint(left_margin + static_cast<int>(histo_data.size())*cell_width, drawing_height + top_margin)); // draw min value and max value const int min_tr_width = static_cast<int>(2 * (std::floor(min_value)*cell_width + left_margin)); const int max_tr_width = static_cast<int>( 2 * ((histo_data.size() - std::floor(max_value))*cell_width + left_margin)); const int tr_y = drawing_height + top_margin + text_margin; painter.setPen(get_histogram_color(min_value)); QRect min_text_rect(0, tr_y, min_tr_width, text_height); painter.drawText(min_text_rect, Qt::AlignCenter, tr("%1").arg(min_value, 0, 'f', 1)); painter.setPen(get_histogram_color(max_value)); QRect max_text_rect(width - max_tr_width, tr_y, max_tr_width, text_height); painter.drawText(max_text_rect, Qt::AlignCenter, tr("%1").arg(max_value, 0, 'f', 1)); }
bool isEmpty() const { return c3t3().triangulation().number_of_vertices() == 0; }