Exemplo n.º 1
1
void
CompliantPlannerDlg::generateButtonClicked()
{
	int resolution = resolutionEdit->text().toInt();
	if (resolution < 1) {
		DBGA("Resolution must be at least 1");
		return;
	}
	//get object bbox dimensions
	SoGetBoundingBoxAction *bba = 
		new SoGetBoundingBoxAction(graspitCore->getIVmgr()->getViewer()->getViewportRegion());
	bba->apply(mObject->getIVGeomRoot());
	SbVec3f bbmin,bbmax;
	bba->getBoundingBox().getBounds(bbmin,bbmax);
	delete bba;
	double a = 0.5*(bbmax[0] - bbmin[0]);
	double b = 0.5*(bbmax[1] - bbmin[1]);
	double c = 0.5*(bbmax[2] - bbmin[2]);
	//ellipsoidSampling(a,b,c,resolution);
	boxSampling(a,b,c, resolution);

	mPlanner->resetPlanner();
	if (visualMarkersBox->isChecked()) {
		visualMarkersBoxClicked();
	}
	update();
}
Exemplo n.º 2
0
SbBox3f ViewProviderDatum::getRelevantBoundBox (
    SoGetBoundingBoxAction &bboxAction, const std::vector <App::DocumentObject *> &objs )
{
    SbBox3f bbox(0,0,0, 0,0,0);

    // Adds the bbox of given feature to the output
    for (auto obj :objs) {
        ViewProvider *vp = Gui::Application::Instance->getViewProvider(obj);
        if (!vp) {
            continue;
        }
        if (!vp->isVisible ()) {
            continue;
        }

        if (obj->isDerivedFrom (Part::Datum::getClassTypeId() ) ) {
            // Treat datums only as their basepoint
            // I hope it's ok to take FreeCAD's point here
            Base::Vector3d basePoint = static_cast<Part::Datum *> ( obj )->getBasePoint ();
            bbox.extendBy (SbVec3f(basePoint.x, basePoint.y, basePoint.z ));
        } else {
            bboxAction.apply ( vp->getRoot () );
            SbBox3f obj_bbox =  bboxAction.getBoundingBox ();

            if ( obj_bbox.getVolume () < Precision::Infinite () ) {
                bbox.extendBy ( obj_bbox );
            }
        }
    }

    return bbox;
}