3 #include <SimpleKDTreeFactory.h>
4 #include <KDTreePrimitiveComparator.h>
7 class SAHKDTreeGeoemtricStrategy;
135 friend class boost::serialization::access;
144 template <
typename Archive>
145 void serialize(Archive &ar,
unsigned int const version){
146 boost::serialization::void_cast_register<
150 ar &boost::serialization::base_object<SimpleKDTreeFactory>(*
this);
327 vector<Primitive *> &primitives,
406 vector<Primitive *>
const &primitives,
409 vector<Primitive *> &leftPrimitives,
410 vector<Primitive *> &rightPrimitives
430 vector<Primitive *>
const &primitives,
433 vector<Primitive *> &leftPrimitives,
434 vector<Primitive *> &rightPrimitives,
439 vector<Primitive *> &leftPrimitives,
440 vector<Primitive *> &rightPrimitives
441 )>f_buildChildrenNodes
458 vector<Primitive *>
const &primitives,
459 vector<Primitive *>
const &leftPrimitives,
460 vector<Primitive *>
const &rightPrimitives
494 vector<Primitive *>
const &primitives,
496 double const splitPos,
515 vector<Primitive *> &primitives,
520 double const minBound,
521 double const boundLength,
535 vector<Primitive *> &primitives
558 vector<Primitive *> &primitives,
560 vector<Primitive *>::iterator begin,
561 vector<Primitive *>::iterator end,
565 vector<Primitive *> &primitives,
570 double const minBound,
571 double const boundLength,
574 )> f_computeLossNodes
599 double const surfaceAreaRoot,
600 double const surfaceAreaInterior,
601 double const surfaceAreaLeaf,
602 vector<Primitive *>
const &primitives
651 vector<Primitive *>
const &primitives,
652 vector<Primitive *>
const &leftPrimitives,
653 vector<Primitive *>
const &rightPrimitives
725 vector<Primitive *>
const &primitives
Class that must be extended by any class which provides factory methods for k-dimensional trees....
Definition: KDTreeFactory.h:22
Class representing the root node of a KDTree.
Definition: KDTreeNodeRoot.h:12
Class representing a KDTree node.
Definition: KDTreeNode.h:9
Decorator for any SAH KDTree which provides support for multi thread KDTree building.
Definition: MultiThreadSAHKDTreeFactory.h:15
Class providing building methods for k-dimensional trees with surface area heuristic (SAH)
Definition: SAHKDTreeFactory.h:126
KDTreeFactory * clone() const override
Definition: SAHKDTreeFactory.cpp:41
void _clone(KDTreeFactory *kdtf) const override
Assign attributes from SAHKDTreeFactory to its clone.
Definition: SAHKDTreeFactory.cpp:49
virtual void computeBestSplit(vector< Primitive * > &primitives, size_t const lossNodes, double const start, double const step, int const splitAxis, double const minBound, double const boundLength, double &loss, double &splitPos) const
Iteratively compute the best split position, it is the one with smaller loss.
Definition: SAHKDTreeFactory.cpp:221
virtual double getInteriorCost() const
Obtain the cost-weight of interior nodes.
Definition: SAHKDTreeFactory.h:757
double co
Cost-weight for testing an object for intersection.
Definition: SAHKDTreeFactory.h:181
bool checkNodeMustSplit(vector< Primitive * > const &primitives, vector< Primitive * > const &leftPrimitives, vector< Primitive * > const &rightPrimitives) const override
Check wheter the node must be splitted (true) or not (false) depending on its total primitives.
Definition: SAHKDTreeFactory.cpp:193
virtual void internalizeILOT(double &hi, double &hl, double &ho, double &ht, KDTreeNode *node, vector< Primitive * > const &primitives, vector< Primitive * > const &leftPrimitives, vector< Primitive * > const &rightPrimitives)
Compute ILOT corresponding to internalization (make interior) of given node and its corresponding lef...
Definition: SAHKDTreeFactory.cpp:382
SAHKDTreeFactory(size_t const lossNodes=21, double const ci=1, double const cl=1, double const co=1)
Surface area heuristic KDTree factory default constructor.
Definition: SAHKDTreeFactory.cpp:6
virtual void buildChildrenNodesRecipe(KDTreeNode *node, KDTreeNode *parent, vector< Primitive * > const &primitives, int const depth, int const index, vector< Primitive * > &leftPrimitives, vector< Primitive * > &rightPrimitives, std::function< void(KDTreeNode *node, int const depth, int const index, vector< Primitive * > &leftPrimitives, vector< Primitive * > &rightPrimitives)>f_buildChildrenNodes)
The recipe for building of children nodes by SAH algorithm. It is meant to be used by the SAHKDTreeFa...
Definition: SAHKDTreeFactory.cpp:138
virtual size_t getLossNodes() const
Obtain the loss nodes used to compute the Surface Area Heuristic.
Definition: SAHKDTreeFactory.h:742
virtual double findSplitPositionBySAHRecipe(KDTreeNode *node, vector< Primitive * > &primitives, std::function< void(vector< Primitive * >::iterator begin, vector< Primitive * >::iterator end, KDTreePrimitiveComparator comparator)> f_sortPrimitives, std::function< void(vector< Primitive * > &primitives, size_t const lossNodes, double const start, double const step, int const splitAxis, double const minBound, double const boundLength, double &loss, double &splitPos)> f_computeLossNodes) const
The recipe for finding split position by SAH algorithm. It is meant to be used by the SAHKDTreeFactor...
Definition: SAHKDTreeFactory.cpp:288
virtual double getCacheT() const
Obtain the T component of ILOT cache.
Definition: SAHKDTreeFactory.h:717
virtual double splitLoss(vector< Primitive * > const &primitives, int const splitAxis, double const splitPos, double const r) const
Compute the loss function for the splitting hyperplane.
Definition: SAHKDTreeFactory.cpp:203
virtual double getObjectCost() const
Obtain the cost-weight of testing an object for intersection.
Definition: SAHKDTreeFactory.h:781
void buildChildrenNodes(KDTreeNode *node, KDTreeNode *parent, vector< Primitive * > const &primitives, int const depth, int const index, vector< Primitive * > &leftPrimitives, vector< Primitive * > &rightPrimitives) override
Build children nodes using heuristic to handle KDTree in-depth partitioning.
Definition: SAHKDTreeFactory.cpp:99
virtual void fromILOTCache(double &I, double &L, double &O, double &T) const
Set references from ILOT cache.
Definition: SAHKDTreeFactory.h:686
virtual double heuristicILOT(double &hi, double &hl, double &ho, double &ht, double const surfaceAreaRoot, double const surfaceAreaInterior, double const surfaceAreaLeaf, vector< Primitive * > const &primitives) const
Compute the heuristic preserving partials result of interest.
Definition: SAHKDTreeFactory.cpp:341
double ci
Cost-weight for traversing interior nodes.
Definition: SAHKDTreeFactory.h:171
std::function< void(void)> _unlockILOT
Function to unlock the ILOT cache. It is the counterpart of the _lockILOT function.
Definition: SAHKDTreeFactory.h:248
virtual void setLeafCost(double const cl)
Set the cost-weight for leaf nodes.
Definition: SAHKDTreeFactory.h:775
void serialize(Archive &ar, unsigned int const version)
Serialize a surface area heuristic KDTree factory to a stream of bytes.
Definition: SAHKDTreeFactory.h:145
KDTreeNode * cacheRoot
Cache pointer to root node of current KDTree being built.
Definition: SAHKDTreeFactory.h:188
virtual double getLeafCost() const
Obtain the cost-weight for leaf nodes.
Definition: SAHKDTreeFactory.h:769
double cacheO
Cache last valid object cost.
Definition: SAHKDTreeFactory.h:218
virtual void fromILOCache(double &I, double &L, double &O) const
Set references from ILOT cache but only for ILO components.
Definition: SAHKDTreeFactory.h:704
size_t lossNodes
How many loss nodes must be computed when optimizing the loss function to determine the best split p...
Definition: SAHKDTreeFactory.h:166
virtual void setObjectCost(double const co)
Set the cost-weight of testing an object for intersection.
Definition: SAHKDTreeFactory.h:787
virtual void initILOT(KDTreeNode *root, vector< Primitive * > const &primitives)
Initialize the ILOT cache from given root node.
Definition: SAHKDTreeFactory.cpp:419
double cacheT
Cache last valid tree cost.
Definition: SAHKDTreeFactory.h:233
double cacheI
Cache last valid interior cost.
Definition: SAHKDTreeFactory.h:198
virtual void toILOTCache(double const I, double const L, double const O, double const T)
Set ILOT cache from given values.
Definition: SAHKDTreeFactory.h:666
virtual void setLossNodes(size_t const lossNodes)
Set the number loss nodes used to compute the Surface Area Heuristic.
Definition: SAHKDTreeFactory.h:750
virtual void setInteriorCost(double const ci)
Set the cost-weight of interior nodes.
Definition: SAHKDTreeFactory.h:763
void computeKDTreeStats(KDTreeNodeRoot *root) const override
Compute the simple stats of the KDTree but also its cost based on surface area heuristic defined in d...
Definition: SAHKDTreeFactory.cpp:73
double cl
Cost-weight for traversing leaf nodes.
Definition: SAHKDTreeFactory.h:176
virtual double cumulativeILOT(double &hi, double &hl, double &ho, double &ht, double const _hi, double const _hl, double const _ho, double const saRoot) const
Compute the cumulative of heuristic ILOT.
Definition: SAHKDTreeFactory.cpp:365
void defineSplit(KDTreeNode *node, KDTreeNode *parent, vector< Primitive * > &primitives, int const depth) const override
Define the split axis and position for current node.
Definition: SAHKDTreeFactory.cpp:62
double cacheL
Cache last valid leaves cost.
Definition: SAHKDTreeFactory.h:208
std::function< void(void)> _lockILOT
Function to lock the ILOT cache on a unique way (no thread but locker one must be able to use it)....
Definition: SAHKDTreeFactory.h:241
virtual double findSplitPositionBySAH(KDTreeNode *node, vector< Primitive * > &primitives) const
Find the best split position using Surface Area Heuristic (SAH) as described in SAHKDTreeFactory::def...
Definition: SAHKDTreeFactory.cpp:247
virtual void setCacheRoot(KDTreeNode *root)
Set the cached root node.
Definition: SAHKDTreeFactory.h:732
Class providing a strategy for geometry-level parallelization of SAH KDTree building....
Definition: SAHKDTreeGeometricStrategy.h:17
Class providing building methods for simple k-dimensional trees.
Definition: SimpleKDTreeFactory.h:18
KDTree primitive comparator.
Definition: KDTreePrimitiveComparator.h:8