+
+GeomShapePtr GeomAPI_Shape::intersect(const GeomShapePtr theShape) const
+{
+ const TopoDS_Shape& aShape1 = const_cast<GeomAPI_Shape*>(this)->impl<TopoDS_Shape>();
+ const TopoDS_Shape& aShape2 = theShape->impl<TopoDS_Shape>();
+
+ BRepAlgoAPI_Section aCommon(aShape1, aShape2);
+ if (!aCommon.IsDone())
+ return GeomShapePtr();
+
+ TopoDS_Shape aResult = aCommon.Shape();
+ if (aResult.ShapeType() == TopAbs_COMPOUND) {
+ NCollection_List<TopoDS_Shape> aSubs;
+ addSimpleToList(aResult, aSubs);
+ if(aSubs.Size() == 1) {
+ aResult = aSubs.First();
+ } else if(aSubs.Size() == 0) {
+ return GeomShapePtr();
+ }
+ }
+
+ GeomShapePtr aResShape(new GeomAPI_Shape);
+ 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<GeomAPI_Shape*>(this)->impl<TopoDS_Shape>();
+ const TopoDS_Shape& aShape2 = theShape->impl<TopoDS_Shape>();
+
+ 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<GeomAPI_Dir> theDir, const double theOffset)
+{
+ gp_Dir aDir = theDir->impl<gp_Dir>();
+ gp_Vec aTrsfVec(aDir.XYZ() * theOffset);
+ gp_Trsf aTranslation;
+ aTranslation.SetTranslation(aTrsfVec);
+ TopoDS_Shape aResult = MY_SHAPE->Moved(aTranslation);
+ setImpl(new TopoDS_Shape(aResult));
+}
+
+bool GeomAPI_Shape::isSelfIntersected(const int theLevelOfCheck) const
+{
+ BOPAlgo_CheckerSI aCSI; // checker of self-interferences
+ aCSI.SetLevelOfCheck(theLevelOfCheck);
+ TopTools_ListOfShape aList;
+ const TopoDS_Shape& aThisShape = const_cast<GeomAPI_Shape*>(this)->impl<TopoDS_Shape>();
+ aList.Append(aThisShape);
+ aCSI.SetArguments(aList);
+ aCSI.Perform();
+ if (aCSI.HasErrors() || aCSI.DS().Interferences().Extent() > 0) {
+ return true;
+ }
+
+ return false;
+}