From 9499645862c5f92b7bf5b74617b9be17ad099c33 Mon Sep 17 00:00:00 2001 From: dbv Date: Thu, 15 Sep 2016 17:16:28 +0300 Subject: [PATCH] Fixed creation of plane by two parallel planes when the distance between them is very small. --- .../ConstructionPlugin_Plane.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/ConstructionPlugin/ConstructionPlugin_Plane.cpp b/src/ConstructionPlugin/ConstructionPlugin_Plane.cpp index 06653561f..7eced565d 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Plane.cpp +++ b/src/ConstructionPlugin/ConstructionPlugin_Plane.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -358,19 +359,13 @@ std::shared_ptr ConstructionPlugin_Plane::createByTwoParallelPlan std::shared_ptr aFace2(new GeomAPI_Face(aFaceShape2)); std::shared_ptr aPln2 = aFace2->getPlane(); - double aDist = aPln1->distance(aPln2) / 2.0; + std::shared_ptr anOrig1 = aPln1->location(); + std::shared_ptr aPntOnPln2 = aPln2->project(anOrig1); - std::shared_ptr aOrig1 = aPln1->location(); - std::shared_ptr aDir1 = aPln1->direction(); + std::shared_ptr aNewOrig(new GeomAPI_Pnt(anOrig1->xyz()->added( + aPntOnPln2->xyz())->multiplied(0.5))); - aOrig1->translate(aDir1, aDist); - std::shared_ptr aNewPln(new GeomAPI_Pln(aOrig1, aDir1)); - - if((aNewPln->distance(aPln2) - aDist) > 1.e-7) { - aDir1->reverse(); - aOrig1->translate(aDir1, 2.0 * aDist); - aNewPln.reset(new GeomAPI_Pln(aOrig1, aDir1)); - } + std::shared_ptr aNewPln(new GeomAPI_Pln(aNewOrig, aPln1->direction())); std::shared_ptr aRes = makeRectangularFace(aFace1, aNewPln); -- 2.39.2