AABB tree: added fourth examples with (segment) edges of a polyhedron

This commit is contained in:
Pierre Alliez 2009-04-26 09:27:42 +00:00
parent 3358154717
commit cde6fb8ad0
8 changed files with 12491 additions and 9 deletions

3
.gitattributes vendored
View File

@ -14,12 +14,14 @@ AABB_tree/doc_tex/AABB_tree_ref/AABB_tree.tex -text
AABB_tree/doc_tex/AABB_tree_ref/intro.tex -text
AABB_tree/doc_tex/AABB_tree_ref/main.tex -text
AABB_tree/dont_submit -text
AABB_tree/examples/AABB_tree/AABB_polyhedron_edge_example.cpp -text
AABB_tree/examples/AABB_tree/AABB_polyhedron_facet_example.cpp -text
AABB_tree/examples/AABB_tree/AABB_segment_3_example.cpp -text
AABB_tree/examples/AABB_tree/AABB_triangle_3_example.cpp -text
AABB_tree/examples/AABB_tree/CMakeLists.txt -text
AABB_tree/examples/AABB_tree/cleanup.bat -text
AABB_tree/include/CGAL/AABB_intersections.h -text
AABB_tree/include/CGAL/AABB_polyhedron_edge_primitive.h -text
AABB_tree/include/CGAL/AABB_polyhedron_triangle_primitive.h -text
AABB_tree/include/CGAL/AABB_traits.h -text
AABB_tree/include/CGAL/Triangle_3_line_3_intersection.h -text
@ -29,6 +31,7 @@ AABB_tree/test/AABB_tree/aabb_projection_test.cpp -text
AABB_tree/test/AABB_tree/cleanup.bat -text
AABB_tree/test/AABB_tree/data/coverrear.off -text
AABB_tree/test/AABB_tree/data/cube.off -text
AABB_tree/test/AABB_tree/data/nested_spheres.off -text
AABB_tree/test/AABB_tree/todo.txt -text
Algebraic_foundations/doc_tex/Algebraic_foundations/Algebraic_foundations.png -text
Algebraic_foundations/doc_tex/Algebraic_foundations/Algebraic_foundations2.png -text

View File

@ -35,6 +35,9 @@ The following example computes the number of intersections between a 3D ray and
The following example computes the number of intersections between a 3D plane and a set of 3D segments. The segments are stored into a list, and the AABB primitive simply wraps a segment and an iterator in the list.
\ccIncludeExampleCode{AABB_tree/AABB_segment_3_example.cpp}
The following example computes the number of intersections between a 3D plane and a set of edges of a triangle polyhedral surfaces. The AABB primitive wraps a halfedge handle and generates on the fly a 3D segment each time its object function is called..
\ccIncludeExampleCode{AABB_tree/AABB_polyhedron_edge_example.cpp}
% Implementation Details
\section{Implementation Details}
\label{AABB_tree_section_intro}

View File

@ -0,0 +1,59 @@
// Copyright (c) 2009 INRIA Sophia-Antipolis (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org); you may redistribute it under
// the terms of the Q Public License version 1.0.
// See the file LICENSE.QPL distributed with CGAL.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $URL: $
// $Id: $
//
//
// Author(s) : Pierre Alliez
//
//******************************************************************************
// File Description :
//
//******************************************************************************
#include <iostream>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/AABB_polyhedron_edge_primitive.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::FT FT;
typedef K::Point_3 Point;
typedef K::Plane_3 Plane;
typedef K::Vector_3 Vector;
typedef CGAL::Polyhedron_3<K> Polyhedron;
typedef CGAL::AABB_polyhedron_edge_primitive<K,Polyhedron> Primitive;
typedef CGAL::AABB_traits<K, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Polyhedron_tree;
int main(void)
{
Point p(1.0, 0.0, 0.0);
Point q(0.0, 1.0, 0.0);
Point r(0.0, 0.0, 1.0);
Point s(0.0, 0.0, 0.0);
Polyhedron polyhedron;
polyhedron.make_tetrahedron( p, q, r, s);
Polyhedron_tree tree(polyhedron.edges_begin(),polyhedron.edges_end());
Point base(0.2, 0.2, 0.2);
Vector normal(0.1, 0.2, 0.3);
Plane plane(base,normal);
std::cout << tree.number_of_intersections(plane)
<< " intersections(s) with plane" << std::endl;
return 0;
}

View File

@ -26,6 +26,7 @@ if ( CGAL_FOUND )
create_single_source_cgal_program("AABB_segment_3_example.cpp")
create_single_source_cgal_program("AABB_triangle_3_example.cpp")
create_single_source_cgal_program("AABB_polyhedron_facet_example.cpp")
create_single_source_cgal_program("AABB_polyhedron_edge_example.cpp")
else()

View File

@ -0,0 +1,82 @@
// Copyright (c) 2009 INRIA Sophia-Antipolis (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org); you may redistribute it under
// the terms of the Q Public License version 1.0.
// See the file LICENSE.QPL distributed with CGAL.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $URL: $
// $Id: $
//
//
// Author(s) : Pierre Alliez, Stephane Tayeb
//
//******************************************************************************
// File Description :
//
//******************************************************************************
#ifndef AABB_POLYHEDRON_EDGE_PRIMITIVE_H_
#define AABB_POLYHEDRON_EDGE_PRIMITIVE_H_
namespace CGAL {
/**
* @class AABB_polyhedron_edge_primitive
*
*
*/
template<typename GeomTraits, typename Polyhedron_>
class AABB_polyhedron_edge_primitive
{
public:
/// AABBTrianglePrimitive types
typedef typename GeomTraits::Segment_3 Object;
typedef typename Polyhedron_::Edge_const_iterator Id;
/// Self
typedef AABB_polyhedron_edge_primitive<GeomTraits, Polyhedron_> Self;
/// Constructors
//AABB_polyhedron_triangle_primitive() { };
AABB_polyhedron_edge_primitive(const Id& handle)
: m_handle(handle) { };
// Default copy constructor and assignment operator are ok
/// Destructor
~AABB_polyhedron_edge_primitive() {};
/// Returns by constructing on the fly the geometric object wrapped by the primitive
Object object() const;
/// Returns the identifier
const Id id() const { return m_handle; }
private:
/// Halfedge handle
Id m_handle;
}; // end class AABB_polyhedron_edge_primitive
template<typename GT, typename P_>
typename AABB_polyhedron_edge_primitive<GT,P_>::Object
AABB_polyhedron_edge_primitive<GT,P_>::object() const
{
typedef typename GT::Point_3 Point;
typedef typename GT::Segment_3 Segment;
const Point& a = m_handle->vertex()->point();
const Point& b = m_handle->opposite()->vertex()->point();
return Object(a,b);
}
} // end namespace CGAL
#endif // AABB_POLYHEDRON_EDGE_PRIMITIVE_H_

View File

@ -44,7 +44,7 @@ void test_speed(Tree& tree,
CGAL::Timer timer;
unsigned int nb = 0;
timer.start();
Point source((FT)0.5, (FT)0.5, (FT)0.5);
Point source((FT)0.0, (FT)0.0, (FT)0.0);
Vector vec((FT)0.1, (FT)0.2, (FT)0.3);
Ray ray(source, vec);
while(timer.time() < 1.0)
@ -108,5 +108,6 @@ int main(void)
std::cout << "AABB intersection tests" << std::endl;
test_kernels("../data/cube.off");
test_kernels("../data/coverrear.off");
test_kernels("../data/nested_spheres.off");
return 0;
}

View File

@ -1,13 +1,14 @@
OFF
8 12 0
0.0 0.0 0.0
1.0 0.0 0.0
1.0 1.0 0.0
0.0 1.0 0.0
0.0 0.0 1.0
1.0 0.0 1.0
1.0 1.0 1.0
0.0 1.0 1.0
-0.5 -0.5 -0.5
0.5 -0.5 -0.5
0.5 0.5 -0.5
-0.5 0.5 -0.5
-0.5 -0.5 0.5
0.5 -0.5 0.5
0.5 0.5 0.5
-0.5 0.5 0.5
3 0 1 3
3 3 1 2
3 0 4 1
@ -20,3 +21,4 @@ OFF
3 6 5 4
3 1 5 6
3 2 1 6

File diff suppressed because it is too large Load Diff