]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/GeomAPI/GeomAPI_Pln.cpp
Salome HOME
Issue #1650: Added option to create axis by two planes.
[modules/shaper.git] / src / GeomAPI / GeomAPI_Pln.cpp
index b162e51f8253139ce455121ae8f006b1aa93f6ea..b562a0c41a181b6525ef28ba5583f31c966d9396 100644 (file)
@@ -13,6 +13,8 @@
 
 #include <gp_Pln.hxx>
 
+#include <IntAna_QuadQuadGeo.hxx>
+
 using namespace std;
 
 GeomAPI_Pln::GeomAPI_Pln(const std::shared_ptr<GeomAPI_Ax3>& theAxis)
@@ -112,3 +114,44 @@ double GeomAPI_Pln::distance(const std::shared_ptr<GeomAPI_Pln> thePlane) const
 
   return aMyPln.Distance(anOtherPln);
 }
+
+void GeomAPI_Pln::translate(const std::shared_ptr<GeomAPI_Dir> theDir, double theDist)
+{
+  gp_Vec aVec(theDir->impl<gp_Dir>());
+  aVec.Normalize();
+  aVec.Multiply(theDist);
+  implPtr<gp_Pln>()->Translate(aVec);
+}
+
+std::shared_ptr<GeomAPI_Lin> GeomAPI_Pln::intersect(const std::shared_ptr<GeomAPI_Pln> thePlane) const
+{
+  std::shared_ptr<GeomAPI_Lin> aRes;
+
+  if(!thePlane.get()) {
+    return aRes;
+  }
+
+  const gp_Pln& aMyPln = impl<gp_Pln>();
+  const gp_Pln& anOtherPln = thePlane->impl<gp_Pln>();
+
+  IntAna_QuadQuadGeo aQuad(aMyPln, anOtherPln, Precision::Confusion(), Precision::Confusion());
+
+  if(aQuad.IsDone() != Standard_True) {
+    return aRes;
+  }
+
+  if(aQuad.NbSolutions() != 1) {
+    return aRes;
+  }
+
+  gp_Lin aLin = aQuad.Line(1);
+  gp_Pnt aLoc = aLin.Location();
+  gp_Dir aDir = aLin.Direction();
+
+  std::shared_ptr<GeomAPI_Pnt> aGeomLoc(new GeomAPI_Pnt(aLoc.X(), aLoc.Y(), aLoc.Z()));
+  std::shared_ptr<GeomAPI_Dir> aGeomDir(new GeomAPI_Dir(aDir.X(), aDir.Y(), aDir.Z()));
+
+  aRes.reset(new GeomAPI_Lin(aGeomLoc, aGeomDir));
+
+  return aRes;
+}