Add an example using OpenMesh

Involves several changes to the Polyhedron_shortest_path class which were
not conformant to the Face Graph concept.
This commit is contained in:
Stephen Kiazyk 2014-08-04 22:59:51 -04:00
parent 0031d86d99
commit a6ea82cbf7
15 changed files with 1373 additions and 500 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,9 @@
#!/bin/sh
if which python2 2>/dev/null >/dev/null; then
exec python2 ${CMAKE_BINARY_DIR}/pkglist_filter.py "$1"
exec python2 /cygdrive/c/Users/stephen/Documents/Programming/CGALDev/Documentation/pkglist_filter.py "$1"
elif which python2.7 2>/dev/null >/dev/null; then
exec python2.7 ${CMAKE_BINARY_DIR}/pkglist_filter.py "$1"
exec python2.7 /cygdrive/c/Users/stephen/Documents/Programming/CGALDev/Documentation/pkglist_filter.py "$1"
elif which python2.6 2>/dev/null >/dev/null; then
exec python2.6 ${CMAKE_BINARY_DIR}/pkglist_filter.py "$1"
exec python2.6 /cygdrive/c/Users/stephen/Documents/Programming/CGALDev/Documentation/pkglist_filter.py "$1"
fi

View File

@ -17,9 +17,9 @@ def main(argv):
if(index > 0):
top_level = pkg[:index]
lower_level = pkg[index+1:]
filename="${CMAKE_SOURCE_DIR}/" + top_level + "/doc/" + lower_level + "/PackageDescription.txt"
filename="/cygdrive/c/Users/stephen/Documents/Programming/CGALDev/Documentation/" + top_level + "/doc/" + lower_level + "/PackageDescription.txt"
else:
filename="${CMAKE_SOURCE_DIR}/" + pkg + "/doc/" + pkg + "/PackageDescription.txt"
filename="/cygdrive/c/Users/stephen/Documents/Programming/CGALDev/Documentation/" + pkg + "/doc/" + pkg + "/PackageDescription.txt"
pkgdesc = codecs.open(filename, 'r', encoding='utf-8')
do_print=False
for l in pkgdesc:

View File

@ -0,0 +1,82 @@
# Created by the script cgal_create_cmake_script_with_options
# This is the CMake script for compiling a set of CGAL applications.
project( Polyhedron_shortest_path )
SET(CMAKE_CXX_FLAGS "-Wall")
cmake_minimum_required(VERSION 2.6.2)
if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" VERSION_GREATER 2.6)
if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER 2.8.3)
cmake_policy(VERSION 2.8.4)
else()
cmake_policy(VERSION 2.6)
endif()
endif()
set( CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true )
if ( COMMAND cmake_policy )
cmake_policy( SET CMP0003 NEW )
endif()
# CGAL and its components
find_package( CGAL QUIET COMPONENTS )
if ( NOT CGAL_FOUND )
message(STATUS "This project requires the CGAL library, and will not be compiled.")
return()
endif()
# include helper file
include( ${CGAL_USE_FILE} )
find_package( OpenMesh QUIET )
if ( OpenMesh_FOUND )
include( UseOpenMesh )
else()
message(STATUS "Examples that use OpenMesh will not be compiled.")
endif()
# Boost and its components
find_package( Boost REQUIRED COMPONENTS program_options )
if ( NOT Boost_FOUND )
message(STATUS "This project requires the Boost library, and will not be compiled.")
return()
endif()
# include for local directory
include_directories( BEFORE include )
# include for local package
include_directories( BEFORE ../../include )
# Boost linking
add_definitions( "-DCGAL_USE_BOOST_PROGRAM_OPTIONS" )
list(APPEND CGAL_3RD_PARTY_LIBRARIES ${Boost_PROGRAM_OPTIONS_LIBRARY} )
# Creating entries for all .cpp/.C files with "main" routine
# ##########################################################
include( CGAL_CreateSingleSourceCGALProgram )
create_single_source_cgal_program( "compute_isolines.cpp" )
create_single_source_cgal_program( "shortest_paths_elephant.cpp" )
create_single_source_cgal_program( "shortest_paths_elephant_multiple_sources.cpp" )
if(OpenMesh_FOUND)
create_single_source_cgal_program( "shortest_paths_elephant_OpenMesh.cpp" )
target_link_libraries( shortest_paths_elephant_OpenMesh ${OPENMESH_LIBRARIES} )
endif()

View File

@ -0,0 +1,575 @@
// (LicenseStuffHere)
//
// $URL$
// $Id$
//
//
// Author(s) : Stephen Kiazyk
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/IO/Polyhedron_iostream.h>
#include <CGAL/Polyhedron_shortest_path/Polyhedron_shortest_path_traits.h>
#include <CGAL/Polyhedron_shortest_path/Polyhedron_shortest_path.h>
#include <CGAL/Polyhedron_shortest_path/Internal/misc_functions.h>
#include <CGAL/boost/graph/graph_traits_Polyhedron_3.h>
#include <CGAL/boost/graph/iterator.h>
#include <boost/program_options.hpp>
#include <iostream>
#include <fstream>
#include <sstream>
#include <cstdlib>
#define UNUSED(X) (void)sizeof(X)
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef CGAL::Polyhedron_3<Kernel> Polyhedron_3;
typedef CGAL::Polyhedron_shortest_path_default_traits<Kernel, Polyhedron_3> Traits;
typedef Traits::Point_3 Point_3;
typedef Traits::Vector_3 Vector_3;
typedef Traits::FT FT;
typedef Traits::Barycentric_coordinate Barycentric_coordinate;
typedef CGAL::Polyhedron_shortest_path<Traits> Polyhedron_shortest_path;
typedef boost::graph_traits<Polyhedron_3> GraphTraits;
typedef GraphTraits::vertex_descriptor vertex_descriptor;
typedef GraphTraits::vertex_iterator vertex_iterator;
typedef GraphTraits::halfedge_descriptor halfedge_descriptor;
typedef GraphTraits::halfedge_iterator halfedge_iterator;
typedef GraphTraits::face_descriptor face_descriptor;
typedef GraphTraits::face_iterator face_iterator;
typedef boost::property_map<typename Traits::FaceGraph, CGAL::vertex_external_index_t>::type VertexExternalIndexMap;
typedef boost::property_map<typename Traits::FaceGraph, CGAL::halfedge_external_index_t>::type HalfedgeExternalIndexMap;
typedef boost::property_map<typename Traits::FaceGraph, CGAL::face_external_index_t>::type FaceExternalIndexMap;
typedef boost::property_map<typename Traits::FaceGraph, CGAL::vertex_point_t>::type VertexPointMap;
enum Sequence_item_type
{
SEQUENCE_ITEM_VERTEX,
SEQUENCE_ITEM_EDGE,
SEQUENCE_ITEM_FACE,
};
template <class Traits>
struct Sequence_item
{
typedef typename Traits::Barycentric_coordinate Barycentric_coordinate;
typedef typename Traits::FT FT;
Sequence_item_type type;
size_t index;
Barycentric_coordinate faceAlpha;
FT edgeAlpha;
vertex_descriptor vertex;
halfedge_descriptor halfedge;
face_descriptor face;
};
Point_3 get_item_location(const Sequence_item<Traits>& item, Polyhedron_shortest_path& helper)
{
if (item.type == SEQUENCE_ITEM_VERTEX)
{
return helper.point(item.vertex);
}
else if (item.type == SEQUENCE_ITEM_EDGE)
{
return helper.point(item.halfedge, item.edgeAlpha);
}
else
{
return helper.point(item.face, item.faceAlpha);
}
}
template <class Traits,
class VIM = typename boost::property_map<typename Traits::FaceGraph, CGAL::vertex_external_index_t>::type,
class HIM = typename boost::property_map<typename Traits::FaceGraph, CGAL::halfedge_external_index_t>::type,
class FIM = typename boost::property_map<typename Traits::FaceGraph, CGAL::face_external_index_t>::type,
class VPM = typename boost::property_map<typename Traits::FaceGraph, CGAL::vertex_point_t>::type>
struct Edge_sequence_collector
{
typedef typename Traits::FaceGraph FaceGraph;
typedef typename Traits::FT FT;
typedef typename Traits::Barycentric_coordinate Barycentric_coordinate;
typedef VIM VertexIndexMap;
typedef HIM HalfedgeIndexMap;
typedef FIM FaceIndexMap;
typedef typename boost::graph_traits<FaceGraph> GraphTraits;
typedef typename GraphTraits::vertex_descriptor vertex_descriptor;
typedef typename GraphTraits::halfedge_descriptor halfedge_descriptor;
typedef typename GraphTraits::face_descriptor face_descriptor;
VertexIndexMap m_vertexIndexMap;
HalfedgeIndexMap m_halfedgeIndexMap;
FaceIndexMap m_faceIndexMap;
std::vector<Sequence_item<Traits> > m_sequence;
Edge_sequence_collector(FaceGraph& p)
: m_vertexIndexMap(CGAL::get(boost::vertex_external_index, p))
, m_halfedgeIndexMap(CGAL::get(CGAL::halfedge_external_index, p))
, m_faceIndexMap(CGAL::get(CGAL::face_external_index, p))
{
}
Edge_sequence_collector(VertexIndexMap& vertexIndexMap, HalfedgeIndexMap& halfedgeIndexMap, FaceIndexMap& faceIndexMap)
: m_vertexIndexMap(vertexIndexMap)
, m_halfedgeIndexMap(halfedgeIndexMap)
, m_faceIndexMap(faceIndexMap)
{
}
void edge(halfedge_descriptor he, FT alpha)
{
Sequence_item<Traits> item;
item.type = SEQUENCE_ITEM_EDGE;
item.index = m_halfedgeIndexMap[he];
item.edgeAlpha = alpha;
item.halfedge = he;
m_sequence.push_back(item);
}
void vertex(vertex_descriptor v)
{
Sequence_item<Traits> item;
item.type = SEQUENCE_ITEM_VERTEX;
item.index = m_vertexIndexMap[v];
item.vertex = v;
m_sequence.push_back(item);
}
void face(face_descriptor f, Barycentric_coordinate alpha)
{
Sequence_item<Traits> item;
item.type = SEQUENCE_ITEM_FACE;
item.index = m_faceIndexMap[f];
item.faceAlpha = alpha;
item.face = f;
m_sequence.push_back(item);
}
};
class Edge_sequence_comparator
{
private:
std::vector<halfedge_descriptor> m_edges;
Polyhedron_3& m_polyhedron;
const Sequence_item<Traits>& second_last(Edge_sequence_collector<Traits>* list) const
{
return list->m_sequence[list->m_sequence.size() - 2];
}
size_t edge_index(halfedge_descriptor e) const
{
for (size_t i = 0; i < m_edges.size(); ++i)
{
if (m_edges[i] == CGAL::opposite(e, m_polyhedron))
{
return i;
}
}
assert(false && "Error, edge was not found");
}
size_t vertex_index(vertex_descriptor v) const
{
for (size_t i = 0; i < m_edges.size(); ++i)
{
if (CGAL::source(m_edges[i], m_polyhedron) == v)
{
return i;
}
}
assert(false && "Error, vertex was not found");
}
size_t get_index(const Sequence_item<Traits>& item) const
{
if (item.type == SEQUENCE_ITEM_VERTEX)
{
return vertex_index(item.vertex);
}
else if (item.type == SEQUENCE_ITEM_EDGE)
{
return edge_index(item.halfedge);
}
else
{
assert(false && "Error, face item found");
}
}
public:
Edge_sequence_comparator(Polyhedron_3& polyhedron, face_descriptor locationFace)
: m_polyhedron(polyhedron)
{
m_edges.push_back(CGAL::halfedge(locationFace, m_polyhedron));
m_edges.push_back(CGAL::next(m_edges[0], m_polyhedron));
m_edges.push_back(CGAL::next(m_edges[1], m_polyhedron));
}
Edge_sequence_comparator(Polyhedron_3& polyhedron, vertex_descriptor locationVertex)
: m_polyhedron(polyhedron)
{
halfedge_descriptor startEdge = CGAL::halfedge(locationVertex, m_polyhedron);
halfedge_descriptor currentEdge = startEdge;
do
{
currentEdge = CGAL::opposite(currentEdge, m_polyhedron);
m_edges.push_back(CGAL::next(currentEdge, m_polyhedron));
currentEdge = CGAL::next(m_edges.back(), m_polyhedron);
}
while(currentEdge != startEdge);
}
Edge_sequence_comparator(Polyhedron_3& polyhedron, halfedge_descriptor locationEdge)
: m_polyhedron(polyhedron)
{
m_edges.push_back(CGAL::next(locationEdge, m_polyhedron));
m_edges.push_back(CGAL::next(m_edges[0], m_polyhedron));
m_edges.push_back(CGAL::next(CGAL::opposite(locationEdge, m_polyhedron), m_polyhedron));
m_edges.push_back(CGAL::next(m_edges[2], m_polyhedron));
}
bool operator() (Edge_sequence_collector<Traits>* lhs, Edge_sequence_collector<Traits>* rhs) const
{
const Sequence_item<Traits>& left = second_last(lhs);
const Sequence_item<Traits>& right = second_last(rhs);
size_t leftIndex = get_index(left);
size_t rightIndex = get_index(right);
if (leftIndex < rightIndex)
{
return true;
}
else if (rightIndex < leftIndex)
{
return false;
}
else if (left.type == SEQUENCE_ITEM_VERTEX)
{
return true;
}
else if (right.type == SEQUENCE_ITEM_VERTEX)
{
return false;
}
else
{
return left.edgeAlpha < right.edgeAlpha;
}
}
};
void run_isolines_no_id(Traits& traits, Polyhedron_3& polyhedron, Polyhedron_shortest_path& shortestPaths, Polyhedron_shortest_path::Face_location faceLocation, const Edge_sequence_comparator& edgeComparator, FT delta, const std::string& outPathsFilename, const std::string& outIsolinesFilename)
{
Traits::Compute_squared_distance_3 compute_squared_distance_3(traits.compute_squared_distance_3_object());
shortestPaths.construct_sequence_tree(faceLocation.first, faceLocation.second);
vertex_iterator verticesCurrent, verticesEnd;
std::ofstream outPaths(outPathsFilename.c_str());
VertexExternalIndexMap vertexIndexMap(CGAL::get(boost::vertex_external_index, polyhedron));
HalfedgeExternalIndexMap halfedgeIndexMap(CGAL::get(CGAL::halfedge_external_index, polyhedron));
FaceExternalIndexMap faceIndexMap(CGAL::get(CGAL::face_external_index, polyhedron));
std::vector<Edge_sequence_collector<Traits>*> edgeSequences;
FT maxDistance(0.0);
for (boost::tie(verticesCurrent, verticesEnd) = boost::vertices(polyhedron); verticesCurrent != verticesEnd; ++verticesCurrent)
{
Edge_sequence_collector<Traits>* collector = new Edge_sequence_collector<Traits>(vertexIndexMap, halfedgeIndexMap, faceIndexMap);
shortestPaths.shortest_path_sequence_to_source_points(*verticesCurrent, *collector);
maxDistance = std::max(maxDistance, shortestPaths.shortest_distance_to_source_points(*verticesCurrent).first);
if (collector->m_sequence.size() >= 2)
{
edgeSequences.push_back(collector);
}
outPaths << collector->m_sequence.size() + 1;
outPaths << " " << shortestPaths.point(*verticesCurrent);
for (size_t i = 0; i < collector->m_sequence.size(); ++i)
{
outPaths << " " << get_item_location(collector->m_sequence[i], shortestPaths);
}
outPaths << std::endl;
}
outPaths.close();
std::sort(edgeSequences.begin(), edgeSequences.end(), edgeComparator);
size_t numPaths = edgeSequences.size();
std::vector<Point_3> currentLocations(numPaths);
std::vector<size_t> currentItems(numPaths);
std::vector<bool> currentlyCompleted(numPaths);
size_t numPathsCompleted = 0;
Point_3 startPoint = shortestPaths.point(faceLocation.first, faceLocation.second);
for (size_t i = 0; i < edgeSequences.size(); ++i)
{
currentLocations[i] = startPoint;
currentItems[i] = edgeSequences[i]->m_sequence.size() - 2;
currentlyCompleted[i] = false;
}
FT currentSampleDistance = FT(0.0);
std::ofstream outIsoLines(outIsolinesFilename.c_str());
while (numPathsCompleted < numPaths - 1)
{
std::vector<Point_3> points;
currentSampleDistance += delta;
// advance each path to the next sample point
for (size_t i = 0; i < numPaths; ++i)
{
FT remainingDistance = delta;
while (!currentlyCompleted[i] && remainingDistance > FT(0.0))
{
Point_3 nextLocation = get_item_location(edgeSequences[i]->m_sequence[currentItems[i]], shortestPaths);
FT distance = CGAL::sqrt(compute_squared_distance_3(nextLocation, currentLocations[i]));
//std::cout << distance << std::endl;
if (distance < remainingDistance)
{
remainingDistance -= distance;
if (currentItems[i] == 0)
{
currentlyCompleted[i] = true;
++numPathsCompleted;
}
else
{
--currentItems[i];
currentLocations[i] = nextLocation;
}
}
else
{
Vector_3 direction = nextLocation - currentLocations[i];
Vector_3 scaled = direction / distance;
currentLocations[i] = currentLocations[i] + scaled * remainingDistance;
remainingDistance = FT(0.0);
}
}
}
//std::cout << "Current Distance: " << currentSampleDistance << std::endl;
//std::cout << "Num Paths Cleared: " << numPathsCompleted << std::endl;
if (numPathsCompleted >= numPaths - 1)
{
break;
}
size_t firstPath = 0;
// connect pairs of adjacent paths
while (currentlyCompleted[firstPath])
{
++firstPath;
}
size_t currentPath = firstPath;
while (currentPath < numPaths)
{
size_t nextPath = currentPath + 1;
while (currentlyCompleted[nextPath % numPaths])
{
++nextPath;
}
points.push_back(currentLocations[currentPath]);
currentPath = nextPath;
}
outIsoLines << points.size();
for (size_t i = 0; i < points.size(); ++i)
{
outIsoLines << " " << points[i];
}
outIsoLines << " " << points[0] << std::endl;
}
outIsoLines.close();
for (size_t i = 0; i < edgeSequences.size(); ++i)
{
delete edgeSequences[i];
}
}
int main(int argc, char** argv)
{
namespace po = boost::program_options ;
po::options_description options;
options.add_options()
("help,h", "Display help message")
("polyhedron,p", po::value<std::string>(), "Polyhedron input file")
("vertex,v", po::value<size_t>(), "Randomization seed value")
("face,f", po::value<size_t>(), "Number of trials to run")
("location,l", po::value<std::string>(), "Number of source points per trial")
("delta,d", po::value<double>()->default_value(0.1), "Number of queries to run per trial")
("output-paths,o", po::value<std::string>()->default_value("shortestpaths.cgal"), "Filename to write shortest paths output")
("output-isolines,i", po::value<std::string>()->default_value("isolines.cgal"), "Filename to write isolines")
;
po::variables_map vm;
po::store(po::parse_command_line(argc, argv, options), vm);
po::notify(vm);
if (vm.count("help"))
{
std::cout << options << std::endl;
}
else if (vm.count("polyhedron"))
{
bool useVertex = false;
bool useFace = false;
if (vm.count("vertex"))
{
useVertex = true;
}
else if (vm.count("face"))
{
if (vm.count("location"))
{
useFace = true;
}
else
{
std::cerr << "Must specify face location with face." << std::endl;
return EXIT_FAILURE;
}
}
else
{
std::cerr << "Must specify either a face or a vertex." << std::endl;
return EXIT_FAILURE;
}
if (useVertex || useFace)
{
FT delta(vm["delta"].as<double>());
if (delta < FT(0.0))
{
std::cerr << "Must specify non-negative isoline delta." << std::endl;
return EXIT_FAILURE;
}
Polyhedron_shortest_path::Face_location faceLocation;
vertex_descriptor targetVertex;
Polyhedron_3 polyhedron;
std::ifstream inFile(vm["polyhedron"].as<std::string>().c_str());
inFile >> polyhedron;
inFile.close();
Traits traits;
Polyhedron_shortest_path shortestPaths(polyhedron, traits);
if (useVertex)
{
size_t vertexIndex = vm["vertex"].as<size_t>();
if (vertexIndex >= boost::num_vertices(polyhedron))
{
std::cerr << "Vertex index out of range (#Vertices = " << boost::num_vertices(polyhedron) << ")." << std::endl;
return EXIT_FAILURE;
}
vertex_iterator currentVertex, endVertex;
boost::tie(currentVertex, endVertex) = boost::vertices(polyhedron);
while (vertexIndex > 0)
{
++currentVertex;
--vertexIndex;
}
faceLocation = shortestPaths.face_location(*currentVertex);
targetVertex = *currentVertex;
}
else
{
size_t faceIndex = vm["face"].as<size_t>();
if (faceIndex >= CGAL::num_faces(polyhedron))
{
std::cerr << "Face index out of range (#Face = " << CGAL::num_faces(polyhedron) << ")." << std::endl;
return EXIT_FAILURE;
}
face_iterator currentFace, endFace;
boost::tie(currentFace, endFace) = CGAL::faces(polyhedron);
while (faceIndex > 0)
{
++currentFace;
--faceIndex;
}
std::istringstream istr(vm["location"].as<std::string>().c_str());
FT coords[3];
istr >> coords[0] >> coords[1] >> coords[2];
Barycentric_coordinate location(coords[0], coords[1], coords[2]);
FT coordinateSum = location[0] + location[1] + location[2];
if (CGAL::abs(coordinateSum - FT(1.0)) > FT(0.00001))
{
std::cerr << "Invalid face location (must be a valid, normalized, barycentric coordinate)." << std::endl;
return EXIT_FAILURE;
}
faceLocation = Polyhedron_shortest_path::Face_location(*currentFace, location);
}
run_isolines_no_id(traits, polyhedron, shortestPaths, faceLocation, useVertex ? Edge_sequence_comparator(polyhedron, targetVertex) : Edge_sequence_comparator(polyhedron, faceLocation.first), delta, vm["output-paths"].as<std::string>(), vm["output-isolines"].as<std::string>());
}
}
else
{
std::cout << "Please specify a polyhedron to use. Use option --help for more details." << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}

View File

@ -1,6 +1,5 @@
OFF
2775 5558 0
0.262933 0.102269 0.138247
0.0843142 0.0418575 -0.0419302
0.0676609 -0.0308717 0.133371

View File

@ -50,7 +50,7 @@ int main(int argc, char** argv)
const size_t targetFaceIndex = 432;
face_iterator facesCurrent, facesEnd;
boost::tie(facesCurrent, facesEnd) = CGAL::faces(polyhedron);
boost::tie(facesCurrent, facesEnd) = faces(polyhedron);
size_t currentFaceIndex = 0;
@ -67,6 +67,8 @@ int main(int argc, char** argv)
Traits traits;
Polyhedron_shortest_path shortestPaths(polyhedron, traits);
shortestPaths.m_debugOutput = true;
shortestPaths.construct_sequence_tree(targetFace, faceLocation);
vertex_iterator verticesCurrent, verticesEnd;

View File

@ -0,0 +1,150 @@
// (LicenseStuffHere)
//
// $URL$
// $Id$
//
//
// Author(s) : Stephen Kiazyk
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <OpenMesh/Core/IO/MeshIO.hh>
#include <OpenMesh/Core/Mesh/PolyMesh_ArrayKernelT.hh>
#include <CGAL/boost/graph/graph_traits_PolyMesh_ArrayKernelT.h>
#include <CGAL/boost/graph/properties_PolyMesh_ArrayKernelT.h>
#include <CGAL/Polyhedron_shortest_path/Polyhedron_shortest_path_traits.h>
#include <CGAL/Polyhedron_shortest_path/Polyhedron_shortest_path.h>
#include <CGAL/boost/graph/iterator.h>
#include <CGAL/property_map.h>
#include <fstream>
#include <iterator>
#define UNUSED(X) (void)sizeof(X)
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef OpenMesh::PolyMesh_ArrayKernelT< /* MyTraits*/> Mesh;
typedef boost::graph_traits<Mesh> GraphTraits;
typedef GraphTraits::vertex_descriptor vertex_descriptor;
typedef GraphTraits::vertex_iterator vertex_iterator;
typedef GraphTraits::halfedge_descriptor halfedge_descriptor;
typedef GraphTraits::halfedge_iterator halfedge_iterator;
typedef GraphTraits::face_descriptor face_descriptor;
typedef GraphTraits::face_iterator face_iterator;
typedef std::map<vertex_descriptor, std::size_t> vertex_int_map;
typedef std::map<halfedge_descriptor, std::size_t> halfedge_int_map;
typedef std::map<face_descriptor, std::size_t> face_int_map;
typedef boost::associative_property_map<vertex_int_map> VertexIndexMap;
typedef boost::associative_property_map<halfedge_int_map> HalfedgeIndexMap;
typedef boost::associative_property_map<face_int_map> FaceIndexMap;
typedef CGAL::Polyhedron_shortest_path_default_traits<Kernel, Mesh> Traits;
typedef CGAL::Polyhedron_shortest_path<Traits,
VertexIndexMap,
HalfedgeIndexMap,
FaceIndexMap,
boost::property_map<Mesh, CGAL::vertex_point_t>::type> Polyhedron_shortest_path;
int main(int argc, char** argv)
{
UNUSED(argc);
UNUSED(argv);
Mesh polyhedron;
OpenMesh::IO::read_mesh(polyhedron, "data/elephant.off");
const size_t targetFaceIndex = 432;
face_iterator facesCurrent, facesEnd;
boost::tie(facesCurrent, facesEnd) = faces(polyhedron);
size_t currentFaceIndex = 0;
face_int_map underlyingFaceMap;
FaceIndexMap faceIndexMap(underlyingFaceMap);
face_descriptor targetFace;
while (currentFaceIndex < num_faces(polyhedron))
{
if (currentFaceIndex == targetFaceIndex)
{
targetFace = *facesCurrent;
}
faceIndexMap[*facesCurrent] = currentFaceIndex;
++facesCurrent;
++currentFaceIndex;
}
vertex_int_map underlyingVertexMap;
VertexIndexMap vertexIndexMap(underlyingVertexMap);
size_t currentVertexIndex = 0;
vertex_iterator verticesCurrent, verticesEnd;
boost::tie(verticesCurrent, verticesEnd) = vertices(polyhedron);
while (currentVertexIndex < num_vertices(polyhedron))
{
vertexIndexMap[*verticesCurrent] = currentVertexIndex;
++currentVertexIndex;
++verticesCurrent;
}
halfedge_int_map underlyingHalfedgeMap;
HalfedgeIndexMap halfedgeIndexMap(underlyingHalfedgeMap);
size_t currentHalfedgeIndex = 0;
halfedge_iterator halfedgesCurrent, halfedgesEnd;
boost::tie(halfedgesCurrent, halfedgesEnd) = halfedges(polyhedron);
while (currentHalfedgeIndex < num_halfedges(polyhedron))
{
halfedgeIndexMap[*halfedgesCurrent] = currentHalfedgeIndex;
++currentHalfedgeIndex;
++halfedgesCurrent;
}
Traits::Barycentric_coordinate faceLocation(Traits::FT(0.25), Traits::FT(0.5), Traits::FT(0.25));
Traits traits;
Polyhedron_shortest_path shortestPaths(polyhedron, vertexIndexMap, halfedgeIndexMap, faceIndexMap, boost::get(boost::vertex_point, polyhedron), traits);
shortestPaths.m_debugOutput = true;
shortestPaths.construct_sequence_tree(targetFace, faceLocation);
std::ofstream outPaths("polylines.cgal");
for (boost::tie(verticesCurrent, verticesEnd) = boost::vertices(polyhedron); verticesCurrent != verticesEnd; ++verticesCurrent)
{
std::vector<Traits::Point_3> points;
shortestPaths.shortest_path_points_to_source_points(*verticesCurrent, std::back_inserter(points));
outPaths << points.size();
for (size_t i = 0; i < points.size(); ++i)
{
outPaths << " " << points[i];
}
outPaths << std::endl;
}
outPaths.close();
return 0;
}

View File

@ -25,8 +25,8 @@
#include <CGAL/Polyhedron_shortest_path/internal/misc_functions.h>
#include <CGAL/Polyhedron_shortest_path/internal/Barycentric.h>
#include <CGAL/boost/graph/graph_traits_Polyhedron_3.h>
#include <CGAL/boost/graph/iterator.h>
#include <boost/variant/get.hpp>
namespace CGAL {
@ -52,8 +52,8 @@ Refer to those respective papers for the details of the implementation.
template<class Traits,
class VIM = typename boost::property_map<typename Traits::FaceGraph, CGAL::vertex_external_index_t>::type,
class HIM = typename boost::property_map<typename Traits::FaceGraph, CGAL::halfedge_external_index_t>::type,
class FIM = typename boost::property_map<typename Traits::FaceGraph, CGAL::face_external_index_t>::type,
class HIM = typename boost::property_map<typename Traits::FaceGraph, halfedge_external_index_t>::type,
class FIM = typename boost::property_map<typename Traits::FaceGraph, face_external_index_t>::type,
class VPM = typename boost::property_map<typename Traits::FaceGraph, CGAL::vertex_point_t>::type>
class Polyhedron_shortest_path
{
@ -94,12 +94,12 @@ public:
typedef typename Traits::Barycentric_coordinate Barycentric_coordinate;
/// \brief An ordered pair specifying a location on the surface of the faceGraph.
/// \detail Assuming you are given the pair (`face`, `location`), the weights of
/// \details Assuming you are given the pair (`face`, `location`), the weights of
/// `location` are applied to the vertices of `face` in the following way
/// the following way:
/// 0 - CGAL::source(CGAL::halfedge(`face`))
/// 1 - CGAL::target(CGAL::halfedge(`face`))
/// 2 - CGAL::target(CGAL::next(CGAL::halfedge(`face`)))
/// 0 - source(halfedge(`face`))
/// 1 - target(halfedge(`face`))
/// 2 - target(next(halfedge(`face`)))
typedef typename std::pair<face_descriptor, Barycentric_coordinate> Face_location;
/// @}
@ -150,9 +150,9 @@ private:
++m_output;
}
void face(face_descriptor face, Barycentric_coordinate location)
void face(face_descriptor f, Barycentric_coordinate location)
{
*m_output = m_owner.point(face, location);
*m_output = m_owner.point(f, location);
++m_output;
}
};
@ -305,7 +305,7 @@ private:
static Triangle_3 triangle_from_halfedge(halfedge_descriptor edge, const FaceGraph& faceGraph)
{
return triangle_from_halfedge(edge, faceGraph, CGAL::get(CGAL::vertex_point, faceGraph));
return triangle_from_halfedge(edge, faceGraph, get(vertex_point, faceGraph));
}
static Triangle_3 triangle_from_halfedge(halfedge_descriptor edge, const FaceGraph& faceGraph, VertexPointMap vertexPointMap)
@ -313,19 +313,19 @@ private:
return CGAL::internal::triangle_from_halfedge<Triangle_3, FaceGraph, VertexPointMap>(edge, faceGraph, vertexPointMap);
}
Triangle_3 triangle_from_face(face_descriptor face) const
Triangle_3 triangle_from_face(face_descriptor f) const
{
return triangle_from_face(face, m_faceGraph, m_vertexPointMap);
return triangle_from_face(f, m_faceGraph, m_vertexPointMap);
}
static Triangle_3 triangle_from_face(face_descriptor face, const FaceGraph& faceGraph)
static Triangle_3 triangle_from_face(face_descriptor f, const FaceGraph& faceGraph)
{
return triangle_from_halfedge(CGAL::halfedge(face, faceGraph), faceGraph, CGAL::get(CGAL::vertex_point, faceGraph));
return triangle_from_halfedge(halfedge(f, faceGraph), faceGraph, get(vertex_point, faceGraph));
}
static Triangle_3 triangle_from_face(face_descriptor face, const FaceGraph& faceGraph, VertexPointMap vertexPointMap)
static Triangle_3 triangle_from_face(face_descriptor f, const FaceGraph& faceGraph, VertexPointMap vertexPointMap)
{
return triangle_from_halfedge(CGAL::halfedge(face, faceGraph), faceGraph, vertexPointMap);
return triangle_from_halfedge(halfedge(f, faceGraph), faceGraph, vertexPointMap);
}
bool window_distance_filter(Cone_tree_node* cone, Segment_2 windowSegment, bool reversed)
@ -345,9 +345,9 @@ private:
Point_2 v1;
Point_2 v3;
size_t v1Index = m_vertexIndexMap[CGAL::source(cone->entry_edge(), m_faceGraph)];
size_t v2Index = m_vertexIndexMap[cone->target_vertex()];
size_t v3Index = m_vertexIndexMap[CGAL::target(cone->entry_edge(), m_faceGraph)];
size_t v1Index = get(m_vertexIndexMap, source(cone->entry_edge(), m_faceGraph));
size_t v2Index = get(m_vertexIndexMap, cone->target_vertex());
size_t v3Index = get(m_vertexIndexMap, target(cone->entry_edge(), m_faceGraph));
Node_distance_pair v1Distance = m_closestToVertices[v1Index];
Node_distance_pair v2Distance = m_closestToVertices[v2Index];
@ -475,7 +475,7 @@ private:
}
}
void expand_root(face_descriptor face, Barycentric_coordinate location)
void expand_root(face_descriptor f, Barycentric_coordinate location)
{
typename Traits::Construct_barycentric_coordinate_weight cbcw(m_traits.construct_barycentric_coordinate_weight_object());
typename Traits::Classify_barycentric_coordinate classify_barycentric_coordinate(m_traits.classify_barycentric_coordinate_object());
@ -487,26 +487,26 @@ private:
switch (type)
{
case CGAL::internal::BARYCENTRIC_COORDINATE_INTERNAL:
expand_face_root(face, location);
expand_face_root(f, location);
break;
case CGAL::internal::BARYCENTRIC_COORDINATE_EDGE:
{
halfedge_descriptor halfedge = CGAL::halfedge(face, m_faceGraph);
halfedge_descriptor he = halfedge(f, m_faceGraph);
for (size_t i = 0; i < associatedEdge; ++i)
{
halfedge = CGAL::next(halfedge, m_faceGraph);
he = next(he, m_faceGraph);
}
expand_edge_root(halfedge, cbcw(location, associatedEdge), cbcw(location, (associatedEdge + 1) % 3));
expand_edge_root(he, cbcw(location, associatedEdge), cbcw(location, (associatedEdge + 1) % 3));
}
break;
case CGAL::internal::BARYCENTRIC_COORDINATE_VERTEX:
{
halfedge_descriptor halfedge = CGAL::halfedge(face, m_faceGraph);
halfedge_descriptor he = halfedge(f, m_faceGraph);
for (size_t i = 0; i < associatedEdge; ++i)
{
halfedge = CGAL::next(halfedge, m_faceGraph);
he = next(he, m_faceGraph);
}
expand_vertex_root(CGAL::source(halfedge, m_faceGraph));
expand_vertex_root(source(he, m_faceGraph));
}
break;
default:
@ -515,12 +515,12 @@ private:
}
}
void expand_face_root(face_descriptor faceId, Barycentric_coordinate faceLocation)
void expand_face_root(face_descriptor f, Barycentric_coordinate faceLocation)
{
typename Traits::Project_triangle_3_to_triangle_2 pt3t2(m_traits.project_triangle_3_to_triangle_2_object());
typename Traits::Construct_vertex_2 cv2(m_traits.construct_vertex_2_object());
halfedge_descriptor start = CGAL::halfedge(faceId, m_faceGraph);
halfedge_descriptor start = halfedge(f, m_faceGraph);
halfedge_descriptor current = start;
Cone_tree_node* faceRoot = new Cone_tree_node(m_traits, m_faceGraph, m_rootNodes.size());
@ -530,7 +530,7 @@ private:
if (m_debugOutput)
{
typename Traits::Construct_barycentric_coordinate_weight cbcw(m_traits.construct_barycentric_coordinate_weight_object());
std::cout << "\tFace Root Expansion: id = " << m_faceIndexMap[faceId] << " , Location = " << cbcw(faceLocation, 0) << " " << cbcw(faceLocation, 1) << " " << cbcw(faceLocation, 2) << " " << std::endl;
std::cout << "\tFace Root Expansion: id = " << get(m_faceIndexMap, f) << " , Location = " << cbcw(faceLocation, 0) << " " << cbcw(faceLocation, 1) << " " << cbcw(faceLocation, 2) << " " << std::endl;
}
for (size_t currentVertex = 0; currentVertex < 3; ++currentVertex)
@ -553,7 +553,7 @@ private:
process_node(child);
current = CGAL::next(current, m_faceGraph);
current = next(current, m_faceGraph);
}
}
@ -566,12 +566,12 @@ private:
if (m_debugOutput)
{
std::cout << "\tEdge Root Expansion: faceA = " << m_faceIndexMap[CGAL::face(baseEdge, m_faceGraph)] << " , faceB = " << m_faceIndexMap[CGAL::face(CGAL::opposite(baseEdge, m_faceGraph), m_faceGraph)] << " , t0 = " << t0 << " , t1 = " << t1 << std::endl;
std::cout << "\tEdge Root Expansion: faceA = " << get(m_faceIndexMap, face(baseEdge, m_faceGraph)) << " , faceB = " << get(m_faceIndexMap, face(opposite(baseEdge, m_faceGraph), m_faceGraph)) << " , t0 = " << t0 << " , t1 = " << t1 << std::endl;
}
halfedge_descriptor baseEdges[2];
baseEdges[0] = baseEdge;
baseEdges[1] = CGAL::opposite(baseEdge, m_faceGraph);
baseEdges[1] = opposite(baseEdge, m_faceGraph);
Triangle_3 faces3d[2];
Triangle_2 layoutFaces[2];
@ -604,7 +604,7 @@ private:
edgeRoot->push_middle_child(mainChild);
process_node(mainChild);
Cone_tree_node* oppositeChild = new Cone_tree_node(m_traits, m_faceGraph, CGAL::prev(baseEdges[side], m_faceGraph), ct2(cv2(layoutFaces[side], 2), cv2(layoutFaces[side], 0), cv2(layoutFaces[side], 1)), sourcePoints[side], FT(0.0), cv2(layoutFaces[side], 2), cv2(layoutFaces[side], 1), Cone_tree_node::EDGE_SOURCE);
Cone_tree_node* oppositeChild = new Cone_tree_node(m_traits, m_faceGraph, prev(baseEdges[side], m_faceGraph), ct2(cv2(layoutFaces[side], 2), cv2(layoutFaces[side], 0), cv2(layoutFaces[side], 1)), sourcePoints[side], FT(0.0), cv2(layoutFaces[side], 2), cv2(layoutFaces[side], 1), Cone_tree_node::EDGE_SOURCE);
node_created();
edgeRoot->push_middle_child(oppositeChild);
process_node(oppositeChild);
@ -615,15 +615,15 @@ private:
{
if (m_debugOutput)
{
std::cout << "\tVertex Root Expansion: Vertex = " << m_vertexIndexMap[vertex] << std::endl;
std::cout << "\tVertex Root Expansion: Vertex = " << get(m_vertexIndexMap, vertex) << std::endl;
}
Cone_tree_node* vertexRoot = new Cone_tree_node(m_traits, m_faceGraph, m_rootNodes.size(), CGAL::prev(CGAL::halfedge(vertex, m_faceGraph), m_faceGraph));
Cone_tree_node* vertexRoot = new Cone_tree_node(m_traits, m_faceGraph, m_rootNodes.size(), prev(halfedge(vertex, m_faceGraph), m_faceGraph));
node_created();
m_rootNodes.push_back(vertexRoot);
m_closestToVertices[m_vertexIndexMap[vertex]] = Node_distance_pair(vertexRoot, FT(0.0));
m_closestToVertices[get(m_vertexIndexMap, vertex)] = Node_distance_pair(vertexRoot, FT(0.0));
expand_pseudo_source(vertexRoot);
}
@ -637,8 +637,8 @@ private:
vertex_descriptor expansionVertex = parent->target_vertex();
halfedge_descriptor startEdge = CGAL::halfedge(expansionVertex, m_faceGraph);
halfedge_descriptor currentEdge = CGAL::halfedge(expansionVertex, m_faceGraph);
halfedge_descriptor startEdge = halfedge(expansionVertex, m_faceGraph);
halfedge_descriptor currentEdge = halfedge(expansionVertex, m_faceGraph);
FT distanceFromTargetToRoot = parent->distance_from_target_to_root();
@ -657,9 +657,9 @@ private:
if (m_debugOutput)
{
std::cout << "Expanding PsuedoSource: id = ";
if (CGAL::face(currentEdge, m_faceGraph) != GraphTraits::null_face())
if (face(currentEdge, m_faceGraph) != GraphTraits::null_face())
{
std::cout << m_faceIndexMap[CGAL::face(currentEdge, m_faceGraph)];
std::cout << get(m_faceIndexMap, face(currentEdge, m_faceGraph));
}
else
{
@ -674,7 +674,7 @@ private:
parent->push_middle_child(child);
process_node(child);
currentEdge = CGAL::opposite(CGAL::next(currentEdge, m_faceGraph), m_faceGraph);
currentEdge = opposite(next(currentEdge, m_faceGraph), m_faceGraph);
}
while (currentEdge != startEdge);
@ -719,7 +719,7 @@ private:
{
LineLineIntersectResult cgalIntersection = i2(cl2(segment), cl2(leftBoundary));
if (!cgalIntersection || !boost::get<Point_2>(&*cgalIntersection))
if (!cgalIntersection || !boost::get<Point_2, Point_2, Line_2>(&*cgalIntersection))
{
if (m_debugOutput)
{
@ -729,7 +729,7 @@ private:
}
else
{
Point_2* result = boost::get<Point_2>(&*cgalIntersection);
Point_2* result = boost::get<Point_2, Point_2, Line_2>(&*cgalIntersection);
FT t0 = pdas2(cs2(segment), ct2(segment), *result);
if (t0 >= FT(1.00000))
@ -779,7 +779,7 @@ private:
{
LineLineIntersectResult cgalIntersection = i2(cl2(segment), cl2(rightBoundary));
if (!cgalIntersection || !boost::get<Point_2>(&*cgalIntersection))
if (!cgalIntersection || !boost::get<Point_2, Point_2, Line_2>(&*cgalIntersection))
{
if (m_debugOutput)
{
@ -789,7 +789,7 @@ private:
}
else
{
Point_2* result = boost::get<Point_2>(&*cgalIntersection);
Point_2* result = boost::get<Point_2, Point_2, Line_2>(&*cgalIntersection);
FT t0 = pdas2(cs2(segment), ct2(segment), *result);
if (t0 <= FT(0.00000))
@ -865,8 +865,8 @@ private:
halfedge_descriptor current = node->entry_edge();
for (size_t i = 0; i < 3; ++i)
{
std::cout << m_vertexIndexMap[CGAL::source(current, m_faceGraph)] << " ";
current = CGAL::next(current, m_faceGraph);
std::cout << get(m_vertexIndexMap, source(current, m_faceGraph)) << " ";
current = next(current, m_faceGraph);
}
std::cout << std::endl;
std::cout << "\tSource Image = " << node->source_image() << std::endl;
@ -882,7 +882,7 @@ private:
std::cout << "\tContains target vertex" << std::endl;
}
size_t entryEdgeIndex = m_halfedgeIndexMap[node->entry_edge()];
size_t entryEdgeIndex = get(m_halfedgeIndexMap, node->entry_edge());
Node_distance_pair currentOccupier = m_vertexOccupiers[entryEdgeIndex];
FT currentNodeDistance = node->distance_from_target_to_root();
@ -892,7 +892,7 @@ private:
if (m_debugOutput)
{
std::cout << "\t Entry Edge = " << entryEdgeIndex << std::endl;
std::cout << "\t Target vertex = " << m_vertexIndexMap[node->target_vertex()] << std::endl;
std::cout << "\t Target vertex = " << get(m_vertexIndexMap, node->target_vertex()) << std::endl;
}
if (currentOccupier.first != NULL)
@ -988,7 +988,7 @@ private:
}
}
size_t targetVertexIndex = m_vertexIndexMap[node->target_vertex()];
size_t targetVertexIndex = get(m_vertexIndexMap, node->target_vertex());
// Check if this is now the absolute closest node, and replace the current closest as appropriate
Node_distance_pair currentClosest = m_closestToVertices[targetVertexIndex];
@ -1084,7 +1084,7 @@ private:
{
typename Traits::Compute_squared_distance_2 csd2(m_traits.compute_squared_distance_2_object());
if (CGAL::face(parent->left_child_edge(), m_faceGraph) != GraphTraits::null_face())
if (face(parent->left_child_edge(), m_faceGraph) != GraphTraits::null_face())
{
Segment_2 leftWindow;
@ -1125,7 +1125,7 @@ private:
{
typename Traits::Compute_squared_distance_2 csd2(m_traits.compute_squared_distance_2_object());
if (CGAL::face(parent->right_child_edge(), m_faceGraph) != GraphTraits::null_face())
if (face(parent->right_child_edge(), m_faceGraph) != GraphTraits::null_face())
{
Segment_2 rightWindow;
bool result = clip_to_bounds(parent->right_child_base_segment(), parent->left_boundary(), parent->right_boundary(), rightWindow);
@ -1231,13 +1231,13 @@ private:
// to the original faceGraph, and deletion without
if (!node->is_root_node() && !destruction)
{
size_t entryEdgeIndex = m_halfedgeIndexMap[node->entry_edge()];
size_t entryEdgeIndex = get(m_halfedgeIndexMap, node->entry_edge());
if (m_vertexOccupiers[entryEdgeIndex].first == node)
{
m_vertexOccupiers[entryEdgeIndex].first = NULL;
size_t targetVertexIndex = m_vertexIndexMap[node->target_vertex()];
size_t targetVertexIndex = get(m_vertexIndexMap, node->target_vertex());
if (m_closestToVertices[targetVertexIndex].first == node)
{
@ -1258,7 +1258,7 @@ private:
for (boost::tie(current, end) = boost::vertices(m_faceGraph); current != end; ++current)
{
size_t vertexIndex = m_vertexIndexMap[*current];
size_t vertexIndex = get(m_vertexIndexMap, *current);
if (is_saddle_vertex(*current) || is_boundary_vertex(*current))
{
@ -1278,17 +1278,17 @@ private:
bool is_boundary_vertex(vertex_descriptor v)
{
halfedge_descriptor h = CGAL::halfedge(v, m_faceGraph);
halfedge_descriptor h = halfedge(v, m_faceGraph);
halfedge_descriptor first = h;
do
{
if (CGAL::face(h, m_faceGraph) == GraphTraits::null_face() || CGAL::face(CGAL::opposite(h, m_faceGraph), m_faceGraph) == GraphTraits::null_face())
if (face(h, m_faceGraph) == GraphTraits::null_face() || face(opposite(h, m_faceGraph), m_faceGraph) == GraphTraits::null_face())
{
return true;
}
h = CGAL::opposite(CGAL::next(h, m_faceGraph), m_faceGraph);
h = opposite(next(h, m_faceGraph), m_faceGraph);
}
while(h != first);
@ -1307,7 +1307,7 @@ private:
{
m_closestToVertices.resize(boost::num_vertices(m_faceGraph));
std::fill(m_closestToVertices.begin(), m_closestToVertices.end(), Node_distance_pair(NULL, FT(0.0)));
m_vertexOccupiers.resize(CGAL::num_halfedges(m_faceGraph));
m_vertexOccupiers.resize(num_halfedges(m_faceGraph));
std::fill(m_vertexOccupiers.begin(), m_vertexOccupiers.end(), Node_distance_pair(NULL, FT(0.0)));
while (!m_expansionPriqueue.empty())
@ -1353,6 +1353,8 @@ private:
while (!current->is_root_node())
{
std::cout << "Node Type : " << current->node_type() << std::endl;
switch (current->node_type())
{
case Cone_tree_node::INTERVAL:
@ -1365,7 +1367,9 @@ private:
assert(cgalIntersection);
Point_2* result = boost::get<Point_2>(&*cgalIntersection);
// TODO: This isn't getting template substituted properly in the OpenMesh version
// I have no fucking clue why
Point_2* result = boost::get<Point_2, Point_2, Line_2>(&*cgalIntersection);
assert(result && "Error, did not get point intersection on path walk to source");
@ -1374,12 +1378,12 @@ private:
if (m_debugOutput)
{
std::cout << "Current Node: " << current << " , Face = " << current->layout_face() << std::endl;
halfedge_descriptor halfedge = current->entry_edge();
halfedge_descriptor he = current->entry_edge();
std::cout << "Face vertices: ";
for (size_t i = 0; i < 3; ++i)
{
std::cout << m_vertexIndexMap[CGAL::source(halfedge, m_faceGraph)] << ",";
halfedge = CGAL::next(halfedge, m_faceGraph);
std::cout << get(m_vertexIndexMap, source(he, m_faceGraph)) << ",";
he = next(he, m_faceGraph);
}
std::cout << std::endl;
std::cout << "Current Location: " << currentLocation << std::endl;
@ -1390,7 +1394,7 @@ private:
std::cout << "Current Left Window: " << current->window_left() << " , " << m_traits.parametric_distance_along_segment_2_object()(entrySegment.start(), entrySegment.end(), current->window_left()) << std::endl;
std::cout << "Current Right Window: " << current->window_right() << " , " << m_traits.parametric_distance_along_segment_2_object()(entrySegment.start(), entrySegment.end(), current->window_right()) << std::endl;
std::cout << "Current Segment Intersection: " << *result << std::endl;
std::cout << "Edge: (" << m_vertexIndexMap[CGAL::source(current->entry_edge(), m_faceGraph)] << "," << m_vertexIndexMap[CGAL::target(current->entry_edge(), m_faceGraph)] << ") : " << t0 << std::endl;
std::cout << "Edge: (" << get(m_vertexIndexMap, source(current->entry_edge(), m_faceGraph)) << "," << get(m_vertexIndexMap, target(current->entry_edge(), m_faceGraph)) << ") : " << t0 << std::endl;
}
visitor.edge(current->entry_edge(), t0);
@ -1411,7 +1415,7 @@ private:
}
break;
case Cone_tree_node::VERTEX_SOURCE:
visitor.vertex(CGAL::target(current->entry_edge(), m_faceGraph));
visitor.vertex(target(current->entry_edge(), m_faceGraph));
currentLocation = current->parent()->tarpoint();
current = current->parent();
break;
@ -1430,7 +1434,7 @@ private:
{
if (!node->is_root_node() && !node->is_null_face())
{
size_t faceIndex = m_faceIndexMap[node->current_face()];
size_t faceIndex = get(m_faceIndexMap, node->current_face());
m_faceOccupiers[faceIndex].push_back(node);
}
@ -1467,12 +1471,10 @@ private:
return cbc(cbcw(location, shift), cbcw(location, (shift + 1) % 3), cbcw(location, (shift + 2) % 3));
}
std::pair<Node_distance_pair, Barycentric_coordinate> nearest_on_face(face_descriptor face, Barycentric_coordinate location)
std::pair<Node_distance_pair, Barycentric_coordinate> nearest_on_face(face_descriptor f, Barycentric_coordinate location)
{
size_t faceIndex = m_faceIndexMap[face];
size_t faceIndex = get(m_faceIndexMap, f);
halfedge_descriptor halfedge = CGAL::halfedge(face, m_faceGraph);
Cone_tree_node* closest = NULL;
FT closestDistance;
@ -1511,7 +1513,7 @@ private:
}
}
std::pair<Node_distance_pair, Barycentric_coordinate> nearest_to_location(face_descriptor face, Barycentric_coordinate location)
std::pair<Node_distance_pair, Barycentric_coordinate> nearest_to_location(face_descriptor f, Barycentric_coordinate location)
{
typename Traits::Construct_barycentric_coordinate_weight cbcw(m_traits.construct_barycentric_coordinate_weight_object());
typename Traits::Construct_barycentric_coordinate cbc(m_traits.construct_barycentric_coordinate_object());
@ -1524,17 +1526,17 @@ private:
switch (type)
{
case CGAL::internal::BARYCENTRIC_COORDINATE_INTERNAL:
return nearest_on_face(face, location);
return nearest_on_face(f, location);
case CGAL::internal::BARYCENTRIC_COORDINATE_EDGE:
{
halfedge_descriptor halfedge = CGAL::halfedge(face, m_faceGraph);
halfedge_descriptor he = halfedge(f, m_faceGraph);
for (size_t i = 0; i < associatedEdge; ++i)
{
halfedge = CGAL::next(halfedge, m_faceGraph);
he = next(he, m_faceGraph);
}
expand_edge_root(halfedge, cbcw(location, associatedEdge), cbcw(location, (associatedEdge + 1) % 3));
expand_edge_root(he, cbcw(location, associatedEdge), cbcw(location, (associatedEdge + 1) % 3));
halfedge_descriptor oppositeHalfedge = CGAL::opposite(halfedge, m_faceGraph);
halfedge_descriptor oppositeHalfedge = opposite(he, m_faceGraph);
size_t oppositeIndex = internal::edge_index(oppositeHalfedge, m_faceGraph);
@ -1543,9 +1545,9 @@ private:
oppositeLocationCoords[oppositeIndex] = cbcw(location, (associatedEdge + 1) % 3);
oppositeLocationCoords[(oppositeIndex + 1) % 3] = cbcw(location, associatedEdge);
std::pair<Node_distance_pair,Barycentric_coordinate> mainFace = nearest_on_face(face, location);
std::pair<Node_distance_pair,Barycentric_coordinate> mainFace = nearest_on_face(f, location);
Barycentric_coordinate oppositeLocation(cbc(oppositeLocationCoords[0], oppositeLocationCoords[1], oppositeLocationCoords[2]));
std::pair<Node_distance_pair,Barycentric_coordinate> otherFace = nearest_on_face(CGAL::face(oppositeHalfedge, m_faceGraph), oppositeLocation);
std::pair<Node_distance_pair,Barycentric_coordinate> otherFace = nearest_on_face(face(oppositeHalfedge, m_faceGraph), oppositeLocation);
if (mainFace.first.first == NULL)
{
@ -1563,16 +1565,16 @@ private:
break;
case CGAL::internal::BARYCENTRIC_COORDINATE_VERTEX:
{
halfedge_descriptor halfedge = CGAL::halfedge(face, m_faceGraph);
halfedge_descriptor he = halfedge(f, m_faceGraph);
for (size_t i = 0; i < associatedEdge; ++i)
{
halfedge = CGAL::next(halfedge, m_faceGraph);
he = next(he, m_faceGraph);
}
vertex_descriptor vertex = CGAL::source(halfedge, m_faceGraph);
vertex_descriptor vertex = source(he, m_faceGraph);
return std::make_pair(m_closestToVertices[m_vertexIndexMap[vertex]], Barycentric_coordinate(FT(0.0), FT(0.0), FT(1.0)));
return std::make_pair(m_closestToVertices[get(m_vertexIndexMap, vertex)], Barycentric_coordinate(FT(0.0), FT(0.0), FT(1.0)));
}
break;
@ -1592,8 +1594,8 @@ private:
reset_algorithm(false);
set_vertex_types();
m_vertexOccupiers.resize(CGAL::num_halfedges(m_faceGraph));
m_closestToVertices.resize(CGAL::num_vertices(m_faceGraph));
m_vertexOccupiers.resize(num_halfedges(m_faceGraph));
m_closestToVertices.resize(boost::num_vertices(m_faceGraph));
if (m_debugOutput)
{
@ -1603,7 +1605,7 @@ private:
for (boost::tie(current,end) = boost::vertices(m_faceGraph); current != end; ++current)
{
std::cout << "Vertex#" << numVertices << ": p = " << m_vertexPointMap[*current] << " , Saddle Vertex: " << (is_saddle_vertex(*current) ? "yes" : "no") << " , Boundary Vertex: " << (is_boundary_vertex(*current) ? "yes" : "no") << std::endl;
std::cout << "Vertex#" << numVertices << ": p = " << get(m_vertexPointMap,*current) << " , Saddle Vertex: " << (is_saddle_vertex(*current) ? "yes" : "no") << " , Boundary Vertex: " << (is_boundary_vertex(*current) ? "yes" : "no") << std::endl;
++numVertices;
}
}
@ -1615,18 +1617,18 @@ private:
{
size_t numFaces = 0;
for (boost::tie(facesCurrent, facesEnd) = CGAL::faces(m_faceGraph); facesCurrent != facesEnd; ++facesCurrent)
for (boost::tie(facesCurrent, facesEnd) = faces(m_faceGraph); facesCurrent != facesEnd; ++facesCurrent)
{
std::cout << "Face#" << numFaces << ": Vertices = (";
++numFaces;
halfedge_iterator faceEdgesStart = CGAL::halfedge(*facesCurrent, m_faceGraph);
halfedge_iterator faceEdgesCurrent = faceEdgesStart;
halfedge_descriptor faceEdgesStart = halfedge(*facesCurrent, m_faceGraph);
halfedge_descriptor faceEdgesCurrent = faceEdgesStart;
do
{
std::cout << m_vertexIndexMap[CGAL::source(*faceEdgesCurrent, m_faceGraph)];
std::cout << get(m_vertexIndexMap, boost::source(faceEdgesCurrent, m_faceGraph));
faceEdgesCurrent = CGAL::next(*faceEdgesCurrent, m_faceGraph);
faceEdgesCurrent = next(faceEdgesCurrent, m_faceGraph);
if (faceEdgesCurrent != faceEdgesStart)
{
@ -1648,7 +1650,7 @@ private:
{
if (m_debugOutput)
{
std::cout << "Root: " << m_faceIndexMap[m_faceLocations[i].first] << " , " << m_faceLocations[i].second[0] << " " << m_faceLocations[i].second[1] << " " << m_faceLocations[i].second[2] << " " << std::endl;
std::cout << "Root: " << get(m_faceIndexMap, m_faceLocations[i].first) << " , " << m_faceLocations[i].second[0] << " " << m_faceLocations[i].second[1] << " " << m_faceLocations[i].second[2] << " " << std::endl;
}
expand_root(m_faceLocations[i].first, m_faceLocations[i].second);
@ -1678,7 +1680,7 @@ private:
case Cone_expansion_event::PSEUDO_SOURCE:
if (m_debugOutput)
{
std::cout << "PseudoSource Expansion: Parent = " << parent << " , Vertex = " << m_vertexIndexMap[event->m_parent->target_vertex()] << " , Distance = " << event->m_distanceEstimate << " , Level = " << event->m_parent->level() + 1 << std::endl;
std::cout << "PseudoSource Expansion: Parent = " << parent << " , Vertex = " << get(m_vertexIndexMap, event->m_parent->target_vertex()) << " , Distance = " << event->m_distanceEstimate << " , Level = " << event->m_parent->level() + 1 << std::endl;
}
expand_pseudo_source(parent);
@ -1686,7 +1688,7 @@ private:
case Cone_expansion_event::LEFT_CHILD:
if (m_debugOutput)
{
std::cout << "Left Expansion: Parent = " << parent << " Edge = (" << m_vertexIndexMap[CGAL::source(event->m_parent->left_child_edge(), m_faceGraph)] << "," << m_vertexIndexMap[CGAL::target(event->m_parent->left_child_edge(), m_faceGraph)] << ") , Distance = " << event->m_distanceEstimate << " , Level = " << event->m_parent->level() + 1 << std::endl;
std::cout << "Left Expansion: Parent = " << parent << " Edge = (" << get(m_vertexIndexMap, source(event->m_parent->left_child_edge(), m_faceGraph)) << "," << get(m_vertexIndexMap, target(event->m_parent->left_child_edge(), m_faceGraph)) << ") , Distance = " << event->m_distanceEstimate << " , Level = " << event->m_parent->level() + 1 << std::endl;
}
expand_left_child(parent, event->m_windowSegment);
@ -1694,7 +1696,7 @@ private:
case Cone_expansion_event::RIGHT_CHILD:
if (m_debugOutput)
{
std::cout << "Right Expansion: Parent = " << parent << " , Edge = (" << m_vertexIndexMap[CGAL::source(event->m_parent->right_child_edge(), m_faceGraph)] << "," << m_vertexIndexMap[CGAL::target(event->m_parent->right_child_edge(), m_faceGraph)] << ") , Distance = " << event->m_distanceEstimate << " , Level = " << event->m_parent->level() + 1 << std::endl;
std::cout << "Right Expansion: Parent = " << parent << " , Edge = (" << get(m_vertexIndexMap, source(event->m_parent->right_child_edge(), m_faceGraph)) << "," << get(m_vertexIndexMap, target(event->m_parent->right_child_edge(), m_faceGraph)) << ") , Distance = " << event->m_distanceEstimate << " , Level = " << event->m_parent->level() + 1 << std::endl;
}
expand_right_child(parent, event->m_windowSegment);
@ -1710,7 +1712,7 @@ private:
}
m_faceOccupiers.clear();
m_faceOccupiers.resize(CGAL::num_faces(m_faceGraph));
m_faceOccupiers.resize(num_faces(m_faceGraph));
for (size_t i = 0; i < m_rootNodes.size(); ++i)
{
@ -1766,8 +1768,8 @@ public:
: m_traits(traits)
, m_faceGraph(faceGraph)
, m_vertexIndexMap(CGAL::get(boost::vertex_external_index, faceGraph))
, m_halfedgeIndexMap(CGAL::get(CGAL::halfedge_external_index, faceGraph))
, m_faceIndexMap(CGAL::get(CGAL::face_external_index, faceGraph))
, m_halfedgeIndexMap(CGAL::get(halfedge_external_index, faceGraph))
, m_faceIndexMap(CGAL::get(face_external_index, faceGraph))
, m_vertexPointMap(CGAL::get(CGAL::vertex_point, faceGraph))
, m_debugOutput(false)
{
@ -1828,9 +1830,7 @@ public:
\details Constructs a shortest paths sequence tree that covers shortest surface paths
to all locations on the faceGraph from the given source vertex.
\param face Handle to the face on which the source originates.
\param location Barycentric coordinate on face specifying the source location.
\param vertex Vertex to serve as the root location of the sequence tree
*/
void construct_sequence_tree(vertex_descriptor vertex)
{
@ -1845,14 +1845,13 @@ public:
\details Constructs a shortest paths sequence tree that covers shortest surface paths
to all locations on the faceGraph reachable from the given source point.
\param face Handle to the face on which the source originates.
\param f Handle to the face on which the source originates.
\param location Barycentric coordinate on face specifying the source location.
*/
void construct_sequence_tree(face_descriptor face, Barycentric_coordinate location)
void construct_sequence_tree(face_descriptor f, Barycentric_coordinate location)
{
m_faceLocations.clear();
m_faceLocations.push_back(std::make_pair(face, location));
m_faceLocations.push_back(std::make_pair(f, location));
construct_sequence_tree_internal();
}
@ -1864,9 +1863,8 @@ public:
\tparam InputIterator a ForwardIterator type which dereferences to Face_location.
\param faceLocationsBegin iterator to the first in the list of face location pairs.
\param faceLocationsEnd iterator to one past the end of the list of face location pairs.
\param begin iterator to the first in the list of vertices
\param end iterator to one past the end of the list of vertices
*/
template <class InputIterator>
typename boost::enable_if<typename boost::is_same<typename std::iterator_traits<InputIterator>::value_type, vertex_descriptor>::value, void>::type construct_sequence_tree(InputIterator begin, InputIterator end)
@ -1887,9 +1885,9 @@ public:
\tparam InputIterator a ForwardIterator type which dereferences to Face_location.
\param faceLocationsBegin iterator to the first in the list of face location pairs.
\param begin iterator to the first in the list of face location pairs.
\param faceLocationsEnd iterator to one past the end of the list of face location pairs.
\param end iterator to one past the end of the list of face location pairs.
*/
template <class InputIterator>
typename boost::enable_if<typename boost::is_same<typename std::iterator_traits<InputIterator>::value_type, Face_location>::type, void>::type construct_sequence_tree(InputIterator begin, InputIterator end)
@ -1945,7 +1943,7 @@ public:
*/
std::pair<FT, size_t> shortest_distance_to_source_points(vertex_descriptor v)
{
Node_distance_pair result = m_closestToVertices[m_vertexIndexMap[v]];
Node_distance_pair result = m_closestToVertices[get(m_vertexIndexMap, v)];
Cone_tree_node* current = result.first;
@ -1962,7 +1960,7 @@ public:
/*!
\brief Computes the shortest surface distance from any surface location to any source point
\param face Face of the faceGraph of the query point
\param f Face of the faceGraph of the query point
\param location Barycentric coordinate on face of the query point
@ -1971,9 +1969,9 @@ public:
reachable, the distance will be a negative value and the source
location will be an index greater than the number of source points.
*/
std::pair<FT, size_t> shortest_distance_to_source_points(face_descriptor face, Barycentric_coordinate location)
std::pair<FT, size_t> shortest_distance_to_source_points(face_descriptor f, Barycentric_coordinate location)
{
std::pair<Node_distance_pair, Barycentric_coordinate> result = nearest_to_location(face, location);
std::pair<Node_distance_pair, Barycentric_coordinate> result = nearest_to_location(f, location);
Cone_tree_node* current = result.first.first;
@ -2002,7 +2000,7 @@ public:
template <class Visitor>
bool shortest_path_sequence_to_source_points(vertex_descriptor v, Visitor& visitor)
{
Cone_tree_node* current = m_closestToVertices[m_vertexIndexMap[v]].first;
Cone_tree_node* current = m_closestToVertices[get(m_vertexIndexMap, v)].first;
if (current)
{
@ -2019,16 +2017,16 @@ public:
\brief Visits the sequence of edges, vertices and faces traversed by the shortest path
from any surface location to any source point.
\param face Face of the faceGraph of the query point
\param f Face of the faceGraph of the query point
\param location Barycentric coordinate on face of the query point
\param visitor A model of FaceGraphShortestPathVisitor to receive the shortest path
*/
template <class Visitor>
bool shortest_path_sequence_to_source_points(face_descriptor face, Barycentric_coordinate location, Visitor& visitor)
bool shortest_path_sequence_to_source_points(face_descriptor f, Barycentric_coordinate location, Visitor& visitor)
{
std::pair<Node_distance_pair, Barycentric_coordinate> result = nearest_to_location(face, location);
std::pair<Node_distance_pair, Barycentric_coordinate> result = nearest_to_location(f, location);
Cone_tree_node* current = result.first.first;
if (current)
@ -2064,17 +2062,17 @@ public:
\brief Visits the sequence of points in the surface-restricted polyline from any surface location
to any source point (used for visualization of the shortest path).
\param face Face of the faceGraph of the query point
\param f Face of the faceGraph of the query point
\param location Barycentric coordinate on face of the query point
\param output An OutputIterator to receive the shortest path points as Point_3
*/
template <class OutputIterator>
void shortest_path_points_to_source_points(face_descriptor face, Barycentric_coordinate location, OutputIterator output)
void shortest_path_points_to_source_points(face_descriptor f, Barycentric_coordinate location, OutputIterator output)
{
*output = point(face, location);
*output = point(f, location);
++output;
Point_path_visitor_wrapper<OutputIterator> wrapper(*this, output);
shortest_path_sequence_to_source_points(face, location, wrapper);
shortest_path_sequence_to_source_points(f, location, wrapper);
}
/// @}
@ -2085,38 +2083,39 @@ public:
/*!
\brief Returns the 3-dimensional coordinate of the given face and face location on the faceGraph.
\param face Face of the faceGraph of the query point
\param f Face of the faceGraph of the query point
\param location Barycentric coordinate on face of the query point
*/
Point_3 point(face_descriptor face, Barycentric_coordinate location) const
Point_3 point(face_descriptor f, Barycentric_coordinate location) const
{
return point(face, location, m_faceGraph, m_vertexPointMap, m_traits);
return point(f, location, m_faceGraph, m_vertexPointMap, m_traits);
}
/*!
\brief Returns the 3-dimensional coordinate of the given face and face location on the faceGraph.
\param face Face of the faceGraph of the query point
\param f Face of the faceGraph of the query point
\param location Barycentric coordinate on face of the query point
\param faceGraph face graph to create face location on
\param traits Optional traits class to use
*/
static Point_3 point(face_descriptor face, Barycentric_coordinate location, const FaceGraph& faceGraph, const Traits& traits = Traits())
static Point_3 point(face_descriptor f, Barycentric_coordinate location, const FaceGraph& faceGraph, const Traits& traits = Traits())
{
return point(face, location, faceGraph, CGAL::get(CGAL::vertex_point, faceGraph), traits);
return point(f, location, faceGraph, CGAL::get(CGAL::vertex_point, faceGraph), traits);
}
/*!
\brief Returns the 3-dimensional coordinate of the given face and face location on the faceGraph.
\param face Face of the faceGraph of the query point
\param f Face of the faceGraph of the query point
\param location Barycentric coordinate on face of the query point
\param faceGraph face graph to create face location on
\param vertexPointMap Point property map to get the 3d points of faceGraph
\param traits Optional traits class to use
*/
static Point_3 point(face_descriptor face, Barycentric_coordinate location, const FaceGraph& faceGraph, VertexPointMap vertexPointMap, const Traits& traits = Traits())
static Point_3 point(face_descriptor f, Barycentric_coordinate location, const FaceGraph& faceGraph, VertexPointMap vertexPointMap, const Traits& traits = Traits())
{
return construct_barycenter_in_triangle_3(triangle_from_face(face, faceGraph, vertexPointMap), location, traits);
return construct_barycenter_in_triangle_3(triangle_from_face(f, faceGraph, vertexPointMap), location, traits);
}
/*!
@ -2149,6 +2148,7 @@ public:
\param edge Edge of the faceGraph to use
\param t Parametric distance along edge
\param faceGraph face graph to create face location on
\param vertexPointMap Point property map to get the 3d points of faceGraph
\param traits Optional traits class to use
*/
static Point_3 point(halfedge_descriptor edge, FT t, const FaceGraph& faceGraph, VertexPointMap vertexPointMap, const Traits& traits = Traits())
@ -2156,7 +2156,7 @@ public:
typename Traits::Construct_barycenter_3 construct_barycenter_3(traits.construct_barycenter_3_object());
// Note: the parameter t is meant to be the weighted coordinate on the _endpoint_ (i.e. target) of the segment
return construct_barycenter_3(vertexPointMap[CGAL::target(edge, faceGraph)], t, vertexPointMap[CGAL::source(edge, faceGraph)]);
return construct_barycenter_3(get(vertexPointMap, target(edge, faceGraph)), t, get(vertexPointMap, source(edge, faceGraph)));
}
/*!
@ -2166,7 +2166,7 @@ public:
*/
Point_3 point(vertex_descriptor vertex) const
{
return m_vertexPointMap[vertex];
return get(m_vertexPointMap, vertex);
}
/*!
@ -2189,8 +2189,8 @@ public:
static Face_location face_location(vertex_descriptor vertex, const FaceGraph& faceGraph, const Traits& traits = Traits())
{
typename Traits::Construct_barycentric_coordinate construct_barycentric_coordinate(traits.construct_barycentric_coordinate_object());
halfedge_descriptor he = CGAL::next(CGAL::halfedge(vertex, faceGraph), faceGraph);
face_descriptor locationFace = CGAL::face(he, faceGraph);
halfedge_descriptor he = next(halfedge(vertex, faceGraph), faceGraph);
face_descriptor locationFace = face(he, faceGraph);
size_t edgeIndex = CGAL::internal::edge_index(he, faceGraph);
FT coords[3] = { FT(0.0), FT(0.0), FT(0.0) };
@ -2222,7 +2222,7 @@ public:
static Face_location face_location(halfedge_descriptor he, FT t, const FaceGraph& faceGraph, const Traits& traits = Traits())
{
typename Traits::Construct_barycentric_coordinate cbc(traits.construct_barycentric_coordinate_object());
face_descriptor locationFace = CGAL::face(he, faceGraph);
face_descriptor locationFace = face(he, faceGraph);
size_t edgeIndex = CGAL::internal::edge_index(he, faceGraph);
const FT oneMinusT(FT(1.0) - t);
@ -2238,7 +2238,7 @@ public:
/*!
\brief Return the nearest face location to the given point.
\param point Point to locate on the faceGraph
\param location Point to locate on the faceGraph
\param tree A cached AABB to perform the point location
*/
template <class AABB_face_graph_tree>
@ -2250,7 +2250,7 @@ public:
/*!
\brief Return the nearest face location to the given point.
\param point Point to locate on the faceGraph
\param location Point to locate on the faceGraph
\param tree A cached AABB to perform the point location
\param faceGraph faceGraph Face graph to intersect
\param vertexPointMap Vertex point mapping for `faceGraph`
@ -2262,9 +2262,9 @@ public:
typename Traits::Construct_barycentric_coordinate_in_triangle_3 cbcit3(traits.construct_barycentric_coordinate_in_triangle_3_object());
typename AABB_face_graph_tree::Point_and_primitive_id result = tree.closest_point_and_primitive(location);
face_descriptor face = result.second;
Barycentric_coordinate b = cbcit3(triangle_from_face(face, faceGraph, vertexPointMap), result.first);
return Face_location(face, b);
face_descriptor f = result.second;
Barycentric_coordinate b = cbcit3(triangle_from_face(f, faceGraph, vertexPointMap), result.first);
return Face_location(f, b);
}
/*!
@ -2273,7 +2273,7 @@ public:
other version in conjunction with `fill_aabb_tree'
if you need to call this method more than once.
\param point Point to locate on the faceGraph
\param location Point to locate on the faceGraph
*/
template <class AABB_face_graph_tree>
Face_location locate(const Point_3& location) const
@ -2287,7 +2287,7 @@ public:
other version in conjunction with `fill_aabb_tree'
if you need to call this method more than once.
\param point Point to locate on the faceGraph
\param location Point to locate on the faceGraph
\param faceGraph faceGraph Face graph to intersect
\param vertexPointMap Vertex point mapping for `faceGraph`
\param traits Optional traits class to use
@ -2428,7 +2428,7 @@ public:
static void fill_aabb_tree(const FaceGraph& faceGraph, AABB_face_graph_tree& outTree)
{
face_iterator facesStart, facesEnd;
boost::tie(facesStart, facesEnd) = CGAL::faces(faceGraph);
boost::tie(facesStart, facesEnd) = faces(faceGraph);
outTree.rebuild(facesStart, facesEnd, faceGraph);
outTree.build();
}

View File

@ -13,8 +13,8 @@
#include <CGAL/Polyhedron_shortest_path/internal/function_objects.h>
#include <CGAL/boost/graph/properties.h>
#include <CGAL/boost/graph/properties_Polyhedron_3.h>
#include <CGAL/boost/graph/graph_traits_Polyhedron_3.h>
//#include <CGAL/boost/graph/properties_Polyhedron_3.h>
//#include <CGAL/boost/graph/graph_traits_Polyhedron_3.h>
#include <ostream>
#include <boost/array.hpp>

View File

@ -170,7 +170,7 @@ public:
face_descriptor current_face() const
{
return CGAL::face(m_entryEdge, m_faceGraph);
return face(m_entryEdge, m_faceGraph);
}
bool is_null_face() const
@ -190,17 +190,17 @@ public:
halfedge_descriptor left_child_edge() const
{
return CGAL::opposite(CGAL::prev(m_entryEdge, m_faceGraph), m_faceGraph);
return opposite(prev(m_entryEdge, m_faceGraph), m_faceGraph);
}
halfedge_descriptor right_child_edge() const
{
return CGAL::opposite(CGAL::next(m_entryEdge, m_faceGraph), m_faceGraph);
return opposite(next(m_entryEdge, m_faceGraph), m_faceGraph);
}
vertex_descriptor target_vertex() const
{
return CGAL::target(CGAL::next(m_entryEdge, m_faceGraph), m_faceGraph);
return target(next(m_entryEdge, m_faceGraph), m_faceGraph);
}
Point_2 source_image() const

View File

@ -391,7 +391,7 @@ public:
if (intersectResult1)
{
Point_2* result = boost::get<Point_2>(&*intersectResult1);
Point_2* result = boost::get<Point_2, Point_2, Line_2>(&*intersectResult1);
assert(result && "Intersection should have been a point");
@ -412,7 +412,7 @@ public:
if (intersectResult2)
{
Point_2* result = boost::get<Point_2>(&*intersectResult2);
Point_2* result = boost::get<Point_2, Point_2, Line_2>(&*intersectResult2);
assert(result && "Intersection should have been a point");
@ -487,24 +487,24 @@ public:
result_type operator() (vertex_descriptor v, FaceGraph& faceGraph) const
{
return (*this)(v, faceGraph, CGAL::get(CGAL::vertex_point, faceGraph));
return (*this)(v, faceGraph, get(boost::vertex_point, faceGraph));
}
template<class VertexPointMap>
result_type operator() (vertex_descriptor v, const FaceGraph& faceGraph, VertexPointMap const& pointMap) const
{
halfedge_descriptor startEdge = CGAL::halfedge(v, faceGraph);
halfedge_descriptor startEdge = halfedge(v, faceGraph);
Point_3 rootPoint(pointMap[v]);
Point_3 prevPoint(pointMap[CGAL::source(startEdge, faceGraph)]);
Point_3 rootPoint(get(pointMap, v));
Point_3 prevPoint(get(pointMap, source(startEdge, faceGraph)));
halfedge_descriptor currentEdge = CGAL::next(startEdge, faceGraph);
halfedge_descriptor currentEdge = next(startEdge, faceGraph);
Point_3 nextPoint(pointMap[CGAL::target(currentEdge, faceGraph)]);
Point_3 nextPoint(get(pointMap, target(currentEdge, faceGraph)));
Triangle_3 baseFace3(rootPoint, nextPoint, prevPoint);
currentEdge = CGAL::opposite(currentEdge, faceGraph);
currentEdge = opposite(currentEdge, faceGraph);
Triangle_2 baseFace2(m_project_triangle_3_to_triangle_2(baseFace3));
@ -523,9 +523,9 @@ public:
do
{
prevPoint = nextPoint;
currentEdge = CGAL::next(currentEdge, faceGraph);
nextPoint = pointMap[CGAL::target(currentEdge, faceGraph)];
currentEdge = CGAL::opposite(currentEdge, faceGraph);
currentEdge = next(currentEdge, faceGraph);
nextPoint = get(pointMap, target(currentEdge, faceGraph));
currentEdge = opposite(currentEdge, faceGraph);
Triangle_3 currentFace3(m_construct_triangle_3(rootPoint, nextPoint, prevPoint));
Triangle_2 currentFace2(m_flatten_triangle_3_along_segment_2(currentFace3, 2, nextSegment));

View File

@ -26,15 +26,15 @@ Triangle_3 triangle_from_halfedge(typename boost::graph_traits<FaceGraph>::halfe
typedef typename boost::graph_traits<FaceGraph>::halfedge_descriptor halfedge_descriptor;
halfedge_descriptor e0 = edge;
halfedge_descriptor e1 = CGAL::next(edge, faceGraph);
halfedge_descriptor e1 = next(edge, faceGraph);
return Triangle_3(vertexPointMap[boost::source(e0, faceGraph)], vertexPointMap[boost::target(e0, faceGraph)], vertexPointMap[boost::target(e1, faceGraph)]);
return Triangle_3(get(vertexPointMap, boost::source(e0, faceGraph)), get(vertexPointMap, boost::target(e0, faceGraph)), get(vertexPointMap, boost::target(e1, faceGraph)));
}
template <class Triangle_3, class FaceGraph>
Triangle_3 triangle_from_halfedge(typename boost::graph_traits<FaceGraph>::halfedge_descriptor edge, const FaceGraph& faceGraph)
{
return triangle_from_halfedge<Triangle_3, FaceGraph, typename boost::property_map<FaceGraph, CGAL::vertex_point_t>::type>(edge, faceGraph, CGAL::get(CGAL::vertex_point, faceGraph));
return triangle_from_halfedge<Triangle_3, FaceGraph, typename boost::property_map<FaceGraph, boost::vertex_point_t>::type>(edge, faceGraph, get(boost::vertex_point, faceGraph));
}
@ -45,16 +45,16 @@ size_t edge_index(typename boost::graph_traits<FaceGraph>::halfedge_descriptor h
typedef typename GraphTraits::face_descriptor face_descriptor;
typedef typename GraphTraits::halfedge_descriptor halfedge_descriptor;
face_descriptor f = CGAL::face(he, p);
face_descriptor f = face(he, p);
halfedge_descriptor start = CGAL::halfedge(f, p);
halfedge_descriptor start = halfedge(f, p);
halfedge_descriptor current = start;
size_t count = 0;
while (current != he)
{
current = CGAL::next(current, p);
current = next(current, p);
++count;
}

View File

@ -14,13 +14,16 @@
#include <CGAL/Polyhedron_3.h>
#include <CGAL/IO/Polyhedron_iostream.h>
#include <CGAL/boost/graph/properties_Polyhedron_3.h>
#include <CGAL/boost/graph/graph_traits_Polyhedron_3.h>
#include <CGAL/Polyhedron_shortest_path/Polyhedron_shortest_path_traits.h>
#include <CGAL/Polyhedron_shortest_path/Polyhedron_shortest_path.h>
#include <CGAL/Polyhedron_shortest_path/Internal/function_objects.h>
#include <CGAL/Polyhedron_shortest_path/Internal/Barycentric.h>
#include <CGAL/Polyhedron_shortest_path/Internal/misc_functions.h>
#include <CGAL/boost/graph/graph_traits_Polyhedron_3.h>
#include <CGAL/boost/graph/iterator.h>
#include <CGAL/Random.h>

View File

@ -28,6 +28,10 @@ int main(int argc, char** argv )
else
OpenMesh::IO::read_mesh(mesh, "data/cactus.off");
std::cout << "#F : " << num_faces(mesh) << std::endl;
std::cout << "#H : " << num_halfedges(mesh) << std::endl;
std::cout << "#V : " << num_vertices(mesh) << std::endl;
// create a property-map for SDF values
typedef std::map<face_descriptor, double> Facet_double_map;
Facet_double_map internal_sdf_map;