mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2024-12-25 08:50:36 +05:00
0022380: EDF 2746 GEOM: Accept compounds of points as an input for "Smoothing surface"
This commit is contained in:
parent
bae730c25a
commit
ef20f40494
@ -7,6 +7,8 @@ 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.
|
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.
|
||||||
|
|
||||||
|
\note The dialog accepts compounds of points as well as single nodes.
|
||||||
|
|
||||||
The result of the operation will be a GEOM_Object(Surface).
|
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(Points)</em>
|
||||||
|
@ -3429,7 +3429,7 @@ Handle(GEOM_Object) GEOMImpl_IAdvancedOperations::MakeDividedCylinder (double th
|
|||||||
//=============================================================================
|
//=============================================================================
|
||||||
/*!
|
/*!
|
||||||
* Create a smoothing surface from a set of points
|
* Create a smoothing surface from a set of points
|
||||||
* \param thelPoints list of points
|
* \param thelPoints list of points or compounds of points
|
||||||
* \return New GEOM_Object, containing the created shape.
|
* \return New GEOM_Object, containing the created shape.
|
||||||
*/
|
*/
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
@ -3454,12 +3454,12 @@ Handle(GEOM_Object) GEOMImpl_IAdvancedOperations::MakeSmoothingSurface (std::lis
|
|||||||
int ind = 1;
|
int ind = 1;
|
||||||
std::list<Handle(GEOM_Object)>::iterator it = thelPoints.begin();
|
std::list<Handle(GEOM_Object)>::iterator it = thelPoints.begin();
|
||||||
for (; it != thelPoints.end(); it++, ind++) {
|
for (; it != thelPoints.end(); it++, ind++) {
|
||||||
Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction();
|
Handle(GEOM_Function) aRefObj = (*it)->GetLastFunction();
|
||||||
if (aRefPnt.IsNull()) {
|
if (aRefObj.IsNull()) {
|
||||||
SetErrorCode("NULL point for bSplineFaceShape");
|
SetErrorCode("NULL point or compound for bSplineFaceShape");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
aData.SetPoint(ind, aRefPnt);
|
aData.SetPntOrComp(ind, aRefObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -36,8 +36,8 @@ public:
|
|||||||
void SetLength(int theLen) { _func->SetInteger(SMOOTHINGSURFACE_ARG_LENG, theLen); }
|
void SetLength(int theLen) { _func->SetInteger(SMOOTHINGSURFACE_ARG_LENG, theLen); }
|
||||||
int GetLength() { return _func->GetInteger(SMOOTHINGSURFACE_ARG_LENG); }
|
int GetLength() { return _func->GetInteger(SMOOTHINGSURFACE_ARG_LENG); }
|
||||||
|
|
||||||
void SetPoint(int theId, Handle(GEOM_Function) theP) { _func->SetReference(SMOOTHINGSURFACE_ARG_LAST + theId, theP); }
|
void SetPntOrComp(int theId, Handle(GEOM_Function) theP) { _func->SetReference(SMOOTHINGSURFACE_ARG_LAST + theId, theP); }
|
||||||
Handle(GEOM_Function) GetPoint(int theId) { return _func->GetReference(SMOOTHINGSURFACE_ARG_LAST + theId); }
|
Handle(GEOM_Function) GetPntOrComp(int theId) { return _func->GetReference(SMOOTHINGSURFACE_ARG_LAST + theId); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Handle(GEOM_Function) _func;
|
Handle(GEOM_Function) _func;
|
||||||
|
@ -34,6 +34,9 @@
|
|||||||
#include <TopoDS_Face.hxx>
|
#include <TopoDS_Face.hxx>
|
||||||
#include <TopoDS_Compound.hxx>
|
#include <TopoDS_Compound.hxx>
|
||||||
#include <TopoDS.hxx>
|
#include <TopoDS.hxx>
|
||||||
|
#include <TopTools_MapOfShape.hxx>
|
||||||
|
#include <TopTools_MapIteratorOfMapOfShape.hxx>
|
||||||
|
#include <TopExp_Explorer.hxx>
|
||||||
|
|
||||||
#include <TColgp_SequenceOfPnt.hxx>
|
#include <TColgp_SequenceOfPnt.hxx>
|
||||||
#include <TColgp_Array2OfPnt.hxx>
|
#include <TColgp_Array2OfPnt.hxx>
|
||||||
@ -168,21 +171,42 @@ Standard_Integer GEOMImpl_SmoothingSurfaceDriver::Execute(TFunction_Logbook& log
|
|||||||
|
|
||||||
GEOMImpl_ISmoothingSurface aData (aFunction);
|
GEOMImpl_ISmoothingSurface aData (aFunction);
|
||||||
|
|
||||||
Standard_Integer nbPoints = aData.GetLength();
|
// Fill the map of vertices.
|
||||||
|
Standard_Integer aNbShapes = aData.GetLength();
|
||||||
|
TopTools_MapOfShape aMapPoints;
|
||||||
|
Standard_Integer i;
|
||||||
|
|
||||||
Handle(TColgp_HArray1OfPnt) anArrayofPnt = new TColgp_HArray1OfPnt(1,nbPoints);
|
for (i = 1; i <= aNbShapes; i++) {
|
||||||
for (int ind=1;ind<=nbPoints;ind++)
|
Handle(GEOM_Function) aFShape = aData.GetPntOrComp(i);
|
||||||
{
|
TopoDS_Shape aShape = aFShape->GetValue();
|
||||||
Handle(GEOM_Function) aPoint = aData.GetPoint(ind);
|
|
||||||
TopoDS_Shape aShapePnt = aPoint->GetValue();
|
if (aShape.ShapeType() == TopAbs_VERTEX) {
|
||||||
TopoDS_Vertex dsPoint;
|
aMapPoints.Add(aShape);
|
||||||
dsPoint = TopoDS::Vertex( aShapePnt );
|
} else {
|
||||||
gp_Pnt aPnt = BRep_Tool::Pnt( dsPoint );
|
TopExp_Explorer anExp(aShape, TopAbs_VERTEX);
|
||||||
anArrayofPnt->SetValue(ind,aPnt);
|
|
||||||
|
for (; anExp.More(); anExp.Next()) {
|
||||||
|
aMapPoints.Add(anExp.Current());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TopoDS_Shape aShape;
|
// Add points to the array of points.
|
||||||
aShape = GEOMImpl_SmoothingSurfaceDriver::MakeSmoothingSurfaceUnClosed(anArrayofPnt);
|
const Standard_Integer aNbPoints = aMapPoints.Extent();
|
||||||
|
Handle(TColgp_HArray1OfPnt) anArrayofPnt =
|
||||||
|
new TColgp_HArray1OfPnt(1, aNbPoints);
|
||||||
|
TopTools_MapIteratorOfMapOfShape anIter(aMapPoints);
|
||||||
|
|
||||||
|
for (i = 1; anIter.More(); anIter.Next(), i++) {
|
||||||
|
TopoDS_Vertex aPoint = TopoDS::Vertex(anIter.Key());
|
||||||
|
gp_Pnt aPnt = BRep_Tool::Pnt(aPoint);
|
||||||
|
|
||||||
|
anArrayofPnt->SetValue(i, aPnt);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make smoothing surface.
|
||||||
|
TopoDS_Shape aShape =
|
||||||
|
GEOMImpl_SmoothingSurfaceDriver::MakeSmoothingSurfaceUnClosed(anArrayofPnt);
|
||||||
|
|
||||||
if (aShape.IsNull()) return 0;
|
if (aShape.IsNull()) return 0;
|
||||||
|
|
||||||
@ -217,7 +241,7 @@ GetCreationInformation(std::string& theOperationName,
|
|||||||
if ( aCI.GetLength() > 1 )
|
if ( aCI.GetLength() > 1 )
|
||||||
theParams[0] << aCI.GetLength() << " points: ";
|
theParams[0] << aCI.GetLength() << " points: ";
|
||||||
for ( int i = 1, nb = aCI.GetLength(); i <= nb; ++i )
|
for ( int i = 1, nb = aCI.GetLength(); i <= nb; ++i )
|
||||||
theParams[0] << aCI.GetPoint( i ) << " ";
|
theParams[0] << aCI.GetPntOrComp( i ) << " ";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
// OCCT Includes
|
// OCCT Includes
|
||||||
#include <TopoDS_Shape.hxx>
|
#include <TopoDS_Shape.hxx>
|
||||||
#include <TopoDS.hxx>
|
#include <TopoDS.hxx>
|
||||||
|
#include <TopoDS_Iterator.hxx>
|
||||||
#include <TopExp.hxx>
|
#include <TopExp.hxx>
|
||||||
#include <TColStd_IndexedMapOfInteger.hxx>
|
#include <TColStd_IndexedMapOfInteger.hxx>
|
||||||
#include <TopTools_IndexedMapOfShape.hxx>
|
#include <TopTools_IndexedMapOfShape.hxx>
|
||||||
@ -208,16 +209,80 @@ bool AdvancedGUI_SmoothingSurfaceDlg::execute (ObjectList& objects)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=================================================================================
|
||||||
|
// function : getNbPoints()
|
||||||
|
// purpose : Returns the number of points in myPoints list.
|
||||||
|
//=================================================================================
|
||||||
|
int AdvancedGUI_SmoothingSurfaceDlg::getNbPoints() const
|
||||||
|
{
|
||||||
|
TopTools_IndexedMapOfShape aMap;
|
||||||
|
|
||||||
|
foreach (GEOM::GeomObjPtr anObj, myPoints) {
|
||||||
|
TopoDS_Shape aShape;
|
||||||
|
|
||||||
|
if(anObj && GEOMBase::GetShape(anObj.get(), aShape) && !aShape.IsNull()) {
|
||||||
|
if (aShape.ShapeType() == TopAbs_VERTEX) {
|
||||||
|
aMap.Add(aShape);
|
||||||
|
} else {
|
||||||
|
// Compound.
|
||||||
|
TopExp::MapShapes(aShape, TopAbs_VERTEX, aMap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const int aNbPoints = aMap.Extent();
|
||||||
|
|
||||||
|
return aNbPoints;
|
||||||
|
}
|
||||||
|
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
// function : SelectionIntoArgument()
|
// function : SelectionIntoArgument()
|
||||||
// purpose : Called when selection as changed or other case
|
// purpose : Called when selection as changed or other case
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
void AdvancedGUI_SmoothingSurfaceDlg::SelectionIntoArgument()
|
void AdvancedGUI_SmoothingSurfaceDlg::SelectionIntoArgument()
|
||||||
{
|
{
|
||||||
QList<GEOM::GeomObjPtr> points = getSelected( TopAbs_VERTEX, -1 );
|
QList<TopAbs_ShapeEnum> aTypes;
|
||||||
|
|
||||||
|
aTypes << TopAbs_VERTEX << TopAbs_COMPOUND;
|
||||||
|
|
||||||
|
QList<GEOM::GeomObjPtr> points = getSelected( aTypes, -1 );
|
||||||
|
|
||||||
|
// Check the selected compounds if they consist of points only.
|
||||||
|
foreach (GEOM::GeomObjPtr anObj, points) {
|
||||||
|
TopoDS_Shape aShape;
|
||||||
|
|
||||||
|
if(anObj && GEOMBase::GetShape(anObj.get(), aShape) && !aShape.IsNull()) {
|
||||||
|
if (aShape.ShapeType() == TopAbs_COMPOUND) {
|
||||||
|
// Check if the compound contains vertices only.
|
||||||
|
TopoDS_Iterator anIter(aShape);
|
||||||
|
Standard_Boolean isValid = Standard_False;
|
||||||
|
|
||||||
|
for (; anIter.More(); anIter.Next()) {
|
||||||
|
const TopoDS_Shape &aSubShape = anIter.Value();
|
||||||
|
|
||||||
|
if (aSubShape.ShapeType() == TopAbs_VERTEX) {
|
||||||
|
isValid = Standard_True;
|
||||||
|
} else {
|
||||||
|
isValid = Standard_False;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isValid) {
|
||||||
|
points.clear();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// NEVERREACHED
|
||||||
|
points.clear();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GEOMBase::Synchronize( myPoints, points );
|
GEOMBase::Synchronize( myPoints, points );
|
||||||
if ( !myPoints.isEmpty() )
|
if ( !myPoints.isEmpty() )
|
||||||
GroupPoints->LineEdit1->setText( QString::number( myPoints.count() ) + "_" + tr( "GEOM_POINT" ) + tr( "_S_" ) );
|
GroupPoints->LineEdit1->setText( QString::number( getNbPoints() ) + "_" + tr( "GEOM_POINT" ) + tr( "_S_" ) );
|
||||||
else
|
else
|
||||||
GroupPoints->LineEdit1->setText( "" );
|
GroupPoints->LineEdit1->setText( "" );
|
||||||
processPreview();
|
processPreview();
|
||||||
|
@ -48,6 +48,7 @@ protected:
|
|||||||
private:
|
private:
|
||||||
void Init();
|
void Init();
|
||||||
void enterEvent( QEvent* );
|
void enterEvent( QEvent* );
|
||||||
|
int getNbPoints() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DlgRef_1Sel* GroupPoints;
|
DlgRef_1Sel* GroupPoints;
|
||||||
|
3
src/GEOM_SWIG/geomBuilder.py
Normal file → Executable file
3
src/GEOM_SWIG/geomBuilder.py
Normal file → Executable file
@ -12629,7 +12629,8 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
|
|||||||
return anObj
|
return anObj
|
||||||
|
|
||||||
## Create a surface from a cloud of points
|
## Create a surface from a cloud of points
|
||||||
# @param thelPoints list of points
|
# @param thelPoints list of points. Compounds of points are
|
||||||
|
# accepted as well.
|
||||||
# @return New GEOM_Object, containing the created shape.
|
# @return New GEOM_Object, containing the created shape.
|
||||||
#
|
#
|
||||||
# @ref tui_creation_smoothingsurface "Example"
|
# @ref tui_creation_smoothingsurface "Example"
|
||||||
|
Loading…
Reference in New Issue
Block a user