From be567df6eb28d423b6f17b371b0a2d6df4984c09 Mon Sep 17 00:00:00 2001 From: azv Date: Fri, 23 Aug 2019 16:26:34 +0300 Subject: [PATCH] Complete fixing the Prism algorithm to use solids instead of semi-spaces to bound an extrusion (issue #17261) --- src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp | 31 ++++++++++----------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp index faec83081..cc1ff67b2 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp @@ -313,12 +313,10 @@ void GeomAlgoAPI_Prism::buildByPlanes(const GeomShapePtr theBaseShap std::shared_ptr aFromPnt( new GeomAPI_Pnt(aFromLoc->xyz()->added(anExtDir->multiplied( aSign ? theFromSize : -theFromSize)))); - GeomShapePtr aBoundingFromShape = GeomAlgoAPI_FaceBuilder::planarFace(aFromPnt, aFromDir); std::shared_ptr aToPnt( new GeomAPI_Pnt(aToLoc->xyz()->added(anExtDir->multiplied( aSign ? -theToSize : theToSize)))); - GeomShapePtr aBoundingToShape = GeomAlgoAPI_FaceBuilder::planarFace(aToPnt, aToDir); // Getting bounding box for base shape. Bnd_Box aBndBox; @@ -393,35 +391,28 @@ void GeomAlgoAPI_Prism::buildByPlanes(const GeomShapePtr theBaseShap IntAna_IntConicQuad aFromIntAna(aLine, aBndFromQuadric); Standard_Real aToParameter = aToIntAna.ParamOnConic(1); Standard_Real aFromParameter = aFromIntAna.ParamOnConic(1); - static const double THE_FACE_SIZE_COEFF = 10.0; if(aToParameter > aFromParameter) { gp_Vec aVec = aToDir->impl(); - if((aVec * anExtVec) > 0) { + if((aVec * anExtVec) > 0) aToDir->setImpl(new gp_Dir(aVec.Reversed())); - aBoundingToShape = - GeomAlgoAPI_FaceBuilder::squareFace(aToPnt, aToDir, THE_FACE_SIZE_COEFF * aBndBoxSize); - } aVec = aFromDir->impl(); - if((aVec * anExtVec) < 0) { + if((aVec * anExtVec) < 0) aFromDir->setImpl(new gp_Dir(aVec.Reversed())); - aBoundingFromShape = - GeomAlgoAPI_FaceBuilder::squareFace(aFromPnt, aFromDir, THE_FACE_SIZE_COEFF * aBndBoxSize); - } } else { gp_Vec aVec = aToDir->impl(); - if((aVec * anExtVec) < 0) { + if((aVec * anExtVec) < 0) aToDir->setImpl(new gp_Dir(aVec.Reversed())); - aBoundingToShape = - GeomAlgoAPI_FaceBuilder::squareFace(aToPnt, aToDir, THE_FACE_SIZE_COEFF * aBndBoxSize); - } aVec = aFromDir->impl(); - if((aVec * anExtVec) > 0) { + if((aVec * anExtVec) > 0) aFromDir->setImpl(new gp_Dir(aVec.Reversed())); - aBoundingFromShape = - GeomAlgoAPI_FaceBuilder::squareFace(aFromPnt, aFromDir, THE_FACE_SIZE_COEFF * aBndBoxSize); - } } + static const double THE_FACE_SIZE_COEFF = 10.0; + GeomShapePtr aBoundingFromShape = + GeomAlgoAPI_FaceBuilder::squareFace(aFromPnt, aFromDir, THE_FACE_SIZE_COEFF * aBndBoxSize); + GeomShapePtr aBoundingToShape = + GeomAlgoAPI_FaceBuilder::squareFace(aToPnt, aToDir, THE_FACE_SIZE_COEFF * aBndBoxSize); + // bounding planes const TopoDS_Shape& aToShape = aBoundingToShape->impl(); const TopoDS_Shape& aFromShape = aBoundingFromShape->impl(); @@ -468,7 +459,7 @@ void GeomAlgoAPI_Prism::buildByPlanes(const GeomShapePtr theBaseShap // Solid based on "From" bounding plane aNormal = aFromDir->impl(); BRepPrimAPI_MakePrism* aFromPrismBuilder = - new BRepPrimAPI_MakePrism(aFromShape, aNormal * (-aBndBoxSize)); + new BRepPrimAPI_MakePrism(aFromShape, aNormal * (-2.0 * aBndBoxSize)); if (!aFromPrismBuilder || !aFromPrismBuilder->IsDone()) { return; } -- 2.39.2