Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] error regarding file stream

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] error regarding file stream


Chronological Thread 
  • From: Ariel Baez <>
  • To:
  • Subject: Re: [cgal-discuss] error regarding file stream
  • Date: Wed, 4 Nov 2009 16:30:29 -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=lwssS3Y5l4DcDD1v3qgpLKZd0j4hMQVPqYa9BSvepimu6GwE/BziLJcEUs54+ACMd2 3TiakT2iVI6pa9DLA07ihaS+Wx6BWZBPT5rSvW5+TwJ939ahC1HCq1/3cfYZGMssIBdr u3UN2g+hdGjHtGJ8rl7EdCZNlhN2ynvxk1bRY=

If I am reading this right its a C++ thing.

See:
http://www.cplusplus.com/reference/iostream/ostream/

with example code for the desired effect here:

http://www.cplusplus.com/reference/iostream/manipulators/setprecision/

Hope this helps.
AB

On Wed, Nov 4, 2009 at 3:05 PM, pratihast22089 <> wrote:

Hi,
Thank you for you quick response and wonderfull suggestion.
It really help for the new developers like me.

I could not get your idea, could you please explain me why it is not
working.
here is my sort version code:


// simple file stream exaple


#include "stdafx.h"
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/property_map.h>
#include <CGAL/IO/read_xyz_points.h>
#include <CGAL/IO/write_xyz_points.h>
#include <CGAL/double.h>

#include <utility> // defines std::pair
#include <vector>
#include <fstream>
#include<iostream>



// types
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef Kernel::Point_3 Point;

using namespace std;

int main(void)
{
   // Reads a .xyz point set file in points[].

   vector<Point> points;
   ifstream in("D:/Cgalcode/file/data/tree.xyz");
   if (!in ||
       !CGAL::read_xyz_points(in,std::back_inserter(points)))
   {
     cerr << "Error: cannot read file data/oni.xyz" << std::endl;
     return EXIT_FAILURE;
   }
 // displaying

       for(unsigned int i = 0; i < points.size(); i++)
   {
               cout.precision(20);
     cout << points[i]<< std::endl;
       }


   // Saves point set.

   ofstream out("D:/Cgalcode/file/data/tree.xyz");
   if (!out ||
       !CGAL::write_xyz_points(out, points.begin(), points.end()))
   {
     return EXIT_FAILURE;
   }

   return EXIT_SUCCESS;
}

input:
 257507.81  471326.84  44.99
 257507.79  471326.90  44.70
 257507.75  471326.93  44.51

output:
257508 471327 44.99
257508 471327 44.7
257508 471327 44.51


Sebastien Loriot wrote:
>
> pratihast22089 wrote:
>> hi,
>>
>> I am facing one simple problem regarding file stream.
>> I have the data file  like this:
>>
>> 257507.75  471326.93  44.51
>>  257507.77  471326.90  44.49
>>  257507.89  471326.93  44.04
>>  257507.81  471326.81  44.51
>>  257507.89  471326.87  44.10
>>
>>
>> While Reading and writing file stream, it  truncate the number behind
>> point
>> of first two columns but not for the third column.
>>
>> output:
>>
>>  257507  471326  44.51
>>  257507  471326  44.49
>>  257507  471326  44.04
>>  257507  471326  44.51
>>  257507  471326  44.10
>>
>>
>> I had included the #include <CGAL/double.h> header file.
>>
>> Could you please help me in this regrads.
>> Thank you in advance.
>>
>> Regards,
>> Arun K Pratihast
>>
>>
>>
>>
> Hello,
>
> Could you please post a minimal example so that we can reproduce the
> problem encountered.
>
>
> S.
>
> --
> You are currently subscribed to cgal-discuss.
> To unsubscribe or access the archives, go to
> https://lists-sop.inria.fr/wws/info/cgal-discuss
>
>
>

--
View this message in context: http://old.nabble.com/error-regarding-file-stream-tp26195935p26203717.html
Sent from the cgal-discuss mailing list archive at Nabble.com.


--
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