Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] "unite" operation in MinKowski_2

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] "unite" operation in MinKowski_2


Chronological Thread 
  • From: "Sebastien Loriot (GeometryFactory)" <>
  • To:
  • Subject: Re: [cgal-discuss] "unite" operation in MinKowski_2
  • Date: Mon, 16 May 2011 08:29:38 +0200

Can you post a complete minimal example showing the problem?

S.

Yue Biek wrote:
Hello,
This time I used the Lazy_exact type for my Point class,but I met problems once more,the problems are discribed as follows.
The Point Class in my code is:
Class MyPoint
{ private:
MP_FT pos[2]; //used to store x and y coordinate public:
MP_FT & x() {return *pos;}
}

I used the following code to show my problem. in main function:
int main()
{
Point p(0.1, 0.2);
MP_FT x = p.x();
std::cout << p.x() << std::endl;
}

but the code show faults:the wrong place is in Interval_nt.h and the code is:
bool is_point() const
{
return sup() == inf();
}
Thank you!

2011/5/13 Efraim Fogel
<

<mailto:>>

You need to use exact-predicate and exact-construction kernel.
When you attach code, attach it in a way that it can be compiled and
executed, and perhaps even read by a human being.


Yue Biek wrote:

My OS is win7(32bit) and environment is VS2008,When I used the
MinKowski_2 in CGAL_3.8, I found the Union operation of two
Boundarys is something wrong.

the function are usd in Minkowski_sum_decomp_2.h
*The exact line is :*
sum_holes = unite(boundary_segments.begin(),
boundary_segments.end(),sum_bound, sum_holes);

My target is to morph between two non-convex but simple polygons.
At first,when I morph between a triangle and a rectangle,the
"unite" operation is right.and the morph process is right.
However,when the input are two non-convex
polygons(PandQ.dat),though the MinKowski sums of the two
polygons can be calcuated, the "unite" operation are something
wrong. when the input are two non convex polygons, the "unite"
operation are right the in the first time,but in the second time
,it fails.

Part of source code are here,Polygon P and Polygon Q are defined
before hand,and they are all non-convex and simple(PandQ.dat).

glClear(GL_COLOR_BUFFER_BIT);
float delt=0.11;
while(true)
{
for(float t=0.1;t<=0.9;t+=delt)
{
glClear(GL_COLOR_BUFFER_BIT);
Polygon s_temp;
Polygon t_temp;

for(size_t i=0;i!=P.size();i++)
{
double temp_x=P[i].x()*(1-t);
double temp_y=P[i].y()*(1-t);
Point temp_p(temp_x,temp_y);
s_temp.push_back(temp_p);
}

for(size_t i=0;i!=Q.size();i++)
{
double temp_x=Q[i].x()*t;
double temp_y=Q[i].y()*t;
Point temp_p(temp_x,temp_y);
t_temp.push_back(temp_p);
}

Polygon_with_holes sum=minkowski_sum_2(s_temp,t_temp,ssab_decomp);
std::cout << "P = "; print_polygon (s_temp);
std::cout << "Q = "; print_polygon (t_temp);
std::cout << "P (+) Q = ";print_polygon(sum.outer_boundary());

if(!sum.is_unbounded())
{
glBegin(GL_LINE_LOOP);
for(Polygon::iterator

cur=sum.outer_boundary().vertices_begin();cur!=sum.outer_boundary().vertices_end();cur++)
{
glVertex2f(cur->x(),cur->y());
}
glEnd();
glFlush();
}
else
{
for (Polygon_with_holes::Hole_iterator
iter=sum.holes_begin();iter!=sum.holes_end();++iter)
{
Polygon::iterator piter=iter->vertices_begin();
glBegin(GL_LINE_LOOP);
for(;piter!=iter->vertices_end();piter++)
{
double temp_x=piter->x();
double temp_y=piter->y();
glVertex2f(temp_x,temp_y);
}
glEnd();
}
}
sum.clear();
s_temp.clear();
t_temp.clear();
if(s_temp.is_empty())
{
cout<<"empty "<<endl;
}
if(t>1.0||t<0.1)
{
delt=-delt;
}
}
}



-- ____ _ ____ _
/_____/_) o /__________ __ //
(____ ( ( ( (_/ (_/-(-'_(/
_/


-- You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://lists-sop.inria.fr/wws/info/cgal-discuss






Archive powered by MHonArc 2.6.16.

Top of Page