|
cgma
|
#include <cassert>#include <string>#include <cctype>#include <iostream>#include "GeometryModifyTool.hpp"#include "GeometryQueryTool.hpp"#include "CubitMessage.hpp"#include "Body.hpp"#include "RefVolume.hpp"#include "RefFace.hpp"#include "RefEdge.hpp"#include "RefVertex.hpp"#include "InitCGMA.hpp"#include "CubitCompat.hpp"#include <algorithm>Go to the source code of this file.
Defines | |
| #define | SRCDIR . |
| #define | STRINGIFY_(X) #X |
| #define | STRINGIFY(X) STRINGIFY_(X) |
| #define | SRCPATH STRINGIFY(SRCDIR) "/" |
| #define | PRINT_SEPARATOR PRINT_INFO("=======================================\n"); |
Functions | |
| CubitStatus | read_geometry (int, char **, bool local=false) |
| CubitStatus | make_Point () |
| int | findString (const char *filename, std::string search) |
| int | main (int argc, char **argv) |
| std::string | type_from_file_name (const std::string &filename) |
| CubitStatus | read_geometry (int num_files, const char **argv, bool local) |
| #define PRINT_SEPARATOR PRINT_INFO("=======================================\n"); |
Definition at line 44 of file cylinders.cpp.
| #define SRCDIR . |
Definition at line 30 of file cylinders.cpp.
Definition at line 35 of file cylinders.cpp.
| #define STRINGIFY | ( | X | ) | STRINGIFY_(X) |
Definition at line 34 of file cylinders.cpp.
| #define STRINGIFY_ | ( | X | ) | #X |
Definition at line 33 of file cylinders.cpp.
| int findString | ( | const char * | filename, |
| std::string | search | ||
| ) |
Definition at line 46 of file cylinders.cpp.
{
std::ifstream Myfile;
Myfile.open (filename);
int found = 0;
std::string line;
size_t offset;
if(Myfile.is_open())
{
while(!Myfile.eof())
{
getline(Myfile,line);
if ((offset = line.find(search, 0)) != std::string::npos)
found ++;
}
Myfile.close();
}
return found;
}
| int main | ( | int | argc, |
| char ** | argv | ||
| ) |
Definition at line 66 of file cylinders.cpp.
{
CubitStatus status = InitCGMA::initialize_cgma();
if (CUBIT_SUCCESS != status) return 1;
//Do make point.
status = make_Point();
if (status == CUBIT_FAILURE)
PRINT_INFO("Operation Failed");
int ret_val = ( CubitMessage::instance()->error_count() );
if ( ret_val > 0 )
{
PRINT_ERROR("Errors found during Mergechk session.\n");
}
return ret_val;
}
Definition at line 134 of file cylinders.cpp.
{
GeometryQueryTool *gti = GeometryQueryTool::instance();
GeometryModifyTool *gmti = GeometryModifyTool::instance();
DLIList<Body*> bodies, single_body, all_bodies, neighbor_list, new_bodies;
DLIList<RefEntity*> free_entities;
const char *argstep = FILENAME;
CubitStatus stat = read_geometry(1, &argstep, false);
//Constructed 12 Volumes: 8 to 19
if (stat == CUBIT_FAILURE) exit(1);
//get all the bodies, use bodies 1-6 to unite and use united body to
//subtract from body 7.
gti->bodies(bodies);
Body* brick = bodies.pop();
all_bodies.append(brick);
stat = gmti->unite(bodies, single_body, CUBIT_FALSE);
assert(CUBIT_SUCCESS == stat && single_body.size() == 1);
stat = gmti->subtract(single_body.get(), all_bodies, new_bodies, CUBIT_FALSE,CUBIT_FALSE);
assert(CUBIT_SUCCESS == stat);
std::cout << "Number of resulting bodies = " << new_bodies.size() << std::endl;
assert(new_bodies.size() == 1);
//delete all entities
bodies.clean_out();
gti->bodies(bodies);
gti->delete_Body(bodies);
free_entities.clean_out();
gti->get_free_ref_entities(free_entities);
assert(free_entities.size() ==0);
return CUBIT_SUCCESS;
}
| CubitStatus read_geometry | ( | int | , |
| char ** | , | ||
| bool | local = false |
||
| ) |
| CubitStatus read_geometry | ( | int | num_files, |
| const char ** | argv, | ||
| bool | local | ||
| ) |
attribs module: list, modify attributes in a give model or models
Arguments: file name(s) of geometry files in which to look
Definition at line 107 of file cylinders.cpp.
{
CubitStatus status = CUBIT_SUCCESS;
GeometryQueryTool *gti = GeometryQueryTool::instance();
assert(gti);
int i;
PRINT_SEPARATOR;
for (i = 0; i < num_files; i++) {
std::string type = type_from_file_name( argv[i] );
if (type.empty()) // just guess OCC
type = "OCC";
std::string filename( local ? "./" : SRCPATH );
char const* local_name = argv[i];
filename += local_name;
status = CubitCompat_import_solid_model(filename.c_str(), type.c_str());
if (status != CUBIT_SUCCESS) {
PRINT_ERROR("Problems reading geometry file %s.\n", filename.c_str());
abort();
}
}
PRINT_SEPARATOR;
return CUBIT_SUCCESS;
}
| std::string type_from_file_name | ( | const std::string & | filename | ) |
Definition at line 85 of file cylinders.cpp.
{
size_t dot_pos = filename.find_last_of( '.' );
if (dot_pos == std::string::npos)
return std::string();
std::string extension = filename.substr( dot_pos + 1 );
std::transform( extension.begin(), extension.end(), extension.begin(), ::tolower );
if (extension == "occ" || extension == "brep")
return "OCC";
else if (extension == "step" || extension == "stp")
return "STEP";
else if (extension == "iges" || extension == "igs")
return "IGES";
else
return std::string();
}