void ViewProviderPoints::cut(const std::vector<SbVec2f>& picked, Gui::View3DInventorViewer &Viewer) { // create the polygon from the picked points Base::Polygon2D cPoly; for (std::vector<SbVec2f>::const_iterator it = picked.begin(); it != picked.end(); ++it) { cPoly.Add(Base::Vector2D((*it)[0],(*it)[1])); } // get a reference to the point feature Points::Feature* fea = (Points::Feature*)pcObject; const Points::PointKernel& points = fea->Points.getValue(); SoCamera* pCam = Viewer.getSoRenderManager()->getCamera(); SbViewVolume vol = pCam->getViewVolume(); // search for all points inside/outside the polygon Points::PointKernel newKernel; for ( Points::PointKernel::const_iterator jt = points.begin(); jt != points.end(); ++jt ) { SbVec3f pt(jt->x,jt->y,jt->z); // project from 3d to 2d vol.projectToScreen(pt, pt); if (!cPoly.Contains(Base::Vector2D(pt[0],pt[1]))) newKernel.push_back(*jt); } if (newKernel.size() == points.size()) return; // nothing needs to be done //Remove the points from the cloud and open a transaction object for the undo/redo stuff Gui::Application::Instance->activeDocument()->openCommand("Cut points"); // sets the points outside the polygon to update the Inventor node fea->Points.setValue(newKernel); // unset the modified flag because we don't need the features' execute() to be called Gui::Application::Instance->activeDocument()->commitCommand(); fea->purgeTouched(); }