Geom_Surface and BRepTools::UVBounds diferent results

Hi, I want to discretize a surface using UV coordinates but I get different bounding, depending on if i use Geom_Surface::Bounds or BRepTools::UVBounds: This is my code:

void DiscretizeFaceUV(const TopoDS_Face &face_) {
  double uMin, uMax, vMin, vMax;
  const Handle(Geom_Surface) &surface = BRep_Tool::Surface(face_);
  ShapeAnalysis_Surface sas(surface);
  surface->Bounds(uMin, uMax, vMin, vMax);
  gp_XYZ p1 = sas.Value(uMin, vMin).XYZ();
  std::cout << "point1:" << p1.X() << " " << p1.Y() << " " << p1.Z()
            << std::endl;
  std::cout << uMin << " " << uMax << " " << vMin << " " << vMax << std::endl;

  BRepTools::UVBounds(face_, uMin, uMax, vMin, vMax);
  gp_XYZ p2 = sas.Value(uMin, vMin).XYZ();
  std::cout << "point2:" << p2.X() << " " << p2.Y() << " " << p2.Z()
            << std::endl;
  std::cout << uMin << " " << uMax << " " << vMin << " " << vMax << std::endl
            << std::endl;
}

which one should I use?

Kirill Gavrilov's picture

Geom_Surface::Bounds() gives you natural bounds of a given Surface (regardless of topological boundaries).
BRepTools::UVBounds() gives you bounds of a given Face based on topological boundaries (bounding curves).

What you actually need depends on what you are looking for in a particular case. Note that checking the UV range via BRepTools::UVBounds() of a Face is not enough to pick a point inside that Face - you'll need to use also a classifier to check that point lies on the Face and not outside (in a whole / behind boundaries).