Transform only specific vertices of a Polyhedron_3

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Transform only specific vertices of a Polyhedron_3

SirM2X
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<int> 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 : )
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Transform only specific vertices of a Polyhedron_3

SirM2X
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... :(
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Transform only specific vertices of a Polyhedron_3

Padraig O Conbhui
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 <[hidden email]> 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



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Transform only specific vertices of a Polyhedron_3

SirM2X
Thanks for your response...
Although that works, it gives me the exact results as the one which I posted the pseudocode for...

Somehow I have a feeling that once the points are assigned, the polygon's faces are not updated, or are messed up somehow.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Transform only specific vertices of a Polyhedron_3

Padraig O Conbhui
Maybe if you get the vertex from the HalfedgeDS object using a Modifier_base class instead of from the polyhedron?

On Fri, Dec 2, 2016 at 3:54 PM, SirM2X <[hidden email]> wrote:
Thanks for your response...
Although that works, it gives me the exact results as the one which I posted
the pseudocode for...

Somehow I have a feeling that once the points are assigned, the polygon's
faces are not updated, or are messed up somehow.



--
View this message in context: http://cgal-discuss.949826.n4.nabble.com/Transform-only-specific-vertices-of-a-Polyhedron-3-tp4662402p4662412.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



Loading...