Skip to content
Snippets Groups Projects
Commit c97921c7 authored by Tom Fischer's avatar Tom Fischer
Browse files

Removed template parameter from AABB.

parent 5de5ecad
No related branches found
No related tags found
No related merge requests found
Showing
with 50 additions and 54 deletions
......@@ -144,7 +144,7 @@ void ElementTreeModel::setMesh(MeshLib::Mesh const*const mesh)
TreeItem* aabb_item = new TreeItem(bounding_box, _rootItem);
_rootItem->appendChild(aabb_item);
const GeoLib::AABB<MeshLib::Node> aabb (MeshLib::MeshInformation::getBoundingBox(*mesh));
const GeoLib::AABB aabb (MeshLib::MeshInformation::getBoundingBox(*mesh));
auto const& min = aabb.getMinPoint();
auto const& max = aabb.getMaxPoint();
......
......@@ -80,7 +80,7 @@ void MeshElementRemovalDialog::accept()
if (this->boundingBoxCheckBox->isChecked())
{
std::vector<MeshLib::Node*> const& nodes (_project.getMesh(this->meshNameComboBox->currentText().toStdString())->getNodes());
GeoLib::AABB<MeshLib::Node> const aabb(nodes.begin(), nodes.end());
GeoLib::AABB const aabb(nodes.begin(), nodes.end());
auto minAABB = aabb.getMinPoint();
auto maxAABB = aabb.getMaxPoint();
......@@ -94,7 +94,7 @@ void MeshElementRemovalDialog::accept()
std::vector<MathLib::Point3d> extent;
extent.push_back(minAABB);
extent.push_back(maxAABB);
const GeoLib::AABB<MathLib::Point3d> updated_aabb(extent.begin(), extent.end());
const GeoLib::AABB updated_aabb(extent.begin(), extent.end());
ex.searchByBoundingBox(updated_aabb);
anything_checked = true;
}
......@@ -144,7 +144,7 @@ void MeshElementRemovalDialog::on_boundingBoxCheckBox_toggled(bool is_checked)
{
_aabbIndex = _currentIndex;
std::vector<MeshLib::Node*> const& nodes (_project.getMesh(this->meshNameComboBox->currentText().toStdString())->getNodes());
GeoLib::AABB<MeshLib::Node> aabb(nodes.begin(), nodes.end());
GeoLib::AABB aabb(nodes.begin(), nodes.end());
auto const& minAABB = aabb.getMinPoint();
auto const& maxAABB = aabb.getMaxPoint();
this->xMinEdit->setText(QString::number(minAABB[0], 'f'));
......
......@@ -71,7 +71,7 @@ int main(int argc, char *argv[])
if (fabs(x_arg.getValue()) < std::numeric_limits<double>::epsilon()
&& fabs(y_arg.getValue()) < std::numeric_limits<double>::epsilon()
&& fabs(z_arg.getValue()) < std::numeric_limits<double>::epsilon()) {
GeoLib::AABB<MeshLib::Node> aabb(mesh->getNodes().begin(), mesh->getNodes().end());
GeoLib::AABB aabb(mesh->getNodes().begin(), mesh->getNodes().end());
displacement[0] = -(aabb.getMaxPoint()[0] + aabb.getMinPoint()[0])/2.0;
displacement[1] = -(aabb.getMaxPoint()[1] + aabb.getMinPoint()[1])/2.0;
displacement[2] = -(aabb.getMaxPoint()[2] + aabb.getMinPoint()[2])/2.0;
......
......@@ -64,7 +64,7 @@ int main(int argc, char *argv[])
INFO ("Time for reading: %g s", run_time.elapsed());
// Geometric information
const GeoLib::AABB<MeshLib::Node> aabb(MeshLib::MeshInformation::getBoundingBox(*mesh));
const GeoLib::AABB aabb(MeshLib::MeshInformation::getBoundingBox(*mesh));
auto minPt(aabb.getMinPoint());
auto maxPt(aabb.getMaxPoint());
INFO("Node coordinates:");
......
......@@ -140,7 +140,7 @@ int main (int argc, char* argv[])
double offset (0.0); // additional offset for elevation (should be 0)
MeshLib::Mesh* ground_truth (FileIO::readMeshFromFile(value));
const std::vector<MeshLib::Node*> ground_truth_nodes (ground_truth->getNodes());
GeoLib::AABB<MeshLib::Node> bounding_box(ground_truth_nodes.begin(), ground_truth_nodes.end());
GeoLib::AABB bounding_box(ground_truth_nodes.begin(), ground_truth_nodes.end());
MathLib::Point3d const& min(bounding_box.getMinPoint());
MathLib::Point3d const& max(bounding_box.getMaxPoint());
......
......@@ -138,7 +138,7 @@ int main (int argc, char* argv[])
MathLib::Point3d(std::array<double,3>{{xLargeArg.getValue(),
yLargeArg.getValue(), zLargeArg.getValue()}})}});
const std::size_t n_removed_elements = ex.searchByBoundingBox(
GeoLib::AABB<MathLib::Point3d>(extent.begin(), extent.end()));
GeoLib::AABB(extent.begin(), extent.end()));
INFO("%d elements found.", n_removed_elements);
}
......
......@@ -32,7 +32,7 @@
namespace GeoLib
{
template <typename POINT>
class Grid : public GeoLib::AABB<POINT>
class Grid : public GeoLib::AABB
{
public:
/**
......@@ -179,7 +179,7 @@ template <typename POINT>
template <typename InputIterator>
Grid<POINT>::Grid(InputIterator first, InputIterator last,
std::size_t max_num_per_grid_cell)
: GeoLib::AABB<POINT>(first, last), _n_steps({{1,1,1}}),
: GeoLib::AABB(first, last), _n_steps({{1,1,1}}),
_step_sizes({{0.0,0.0,0.0}}), _inverse_step_sizes({{0.0,0.0,0.0}}),
_grid_cell_nodes_map(nullptr)
{
......
......@@ -100,7 +100,7 @@ public:
const std::vector<std::size_t>& getIDMap () const { return _pnt_id_map; }
const GeoLib::AABB<GeoLib::Point>& getAABB () const;
const GeoLib::AABB& getAABB () const;
std::string const& getItemNameByID(std::size_t id) const;
......@@ -136,7 +136,7 @@ private:
/// given point id.
std::vector<std::string> _id_to_name_map;
AABB<GeoLib::Point> _aabb;
AABB _aabb;
double _rel_eps;
std::unique_ptr<GeoLib::OctTree<GeoLib::Point, 16>> _oct_tree;
};
......
......@@ -138,7 +138,7 @@ private:
void splitPolygonAtIntersection (std::list<Polygon*>::iterator polygon_it);
void splitPolygonAtPoint (std::list<Polygon*>::iterator polygon_it);
std::list<Polygon*> _simple_polygon_list;
AABB<GeoLib::Point> _aabb;
AABB _aabb;
};
/**
......
......@@ -58,7 +58,7 @@ void Surface::addTriangle(std::size_t pnt_a, std::size_t pnt_b, std::size_t pnt_
ids[0] = pnt_a;
ids[1] = pnt_b;
ids[2] = pnt_c;
_bounding_volume = new AABB<Point>(_sfc_pnts, ids);
_bounding_volume = new AABB(_sfc_pnts, ids);
if (_surface_grid == nullptr) {
_surface_grid = new SurfaceGrid(this);
}
......
......@@ -87,7 +87,7 @@ public:
* method allows access to the internal axis aligned bounding box
* @return axis aligned bounding box
*/
AABB<GeoLib::Point> const& getAABB () const { return *_bounding_volume; }
AABB const& getAABB () const { return *_bounding_volume; }
protected:
/** a vector of pointers to Points */
......@@ -95,7 +95,7 @@ protected:
/** position of pointers to the geometric points */
std::vector<Triangle*> _sfc_triangles;
/** bounding volume is an axis aligned bounding box */
AABB<GeoLib::Point> *_bounding_volume;
AABB *_bounding_volume;
/** a helper structure to accelerate the search */
SurfaceGrid * _surface_grid;
};
......
......@@ -27,7 +27,7 @@ namespace GeoLib {
class Triangle;
class Surface;
class SurfaceGrid : public AABB<GeoLib::Point> {
class SurfaceGrid : public AABB {
public:
explicit SurfaceGrid(GeoLib::Surface const*const sfc);
bool isPointInSurface(MathLib::Point3d const & pnt,
......
......@@ -110,7 +110,7 @@ void GeoMapper::mapData()
double min_val(0), max_val(0);
if (_surface_mesh)
{
GeoLib::AABB<MeshLib::Node> bounding_box(
GeoLib::AABB bounding_box(
_surface_mesh->getNodes().begin(), _surface_mesh->getNodes().end());
min_val = bounding_box.getMinPoint()[2];
max_val = bounding_box.getMaxPoint()[2];
......@@ -217,7 +217,7 @@ void GeoMapper::advancedMapOnMesh(
const std::vector<GeoLib::Point*> *points (this->_geo_objects.getPointVec(this->_geo_name));
const std::vector<GeoLib::Polyline*> *org_lines (this->_geo_objects.getPolylineVec(this->_geo_name));
const GeoLib::AABB<GeoLib::Point> aabb(points->begin(), points->end());
const GeoLib::AABB aabb(points->begin(), points->end());
const double eps = sqrt(std::numeric_limits<float>::epsilon()) *
sqrt( MathLib::sqrDist(aabb.getMinPoint(),aabb.getMaxPoint())) ;
......
......@@ -16,9 +16,8 @@ namespace MeshLib
CoordinateSystem::CoordinateSystem(const Element &ele)
{
const GeoLib::AABB<MeshLib::Node> aabb(ele.getNodes(),
ele.getNodes()+ele.getNNodes());
const CoordinateSystem bboxCoordSys(getCoordinateSystem(aabb));
GeoLib::AABB const aabb(ele.getNodes(), ele.getNodes() + ele.getNNodes());
CoordinateSystem const bboxCoordSys(getCoordinateSystem(aabb));
if (bboxCoordSys.getDimension() >= ele.getDimension()) {
_type = bboxCoordSys.getType();
} else { // e.g. zero volume elements
......@@ -31,4 +30,23 @@ CoordinateSystem::CoordinateSystem(const Element &ele)
}
}
unsigned char CoordinateSystem::getCoordinateSystem(const GeoLib::AABB &bbox) const
{
unsigned char coords = 0;
const MathLib::Vector3 pt_diff(bbox.getMinPoint(), bbox.getMaxPoint());
// The axis aligned bounding box is a from the right half-open interval.
// Therefore, the difference between the particular coordinates of the
// points is modified by the unit in the last place towards zero.
if (std::nexttoward(std::abs(pt_diff[0]), 0.0) > .0)
coords |= CoordinateSystemType::X;
if (std::nexttoward(std::abs(pt_diff[1]), 0.0) > .0)
coords |= CoordinateSystemType::Y;
if (std::nexttoward(std::abs(pt_diff[2]), 0.0) > .0)
coords |= CoordinateSystemType::Z;
return coords;
}
} // end
......@@ -47,8 +47,7 @@ public:
explicit CoordinateSystem(const Element &ele);
/// Decides a coordinate system from a bounding box
template <class T>
explicit CoordinateSystem(const GeoLib::AABB<T> &bbox) : _type(getCoordinateSystem(bbox)) {}
explicit CoordinateSystem(const GeoLib::AABB &bbox) : _type(getCoordinateSystem(bbox)) {}
/// get this coordinate type
unsigned char getType() const { return _type; }
......@@ -73,32 +72,11 @@ public:
bool hasZ() const { return (_type & CoordinateSystemType::type::Z) != 0; }
private:
template <class T>
unsigned char getCoordinateSystem(const GeoLib::AABB<T> &bbox) const;
unsigned char getCoordinateSystem(const GeoLib::AABB &bbox) const;
unsigned char _type;
};
template <class T>
unsigned char CoordinateSystem::getCoordinateSystem(const GeoLib::AABB<T> &bbox) const
{
unsigned char coords = 0;
const MathLib::Vector3 pt_diff(bbox.getMinPoint(), bbox.getMaxPoint());
// The axis aligned bounding box is a from the right half-open interval.
// Therefore, the difference between the particular coordinates of the
// points is modified by the unit in the last place towards zero.
if (std::nexttoward(std::abs(pt_diff[0]), 0.0) > .0)
coords |= CoordinateSystemType::X;
if (std::nexttoward(std::abs(pt_diff[1]), 0.0) > .0)
coords |= CoordinateSystemType::Y;
if (std::nexttoward(std::abs(pt_diff[2]), 0.0) > .0)
coords |= CoordinateSystemType::Z;
return coords;
}
} // MeshLib
#endif // COORDINATESYSTEMTYPE_H_
......@@ -48,8 +48,8 @@ bool Mesh2MeshPropertyInterpolation::setPropertiesForMesh(Mesh *dest_mesh, std::
return false;
}
GeoLib::AABB<MeshLib::Node> src_aabb(_src_mesh->getNodes().begin(), _src_mesh->getNodes().end());
GeoLib::AABB<MeshLib::Node> dest_aabb(dest_mesh->getNodes().begin(), dest_mesh->getNodes().end());
GeoLib::AABB src_aabb(_src_mesh->getNodes().begin(), _src_mesh->getNodes().end());
GeoLib::AABB dest_aabb(dest_mesh->getNodes().begin(), dest_mesh->getNodes().end());
if (!src_aabb.containsAABB(dest_aabb)) {
ERR("MeshLib::Mesh2MeshPropertyInterpolation::setPropertiesForMesh() source mesh to small.");
ERR("src_aabb: %f, %f, %f | %f, %f, %f", src_aabb.getMinPoint()[0], src_aabb.getMinPoint()[1], src_aabb.getMinPoint()[2], src_aabb.getMaxPoint()[0], src_aabb.getMaxPoint()[1], src_aabb.getMaxPoint()[2]);
......@@ -89,7 +89,7 @@ void Mesh2MeshPropertyInterpolation::interpolatePropertiesForMesh(Mesh *dest_mes
for (std::size_t k(0); k<n_dest_elements; k++)
{
// compute axis aligned bounding box around the current element
const GeoLib::AABB<MeshLib::Node> elem_aabb(dest_elements[k]->getNodes(), dest_elements[k]->getNodes()+dest_elements[k]->getNBaseNodes());
const GeoLib::AABB elem_aabb(dest_elements[k]->getNodes(), dest_elements[k]->getNodes()+dest_elements[k]->getNBaseNodes());
// request "interesting" nodes from grid
std::vector<std::vector<MeshLib::Node*> const*> nodes;
......
......@@ -37,10 +37,10 @@ const std::pair<int, int> MeshInformation::getValueBounds(const MeshLib::Mesh &m
return {*(mat_bounds.first), *(mat_bounds.second)};
}
const GeoLib::AABB<MeshLib::Node> MeshInformation::getBoundingBox(const MeshLib::Mesh &mesh)
const GeoLib::AABB MeshInformation::getBoundingBox(const MeshLib::Mesh &mesh)
{
const std::vector<MeshLib::Node*> &nodes (mesh.getNodes());
return GeoLib::AABB<MeshLib::Node>(nodes.begin(), nodes.end());
return GeoLib::AABB(nodes.begin(), nodes.end());
}
const std::array<unsigned, 7> MeshInformation::getNumberOfElementTypes(const MeshLib::Mesh &mesh)
......
......@@ -33,7 +33,7 @@ public:
static const std::pair<int, int> getValueBounds(const MeshLib::Mesh &mesh);
/// Returns the bounding box of the mesh.
static const GeoLib::AABB<MeshLib::Node> getBoundingBox(const MeshLib::Mesh &mesh);
static const GeoLib::AABB getBoundingBox(const MeshLib::Mesh &mesh);
/**
* Returns an array with the number of elements of each type in the given mesh.
......
......@@ -74,7 +74,7 @@ std::size_t ElementSearch::searchByContent(double eps)
}
std::size_t ElementSearch::searchByBoundingBox(
GeoLib::AABB<MathLib::Point3d> const& aabb)
GeoLib::AABB const& aabb)
{
auto matchedIDs = filter(_mesh.getElements(),
[&aabb](MeshLib::Element* e) {
......
......@@ -41,7 +41,7 @@ public:
std::size_t searchByContent(double eps = std::numeric_limits<double>::epsilon());
/// Marks all elements with at least one node outside the bounding box spanned by x1 and x2;
std::size_t searchByBoundingBox(GeoLib::AABB<MathLib::Point3d> const& aabb);
std::size_t searchByBoundingBox(GeoLib::AABB const& aabb);
/// Marks all elements connecting to any of the given nodes
std::size_t searchByNodeIDs(const std::vector<std::size_t> &node_ids);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment