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).
<b>TUI Command:</b> <em>geompy.MakeSmoothingSurface(Points)</em>
//=============================================================================
/*!
* 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.
*/
//=============================================================================
int ind = 1;
std::list<Handle(GEOM_Object)>::iterator it = thelPoints.begin();
for (; it != thelPoints.end(); it++, ind++) {
- Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction();
- if (aRefPnt.IsNull()) {
- SetErrorCode("NULL point for bSplineFaceShape");
+ Handle(GEOM_Function) aRefObj = (*it)->GetLastFunction();
+ if (aRefObj.IsNull()) {
+ SetErrorCode("NULL point or compound for bSplineFaceShape");
return NULL;
}
- aData.SetPoint(ind, aRefPnt);
+ aData.SetPntOrComp(ind, aRefObj);
}
void SetLength(int theLen) { _func->SetInteger(SMOOTHINGSURFACE_ARG_LENG, theLen); }
int GetLength() { return _func->GetInteger(SMOOTHINGSURFACE_ARG_LENG); }
- void SetPoint(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); }
+ 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); }
private:
Handle(GEOM_Function) _func;
#include <TopoDS_Face.hxx>
#include <TopoDS_Compound.hxx>
#include <TopoDS.hxx>
+#include <TopTools_MapOfShape.hxx>
+#include <TopTools_MapIteratorOfMapOfShape.hxx>
+#include <TopExp_Explorer.hxx>
#include <TColgp_SequenceOfPnt.hxx>
#include <TColgp_Array2OfPnt.hxx>
// cout << "Youhou : " << aType << endl;
GEOMImpl_ISmoothingSurface aData (aFunction);
-
- Standard_Integer nbPoints = aData.GetLength();
- Handle(TColgp_HArray1OfPnt) anArrayofPnt = new TColgp_HArray1OfPnt(1,nbPoints);
- for (int ind=1;ind<=nbPoints;ind++)
- {
- Handle(GEOM_Function) aPoint = aData.GetPoint(ind);
- TopoDS_Shape aShapePnt = aPoint->GetValue();
- TopoDS_Vertex dsPoint;
- dsPoint = TopoDS::Vertex( aShapePnt );
- gp_Pnt aPnt = BRep_Tool::Pnt( dsPoint );
- anArrayofPnt->SetValue(ind,aPnt);
+ // Fill the map of vertices.
+ Standard_Integer aNbShapes = aData.GetLength();
+ TopTools_MapOfShape aMapPoints;
+ Standard_Integer i;
+
+ for (i = 1; i <= aNbShapes; i++) {
+ Handle(GEOM_Function) aFShape = aData.GetPntOrComp(i);
+ TopoDS_Shape aShape = aFShape->GetValue();
+
+ if (aShape.ShapeType() == TopAbs_VERTEX) {
+ aMapPoints.Add(aShape);
+ } else {
+ TopExp_Explorer anExp(aShape, TopAbs_VERTEX);
+
+ for (; anExp.More(); anExp.Next()) {
+ aMapPoints.Add(anExp.Current());
+ }
+ }
+ }
+
+ // Add points to the array of points.
+ 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);
}
- TopoDS_Shape aShape;
- aShape = GEOMImpl_SmoothingSurfaceDriver::MakeSmoothingSurfaceUnClosed(anArrayofPnt);
+ // Make smoothing surface.
+ TopoDS_Shape aShape =
+ GEOMImpl_SmoothingSurfaceDriver::MakeSmoothingSurfaceUnClosed(anArrayofPnt);
if (aShape.IsNull()) return 0;
if ( aCI.GetLength() > 1 )
theParams[0] << aCI.GetLength() << " points: ";
for ( int i = 1, nb = aCI.GetLength(); i <= nb; ++i )
- theParams[0] << aCI.GetPoint( i ) << " ";
+ theParams[0] << aCI.GetPntOrComp( i ) << " ";
break;
default:
return false;
// OCCT Includes
#include <TopoDS_Shape.hxx>
#include <TopoDS.hxx>
+#include <TopoDS_Iterator.hxx>
#include <TopExp.hxx>
#include <TColStd_IndexedMapOfInteger.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
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()
// purpose : Called when selection as changed or other case
//=================================================================================
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 );
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
GroupPoints->LineEdit1->setText( "" );
processPreview();
private:
void Init();
void enterEvent( QEvent* );
+ int getNbPoints() const;
private:
DlgRef_1Sel* GroupPoints;
return anObj
## 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.
#
# @ref tui_creation_smoothingsurface "Example"