gmsh-TingyuanDoc  0.1
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
SOrientedBoundingBox.h
Go to the documentation of this file.
1 // Gmsh - Copyright (C) 1997-2022 C. Geuzaine, J.-F. Remacle
2 //
3 // See the LICENSE.txt file in the Gmsh root directory for license information.
4 // Please report all issues on https://gitlab.onelab.info/gmsh/gmsh/issues.
5 //
6 // Contributor(s):
7 // Bastien Gorissen
8 //
9 
10 #ifndef ORIENTED_BOUNDING_BOX_H
11 #define ORIENTED_BOUNDING_BOX_H
12 
13 #include "SVector3.h"
14 #include "SPoint2.h"
15 
16 #include <algorithm>
17 #include <array>
18 #include <vector>
19 
21 public:
23 
24  double area();
25 
26 public:
27  std::array<double, 2> center;
28  std::array<double, 2> size;
29  std::array<double, 2> axisX;
30  std::array<double, 2> axisY;
31 };
32 
34 public:
36 
37  // x, y, z are the box center, whereas the sizes are in the local
38  // axis system of the box. The axis form the local coordinates
39  // system of the box. All these data are given in the local
40  // coordinates system of the object.
41  SOrientedBoundingBox(SVector3 &center, double sizeX, double sizeY,
42  double sizeZ, const SVector3 &axisX,
43  const SVector3 &axisY, const SVector3 &axisZ);
44 
46 
47  const SVector3 &getCenter() const { return center; }
48  double getCenterX() const { return center[0]; }
49  double getCenterY() const { return center[1]; }
50  double getCenterZ() const { return center[2]; }
51  SVector3 getSize() const { return size; }
52 
53  double getMaxSize() const
54  {
55  return std::max(size[0], std::max(size[1], size[2]));
56  }
57 
58  double getMinSize() const
59  {
60  return std::min(size[0], std::min(size[1], size[2]));
61  }
62 
64  SVector3 getAxis(int axis) const;
65 
66  static SOrientedBoundingBox *buildOBB(std::vector<SPoint3> &vertices);
67 
68  bool intersects(SOrientedBoundingBox &obb) const;
69 
70  static double compare(SOrientedBoundingBox &obb1, SOrientedBoundingBox &obb2);
71 
72 public:
73  double p1x, p1y, p1z;
74  double p2x, p2y, p2z;
75  double p3x, p3y, p3z;
76  double p4x, p4y, p4z;
77  double p5x, p5y, p5z;
78  double p6x, p6y, p6z;
79  double p7x, p7y, p7z;
80  double p8x, p8y, p8z;
81 
82 private:
83  void fillp();
84 
85 private:
91 };
92 
93 #endif
SOrientedBoundingBox::getCenterX
double getCenterX() const
Definition: SOrientedBoundingBox.h:48
SOrientedBoundingBox::axisY
SVector3 axisY
Definition: SOrientedBoundingBox.h:89
SOrientedBoundingBox::p3y
double p3y
Definition: SOrientedBoundingBox.h:75
SOrientedBoundingBox::size
SVector3 size
Definition: SOrientedBoundingBox.h:87
SOrientedBoundingBox::p7y
double p7y
Definition: SOrientedBoundingBox.h:79
SOrientedBoundingBox::getSize
SVector3 getSize() const
Definition: SOrientedBoundingBox.h:51
SOrientedBoundingBox::p5x
double p5x
Definition: SOrientedBoundingBox.h:77
SOrientedBoundingRectangle::center
std::array< double, 2 > center
Definition: SOrientedBoundingBox.h:27
SOrientedBoundingBox::axisZ
SVector3 axisZ
Definition: SOrientedBoundingBox.h:90
SVector3
Definition: SVector3.h:16
SOrientedBoundingBox
Definition: SOrientedBoundingBox.h:33
SOrientedBoundingBox::getCenterZ
double getCenterZ() const
Definition: SOrientedBoundingBox.h:50
SVector3.h
SOrientedBoundingRectangle::size
std::array< double, 2 > size
Definition: SOrientedBoundingBox.h:28
SOrientedBoundingBox::p6z
double p6z
Definition: SOrientedBoundingBox.h:78
SOrientedBoundingBox::p8x
double p8x
Definition: SOrientedBoundingBox.h:80
SOrientedBoundingBox::p8y
double p8y
Definition: SOrientedBoundingBox.h:80
SOrientedBoundingBox::p4z
double p4z
Definition: SOrientedBoundingBox.h:76
SOrientedBoundingBox::p4x
double p4x
Definition: SOrientedBoundingBox.h:76
SOrientedBoundingBox::fillp
void fillp()
Definition: SOrientedBoundingBox.cpp:32
SOrientedBoundingBox::p5z
double p5z
Definition: SOrientedBoundingBox.h:77
SOrientedBoundingRectangle::area
double area()
Definition: SOrientedBoundingBox.cpp:30
SOrientedBoundingBox::p5y
double p5y
Definition: SOrientedBoundingBox.h:77
SOrientedBoundingBox::getMaxSize
double getMaxSize() const
Definition: SOrientedBoundingBox.h:53
SOrientedBoundingBox::getMinSize
double getMinSize() const
Definition: SOrientedBoundingBox.h:58
SOrientedBoundingRectangle::axisX
std::array< double, 2 > axisX
Definition: SOrientedBoundingBox.h:29
SOrientedBoundingBox::center
SVector3 center
Definition: SOrientedBoundingBox.h:86
SOrientedBoundingBox::p2y
double p2y
Definition: SOrientedBoundingBox.h:74
SOrientedBoundingBox::intersects
bool intersects(SOrientedBoundingBox &obb) const
Definition: SOrientedBoundingBox.cpp:119
SOrientedBoundingBox::getCenter
const SVector3 & getCenter() const
Definition: SOrientedBoundingBox.h:47
SOrientedBoundingBox::getCenterY
double getCenterY() const
Definition: SOrientedBoundingBox.h:49
SOrientedBoundingRectangle
Definition: SOrientedBoundingBox.h:20
SOrientedBoundingBox::p1z
double p1z
Definition: SOrientedBoundingBox.h:73
SOrientedBoundingBox::SOrientedBoundingBox
SOrientedBoundingBox()
Definition: SOrientedBoundingBox.cpp:71
SOrientedBoundingBox::p4y
double p4y
Definition: SOrientedBoundingBox.h:76
SOrientedBoundingRectangle::SOrientedBoundingRectangle
SOrientedBoundingRectangle()
Definition: SOrientedBoundingBox.cpp:24
SOrientedBoundingRectangle::axisY
std::array< double, 2 > axisY
Definition: SOrientedBoundingBox.h:30
SOrientedBoundingBox::p6y
double p6y
Definition: SOrientedBoundingBox.h:78
SOrientedBoundingBox::compare
static double compare(SOrientedBoundingBox &obb1, SOrientedBoundingBox &obb2)
Definition: SOrientedBoundingBox.cpp:553
SOrientedBoundingBox::p8z
double p8z
Definition: SOrientedBoundingBox.h:80
SOrientedBoundingBox::axisX
SVector3 axisX
Definition: SOrientedBoundingBox.h:88
SOrientedBoundingBox::buildOBB
static SOrientedBoundingBox * buildOBB(std::vector< SPoint3 > &vertices)
Definition: SOrientedBoundingBox.cpp:150
SOrientedBoundingBox::p7z
double p7z
Definition: SOrientedBoundingBox.h:79
SOrientedBoundingBox::p3z
double p3z
Definition: SOrientedBoundingBox.h:75
SOrientedBoundingBox::p2x
double p2x
Definition: SOrientedBoundingBox.h:74
SOrientedBoundingBox::p7x
double p7x
Definition: SOrientedBoundingBox.h:79
SOrientedBoundingBox::p6x
double p6x
Definition: SOrientedBoundingBox.h:78
SOrientedBoundingBox::p1x
double p1x
Definition: SOrientedBoundingBox.h:73
SOrientedBoundingBox::p3x
double p3x
Definition: SOrientedBoundingBox.h:75
SOrientedBoundingBox::p1y
double p1y
Definition: SOrientedBoundingBox.h:73
SOrientedBoundingBox::getAxis
SVector3 getAxis(int axis) const
valid values for axis are 0 (X-axis), 1 (Y-axis) or 2 (Z-axis)
Definition: SOrientedBoundingBox.cpp:108
SOrientedBoundingBox::p2z
double p2z
Definition: SOrientedBoundingBox.h:74
SPoint2.h