// Created on: 2013-12-20 // Created by: Denis BOGOLEPOV // Copyright (c) 2013-2014 OPEN CASCADE SAS // // This file is part of Open CASCADE Technology software library. // // 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. // // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. #include // ======================================================================= // function : BVH_Geometry // purpose : // ======================================================================= template BVH_Geometry::BVH_Geometry() : myIsDirty (Standard_False), myBVH (new BVH_Tree()) { // Set default builder - binned SAH split myBuilder = new BVH_BinnedBuilder (1 /* primitive per leaf */); } // ======================================================================= // function : ~BVH_Geometry // purpose : // ======================================================================= template BVH_Geometry::~BVH_Geometry() { myBVH.Nullify(); myBuilder.Nullify(); } // ======================================================================= // function : MarkDirty // purpose : // ======================================================================= template void BVH_Geometry::MarkDirty() { myIsDirty = Standard_True; } // ======================================================================= // function : Box // purpose : // ======================================================================= template BVH_Box BVH_Geometry::Box() const { if (!myIsDirty) { return myBox; } myBox = BVH_Set::Box(); return myBox; } // ======================================================================= // function : BVH // purpose : // ======================================================================= template const NCollection_Handle >& BVH_Geometry::BVH() { if (myIsDirty) { Update(); } return myBVH; } // ======================================================================= // function : Update // purpose : // ======================================================================= template void BVH_Geometry::Update() { if (!myIsDirty) { return; } myBuilder->Build (this, myBVH.operator->(), Box()); myIsDirty = Standard_False; } // ======================================================================= // function : Builder // purpose : // ======================================================================= template const NCollection_Handle >& BVH_Geometry::Builder() const { return myBuilder; } // ======================================================================= // function : SetBuilder // purpose : // ======================================================================= template void BVH_Geometry::SetBuilder (NCollection_Handle >& theBuilder) { myBuilder = theBuilder; }