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: Yue Biek <>
  • To:
  • Subject: Re: [cgal-discuss] "unite" operation in MinKowski_2
  • Date: Mon, 16 May 2011 16:45:24 +0800
  • 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=rl1Bcti5IcspBSxnkT4nK5Wo6qHimvptW7xbGI/MVeCgWRT86T6Iq0d+V8i61A/5Hy Grqz83vufaVDtrcQejZcugTYHClpVxZNTyCLVsHLtcb4YW2cyDcIdyqFElYoIz3kmSrk X6RQRzIdt5cziQG7ZoSCNGhlKp+ZmyAgPh2S0=

Dear S.

Maybe I didn't quite clearly describe my problem. I will restate the problem here and include files in the attachment(can be executed in VS2008)for you to reproduce the error.

I need to define a 2d Point class of my own. The objects of this Point class makes up the polygons that are involved in Minkowski Sum computation. 
It looks something like the following:

typedef CGAL::Exact_predicates_exact_constructions_kernel ExactK;
typedef ExactK::FT MP_FT;

class C_Point2
{
private:
MP_FT pos[2];
// other info specific to C_Point2
// ...
// methods required to return cartesion coordinates
}

Also, I defined all the necessary classes for the Point to work with CGAL, i.e. C_Construct_point2, C_Construct_coord_iterator, and most of all, the kernel class C_Kernel. They can be found in the attached files.

I first write a simple demo to test the validity of C_Point2. 

int main()
{
Point p(0.1, 0.2);
MP_FT x = p.x();
std::cout << p.x() << std::endl;
}

However, the problem issued when p.x() executes. I found the error is caused by a test down in to_double() method:
// Interval_nt.h
bool is_point() const
 {
   return sup() == inf();
 }

It seems that it complains the cartesion component of C_Point has different supremum and infimum. If my guess is right, how could this happen?
Really need some pointers here.

Thanks alot!

Sincerely,
Yue.

2011/5/16 Sebastien Loriot (GeometryFactory) <sloriot.ml@gmail.com>
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




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


Attachment: C_Point2.rar
Description: application/rar




Archive powered by MHonArc 2.6.16.

Top of Page