#include <BOPTools_AlgoTools.hxx>
#include <BRep_Tool.hxx>
#include <BRepAdaptor_Surface.hxx>
+#include <BRepGProp_Face.hxx>
#include <BRepTools.hxx>
#include <Geom_Surface.hxx>
#include <Geom_SphericalSurface.hxx>
Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace);
if (aSurf->IsKind(STANDARD_TYPE(Geom_ConicalSurface))) {
gp_Cone aCon = Handle(Geom_ConicalSurface)::DownCast(aSurf)->Cone();
- const gp_Pnt& aLoc = aCon.Location();
- const gp_Dir& aDir = aCon.Position().Direction();
- double aRadius1 = aCon.RefRadius();
+ gp_Pnt aLoc = aCon.Location();
+ gp_Dir aDir = aCon.Position().Direction();
double aUMin, aUMax, aVMin, aVMax;
BRepTools::UVBounds(aFace, aUMin, aUMax, aVMin, aVMax);
double aSemiAngle = Abs(aCon.SemiAngle());
- double aRadius2 = aRadius1 - (aVMax - aVMin) * Sin(aSemiAngle);
+ double aRadius1 = aCon.RefRadius() + aVMin * Sin(aCon.SemiAngle());
+ double aRadius2 = aCon.RefRadius() + aVMax * Sin(aCon.SemiAngle());
+
+ aLoc.ChangeCoord() += aDir.XYZ() * aVMin * Cos(aCon.SemiAngle());
GeomPointPtr aLocation(new GeomAPI_Pnt(aLoc.X(), aLoc.Y(), aLoc.Z()));
GeomDirPtr aDirection(new GeomAPI_Dir(aDir.X(), aDir.Y(), aDir.Z()));
}
return aTorus;
}
+
+GeomPointPtr GeomAPI_Face::middlePoint() const
+{
+ GeomPointPtr anInnerPoint;
+
+ const TopoDS_Face& aFace = impl<TopoDS_Face>();
+ if (aFace.IsNull())
+ return anInnerPoint;
+
+ BRepGProp_Face aProp(aFace);
+ double aUMin, aUMax, aVMin, aVMax;
+ aProp.Bounds(aUMin, aUMax, aVMin, aVMax);
+
+ Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace);
+ if (aSurf.IsNull())
+ return anInnerPoint;
+
+ gp_Pnt aPnt = aSurf->Value((aUMin + aUMax) * 0.5, (aVMin + aVMax) * 0.5);
+ anInnerPoint = GeomPointPtr(new GeomAPI_Pnt(aPnt.X(), aPnt.Y(), aPnt.Z()));
+ return anInnerPoint;
+}