Subject: CGAL users discussion list
List archive
- From: tina rumi <>
- To:
- Subject: Re: [cgal-discuss] error in using CGAL::grid_simplify_point_set
- Date: Wed, 9 Dec 2009 13:08:22 -0500
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=An7YePaT98tuuVEt81bCqBCXtOOWg90+YXssUr3XLnkihAkxBvKhINQUeO1vfJvpC6 Utuj5b0FgYKCU0hxrE+/XYnqq76lPeMBI1qM1trSYOPmhoaqYuY7A+vKt4HuCsm97QDY D85dcBO90Sj+3tqWG57l5B+tB4XM28HXnUzxk=
Thanks Nader and Laurent,
actually, it didn't work again. my data doesn't include normal , so I have to read just x,y and z then produce the normal with cgal function. I am using vector for the data type also , I put the list in the comment , so I don't think bug is related to that. I will copy my code here again. I copy my code here, I really appriciate if you can help me. I test my code part by part and the problem is in the simplification part.
Nader, we define FT in the code but never use it, do we need it here?
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/property_map.h>
#include <CGAL/remove_outliers.h>
#include <CGAL/IO/read_xyz_points.h>
#include <CGAL/grid_simplify_point_set.h>
#include <CGAL/jet_smooth_point_set.h>
#include <CGAL/pca_estimate_normals.h>
#include <CGAL/mst_orient_normals.h>
#include <CGAL/property_map.h>
#include <CGAL/IO/write_xyz_points.h>
#include <vector>
#include <fstream>
#include <utility> // defines std::pair
#include <list>
// types
// kernel
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
// Simple geometric types
typedef Kernel::FT FT;
typedef Kernel::Point_3 Point;
typedef Kernel::Vector_3 Vector;
// Point with normal vector stored in a std::pair.
typedef std::pair<Point, Vector> PointVectorPair;
typedef std::vector<PointVectorPair> PointList;
int main(void)
{
PointList points; // Type of input point set
// Reads a .xyz point set file in points[].
// The Dereference_property_map property map can be omitted here as it is the default value.
//std::list<PointVectorPair> points;
std::ifstream stream("../data/sphere.xyz");
if (!stream ||
!CGAL::read_xyz_points(stream, std::back_inserter(points),
CGAL::First_of_pair_property_map<PointVectorPair>()
))
{
std::cerr << "Error: cannot read file data" << std::endl;
return EXIT_FAILURE;
}
// Removes outliers using erase-remove idiom.
// The Dereference_property_map property map can be omitted here as it is the default value.
const double removed_percentage = 5.0; // percentage of points to remove
const int nb_neighbors = 24; // considers 24 nearest neighbor points
points.erase(CGAL::remove_outliers(points.begin(), points.end(),
CGAL::Dereference_property_map<Point>(),
nb_neighbors, removed_percentage),
points.end());
// Optional: after erase(), use Scott Meyer's "swap trick" to trim excess capacity
PointList(points).swap(points);
// simplification by clustering using erase-remove idiom
double cell_size = 0.001;
PointList::iterator unwanted_points_begin = CGAL::grid_simplify_point_set(points.begin(), points.end(), CGAL::First_of_pair_property_map<PointVectorPair>(), cell_size);
// delete unwanted points
points.erase(unwanted_points_begin , points.end());
// Optional: after erase(), use Scott Meyer's "swap trick" to trim excess capacity
PointList(points).swap(points);
// Smoothing.
const unsigned int nb_neighbors2 = 8; // default is 24 for real-life point sets
CGAL::jet_smooth_point_set(points.begin(), points.end(), CGAL::First_of_pair_property_map<PointVectorPair>(), nb_neighbors2);
// Estimates normals direction.
// Note: pca_estimate_normals() requires an iterator over points
// as well as property maps to access each point's position and normal.
const int nb_neighbors3 = 18; // K-nearest neighbors = 3 rings
CGAL::pca_estimate_normals(points.begin(), points.end(),
CGAL::First_of_pair_property_map<PointVectorPair>(),
CGAL::Second_of_pair_property_map<PointVectorPair>(),
nb_neighbors3);
// Orients normals.
// Note: mst_orient_normals() requires an iterator over points
// as well as property maps to access each point's position and normal.
PointList::iterator unoriented_points_begin =
CGAL::mst_orient_normals(points.begin(), points.end(),
CGAL::First_of_pair_property_map<PointVectorPair>(),
CGAL::Second_of_pair_property_map<PointVectorPair>(),
nb_neighbors);
// Optional: delete points with an unoriented normal
// if you plan to call a reconstruction algorithm that expects oriented normals.
points.erase(unoriented_points_begin, points.end());
// Optional: after erase(), use Scott Meyer's "swap trick" to trim excess capacity
PointList(points).swap(points);
// Saves point set.
// Note: write_xyz_points_and_normals() requires an output iterator
// over points as well as property maps to access each
// point position and normal.
std::ofstream out("out_normal.xyz");
if (!out ||
!CGAL::write_xyz_points_and_normals(
out, points.begin(), points.end(),
CGAL::First_of_pair_property_map<PointVectorPair>(),
CGAL::Second_of_pair_property_map<PointVectorPair>()))
{
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
Thank you,
Tina
On Wed, Dec 9, 2009 at 4:33 AM, Nader Salman <> wrote:
Hi Laurent,
i read Tina's code but culdn't answer yesterday.
Here are the quick remarks:
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/property_map.h>#include <CGAL/IO/read_xyz_points.h>#include <CGAL/grid_simplify_point_set.h>
#include <CGAL/property_map.h>
#include <vector>#include <list> // IMPORTANT : This method modifies the order of input
#include <fstream>
#include <utility> // defines std::pair
// points so as to pack all remaining points first,
// and returns an iterator over the first point to remove
// (see erase-remove idiom). For this reason it should not
// be called on sorted containers.
// typesint main(void)
// kernel
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
// Simple geometric types
typedef Kernel::FT FT;
typedef Kernel::Point_3 Point;
typedef Kernel::Vector_3 Vector;
// Point with normal vector stored in a std::pair.
typedef std::pair<Point, Vector> PointVectorPair;
typedef std::vector<PointVectorPair> PointList;
{
PointList points; // Type of input point set
// Reads a .xyz point set file in points[].Bug std::list<PointVectorPair> points; // Check important notice higher and redefinition here...
// The Dereference_property_map property map can be omitted here as it is the default value.
std::ifstream stream("../data/kitten.xyz");
Bug CGAL::read_xyz_points// if you want to read the normals you should use the correct function
if (!stream ||
!CGAL::read_xyz_points_and_normals(stream, std::back_inserter(points),
CGAL::First_of_pair_property_map<PointVectorPair>(),
CGAL::Second_of_pair_property_map<PointVectorPair>()))
{
std::cerr << "Error: cannot read file data" << std::endl;
return EXIT_FAILURE;
}// simplification by clustering using erase-remove idiom
double cell_size = 0.001;
PointList::iterator unwanted_points_begin =
CGAL::grid_simplify_point_set(points.begin(), points.end(),
CGAL::First_of_pair_property_map<PointVectorPair>(), cell_size);
// delete unwanted points
points.erase(unwanted_points_begin , points.end());
// Optional: after erase(), use Scott Meyer's "swap trick" to trim excess capacity
PointList(points).swap(points);
out, points.begin(), points.end(),
// Saves point set.
// Note: write_xyz_points_and_normals() requires an output iterator
// over points as well as property maps to access each
// point position and normal.
std::ofstream out("out_normal.xyz");
if (!out ||
!CGAL::write_xyz_points_and_normals(
CGAL::First_of_pair_property_map<PointVectorPair>(),CGAL::Second_of_pair_property_map<PointVectorPair>()))Cheers,
{
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
Nader S.
Laurent Saboret a écrit :Hi Tina,
Could you please post your complete code, so we can try to reproduce the compilation error below.
Best regards,
Laurent Saboret
tina rumi wrote:Hi Nad,
Thanks a lot for your help. I am getting another error when I am running your code. here is the error that I got:
1>Compiling...
1>cloud_points.cpp
1>c:\cgal\cgal-3.5\include\cgal\grid_simplify_point_set.h(61) : error C2039: 'x' : is not a member of 'std::pair<_Ty1,_Ty2>'
1> with
1> [
1> _Ty1=Point,
1> _Ty2=Vector
1> ]
1> c:\cgal\cgal-3.5\include\cgal\grid_simplify_point_set.h(59) : while compiling class template member function 'bool CGAL::CGALi::Less_epsilon_points_3<Point_3>::operator ()(const Point_3 &,const Point_3 &) const'
1> with
1> [
1> Point_3=Enriched_point
1> ]
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\set(48) : see reference to class template instantiation 'CGAL::CGALi::Less_epsilon_points_3<Point_3>' being compiled
1> with
1> [
1> Point_3=Enriched_point
1> ]
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\xtree(22) : see reference to class template instantiation 'std::_Tset_traits<_Kty,_Pr,_Alloc,_Mfl>' being compiled
1> with
1> [
1> _Kty=Enriched_point,
1> _Pr=CGAL::CGALi::Less_epsilon_points_3<Enriched_point>,
1> _Alloc=std::allocator<PointVectorPair>,
1> _Mfl=false
1> ]
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\xtree(63) : see reference to class template instantiation 'std::_Tree_nod<_Traits>' being compiled
1> with
1> [
1> _Traits=std::_Tset_traits<Enriched_point,CGAL::CGALi::Less_epsilon_points_3<Enriched_point>,std::allocator<PointVectorPair>,false>
1> ]
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\xtree(89) : see reference to class template instantiation 'std::_Tree_ptr<_Traits>' being compiled
1> with
1> [
1> _Traits=std::_Tset_traits<Enriched_point,CGAL::CGALi::Less_epsilon_points_3<Enriched_point>,std::allocator<PointVectorPair>,false>
1> ]
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\xtree(107) : see reference to class template instantiation 'std::_Tree_val<_Traits>' being compiled
1> with
1> [
1> _Traits=std::_Tset_traits<Enriched_point,CGAL::CGALi::Less_epsilon_points_3<Enriched_point>,std::allocator<PointVectorPair>,false>
1> ]
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\set(57) : see reference to class template instantiation 'std::_Tree<_Traits>' being compiled
1> with
1> [
1> _Traits=std::_Tset_traits<Enriched_point,CGAL::CGALi::Less_epsilon_points_3<Enriched_point>,std::allocator<PointVectorPair>,false>
1> ]
1> c:\cgal\cgal-3.5\include\cgal\grid_simplify_point_set.h(99) : see reference to class template instantiation 'std::set<_Kty,_Pr>' being compiled
1> with
1> [
1> _Kty=Enriched_point,
1> _Pr=CGAL::CGALi::Less_epsilon_points_3<Enriched_point>
1> ]
1> c:\cgal\cgal-3.5\include\cgal\grid_simplify_point_set.h(154) : see reference to class template instantiation 'CGAL::Epsilon_point_set_3<Point_3>' being compiled
1> with
1> [
1> Point_3=Enriched_point
1> ]
1> c:\cgal\cgal-3.5\include\cgal\grid_simplify_point_set.h(190) : see reference to function template instantiation 'ForwardIterator CGAL::grid_simplify_point_set<ForwardIterator,PointPMap,CGAL::Filtered_kernel<CK>>(ForwardIterator,ForwardIterator,PointPMap,double,const Kernel &)' being compiled
1> with
1> [
1> ForwardIterator=std::_Vector_iterator<PointVectorPair,std::allocator<PointVectorPair>>,
1> PointPMap=CGAL::First_of_pair_property_map<PointVectorPair>,
1> CK=CGAL::Simple_cartesian<double>,
1> Kernel=CGAL::Filtered_kernel<CGAL::Simple_cartesian<double>>
1> ]
1> f:\fingerprint\codes\cloud_points\cloud_points\cloud_points.cpp(203) : see reference to function template instantiation 'ForwardIterator CGAL::grid_simplify_point_set<std::_Vector_iterator<_Ty,_Alloc>,CGAL::First_of_pair_property_map<Pair>>(ForwardIterator,ForwardIterator,PointPMap,double)' being compiled
1> with
1> [
1> ForwardIterator=std::_Vector_iterator<PointVectorPair,std::allocator<PointVectorPair>>,
1> _Ty=PointVectorPair,
1> _Alloc=std::allocator<PointVectorPair>,
1> Pair=PointVectorPair,
1> PointPMap=CGAL::First_of_pair_property_map<PointVectorPair>
1> ]
1>c:\cgal\cgal-3.5\include\cgal\grid_simplify_point_set.h(62) : error C2039: 'y' : is not a member of 'std::pair<_Ty1,_Ty2>'
1> with
1> [
1> _Ty1=Point,
1> _Ty2=Vector
1> ]
1>c:\cgal\cgal-3.5\include\cgal\grid_simplify_point_set.h(63) : error C2039: 'z' : is not a member of 'std::pair<_Ty1,_Ty2>'
1> with
1> [
1> _Ty1=Point,
1> _Ty2=Vector
1> ]
1>c:\cgal\cgal-3.5\include\cgal\grid_simplify_point_set.h(63) : error C2661: 'std::pair<_Ty1,_Ty2>::pair' : no overloaded function takes 3 arguments
1> with
1> [
1> _Ty1=Point,
1> _Ty2=Vector
1> ]
1>c:\cgal\cgal-3.5\include\cgal\grid_simplify_point_set.h(64) : error C2039: 'x' : is not a member of 'std::pair<_Ty1,_Ty2>'
1> with
1> [
1> _Ty1=Point,
1> _Ty2=Vector
1> ]
1>c:\cgal\cgal-3.5\include\cgal\grid_simplify_point_set.h(65) : error C2039: 'y' : is not a member of 'std::pair<_Ty1,_Ty2>'
1> with
1> [
1> _Ty1=Point,
1> _Ty2=Vector
1> ]
1>c:\cgal\cgal-3.5\include\cgal\grid_simplify_point_set.h(66) : error C2039: 'z' : is not a member of 'std::pair<_Ty1,_Ty2>'
1> with
1> [
1> _Ty1=Point,
1> _Ty2=Vector
1> ]
1>c:\cgal\cgal-3.5\include\cgal\grid_simplify_point_set.h(66) : error C2661: 'std::pair<_Ty1,_Ty2>::pair' : no overloaded function takes 3 arguments
1> with
1> [
1> _Ty1=Point,
1> _Ty2=Vector
1> ]
1>Build log was saved at "file://f:\fingerprint\codes\cloud_points\cloud_points\Debug\BuildLog.htm"
1>cloud_points - 8 error(s), 0 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
Thank you,
Tina
On Tue, Dec 8, 2009 at 12:57 PM, Nader SALMAN <> wrote:
A correction , here you go :
PointList points // Type of input point set
// kernel
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
// Simple geometric types
typedef Kernel::FT FT;
typedef Kernel::Point_3 Point;
typedef Kernel::Vector_3 Vector;
// Point with normal vector stored in a std::pair.
typedef std::pair<Point, Vector> PointVectorPair;
typedef std::vector<PointVectorPair> PointList;
// simplification by clustering using erase-remove idiom
double cell_size = 0.001;PointList::iterator unwanted_points_begin = CGAL::grid_simplify_point_set(points.begin(), points.end(), CGAL::First_of_pair_property_map<PointVectorPair>(), cell_size);
// delete unwanted points
points.erase(unwanted_points_begin , points.end());
PointList(points).swap(points);
// Optional: after erase(), use Scott Meyer's "swap trick" to trim excess capacity
Sorry for the earlier message,
Cheers,
Nad.
Nader SALMAN
Nader SALMAN a écrit :Hi Tina,
thank you for your interest in CGAl and for using the PSP package.
here is how you should do it in general :
// kernel
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
// Simple geometric types
typedef Kernel::FT FT;
typedef Kernel::Point_3 Point;
typedef Kernel::Vector_3 Vector;
// Point with normal vector stored in a std::pair.
typedef std::pair<Point, Vector> PointVectorPair;
typedef std::vector<PointVectorPair> PointList;
CGAL::grid_simplify_point_set(points.begin(), points.end(),
CGAL::First_of_pair_property_map<PointVectorPair>(),
cell_size);
in your case it would be :
// simplification by clustering using erase-remove idiom
double cell_size = 0.001;
points.erase(CGAL::grid_simplify_point_set(points.begin(), points.end(), CGAL::First_of_pair_property_map<PointVectorPair>(), cell_size), points.end());
// Optional: after erase(), use Scott Meyer's "swap trick" to trim excess capacity
std::vector<Point>(points).swap(points);
Hope this helped!
Cheers,
Nad.
Nader SALMAN Geometrica Lab, Byron Y308 INRIA Sophia Antipolis (FRANCE) Tel: +33(0)4 9238 7161 Fax: +33(0)4 9715 5395 http://www-sop.inria.fr/members/Nader.Salman
tina rumi a écrit :Hi all,
I am trying to use following function:
points.erase(CGAL::grid_simplify_point_set(points.begin(), points.end(), cell_size),
points.end());
the type that I am using for points is :
// types
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef Kernel::Point_3 Point;
typedef Kernel::Vector_3 Vector;
// Point with normal vector stored in a std::pair.
typedef std::pair<Point, Vector> PointVectorPair;
std::list<PointVectorPair> points;
but it caused error. I want to keep this type for points. Do you have any suggestion to fix it.
Thank you,
Tina
Ce courrier électronique et toutes les pièces éventuellement jointes qu’il contient sont CONFIDENTIELS et destinés exclusivement à l’usage de leur destinataire. Si une erreur de transmission ou une adresse erronée a mal dirigée ce courrier, merci d’en informer l’expéditeur en lui faisant une réponse par courrier électronique dès réception. Si vous n’êtes pas le destinataire de ce courrier, vous ne devez pas l’utiliser, le conserver, en faire état, le distribuer, le copier, l’imprimer ou en révéler le contenu à une tierce partie. Ce courrier électronique est à usage strictement informatif et ne saurait engager de quelque manière que ce soit INFOTERRA France SAS, ni ses filiales. This e-mail and any attachments hereto are CONFIDENTIAL and intended solely for the use of the addressee. If you have received this e-mail in error please send it back to the person that sent it to you. If you have received it in error, please notify the sender by return email. If you are not the addressee of this email, you must not use, keep, disseminate, copy, print or otherwise deal with it. This email is for information only and will not bind INFOTERRA France SAS in any contract or obligation, nor its subsidiaries.
- [cgal-discuss] error in using CGAL::grid_simplify_point_set, tina rumi, 12/08/2009
- Re: [cgal-discuss] error in using CGAL::grid_simplify_point_set, Nader SALMAN, 12/08/2009
- Re: [cgal-discuss] error in using CGAL::grid_simplify_point_set, Nader SALMAN, 12/08/2009
- Re: [cgal-discuss] error in using CGAL::grid_simplify_point_set, tina rumi, 12/08/2009
- Re: [cgal-discuss] error in using CGAL::grid_simplify_point_set, tina rumi, 12/08/2009
- Re: [cgal-discuss] error in using CGAL::grid_simplify_point_set, Laurent Saboret, 12/09/2009
- Re: [cgal-discuss] error in using CGAL::grid_simplify_point_set, Nader Salman, 12/09/2009
- Re: [cgal-discuss] error in using CGAL::grid_simplify_point_set, tina rumi, 12/09/2009
- Re: [cgal-discuss] error in using CGAL::grid_simplify_point_set, Nader SALMAN, 12/10/2009
- Re: [cgal-discuss] error in using CGAL::grid_simplify_point_set, tina rumi, 12/10/2009
- Re: [cgal-discuss] error in using CGAL::grid_simplify_point_set, Nader SALMAN, 12/11/2009
- Re: [cgal-discuss] error in using CGAL::grid_simplify_point_set, tina rumi, 12/11/2009
- Re: [cgal-discuss] error in using CGAL::grid_simplify_point_set, tina rumi, 12/09/2009
- Re: [cgal-discuss] error in using CGAL::grid_simplify_point_set, Nader Salman, 12/09/2009
- Re: [cgal-discuss] error in using CGAL::grid_simplify_point_set, tina rumi, 12/08/2009
- Re: [cgal-discuss] error in using CGAL::grid_simplify_point_set, Nader SALMAN, 12/08/2009
- Re: [cgal-discuss] error in using CGAL::grid_simplify_point_set, Nader SALMAN, 12/08/2009
Archive powered by MHonArc 2.6.16.