Salome HOME
Bug fixes for the Placement feature
authorazv <azv@opencascade.com>
Tue, 2 Dec 2014 14:26:30 +0000 (17:26 +0300)
committerazv <azv@opencascade.com>
Tue, 2 Dec 2014 14:26:30 +0000 (17:26 +0300)
src/FeaturesPlugin/FeaturesPlugin_Placement.cpp
src/GeomAPI/GeomAPI_Face.cpp
src/GeomAlgoAPI/GeomAlgoAPI_Placement.cpp

index b9b567f41de06280a519132846878e3ee49977b5..af86e815255c9bb88d0788cd453e9f1bec155b94 100644 (file)
@@ -116,6 +116,7 @@ void FeaturesPlugin_Placement::LoadNamingDS(
     std::shared_ptr<GeomAPI_Shape> theBasis,
     std::shared_ptr<GeomAPI_Shape> theContext)
 {
+  theResultBody->store(theFeature.shape());
   /// TODO: SZY
 /*
 
index a455a0aaa8b89cfa6f24fdfe7038b63d5ca27905..ba111a67d1936924af2049b606c934f33b45f4f9 100644 (file)
@@ -11,6 +11,7 @@
 #include <TopoDS_Face.hxx>
 #include <TopoDS.hxx>
 #include <BRep_Tool.hxx>
+#include <BRepAdaptor_Surface.hxx>
 #include <Geom_Surface.hxx>
 #include <Geom_Plane.hxx>
 
@@ -69,17 +70,20 @@ bool GeomAPI_Face::isPlanar() const
 std::shared_ptr<GeomAPI_Pln> GeomAPI_Face::getPlane() const
 {
   const TopoDS_Shape& aShape = const_cast<GeomAPI_Face*>(this)->impl<TopoDS_Shape>();
-  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<GeomAPI_Pln>();
 
   // 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<GeomAPI_Pnt> aCenter(
       new GeomAPI_Pnt(aCentralPnt.X(), aCentralPnt.Y(), aCentralPnt.Z()));
 
index b8718f938e7e6b2b83a6230a6b4f72ce89fbed8a..6a378adde2ce10d71514694ad793a12805661566 100644 (file)
@@ -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