Ejemplo n.º 1
0
//---------------------------------------------------------------------------
//Reading geometric information of the RVE
int Input::Read_rve_geometry(struct Geom_RVE &geom_rve, ifstream &infile)
{
    if(geom_rve.mark)
    {
        cout << "Attention: \"" << geom_rve.keywords << "\" has been input!" << endl;
        hout << "Attention: \"" << geom_rve.keywords << "\" has been input!" << endl;
        return 0;
    }
    else geom_rve.mark = true;

    //-----------------------------------------------------------------------------------------------------------------------------------------
    //Define the domain of RVE: the lower-left corner point of RVE and the length, width and height of RVE
    istringstream istr0(Get_Line(infile));
    istr0 >> geom_rve.origin.x >> geom_rve.origin.y >> geom_rve.origin.z;
    istr0 >> geom_rve.len_x >> geom_rve.wid_y >> geom_rve.hei_z;
    if(geom_rve.len_x<=0||geom_rve.wid_y<=0||geom_rve.hei_z<=0)
    {
        cout << "Error: the sizes of RVE should be positive!" << endl;
        hout << "Error: the sizes of RVE should be positive!" << endl;
        return 0;
    }
    geom_rve.volume = geom_rve.len_x*geom_rve.wid_y*geom_rve.hei_z;

    //-----------------------------------------------------------------------------------------------------------------------------------------
    //Define the size range of the observation window and descrement by every step in x, y and z directions
    istringstream istr1(Get_Line(infile));
    istr1 >> geom_rve.win_max_x >> geom_rve.win_max_y >> geom_rve.win_max_z;
    istringstream istr2(Get_Line(infile));
    istr2 >> geom_rve.win_delt_x >> geom_rve.win_delt_y >> geom_rve.win_delt_z;
    istringstream istr3(Get_Line(infile));
    istr3 >> geom_rve.win_min_x >> geom_rve.win_min_y >> geom_rve.win_min_z;

    if(geom_rve.win_max_x<=0.0||geom_rve.win_max_y<=0.0||geom_rve.win_max_z<=0.0||
            geom_rve.win_max_x>geom_rve.len_x||geom_rve.win_max_y>geom_rve.wid_y||geom_rve.win_max_z>geom_rve.hei_z)
    {
        cout << "Error: the win_max in each direction of RVE should be positive and must be smaller than the size of RVE." << endl;
        hout << "Error: the win_max in each direction of RVE should be positive and must be smaller than the size of RVE." << endl;
        return 0;
    }
    if(geom_rve.win_min_x<=0.0||geom_rve.win_min_y<=0.0||geom_rve.win_min_z<=0.0||
            geom_rve.win_min_x>geom_rve.win_max_x||geom_rve.win_min_y>geom_rve.win_max_y||geom_rve.win_min_z>geom_rve.win_max_z)
    {
        cout << "Error: the win_min in each direction of RVE should be positive and must be smaller than max." << endl;
        hout << "Error: the win_min in each direction of RVE should be positive and must be smaller than max." << endl;
        return 0;
    }
    if(geom_rve.win_delt_x<=0.0||geom_rve.win_delt_y<=0.0||geom_rve.win_delt_z<=0.0)
    {
        cout << "Error: the win_delt in each direction of RVE should be positive." << endl;
        hout << "Error: the win_delt in each direction of RVE should be positive." << endl;
        return 0;
    }

    //Details: +Zero for reducing the error of division
    int num[3] = {	(int)((geom_rve.win_max_x-geom_rve.win_min_x + Zero)/geom_rve.win_delt_x),
                    (int)((geom_rve.win_max_y-geom_rve.win_min_y + Zero)/geom_rve.win_delt_y),
                    (int)((geom_rve.win_max_z-geom_rve.win_min_z + Zero)/geom_rve.win_delt_z)
                 };

    if(num[0]!=num[1]||num[0]!=num[2])
    {
        cout << "Error: the numbers of cutoff times are different in three directions (x, y, z)." << endl;
        hout << "Error: the numbers of cutoff times are different in three directions (x, y, z)." << endl;
        return 0;
    }
    else geom_rve.cut_num = num[0];

    //-----------------------------------------------------------------------------------------------------------------------------------------
    //Define the minimum size for background grids (looking for contact points)
    istringstream istr4(Get_Line(infile));
    istr4 >> geom_rve.gs_minx >> geom_rve.gs_miny >> geom_rve.gs_minz;
    if(geom_rve.gs_minx<=0||geom_rve.gs_miny<=0||geom_rve.gs_minz<=0)
    {
        cout << "Error: the number of segments in each direction of RVE should be positive!" << endl;
        hout << "Error: the number of segments in each direction of RVE should be positive" << endl;
        return 0;
    }
    else if((int)(geom_rve.win_max_x/geom_rve.gs_minx)>500||
            (int)(geom_rve.win_max_y/geom_rve.gs_miny)>500||
            (int)(geom_rve.win_max_z/geom_rve.gs_minz)>500)
    {
        cout << "Error: the number of divisions in one of boundary is too big (>500), which leads to the memory problem!" << endl;
        hout << "Error: the number of divisions in one of boundary is too big (>500), which leads to the memory problem!" << endl;
        return 0;
    }

    return 1;
}
Ejemplo n.º 2
0
int main()
{
   //---
   // Test ossiIpt::operator>>
   //---
   std::string is1(" ( 0, 1 )");
   std::string is2(" (2,3)");
   std::string is3(" ( 4, 5 )");
   std::string is4_5_6_7(" ( 6, 7 )(8, 9) ( 10, 11 ) ( 12, 13) 9876");

   ossimIpt ip1;
   ossimIpt ip2;
   ossimIpt ip3;
   ossimIpt ip4;
   ossimIpt ip5;
   ossimIpt ip6;
   ossimIpt ip7;
   

   ip1.toPoint(is1);
   ip2.toPoint(is2);
   ip3.toPoint(is3);
   int i;

   std::istringstream istr(is4_5_6_7);
   istr >> ip4 >> ip5 >> ip6 >> ip7 >> i;

   //---
   // Test ossiDpt::operator>>
   //---
   std::string ds1(" ( 0.0, 1.1 )");
   std::string ds2(" (2.2,3.3)");
   std::string ds3(" ( 4.4, 5.5 )");
   std::string ds4_5_6_7(" ( 6.6, 7.7 )(8.8, 9.9) ( 10.0, 11.0 ) ( 12.0, 13.0) 9876.12345678");
   std::string ds8("12 20");

   ossimDpt dp1;
   ossimDpt dp2;
   ossimDpt dp3;
   ossimDpt dp4;
   ossimDpt dp5;
   ossimDpt dp6;
   ossimDpt dp7;
   ossimDpt dp8;

   dp1.toPoint(ds1);
   dp2.toPoint(ds2);
   dp3.toPoint(ds3);
   double d;

   std::istringstream istr2(ds4_5_6_7);
   istr2 >> dp4 >> dp5 >> dp6 >> dp7 >> d;

   dp8.toPoint(ds8); // Test an invalid string "12 20"

    //---
   // Test ossiDpt3d
   //---
   std::string ds3d1  = " ( 0.0, 1.1, 2.2 )";
   std::string ds3d2 = "(1.0,2.0,3.0)";
   
   ossimDpt3d dp3d1;
   ossimDpt3d dp3d2;
   dp3d1.toPoint(ds3d1);
   dp3d2.toPoint(ds3d2);


   //---
   // Test ossiGpt::operator>>
   //---
   std::string gs1("(0.0,0.0,0.0,WGE)");
   std::string gs2("(1.1,2.2,3.3,NAR-C)");
   std::string gs3(" (4.4,5.5,6.6,NAS-C )");
   std::string gs4_5_6_7(" (4.4,5.5,6.6,NAS-C )( 10.0, 10.0 ,5.0, TOY-C ) (17, -89, 50.0, xxx) (28.2, -44.5, 10000.0, NAS-B) 12345.6789");

   ossimGpt gp1;
   ossimGpt gp2;
   ossimGpt gp3;
   ossimGpt gp4;
   ossimGpt gp5;
   ossimGpt gp6;
   ossimGpt gp7;
   double d2;

   gp1.toPoint(gs1);
   gp2.toPoint(gs2);
   gp3.toPoint(gs3);

   std::istringstream istr4(gs4_5_6_7);
   istr4 >> gp4 >> gp5 >> gp6 >> gp7 >> d2;


   //---
   // Test ossimEcefPoint toString and toPoint methods.
   //---
   std::string es1("(1.0,2.0,3.0)");
   ossimEcefPoint ep1;
   ep1.toPoint(es1);
   std::string es2 = ep1.toString(10).string();

   //---
   // Test ossimEcefPoint toString and toPoint methods.
   //---
   ossimEcefVector ev1;
   ev1.toPoint(es1);
   std::string es3 = ev1.toString(10).string();
  
   std::cout
      << "\nis1:       " << is1
      << "\nip1:       " << ip1
      << "\nis2:       " << is2
      << "\nip2:       " << ip2
      << "\nis3:       " << is3
      << "\nip3:       " << ip3
      << "\nis4_5_6_7: " << is4_5_6_7
      << "\nip4:       " << ip4
      << "\nip5:       " << ip5
      << "\nip6:       " << ip6
      << "\nip7:       " << ip7
      << "\ni:         " << i

      << "\n\n\nds1:       " << ds1
      << "\ndp1:       " << dp1
      << "\nds2:       " << ds2
      << "\ndp2:       " << dp2
      << "\nds3:       " << ds3
      << "\ndp3:       " << dp3
      << "\nds4_5_6_7: " << ds4_5_6_7
      << "\ndp4:       " << dp4
      << "\ndp5:       " << dp5
      << "\ndp6:       " << dp6
      << "\ndp7:       " << dp7
      << "\nds8:       " << ds8
      << "\ndp8:       " << dp8
      << "\nd:         " << d

      << "\n\nds3d1:       " << ds3d1
      << "\nds3d2:     " << ds3d2
      << "\ndp3d1:     " << dp3d1
      << "\ndp3d2:     " << dp3d2

      << "\n\n\ngs1:       " << gs1
      << "\ngp1:       " << gp1
      << "\ngs2:       " << gs2
      << "\ngp2:       " << gp2
      << "\ngs3:       " << gs3
      << "\ngp3:       " << gp3
      << "\ngs4_5_6_7: " << gs4_5_6_7
      << "\ngp4:       " << gp4
      << "\ngp5:       " << gp5
      << "\ngp6:       " << gp6
      << "\ngp7:       " << gp7
      << "\nd2:         " << d2

      << "\n\n\nes1:       " << es1
      << "\nep1:       " << ep1
      << "\nes2:       " << es2
      << "\nev1:       " << ev1
      << "\nes3:       " << es3

      << std::endl;

   return 0;
}