std::shared_ptr<GeomAPI_Face> aFace(new GeomAPI_Face(aShape));
- std::shared_ptr<GeomAPI_Pln> aPln = GeomAlgoAPI_FaceBuilder::plane(aFace);
+ std::shared_ptr<GeomAPI_Pln> aPln = aFace->getPlane();
std::shared_ptr<GeomAPI_Pnt> aOrig = aPln->location();
std::shared_ptr<GeomAPI_Dir> aDir = aPln->direction();
#include <Geom_Surface.hxx>
#include <Geom_CylindricalSurface.hxx>
#include <Geom_RectangularTrimmedSurface.hxx>
+#include <GeomLib_IsPlanarSurface.hxx>
#include <IntTools_Context.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Face.hxx>
std::shared_ptr<GeomAPI_Pln> GeomAPI_Face::getPlane() const
{
- const TopoDS_Shape& aShape = const_cast<GeomAPI_Face*>(this)->impl<TopoDS_Shape>();
- BRepAdaptor_Surface aSurfAdapt(TopoDS::Face(aShape));
-
- if (aSurfAdapt.GetType() != GeomAbs_Plane)
- return std::shared_ptr<GeomAPI_Pln>();
-
- // Obtain central point
- double aUMin, aUMax, aVMin, aVMax;
- aUMin = aSurfAdapt.FirstUParameter();
- aUMax = aSurfAdapt.LastUParameter();
- aVMin = aSurfAdapt.FirstVParameter();
- aVMax = aSurfAdapt.LastVParameter();
- gp_Pnt aCentralPnt;
- gp_Vec aDU, aDV;
- aSurfAdapt.D1((aUMin+aUMax)*0.5, (aVMin+aVMax)*0.5, aCentralPnt, aDU, aDV);
- std::shared_ptr<GeomAPI_Pnt> aCenter(
- new GeomAPI_Pnt(aCentralPnt.X(), aCentralPnt.Y(), aCentralPnt.Z()));
-
- // Obtain plane direction
- gp_XYZ aNormalVec = aDU.XYZ().Crossed(aDV.XYZ());
- if (aNormalVec.SquareModulus() < Precision::Confusion() * Precision::Confusion())
- return std::shared_ptr<GeomAPI_Pln>();
- std::shared_ptr<GeomAPI_Dir> aNormal(
- new GeomAPI_Dir(aNormalVec.X(), aNormalVec.Y(), aNormalVec.Z()));
-
- std::shared_ptr<GeomAPI_Pln> aResult(new GeomAPI_Pln(aCenter, aNormal));
+ std::shared_ptr<GeomAPI_Pln> aResult;
+ TopoDS_Shape aShape = this->impl<TopoDS_Shape>();
+ if (aShape.IsNull())
+ return aResult; // null shape
+ if (aShape.ShapeType() != TopAbs_FACE)
+ return aResult; // not face
+ TopoDS_Face aFace = TopoDS::Face(aShape);
+ if (aFace.IsNull())
+ return aResult; // not face
+ Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace);
+ if (aSurf.IsNull())
+ return aResult; // no surface
+ GeomLib_IsPlanarSurface isPlanar(aSurf);
+ if(!isPlanar.IsPlanar()) {
+ return aResult;
+ }
+ gp_Pln aPln = isPlanar.Plan();
+ double aA, aB, aC, aD;
+ aPln.Coefficients(aA, aB, aC, aD);
+ if (aFace.Orientation() == TopAbs_REVERSED) {
+ aA = -aA;
+ aB = -aB;
+ aC = -aC;
+ aD = -aD;
+ }
+ aResult = std::shared_ptr<GeomAPI_Pln>(new GeomAPI_Pln(aA, aB, aC, aD));
return aResult;
}
#include <BRepBuilderAPI_MakeFace.hxx>
#include <GC_MakePlane.hxx>
#include <Geom_Plane.hxx>
-#include <GeomLib_IsPlanarSurface.hxx>
#include <gp_Pln.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Face.hxx>
aFace->setImpl(new TopoDS_Face(aMakeFace.Face()));
return aFace;
}
-
-//==================================================================================================
-std::shared_ptr<GeomAPI_Pln> GeomAlgoAPI_FaceBuilder::plane(const std::shared_ptr<GeomAPI_Face> theFace)
-{
- std::shared_ptr<GeomAPI_Pln> aResult;
- if (!theFace)
- return aResult; // bad shape
- TopoDS_Shape aShape = theFace->impl<TopoDS_Shape>();
- if (aShape.IsNull())
- return aResult; // null shape
- if (aShape.ShapeType() != TopAbs_FACE)
- return aResult; // not face
- TopoDS_Face aFace = TopoDS::Face(aShape);
- if (aFace.IsNull())
- return aResult; // not face
- Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace);
- if (aSurf.IsNull())
- return aResult; // no surface
- GeomLib_IsPlanarSurface isPlanar(aSurf);
- if(!isPlanar.IsPlanar()) {
- return aResult;
- }
- gp_Pln aPln = isPlanar.Plan();
- double aA, aB, aC, aD;
- aPln.Coefficients(aA, aB, aC, aD);
- if (aFace.Orientation() == TopAbs_REVERSED) {
- aA = -aA;
- aB = -aB;
- aC = -aC;
- aD = -aD;
- }
- aResult = std::shared_ptr<GeomAPI_Pln>(new GeomAPI_Pln(aA, aB, aC, aD));
- return aResult;
-}
\ No newline at end of file
/// Creates a planar face parallel to theFace and passing through theVertex.
static std::shared_ptr<GeomAPI_Face> planarFaceByFaceAndVertex(const std::shared_ptr<GeomAPI_Face> theFace,
const std::shared_ptr<GeomAPI_Vertex> theVertex);
-
- /// Returns the plane of the planar face. If it is not planar, returns empty ptr.
- static std::shared_ptr<GeomAPI_Pln> plane(const std::shared_ptr<GeomAPI_Face> theFace);
};
#endif
#include "GeomAlgoAPI_Revolution.h"
#include <GeomAPI_Face.h>
+#include <GeomAPI_Pln.h>
#include <GeomAPI_ShapeExplorer.h>
#include <GeomAlgoAPI_DFLoader.h>
#include <GeomAlgoAPI_FaceBuilder.h>
if(!isFromPlanar.IsPlanar() || !isToPlanar.IsPlanar()) {// non-planar shapes is not supported for revolution bounding
return;
}
- gp_Pln aFromPln = isFromPlanar.Plan();
- gp_Pln aToPln = isToPlanar.Plan();
+
+ std::shared_ptr<GeomAPI_Face> aGeomFromFace(new GeomAPI_Face(theFromShape));
+ std::shared_ptr<GeomAPI_Face> aGeomToFace(new GeomAPI_Face(theToShape));
+
+ gp_Pln aFromPln = aGeomFromFace->getPlane()->impl<gp_Pln>();
+ gp_Pln aToPln = aGeomToFace->getPlane()->impl<gp_Pln>();
// Orienting bounding planes properly so that the center of mass of the base face stays
// on the result shape after cut.
aResult = aRevolBuilder->Shape();
// Getting bounding face.
- TopoDS_Face aBoundingFace;
bool isFromFaceSet = false;
+ std::shared_ptr<GeomAPI_Face> aGeomBoundingFace;
if(theFromShape) {
- aBoundingFace = TopoDS::Face(theFromShape->impl<TopoDS_Shape>());
+ aGeomBoundingFace.reset(new GeomAPI_Face(theFromShape));
isFromFaceSet = true;
} else if(theToShape) {
- aBoundingFace = TopoDS::Face(theToShape->impl<TopoDS_Shape>());
+ aGeomBoundingFace.reset(new GeomAPI_Face(theToShape));
}
+ TopoDS_Face aBoundingFace = TopoDS::Face(aGeomBoundingFace->impl<TopoDS_Shape>());
// Getting plane from bounding face.
GeomLib_IsPlanarSurface isBoundingPlanar(BRep_Tool::Surface(aBoundingFace));
if(!isBoundingPlanar.IsPlanar()) { // non-planar shapes is not supported for revolution bounding
return;
}
- gp_Pln aBoundingPln = isBoundingPlanar.Plan();
+
+ gp_Pln aBoundingPln = aGeomBoundingFace->getPlane()->impl<gp_Pln>();
// Orienting bounding plane properly so that the center of mass of the base face stays
// on the result shape after cut.
if (aGShape.get() != NULL) {
// get plane parameters
std::shared_ptr<GeomAPI_Face> aFace(new GeomAPI_Face(aGShape));
- std::shared_ptr<GeomAPI_Pln> aPlane = GeomAlgoAPI_FaceBuilder::plane(aFace);
+ std::shared_ptr<GeomAPI_Pln> aPlane = aFace->getPlane();
std::shared_ptr<GeomAPI_Dir> aDir = aPlane->direction();
gp_XYZ aXYZ = aDir->impl<gp_Dir>().XYZ();
double aTwist = 0.0;
// get plane parameters
std::shared_ptr<GeomAPI_Face> aFace(new GeomAPI_Face(aGShape));
- std::shared_ptr<GeomAPI_Pln> aPlane = GeomAlgoAPI_FaceBuilder::plane(aFace);
+ std::shared_ptr<GeomAPI_Pln> aPlane = aFace->getPlane();
if (!aPlane.get())
return std::shared_ptr<GeomAPI_Dir>();
if (aSelection) { // update arguments due to the selection value
// update the sketch plane
std::shared_ptr<GeomAPI_Face> aFace(new GeomAPI_Face(aSelection));
- std::shared_ptr<GeomAPI_Pln> aPlane = GeomAlgoAPI_FaceBuilder::plane(aFace);
+ std::shared_ptr<GeomAPI_Pln> aPlane = aFace->getPlane();
if (aPlane) {
double anA, aB, aC, aD;
aPlane->coefficients(anA, aB, aC, aD);