0024610: Visualization, Visual3d_View::MinMaxValues() - skip erased objects while...
[occt.git] / src / Graphic3d / Graphic3d_StructureManager.cxx
old mode 100755 (executable)
new mode 100644 (file)
index a618744..8c7a92b
@@ -1,22 +1,17 @@
 // Created by: NW,JPB,CAL
 // Copyright (c) 1991-1999 Matra Datavision
-// Copyright (c) 1999-2012 OPEN CASCADE SAS
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
 //
-// The content of this file is subject to the Open CASCADE Technology Public
-// License Version 6.5 (the "License"). You may not use the content of this file
-// except in compliance with the License. Please obtain a copy of the License
-// at http://www.opencascade.org and read it completely before using this file.
+// This file is part of Open CASCADE Technology software library.
 //
-// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
 //
-// The Original Code and all software distributed under the License is
-// distributed on an "AS IS" basis, without warranty of any kind, and the
-// Initial Developer hereby disclaims all such warranties, including without
-// limitation, any warranties of merchantability, fitness for a particular
-// purpose or non-infringement. Please see the License for the specific terms
-// and conditions governing the rights and limitations under the License.
-
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
 
 #define XTRACE
 
@@ -66,9 +61,6 @@ static Standard_Integer StructureManager_CurrentId = 0;
 //      -- les structures mises en evidence
 //      MyHighlightedStructure  :       SequenceOfStructure;
 
-//      -- les structures visibles
-//      MyVisibleStructure      :       SequenceOfStructure;
-
 //      -- les structures detectables
 //      MyPickStructure         :       SequenceOfStructure;
 
@@ -80,7 +72,6 @@ static Standard_Integer StructureManager_CurrentId = 0;
 Graphic3d_StructureManager::Graphic3d_StructureManager (const Handle(Graphic3d_GraphicDriver)& theDriver):
 MyDisplayedStructure (),
 MyHighlightedStructure (),
-MyVisibleStructure (),
 MyPickStructure () {
 
 Standard_Real Coef;
@@ -145,7 +136,6 @@ void Graphic3d_StructureManager::Destroy () {
 
         MyDisplayedStructure.Clear ();
         MyHighlightedStructure.Clear ();
-        MyVisibleStructure.Clear ();
         MyPickStructure.Clear ();
         StructureManager_ArrayId[MyId]  = 0;
 
@@ -232,18 +222,6 @@ void Graphic3d_StructureManager::Remove (const Standard_Integer AnId) {
 
 }
 
-void Graphic3d_StructureManager::Visible (const Handle(Graphic3d_Structure)& AStructure) {
-
-  MyVisibleStructure.Add(AStructure);
-
-}
-
-void Graphic3d_StructureManager::Invisible (const Handle(Graphic3d_Structure)& AStructure) {
-
-  MyVisibleStructure.Remove(AStructure);
-}
-
 void Graphic3d_StructureManager::Detectable (const Handle(Graphic3d_Structure)& AStructure) {
 
   MyPickStructure.Add(AStructure);
@@ -293,47 +271,6 @@ void Graphic3d_StructureManager::PickStructures (Graphic3d_MapOfStructure& SG) c
 
 }
 
-void Graphic3d_StructureManager::VisibleStructures (Graphic3d_MapOfStructure& SG) const {
-
-  SG.Assign(MyVisibleStructure);
-
-
-}
-
-void Graphic3d_StructureManager::MinMaxValues (Standard_Real& XMin, Standard_Real& YMin, Standard_Real& ZMin, Standard_Real& XMax, Standard_Real& YMax, Standard_Real& ZMax) const {
-
-Standard_Boolean Flag = Standard_True;
-Standard_Real Xm, Ym, Zm, XM, YM, ZM, RL, RF;
-
-        RL = RealLast ();
-        RF = RealFirst ();
-
-        XMin = YMin = ZMin = RL;
-        XMax = YMax = ZMax = RF;
-
-        Graphic3d_MapIteratorOfMapOfStructure it(MyDisplayedStructure);
-        for (; it.More(); it.Next()) {
-          Handle(Graphic3d_Structure) SG = it.Key();
-          if (! (SG->IsEmpty() || SG->IsInfinite ())) {
-            SG->MinMaxValues (Xm, Ym, Zm, XM, YM, ZM);
-            if (Xm < XMin) XMin = Xm;
-            if (Ym < YMin) YMin = Ym;
-            if (Zm < ZMin) ZMin = Zm;
-            if (XM > XMax) XMax = XM;
-            if (YM > YMax) YMax = YM;
-            if (ZM > ZMax) ZMax = ZM;
-            Flag = Standard_False;
-          }
-        }
-
-        // If all structures are empty or infinite
-        if (Flag) {
-          XMin = YMin = ZMin = RF;
-          XMax = YMax = ZMax = RL;
-        }
-}
 Standard_Integer Graphic3d_StructureManager::NewIdentification () {
 
 Standard_Integer Id     = MyStructGenId.Next ();
@@ -397,3 +334,27 @@ const Handle(Graphic3d_GraphicDriver)& Graphic3d_StructureManager::GraphicDriver
         return (MyGraphicDriver);
 
 }
+
+void Graphic3d_StructureManager::RecomputeStructures()
+{
+  // Go through all unique structures including child (connected) ones and ensure that they are computed.
+  Graphic3d_MapOfStructure aStructNetwork;
+
+  for (Graphic3d_MapIteratorOfMapOfStructure anIter(MyDisplayedStructure); anIter.More(); anIter.Next())
+  {
+    Handle(Graphic3d_Structure) aStructure = anIter.Key();
+    anIter.Key()->Network (anIter.Key(), Graphic3d_TOC_DESCENDANT, aStructNetwork);
+  }
+
+  RecomputeStructures (aStructNetwork);
+}
+
+void Graphic3d_StructureManager::RecomputeStructures (const Graphic3d_MapOfStructure& theStructures)
+{
+  for (Graphic3d_MapIteratorOfMapOfStructure anIter (theStructures); anIter.More(); anIter.Next())
+  {
+    Handle(Graphic3d_Structure) aStruct = anIter.Key();
+    aStruct->Clear();
+    aStruct->Compute();
+  }
+}