Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 #include "starMesh.H"
00030 #include <OpenFOAM/IFstream.H>
00031 
00032 
00033 
00034 void starMesh::readPoints(const scalar scaleFactor)
00035 {
00036     label nPoints = 0;
00037     label maxLabel = -1;
00038 
00039     fileName pointsFileName(casePrefix_ + ".vrt");
00040 
00041     {
00042         IFstream pointsFile(pointsFileName);
00043 
00044         
00045 
00046         if (pointsFile.good())
00047         {
00048             label pointLabel;
00049             scalar x, y, z;
00050 
00051             maxLabel = -1;
00052             while ((pointsFile >> pointLabel).good())
00053             {
00054                 nPoints++;
00055                 maxLabel = max(maxLabel, pointLabel);
00056                 pointsFile >> x >> y >> z;
00057             }
00058         }
00059         else
00060         {
00061             FatalErrorIn("starMesh::readPoints()")
00062                 << "Cannot read file " << pointsFileName
00063                 << abort(FatalError);
00064         }
00065     }
00066 
00067     Info<< "Number of points = " << nPoints << endl << endl;
00068 
00069     points_.setSize(nPoints);
00070     starPointID_.setSize(nPoints);
00071 
00072     
00073     starPointID_ = -1;
00074 
00075     starPointLabelLookup_.setSize(maxLabel+1);
00076 
00077     
00078     starPointLabelLookup_ = -1;
00079 
00080     if (nPoints > 0)
00081     {
00082         
00083         
00084 
00085         IFstream pointsFile(pointsFileName);
00086         label pointLabel;
00087 
00088         forAll(points_, p)
00089         {
00090             pointsFile
00091                 >> pointLabel
00092                 >> points_[p].x()
00093                 >> points_[p].y()
00094                 >> points_[p].z();
00095 
00096             starPointID_[p] = pointLabel;
00097             starPointLabelLookup_[pointLabel] = p;
00098         }
00099 
00100         if (scaleFactor > 1.0 + SMALL || scaleFactor < 1.0 - SMALL)
00101         {
00102             points_ *= scaleFactor;
00103         }
00104     }
00105     else
00106     {
00107         FatalError
00108             << "void starMesh::readPoints() : "
00109             << "no points in file "
00110             << pointsFileName
00111             << abort(FatalError);
00112     }
00113 }
00114 
00115 
00116