19 #include <type_traits>
53 std::size_t TDimension,
57 class TDistanceIteratorType,
58 class TIteratorIteratorType =
typename std::vector<TIteratorType>::iterator
99 virtual void PrintData(std::ostream& rOStream, std::string
const& Perfix = std::string())
const {}
139 SizeType const& MaxNumberOfResults )
154 return msNullPointer;
168 template<std::
size_t TDimension,
class TPo
intType,
class TPo
interType,
class TIteratorType,
class TDistanceIteratorType,
class TIteratorIteratorType>
170 TreeNode<TDimension, TPointType, TPointerType, TIteratorType, TDistanceIteratorType, TIteratorIteratorType>::msNull;
172 template<std::
size_t TDimension,
class TPo
intType,
class TPo
interType,
class TIteratorType,
class TDistanceIteratorType,
class TIteratorIteratorType>
174 TreeNode<TDimension, TPointType, TPointerType, TIteratorType, TDistanceIteratorType, TIteratorIteratorType>::msNullPointer;
176 template<std::
size_t TDimension,
class TPo
intType,
class TPo
interType,
class TIteratorType,
class TDistanceIteratorType,
class TIteratorIteratorType>
177 TreeNode<TDimension, TPointType, TPointerType, TIteratorType, TDistanceIteratorType, TIteratorIteratorType>
178 TreeNode<TDimension, TPointType, TPointerType, TIteratorType, TDistanceIteratorType, TIteratorIteratorType>::msNullLeaf;
188 template<
class TPartitionType >
196 template <
typename T,
typename =
void>
201 template <
typename T>
203 using type =
typename T::ObjectType;
254 static constexpr std::size_t
Dimension = PartitionType::Dimension;
285 ) : mBucketSize(BucketSize),
286 mitPointsBegin(itPointsBegin),
287 mitPointsEnd(itPointsEnd)
289 if(mitPointsBegin == mitPointsEnd)
297 r_high_point[
i] = (**mitPointsBegin)[
i];
298 r_low_point[
i] = (**mitPointsBegin)[
i];
301 for(
IteratorType point_iterator = mitPointsBegin ; point_iterator != mitPointsEnd ; point_iterator++) {
303 if((**point_iterator)[
i] > r_high_point[
i]) {
304 r_high_point[
i] = (**point_iterator)[
i];
305 }
else if((**point_iterator)[
i] < r_low_point[
i]) {
306 r_low_point[
i] = (**point_iterator)[
i];
311 mRoot = TPartitionType::Construct(mitPointsBegin, mitPointsEnd, r_high_point, r_low_point, mBucketSize);
324 ) : mitPointsBegin(itPointsBegin),
325 mitPointsEnd(itPointsEnd)
327 if(mitPointsBegin == mitPointsEnd)
335 mBucketSize =
static_cast<std::size_t
>( (
double) NumPoints / (
double) Parts.
mNumPartitions ) + 1;
337 r_high_point = **mitPointsBegin;
338 r_low_point = **mitPointsBegin;
339 for(
IteratorType point_iterator = mitPointsBegin ; point_iterator != mitPointsEnd ; point_iterator++) {
341 if((**point_iterator)[
i] > r_high_point[
i]) {
342 r_high_point[
i] = (**point_iterator)[
i];
343 }
else if((**point_iterator)[
i] < r_low_point[
i]) {
344 r_low_point[
i] = (**point_iterator)[
i];
349 mRoot = TPartitionType::Construct(mitPointsBegin, mitPointsEnd, r_high_point, r_low_point, mBucketSize);
381 if (ResultDistance<Tolerance*Tolerance)
447 mRoot->
SearchInRadius(ThisPoint, Radius, Radius2, Results, ResultsDistances, NumberOfResults, MaxNumberOfResults);
449 return NumberOfResults;
472 mRoot->
SearchInRadius(ThisPoint, Radius, Radius2, Results, NumberOfResults, MaxNumberOfResults);
473 return NumberOfResults;
492 mRoot->
SearchInBox(MinPointBox,MaxPointBox,Results,NumberOfResults,MaxNumberOfResults);
493 return NumberOfResults;
537 virtual std::string
Info()
const
549 virtual void PrintData(std::ostream& rOStream, std::string
const& Perfix = std::string())
const
599 Tree& operator=(
Tree const& rOther);
607 template<
class TPartitionType >
619 template<
class TPartitionType>
623 template<
class TPartitionType>
627 rOStream << std::endl;
TPointType & GetMinPoint()
Gets a reference to the minimum point.
Definition: bounding_box.h:179
TPointType & GetMaxPoint()
Gets a reference to the maximum point.
Definition: bounding_box.h:199
This class defines the node.
Definition: node.h:65
Definition: search_structure.h:309
Class to represent partitions for the tree.
Definition: tree.h:211
Partitions(const std::size_t NumPartitions)
Constructor to initialize the number of partitions.
Definition: tree.h:217
std::size_t mNumPartitions
The number of partitions.
Definition: tree.h:220
~Partitions()
Destructor.
Definition: tree.h:220
A generic tree data structure for spatial partitioning.
Definition: tree.h:190
virtual void PrintData(std::ostream &rOStream, std::string const &Perfix=std::string()) const
Print object's data.
Definition: tree.h:549
SizeType SearchInBox(PointType const &MinPointBox, PointType const &MaxPointBox, IteratorType Results, SizeType MaxNumberOfResults)
Search for points within a given axis-aligned box.
Definition: tree.h:484
BoundingBox< PointType > & GetBoundingBox()
Get the bounding box.
Definition: tree.h:523
typename PartitionType::SearchStructureType SearchStructureType
The search structure type definition.
Definition: tree.h:269
typename NodeType::SizeType SizeType
The size type definition.
Definition: tree.h:263
typename NodeType::IndexType IndexType
The index type definition.
Definition: tree.h:266
typename PartitionType::PointType PointType
The point type definition.
Definition: tree.h:236
static constexpr std::size_t Dimension
Dimension definition.
Definition: tree.h:254
typename PartitionType::DistanceFunction DistanceFunction
The distance function type definition.
Definition: tree.h:251
Tree(IteratorType itPointsBegin, IteratorType itPointsEnd, SizeType BucketSize=1)
Construct a new Tree object.
Definition: tree.h:281
PointerType SearchNearestPoint(PointType const &ThisPoint, CoordinateType &rResultDistance)
Search for the nearest point to a given point.
Definition: tree.h:391
typename PartitionType::LeafType LeafType
The leaf type definition.
Definition: tree.h:233
PointType & BoundingBoxHighPoint()
Get a reference to the high point of the bounding box.
Definition: tree.h:513
virtual std::string Info() const
Turn back information as a string.
Definition: tree.h:537
typename PartitionType::IteratorType IteratorType
The iterator type definition.
Definition: tree.h:239
typename PartitionType::PointerType PointerType
The pointer type definition.
Definition: tree.h:248
PointType & BoundingBoxLowPoint()
Get a reference to the low point of the bounding box.
Definition: tree.h:504
SizeType SearchInRadius(PointType const &ThisPoint, CoordinateType Radius, IteratorType Results, DistanceIteratorType ResultsDistances, SizeType MaxNumberOfResults)
Search for points within a given radius of a point.
Definition: tree.h:434
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: tree.h:543
KRATOS_CLASS_POINTER_DEFINITION(Tree)
Pointer definition of Tree.
typename NodeType::CoordinateType CoordinateType
The coordinate type definition.
Definition: tree.h:260
SizeType SearchInRadius(PointType const &ThisPoint, CoordinateType Radius, IteratorType Results, SizeType MaxNumberOfResults)
Search for points within a given radius of a point.
Definition: tree.h:460
virtual ~Tree()
Destructor.
Definition: tree.h:353
Tree(IteratorType itPointsBegin, IteratorType itPointsEnd, Partitions Parts)
Construct a new Tree object.
Definition: tree.h:320
TPartitionType PartitionType
The partition type definition.
Definition: tree.h:230
PointerType SearchNearestPoint(PointType const &ThisPoint)
Search for points within a given radius of a point.
Definition: tree.h:414
PointerType ExistPoint(PointerType const &ThisPoint, CoordinateType const Tolerance=static_cast< CoordinateType >(10.0 *DBL_EPSILON))
Check if a point exists in the tree within a given tolerance.
Definition: tree.h:372
typename PartitionType::DistanceIteratorType DistanceIteratorType
The distance iterator type definition.
Definition: tree.h:245
typename GetObjectType< PointType >::type ObjectType
The object type.
Definition: tree.h:242
Short class definition.
Definition: tree.h:61
KRATOS_CLASS_POINTER_DEFINITION(TreeNode)
Pointer definition of TreeNode.
TPointerType PointerType
Define PointerType as TPointerType.
Definition: tree.h:82
virtual void SearchInBox(PointType const &SearchMinPoint, PointType const &SearchMaxPoint, IteratorType &Results, SizeType &NumberOfResults, SizeType const &MaxNumberOfResults)
Definition: tree.h:138
static TreeNode & NullLeaf()
Definition: tree.h:157
TDistanceIteratorType DistanceIteratorType
Define DistanceIteratorType as TDistanceIteratorType.
Definition: tree.h:88
virtual void SearchInRadius(PointType const &ThisPoint, CoordinateType const &Radius, CoordinateType const &Radius2, IteratorType &Results, SizeType &NumberOfResults, SizeType const &MaxNumberOfResults)
Definition: tree.h:124
static IteratorType & NullIterator()
Definition: tree.h:147
virtual void SearchNearestPoint(PointType const &ThisPoint, PointerType &rResult, CoordinateType &rResultDistance, SearchStructureType &Auxiliar)
Definition: tree.h:107
virtual void SearchNearestPoint(PointType const &ThisPoint, PointerType &rResult, CoordinateType &rResultDistance)
Definition: tree.h:105
TreeNode()
Definition: tree.h:101
typename std::vector< IteratorType >::iterator IteratorIteratorType
Define IteratorIteratorType as an iterator type for a vector of IteratorType.
Definition: tree.h:94
TIteratorType IteratorType
Define IteratorType as TIteratorType.
Definition: tree.h:85
virtual void SearchInRadius(PointType const &ThisPoint, CoordinateType const &Radius, CoordinateType const &Radius2, IteratorType &Results, DistanceIteratorType &ResultsDistances, SizeType &NumberOfResults, SizeType const &MaxNumberOfResults)
Definition: tree.h:110
virtual ~TreeNode()
Definition: tree.h:103
TPointType PointType
Define PointType as TPointType.
Definition: tree.h:79
double CoordinateType
Define CoordinateType as double.
Definition: tree.h:76
virtual void SearchInRadius(PointType const &ThisPoint, CoordinateType const &Radius, CoordinateType const &Radius2, IteratorType &Results, SizeType &NumberOfResults, SizeType const &MaxNumberOfResults, SearchStructureType &Auxiliar)
Definition: tree.h:131
virtual void PrintData(std::ostream &rOStream, std::string const &Perfix=std::string()) const
Definition: tree.h:99
std::size_t IndexType
Define IndexType as std::size_t.
Definition: tree.h:73
std::size_t SizeType
Define SizeType as std::size_t.
Definition: tree.h:70
static PointerType & NullPointer()
Definition: tree.h:152
virtual void SearchInRadius(PointType const &ThisPoint, CoordinateType const &Radius, CoordinateType const &Radius2, IteratorType &Results, DistanceIteratorType &ResultsDistances, SizeType &NumberOfResults, SizeType const &MaxNumberOfResults, SearchStructureType &Auxiliar)
Definition: tree.h:117
std::size_t PointerDistance(TPointerType const &PointerBegin, TPointerType const &PointerEnd)
Definition: search_structure.h:91
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
std::size_t SizeType
The definition of the size type.
Definition: mortar_classes.h:43
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
TABLE_NUMBER_ANGULAR_VELOCITY TABLE_NUMBER_MOMENT I33 BEAM_INERTIA_ROT_UNIT_LENGHT_Y KRATOS_DEFINE_APPLICATION_VARIABLE(DEM_APPLICATION, double, BEAM_INERTIA_ROT_UNIT_LENGHT_Z) typedef std double
Definition: DEM_application_variables.h:182
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
namespace
Definition: array_1d.h:793
integer i
Definition: TensorModule.f:17
#define DBL_MAX
Definition: search_structure.h:23
typename T::ObjectType type
Definition: tree.h:203
void type
Definition: tree.h:198
Configure::IteratorType IteratorType
Definition: transfer_utility.h:249
Configure::PointType PointType
Definition: transfer_utility.h:245