// =======================================================================
 OpenGl_RTVec4f OpenGl_RaytraceScene::Center (const int theTriangle) const
 {
-  const OpenGl_RTVec4i anIndex (Triangles [theTriangle]);
+  const OpenGl_RTVec4i& anIndex = Triangles [theTriangle];
+
   return ( Vertices[anIndex.x()] +
            Vertices[anIndex.y()] +
            Vertices[anIndex.z()] ) * ( 1.f / 3.f );
 float OpenGl_RaytraceScene::CenterAxis (const int theTriangle,
                                         const int theAxis) const
 {
-  const OpenGl_RTVec4i anIndex (Triangles [theTriangle]);
+  const OpenGl_RTVec4i& anIndex = Triangles [theTriangle];
+
   return ( Vertices[anIndex.x()][theAxis] +
            Vertices[anIndex.y()][theAxis] +
            Vertices[anIndex.z()][theAxis] ) * ( 1.f / 3.f );
 // =======================================================================
 OpenGl_AABB OpenGl_RaytraceScene::Box (const int theTriangle) const
 {
-  const OpenGl_RTVec4i anIndex (Triangles[theTriangle]);
+  const OpenGl_RTVec4i& anIndex = Triangles[theTriangle];
 
-  const OpenGl_RTVec4f pA = Vertices[anIndex.x()];
-  const OpenGl_RTVec4f pB = Vertices[anIndex.y()];
-  const OpenGl_RTVec4f pC = Vertices[anIndex.z()];
+  const OpenGl_RTVec4f& pA = Vertices[anIndex.x()];
+  const OpenGl_RTVec4f& pB = Vertices[anIndex.y()];
+  const OpenGl_RTVec4f& pC = Vertices[anIndex.z()];
 
   OpenGl_AABB aBox (pA);
 
 
   }
 }
 
+// =======================================================================
+// function : UnregisterFromAncestorStructure
+// purpose  :
+// =======================================================================
+void OpenGl_Structure::UnregisterFromAncestorStructure() const
+{
+  for (OpenGl_ListOfStructure::Iterator anIta (myAncestorStructures); anIta.More(); anIta.Next())
+  {
+    OpenGl_Structure* anAncestor = const_cast<OpenGl_Structure*> (anIta.ChangeValue());
+
+    for (OpenGl_ListOfStructure::Iterator anIts (anAncestor->myConnected); anIts.More(); anIts.Next())
+    {
+      if (anIts.Value() == this)
+      {
+        anAncestor->myConnected.Remove (anIts);
+        return;
+      }      
+    }
+  }
+}
+
 // =======================================================================
 // function : UpdateStateWithAncestorStructures
 // purpose  :
   OpenGl_Element::Destroy (theGlCtx, myAspectMarker);
   OpenGl_Element::Destroy (theGlCtx, myAspectText);
   ClearHighlightColor (theGlCtx);
+
+#ifdef HAVE_OPENCL
+  // Remove from connected list of ancestor
+  UnregisterFromAncestorStructure();
+#endif
 }
 
 // =======================================================================
 
   //! Unregisters ancestor connected structure (for updating ray-tracing state).
   void UnregisterAncestorStructure (const OpenGl_Structure* theStructure) const;
 
+  //! Unregisters structure from ancestor structure (for updating ray-tracing state).
+  void UnregisterFromAncestorStructure() const;
+
   //! Updates modification state for structure and its parents.
   void UpdateStateWithAncestorStructures() const;
 
 
 using namespace OpenGl_Raytrace;
 
 //! Use this macro to output ray-tracing debug info
-// #define RAY_TRACE_PRINT_INFO
+//#define RAY_TRACE_PRINT_INFO
 
 #ifdef RAY_TRACE_PRINT_INFO
   #include <OSD_Timer.hxx>
 
--- /dev/null
+puts "TODO ?OCC24130 Windows: TKOpenGl | Type\: Error | ID\: 0 | Severity\: High | Message\:"
+
+puts "========"
+puts "Ray Tracing - check rendering of multi-connected structures"
+puts "========"
+
+# create boxes
+box b1 0 0 0 1 2 3
+box b2 3 0 0 3 2 1
+
+# draw box
+vinit View1
+vclear
+vsetdispmode 1
+vraytrace 0
+vaxo
+vconnectsh b1c -3 0 0 1 0 0 0 0 1 b1 b2
+vfit
+vrotate 0.2 0.0 0.0
+vclear
+vconnectsh b1c -3 0 0 1 0 0 0 0 1 b1 b2
+
+# take snapshot with fixed pipeline
+vdump $::imagedir/${::casename}_OFF.png
+
+# turn on ray tracing
+vraytrace 1
+vclinfo
+vdump $::imagedir/${::casename}_rt1.png
+
+vclear
+vconnectsh b1c -3 0 0 1 0 0 0 0 1 b1 b2