X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FGeomAPI%2FGeomAPI_Shape.cpp;h=c1df335558bd9f4f7680e158f68a43984bd27619;hb=4df4bd61da1ea5d357671c819a8ced6ec9ba77ac;hp=c811116dff5529eb7b96243b3eecbd07d05bdf2d;hpb=3fec0e5ea40ca705c686197789a815d4a3364b20;p=modules%2Fshaper.git diff --git a/src/GeomAPI/GeomAPI_Shape.cpp b/src/GeomAPI/GeomAPI_Shape.cpp index c811116df..c1df33555 100644 --- a/src/GeomAPI/GeomAPI_Shape.cpp +++ b/src/GeomAPI/GeomAPI_Shape.cpp @@ -1,8 +1,22 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: GeomAPI_Shape.cpp -// Created: 23 Apr 2014 -// Author: Mikhail PONIKAROV +// Copyright (C) 2014-2017 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 +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// 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 +// +// See http://www.salome-platform.org/ or +// email : webmaster.salome@opencascade.com +// #include "GeomAPI_Shape.h" @@ -10,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -31,6 +46,8 @@ #include #include // for std::transform +#include + #define MY_SHAPE implPtr() GeomAPI_Shape::GeomAPI_Shape() @@ -455,3 +472,31 @@ GeomShapePtr GeomAPI_Shape::intersect(const GeomShapePtr theShape) const aResShape->setImpl(new TopoDS_Shape(aResult)); return aResShape; } + +bool GeomAPI_Shape::isIntersect(const GeomShapePtr theShape) const +{ + if(!theShape.get()) { + return false; + } + + const TopoDS_Shape& aShape1 = const_cast(this)->impl(); + const TopoDS_Shape& aShape2 = theShape->impl(); + + BRepExtrema_DistShapeShape aDist(aShape1, aShape2); + aDist.Perform(); + if(aDist.IsDone() && aDist.Value() < Precision::Confusion()) { + return true; + } + + return false; +} + +void GeomAPI_Shape::translate(const std::shared_ptr theDir, const double theOffset) +{ + gp_Dir aDir = theDir->impl(); + gp_Vec aTrsfVec(aDir.XYZ() * theOffset); + gp_Trsf aTranslation; + aTranslation.SetTranslation(aTrsfVec); + TopoDS_Shape aResult = MY_SHAPE->Moved(aTranslation); + setImpl(new TopoDS_Shape(aResult)); +}