Jpp  15.0.1-rc.1-highQE
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JPhotonPathIO.cc File Reference
#include <iostream>
#include <fstream>
#include "TRandom3.h"
#include "JMarkov/JPhotonPath.hh"
#include "JMarkov/JPhotonPathReader.hh"
#include "JMarkov/JPhotonPathWriter.hh"

Go to the source code of this file.

Functions

void printPolyline (JPolyline3D &pl)
 
int main (int argc, char **argv)
 

Function Documentation

void printPolyline ( JPolyline3D pl)

Definition at line 13 of file JPhotonPathIO.cc.

13  {
14  for( int i=0 ; i<(int)pl.size()-1 ; ++i )
15  cout << "(" << pl[i] << ")-" ;
16  if( pl.size()>0 ) cout << "(" << pl.back() << ")" ;
17 }
int main ( int  argc,
char **  argv 
)

Definition at line 25 of file JPhotonPathIO.cc.

25  {
26  // initialization
27  TRandom* ran = new TRandom3(0) ;
28  const int npaths = 5 ;
29  char fname[100] = "out.paths" ;
30 
31  // write some example paths to a file
32  cout << "Writing some example paths to '" << fname << "'." << endl ;
33 
35  writer.open(fname) ;
36  for( int n=0 ; n<npaths ; ++n ) {
37  // create path
38  int nscat = ran->Integer(6) ; // how often the photon scatters
39  JPhotonPath path(nscat) ;
40  // loop over the vertices
41  for( JPhotonPath::iterator it=path.begin() ; it!=path.end() ; ++it ) {
42  double x = ran->Integer(50) ;
43  double y = ran->Integer(50) ;
44  double z = ran->Integer(50) ;
45  it->setPosition( JGEOMETRY3D::JVector3D(x,y,z) ) ;
46  }
47  // print the path
48  printPolyline( path ) ;
49  cout << endl ;
50  // write the path
51  writer.put(path) ;
52  }
53  writer.close() ;
54  cout << endl ;
55 
56  // read paths from a file
58  reader.open("out.paths") ;
59 
60  int nread = 0 ;
61  JPhotonPath* p = NULL ;
62  cout << "Reading file" << endl ;
63  while( reader.hasNext() ) {
64  p = reader.next() ;
65  printPolyline( *p ) ;
66  cout << endl ;
67  ++nread ;
68  }
69 
70  cout << "Done reading file. Read " << nread << " paths from it." << endl ;
71  cout << endl ;
72  cout << "Done!" << endl ;
73 
74  return 0 ;
75 }
virtual void open(const char *file_name) override
Open file.
virtual void open(const char *file_name) override
Open file.
virtual bool hasNext() override
Check availability of next element.
virtual const pointer_type & next() override
Get next element.
A photon path.
Definition: JPhotonPath.hh:38
const int n
Definition: JPolint.hh:660
$WORKDIR driver txt done cat $WORKDIR driver txt<< EOFprocess ${DATAFILTER}$FILTER_HOST csh-c '(setenv ROOTSYS $ROOTSYS &&source $JPP_DIR/setenv.csh $JPP_DIR &&JDataFilter-H\$SERVER\$-M\$LOGGER\$-d $DEBUG-u ${DATAFILTER}-P $PORT</dev/null > &/dev/null)&';process ${DATAWRITER}$WRITER_HOST csh-c '(setenv ROOTSYS $ROOTSYS &&source $JPP_DIR/setenv.csh $JPP_DIR &&JDataWriter-H\$SERVER\$-M\$LOGGER\$-d $DEBUG-u ${DATAWRITER}</dev/null > &/dev/null)&';print enterevent ev_init{RC_CMD}event ev_reset{RC_CMD}event ev_init{RC_CMD}event ev_configure{RC_DFLTR%<$WORKDIR/ev_configure_datafilter.txt > RC_DOM<$WORKDIR/ev_configure_domsimulator.txt > RC_DWRT path
Data structure for vector in three dimensions.
Definition: JVector3D.hh:34
virtual bool put(const T &object) override
Object output.
virtual void close()
Close file.
void printPolyline(const JPolyline3D &pl)
Definition: JPolyline3D.cc:8