GeomConvert_ApproxSurface sample code

Hi there are any GeomConvert_ApproxSurface sample code aviable?
thank you for the help!

Davide Canalia's picture

I have found a solution so i think it is good to post here a bit of code:
Handle_Geom_Surface surf=BRep_Tool::Surface(face);//Face is a TopoDS_Face

GeomAbs_Shape contU=GeomAbs_Shape::GeomAbs_C1;
GeomAbs_Shape contV=GeomAbs_Shape::GeomAbs_C1;
int precisCode=0;
int maxSegment=200;
double tollerance=0.1;

GeomConvert_ApproxSurface gcAS(surf,tollerance,contU,contV,degreeU,degreeV,maxSegment, precisCode);

if(gcAS.IsDone())
{
if(gcAS.HasResult())
{
Handle(Geom_Surface) rSurf=gcAS.Surface();
}
}

Stephane Routelous's picture

you have to use :
TopLoc_Location loc;
Handle_Geom_Surface surf=BRep_Tool::Surface(face,loc);

rSurf->Transform(loc.Transformation());

because the surface you get is not transformed by the location of the shape.

Stephane

Davide Canalia's picture

Thank you for your help :)

I have an other little problem, regarding trimming surface.

If i approximate a trimmed bspline (for example a cylindrical surface trimmed with a 6 edged polycon) the resulting surface is not trimmed.

I think i need to save the original curve (extracted from face outer wire) than project them on the new surface and create a new face with the projected wire and the approx surface.

Is it correct? or i'm missing something?