0028259: Method MakeBlocksCnx is duplicated in two different places in BOPAlgo
[occt.git] / src / BVH / BVH_RadixSorter.hxx
CommitLineData
3a507ddb 1// Created on: 2016-04-13
2// Created by: Denis BOGOLEPOV
3// Copyright (c) 2013-2016 OPEN CASCADE SAS
4//
5// This file is part of Open CASCADE Technology software library.
6//
7// This library is free software; you can redistribute it and/or modify it under
8// the terms of the GNU Lesser General Public License version 2.1 as published
9// by the Free Software Foundation, with special exception defined in the file
10// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11// distribution for complete text of the license and disclaimer of any warranty.
12//
13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
15
16#ifndef _BVH_RadixSorter_Header
17#define _BVH_RadixSorter_Header
18
19#include <BVH_Sorter.hxx>
20#include <BVH_Builder.hxx>
21
22#include <NCollection_Handle.hxx>
23#include <NCollection_Array1.hxx>
24
25//! Pair of Morton code and primitive ID.
26typedef std::pair<Standard_Integer, Standard_Integer> BVH_EncodedLink;
27
28//! Performs radix sort of a BVH primitive set using
29//! 10-bit Morton codes (or 1024 x 1024 x 1024 grid).
30template<class T, int N>
31class BVH_RadixSorter : public BVH_Sorter<T, N>
32{
33public:
34
35 typedef typename BVH::VectorType<T, N>::Type BVH_VecNt;
36
37public:
38
39 //! Creates new BVH radix sorter for the given AABB.
40 BVH_RadixSorter (const BVH_Box<T, N>& theBox) : myBox (theBox) { }
41
42 //! Sorts the set.
43 virtual void Perform (BVH_Set<T, N>* theSet);
44
45 //! Sorts the given (inclusive) range in the set.
46 virtual void Perform (BVH_Set<T, N>* theSet, const Standard_Integer theStart, const Standard_Integer theFinal);
47
48 //! Returns Morton codes assigned to BVH primitives.
49 const NCollection_Array1<BVH_EncodedLink>& EncodedLinks() const { return *myEncodedLinks; }
50
51protected:
52
53 //! Axis-aligned bounding box (AABB) to perform sorting.
54 BVH_Box<T, N> myBox;
55
56 //! Morton codes assigned to BVH primitives.
57 NCollection_Handle<NCollection_Array1<BVH_EncodedLink> > myEncodedLinks;
58
59};
60
61#include <BVH_RadixSorter.lxx>
62
63#endif // _BVH_RadixSorter_Header