From: fps Date: Fri, 4 Nov 2011 11:11:22 +0000 (+0000) Subject: Create a spehre surface X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d0ff2afc6f6112e08a0685c70353cf6cd97f209b;p=modules%2Fgeom.git Create a spehre surface --- diff --git a/src/GEOMImpl/GEOMImpl_SmoothingSurfaceDriver.cxx b/src/GEOMImpl/GEOMImpl_SmoothingSurfaceDriver.cxx index 0ea77cb95..03da412c0 100644 --- a/src/GEOMImpl/GEOMImpl_SmoothingSurfaceDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_SmoothingSurfaceDriver.cxx @@ -32,19 +32,28 @@ //@@ include required header files here @@// #include #include +#include #include -#include + #include #include -/*#include -#include -#include -#include -#include */ +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include //======================================================================= //function : GetID @@ -82,22 +91,57 @@ Standard_Integer GEOMImpl_SmoothingSurfaceDriver::Execute(TFunction_Logbook& log GEOMImpl_ISmoothingSurface aData (aFunction); - /*bool isClosed = aData.GetisClosed(); - int nbPoints = aData.GetLength();*/ + bool isClosed = aData.GetisClosed(); + int nbPoints = aData.GetLength(); TopoDS_Shape aShape; - /*if (isClosed) + GeomPlate_BuildPlateSurface aBuilder(3,0); + if (isClosed) { - // Surface initiale : Sphere + // Initial surface : Sphere + // ** Creation of compound + BRep_Builder aB; + TopoDS_Compound aComp; + aB.MakeCompound(aComp); + for (int ind=1;ind<=nbPoints;ind++) + { + Handle(GEOM_Function) aPoint = aData.GetPoint(ind); + TopoDS_Shape aShapePnt = aPoint->GetValue(); + aB.Add(aComp,aShapePnt); + } + // ** Retrieve center of mass + GProp_GProps aSystem; + BRepGProp::SurfaceProperties(aComp, aSystem); + gp_Pnt aCenterMass = aSystem.CentreOfMass(); + // ** Computation of radius + Bnd_Box BoundingBox; + Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax; + BRepBndLib::Add(aComp, BoundingBox); + BoundingBox.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax); + Standard_Real aRMax = aXmax-aXmin; + if (aRMax < aYmax-aYmin ) + aRMax = aYmax-aYmin; + if (aRMax < aZmax-aZmin ) + aRMax = aZmax-aZmin; + // ** Creation of sphere + aShape/*TopoDS_Shape aSphere*/ = BRepPrimAPI_MakeSphere(aCenterMass, aRMax).Face(); + // ** Extraction of surface + // ** Initialization of surface + /*Handle(BRepAdaptor_HSurface) HSI = new BRepAdaptor_HSurface(); + HSI->ChangeSurface().Initialize(aSphere); + aBuilder.LoadInitSurface( BRep_Tool::Surface(HSI->ChangeSurface().Face()));*/ } - else - { - // Surface initiale : Plane - - }*/ - + /*for (int i=1; i<=nbPoints ; i++) + { + Handle(GEOM_Function) aPoint = aData.GetPoint(i); + TopoDS_Shape aShapePnt = aPoint->GetValue(); + Handle(GeomPlate_PointConstraint) PCont= new GeomPlate_PointConstraint(aShapePnt,0); + aBuilder.Add(PCont); + } + aBuilder.Perform(); + Handle(GeomPlate_Surface) gpPlate = aBuilder.Surface();*/ if (aShape.IsNull()) return 0; aFunction->SetValue(aShape);