Added a test on selected input faces in sketcher dlg to check if they are planar.

This commit is contained in:
rnc 2012-04-25 15:08:19 +00:00
parent d1f194cbdc
commit 9a00eb28aa

View File

@ -38,6 +38,8 @@
#include <Geom_Surface.hxx> #include <Geom_Surface.hxx>
#include <Geom_Plane.hxx> #include <Geom_Plane.hxx>
#include <GeomLib_IsPlanarSurface.hxx>
#include <SUIT_Desktop.h> #include <SUIT_Desktop.h>
#include <SUIT_Session.h> #include <SUIT_Session.h>
#include <SUIT_MessageBox.h> #include <SUIT_MessageBox.h>
@ -1370,13 +1372,26 @@ void EntityGUI_SketcherDlg::SelectionIntoArgument()
&& !aShape.IsNull()) && !aShape.IsNull())
{ {
QString aName = GEOMBase::GetName( aSelectedObject.get() ); QString aName = GEOMBase::GetName( aSelectedObject.get() );
myEditCurrentArgument->setText(aName);
if (myEditCurrentArgument==WPlaneLineEdit) if (myEditCurrentArgument==WPlaneLineEdit)
{ {
AddLocalCS(aSelectedObject.get()); // Check if the face is planar
selButton->setDown(false); Handle(Geom_Surface) aSurf = BRep_Tool::Surface(TopoDS::Face(aShape));
WPlaneLineEdit->setEnabled(false); GeomLib_IsPlanarSurface aPlanarCheck(aSurf, Precision::Confusion());
TypeClicked( myConstructorId );
if (aPlanarCheck.IsPlanar())
{
myEditCurrentArgument->setText(aName);
AddLocalCS(aSelectedObject.get());
selButton->setDown(false);
WPlaneLineEdit->setEnabled(false);
TypeClicked( myConstructorId );
}
else
{
myEditCurrentArgument->setText(tr("GEOM_SKETCHER_WPLANE"));
// The following leads to crash TODO : find a way to return a warning
// Standard_Failure::Raise(tr("GEOM_SKETCHER_NOT_PLANAR").toStdString().c_str());
}
} }
else else
{ {
@ -1390,6 +1405,7 @@ void EntityGUI_SketcherDlg::SelectionIntoArgument()
gp_Pnt aPnt; gp_Pnt aPnt;
if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) if ( GEOMBase::VertexToPoint( aShape, aPnt ) )
{ {
myEditCurrentArgument->setText(aName);
myX = aPnt.X(); myX = aPnt.X();
myY = aPnt.Y(); myY = aPnt.Y();
double Xcoord = myX; double Xcoord = myX;