mirror of https://github.com/CGAL/cgal
Add offset support for the Cut_plugin
This commit is contained in:
parent
faf7c4ae3f
commit
1face074bf
|
|
@ -31,6 +31,7 @@ template<typename Primitive, typename Node>
|
|||
struct AABB_drawing_traits
|
||||
{
|
||||
std::vector<float> *v_edges;
|
||||
double offset[3];
|
||||
|
||||
typedef CGAL::Bbox_3 Bbox;
|
||||
bool go_further() { return true; }
|
||||
|
|
@ -83,13 +84,13 @@ struct AABB_drawing_traits
|
|||
void gl_draw_edge(double px, double py, double pz,
|
||||
double qx, double qy, double qz)
|
||||
{
|
||||
v_edges->push_back((float)px);
|
||||
v_edges->push_back((float)py);
|
||||
v_edges->push_back((float)pz);
|
||||
v_edges->push_back((float)px+offset[0]);
|
||||
v_edges->push_back((float)py+offset[1]);
|
||||
v_edges->push_back((float)pz+offset[2]);
|
||||
|
||||
v_edges->push_back((float)qx);
|
||||
v_edges->push_back((float)qy);
|
||||
v_edges->push_back((float)qz);
|
||||
v_edges->push_back((float)qx+offset[0]);
|
||||
v_edges->push_back((float)qy+offset[1]);
|
||||
v_edges->push_back((float)qz+offset[2]);
|
||||
}
|
||||
}; // AABB_drawing_traits
|
||||
|
||||
|
|
|
|||
|
|
@ -863,7 +863,7 @@ void MainWindow::updateViewerBBox()
|
|||
qglviewer::Vec offset(0,0,0);
|
||||
for(int i=0; i<3; ++i)
|
||||
{
|
||||
if(log2(bbox.min(i)) > 13.0 )
|
||||
// if(log2(bbox.min(i)) > 13.0 )
|
||||
offset[i] = -bbox.min(i);
|
||||
}
|
||||
viewer->setOffset(offset);
|
||||
|
|
|
|||
|
|
@ -98,8 +98,9 @@ public:
|
|||
FT x = -diag/fd + FT(i)/FT(grid_size) * dx;
|
||||
{
|
||||
FT y = -diag/fd + FT(j)/FT(grid_size) * dy;
|
||||
|
||||
Point query = transfo( Point(x,y,z) );
|
||||
const qglviewer::Vec v_offset = static_cast<CGAL::Three::Viewer_interface*>(QGLViewer::QGLViewerPool().first())->offset();
|
||||
Simple_kernel::Vector_3 offset(v_offset.x, v_offset.y, v_offset.z);
|
||||
Point query = transfo( Point(x,y,z))-offset;
|
||||
FT min = DBL_MAX;
|
||||
|
||||
Q_FOREACH(Tree *tree, trees->values())
|
||||
|
|
@ -284,11 +285,14 @@ private:
|
|||
|
||||
void computeElements() const
|
||||
{
|
||||
const qglviewer::Vec offset = static_cast<CGAL::Three::Viewer_interface*>(QGLViewer::QGLViewerPool().first())->offset();
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
positions_lines.clear();
|
||||
|
||||
CGAL::AABB_drawing_traits<Facet_primitive, CGAL::AABB_node<Facet_traits> > traits;
|
||||
traits.v_edges = &positions_lines;
|
||||
for(int i=0; i<3; ++i)
|
||||
traits.offset[i] = offset[i];
|
||||
|
||||
tree.traversal(0, traits);
|
||||
QApplication::restoreOverrideCursor();
|
||||
|
|
@ -403,14 +407,16 @@ private:
|
|||
}
|
||||
void computeElements() const
|
||||
{
|
||||
const qglviewer::Vec v_offset = static_cast<CGAL::Three::Viewer_interface*>(QGLViewer::QGLViewerPool().first())->offset();
|
||||
Simple_kernel::Vector_3 offset(v_offset.x, v_offset.y, v_offset.z);
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
positions_lines.clear();
|
||||
|
||||
for(size_t i = 0, end = edges.size();
|
||||
i < end; ++i)
|
||||
{
|
||||
const Simple_kernel::Point_3& a = edges[i].source();
|
||||
const Simple_kernel::Point_3& b = edges[i].target();
|
||||
const Simple_kernel::Point_3& a = edges[i].source()+offset;
|
||||
const Simple_kernel::Point_3& b = edges[i].target()+offset;
|
||||
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());
|
||||
}
|
||||
|
|
@ -1329,7 +1335,8 @@ void Polyhedron_demo_cut_plugin::computeIntersection()
|
|||
scene->addItem(edges_item);
|
||||
}
|
||||
|
||||
const qglviewer::Vec& pos = plane_item->manipulatedFrame()->position();
|
||||
const qglviewer::Vec offset = static_cast<CGAL::Three::Viewer_interface*>(QGLViewer::QGLViewerPool().first())->offset();
|
||||
const qglviewer::Vec& pos = plane_item->manipulatedFrame()->position() - offset;
|
||||
const qglviewer::Vec& n =
|
||||
plane_item->manipulatedFrame()->inverseTransformOf(qglviewer::Vec(0.f, 0.f, 1.f));
|
||||
Simple_kernel::Plane_3 plane(n[0], n[1], n[2], - n * pos);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ Scene_plane_item::Scene_plane_item(const CGAL::Three::Scene_interface* scene_int
|
|||
frame(new ManipulatedFrame())
|
||||
{
|
||||
setNormal(0., 0., 1.);
|
||||
|
||||
//Generates an integer which will be used as ID for each buffer
|
||||
invalidateOpenGLBuffers();
|
||||
}
|
||||
|
|
@ -50,6 +51,7 @@ void Scene_plane_item::initializeBuffers(Viewer_interface *viewer) const
|
|||
|
||||
void Scene_plane_item::compute_normals_and_vertices(void) const
|
||||
{
|
||||
const qglviewer::Vec offset = static_cast<CGAL::Three::Viewer_interface*>(QGLViewer::QGLViewerPool().first())->offset();
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
positions_quad.resize(0);
|
||||
positions_lines.resize(0);
|
||||
|
|
@ -60,23 +62,23 @@ void Scene_plane_item::compute_normals_and_vertices(void) const
|
|||
|
||||
positions_quad.push_back(-diag);
|
||||
positions_quad.push_back(-diag);
|
||||
positions_quad.push_back(0.0);
|
||||
positions_quad.push_back(0.0 );
|
||||
positions_quad.push_back(-diag);
|
||||
positions_quad.push_back(diag);
|
||||
positions_quad.push_back(0.0);
|
||||
positions_quad.push_back(diag);
|
||||
positions_quad.push_back(diag );
|
||||
positions_quad.push_back(0.0 );
|
||||
positions_quad.push_back(diag );
|
||||
positions_quad.push_back(-diag);
|
||||
positions_quad.push_back(0.0);
|
||||
positions_quad.push_back(0.0 );
|
||||
|
||||
positions_quad.push_back(diag);
|
||||
positions_quad.push_back(diag );
|
||||
positions_quad.push_back(-diag);
|
||||
positions_quad.push_back(0.0);
|
||||
positions_quad.push_back(0.0 );
|
||||
positions_quad.push_back(-diag);
|
||||
positions_quad.push_back(diag);
|
||||
positions_quad.push_back(0.0);
|
||||
positions_quad.push_back(diag);
|
||||
positions_quad.push_back(diag);
|
||||
positions_quad.push_back(0.0);
|
||||
positions_quad.push_back(diag );
|
||||
positions_quad.push_back(0.0 );
|
||||
positions_quad.push_back(diag );
|
||||
positions_quad.push_back(diag );
|
||||
positions_quad.push_back(0.0 );
|
||||
|
||||
}
|
||||
//The grid
|
||||
|
|
@ -87,23 +89,23 @@ void Scene_plane_item::compute_normals_and_vertices(void) const
|
|||
{
|
||||
|
||||
positions_lines.push_back(-diag + x* u);
|
||||
positions_lines.push_back(-diag);
|
||||
positions_lines.push_back(0.0);
|
||||
positions_lines.push_back(-diag );
|
||||
positions_lines.push_back(0.0 );
|
||||
|
||||
positions_lines.push_back(-diag + x* u);
|
||||
positions_lines.push_back(diag);
|
||||
positions_lines.push_back(0.0);
|
||||
positions_lines.push_back(diag );
|
||||
positions_lines.push_back(0.0 );
|
||||
}
|
||||
for(int v=0; v<11; v++)
|
||||
{
|
||||
|
||||
positions_lines.push_back(-diag);
|
||||
positions_lines.push_back(-diag );
|
||||
positions_lines.push_back(-diag + v * y);
|
||||
positions_lines.push_back(0.0);
|
||||
positions_lines.push_back(0.0 );
|
||||
|
||||
positions_lines.push_back(diag);
|
||||
positions_lines.push_back(diag );
|
||||
positions_lines.push_back(-diag + v * y);
|
||||
positions_lines.push_back(0.0);
|
||||
positions_lines.push_back(0.0 );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -227,7 +229,8 @@ void Scene_plane_item::setPosition(float x, float y, float z) {
|
|||
}
|
||||
|
||||
void Scene_plane_item::setPosition(double x, double y, double z) {
|
||||
frame->setPosition((float)x, (float)y, (float)z);
|
||||
const qglviewer::Vec offset = static_cast<CGAL::Three::Viewer_interface*>(QGLViewer::QGLViewerPool().first())->offset();
|
||||
frame->setPosition((float)x+offset.x, (float)y+offset.y, (float)z+offset.z);
|
||||
}
|
||||
|
||||
void Scene_plane_item::setNormal(float x, float y, float z) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue