Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Error in a file that does not use CGAL classes

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Error in a file that does not use CGAL classes


Chronological Thread 
  • From: "Laurent Rineau (GeometryFactory)" <>
  • To:
  • Subject: Re: [cgal-discuss] Error in a file that does not use CGAL classes
  • Date: Fri, 12 Mar 2010 00:13:23 +0100
  • Organization: GeometryFactory

Le Jeudi 11 Mars 2010 21:26:31, Nicholas Mario Wardhana a écrit :
> Hi all,
>
> We just used CGAL in our project to search for some closest neighbours
> of each waypoint. The code is adopted from :
>
> http://www.cgal.org/Manual/last/doc_html/cgal_manual/Spatial_searching/Chap
> ter_main.html#Subsection_57.3.5
>
> and is adapted according to our situation. Two files that use classes
> from CGAL can compile (with some warnings, but for now I just decided
> to disregard them). There is a problem though: a class that does not
> use any of the CGAL classes fails to compile. I am wondering whether I
> did something wrongly or miss some necessary steps.
>
> Below I include the codes and also the errors that we get. The errors
> appear in GameScene.cpp, which does not use CGAL. I think it includes
> Waypoint.h, which uses CGAL, but if there is something wrong with it,
> the compilation WaypointGenerator.cpp should fail, since it heavily
> relies on the code from Waypoint.h, shouldn't it?
>
> We write our code in Visual Studio 2005 on a machine that runs Windows
> XP. We use CGAL version 3.5 and boost version 1.35. Please let me know
> if further information is needed. Thank you very much.
>
>
> Best regards,
> Nicholas Mario Wardhana
>
>
> ///////////////////////////////////////////////////////////////////////////
> /////////////////////////////////////////
> //////////////////////////////////// code in Waypoint.h starts here
> /////////////////////////////////
>
> //-------------------------------------------------
>
> namespace CGAL {
> template <>
> struct Kernel_traits<Waypoint*> {
> struct Kernel {
> typedef double FT;
> typedef double RT;
> };
> };
> }
>
> //-------------------------------------------------
>
> struct Construct_coord_iterator {
> const float* operator()(Waypoint* const& p) const
> {
> return static_cast<const float*>(p->point_CGAL);
> }
>
> const float* operator()(Waypoint* const& p, int) const
> {
> return static_cast<const float*>(p->point_CGAL+3);
> }
> };
>
> //-------------------------------------------------
>
> struct Distance {
> typedef Waypoint* Query_item;
>
>
> float transformed_distance(Waypoint* const& p1, Waypoint* const& p2)
> const
> { float distx = p1->GetPoint().x - p2->GetPoint().x;
> float disty = p1->GetPoint().y - p2->GetPoint().y;
> float distz = p1->GetPoint().z - p2->GetPoint().z;
> return distx*distx+disty*disty+distz*distz;
> }
>
> template <class TreeTraits>
> float min_distance_to_rectangle(Waypoint* const& p,
> const CGAL::Kd_tree_rectangle<TreeTraits>&
> b) const {
> float distance(0.0), h = p->GetPoint().x;
> if (h < b.min_coord(0)) distance +=
> (b.min_coord(0)-h)*(b.min_coord(0)-h); if (h > b.max_coord(0)) distance +=
> (h-b.max_coord(0))*(h-b.max_coord(0)); h=p->GetPoint().y;
> if (h < b.min_coord(1)) distance +=
> (b.min_coord(1)-h)*(b.min_coord(1)-h); if (h > b.max_coord(1)) distance +=
> (h-b.max_coord(1))*(h-b.min_coord(1)); h=p->GetPoint().z;
> if (h < b.min_coord(2)) distance +=
> (b.min_coord(2)-h)*(b.min_coord(2)-h); if (h > b.max_coord(2)) distance +=
> (h-b.max_coord(2))*(h-b.max_coord(2)); return distance;
> }
>
> template <class TreeTraits>
> float max_distance_to_rectangle(Waypoint* const& p,
> const CGAL::Kd_tree_rectangle<TreeTraits>&
> b) const {
> float h = p->GetPoint().x;
>
> float d0 = (h >= (b.min_coord(0)+b.max_coord(0))/2.0) ?
> (h-b.min_coord(0))*(h-b.min_coord(0))
> :
> (b.max_coord(0)-h)*(b.max_coord(0)-h);
>
> h=p->GetPoint().y;
> float d1 = (h >= (b.min_coord(1)+b.max_coord(1))/2.0) ?
> (h-b.min_coord(1))*(h-b.min_coord(1))
> :
> (b.max_coord(1)-h)*(b.max_coord(1)-h);
> h=p->GetPoint().z;
> float d2 = (h >= (b.min_coord(2)+b.max_coord(2))/2.0) ?
> (h-b.min_coord(2))*(h-b.min_coord(2))
> :
> (b.max_coord(2)-h)*(b.max_coord(2)-h);
> return d0 + d1 + d2;
> }
>
> float new_distance(float& dist, float old_off, float new_off,
> int /* cutting_dimension */) const {
> return dist + new_off*new_off - old_off*old_off;
> }
>
> float transformed_distance(double d) const { return d*d; }
>
> float inverse_of_transformed_distance(double d) { return std::sqrt(d); }
>
> }; // end of struct Distance
>
> //////////////////////////////////// code in Waypoint.h ends here
> ///////////////////////////////////
> ///////////////////////////////////////////////////////////////////////////
> /////////////////////////////////////////
>
> ///////////////////////////////////////////////////////////////////////////
> /////////////////////////////////////////
> //////////////////////////////////// Code in WaypointGenerator.cpp starts
> here ///////////////
>
> typedef CGAL::Search_traits<float, Waypoint*, const float*,
> Construct_coord_iterator> Traits;
> typedef CGAL::Orthogonal_k_neighbor_search<Traits, Distance >
> K_neighbor_search; typedef K_neighbor_search::Tree Tree;
>
> Tree tree(waypointGraph.begin(),waypointGraph.end());
>
> K_neighbor_search search(tree, leftmostWP, n_i);
>
> for(K_neighbor_search::iterator it = search.begin();
> it != search.end();
> it++)
> {
> // lalalalala...
> }
>
>
> //////////////////////////////////// Code in WaypointGenerator.cpp
> ends here /////////////////
> ///////////////////////////////////////////////////////////////////////////
> /////////////////////////////////////////
>
> ///////////////////////////////////////////////////////////////////////////
> /////////////////////////////////////////
> //////////////////////////////////// Error list starts here
> /////////////////////////////////////////////////
>
> 1>------ Build started: Project: GameFactoryDemo, Configuration: Debug
> Win32 ------
> 1>Compiling...
> 1>GameScene.cpp
> 1>d:\api\cgal-3.5\include\cgal\fpu.h(117) : warning C4091: '' :
> ignored on left of 'const double' when no variable is declared
> 1>d:\api\cgal-3.5\include\cgal\fpu.h(117) : error C2143: syntax error
>
> : missing ';' before 'constant'

Your code in GameScene.cpp (or a header that it uses) defines a macro named
"infinity" or "HUGE_VAL", and that macro perturbs the code in <CGAL/FPU.h>,
line 117. I guess the problem is the name "infinity".

--
Laurent Rineau, PhD
Release Manager of the CGAL Project http://www.cgal.org/
R&D Engineer at GeometryFactory http://www.geometryfactory.com/



Archive powered by MHonArc 2.6.16.

Top of Page