Subject: CGAL users discussion list
List archive
- From: Nicholas Mario Wardhana <>
- To:
- Subject: [cgal-discuss] Error in a file that does not use CGAL classes
- Date: Fri, 12 Mar 2010 04:26:31 +0800
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=MZyLOwdQTVVUtqIidqCPR9r0BdSu04oR2FdGbFSn1CoNOiJCyRN57bMlh0tbnKe5Ui qxDHB9SYpdjhqNbktfUk/5cF2gg3lGxguZsEDQ467fJ7blw0STw7iXMHbuXdDzjb9V/Z 85F7XfGCKgg7IbQrVqU4+whVdoVydTOT7dnQY=
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/Chapter_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'
1>d:\api\cgal-3.5\include\cgal\fpu.h(117) : error C2059: syntax error
: 'constant'
1>d:\api\cgal-3.5\include\cgal\double.h(149) : error C2589: 'constant'
: illegal token on right side of '::'
1>d:\api\cgal-3.5\include\cgal\double.h(149) : error C2059: syntax error :
'::'
1>d:\api\cgal-3.5\include\cgal\double.h(150) : error C2589: 'constant'
: illegal token on right side of '::'
1>d:\api\cgal-3.5\include\cgal\mp_float.h(623) : error C2589:
'constant' : illegal token on right side of '::'
1>d:\api\cgal-3.5\include\cgal\mp_float.h(623) : error C2059: syntax
error : '::'
1>d:\api\cgal-3.5\include\cgal\mp_float.h(624) : error C2589:
'constant' : illegal token on right side of '::'
1>Build log was saved at
"file://d:\nixx\Project\GFA_Work\GameFactoryDemo\Debug\BuildLog.htm"
1>GameFactoryDemo - 8 error(s), 1 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
//////////////////////////////////// Error list ends here
/////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- [cgal-discuss] Error in a file that does not use CGAL classes, Nicholas Mario Wardhana, 03/11/2010
- Re: [cgal-discuss] Error in a file that does not use CGAL classes, Laurent Rineau (GeometryFactory), 03/12/2010
- Re: [cgal-discuss] Error in a file that does not use CGAL classes, Laurent Rineau (GeometryFactory), 03/12/2010
- Re: [cgal-discuss] Error in a file that does not use CGAL classes, Ramin H, 03/12/2010
- Re: [cgal-discuss] Error in a file that does not use CGAL classes, Nicholas Mario Wardhana, 03/12/2010
- Re: [cgal-discuss] Error in a file that does not use CGAL classes, Ramin H, 03/12/2010
Archive powered by MHonArc 2.6.16.