Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Offset Plane

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Offset Plane


Chronological Thread 
  • From: "Sebastien Loriot (GeometryFactory)" <>
  • To:
  • Subject: Re: [cgal-discuss] Offset Plane
  • Date: Fri, 27 May 2011 09:29:04 +0200

Try with

CGAL::polyhedron_cut_plane_3(result, he->opposite(), pl3);
instead of
CGAL::polyhedron_cut_plane_3(result, he, pl3);

he->vertex() need to be on the negative side of the plane.

S.

Max Harris wrote:
polyhedron_cut_plane_3() breaks when I try running the code below. What am I doing wrong?

Here's the output:
*Plane: -0 -1 -0 -0*
**
*Normal: -0 -1 -0*
**
*Scaled normal: -0 0.1 -0*
**
*Transformed plane: -0 -1 -0 0.1*
*terminate called after throwing an instance of 'CGAL::Precondition_exception'*
* what(): CGAL ERROR: precondition violation!*
*Expr: pred( h->vertex())*
*File: /usr/local/include/CGAL/polyhedron_cut_plane_3.h*
*Line: 120*

Root::Root()
{
Polyhedron P;
make_cube_3(P);
Facet_iterator f = P.facets_begin(); Plane pl2 = f->plane(); // plane equation of the facet
cout << "Plane: " << pl2 << endl;
CGAL::Vector_3<Kernel> normal = pl2.orthogonal_vector();
cout << "\nNormal: " << normal << endl;
Vector sn = normal.transform(Transformation(CGAL::SCALING, -0.1));
cout << "\nScaled normal: " << sn << endl;
Plane pl3 = pl2.transform(Transformation(CGAL::TRANSLATION, sn));
cout << "\nTransformed plane: " << pl3 << endl;
Polyhedron result;
Halfedge_handle he = make_cube_3(result);
CGAL::polyhedron_cut_plane_3(result, he, pl3);
}


template <class Poly>
typename Poly::Halfedge_handle Root::make_cube_3(Poly& P)
{
// appends a cube of size [0,1]^3 to the polyhedron P.
CGAL_precondition( P.is_valid());
typedef typename Poly::Point_3 Point;
typedef typename Poly::Plane_3 Plane;
typedef typename Poly::Halfedge_handle Halfedge_handle;
Halfedge_handle h = P.make_tetrahedron(Point( 1, 0, 0),
Point( 0, 0, 1),
Point( 0, 0, 0),
Point( 0, 1, 0));
Halfedge_handle g = h->next()->opposite()->next();
P.split_edge( h->next());
P.split_edge( g->next());
P.split_edge( g);
h->next()->vertex()->point() = Point( 1, 0, 1);
g->next()->vertex()->point() = Point( 0, 1, 1);
g->opposite()->vertex()->point() = Point( 1, 1, 0);
Halfedge_handle f = P.split_facet( g->next(), g->next()->next()->next());
Halfedge_handle e = P.split_edge( f);
e->vertex()->point() = Point( 1, 1, 1);
P.split_facet( e, f->next()->next());
CGAL_postcondition( P.is_valid());
g = h;
g->facet()->plane() = Plane( g->vertex()->point(),
g->next()->vertex()->point(),
g->next()->next()->vertex()->point());
g = h->opposite();
g->facet()->plane() = Plane( g->vertex()->point(),
g->next()->vertex()->point(),
g->next()->next()->vertex()->point());
g = h->next()->opposite();
g->facet()->plane() = Plane( g->vertex()->point(),
g->next()->vertex()->point(),
g->next()->next()->vertex()->point());
g = h->next()->next()->opposite();
g->facet()->plane() = Plane( g->vertex()->point(),
g->next()->vertex()->point(),
g->next()->next()->vertex()->point());
g = h->next()->next()->next()->opposite();
g->facet()->plane() = Plane( g->vertex()->point(),
g->next()->vertex()->point(),
g->next()->next()->vertex()->point());
g = g->next()->next()->opposite();
g->facet()->plane() = Plane( g->vertex()->point(),
g->next()->vertex()->point(),
g->next()->next()->vertex()->point());
return h;
}

On May 25, 2011, at 12:47 AM, Marc Glisse wrote:

On Wed, 25 May 2011, harris.max wrote:

I'm trying to get CGAL to generate a plane that's offset by some specifiable
distance from an existing plane, but everything I've tried so far isn't
working. What's the best way to do this?

What did you try that isn't working?

There doesn't seem to be any function to do that directly, but you could for instance use Construct_orthogonal_vector_3 to get a normal vector, scale it to whatever distance you want, then translate the plane?

--
Marc Glisse

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://lists-sop.inria.fr/wws/info/cgal-discuss






Archive powered by MHonArc 2.6.16.

Top of Page