cgma
spheres.cpp
Go to the documentation of this file.
00001 
00002 #undef NDEBUG
00003 #include <cassert>
00004 #include <iostream>
00005 
00006 #include "GeometryModifyTool.hpp"
00007 #include "GeometryQueryTool.hpp"
00008 #include "Body.hpp"
00009 #include "AppUtil.hpp"
00010 #include "InitCGMA.hpp"
00011 
00012 #ifndef TEST_ENGINE
00013 # define TEST_ENGINE 0
00014 #endif
00015 
00016 #define BS 1.0
00017 #define RAD 0.4
00018 #define GQI GeometryQueryTool::instance()
00019 #define GMI GeometryModifyTool::instance()
00020 
00021 int main( int argc, char* argv[] )
00022 {
00023     // Start up CGM
00024   CubitStatus result = InitCGMA::initialize_cgma(TEST_ENGINE);
00025   if (CUBIT_SUCCESS != result) return 1;
00026 
00027     // Create a brick
00028   Body* brick = GMI->brick(BS, BS, BS);
00029   assert(brick != 0);
00030   DLIList<Body *> bodies, single_body, all_bodies, neighbor_list, new_bodies;
00031   all_bodies.append(brick);
00032   for (int i = -1; i <= 1; i+= 2) {
00033     for (int j = -1; j <= 1; j+= 2) {
00034       for (int k = -1; k <= 1; k+= 2) {
00035         Body* sph = GMI->sphere(RAD);
00036         assert(brick != 0);
00037         DLIList<Body*> bods;
00038         bods.append(sph);
00039         GQI->translate(bods, CubitVector(i*.5*BS, j*.5*BS, k*.5*BS));
00040         bodies.append(sph);
00041       }
00042     }
00043   }
00044   CubitStatus stat = GMI->unite(bodies, single_body);
00045   assert(CUBIT_SUCCESS == stat && single_body.size() == 1);
00046   stat = GMI->webcut_with_body(all_bodies, single_body.get(), new_bodies, neighbor_list);
00047   assert(CUBIT_SUCCESS == stat);
00048   std::cout << "Number of resulting bodies = " << new_bodies.size() << std::endl;
00049   DLIList<RefEntity*> re_list;
00050   for (int i = 0; i < new_bodies.size(); i++) re_list.append(new_bodies.get_and_step());
00051 
00052   bodies.clean_out();
00053   GQI->bodies(bodies);
00054   assert (bodies.size() == 10);
00055   //delete all entities
00056   GQI->delete_Body(bodies);
00057 
00058   DLIList<RefEntity*> free_entities;
00059   GQI->get_free_ref_entities(free_entities);
00060   assert(free_entities.size() ==0);
00061   return 0;
00062 }
00063 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines