mirror of https://github.com/CGAL/cgal
AABB tree: one more example with segment
This commit is contained in:
parent
2b4238afea
commit
aea8cce7ad
|
|
@ -15,8 +15,10 @@ 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_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_triangle_primitive.h -text
|
||||
AABB_tree/include/CGAL/AABB_traits.h -text
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
shark.ppt
|
||||
cleanup.bat
|
||||
|
|
@ -36,9 +36,9 @@ typedef K::Ray_3 Ray;
|
|||
typedef K::Point_3 Point;
|
||||
typedef K::Vector_3 Vector;
|
||||
typedef CGAL::Polyhedron_3<K> Polyhedron;
|
||||
typedef CGAL::AABB_polyhedron_triangle_primitive<K,Polyhedron> Polyhedron_triangle_primitive;
|
||||
typedef CGAL::AABB_traits<K, Polyhedron_triangle_primitive> AABB_Polyhedron_traits;
|
||||
typedef CGAL::AABB_tree<AABB_Polyhedron_traits> Polyhedron_tree;
|
||||
typedef CGAL::AABB_polyhedron_triangle_primitive<K,Polyhedron> Primitive;
|
||||
typedef CGAL::AABB_traits<K, Primitive> Traits;
|
||||
typedef CGAL::AABB_tree<Traits> Polyhedron_tree;
|
||||
|
||||
int main(void)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,85 @@
|
|||
// 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 <list>
|
||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/AABB_traits.h>
|
||||
#include <CGAL/AABB_tree.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::Segment_3 Segment;
|
||||
|
||||
template <class Iterator>
|
||||
class Segment_primitive
|
||||
{
|
||||
// type
|
||||
public:
|
||||
typedef K::Segment_3 Object; // object type
|
||||
typedef Iterator Id; // Id type
|
||||
|
||||
// member data
|
||||
private:
|
||||
Id m_it; // iterator
|
||||
Object m_object; // 3D segment
|
||||
|
||||
public:
|
||||
Segment_primitive(Id it)
|
||||
: m_it(it)
|
||||
{
|
||||
m_object = *it; // copy segmetn
|
||||
}
|
||||
public:
|
||||
const Object& object() const { return m_object; }
|
||||
Object& object() { return m_object; }
|
||||
Id id() { return m_it; }
|
||||
};
|
||||
|
||||
typedef std::list<typename Segment>::iterator Iterator;
|
||||
typedef Segment_primitive<Iterator> Primitive;
|
||||
typedef CGAL::AABB_traits<typename K, typename Primitive> Traits;
|
||||
typedef CGAL::AABB_tree<typename Traits> Polyhedron_tree;
|
||||
|
||||
int main(void)
|
||||
{
|
||||
Point a(1.0, 0.0, 0.0);
|
||||
Point b(0.0, 1.0, 0.0);
|
||||
Point c(0.0, 0.0, 1.0);
|
||||
Point d(0.0, 0.0, 0.0);
|
||||
|
||||
std::list<Segment> segments;
|
||||
segments.push_back(Segment(a,b));
|
||||
segments.push_back(Segment(a,c));
|
||||
segments.push_back(Segment(c,d));
|
||||
|
||||
Polyhedron_tree tree(segments.begin(),segments.end());
|
||||
Plane plane(a,b,d);
|
||||
std::cout << tree.number_of_intersections(plane)
|
||||
<< " intersections(s) with plane" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
# Created by the script cgal_create_cmake_script
|
||||
# This is the CMake script for compiling a CGAL application.
|
||||
|
||||
project(AABB_example)
|
||||
project(AABB_examples)
|
||||
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.4.5)
|
||||
|
||||
|
|
@ -23,9 +23,11 @@ if ( CGAL_FOUND )
|
|||
|
||||
include( CGAL_CreateSingleSourceCGALProgram )
|
||||
|
||||
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")
|
||||
|
||||
|
||||
else()
|
||||
|
||||
message(STATUS "This program requires the CGAL library, and will not be compiled.")
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
del *.vcproj* *.user *.cmake ZERO* *.ncb *.sln *.suo CMakeCache.txt /Q
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
// PA: this file will move later to the kernel folder
|
||||
|
||||
#include <CGAL/intersections.h>
|
||||
#include <CGAL/Ray_3_Bbox_3_do_intersect.h>
|
||||
#include <CGAL/Bbox_3_Bbox_3_do_intersect.h>
|
||||
#include <CGAL/Segment_3_Bbox_3_do_intersect.h>
|
||||
|
|
|
|||
|
|
@ -271,7 +271,7 @@ template<typename Query>
|
|||
bool
|
||||
AABB_traits<GT,P>::intersection(const Query& q,
|
||||
const P& pr,
|
||||
Intersection& intersection) const
|
||||
Intersection& result) const
|
||||
{
|
||||
// TODO: implement a real intersection construction method
|
||||
// do_intersect is needed here because we construct intersection between
|
||||
|
|
@ -286,7 +286,7 @@ AABB_traits<GT,P>::intersection(const Query& q,
|
|||
Object o = pr.object();
|
||||
CGAL::Object intersection_obj = CGAL::intersection(o, q);
|
||||
|
||||
return CGAL::assign(intersection, intersection_obj);
|
||||
return CGAL::assign(result, intersection_obj);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
# This is the CMake script for compiling a CGAL application.
|
||||
|
||||
|
||||
project(AABB_example)
|
||||
project(AABB_tests)
|
||||
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.4.5)
|
||||
|
||||
|
|
@ -16,7 +16,6 @@ endif()
|
|||
|
||||
# Find CGAL
|
||||
find_package(CGAL COMPONENTS)
|
||||
#include( ${CGAL_USE_FILE} )
|
||||
|
||||
if ( CGAL_FOUND )
|
||||
|
||||
|
|
@ -25,6 +24,7 @@ if ( CGAL_FOUND )
|
|||
include( CGAL_CreateSingleSourceCGALProgram )
|
||||
|
||||
create_single_source_cgal_program("aabb_intersection_test.cpp")
|
||||
create_single_source_cgal_program("aabb_projection_test.cpp")
|
||||
|
||||
else()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue