mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-01-26 16:30:34 +05:00
0023272: [CEA] Add a tolerance for basic properties computation
This commit is contained in:
parent
afce74184a
commit
2c66cf4f4a
BIN
doc/salome/gui/GEOM/images/neo-basicprop.png
Executable file → Normal file
BIN
doc/salome/gui/GEOM/images/neo-basicprop.png
Executable file → Normal file
Binary file not shown.
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 23 KiB |
@ -15,8 +15,9 @@ in the viewer to navigate between selectable objects.
|
|||||||
For more details, please refer to the \em "Functionality common for OCC and VTK viewers" chapter
|
For more details, please refer to the \em "Functionality common for OCC and VTK viewers" chapter
|
||||||
of the GUI module's documentation.
|
of the GUI module's documentation.
|
||||||
|
|
||||||
<b>TUI Command:</b> <em>geompy.BasicProperties(Shape),</em> where
|
<b>TUI Command:</b> <em>geompy.BasicProperties(Shape, theTolerance=1.e-6),</em>
|
||||||
\em Shape is a shape whose properties are inquired.
|
where \em Shape is a shape whose properties are inquired, \em theTolerance is
|
||||||
|
maximal relative error of area and volume computation.
|
||||||
|
|
||||||
See also a \ref tui_basic_properties_page "TUI example".
|
See also a \ref tui_basic_properties_page "TUI example".
|
||||||
|
|
||||||
|
@ -4337,12 +4337,14 @@ module GEOM
|
|||||||
* \brief Get summarized length of all wires,
|
* \brief Get summarized length of all wires,
|
||||||
* area of surface and volume of the given shape.
|
* area of surface and volume of the given shape.
|
||||||
* \param theShape Shape to define properties of.
|
* \param theShape Shape to define properties of.
|
||||||
|
* \param theTolerance maximal relative error of area and volume computation.
|
||||||
* \param theLength Output. Summarized length of all wires of the given shape.
|
* \param theLength Output. Summarized length of all wires of the given shape.
|
||||||
* \param theSurfArea Output. Area of surface of the given shape.
|
* \param theSurfArea Output. Area of surface of the given shape.
|
||||||
* \param theVolume Output. Volume of the given shape.
|
* \param theVolume Output. Volume of the given shape.
|
||||||
* \return Returns shape properties through the last three arguments.
|
* \return Returns shape properties through the last three arguments.
|
||||||
*/
|
*/
|
||||||
void GetBasicProperties (in GEOM_Object theShape,
|
void GetBasicProperties (in GEOM_Object theShape,
|
||||||
|
in double theTolerance,
|
||||||
out double theLength,
|
out double theLength,
|
||||||
out double theSurfArea,
|
out double theSurfArea,
|
||||||
out double theVolume);
|
out double theVolume);
|
||||||
|
@ -965,6 +965,7 @@ Handle(GEOM_Object) GEOMImpl_IMeasureOperations::GetNormal
|
|||||||
*/
|
*/
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
void GEOMImpl_IMeasureOperations::GetBasicProperties (Handle(GEOM_Object) theShape,
|
void GEOMImpl_IMeasureOperations::GetBasicProperties (Handle(GEOM_Object) theShape,
|
||||||
|
const Standard_Real theTolerance,
|
||||||
Standard_Real& theLength,
|
Standard_Real& theLength,
|
||||||
Standard_Real& theSurfArea,
|
Standard_Real& theSurfArea,
|
||||||
Standard_Real& theVolume)
|
Standard_Real& theVolume)
|
||||||
@ -984,7 +985,7 @@ void GEOMImpl_IMeasureOperations::GetBasicProperties (Handle(GEOM_Object) theSha
|
|||||||
|
|
||||||
//Compute the parameters
|
//Compute the parameters
|
||||||
GProp_GProps LProps, SProps;
|
GProp_GProps LProps, SProps;
|
||||||
Standard_Real anEps = 1.e-6;
|
Standard_Real anEps = theTolerance >= 0 ? theTolerance : 1.e-6;
|
||||||
try {
|
try {
|
||||||
OCC_CATCH_SIGNALS;
|
OCC_CATCH_SIGNALS;
|
||||||
BRepGProp::LinearProperties(aShape, LProps);
|
BRepGProp::LinearProperties(aShape, LProps);
|
||||||
|
@ -119,6 +119,7 @@ class GEOMImpl_IMeasureOperations : public GEOM_IOperations {
|
|||||||
Handle(GEOM_Object) theOptionalPoint);
|
Handle(GEOM_Object) theOptionalPoint);
|
||||||
|
|
||||||
Standard_EXPORT void GetBasicProperties (Handle(GEOM_Object) theShape,
|
Standard_EXPORT void GetBasicProperties (Handle(GEOM_Object) theShape,
|
||||||
|
const Standard_Real theTolerance,
|
||||||
Standard_Real& theLength,
|
Standard_Real& theLength,
|
||||||
Standard_Real& theSurfArea,
|
Standard_Real& theSurfArea,
|
||||||
Standard_Real& theVolume);
|
Standard_Real& theVolume);
|
||||||
|
@ -495,6 +495,7 @@ GEOM::GEOM_Object_ptr GEOM_IMeasureOperations_i::GetNormal
|
|||||||
*/
|
*/
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
void GEOM_IMeasureOperations_i::GetBasicProperties (GEOM::GEOM_Object_ptr theShape,
|
void GEOM_IMeasureOperations_i::GetBasicProperties (GEOM::GEOM_Object_ptr theShape,
|
||||||
|
CORBA::Double theTolerance,
|
||||||
CORBA::Double& theLength,
|
CORBA::Double& theLength,
|
||||||
CORBA::Double& theSurfArea,
|
CORBA::Double& theSurfArea,
|
||||||
CORBA::Double& theVolume)
|
CORBA::Double& theVolume)
|
||||||
@ -507,7 +508,8 @@ void GEOM_IMeasureOperations_i::GetBasicProperties (GEOM::GEOM_Object_ptr theSha
|
|||||||
if (aShape.IsNull()) return;
|
if (aShape.IsNull()) return;
|
||||||
|
|
||||||
// Get shape parameters
|
// Get shape parameters
|
||||||
GetOperations()->GetBasicProperties(aShape, theLength, theSurfArea, theVolume);
|
GetOperations()->GetBasicProperties(aShape, theTolerance, theLength,
|
||||||
|
theSurfArea, theVolume);
|
||||||
}
|
}
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
@ -52,6 +52,7 @@ class GEOM_I_EXPORT GEOM_IMeasureOperations_i :
|
|||||||
CORBA::Double& Xx, CORBA::Double& Xy, CORBA::Double& Xz);
|
CORBA::Double& Xx, CORBA::Double& Xy, CORBA::Double& Xz);
|
||||||
|
|
||||||
void GetBasicProperties (GEOM::GEOM_Object_ptr theShape,
|
void GetBasicProperties (GEOM::GEOM_Object_ptr theShape,
|
||||||
|
CORBA::Double theTolerance,
|
||||||
CORBA::Double& theLength,
|
CORBA::Double& theLength,
|
||||||
CORBA::Double& theSurfArea,
|
CORBA::Double& theSurfArea,
|
||||||
CORBA::Double& theVolume);
|
CORBA::Double& theVolume);
|
||||||
|
@ -10579,6 +10579,8 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
|
|||||||
## Get summarized length of all wires,
|
## Get summarized length of all wires,
|
||||||
# area of surface and volume of the given shape.
|
# area of surface and volume of the given shape.
|
||||||
# @param theShape Shape to define properties of.
|
# @param theShape Shape to define properties of.
|
||||||
|
# @param theTolerance maximal relative error of area
|
||||||
|
# and volume computation.
|
||||||
# @return [theLength, theSurfArea, theVolume]\n
|
# @return [theLength, theSurfArea, theVolume]\n
|
||||||
# theLength: Summarized length of all wires of the given shape.\n
|
# theLength: Summarized length of all wires of the given shape.\n
|
||||||
# theSurfArea: Area of surface of the given shape.\n
|
# theSurfArea: Area of surface of the given shape.\n
|
||||||
@ -10586,13 +10588,15 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
|
|||||||
#
|
#
|
||||||
# @ref tui_basic_properties_page "Example"
|
# @ref tui_basic_properties_page "Example"
|
||||||
@ManageTransactions("MeasuOp")
|
@ManageTransactions("MeasuOp")
|
||||||
def BasicProperties(self,theShape):
|
def BasicProperties(self,theShape, theTolerance=1.e-6):
|
||||||
"""
|
"""
|
||||||
Get summarized length of all wires,
|
Get summarized length of all wires,
|
||||||
area of surface and volume of the given shape.
|
area of surface and volume of the given shape.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
theShape Shape to define properties of.
|
theShape Shape to define properties of.
|
||||||
|
theTolerance maximal relative error of area
|
||||||
|
and volume computation.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
[theLength, theSurfArea, theVolume]
|
[theLength, theSurfArea, theVolume]
|
||||||
@ -10601,7 +10605,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
|
|||||||
theVolume: Volume of the given shape.
|
theVolume: Volume of the given shape.
|
||||||
"""
|
"""
|
||||||
# Example: see GEOM_TestMeasures.py
|
# Example: see GEOM_TestMeasures.py
|
||||||
aTuple = self.MeasuOp.GetBasicProperties(theShape)
|
aTuple = self.MeasuOp.GetBasicProperties(theShape, theTolerance)
|
||||||
RaiseIfFailed("GetBasicProperties", self.MeasuOp)
|
RaiseIfFailed("GetBasicProperties", self.MeasuOp)
|
||||||
return aTuple
|
return aTuple
|
||||||
|
|
||||||
|
@ -37,6 +37,8 @@
|
|||||||
|
|
||||||
#include <TColStd_MapOfInteger.hxx>
|
#include <TColStd_MapOfInteger.hxx>
|
||||||
|
|
||||||
|
#define DEFAULT_TOLERANCE_VALUE 1.e-6
|
||||||
|
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
// class : MeasureGUI_PropertiesDlg()
|
// class : MeasureGUI_PropertiesDlg()
|
||||||
// purpose : Constructs a MeasureGUI_PropertiesDlg which is a child of 'parent', with the
|
// purpose : Constructs a MeasureGUI_PropertiesDlg which is a child of 'parent', with the
|
||||||
@ -45,7 +47,11 @@
|
|||||||
// true to construct a modal dialog.
|
// true to construct a modal dialog.
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
MeasureGUI_PropertiesDlg::MeasureGUI_PropertiesDlg( GeometryGUI* GUI, QWidget* parent )
|
MeasureGUI_PropertiesDlg::MeasureGUI_PropertiesDlg( GeometryGUI* GUI, QWidget* parent )
|
||||||
: MeasureGUI_Skeleton( GUI, parent )
|
: MeasureGUI_Skeleton(GUI, parent),
|
||||||
|
myTolerance(0),
|
||||||
|
myLength(0),
|
||||||
|
mySurface(0),
|
||||||
|
myVolume(0)
|
||||||
{
|
{
|
||||||
QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap(
|
QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap(
|
||||||
"GEOM", tr( "ICON_DLG_BASICPROPERTIES" ) ) );
|
"GEOM", tr( "ICON_DLG_BASICPROPERTIES" ) ) );
|
||||||
@ -59,21 +65,45 @@ MeasureGUI_PropertiesDlg::MeasureGUI_PropertiesDlg( GeometryGUI* GUI, QWidget* p
|
|||||||
mainFrame()->GroupConstructors->setTitle( tr( "GEOM_PROPERTIES" ) );
|
mainFrame()->GroupConstructors->setTitle( tr( "GEOM_PROPERTIES" ) );
|
||||||
mainFrame()->RadioButton1->setIcon( image0 );
|
mainFrame()->RadioButton1->setIcon( image0 );
|
||||||
|
|
||||||
myGrp = new MeasureGUI_1Sel3LineEdit( centralWidget() );
|
QGroupBox *aGrpBox =
|
||||||
myGrp->GroupBox1->setTitle( tr( "GEOM_PROPERTIES_CONSTR" ) );
|
new QGroupBox(tr("GEOM_PROPERTIES_CONSTR"), centralWidget());
|
||||||
myGrp->TextLabel1->setText( tr( "GEOM_OBJECT" ) );
|
QLabel *anObjLbl = new QLabel(tr("GEOM_OBJECT"), aGrpBox);
|
||||||
myGrp->TextLabel2->setText( tr( "GEOM_LENGTH" ) );
|
QLabel *aTolLbl = new QLabel(tr("GEOM_TOLERANCE"), aGrpBox);
|
||||||
myGrp->TextLabel3->setText( tr( "GEOM_PROPERTIES_SURFACE" ) );
|
QLabel *aLenLbl = new QLabel(tr("GEOM_LENGTH"), aGrpBox);
|
||||||
myGrp->TextLabel4->setText( tr( "GEOM_PROPERTIES_VOLUME" ) );
|
QLabel *aSurfLbl = new QLabel(tr("GEOM_PROPERTIES_SURFACE"), aGrpBox);
|
||||||
myGrp->LineEdit1->setReadOnly( true );
|
QLabel *aVolLbl = new QLabel(tr("GEOM_PROPERTIES_VOLUME"), aGrpBox);
|
||||||
myGrp->PushButton1->setIcon( image1 );
|
|
||||||
myGrp->LineEdit2->setReadOnly( true );
|
|
||||||
myGrp->LineEdit3->setReadOnly( true );
|
|
||||||
myGrp->LineEdit4->setReadOnly( true );
|
|
||||||
|
|
||||||
QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
|
mySelBtn = new QPushButton(aGrpBox);
|
||||||
layout->setMargin( 0 ); layout->setSpacing( 6 );
|
mySelBtn->setIcon(image1);
|
||||||
layout->addWidget( myGrp );
|
mySelEdit = new QLineEdit(aGrpBox);
|
||||||
|
mySelEdit->setReadOnly(true);
|
||||||
|
myTolerance = new SalomeApp_DoubleSpinBox(aGrpBox);
|
||||||
|
myLength = new QLineEdit(aGrpBox);
|
||||||
|
mySurface = new QLineEdit(aGrpBox);
|
||||||
|
myVolume = new QLineEdit(aGrpBox);
|
||||||
|
myLength->setReadOnly(true);
|
||||||
|
mySurface->setReadOnly(true);
|
||||||
|
myVolume->setReadOnly(true);
|
||||||
|
|
||||||
|
QGridLayout* aLayout = new QGridLayout(aGrpBox);
|
||||||
|
|
||||||
|
aLayout->setMargin(9);
|
||||||
|
aLayout->setSpacing(6);
|
||||||
|
aLayout->addWidget(anObjLbl, 0, 0);
|
||||||
|
aLayout->addWidget(aTolLbl, 1, 0);
|
||||||
|
aLayout->addWidget(aLenLbl, 2, 0);
|
||||||
|
aLayout->addWidget(aSurfLbl, 3, 0);
|
||||||
|
aLayout->addWidget(aVolLbl, 4, 0);
|
||||||
|
aLayout->addWidget(mySelBtn, 0, 1);
|
||||||
|
aLayout->addWidget(mySelEdit, 0, 2);
|
||||||
|
aLayout->addWidget(myTolerance, 1, 1, 1, 2);
|
||||||
|
aLayout->addWidget(myLength, 2, 1, 1, 2);
|
||||||
|
aLayout->addWidget(mySurface, 3, 1, 1, 2);
|
||||||
|
aLayout->addWidget(myVolume, 4, 1, 1, 2);
|
||||||
|
|
||||||
|
QVBoxLayout* aDlgLayout = new QVBoxLayout( centralWidget() );
|
||||||
|
aDlgLayout->setMargin( 0 ); aDlgLayout->setSpacing( 6 );
|
||||||
|
aDlgLayout->addWidget(aGrpBox);
|
||||||
|
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
|
|
||||||
@ -99,9 +129,24 @@ MeasureGUI_PropertiesDlg::~MeasureGUI_PropertiesDlg()
|
|||||||
//=================================================================================
|
//=================================================================================
|
||||||
void MeasureGUI_PropertiesDlg::Init()
|
void MeasureGUI_PropertiesDlg::Init()
|
||||||
{
|
{
|
||||||
mySelBtn = myGrp->PushButton1;
|
mySelEdit->setMinimumSize(100, 0);
|
||||||
mySelEdit = myGrp->LineEdit1;
|
|
||||||
|
// Obtain precision from preferences
|
||||||
|
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
|
||||||
|
int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
|
||||||
|
|
||||||
|
myTolerance->setPrecision(aPrecision);
|
||||||
|
// it's necessary to set decimals before the range setting,
|
||||||
|
// by default Qt rounds boundaries to 2 decimals at setRange
|
||||||
|
myTolerance->setDecimals(qAbs(aPrecision));
|
||||||
|
myTolerance->setRange(0., 1.);
|
||||||
|
myTolerance->setSingleStep(DEFAULT_TOLERANCE_VALUE);
|
||||||
|
myTolerance->setValue(DEFAULT_TOLERANCE_VALUE);
|
||||||
|
|
||||||
MeasureGUI_Skeleton::Init();
|
MeasureGUI_Skeleton::Init();
|
||||||
|
|
||||||
|
connect(myTolerance, SIGNAL(valueChanged(double)),
|
||||||
|
this, SLOT(toleranceChanged(double)));
|
||||||
}
|
}
|
||||||
|
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
@ -146,6 +191,16 @@ void MeasureGUI_PropertiesDlg::SelectionIntoArgument()
|
|||||||
processObject();
|
processObject();
|
||||||
redisplayPreview();
|
redisplayPreview();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=================================================================================
|
||||||
|
// function : isValid
|
||||||
|
// purpose :
|
||||||
|
//=================================================================================
|
||||||
|
bool MeasureGUI_PropertiesDlg::isValid(QString& msg)
|
||||||
|
{
|
||||||
|
return myTolerance->isValid(msg) && MeasureGUI_Skeleton::isValid(msg);
|
||||||
|
}
|
||||||
|
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
// function : processObject
|
// function : processObject
|
||||||
// purpose :
|
// purpose :
|
||||||
@ -156,16 +211,16 @@ void MeasureGUI_PropertiesDlg::processObject()
|
|||||||
|
|
||||||
if ( !getParameters( aLength, anArea, aVolume ) ) {
|
if ( !getParameters( aLength, anArea, aVolume ) ) {
|
||||||
mySelEdit->setText( "" );
|
mySelEdit->setText( "" );
|
||||||
myGrp->LineEdit2->setText( "" );
|
myLength->setText( "" );
|
||||||
myGrp->LineEdit3->setText( "" );
|
mySurface->setText( "" );
|
||||||
myGrp->LineEdit4->setText( "" );
|
myVolume->setText( "" );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
|
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
|
||||||
int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
|
int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
|
||||||
myGrp->LineEdit2->setText( DlgRef::PrintDoubleValue( aLength, aPrecision ) );
|
myLength->setText( DlgRef::PrintDoubleValue( aLength, aPrecision ) );
|
||||||
myGrp->LineEdit3->setText( DlgRef::PrintDoubleValue( anArea, aPrecision ) );
|
mySurface->setText( DlgRef::PrintDoubleValue( anArea, aPrecision ) );
|
||||||
myGrp->LineEdit4->setText( DlgRef::PrintDoubleValue( aVolume, aPrecision ) );
|
myVolume->setText( DlgRef::PrintDoubleValue( aVolume, aPrecision ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,7 +237,7 @@ bool MeasureGUI_PropertiesDlg::getParameters( double& theLength,
|
|||||||
else {
|
else {
|
||||||
GEOM::GEOM_IMeasureOperations_var anOper = GEOM::GEOM_IMeasureOperations::_narrow( getOperation() );
|
GEOM::GEOM_IMeasureOperations_var anOper = GEOM::GEOM_IMeasureOperations::_narrow( getOperation() );
|
||||||
try {
|
try {
|
||||||
anOper->GetBasicProperties( myObj.get(), theLength, theArea, theVolume );
|
anOper->GetBasicProperties( myObj.get(), myTolerance->value(), theLength, theArea, theVolume );
|
||||||
}
|
}
|
||||||
catch( const SALOME::SALOME_Exception& e ) {
|
catch( const SALOME::SALOME_Exception& e ) {
|
||||||
SalomeApp_Tools::QtCatchCorbaException( e );
|
SalomeApp_Tools::QtCatchCorbaException( e );
|
||||||
@ -210,3 +265,12 @@ SALOME_Prs* MeasureGUI_PropertiesDlg::buildPrs()
|
|||||||
}
|
}
|
||||||
return prs;
|
return prs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=================================================================================
|
||||||
|
// function : toleranceChanged
|
||||||
|
// purpose :
|
||||||
|
//=================================================================================
|
||||||
|
void MeasureGUI_PropertiesDlg::toleranceChanged(double)
|
||||||
|
{
|
||||||
|
processObject();
|
||||||
|
}
|
||||||
|
@ -29,7 +29,8 @@
|
|||||||
|
|
||||||
#include "MeasureGUI_Skeleton.h"
|
#include "MeasureGUI_Skeleton.h"
|
||||||
|
|
||||||
class MeasureGUI_1Sel3LineEdit;
|
class SalomeApp_DoubleSpinBox;
|
||||||
|
class QLineEdit;
|
||||||
|
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
// class : MeasureGUI_PropertiesDlg
|
// class : MeasureGUI_PropertiesDlg
|
||||||
@ -46,6 +47,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
// redefined from GEOMBase_Helper and MeasureGUI_Skeleton
|
// redefined from GEOMBase_Helper and MeasureGUI_Skeleton
|
||||||
|
virtual bool isValid( QString& );
|
||||||
virtual void processObject();
|
virtual void processObject();
|
||||||
virtual void activateSelection();
|
virtual void activateSelection();
|
||||||
virtual void SelectionIntoArgument();
|
virtual void SelectionIntoArgument();
|
||||||
@ -57,8 +59,14 @@ private:
|
|||||||
double&,
|
double&,
|
||||||
double& );
|
double& );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MeasureGUI_1Sel3LineEdit* myGrp;
|
SalomeApp_DoubleSpinBox *myTolerance;
|
||||||
|
QLineEdit *myLength;
|
||||||
|
QLineEdit *mySurface;
|
||||||
|
QLineEdit *myVolume;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void toleranceChanged(double);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MEASUREGUI_PROPERTIESDLG_H
|
#endif // MEASUREGUI_PROPERTIESDLG_H
|
||||||
|
Loading…
Reference in New Issue
Block a user