Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] generated .off file has vertices at locations exceeding the original range

Subject: CGAL users discussion list

List archive

[cgal-discuss] generated .off file has vertices at locations exceeding the original range


Chronological Thread 
  • From: sindhu r <>
  • To:
  • Subject: [cgal-discuss] generated .off file has vertices at locations exceeding the original range
  • Date: Mon, 7 Sep 2020 14:28:34 -0400
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None ; spf=Pass ; spf=None
  • Ironport-phdr: 9a23:vZHC1RCT4CyVNwAH4VYYUyQJP3N1i/DPJgcQr6AfoPdwSPvyrsbcNUDSrc9gkEXOFd2Cra4d1ayP6fyrCTVIyK3CmUhKSIZLWR4BhJdetC0bK+nBN3fGKuX3ZTcxBsVIWQwt1Xi6NU9IBJS2PAWK8TW94jEIBxrwKxd+KPjrFY7OlcS30P2594HObwlSizexfLJ/IA+roQnPucQajohvJrsswRbVv3VEfPhby3l1LlyJhRb84cmw/J9n8ytOvv8q6tBNX6bncakmVLJUFDspPXw7683trhnDUBCA5mAAXWUMkxpHGBbK4RfnVZrsqCT6t+592C6HPc3qSL0/RDqv47t3RBLulSwKMSMy/mPKhcxqlK9UrxKvqRJ8zYDJfo+aKOFzfqbBcd4AX2dNQtpdWi5HD4ihb4UPFe0BPeNAoonmplsOqwaxBQmxBOjy0D9Dm3j73bY70+QnCw3JwBYvH8gKsHvKsNX1M6ESXPu6zKnN1zrDbvdW1S3h54jPdxAsuPeBVq9/fsTN00cgDR/FjkmOpoz/OTOYzvoAvmib4ed8Se+ihHIqpgJzrzWh2Mohl4fHi40Jx1zY9ih3z4g4KN63RkN5YdCpEYVcujyGO4ZrQs0vTW9mtSU8x7YbupC7ZDAHxIo7yxPbcfCKcIiF7gj+WOuQIDp0nn1odbO5ih2v60av0Pf8WdOx0FtSripKjN3MtncV2hzW8MeHS/998l6g2TaIygzf8+9ELE81mKbBJJ4hxbkwlpUXsUvdBCP5hEL2jKqOekUl/Oin9fjnb634qpOAM4J4kALzP6Q0lsCiAOk1MxICUmea9Oik0b3s50z5QLFEjv0slanZtYjXJd8apq6/GQNazpws6wy7Dzi4zNQYmn8HIUlKeBKClYfpOlXOLOrkAve4hlSgiC1ryOzePr39HpXNKWDOn6vufbln705Q0Rc8zdFE551IF7EBO+nzV1TqtN3YCx85Kxa7z/zmCNV7zIMeWHiADrWXMKPI4he04bckLOCIIYMUoz3gMOMN5vj0jHZ/l0VOU7Ou2M4MaXa0HukuOQ3NenvqxNwIC2MHog04ZOPvgVyGFzVUYiDhDOoH+jgnBdf+Xs/4TYe3jenZhXbpLthtfmlDT2u0PzLtfoSAVe0LbXvLcMBkmz0AE7OmTt14jEz8hErB07Nia9Hs1GgYuJbkjoUn4uTSkVQz8mUxAZjDlW6KSG5wkyUDQDpkhPkj83w48U+K1O1Du9IdDcZavqobXQIzNJqaxOt/WYj/

Hello,
I am trying to do the following: 
  1. define a set of 3d coordinates describing a surface
  2. compute and orient normals
  3. generate a polyhedral mesh and save it to a .off file for further use.
What I have done so far: I have accomplished all 3, however my polyhedral mesh and my .off file seem incorrect. 

My .off file (attached) was generated using the points and normals from a .xyz file (also attached). The xyz file represents points that span the x-y plane 0 <= (x,y) <= 6, and 0 <= rand(z) <= 0.2. It does not have any holes or islands; it looks like a blanket. My final test case will involve holes and/or islands, but for the moment even this simple example shows something strange about the .off file that I generate using the Poisson reconstruction method.

While the .xyz file contains points respecting the 0 <= (x,y) <= 6, and 0 <= rand(z) <= 0.2 condition, my .off file seems (lines 4, 7, 8 etc..) to have vertices with x,y,z locations that are way off my points specified in the .xyz file. I think I'm using the Poisson reconstruction incorrectly (minimal working code attached). The image of the polyhedral mesh (attached) does not remotely resemble what I hoped for :(.

I'm sorry if it is a basic question, and I would be grateful for any guidance. Thank you!

Regards,
Sindhu R
/*
 * cgal_discuss_v0_minimal_working_code.cpp
 *
 *  Created on: Sep. 3, 2020
 *      Author: sin
 */

#include <stdio.h>
#include <iostream>
#include <utility> // defines std::pair
#include <vector>
#include <fstream>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/poisson_surface_reconstruction.h>
#include <CGAL/IO/read_xyz_points.h>
#include <CGAL/Polygon_mesh_processing/repair.h>
#include <CGAL/draw_polyhedron.h>

typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef Kernel::Point_3 Point;
typedef Kernel::Vector_3 Vector;
typedef std::pair<Point, Vector> Pwn;
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;


int main()
{
	const char* xyz_normal_filename = "/home/sin/cpp_eclipsew/CGAL_test_1/data/cgal_custom_points_with_normals.xyz";
	Polyhedron output_mesh;
	std::vector<Pwn> obstacle_free_room_points_normals;
	std::ifstream stream(xyz_normal_filename);

	if (!stream ||
			!CGAL::read_xyz_points(
					stream,
					std::back_inserter(obstacle_free_room_points_normals),
					CGAL::parameters::point_map(CGAL::First_of_pair_property_map<Pwn>()).
					normal_map(CGAL::Second_of_pair_property_map<Pwn>())))
	{
		std::cerr << "Error: cannot read file " << xyz_normal_filename << std::endl;
	}


	const char* poisson_fname_removed_isolated_vertices =
				"/home/sin/cpp_eclipsew/CGAL_test_1/data/v0_clean_cgal_custom_poisson_points_with_normals.off";

	double average_spacing = CGAL::compute_average_spacing<CGAL::Sequential_tag>
	(obstacle_free_room_points_normals, 6, CGAL::parameters::point_map(CGAL::First_of_pair_property_map<Pwn>()));
	if (CGAL::poisson_surface_reconstruction_delaunay
			(obstacle_free_room_points_normals.begin(), obstacle_free_room_points_normals.end(),
					CGAL::First_of_pair_property_map<Pwn>(),
					CGAL::Second_of_pair_property_map<Pwn>(),
					output_mesh, average_spacing))
	{


		CGAL::Polygon_mesh_processing::remove_isolated_vertices(output_mesh);
		std::ofstream out_cleaned(poisson_fname_removed_isolated_vertices);
		out_cleaned << output_mesh;
		CGAL::draw(output_mesh);

	}
	else
		std::cout << "Failure :( \n";
	std::cout << "Success \n";

	return 1;

}


Attachment: cgal_custom_points_with_normals.xyz
Description: Binary data

Attachment: v0_clean_cgal_custom_poisson_points_with_normals.off
Description: Binary data

Attachment: cgal_v0_6x6_mesh.png
Description: PNG image




Archive powered by MHonArc 2.6.19+.

Top of Page