本文整理匯總了C++中CGAL_assertion函數的典型用法代碼示例。如果您正苦於以下問題:C++ CGAL_assertion函數的具體用法?C++ CGAL_assertion怎麽用?C++ CGAL_assertion使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了CGAL_assertion函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: edge_attached_to
// Returns whether the facet facet is attached to the cell
// that is used to represent facet
bool edge_attached_to(const DT_3& dt, const Edge& edge, const Facet& facet) {
if(dt.is_infinite(facet)) {
return false;
}
Vertex_handle v1 = edge.first->vertex(edge.second);
Vertex_handle v2 = edge.first->vertex(edge.third);
Cell_handle cell = facet.first;
int i1 = facet.second;
int i2 = cell->index(v1);
int i3 = cell->index(v2);
CGAL_assertion(i1!=i2);
CGAL_assertion(i1!=i3);
CGAL_assertion(i2!=i3);
int j = 0;
while(j==i1 || j==i2 || j==i3) {
j++;
}
// j is the index of the third point of the facet
Vertex_handle w = cell->vertex(j);
return CGAL::side_of_bounded_sphere(v1->point(),v2->point(),w->point())==CGAL::ON_BOUNDED_SIDE;
}
示例2: main
int main()
{
const int D = 5; // we work in Euclidean 5-space
const int N = 100; // we will insert 100 points
// - - - - - - - - - - - - - - - - - - - - - - - - STEP 1
CGAL::Random_points_in_cube_d<Triangulation::Point> rand_it(D, 1.0);
std::vector<Triangulation::Point> points;
CGAL::cpp11::copy_n(rand_it, N, std::back_inserter(points));
Triangulation t(D); // create triangulation
CGAL_assertion(t.empty());
t.insert(points.begin(), points.end()); // compute triangulation
CGAL_assertion( t.is_valid() );
// - - - - - - - - - - - - - - - - - - - - - - - - STEP 2
typedef Triangulation::Face Face;
typedef std::vector<Face> Faces;
Faces edges;
std::back_insert_iterator<Faces> out(edges);
t.tds().incident_faces(t.infinite_vertex(), 1, out);
// collect faces of dimension 1 (edges) incident to the infinite vertex
std::cout << "There are " << edges.size()
<< " vertices on the convex hull." << std::endl;
#include "triangulation1.cpp" // See below
#include "triangulation2.cpp"
return 0;
}
示例3: get_free_edge
int get_free_edge(CDT::Face_handle fh)
{
CGAL_assertion( number_of_existing_edge(fh)==2 );
for (int i=0; i<3; ++i)
if (!fh->info().exist_edge[i]) return i;
CGAL_assertion(false);
return -1;
}
示例4: CGAL_assertion
inline
void MP_Float::construct_from_builtin_fp_type(T d)
{
if (d == 0)
return;
// Protection against rounding mode != nearest, and extended precision.
Set_ieee_double_precision P;
CGAL_assertion(is_finite(d));
// This is subtle, because ints are not symetric against 0.
// First, scale d, and adjust exp accordingly.
exp = 0;
while (d < trunc_min || d > trunc_max) {
++exp;
d /= base;
}
while (d >= trunc_min/base && d <= trunc_max/base) {
--exp;
d *= base;
}
// Then, compute the limbs.
// Put them in v (in reverse order temporarily).
T orig = d, sum = 0;
while (true) {
int r = my_nearbyint(d);
if (d-r >= T(base/2-1)/(base-1))
++r;
v.push_back(r);
// We used to do simply "d -= v.back();", but when the most significant
// limb is 1 and the second is -32768, then it can happen that
// |d - v.back()| > |d|, hence a bit of precision can be lost.
// Hence the need for sum/orig.
sum += v.back();
d = orig-sum;
if (d == 0)
break;
sum *= base;
orig *= base;
d *= base;
--exp;
}
// Reverse v.
std::reverse(v.begin(), v.end());
CGAL_assertion(v.back() != 0);
}
示例5: main
int main(){
int N = 3;
CGAL::Timer cost;
std::vector<Point_d> points;
Point_d point1(1,3,5);
Point_d point2(4,8,10);
Point_d point3(2,7,9);
Point_d point(1,2,3);
points.push_back(point1);
points.push_back(point2);
points.push_back(point3);
K Kernel
D Dt(d,Kernel,Kernel);
// CGAL_assertion(Dt.empty());
// insert the points in the triangulation
cost.reset();cost.start();
std::cout << " Delaunay triangulation of "<<N<<" points in dim "<<d<< std::flush;
std::vector<Point_d>::iterator it;
for(it = points.begin(); it!= points.end(); ++it){
Dt.insert(*it);
}
std::list<Simplex_handle> NL = Dt.all_simplices(D::NEAREST);
std::cout << " done in "<<cost.time()<<" seconds." << std::endl;
CGAL_assertion(Dt.is_valid() );
CGAL_assertion(!Dt.empty());
Vertex_handle v = Dt.nearest_neighbor(point);
Simplex_handle s = Dt.simplex(v);
std::vector<Point_d> Simplex_vertices;
for(int j=0; j<=d; ++j){
Vertex_handle vertex = Dt.vertex_of_simplex(s,j);
Simplex_vertices.push_back(Dt.associated_point(vertex));
}
std::vector<K::FT> coords;
K::Barycentric_coordinates_d BaryCoords;
BaryCoords(Simplex_vertices.begin(), Simplex_vertices.end(),point,std::inserter(coords, coords.begin()));
std::cout << coords[0] << std::endl;
return 0;
}
示例6: main
int main(int argc, char **argv)
{
int N = 100; if( argc > 2 )N = atoi(argv[1]); // number of points
CGAL::Timer cost; // timer
// Instanciate a random point generator
CGAL::Random rng(0);
typedef CGAL::Random_points_in_cube_d<T::Point> Random_points_iterator;
Random_points_iterator rand_it(D, 1.0, rng);
// Generate N random points
std::vector<T::Point> points;
CGAL::cpp11::copy_n(rand_it, N, std::back_inserter(points));
T t(D);
CGAL_assertion(t.empty());
// insert the points in the triangulation
cost.reset();cost.start();
std::cout << " Delaunay triangulation of "<<N<<" points in dim "<<D<< std::flush;
t.insert(points.begin(), points.end());
std::cout << " done in "<<cost.time()<<" seconds." << std::endl;
CGAL_assertion( t.is_valid() );
// insert with special operations in conflict zone and new created cells
cost.reset();
std::cout << " adding "<<N<<" other points "<< std::endl;
for(int i=0; i<N; ++i)
{
T::Vertex_handle v;
T::Face f(t.current_dimension());
T::Facet ft;
T::Full_cell_handle c;
T::Locate_type lt;
typedef std::vector<T::Full_cell_handle> Full_cells;
Full_cells zone, new_full_cells;
std::back_insert_iterator<Full_cells> out(zone);
c = t.locate(*++rand_it, lt, f, ft, v);
// previously inserted vertex v is used as hint for point location (if defined)
T::Facet ftc = t.compute_conflict_zone(*rand_it, c, out);
std::cout<<i<<" conflict zone of size "<<zone.size()<<" -> "<<std::flush;
out = std::back_inserter(new_full_cells);
CGAL_assertion( t.is_valid() );
v = t.insert_in_hole(*rand_it, zone.begin(), zone.end(), ftc, out);
std::cout<<new_full_cells.size()<<" new cells"<<std::endl;
}
std::cout << " done in "<<cost.time()<<" seconds." << std::endl;
return 0;
}
示例7: main
int main(int argc, char* argv[]) {
assert(argc>1 && argc < 7);
int nx = argc>2 ? std::atoi(argv[2]) : 2;
int ny = argc>3 ? std::atoi(argv[3]) : 2;
int nz = argc>4 ? std::atoi(argv[4]) : 2;
std::ifstream in(argv[1]);
Nef_polyhedron Nin;
in >> Nin;
Nin.transform(Aff_transformation_3(CGAL::SCALING,2,1));
std::ostringstream out1;
ggen g(out1, Nin);
g.print(nx,ny,nz);
std::istringstream in1(out1.str());
Nef_polyhedron N1;
in1 >> N1;
RT s = g.size_x();
N1.transform(Aff_transformation_3(CGAL::TRANSLATION,Vector_3(s,s,s,2)));
CGAL_assertion(N1.is_valid());
std::ostringstream out2;
CGAL::Random r;
if(argc>5) {
tgen t2(out2,s,std::atoi(argv[5]));
t2.create_tetrahedra(nx+1,ny+1,nz+1);
} else {
tgen t2(out2,s);
t2.create_tetrahedra(nx+1,ny+1,nz+1);
}
std::istringstream in2(out2.str());
Nef_polyhedron N2;
in2 >> N2;
CGAL_assertion(N2.is_valid());
cgal_nef3_timer_on = true;
#if defined CGAL_NEF3_UNION
N1.join(N2);
#elif defined CGAL_NEF3_INTERSECTION
N1.intersection(N2);
#elif defined CGAL_NEF3_DIFFERENCE
N1.difference(N2);
#else
N1.symmetric_difference(N2);
#endif
}
示例8: main
int main()
{
std::vector<Point> points;
points.push_back(Point(0,0));
points.push_back(Point(1,0));
points.push_back(Point(0,1));
points.push_back(Point(4,10));
points.push_back(Point(2,2));
points.push_back(Point(-1,0));
Delaunay T;
T.insert( boost::make_transform_iterator(points.begin(),Auto_count()),
boost::make_transform_iterator(points.end(), Auto_count() ) );
CGAL_assertion( T.number_of_vertices() == 6 );
// check that the info was correctly set.
Delaunay::Finite_vertices_iterator vit;
for (vit = T.finite_vertices_begin(); vit != T.finite_vertices_end(); ++vit)
if( points[ vit->info() ] != vit->point() ){
std::cerr << "Error different info" << std::endl;
exit(EXIT_FAILURE);
}
std::cout << "OK" << std::endl;
return 0;
}
示例9: main
int main() {
Polyhedron P;
Build_triangle<HalfedgeDS> triangle;
P.delegate( triangle);
CGAL_assertion( P.is_triangle( P.halfedges_begin()));
return 0;
}
示例10: merge_cluster
void merge_cluster(map<int, cell_cluster> &cluster_set, int rep1, int rep2)
{
cell_cluster *c_rep1 = &cluster_set[rep1]; // head of cluster 1
cell_cluster *c = &cluster_set[c_rep1->tail]; // tail of cluster 1
CGAL_assertion(c != 0);
CGAL_assertion(c->nxt == NULL);
cell_cluster *c_rep2 = &cluster_set[rep2];
c_rep1->tail = c_rep2->tail;
c->nxt = c_rep2;
while(c->nxt != 0)
{
c->nxt->rep = rep1;
c = c->nxt;
}
}
示例11: add_cell_to_cluster
void add_cell_to_cluster(map<int, cell_cluster> &cluster_set, int rep1, int rep2)
{
cell_cluster *c_rep1 = &cluster_set[rep1]; // pointer to the head of 1st cluster.
cell_cluster *c = &cluster_set[c_rep1->tail]; // pointer to the end of 1st cluster.
CGAL_assertion(c != 0);
CGAL_assertion(c->nxt == NULL);
cell_cluster *c_rep2 = &cluster_set[rep2]; // head of 2nd cluster.
c_rep1->tail = c_rep2->tail;
c->nxt = c_rep2;
while(c->nxt != 0)
{
c->nxt->rep = rep1;
c = c->nxt;
}
}
示例12: main
int main()
{
// Construct the input segments.
Segment_2 segments[] = {Segment_2 (Point_2 (1, 5), Point_2 (8, 5)),
Segment_2 (Point_2 (1, 1), Point_2 (8, 8)),
Segment_2 (Point_2 (3, 1), Point_2 (3, 8)),
Segment_2 (Point_2 (8, 5), Point_2 (8, 8))};
// Compute all intersection points.
std::list<Point_2> pts;
CGAL::compute_intersection_points (segments, segments + 4,
std::back_inserter (pts));
// Print the result.
std::cout << "Found " << pts.size() << " intersection points: " << std::endl;
std::copy (pts.begin(), pts.end(),
std::ostream_iterator<Point_2>(std::cout, "\n"));
// Compute the non-intersecting sub-segments induced by the input segments.
std::list<Segment_2> sub_segs;
CGAL::compute_subcurves(segments, segments + 4, std::back_inserter(sub_segs));
std::cout << "Found " << sub_segs.size()
<< " interior-disjoint sub-segments." << std::endl;
CGAL_assertion (CGAL::do_curves_intersect (segments, segments + 4));
return 0;
}
示例13: main
int main()
{
std::vector< std::pair<Wpoint,unsigned> > points;
points.push_back( std::make_pair(Wpoint(Point(0,0),2),0) );
points.push_back( std::make_pair(Wpoint(Point(1,0),2),1) );
points.push_back( std::make_pair(Wpoint(Point(0,1),2),2) );
points.push_back( std::make_pair(Wpoint(Point(-4,54),2),3) );
points.push_back( std::make_pair(Wpoint(Point(2,2),2),4) );
points.push_back( std::make_pair(Wpoint(Point(-1,0),2),5) );
Regular rt;
rt.insert( points.begin(),points.end() );
CGAL_assertion( rt.number_of_vertices() == 6 );
// check that the info was correctly set.
Regular::Finite_vertices_iterator vit;
for (vit = rt.finite_vertices_begin(); vit != rt.finite_vertices_end(); ++vit)
if( points[ vit->info() ].first != vit->point() ){
std::cerr << "Error different info" << std::endl;
exit(EXIT_FAILURE);
}
std::cout << "OK" << std::endl;
return 0;
}
示例14: Add_Sub
inline
MP_Float
Add_Sub(const MP_Float &a, const MP_Float &b, const BinOp &op)
{
CGAL_assertion(!b.is_zero());
exponent_type min_exp, max_exp;
if (a.is_zero()) {
min_exp = b.min_exp();
max_exp = b.max_exp();
}
else {
min_exp = (std::min)(a.min_exp(), b.min_exp());
max_exp = (std::max)(a.max_exp(), b.max_exp());
}
MP_Float r;
r.exp = min_exp;
r.v.resize(static_cast<int>(max_exp - min_exp + 1)); // One more for carry.
r.v[0] = 0;
for(int i = 0; i < max_exp - min_exp; i++)
{
MP_Float::limb2 tmp = r.v[i] + op(a.of_exp(i+min_exp),
b.of_exp(i+min_exp));
MP_Float::split(tmp, r.v[i+1], r.v[i]);
}
r.canonicalize();
return r;
}
示例15: main
int main(int argc, char* argv[]) {
CGAL_assertion(argc==2);
std::ifstream in1(argv[1]);
Polyhedron P1;
in1 >> P1;
std::transform( P1.facets_begin(), P1.facets_end(), P1.planes_begin(),
Plane_equation());
CGAL_assertion(is_strongly_convex_3(P1));
Gausian_map G1(P1);
G1.visualize();
}