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,15 +1372,28 @@ 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)
{ {
// Check if the face is planar
Handle(Geom_Surface) aSurf = BRep_Tool::Surface(TopoDS::Face(aShape));
GeomLib_IsPlanarSurface aPlanarCheck(aSurf, Precision::Confusion());
if (aPlanarCheck.IsPlanar())
{
myEditCurrentArgument->setText(aName);
AddLocalCS(aSelectedObject.get()); AddLocalCS(aSelectedObject.get());
selButton->setDown(false); selButton->setDown(false);
WPlaneLineEdit->setEnabled(false); WPlaneLineEdit->setEnabled(false);
TypeClicked( myConstructorId ); TypeClicked( myConstructorId );
} }
else 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
{ {
gp_Trsf aTrans; gp_Trsf aTrans;
gp_Ax3 aWPlane = GetActiveLocalCS(); gp_Ax3 aWPlane = GetActiveLocalCS();
@ -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;