#include <GeomAPI_Edge.h>
#include <GeomAPI_Face.h>
+#include <GeomAPI_Lin.h>
#include <GeomAPI_Pln.h>
#include <GeomAPI_Pnt.h>
#include <GeomAPI_Shape.h>
#include <BRep_Tool.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>
#include <GCPnts_AbscissaPoint.hxx>
+#include <Geom_Line.hxx>
#include <GeomAdaptor_Curve.hxx>
+#include <GeomAPI_ExtremaCurveCurve.hxx>
#include <gp_Pln.hxx>
#include <gp_Pnt.hxx>
#include <TopoDS.hxx>
const bool theIsPercent,
const bool theIsReverse)
{
+ std::shared_ptr<GeomAPI_Vertex> aVertex;
+
if(!theEdge.get()) {
- return NULL;
+ return aVertex;
}
double aValue = theValue;
Standard_Real aUFirst, aULast;
Handle(Geom_Curve) anEdgeCurve = BRep_Tool::Curve(anEdge, aUFirst, aULast);
- std::shared_ptr<GeomAPI_Vertex> aVertex;
if(!anEdgeCurve.IsNull() ) {
Handle(Geom_Curve) aReOrientedCurve = anEdgeCurve;
const std::shared_ptr<GeomAPI_Vertex> theVertex,
const std::shared_ptr<GeomAPI_Face> thePlane)
{
+ std::shared_ptr<GeomAPI_Vertex> aVertex;
+
if(!theVertex.get() || !thePlane.get() || !thePlane->isPlanar()) {
- return NULL;
+ return aVertex;
}
- std::shared_ptr<GeomAPI_Pnt> aGeomPnt = theVertex->point();
- gp_Pnt aPnt = aGeomPnt->impl<gp_Pnt>();
+ std::shared_ptr<GeomAPI_Pnt> aProjPnt = theVertex->point();
+ std::shared_ptr<GeomAPI_Pln> aProjPln = thePlane->getPlane();
- std::shared_ptr<GeomAPI_Pln> aGeomPln = thePlane->getPlane();
- gp_Pln aPln = aGeomPln->impl<gp_Pln>();
+ std::shared_ptr<GeomAPI_Pnt> aPnt = aProjPln->project(aProjPnt);
- gp_Dir aPntAxis = aPnt.XYZ() - aPln.Location().XYZ();
- gp_Dir aPlnNorm = aPln.Axis().Direction();
+ if(!aPnt.get()) {
+ return aVertex;
+ }
+
+ aVertex.reset(new GeomAPI_Vertex(aPnt->x(), aPnt->y(), aPnt->z()));
- if(aPntAxis * aPlnNorm > 0) {
- aPlnNorm.Reverse();
+ return aVertex;
+}
+
+//==================================================================================================
+std::shared_ptr<GeomAPI_Vertex> GeomAlgoAPI_PointBuilder::vertexByIntersection(
+ const std::shared_ptr<GeomAPI_Edge> theEdge1,
+ const std::shared_ptr<GeomAPI_Edge> theEdge2)
+{
+ std::shared_ptr<GeomAPI_Vertex> aVertex;
+
+ if(!theEdge1.get() || !theEdge2.get() || !theEdge1->isLine() || !theEdge2->isLine()) {
+ return aVertex;
}
- double aDistance = aPln.Distance(aPnt);
- aPnt.Translate(gp_Vec(aPlnNorm) * aDistance);
+ std::shared_ptr<GeomAPI_Lin> aLin1 = theEdge1->line();
+ std::shared_ptr<GeomAPI_Lin> aLin2 = theEdge2->line();
+
+ std::shared_ptr<GeomAPI_Pnt> aPnt = aLin1->intersect(aLin2);
+
+ if(!aPnt.get()) {
+ return aVertex;
+ }
- return std::shared_ptr<GeomAPI_Vertex>(new GeomAPI_Vertex(aPnt.X(), aPnt.Y(), aPnt.Z()));
+ aVertex.reset(new GeomAPI_Vertex(aPnt->x(), aPnt->y(), aPnt->z()));
+
+ return aVertex;
+}
+
+//==================================================================================================
+std::shared_ptr<GeomAPI_Vertex> GeomAlgoAPI_PointBuilder::vertexByIntersection(
+ const std::shared_ptr<GeomAPI_Edge> theEdge,
+ const std::shared_ptr<GeomAPI_Face> theFace)
+{
+ std::shared_ptr<GeomAPI_Vertex> aVertex;
+
+ if(!theEdge.get() || !theFace.get() || !theEdge->isLine() || !theFace->isPlanar()) {
+ return aVertex;
+ }
+
+ std::shared_ptr<GeomAPI_Lin> aLin = theEdge->line();
+ std::shared_ptr<GeomAPI_Pln> aPln = theFace->getPlane();
+
+ std::shared_ptr<GeomAPI_Pnt> aPnt = aPln->intersect(aLin);
+
+ if(!aPnt.get()) {
+ return aVertex;
+ }
+
+ aVertex.reset(new GeomAPI_Vertex(aPnt->x(), aPnt->y(), aPnt->z()));
+
+ return aVertex;
}