]> OCCT Git - occt-copy.git/commitdiff
Changes from CR2618_1.
authorisk <isk@opencascade.com>
Thu, 29 Oct 2015 11:30:46 +0000 (14:30 +0300)
committerisk <isk@opencascade.com>
Thu, 29 Oct 2015 11:30:46 +0000 (14:30 +0300)
src/V3d/V3d_View.cxx

index dccc1f8689fbd04d34b1c9642e6d5c32f0d7229d..ff1ebb3732b41b330729606416083505a1a09771 100644 (file)
@@ -2163,108 +2163,9 @@ void V3d_View::Gravity (Standard_Real& theX,
                         Standard_Real& theY,
                         Standard_Real& theZ) const
 {
-  Graphic3d_MapOfStructure aSetOfStructures;
-  myView->DisplayedStructures (aSetOfStructures);
-
-  Standard_Boolean hasSelection = Standard_False;
-  for (Graphic3d_MapIteratorOfMapOfStructure aStructIter (aSetOfStructures);
-       aStructIter.More(); aStructIter.Next())
-  {
-    if (aStructIter.Key()->IsHighlighted()
-     && aStructIter.Key()->IsVisible())
-    {
-      hasSelection = Standard_True;
-      break;
-    }
-  }
-
-  Standard_Real Xmin, Ymin, Zmin, Xmax, Ymax, Zmax;
-  Standard_Integer aNbPoints = 0;
-  gp_XYZ aResult (0.0, 0.0, 0.0);
-  for (Graphic3d_MapIteratorOfMapOfStructure aStructIter (aSetOfStructures);
-       aStructIter.More(); aStructIter.Next())
-  {
-    const Handle(Graphic3d_Structure)& aStruct = aStructIter.Key();
-    if (!aStruct->IsVisible()
-    || (hasSelection && !aStruct->IsHighlighted())
-    ||  aStruct->IsEmpty())
-    {
-      continue;
-    }
-
-    Bnd_Box aBox = aStruct->MinMaxValues();
-    if (aBox.IsVoid() || aStruct->IsInfinite())
-    {
-      continue;
-    }
-
-    // use camera projection to find gravity point
-    aBox.Get (Xmin, Ymin, Zmin,
-              Xmax, Ymax, Zmax);
-    gp_Pnt aPnts[THE_NB_BOUND_POINTS] =
-    {
-      gp_Pnt (Xmin, Ymin, Zmin), gp_Pnt (Xmin, Ymin, Zmax),
-      gp_Pnt (Xmin, Ymax, Zmin), gp_Pnt (Xmin, Ymax, Zmax),
-      gp_Pnt (Xmax, Ymin, Zmin), gp_Pnt (Xmax, Ymin, Zmax),
-      gp_Pnt (Xmax, Ymax, Zmin), gp_Pnt (Xmax, Ymax, Zmax)
-    };
-
-    for (Standard_Integer aPntIt = 0; aPntIt < THE_NB_BOUND_POINTS; ++aPntIt)
-    {
-      const gp_Pnt& aBndPnt    = aPnts[aPntIt];
-      const gp_Pnt  aProjected = Camera()->Project (aBndPnt);
-      if (Abs (aProjected.X()) <= 1.0
-       && Abs (aProjected.Y()) <= 1.0)
-      {
-        aResult += aBndPnt.XYZ();
-        ++aNbPoints;
-      }
-    }
-  }
-
-  if (aNbPoints == 0)
-  {
-    for (Graphic3d_MapIteratorOfMapOfStructure aStructIter (aSetOfStructures);
-         aStructIter.More(); aStructIter.Next())
-    {
-      const Handle(Graphic3d_Structure)& aStruct = aStructIter.Key();
-      if (aStruct->IsEmpty())
-      {
-        continue;
-      }
-
-      Bnd_Box aBox = aStruct->MinMaxValues();
-      if (aBox.IsVoid() || aStruct->IsInfinite())
-      {
-        continue;
-      }
-
-      aBox.Get (Xmin, Ymin, Zmin,
-                Xmax, Ymax, Zmax);
-      gp_Pnt aPnts[THE_NB_BOUND_POINTS] =
-      {
-        gp_Pnt (Xmin, Ymin, Zmin), gp_Pnt (Xmin, Ymin, Zmax),
-        gp_Pnt (Xmin, Ymax, Zmin), gp_Pnt (Xmin, Ymax, Zmax),
-        gp_Pnt (Xmax, Ymin, Zmin), gp_Pnt (Xmax, Ymin, Zmax),
-        gp_Pnt (Xmax, Ymax, Zmin), gp_Pnt (Xmax, Ymax, Zmax)
-      };
-
-      for (Standard_Integer aPntIt = 0; aPntIt < THE_NB_BOUND_POINTS; ++aPntIt)
-      {
-        const gp_Pnt& aBndPnt = aPnts[aPntIt];
-        aResult += aBndPnt.XYZ();
-        ++aNbPoints;
-      }
-    }
-  }
-
-  if (aNbPoints > 0)
-  {
-    aResult /= aNbPoints;
-  }
-  theX = aResult.X();
-  theY = aResult.Y();
-  theZ = aResult.Z();
+  theX = myCamera->Center().X();
+  theY = myCamera->Center().Y();
+  theZ = myCamera->Center().Z();
 }
 
 //=======================================================================