MeshKit  1.0
test_mbvolop.cpp
Go to the documentation of this file.
00001 
00010 #include <iostream>
00011 #include <fstream>
00012 
00013 #include <time.h>
00014 #include <stdlib.h>
00015 #include <cstring>
00016 
00017 #include "meshkit/MKCore.hpp"
00018 #include "meshkit/MeshOp.hpp"
00019 #include "meshkit/ModelEnt.hpp"
00020 #include "meshkit/MBVolOp.hpp"
00021 #include "meshkit/MBSplitOp.hpp"
00022 
00023 
00024 using namespace MeshKit;
00025 
00026 #include "TestUtil.hpp"
00027 #include "meshkit/ReadPolyLine.hpp"
00028 
00029 MKCore *mk;
00030 
00031 std::string usage_string =
00032 " <input file bottom> <input file top>    input files.\n"
00033 "< direction > 3 doubles for sweeping direction\n"
00034 " <output file >   output moab database \n";
00035 
00036 std::string filename_top;
00037 std::string filename_bot;
00038 double direction[3]={0., 0., 1.};
00039 std::string output_file_name;
00040 
00041 
00042 int main(int argc, char* argv[])
00043 {
00044   // check command line arg
00045 
00046   filename_bot = TestDir + "/BedCropL3.h5m";
00047   filename_top = TestDir + "/SurfCropL3.h5m";//"/polyPB.txt";
00048 
00049   output_file_name = "volumesIce.h5m"; // output
00050 
00051   //number_tests_successful = 0;
00052 
00053   if (argc<=1)
00054   {
00055     std::cout<<usage_string;
00056     std::cout << "\n\n";
00057     std::cout<< "default arguments:" << filename_bot << " "<<filename_top << " "
00058         << " "<<direction[0] << " " << direction[1] << " "<< direction[2]<<" " << output_file_name <<"\n";
00059   }
00060   else if (argc==7)
00061   {
00062     filename_bot = argv[1];
00063     filename_top = argv[2];
00064     direction[0] = atof(argv[3]);
00065     direction[1] = atof(argv[4]);
00066     direction[2] = atof(argv[5]);
00067     output_file_name= argv[6];
00068   }
00069   else
00070   {
00071     std::cout << usage_string << " abort.\n";
00072     return 1;
00073   }
00074   // initialize everything
00075 
00076   mk = new MKCore();
00077   mk->load_mesh(filename_bot.c_str());
00078   MEntVector  botFaces;
00079   // we should have 2 faces only, for top and bottom
00080   mk->get_entities_by_dimension(2, botFaces);
00081   // load a second one
00082   mk->load_mesh(filename_top.c_str());
00083   MEntVector  allFaces;
00084   mk->get_entities_by_dimension(2, allFaces);
00085 
00086   MBVolOp *eVolOp = (MBVolOp*) mk->construct_meshop("MBVolOp", allFaces);
00087 
00088   //selection.push_back(*dum.rbegin());// push just the last one retrieved from core
00089   eVolOp->set_direction(direction[0], direction[1], direction[2]);
00090 
00091   std::cout<<"Total number of faces: " << allFaces.size() << "\n";
00092   mk->setup_and_execute();
00093 
00094   if(output_file_name.length()>0)
00095   {
00096     std::cout << "writing output to " << output_file_name << std::endl;
00097     // output only the root set with the volume
00098     //
00099     MEntSelection & mentset = eVolOp->me_selection();
00100     moab::Range rangeResult = (*(mentset.begin()) ).second;
00101     moab::EntityHandle resultSet = rangeResult[0]; // the first set
00102     mk->moab_instance()->write_mesh(output_file_name.c_str(), &resultSet, 1);// write the result set only
00103   }
00104 
00105   return 0;
00106 }
00107 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines