From 71cf58ac99d209975c4dc6d25d2fc9705eab3908 Mon Sep 17 00:00:00 2001 From: azv Date: Tue, 2 Dec 2014 17:26:30 +0300 Subject: [PATCH] Bug fixes for the Placement feature --- src/FeaturesPlugin/FeaturesPlugin_Placement.cpp | 1 + src/GeomAPI/GeomAPI_Face.cpp | 12 ++++++++---- src/GeomAlgoAPI/GeomAlgoAPI_Placement.cpp | 9 ++++++--- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/FeaturesPlugin/FeaturesPlugin_Placement.cpp b/src/FeaturesPlugin/FeaturesPlugin_Placement.cpp index b9b567f41..af86e8152 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Placement.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Placement.cpp @@ -116,6 +116,7 @@ void FeaturesPlugin_Placement::LoadNamingDS( std::shared_ptr theBasis, std::shared_ptr theContext) { + theResultBody->store(theFeature.shape()); /// TODO: SZY /* diff --git a/src/GeomAPI/GeomAPI_Face.cpp b/src/GeomAPI/GeomAPI_Face.cpp index a455a0aaa..ba111a67d 100644 --- a/src/GeomAPI/GeomAPI_Face.cpp +++ b/src/GeomAPI/GeomAPI_Face.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -69,17 +70,20 @@ bool GeomAPI_Face::isPlanar() const std::shared_ptr GeomAPI_Face::getPlane() const { const TopoDS_Shape& aShape = const_cast(this)->impl(); - Handle(Geom_Surface) aSurf = BRep_Tool::Surface(TopoDS::Face(aShape)); + BRepAdaptor_Surface aSurfAdapt(TopoDS::Face(aShape)); - if (!aSurf->IsKind(STANDARD_TYPE(Geom_Plane))) + if (aSurfAdapt.GetType() != GeomAbs_Plane) return std::shared_ptr(); // Obtain central point double aUMin, aUMax, aVMin, aVMax; - aSurf->Bounds(aUMin, aUMax, aVMin, aVMax); + aUMin = aSurfAdapt.FirstUParameter(); + aUMax = aSurfAdapt.LastUParameter(); + aVMin = aSurfAdapt.FirstVParameter(); + aVMax = aSurfAdapt.LastVParameter(); gp_Pnt aCentralPnt; gp_Vec aDU, aDV; - aSurf->D1((aUMin+aUMax)*0.5, (aVMin+aVMax)*0.5, aCentralPnt, aDU, aDV); + aSurfAdapt.D1((aUMin+aUMax)*0.5, (aVMin+aVMax)*0.5, aCentralPnt, aDU, aDV); std::shared_ptr aCenter( new GeomAPI_Pnt(aCentralPnt.X(), aCentralPnt.Y(), aCentralPnt.Z())); diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Placement.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Placement.cpp index b8718f938..6a378adde 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Placement.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Placement.cpp @@ -42,9 +42,12 @@ void GeomAlgoAPI_Placement::build( gp_Vec aSrcDir(aSourceDir->x(), aSourceDir->y(), aSourceDir->z()); gp_Vec aDstDir(aDestDir->x(), aDestDir->y(), aDestDir->z()); gp_Quaternion aRot(aSrcDir, aDstDir); - gp_Vec aTrans(aDestLoc->x() - aSourceLoc->x(), - aDestLoc->y() - aSourceLoc->y(), - aDestLoc->z() - aSourceLoc->z()); + aTrsf.SetRotation(aRot); + gp_Vec aSrcCenter(aSourceLoc->x(), aSourceLoc->y(), aSourceLoc->z()); + aSrcCenter.Transform(aTrsf); + gp_Vec aTrans(aDestLoc->x() - aSrcCenter.X(), + aDestLoc->y() - aSrcCenter.Y(), + aDestLoc->z() - aSrcCenter.Z()); aTrsf.SetTransformation(aRot, aTrans); // Transform the shape with copying it -- 2.39.2