Problem with faces.... ?

Hi !

I try to get all the faces from a shape I created with BRepPrimAPI_MakeBox( 1, 1, 1);, but I get incorrect result. First of all, the bounds returned for the faces are weird min=-2.0e+100 and max=2.0e+100, is this correct, it looks a bit odd to me ?

And when I use Geom_Surface::D0( umin, vmin, pt), pt.X and pt.Y is correct, but pt.Z is a large negative value, am I doing anything wrong with this, the code looks like this:

 void renderShape( TopoDS_Shape& shape) {

TopExp_Explorer ex;

TopTools_MapOfShape map;

for( ex.Init( shape, TopAbs_FACE); ex.More(); ex.Next()) // Iterate over all faces

{

const TopoDS_Shape& shp = ex.Current();

TopLoc_Location loc;

FXASSERT( shp.ShapeType() == TopAbs_FACE);

TopoDS_Face face = TopoDS::Face( shp);

gp_Trsf xform = loc;

if( map.Add( face))

{

BRepAdaptor_Surface sa( face);

const Handle(Geom_Surface)& surf = Handle(Geom_Surface)::DownCast(sa.Surface().Surface());

double u1, u2, v1, v2;

surf->Bounds( u1, u2, v1, v2); surf->D0( u1, v2, pt); return odd Z values here...

}

} } 
Jean Michel Boulcourt's picture

Hello Mikael,

You should instead use BRepTools:UVBounds that will return you the bounds corresponding to the limit of the Face and not to the Surface which in your case is infinite (2.e+100).

m-aronsson's picture

Thanks, that helped a lot, just one question, the help text for Bounds() says that it returns Standard_Real::FirstReal() and LastReal() for infinite surfaces, but FirstReal() and LastReal() returns, I think it was 1.0e+308 or something like that, but the bounds was +/-2.0e+100.

Is this a bug or a typo in the documentation ?

Mikael

Jean Michel Boulcourt's picture

In case of infinite surfaces Bounds() method returns Precision::Infinite() which is a value equals to 2.0e+100. So it looks like a typo in the documentation.