本文整理汇总了C++中Triangulation::is_valid方法的典型用法代码示例。如果您正苦于以下问题:C++ Triangulation::is_valid方法的具体用法?C++ Triangulation::is_valid怎么用?C++ Triangulation::is_valid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Triangulation
的用法示例。
在下文中一共展示了Triangulation::is_valid方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main( )
{
std::cout << "insertion of 1000 random points" << std::endl;
Triangulation t;
CGAL::Random_points_in_square_2<Point, Creator> g(1.);
CGAL::cpp11::copy_n( g, 1000, std::back_inserter(t));
//verbose mode of is_valid ; shows the number of vertices at each level
std::cout << "The number of vertices at successive levels" << std::endl;
assert(t.is_valid(true));
return 0;
}
示例2: Point
int
main( )
{
Triangulation cdt;
std::cout << "Inserting a grid 5 x 5 of constraints " << std::endl;
for (int i = 1; i < 6; ++i)
cdt.insert_constraint( Point(0,i), Point(6,i));
for (int j = 1; j < 6; ++j)
cdt.insert_constraint( Point(j,0), Point(j,6));
int count = 0;
for (Triangulation::Subconstraint_iterator scit = cdt.subconstraints_begin();
scit != cdt.subconstraints_end();
++scit) ++count;
std::cout << "The number of resulting constrained edges is ";
std::cout << count << std::endl;
//verbose mode of is_valid ; shows the number of vertices at each level
std::cout << "The number of vertices at successive levels" << std::endl;
assert(cdt.is_valid(true));
return 0;
}
示例3: main
int main()
{
Triangulation t;
Random random(1284141159);
std::cout << "Seed: " << random.get_seed () << std::endl;
// Random_points_in_square g(0.495, random);
Random_points_on_circle g(0.495, random);
Vector midpoint(0.5, 0.5);
for (int i = 0; i < N_PTS; ++i)
{
t.insert(*(++g) + midpoint);
}
if (!t.is_valid(true))
{
std::cout << "l:" << __LINE__ << std::endl;
std::exit(1);
}
return 0;
}
示例4: main
int main()
{
Random random(1284141159);
Random_points_in_square g(0.495, random);
Vector midpoint(0.5, 0.5);
#if 0
// Should take 5 seconds on the iMac
std::vector<Point> pts;
pts.resize(500000);
for (size_t i = 0; i < pts.size(); ++i) pts[i] = *(++g) + midpoint;
Gt gt;
for (size_t i = 0; i < pts.size() - 2; ++i) gt.orientation_2_object()(pts[i], pts[i + 1], pts[i + 2]);
return 0;
#endif
std::cout << "i" << ", \t"
<< "total time" << ", \t"
<< "total_time cumm" << ", \t"
<< "locate_time" << ", \t" << "insert_time" << ", \t"
<< "periodic_insert_time" << ", \t" << "periodic_insert_time" << std::endl;
// First run is for heating up the CPU, don't output the stats
for (int run = 0; run < N_RUNS; ++run)
{
// Reset timings
total_time = 0.0;
locate_time = 0.0;
insert_time = 0.0;
periodic_locate_time = 0.0;
periodic_insert_time = 0.0;
#ifdef PERIODIC
Triangulation t;
const bool insert_periodic_copies = false;
#else
EuclideanTriangulation t;
const bool insert_periodic_copies = false;
#endif
std::clock_t start_time = std::clock();
// Do one additional point to get the statistics right
for (int i = 0; i <= N_PTS; ++i)
{
Point p = *(++g) + midpoint;
t.insert(p);
if (insert_periodic_copies)
{
for (int x = 0; x < 3; ++x)
{
for (int y = 0; y < 3; ++y)
{
if (x + y > 0)
{
t.insert(p + Vector(x, y));
}
}
}
}
if (i % 500 == 0)
{
std::cout << i << ", \t"
<< (std::clock() - start_time) / (double)CLOCKS_PER_SEC << ", \t"
<< total_time << ", \t"
<< locate_time << ", \t" << insert_time << ", \t"
<< periodic_insert_time << ", \t" << periodic_insert_time << std::endl;
}
}
CGAL_assertion(t.is_valid());
std::cout << std::endl;
}
return 0;
}
示例5: main
int main()
{
Triangulation t;
Face_handle fh;
// Check the empty triangulation
fh = test_point_location(t, Point(0.5, 0.5), Triangulation::EMPTY);
CGAL_assertion(fh == Face_handle());
// Insert the first point
Point p0(0.5, 0.5);
Vertex_handle vh0 = t.insert(p0);
CGAL_assertion(t.is_valid(true));
CGAL_USE(vh0);
fh = test_point_location(t, p0, Triangulation::VERTEX);
CGAL_assertion(fh->has_vertex(vh0));
fh = test_point_location(t, p0 + Vector(0.1, 0.1), Triangulation::EDGE);
CGAL_assertion(fh->has_vertex(vh0));
fh = test_point_location(t, p0 + Vector(-0.1, -0.1), Triangulation::EDGE);
CGAL_assertion(fh->has_vertex(vh0));
fh = test_point_location(t, p0 + Vector(-0.2, -0.3), Triangulation::FACE);
CGAL_assertion(fh->has_vertex(vh0));
CGAL_assertion(t.is_valid(true));
// Insert the second point on an edge
Point p1(0.7, 0.7);
Vertex_handle vh1 = t.insert(p1);
CGAL_USE(vh1);
CGAL_assertion(t.is_valid(true));
fh = test_point_location(t, p0, Triangulation::VERTEX);
CGAL_assertion(fh->has_vertex(vh0));
fh = test_point_location(t, p1, Triangulation::VERTEX);
CGAL_assertion(fh->has_vertex(vh1));
fh = test_point_location(t, p0 + Vector(0.1, 0.1), Triangulation::EDGE);
CGAL_assertion(fh->has_vertex(vh0));
CGAL_assertion(fh->has_vertex(vh1));
fh = test_point_location(t, p0 + Vector(-0.1, -0.1), Triangulation::EDGE);
CGAL_assertion(fh->has_vertex(vh0));
CGAL_assertion(!fh->has_vertex(vh1));
fh = test_point_location(t, p1 + Vector(0.1, 0.1), Triangulation::EDGE);
CGAL_assertion(!fh->has_vertex(vh0));
CGAL_assertion(fh->has_vertex(vh1));
fh = test_point_location(t, p0 + Vector(-0.02, -0.03), Triangulation::FACE);
CGAL_assertion(fh->has_vertex(vh0));
fh = test_point_location(t, p1 + Vector(-0.02, -0.03), Triangulation::FACE);
CGAL_assertion(fh->has_vertex(vh1));
CGAL_assertion(t.is_valid(true));
// Insert the third point in a face
Point p2(0.8, 0.6);
Vertex_handle vh2 = t.insert(p2);
CGAL_USE(vh2);
CGAL_assertion(t.is_valid(true));
fh = test_point_location(t, p0, Triangulation::VERTEX);
CGAL_assertion(fh->has_vertex(vh0));
fh = test_point_location(t, p1, Triangulation::VERTEX);
CGAL_assertion(fh->has_vertex(vh1));
fh = test_point_location(t, p2, Triangulation::VERTEX);
CGAL_assertion(fh->has_vertex(vh2));
fh = test_point_location(t, Point(0.6, 0.6), Triangulation::EDGE);
CGAL_assertion(fh->has_vertex(vh0));
CGAL_assertion(fh->has_vertex(vh1));
test_point_location(t, Point(0.7, 0.6), Triangulation::FACE);
test_point_location(t, p0 + Vector(-0.02, -0.03), Triangulation::FACE);
test_point_location(t, p0 + Vector(0.02, -0.03), Triangulation::FACE);
test_point_location(t, p0 + Vector(-0.02, 0.03), Triangulation::FACE);
test_point_location(t, p0 + Vector(0.02, 0.03), Triangulation::FACE);
return 0;
}
示例6: assert
CVCGEOM_NAMESPACE::cvcgeom_t*
pocket_tunnel_fromsurf(const CVCGEOM_NAMESPACE::cvcgeom_t* molsurf, int num_pockets, int num_tunnels ) // input surface data.
{
map<int, cell_cluster> cluster_set;
// int output_seg_count = DEFAULT_OUTPUT_SEG_COUNT;
// robust cocone parameters.
double bb_ratio = DEFAULT_BIGBALL_RATIO;
double theta_ff = M_PI/180.0*DEFAULT_THETA_FF_d;
double theta_if = M_PI/180.0*DEFAULT_THETA_IF_d;
vector<Point> pts_list;
for(int i = 0; i < molsurf->points().size(); i++)
{
float x = molsurf->points()[i][0],
y = molsurf->points()[i][1],
z = molsurf->points()[i][2];
pts_list.push_back(Point(x,y,z));
}
//CGAL::Timer timer;
//timer.start();
// cout <<"list size:" << pts_list.size() << endl;
cerr << "Delaunay ";
Triangulation triang;
triang.insert(pts_list.begin(), pts_list.end());
assert(triang.is_valid());
cerr << "done." << endl;
//cerr << "Time: " << timer.time() << endl; timer.reset();
// ------------------------------------------
// Initialization of all the required fields
// needed for Tight Cocone and Segmentation
// ------------------------------------------
cerr << "Initialization ";
initialize(triang);
cerr << ".";
// compute voronoi vertex
compute_voronoi_vertex_and_cell_radius(triang);
cerr << ". done." << endl;
//cerr << "Time: " << timer.time() << endl; timer.reset();
// ------------------------------------------
// Surface Reconstruction using Tight Cocone
// ------------------------------------------
cerr << "Surface Reconstruction ";
tcocone(DEFAULT_ANGLE, DEFAULT_SHARP, DEFAULT_FLAT, DEFAULT_RATIO, triang);
cerr << " done." << endl;
//cerr << "Time: " << timer.time() << endl; timer.reset();
#ifdef _DEBUG_OUTPUT_
write_wt(triang, "debug_output/temp_recon");
#endif
cerr << "Computing S_MAX ";
double mr = 1.3; // not used in this routine.
vector<int> sorted_smax_index_vector = compute_smax(triang, cluster_set, mr);
cerr << " done." << endl;
// detect pocket, tunnel, void.
cerr << "Computing Pocket-Tunnels ";
detect_handle(triang, cluster_set);
cerr << " done." << endl;
//cerr << "Time: " << timer.time() << endl; timer.reset();
#ifdef _DEBUG_OUTPUT_
// write_handle(triang, cluster_set, sorted_smax_index_vector, output_seg_count, "debug_output/temp_PTV");
#endif
// convert the handles into rawc geometries to be viewed by TexMol.
CVCGEOM_NAMESPACE::cvcgeom_t* PTV;
convert_pocket_tunnel_to_rawc_geometry(&PTV, triang, cluster_set,
sorted_smax_index_vector, num_pockets, num_tunnels);
return PTV;
}
示例7: main
int main()
{
Triangulation t;
Vector midpoint(0.5, 0.5);
Face_handle fh;
Triangulation::Locate_type lt;
int i;
fh = t.locate(Point(0, 0) + midpoint, lt, i);
CGAL_assertion(lt == Triangulation::EMPTY);
Vertex_handle vh_midpoint = t.insert(Point(0, 0) + midpoint);
fh = t.locate(Point(0, 0) + midpoint, lt, i);
CGAL_assertion(lt == Triangulation::VERTEX && fh->vertex(i) == vh_midpoint);
t.remove(vh_midpoint);
CGAL_assertion(t.empty());
// High degree vertex
for (int n = 3; n < 8; ++n)
{
vh_midpoint = t.insert(Point(0, 0) + midpoint);
for (int i = 0; i < n; ++i)
{
t.insert(Point(0.3 * sin(i * 1.0 / n * 2 * M_PI), 0.3 * cos(i * 1.0 / n * 2 * M_PI)) + midpoint);
}
t.remove(vh_midpoint);
CGAL_assertion(t.is_valid(true));
while (!t.empty())
{
t.remove(t.vertices_begin());
CGAL_assertion(t.is_valid(true));
}
}
Random random(1284141159);
std::cout << "Seed: " << random.get_seed () << std::endl;
Random_points_in_square g(0.495, random);
CGAL_assertion(t.is_valid());
std::cout << "Removing first point" << std::endl;
Vertex_handle vh0 = t.insert(Point(0.5, 0.5));
CGAL_assertion(t.is_valid());
t.remove(vh0);
CGAL_assertion(t.is_valid());
CGAL_assertion(t.empty());
{
Random random(1284141159);
std::cout << "Seed: " << random.get_seed () << std::endl;
Random_points_in_square g(0.495, random);
Vector midpoint(0.5, 0.5);
Triangulation t;
CGAL_assertion(t.is_valid());
std::cout << "Removing first point" << std::endl;
Vertex_handle vh0 = t.insert(Point(0.5, 0.5));
CGAL_assertion(t.is_valid());
t.remove(vh0);
CGAL_assertion(t.is_valid());
CGAL_assertion(t.empty());
std::cout << "Inserting random points and removing them." << std::endl;
for (int i = 0; i < N_PTS; ++i)
{
t.insert(*(++g) + midpoint);
}
CGAL_assertion(t.is_valid());
for (int i = 0; i < N_PTS; ++i)
{
// Find a random vertex
Vertex_handle vh = t.locate(*(++g) + midpoint)->vertex(0);
vh = t.get_original_vertex(vh);
t.remove(vh);
CGAL_assertion(t.is_valid());
}
}
return 0;
}
示例8: main
int main(int narg, char** argv)
{
if (narg>1 && (!strcmp(argv[1],"-h") || !strcmp(argv[1],"-?")) )
{
std::cout<<"Usage : voronoi_3 filename"<<std::endl
<<" filename being a fine containing 3D points used to "
<<" compute the Delaunay_triangulation_3."<<std::endl;
return EXIT_FAILURE;
}
std::string filename;
if ( narg==1 )
{
filename=std::string("data/points_3");
std::cout<<"No filename given: use data/points_3 by default."<<std::endl;
}
else
filename=std::string(argv[1]);
// 1) Compute the Delaunay_triangulation_3.
Triangulation T;
std::ifstream iFile(filename.c_str());
if (!iFile)
{
std::cout << "Problem reading file " << filename << std::endl;
return EXIT_FAILURE;
}
std::istream_iterator<Point> begin(iFile), end;
T.insert(begin, end);
CGAL_assertion(T.is_valid(false));
// 2) Convert the triangulation into a 3D lcc.
LCC_3 lcc;
std::map<Triangulation::Cell_handle,
LCC_3::Dart_handle > vol_to_dart;
Dart_handle dh=CGAL::import_from_triangulation_3<LCC_3, Triangulation>
(lcc, T, &vol_to_dart);
std::cout<<"Delaunay triangulation :"<<std::endl<<" ";
lcc.display_characteristics(std::cout) << ", valid="
<< lcc.is_valid() << std::endl;
// 3) Compute the dual lcc.
LCC_3 dual_lcc;
Dart_handle ddh=lcc.dual(dual_lcc, dh);
// Here, dual_lcc is the 3D Voronoi diagram.
CGAL_assertion(dual_lcc.is_without_boundary());
// 4) We update the geometry of dual_lcc by using the std::map
// face_to_dart.
transform_dart_to_their_dual<LCC_3,Triangulation>
(lcc, dual_lcc, vol_to_dart);
set_geometry_of_dual<LCC_3,Triangulation>(dual_lcc, T, vol_to_dart);
// 5) Display the dual_lcc characteristics.
std::cout<<"Voronoi subdvision :"<<std::endl<<" ";
dual_lcc.display_characteristics(std::cout) << ", valid="
<< dual_lcc.is_valid()
<< std::endl;
display_voronoi(dual_lcc, ddh);
return EXIT_SUCCESS;
}