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: Max Harris <>
  • To:
  • Subject: Re: [cgal-discuss] Offset Plane
  • Date: Thu, 26 May 2011 15:57:10 -0500
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:mime-version:content-type:subject:date:in-reply-to:to :references:message-id:x-mailer; b=D7aWiIdoOfDENmAqAttBnuPLdBk70nhQvA7c0I2B+Psfelg1rLh1LFSf0Y0fQrlZym hU6s7i8sOTtPlhsaXROu26T9EhtC+txT9pTt9FpfqGBo+Rq6Hua5BWrl6qEm833ahGaf AI73a5pB66p6vRxVTD6TGsgsnvX2PxNzBjax8=

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(Point100),
   Point001),
   Point000),
   Point010));
    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()     = Point101);
    g->next()->vertex()->point()     = Point011);
    g->opposite()->vertex()->point() = Point110);
    Halfedge_handle f = P.split_facet( g->next(), g->next()->next()->next());
    Halfedge_handle e = P.split_edge( f);
    e->vertex()->point() = Point111);
    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