Salome HOME
Copyright update 2020
[modules/shaper.git] / src / GeomAlgoAPI / GeomAlgoAPI_PointBuilder.cpp
index ce7be932c4557724520697e7176ff191817a03d1..856e430efd47b21db05dd35707a47935228370de 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2017  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2020  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 //
 // You should have received a copy of the GNU Lesser General Public
 // License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
 #include "GeomAlgoAPI_PointBuilder.h"
@@ -148,14 +147,11 @@ std::shared_ptr<GeomAPI_Vertex> GeomAlgoAPI_PointBuilder::vertexByProjection(
 
   GeomAPI_ProjectPointOnCurve aProjection(aPnt, aCurve);
 
-  if (aProjection.NbPoints() == 0) {
-    return aVertex;
+  if (aProjection.NbPoints() != 0) {
+    gp_Pnt aNearestPoint = aProjection.NearestPoint();
+    aVertex.reset(new GeomAPI_Vertex(aNearestPoint.X(), aNearestPoint.Y(), aNearestPoint.Z()));
   }
 
-  gp_Pnt aNearestPoint = aProjection.NearestPoint();
-
-  aVertex.reset(new GeomAPI_Vertex(aNearestPoint.X(), aNearestPoint.Y(), aNearestPoint.Z()));
-
   return aVertex;
 }
 
@@ -166,21 +162,16 @@ std::shared_ptr<GeomAPI_Vertex> GeomAlgoAPI_PointBuilder::vertexByProjection(
 {
   std::shared_ptr<GeomAPI_Vertex> aVertex;
 
-  if(!theVertex.get() || !theFace.get() || !theFace->isPlanar()) {
-    return aVertex;
-  }
-
-  std::shared_ptr<GeomAPI_Pnt> aProjPnt = theVertex->point();
-  std::shared_ptr<GeomAPI_Pln> aProjPln = theFace->getPlane();
+  if (theVertex.get() && theFace.get() && theFace->isPlanar()) {
+    std::shared_ptr<GeomAPI_Pnt> aProjPnt = theVertex->point();
+    std::shared_ptr<GeomAPI_Pln> aProjPln = theFace->getPlane();
 
-  std::shared_ptr<GeomAPI_Pnt> aPnt = aProjPln->project(aProjPnt);
+    std::shared_ptr<GeomAPI_Pnt> aPnt = aProjPln->project(aProjPnt);
 
-  if(!aPnt.get()) {
-    return aVertex;
+    if (aPnt.get())
+      aVertex.reset(new GeomAPI_Vertex(aPnt->x(), aPnt->y(), aPnt->z()));
   }
 
-  aVertex.reset(new GeomAPI_Vertex(aPnt->x(), aPnt->y(), aPnt->z()));
-
   return aVertex;
 }
 
@@ -191,45 +182,15 @@ std::shared_ptr<GeomAPI_Vertex> GeomAlgoAPI_PointBuilder::vertexByIntersection(
 {
   std::shared_ptr<GeomAPI_Vertex> aVertex;
 
-  if(!theEdge1.get() || !theEdge2.get() || !theEdge1->isLine() || !theEdge2->isLine()) {
-    return aVertex;
-  }
-
-  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;
-  }
-
-  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();
+  if (theEdge1.get() && theEdge2.get() && theEdge1->isLine() && theEdge2->isLine()) {
+    std::shared_ptr<GeomAPI_Lin> aLin1 = theEdge1->line();
+    std::shared_ptr<GeomAPI_Lin> aLin2 = theEdge2->line();
 
-  std::shared_ptr<GeomAPI_Pnt> aPnt = aPln->intersect(aLin);
+    std::shared_ptr<GeomAPI_Pnt> aPnt = aLin1->intersect(aLin2);
 
-  if(!aPnt.get()) {
-    return aVertex;
+    if (aPnt.get())
+      aVertex.reset(new GeomAPI_Vertex(aPnt->x(), aPnt->y(), aPnt->z()));
   }
 
-  aVertex.reset(new GeomAPI_Vertex(aPnt->x(), aPnt->y(), aPnt->z()));
-
   return aVertex;
 }