31 void writeOutput(
char* outputFolder, std::vector<Poly> &acceptedPoly, std::vector<IntPoints> &intPts, std::vector<Point> &triplePoints, 
struct Stats &pstats, std::vector<unsigned int> &finalFractures, std::vector<Shape> &shapeFamilies) {
    33     std::string output = outputFolder;
    36     std::string permOutputFile = output + 
"/perm.dat";
    37     std::string 
aperture = output + 
"/aperture.dat";
    38     std::string intersectionFolder = output + 
"/intersections";
    39     std::string radiiFolder = output + 
"/radii/"; 
    48     writeParamsFile(finalFractures, acceptedPoly, shapeFamilies, pstats, triplePoints, output);
    71         std::cout << 
"Writing Accepted Radii Files Per Family\n";
    73         int size = shapeFamilies.size();
    74         for (
int i = 0; i < size; i++) {
    92         std::cout << 
"Writing Final Radii Files Per Family\n";    
    94         int size = shapeFamilies.size();
    95         for (
int i = 0; i < size; i++) {
   110         std::cout << 
"Writing Triple Intersection Points File\n";
   111         writeTriplePts(triplePoints, finalFractures, acceptedPoly, intPts, output);
   133 void writePoints(std::ostream &output, std::vector<Point> &points, 
int start, 
unsigned int &count){
   135     for (
int i = start; i < n; i++) {
   136         output << std::setprecision(13) << count << 
" " << points[i].x 
   137                << 
" " << points[i].y << 
" " << points[i].z<< 
"\n";
   153      std::vector<unsigned int> &intStart, std::vector<unsigned int> &intersectingFractures){
   155     unsigned int count=1;
   159     for (
int i = 0; i<numPoints-numIntersections; i++){
   160         if(intStart[idx] == count+1){
   164         fractIntFile<< i+1 << 
" " <<fract1<< 
" line " <<count<< 
" " <<count+1<< 
"\n";
   168     fractIntFile<< 
"2 1 1\n";
   169     fractIntFile<< 
"a_b, integer\n";
   170     fractIntFile<< 
"b_a, integer\n";
   172     for (
int i=0; i<numPoints; i++){
   173         if(intStart[idx] == (
unsigned) i+1){
   176     fractIntFile<<i+1<< 
" " <<fract1<< 
" " <<intersectingFractures[idx]<< 
"\n";
   180     fractIntFile.seekp(0);
   181     fractIntFile<<numPoints<< 
" " <<numPoints - numIntersections<< 
" " <<2<< 
" " << 
"0 0";
   196     if ((stat(path, &sb) == 0 && S_ISDIR(sb.st_mode))) {
   218 void adjustIntFractIDs(std::vector<unsigned int> &finalFractures, std::vector<Poly> &allPolys, std::vector<IntPoints> &intPts){
   220     for (
unsigned int i = 0; i < finalFractures.size(); i++){
   222         for (
unsigned int j = 0; j < allPolys[finalFractures[i]].intersectionIndex.size(); j++){
   224             unsigned int intIdx = allPolys[finalFractures[i]].intersectionIndex[j];
   225             if (intPts[intIdx].fract1 ==  finalFractures[i]){
   226                 intPts[intIdx].fract1 =  -( (
long int) i+1);
   228             else if (intPts[intIdx].fract2 == finalFractures[i]){
   229                 intPts[intIdx].fract2 = -( (
long int) i+1);
   248 void writeIntersectionFiles(std::vector<unsigned int> &finalFractures, std::vector<Poly> &acceptedPoly, std::vector<IntPoints> &intPts, std::vector<Point> &triplePoints, std::string intersectionFolder, 
struct Stats &pstats) { 
   250     Point tempPoint1, tempPoint2; 
   252     std::cout << 
"\nWriting Intersection Files\n";    
   256     std::ofstream fractIntFile; 
   260     for (
unsigned int i = 0; i < finalFractures.size(); i++){
   263         std::vector<unsigned int> intStart;         
   264         unsigned int count = 1;
   267         unsigned int numIntPts = 0; 
   269         std::vector<unsigned int> intersectingFractures; 
   272         std::string file = intersectionFolder + 
"/intersections_" + std::to_string(i+1) + 
".inp";
   273         fractIntFile.open(file.c_str(), std::ofstream::out | std::ofstream::trunc);
   278         fractIntFile<< 
"                                                               \n";    
   281         unsigned int size = acceptedPoly[finalFractures[i]].intersectionIndex.size();
   282         for (
unsigned int j = 0; j < size; j++){        
   286             std::vector<Point> tempTripPts; 
   292             double curLength = 0;
   294             unsigned int polyIntIdx = acceptedPoly[finalFractures[i]].intersectionIndex[j];
   299                                          acceptedPoly[finalFractures[i]], triplePoints, tempTripPts);
   302             int triplePtsSize = tempTripPts.size();
   307             if (intPts[polyIntIdx].fract1 == -(i+1)){
   308                 fract2 = -intPts[polyIntIdx].fract2;
   309                 intersectingFractures.push_back(fract2);    
   312                 fract2 = -intPts[polyIntIdx].fract1;
   313                 intersectingFractures.push_back(fract2);
   317             if (triplePtsSize != 0) {
   326                 double *distances = 
new double[triplePtsSize]; 
   328                 double pt1[3] = {tempIntersection.
x1, tempIntersection.
y1, tempIntersection.
z1};
   329                 tempPoint1.
x = intPts[polyIntIdx].x1;
   330                 tempPoint1.
y = intPts[polyIntIdx].y1;
   331                 tempPoint1.
z = intPts[polyIntIdx].z1;
   333                 for (
int k = 0; k < triplePtsSize; k++) { 
   334                     double point[3] = {tempTripPts[k].x, tempTripPts[k].y, tempTripPts[k].z};
   344                 double pt2[3] = {tempTripPts[s[0]].x, tempTripPts[s[0]].y, tempTripPts[s[0]].z};
   345                 tempPoint2 = triplePoints[intPts[polyIntIdx].triplePointsIdx[s[0]]];
   350                 numIntPts += points.size();
   354                 if (triplePtsSize == 1){ 
   355                     pt1[0] = pt2[0];    pt1[1]=pt2[1];     pt1[2]=pt2[2];
   356                     pt2[0]=tempIntersection.
x2;     pt2[1]=tempIntersection.
y2;     pt2[2]=tempIntersection.
z2; 
   358                     tempPoint1 = tempPoint2;
   359                     tempPoint2.
x = intPts[polyIntIdx].x2;
   360                     tempPoint2.
y = intPts[polyIntIdx].y2;
   361                     tempPoint2.
z = intPts[polyIntIdx].z2;
   364                     for (
int jj=0; jj < (triplePtsSize-1); jj++){
   366                         pt1[0] = tempTripPts[s[jj]].x;   pt1[1]=tempTripPts[s[jj]].y; pt1[2]=tempTripPts[s[jj]].z;
   367                         pt2[0] = tempTripPts[s[jj+1]].x; pt2[1]=tempTripPts[s[jj+1]].y; pt2[2]=tempTripPts[s[jj+1]].z;
   369                         tempPoint1 = triplePoints[intPts[polyIntIdx].triplePointsIdx[s[jj]]];
   370                         tempPoint2 = triplePoints[intPts[polyIntIdx].triplePointsIdx[s[jj+1]]];
   375                         numIntPts += points.size()-1;
   379                     pt1[0]=pt2[0];     pt1[1]=pt2[1];     pt1[2]=pt2[2];
   380                     pt2[0]=tempIntersection.
x2;     pt2[1]=tempIntersection.
y2;     pt2[2]=tempIntersection.
z2;
   382                     tempPoint1 = tempPoint2;
   383                     tempPoint2.
x = intPts[polyIntIdx].x2;
   384                     tempPoint2.
y = intPts[polyIntIdx].y2;
   385                     tempPoint2.
z = intPts[polyIntIdx].z2;
   391                 numIntPts += points.size()-1;
   398                 double pt1[3] = {tempIntersection.
x1, tempIntersection.
y1, tempIntersection.
z1};
   399                 double pt2[3] = {tempIntersection.
x2, tempIntersection.
y2, tempIntersection.
z2};
   400                 tempPoint1.
x = intPts[polyIntIdx].x1;
   401                 tempPoint1.
y = intPts[polyIntIdx].y1;
   402                 tempPoint1.
z = intPts[polyIntIdx].z1;
   404                 tempPoint2.
x = intPts[polyIntIdx].x2;
   405                 tempPoint2.
y = intPts[polyIntIdx].y2;
   406                 tempPoint2.
z = intPts[polyIntIdx].z2;
   410                 numIntPts += points.size();
   414             intStart.push_back(count);
   423         intersectingFractures.clear();
   425         fractIntFile.close();
   437 void rotateFractures(std::vector<unsigned int> &finalFractures, std::vector<Poly> &acceptedPoly) {
   439     for (
unsigned int i = 0; i < finalFractures.size(); i++) {
   441         if (acceptedPoly[finalFractures[i]].XYPlane == 
true) {
   445         acceptedPoly[finalFractures[i]].XYPlane = 
true;
   447         double normalB[3] = {0,0,1};
   457 void writePolysInp_old(std::vector<unsigned int> &finalFractures, std::vector<Poly> &acceptedPoly, std::string &output){
   459     std::ofstream polyOutput;
   460     std::string polyOutputFile = output+
"/polys.inp";
   461     polyOutput.open(polyOutputFile.c_str(), std::ofstream::out | std::ofstream::trunc);
   463     std::cout << 
"Writing " << polyOutputFile << 
"\n";
   465     unsigned long long int vertexCount = 0;
   468     for (
unsigned int j = 0; j < finalFractures.size(); j++){ 
   469         vertexCount += acceptedPoly[finalFractures[j]].numberOfNodes;
   472     polyOutput << vertexCount << 
" " << vertexCount - finalFractures.size() << 
" 0" << 
" 0" << 
" 0" << 
"\n";
   475     int polyCount = finalFractures.size();
   476     for (
int j = 0; j<polyCount; j++){    
   479         for (
int i = 0; i < acceptedPoly[finalFractures[j]].numberOfNodes; i++) {
   481                 polyOutput << std::setprecision(15) << count << 
" "    482                            << acceptedPoly[finalFractures[j]].vertices[idx] << 
" "    483                            << acceptedPoly[finalFractures[j]].vertices[idx+1] << 
" "    484                            << acceptedPoly[finalFractures[j]].vertices[idx+2] << 
"\n"; 
   493     for (j = 0; j<polyCount; j++){        
   494         for (
int i = 0; i < acceptedPoly[finalFractures[j]].numberOfNodes-1; i++) {
   495             polyOutput << count2<< 
" " << j+1 << 
" line " << count << 
" " <<count+1<< 
"\n"; 
   510 void writePolysInp(std::vector<unsigned int> &finalFractures, std::vector<Poly> &acceptedPoly, std::string &output) {
   512     std::ofstream polyOutput;
   513     std::cout << 
"Writing poly inp files\n";
   515     int polyCount = finalFractures.size();
   517     for (
int j = 0; j < polyCount; j++) {    
   518         std::string polyOutputFile = output + 
"/polys/poly_" + std::to_string(j+1) + 
".inp";
   519         polyOutput.open(polyOutputFile.c_str(), std::ofstream::out | std::ofstream::trunc);
   522         polyOutput << acceptedPoly[finalFractures[j]].numberOfNodes << 
" "    523                    << acceptedPoly[finalFractures[j]].numberOfNodes-1 << 
" 0" << 
" 0" << 
" 0 " << 
"\n";
   526         int numberOfNodes = acceptedPoly[finalFractures[j]].numberOfNodes; 
   527         for (
int i = 0; i < numberOfNodes; i++) {
   529             polyOutput << std::setprecision(15) << i+1 << 
" "    530                        << acceptedPoly[finalFractures[j]].vertices[idx] << 
" "    531                        << acceptedPoly[finalFractures[j]].vertices[idx+1] << 
" "    532                        << acceptedPoly[finalFractures[j]].vertices[idx+2] << 
"\n"; 
   536         for (
int i = 1; i < numberOfNodes; i++) {
   537             polyOutput << i << 
" " << j+1  << 
" line " << i  << 
" " << i+1 << 
"\n";
   551 void writeParamsFile(std::vector<unsigned int> &finalFractures, std::vector<Poly> &acceptedPoly, std::vector<Shape> &shapeFamilies, 
Stats &pstats, std::vector<Point> &triplePoints, std::string &output) {
   553     std::ofstream params;
   554     std::string paramsOutputFile = output+
"/params.txt";
   555     params.open(paramsOutputFile.c_str(), std::ofstream::out | std::ofstream::trunc);
   557     std::cout << 
"Writing " << paramsOutputFile << 
"\n";
   558     params << finalFractures.size() << 
"\n";
   573 void writeApertureFile(std::vector<unsigned int> &finalFractures, std::vector<Poly> &acceptedPoly, std::string &output) {
   574     std::string file = output+
"/aperture.dat";
   576     ap.open(file.c_str(), std::ofstream::out | std::ofstream::trunc);
   578     std::cout << 
"Writing aperture.dat\n";
   579     ap<< 
"aperture.dat" << 
"\n";
   581     int size = finalFractures.size();
   582     for (
int i = 0; i < size; i++) {
   583         ap << -(7+i) << 
" 0 0 " << std::setprecision(10) << acceptedPoly[finalFractures[i]].aperture << 
"\n";
   594 void writePermFile(std::vector<unsigned int> &finalFractures, std::vector<Poly> &acceptedPoly, std::string &output) {
   595     std::string file = output+
"/perm.dat"; 
   597     perm.open(file.c_str(), std::ofstream::out | std::ofstream::trunc);
   599     std::cout << 
"Writing perm.dat\n";
   600     perm<< 
"permeabiliy" << 
"\n";
   602     int size = finalFractures.size();
   603     for (
int i = 0; i < size; i++) {
   604        perm << -(7+i) << 
" 0 0 " <<  std::setprecision(10) << acceptedPoly[finalFractures[i]].permeability << 
" " <<acceptedPoly[finalFractures[i]].permeability<< 
" " <<acceptedPoly[finalFractures[i]].permeability<< 
"\n";
   617 void writeRadiiFile(std::vector<unsigned int> &finalFractures, std::vector<Poly> &acceptedPoly, std::string &output) {
   619     std::cout << 
"Writing Radii File (radii.dat)\n";
   621     std::string file = output+
"/radii.dat";
   623     radii.open(file.c_str(), std::ofstream::out | std::ofstream::trunc);
   625     radii << 
"Format: xRadius yRadius Family# Removed (-1 = userRectangle, 0 = userEllipse, > 0 is family in order of famProb)\n";
   627     unsigned int finalFractLimit = finalFractures.size() - 1;
   628     unsigned int size = acceptedPoly.size();
   629     unsigned int curFinalIdx = 0;
   631     if (finalFractures.size() <= 0) 
return;
   633     for (
unsigned int i = 0; i < size; i++) {
   634         radii <<  std::setprecision(8) << acceptedPoly[i].xradius << 
" " << acceptedPoly[i].yradius
   635                    << 
" " << acceptedPoly[i].familyNum+1;
   639         if (i != finalFractures[curFinalIdx]) {
   643             if (curFinalIdx < finalFractLimit) {
   661     std::cout << 
"Writing Fracture Translations File (translations.dat)\n";
   662     std::string filePath = output + 
"/translations.dat";
   664     file.open(filePath.c_str(), std::ofstream::out | std::ofstream::trunc);
   666     file << 
"Format: x y z  (R = removed from domain due to fracture isolation)\n";
   668     unsigned int finalFractLimit = finalFractures.size() - 1;
   669     unsigned int size = acceptedPoly.size();
   670     unsigned int curFinalIdx = 0;
   672     if (finalFractures.size() <= 0) 
return;
   674     for (
unsigned int i = 0; i < size; i++) {
   675         file << std::setprecision(10) << acceptedPoly[i].translation[0] << 
" "    676              << acceptedPoly[i].translation[1] << 
" " << acceptedPoly[i].translation[2];
   680         if (i != finalFractures[curFinalIdx]) {
   684             if (curFinalIdx < finalFractLimit) {
   699 void writeFinalPolyRadii(std::vector<unsigned int> &finalFractures, std::vector<Poly> &acceptedPoly, std::string &output){
   700     std::string file = output + 
"/radii_Final.dat";
   701     std::ofstream radiiFinal;
   702     radiiFinal.open(file.c_str(), std::ofstream::out | std::ofstream::trunc);
   704     radiiFinal << 
"Fracture Radii List After Isolated Fracture and Cluster Removal\n";
   705     radiiFinal << 
"Format: xRadius yRadius Family# (-1 = userRectangle, 0 = userEllipse, > 0 is family in order of famProb)\n";
   707     int size =   finalFractures.size();
   708     for (
int i = 0; i < size; i++) {
   709         radiiFinal << acceptedPoly[finalFractures[i]].xradius << 
" "    710                    << acceptedPoly[finalFractures[i]].yradius << 
" "    711                    << acceptedPoly[finalFractures[i]].familyNum + 1 << 
"\n";
   724     std::string file = output + 
"/radii_AllAccepted.dat";
   725     std::ofstream radiiAcpt;
   726     radiiAcpt.open(file.c_str(), std::ofstream::out | std::ofstream::trunc);
   728     radiiAcpt << 
"Fracture Radii List Before Isolated Fracture and Cluster Removal\n";
   729     radiiAcpt << 
"Format: xRadius yRadius Distrubution# (-1 = userRectangle, 0 = userEllipse, > 0 is family in order of famProb)\n";
   731     int size = acceptedPoly.size();
   732     for (
int i = 0; i < size; i++) {
   733         radiiAcpt << acceptedPoly[i].xradius << 
" " << acceptedPoly[i].yradius << 
" " <<acceptedPoly[i].familyNum+1 << 
"\n";
   748     std::string fileName = output + 
"/radii_AllAccepted_Fam_" + std::to_string(familyNum + 1) + 
".dat";
   750     file.open(fileName.c_str(), std::ofstream::out | std::ofstream::trunc);
   752     file << 
"Fracture Radii List Before Isolated Fracture and Cluster Removal (Family " << familyNum+1 << 
")\n";
   753     file << 
"Format: xRadius yRadius Distrubution# (-1 = userRectangle, 0 = userEllipse, > 0 is family in order of famProb)\n";
   755     int size = acceptedPoly.size();
   756     for (
int i = 0; i < size; i++) {
   757         if (acceptedPoly[i].familyNum == familyNum) {
   758             file << acceptedPoly[i].xradius << 
" " << acceptedPoly[i].yradius << 
" " <<acceptedPoly[i].familyNum+1 << 
"\n";
   772 void writeFinalRadii_OfFamily(std::vector<unsigned int> &finalFractures, 
int familyNum, std::vector<Poly> &acceptedPoly, std::string &output){
   773     std::string fileName = output+
"/radii_Final_Fam_" + std::to_string(familyNum + 1) + 
".dat";
   775     file.open(fileName.c_str(), std::ofstream::out | std::ofstream::trunc);
   777     file << 
"Fracture Radii List After Isolated Fracture and Cluster Removal (Family " << familyNum+1 << 
")\n";
   778     file << 
"Format: xRadius yRadius Distrubution# (-1 = userRectangle, 0 = userEllipse, > 0 is family in order of famProb)\n";
   780     int size = finalFractures.size();
   781     for (
int i = 0; i < size; i++) {
   782         if (acceptedPoly[finalFractures[i]].familyNum == familyNum) {
   783             file << acceptedPoly[finalFractures[i]].xradius << 
" " << acceptedPoly[finalFractures[i]].yradius << 
" " <<acceptedPoly[finalFractures[i]].familyNum+1 << 
"\n";
   797 void writeTriplePts(std::vector<Point> &triplePoints, std::vector<unsigned int> &finalFractures, std::vector<Poly> &acceptedPoly, std::vector<IntPoints> &intPts, std::string &output) {
   800     std::string fileName = output + 
"/triple_points.dat";
   802     file.open(fileName.c_str(), std::ofstream::out | std::ofstream::trunc);
   808     std::vector<unsigned int> triplePtsList;
   810     int size = finalFractures.size();
   811     for (
int i = 0; i < size; i++) {
   812         int intersectCount = acceptedPoly[finalFractures[i]].intersectionIndex.size();
   813         for (
int j = 0; j < intersectCount; j++) {                                        
   814             int tripleSize = intPts[acceptedPoly[finalFractures[i]].intersectionIndex[j]].triplePointsIdx.size();
   815             for (
int k = 0; k < tripleSize; k++) {
   816                 int triplePtIdx = intPts[acceptedPoly[finalFractures[i]].intersectionIndex[j]].triplePointsIdx[k];
   817                 triplePtsList.push_back(triplePtIdx);
   822     size = triplePtsList.size();
   827         std::sort(triplePtsList.begin(), triplePtsList.end());
   828         std::vector<unsigned int> finalPts;
   829         unsigned int  prevPt = triplePtsList[0];
   830         finalPts.push_back(prevPt);
   831         for (
int i = 1; i < size; i++) {
   832             unsigned int curPt = triplePtsList[i];
   833             if (curPt != prevPt) {
   834                 finalPts.push_back(curPt);
   839         triplePtsList.clear();
   842         size = finalPts.size();
   843         for (
int i = 0; i < size; i++) {
   844         file << std::setprecision(17) 
   845              << triplePoints[finalPts[i]].x  
   846              << 
" " << triplePoints[finalPts[i]].y 
   847              << 
" " << triplePoints[finalPts[i]].z 
   860     std::cout << 
"Writing Rejection Statistics File (rejections.dat)\n";
   861     std::string fileName = output+
"/rejections.dat";
   863     file.open(fileName.c_str(), std::ofstream::out | std::ofstream::trunc);
   884     double radToDeg = 180 / M_PI;
   886     std::cout << 
"Writing Family Definitions File (families.dat)\n";
   887     std::string fileName = output+
"/families.dat";
   889     file.open(fileName.c_str(), std::ofstream::out | std::ofstream::trunc);
   894     for(
unsigned int i = 0; i < shapeFamilies.size(); i++) {
   897         file << 
shapeType(shapeFamilies[i]) << 
" Family "   900         file << 
"Global Family " << i + 1 << 
"\n";
   903         if (shapeFamilies[i].shapeFamily == 0) {  
   904             file << 
"Number of Vertices: " << shapeFamilies[i].numPoints << endl;
   907             file << 
"Number of Vertices: 4" << endl;
   911         file << 
"Aspect Ratio: " << shapeFamilies[i].aspectRatio << endl;
   915             file << 
"P32 (Fracture Intensity) Target: "   916                  << shapeFamilies[i].p32Target << endl;
   920         if (shapeFamilies[i].betaDistribution == 0) {
   921             file << 
"Beta Distribution (Rotation Around Normal Vector): [0, 2PI)" << endl;
   924             file << 
"Beta (Rotation Around Normal Vector): "   925                  << shapeFamilies[i].beta << 
" rad, "    926                  << shapeFamilies[i].beta * radToDeg << 
" deg" << endl;
   930         file << 
"Theta: " << shapeFamilies[i].theta << 
" rad, "    931              << shapeFamilies[i].theta * radToDeg << 
" deg" << endl;
   934         file << 
"Phi: " << shapeFamilies[i].phi << 
" rad, "    935              << shapeFamilies[i].phi * radToDeg << 
" deg" << endl;
   938         file << 
"Kappa: " << shapeFamilies[i].kappa << endl;
   942         if (shapeFamilies[i].layer == 0) {
   943             file << 
"Layer: Entire domain" << endl;
   946             int idx = (shapeFamilies[i].layer - 1) * 2;
   947             file << 
"Layer: " << shapeFamilies[i].layer << 
" {" << 
layers[idx]
   953         switch (shapeFamilies[i].distributionType) {
   955                 file << 
"Distribution: Lognormal\n";
   956                 file << 
"Mean: " << shapeFamilies[i].mean << endl;
   957                 file << 
"Standard Deviation: " << shapeFamilies[i].sd <<  endl;
   958                 file << 
"Minimum Radius: " << shapeFamilies[i].logMin << 
"m" << endl;
   959                 file << 
"Maximum Radius: " << shapeFamilies[i].logMax << 
"m" << endl;
   963                 file << 
"Distribution: Truncated Power-Law\n";
   964                 file << 
"Alpha: " << shapeFamilies[i].alpha << endl;
   965                 file << 
"Minimum Radius: " << shapeFamilies[i].min << 
"m" << endl;
   966                 file << 
"Maximum Radius: " << shapeFamilies[i].max << 
"m" << endl;
   970                 file << 
"Distribution: Exponential\n";
   971                 file << 
"Mean: " << shapeFamilies[i].expMean << endl;
   972                 file << 
"Lambda: " << shapeFamilies[i].expLambda << endl;
   973                 file << 
"Minimum Radius: " << shapeFamilies[i].expMin << 
"m" << endl;
   974                 file << 
"Maximum Radius: " << shapeFamilies[i].expMax << 
"m" << endl;
   978                 file << 
"Distribution: Constant\n";
   979                 file << 
"Radius: " << shapeFamilies[i].constRadi << 
"m" << endl;
   981         file << 
"Family Insertion Probability: " << 
famProbOriginal[i] << 
"\n\n";
   995         std::string tempStr = 
"rm -r ";
   997         if (system(tempStr.c_str())) {
   998             std::cout << 
"ERROR: Problem executing system "    999                       << 
"command: " << tempStr << 
"\n";
  1006         int dir_err = mkdir(dir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
  1007         if (-1 == dir_err)  {
  1008         std::cout << 
"\nError creating directory " << dir << 
"\n";
  1021 void writeConnectivity(std::vector<unsigned int> &finalFractures, std::vector<Poly> &acceptedPoly, std::vector<IntPoints> &intPts, std::string &output) {
  1023     std::cout << 
"Writing Connectivity Data (connectivity.dat)\n";
  1024     std::string fileName = output + 
"/connectivity.dat";
  1026     file.open(fileName.c_str(), std::ofstream::out | std::ofstream::trunc);
  1036     for (
unsigned int i = 0; i < finalFractures.size(); i++) {
  1038         unsigned int size = acceptedPoly[finalFractures[i]].intersectionIndex.size();
  1039         for (
unsigned int j = 0; j < size; j++) {
  1040             long int intIdx = acceptedPoly[finalFractures[i]].intersectionIndex[j];
  1047             if (finalFractures[i]+1 != -intPts[intIdx].fract1) {
  1048                 file << -intPts[intIdx].fract1 << 
" ";
  1051                 file << -intPts[intIdx].fract2 << 
" ";
  1067 void writeRotationData(std::vector<Poly> &acceptedPoly, std::vector<unsigned int> &finalFractures, std::vector<Shape> &shapeFamilies, std::string output) {
  1070     std::string fileOutputFile = output+
"/poly_info.dat";
  1071     file.open(fileOutputFile.c_str(), std::ofstream::out | std::ofstream::trunc);
  1073     std::cout << 
"Writing Rotation Data File (poly_info.dat)\n";
  1083         maxDomainSize *= 10;        
  1085     for (
unsigned int i = 0; i < finalFractures.size(); i++ ) {
  1088         double normal[3] = {acceptedPoly[finalFractures[i]].normal[0], acceptedPoly[finalFractures[i]].normal[1], acceptedPoly[finalFractures[i]].normal[2]};
  1089         double e3[3] = {0,0,1};
  1092         double theta = std::acos(
dotProduct(normal, e3));
  1094         theta = theta * (180/M_PI);
  1098         if (!(std::abs(v[0]) < 
eps && std::abs(v[1]) < 
eps && std::abs(v[2]) < 
eps)){ 
  1103         double x0 = (-maxDomainSize*v[0]);
  1104         double y0 = (-maxDomainSize*v[1]);
  1105         double z0 = (-maxDomainSize*v[2]);
  1107         double x1 = maxDomainSize*v[0];
  1108         double y1 = maxDomainSize*v[1];
  1109         double z1 = maxDomainSize*v[2];    
  1118         if (acceptedPoly[finalFractures[i]].familyNum == -1) {
  1119             famNum = shapeFamilies.size() + 1;
  1121         else if (acceptedPoly[finalFractures[i]].familyNum == -2) {
  1122             famNum = shapeFamilies.size() + 2;
  1125             famNum = acceptedPoly[finalFractures[i]].familyNum + 1;
  1129         file << (i+1) << 
" " << famNum << std::setprecision(15) << 
" " << theta << 
" " << x0 
  1130                << 
" " << y0 << 
" " << z0 << 
" " << x1 << 
" " << y1 << 
" " << z1 << 
"\n";
  1150     std::string fileOutputFile = output+
"/rejectsPerAttempt.dat";
  1151     file.open(fileOutputFile.c_str(), std::ofstream::out | std::ofstream::trunc);
  1153     std::cout << 
"Writing Rotation Data File (rejectsPerAttempt.dat)\n";
 double euclideanDistance(double *A, double *B)
 
struct IntPoints polyAndIntersection_RotationToXY(struct IntPoints &intersection, Poly &newPoly, std::vector< Point > &triplePoints, std::vector< Point > &tempTripPts)
 
void writeFractureTranslations(std::vector< unsigned int > &finalFractures, std::vector< Poly > &acceptedPoly, std::string &output)
 
void writeRadiiFile(std::vector< unsigned int > &finalFractures, std::vector< Poly > &acceptedPoly, std::string &output)
 
int * sortedIndex(const double *v, int n)
 
unsigned long long int shortIntersection
 
unsigned long long int closeToNode
 
unsigned long long int closeToEdge
 
void writeApertureFile(std::vector< unsigned int > &finalFractures, std::vector< Poly > &acceptedPoly, std::string &output)
 
unsigned long long int triple
 
unsigned long long int interCloseToInter
 
std::string shapeType(struct Shape &shapeFam)
 
void writeRejectionStats(Stats &pstats, std::string &output)
 
void rotateFractures(std::vector< unsigned int > &finalFractures, std::vector< Poly > &acceptedPoly)
 
void writeFinalRadii_OfFamily(std::vector< unsigned int > &finalFractures, int familyNum, std::vector< Poly > &acceptedPoly, std::string &output)
 
void writePermFile(std::vector< unsigned int > &finalFractures, std::vector< Poly > &acceptedPoly, std::string &output)
 
struct RejectionReasons rejectionReasons
 
void writeAllAcceptedRadii(std::vector< Poly > &acceptedPoly, std::string &output)
 
void writeConnectivity(std::vector< unsigned int > &finalFractures, std::vector< Poly > &acceptedPoly, std::vector< IntPoints > &intPts, std::string &output)
 
void writeIntersectionFiles(std::vector< unsigned int > &finalFractures, std::vector< Poly > &acceptedPoly, std::vector< IntPoints > &intPts, std::vector< Point > &triplePoints, std::string intersectionFolder, struct Stats &pstats)
 
unsigned long long int closePointToEdge
 
unsigned int intersectionNodeCount
 
void writeParamsFile(std::vector< unsigned int > &finalFractures, std::vector< Poly > &acceptedPoly, std::vector< Shape > &shapeFamilies, Stats &pstats, std::vector< Point > &triplePoints, std::string &output)
 
bool DIR_exists(const char *path)
 
unsigned long long int outside
 
void writeFinalPolyRadii(std::vector< unsigned int > &finalFractures, std::vector< Poly > &acceptedPoly, std::string &output)
 
int getFamilyNumber(int familyIndex, int familyShape)
 
std::vector< unsigned int > rejectsPerAttempt
 
void applyRotation3D(Poly &newPoly, double *normalB)
 
void writeOutput(char *outputFolder, std::vector< Poly > &acceptedPoly, std::vector< IntPoints > &intPts, std::vector< Point > &triplePoints, struct Stats &pstats, std::vector< unsigned int > &finalFractures, std::vector< Shape > &shapeFamilies)
 
void writePolysInp(std::vector< unsigned int > &finalFractures, std::vector< Poly > &acceptedPoly, std::string &output)
 
T dotProduct(const T *A, const T *B)
 
void writeRejectsPerAttempt(Stats &pstats, std::string &output)
 
void makeDIR(const char *dir)
 
unsigned int tripleNodeCount
 
void writeAllAcceptedRadii_OfFamily(int familyNum, std::vector< Poly > &acceptedPoly, std::string &output)
 
void writeTriplePts(std::vector< Point > &triplePoints, std::vector< unsigned int > &finalFractures, std::vector< Poly > &acceptedPoly, std::vector< IntPoints > &intPts, std::string &output)
 
void finishWritingIntFile(std::ostream &fractIntFile, int fract1, int numPoints, int numIntersections, std::vector< unsigned int > &intStart, std::vector< unsigned int > &intersectingFractures)
 
void writePolysInp_old(std::vector< unsigned int > &finalFractures, std::vector< Poly > &acceptedPoly, std::string &output)
 
void writeShapeFams(std::vector< Shape > &shapeFamilies, std::string &output)
 
T * crossProduct(const T *v1, const T *v2)
 
void writeRotationData(std::vector< Poly > &acceptedPoly, std::vector< unsigned int > &finalFractures, std::vector< Shape > &shapeFamilies, std::string output)
 
void adjustIntFractIDs(std::vector< unsigned int > &finalFractures, std::vector< Poly > &allPolys, std::vector< IntPoints > &intPts)
 
void writePoints(std::ostream &output, std::vector< Point > &points, int start, unsigned int &count)
 
std::vector< Point > discretizeLineOfIntersection(double *pt1, double *pt2, double dist)