Transform only specific vertices of a Polyhedron_3

5 messages
Open this post in threaded view
|

Transform only specific vertices of a Polyhedron_3

 Given a polyhedron that was generated by a convex hull, my task is to use a black box optimization algorithm to find a translation transform that when applied to a specific set of points of the polyhedron, an objective function is minimized. Obviously, one approach is to regenerate the convex hull for every generated translation. However, convex hull computation is slow, and also we know a-priori that only a subset of the convex hull's points need to be modified to minimize the objective function. So I thought, I'd generate the convex hull once, use std::transform to modify a subset of the polyhedron's points, and then compute the objective function. Something like this: ```set specificSetOfPoints; . . // Store the index of the points of interest in the set defined above . void compute(Vector translate) { // Clone the polyhedron -- cHull is the pre-computed convex hull Polyhedron currPoly = Polyhedron(cHull); int index = -1; std::transform(currPoly.points_begin(), currPoly.points_end(), currPoly.points_begin(), [this, &translate, &index](Polyhedron::Point_3& p) { index++; // Does this point belong to the specific set of points? if (this->specificSetOfPoints.count(index)) return Polyhedron::Point_3(p.x() + translate.x(), p.y() + translate.y(), p.z() + translate.z()); // Do nothing return Polyhedron::Point_3(p.x(), p.y(), p.z()); }); float objective = objectiveFunction(currPoly); }```However, the above code results in different objective function values compared to the case where I recompute the convex hull every compute() call. Is there an easy way to apply the translation trasnform to a subset of the points of the polyhedron object? Thanks in advance : )
Open this post in threaded view
|

Re: Transform only specific vertices of a Polyhedron_3

 Anyone...? I feel there is an easy way to transform the vertices of a polyhedron in-place, and I'm missing it... There is vertex.point.transform() but, it returns a new point, and I'm not sure if I can modify the original vertex with this transformed point... :(
Open this post in threaded view
|

Re: Transform only specific vertices of a Polyhedron_3

 You can do vertex_handle->point() = vertex_handle->point().transform(...) since vertex.point() returns a reference type.On Fri, Dec 2, 2016 at 3:21 PM, SirM2X wrote:Anyone...? I feel there is an easy way to transform the vertices of a polyhedron in-place, and I'm missing it... There is /vertex.point.transform()/ but, it returns a new point, and I'm not sure if I can modify the original vertex with this transformed point... :( -- View this message in context: http://cgal-discuss.949826.n4.nabble.com/Transform-only-specific-vertices-of-a-Polyhedron-3-tp4662402p4662410.html Sent from the cgal-discuss mailing list archive at Nabble.com. -- You are currently subscribed to cgal-discuss. To unsubscribe or access the archives, go to https://sympa.inria.fr/sympa/info/cgal-discuss