0022475: EDF 2811 GEOM: Features for "Smoothing Surface" function

This commit is contained in:
skv 2014-03-26 13:07:43 +04:00
parent ef20f40494
commit a4aaa470ae
15 changed files with 199 additions and 38 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View File

@ -5,13 +5,20 @@
To create a <b> Smoothing Surface</b> in the <b>Main Menu</b> select <b>New Entity - >
Advanced - > SmoothingSurface </b>
Specify the \b Name of the surface and the list of \b Points, from which it is approximated and press "Apply" or "Apply & Close" button.
To create a surface it is necessary to specify the \b Name of the surface, the list of \b Points
from which it is approximated and some plate approximation parameters such as: <b>Max nbr of
Bezier pieces</b>, <b>Max BSpline surface degree</b> and <b>Max plate criterion value</b>.
And then press "Apply" or "Apply & Close" button.
\note The dialog accepts compounds of points as well as single nodes.
The result of the operation will be a GEOM_Object(Surface).
<b>TUI Command:</b> <em>geompy.MakeSmoothingSurface(Points)</em>
<b>TUI Command:</b> <em>geompy.MakeSmoothingSurface(thelPoints, theNbMax, theDegMax, theDMax)</em>, where:
- \em thelPoints list of points. Compounds of points are accepted as well
- \em theNbMax maximum number of Bezier pieces in the resulting surface
- \em theDegMax maximum degree of the resulting BSpline surface
- \em theDMax specifies maximum value of the GeomPlate_PlateG0Criterion criterion
\image html smoothingsurface_dlg.png

View File

@ -4694,10 +4694,16 @@ module GEOM
/*!
*
* Create a smoothing surface from a set of points
* \param thelPoints list of points
* \param thelPoints list of points. Compounds of points are accepted as well.
* \param theNbMax maximum number of Bezier pieces in the resulting surface.
* \param theDegMax maximum degree of the resulting BSpline surface
* \param theDMax specifies maximum value of the GeomPlate_PlateG0Criterion criterion.
* \return New GEOM_Object, containing the created shape.
*/
GEOM_Object MakeSmoothingSurface (in ListOfGO thelPoints);
GEOM_Object MakeSmoothingSurface (in ListOfGO thelPoints,
in long theNbMax,
in long theDegMax,
in double theDMax);
/*@@ insert new functions before this line @@ do not remove this line @@*/
};

View File

@ -3430,10 +3430,16 @@ Handle(GEOM_Object) GEOMImpl_IAdvancedOperations::MakeDividedCylinder (double th
/*!
* Create a smoothing surface from a set of points
* \param thelPoints list of points or compounds of points
* \param theNbMax maximum number of Bezier pieces in the resulting surface.
* \param theDegMax maximum degree of the resulting BSpline surface
* \param theDMax specifies maximum value of the GeomPlate_PlateG0Criterion criterion.
* \return New GEOM_Object, containing the created shape.
*/
//=============================================================================
Handle(GEOM_Object) GEOMImpl_IAdvancedOperations::MakeSmoothingSurface (std::list<Handle(GEOM_Object)> thelPoints)
Handle(GEOM_Object) GEOMImpl_IAdvancedOperations::MakeSmoothingSurface (std::list<Handle(GEOM_Object)> thelPoints,
int theNbMax,
int theDegMax,
double theDMax)
{
SetErrorCode(KO);
@ -3462,6 +3468,9 @@ Handle(GEOM_Object) GEOMImpl_IAdvancedOperations::MakeSmoothingSurface (std::lis
aData.SetPntOrComp(ind, aRefObj);
}
aData.SetNbMax(theNbMax);
aData.SetDegMax(theDegMax);
aData.SetDMax(theDMax);
//Compute the resulting value
try {
@ -3487,7 +3496,10 @@ Handle(GEOM_Object) GEOMImpl_IAdvancedOperations::MakeSmoothingSurface (std::lis
while (it != thelPoints.end()) {
pd << ", " << (*it++);
}
pd << "])";
pd << "], "
<< theNbMax << ", "
<< theDegMax << ", "
<< theDMax <<")";
SetErrorCode(OK);

View File

@ -236,7 +236,10 @@ public:
double theH,
int thePattern);
Standard_EXPORT Handle(GEOM_Object) MakeSmoothingSurface (std::list<Handle(GEOM_Object)> thelPoints);
Standard_EXPORT Handle(GEOM_Object) MakeSmoothingSurface (std::list<Handle(GEOM_Object)> thelPoints,
int theNbMax,
int theDegMax,
double theDMax);
/*@@ insert new functions before this line @@ do not remove this line @@*/
};
#endif

View File

@ -27,6 +27,9 @@
#define SMOOTHINGSURFACE_ARG_LENG 1
#define SMOOTHINGSURFACE_ARG_LAST 2
#define SMOOTHINGSURFACE_ARG_NB_MAX 3
#define SMOOTHINGSURFACE_ARG_DEG_MAX 4
#define SMOOTHINGSURFACE_ARG_D_MAX 5
class GEOMImpl_ISmoothingSurface
{
@ -39,6 +42,15 @@ public:
void SetPntOrComp(int theId, Handle(GEOM_Function) theP) { _func->SetReference(SMOOTHINGSURFACE_ARG_LAST + theId, theP); }
Handle(GEOM_Function) GetPntOrComp(int theId) { return _func->GetReference(SMOOTHINGSURFACE_ARG_LAST + theId); }
void SetNbMax(int theNbMax) { _func->SetInteger(SMOOTHINGSURFACE_ARG_NB_MAX, theNbMax); }
int GetNbMax() { return _func->GetInteger(SMOOTHINGSURFACE_ARG_NB_MAX); }
void SetDegMax(int theDegMax) { _func->SetInteger(SMOOTHINGSURFACE_ARG_DEG_MAX, theDegMax); }
int GetDegMax() { return _func->GetInteger(SMOOTHINGSURFACE_ARG_DEG_MAX); }
void SetDMax(double theDMax) { _func->SetReal(SMOOTHINGSURFACE_ARG_D_MAX, theDMax); }
double GetDMax() { return _func->GetReal(SMOOTHINGSURFACE_ARG_D_MAX); }
private:
Handle(GEOM_Function) _func;
};

View File

@ -98,13 +98,17 @@ GEOMImpl_SmoothingSurfaceDriver::GEOMImpl_SmoothingSurfaceDriver()
//function : MakeSmoothingSurfaceUnClosed
//purpose :
//=======================================================================
TopoDS_Shape GEOMImpl_SmoothingSurfaceDriver::MakeSmoothingSurfaceUnClosed(Handle_TColgp_HArray1OfPnt myListOfPoints) const
TopoDS_Shape GEOMImpl_SmoothingSurfaceDriver::MakeSmoothingSurfaceUnClosed
(const Handle_TColgp_HArray1OfPnt &theListOfPoints,
const Standard_Integer theNbMax,
const Standard_Integer theDegMax,
const Standard_Real theDMax) const
{
TopoDS_Face aInitShape;
// Create an average Plane
//Handle(TColgp_HArray1OfPnt) HAP = new TColgp_HArray1OfPnt(1,myListOfPoints.Length())
GeomPlate_BuildAveragePlane gpbap(myListOfPoints,myListOfPoints->Length(),Precision::Confusion(),1,1);
//Handle(TColgp_HArray1OfPnt) HAP = new TColgp_HArray1OfPnt(1,theListOfPoints.Length())
GeomPlate_BuildAveragePlane gpbap(theListOfPoints,theListOfPoints->Length(),Precision::Confusion(),1,1);
Handle(Geom_Plane) plane(gpbap.Plane());
Standard_Real Umin, Umax, Vmin, Vmax;
gpbap.MinMaxBox(Umin,Umax,Vmin,Vmax);
@ -121,11 +125,11 @@ TopoDS_Shape GEOMImpl_SmoothingSurfaceDriver::MakeSmoothingSurfaceUnClosed(Handl
Standard_Integer j, j1, j2;
// cout << "Init surface" << endl;
j1 = myListOfPoints->Lower();
j2 = myListOfPoints->Upper();
j1 = theListOfPoints->Lower();
j2 = theListOfPoints->Upper();
for (j=j1; j<=j2 ; j++)
{
gp_Pnt aPnt = myListOfPoints->Value(j);
gp_Pnt aPnt = theListOfPoints->Value(j);
Handle(GeomPlate_PointConstraint) PCont = new GeomPlate_PointConstraint(aPnt,0);
aBuilder.Add(PCont);
}
@ -136,10 +140,14 @@ TopoDS_Shape GEOMImpl_SmoothingSurfaceDriver::MakeSmoothingSurfaceUnClosed(Handl
// A ce niveau : surface algo
Handle(GeomPlate_Surface) gpPlate = aBuilder.Surface();
Standard_Integer nbcarreau=2;
Standard_Integer degmax=8;
Standard_Real seuil;
seuil = Max(0.0001,10*aBuilder.G0Error());
Standard_Integer nbcarreau = (theNbMax > 0 ? theNbMax : 2);
Standard_Integer degmax = (theDegMax > 0 ? theDegMax : 8);
Standard_Real seuil = theDMax;
if (seuil <= 0.) {
seuil = Max(0.0001,10*aBuilder.G0Error());
}
GeomPlate_MakeApprox Mapp(gpPlate,0.0001,nbcarreau,degmax,seuil);
// cout << "Approx surface" << endl;
@ -204,9 +212,13 @@ Standard_Integer GEOMImpl_SmoothingSurfaceDriver::Execute(TFunction_Logbook& log
anArrayofPnt->SetValue(i, aPnt);
}
const Standard_Integer aNbMax = aData.GetNbMax();
const Standard_Integer aDegMax = aData.GetDegMax();
const Standard_Real aDMax = aData.GetDMax();
// Make smoothing surface.
TopoDS_Shape aShape =
GEOMImpl_SmoothingSurfaceDriver::MakeSmoothingSurfaceUnClosed(anArrayofPnt);
TopoDS_Shape aShape = GEOMImpl_SmoothingSurfaceDriver::
MakeSmoothingSurfaceUnClosed(anArrayofPnt, aNbMax, aDegMax, aDMax);
if (aShape.IsNull()) return 0;
@ -237,11 +249,21 @@ GetCreationInformation(std::string& theOperationName,
switch ( aType ) {
case SMOOTHINGSURFACE_LPOINTS:
AddParam( theParams, "Points" );
if ( aCI.GetLength() > 1 )
theParams[0] << aCI.GetLength() << " points: ";
for ( int i = 1, nb = aCI.GetLength(); i <= nb; ++i )
theParams[0] << aCI.GetPntOrComp( i ) << " ";
{
AddParam( theParams, "Points" );
if ( aCI.GetLength() > 1 )
theParams[0] << aCI.GetLength() << " points: ";
for ( int i = 1, nb = aCI.GetLength(); i <= nb; ++i )
theParams[0] << aCI.GetPntOrComp( i ) << " ";
const Standard_Integer aNbMax = aCI.GetNbMax();
const Standard_Integer aDegMax = aCI.GetDegMax();
const Standard_Real aDMax = aCI.GetDMax();
AddParam(theParams, "Max nbr of Bezier pieces", aCI.GetNbMax());
AddParam(theParams, "Max BSpline surface degree", aCI.GetDegMax());
AddParam(theParams, "Max plate criterion value", aCI.GetDMax());
}
break;
default:
return false;

View File

@ -63,7 +63,11 @@ public:
DEFINE_STANDARD_RTTI( GEOMImpl_SmoothingSurfaceDriver )
private:
TopoDS_Shape MakeSmoothingSurfaceUnClosed(Handle_TColgp_HArray1OfPnt myListOfPoints) const;
TopoDS_Shape MakeSmoothingSurfaceUnClosed
(const Handle_TColgp_HArray1OfPnt &theListOfPoints,
const Standard_Integer theNbMax,
const Standard_Integer theDegMax,
const Standard_Real theDMax) const;
};
#endif // _GEOMImpl_SmoothingSurfaceDriver_HXX

View File

@ -755,10 +755,16 @@ GEOM::GEOM_Object_ptr GEOM_IAdvancedOperations_i::MakeDividedCylinder (CORBA::Do
/*!
*
* \param thelPoints list of points
* \param theNbMax maximum number of Bezier pieces in the resulting surface.
* \param theDegMax maximum degree of the resulting BSpline surface
* \param theDMax specifies maximum value of the GeomPlate_PlateG0Criterion criterion.
* \return New GEOM_Object, containing the created shape.
*/
//=============================================================================
GEOM::GEOM_Object_ptr GEOM_IAdvancedOperations_i::MakeSmoothingSurface (const GEOM::ListOfGO& thelPoints)
GEOM::GEOM_Object_ptr GEOM_IAdvancedOperations_i::MakeSmoothingSurface (const GEOM::ListOfGO& thelPoints,
CORBA::Long theNbMax,
CORBA::Long theDegMax,
CORBA::Double theDMax)
{
GEOM::GEOM_Object_var aGEOMObject;
@ -775,7 +781,8 @@ GEOM::GEOM_Object_ptr GEOM_IAdvancedOperations_i::MakeSmoothingSurface (const GE
aPoints.push_back(aPnt);
}
//Create the SmoothingSurface
Handle(GEOM_Object) anObject = GetOperations()->MakeSmoothingSurface(aPoints);
Handle(GEOM_Object) anObject = GetOperations()->MakeSmoothingSurface
(aPoints, theNbMax, theDegMax, theDMax);
if (!GetOperations()->IsDone() || anObject.IsNull())
return aGEOMObject._retn();

View File

@ -127,7 +127,10 @@ class ADVANCEDENGINE_EXPORT GEOM_IAdvancedOperations_i :
GEOM::GEOM_Object_ptr MakeDividedCylinder (CORBA::Double theR,
CORBA::Double theH,
GEOM::pattern thePattern);
GEOM::GEOM_Object_ptr MakeSmoothingSurface (const GEOM::ListOfGO& thelPoints);
GEOM::GEOM_Object_ptr MakeSmoothingSurface (const GEOM::ListOfGO& thelPoints,
CORBA::Long theNbMax,
CORBA::Long theDegMax,
CORBA::Double theDMax);
/*@@ insert new functions before this line @@ do not remove this line @@*/
::GEOMImpl_IAdvancedOperations* GetOperations()

View File

@ -42,7 +42,10 @@
// Constructor
//=================================================================================
AdvancedGUI_SmoothingSurfaceDlg::AdvancedGUI_SmoothingSurfaceDlg (GeometryGUI* theGeometryGUI, QWidget* parent)
: GEOMBase_Skeleton(theGeometryGUI, parent, false)
: GEOMBase_Skeleton(theGeometryGUI, parent, false),
myNbMaxSpin(0),
myDegMaxSpin(0),
myDMaxSpin(0)
{
QPixmap imageOp (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_SMOOTHINGSURFACE_LPOINTS")));
QPixmap imageSel (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT")));
@ -65,6 +68,20 @@ AdvancedGUI_SmoothingSurfaceDlg::AdvancedGUI_SmoothingSurfaceDlg (GeometryGUI* t
GroupPoints->PushButton1->setIcon( image1 );
GroupPoints->LineEdit1->setReadOnly( true );
QLabel *aNbMax = new QLabel(tr("GEOM_SMOOTHINGSURFACE_ARG_NB_MAX"));
QLabel *aDegMax = new QLabel(tr("GEOM_SMOOTHINGSURFACE_ARG_DEG_MAX"));
QLabel *aDMax = new QLabel(tr("GEOM_SMOOTHINGSURFACE_ARG_D_MAX"));
myNbMaxSpin = new SalomeApp_IntSpinBox(0, 1000, 1, 0, true, true);
myDegMaxSpin = new SalomeApp_IntSpinBox(0, 1000, 1, 0, true, true);
myDMaxSpin = new SalomeApp_DoubleSpinBox;
GroupPoints->gridLayout1->addWidget(aNbMax, 1, 0);
GroupPoints->gridLayout1->addWidget(aDegMax, 2, 0);
GroupPoints->gridLayout1->addWidget(aDMax, 3, 0);
GroupPoints->gridLayout1->addWidget(myNbMaxSpin, 1, 1, 1, 2);
GroupPoints->gridLayout1->addWidget(myDegMaxSpin, 2, 1, 1, 2);
GroupPoints->gridLayout1->addWidget(myDMaxSpin, 3, 1, 1, 2);
QVBoxLayout* layout = new QVBoxLayout(centralWidget());
layout->setMargin(0); layout->setSpacing(6);
layout->addWidget(GroupPoints);
@ -91,7 +108,12 @@ void AdvancedGUI_SmoothingSurfaceDlg::Init()
{
// Get setting of step value from file configuration
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100);
initSpinBox(myDMaxSpin, 0., COORD_MAX, 0.00001, "parametric_precision" );
myNbMaxSpin->setValue(2);
myDegMaxSpin->setValue(8);
myDMaxSpin->setValue(0.);
//@@ initialize dialog box widgets here @@//
@ -102,7 +124,13 @@ void AdvancedGUI_SmoothingSurfaceDlg::Init()
this, SLOT(SetDoubleSpinBoxStep(double)));
connect( myGeomGUI->getApp()->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
connect(myNbMaxSpin, SIGNAL(valueChanged(const QString&)),
this, SLOT(processPreview()) );
connect(myDegMaxSpin, SIGNAL(valueChanged(const QString&)),
this, SLOT(processPreview()) );
connect(myDMaxSpin, SIGNAL(valueChanged(const QString&)),
this, SLOT(processPreview()) );
initName(tr("GEOM_SMOOTHINGSURFACE"));
//displayPreview();
}
@ -167,9 +195,14 @@ GEOM::GEOM_IOperations_ptr AdvancedGUI_SmoothingSurfaceDlg::createOperation()
//=================================================================================
bool AdvancedGUI_SmoothingSurfaceDlg::isValid (QString& msg)
{
bool ok = true;
if (myPoints.empty()) {
msg += tr("GEOM_SMOOTHINGSURFACE_NO_POINTS");
return false;
}
//@@ add custom validation actions here @@//
bool ok = myNbMaxSpin->isValid (msg, !IsPreview()) &&
myDegMaxSpin->isValid(msg, !IsPreview()) &&
myDMaxSpin->isValid (msg, !IsPreview());
return ok;
}
@ -192,9 +225,12 @@ bool AdvancedGUI_SmoothingSurfaceDlg::execute (ObjectList& objects)
for ( int i = 0; i < myPoints.count(); i++ )
points[i] = myPoints[i].copy();
const int aNbMax = myNbMaxSpin->value();
const int aDegMax = myDegMaxSpin->value();
const double aDMax = myDMaxSpin->value();
// call engine function
anObj = anOper->MakeSmoothingSurface(points);
anObj = anOper->MakeSmoothingSurface(points, aNbMax, aDegMax, aDMax);
res = !anObj->_is_nil();
if (res && !IsPreview())
{

View File

@ -26,6 +26,7 @@
#include <list>
class DlgRef_1Sel;
class SalomeApp_IntSpinBox;
//=================================================================================
// class : AdvancedGUI_SmoothingSurfaceDlg
@ -53,6 +54,9 @@ private:
private:
DlgRef_1Sel* GroupPoints;
QList<GEOM::GeomObjPtr> myPoints;
SalomeApp_IntSpinBox *myNbMaxSpin;
SalomeApp_IntSpinBox *myDegMaxSpin;
SalomeApp_DoubleSpinBox *myDMaxSpin;
private slots:
void ClickOnOk();

View File

@ -287,11 +287,27 @@
</message>
<message>
<source>GEOM_SMOOTHINGSURFACE_ARG</source>
<translation>Nodes</translation>
<translation>Arguments</translation>
</message>
<message>
<source>GEOM_SMOOTHINGSURFACE_ARG_POINTS</source>
<translation>Points</translation>
</message>
<message>
<source>GEOM_SMOOTHINGSURFACE_ARG_NB_MAX</source>
<translation>Max nbr of Bezier pieces</translation>
</message>
<message>
<source>GEOM_SMOOTHINGSURFACE_ARG_DEG_MAX</source>
<translation>Max BSpline surface degree</translation>
</message>
<message>
<source>GEOM_SMOOTHINGSURFACE_ARG_D_MAX</source>
<translation>Max plate criterion value</translation>
</message>
<message>
<source>GEOM_SMOOTHINGSURFACE_NO_POINTS</source>
<translation>No points selected</translation>
</message>
</context>
</TS>

View File

@ -3516,7 +3516,7 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeSmoothingSurface (GEOM::GEOM_List_ptr t
if (GEOM_List_i<GEOM::ListOfGO>* aListImplP =
dynamic_cast<GEOM_List_i<GEOM::ListOfGO>*>(GetServant(thelPoints, myPOA).in())) {
getCurvesOp();
GEOM::GEOM_Object_ptr anObj = myAdvancedOp->MakeSmoothingSurface(aListImplP->GetList());
GEOM::GEOM_Object_ptr anObj = myAdvancedOp->MakeSmoothingSurface(aListImplP->GetList(), 2, 8, 0.);
endService( " GEOM_Superv_i::MakeSmoothingSurface" );
return anObj;
}

33
src/GEOM_SWIG/geomBuilder.py Executable file → Normal file
View File

@ -12631,12 +12631,41 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
## Create a surface from a cloud of points
# @param thelPoints list of points. Compounds of points are
# accepted as well.
# @param theNbMax maximum number of Bezier pieces in the resulting
# surface.
# @param theDegMax maximum degree of the resulting BSpline surface.
# @param theDMax specifies maximum value of the
# GeomPlate_PlateG0Criterion criterion.
# @param theName Object name; when specified, this parameter is used
# for result publication in the study. Otherwise, if automatic
# publication is switched on, default value is used for result name.
# @return New GEOM_Object, containing the created shape.
#
# @ref tui_creation_smoothingsurface "Example"
def MakeSmoothingSurface(self, thelPoints):
anObj = self.AdvOp.MakeSmoothingSurface(thelPoints)
def MakeSmoothingSurface(self, thelPoints, theNbMax=2, theDegMax=8,
theDMax=0.0, theName=None):
"""
Create a surface from a cloud of points
Parameters:
thelPoints list of points. Compounds of points are
accepted as well.
theNbMax maximum number of Bezier pieces in the resulting
surface.
theDegMax maximum degree of the resulting BSpline surface.
theDMax specifies maximum value of the
GeomPlate_PlateG0Criterion criterion.
theName Object name; when specified, this parameter is used
for result publication in the study. Otherwise, if automatic
publication is switched on, default value is used for result name.
Returns:
New GEOM_Object, containing the created shape.
"""
anObj = self.AdvOp.MakeSmoothingSurface
(thelPoints, theNbMax, theDegMax, theDMax)
RaiseIfFailed("MakeSmoothingSurface", self.AdvOp)
self._autoPublish(anObj, theName, "smoothing")
return anObj
## Export a shape to XAO format