[MOAB-dev] r2715 - MOAB/trunk
jiangtao_ma at yahoo.com
jiangtao_ma at yahoo.com
Fri Mar 13 11:33:26 CDT 2009
Author: janehu
Date: 2009-03-13 11:33:25 -0500 (Fri, 13 Mar 2009)
New Revision: 2715
Modified:
MOAB/trunk/ReadCGM.cpp
MOAB/trunk/ReadCGM.hpp
MOAB/trunk/ReadNCDF.hpp
Log:
Added option for tolerance and attribute for porting cgm to moab.
Modified: MOAB/trunk/ReadCGM.cpp
===================================================================
--- MOAB/trunk/ReadCGM.cpp 2009-03-13 14:16:05 UTC (rev 2714)
+++ MOAB/trunk/ReadCGM.cpp 2009-03-13 16:33:25 UTC (rev 2715)
@@ -46,6 +46,7 @@
#include <assert.h>
#include "ReadCGM.hpp"
+#include "MBReadUtilIface.hpp"
#define GF_CUBIT_FILE_TYPE "CUBIT"
#define GF_STEP_FILE_TYPE "STEP"
@@ -100,13 +101,69 @@
const int* blocks_to_load,
const int num_blocks)
{
- //opts, blocks_to_load and num_blocks are ignored.
+ // blocks_to_load and num_blocks are ignored.
+ //opts is currently designed as following
+ //cgm_opts = [d <tol>|D] [,n <tol>|N] [,l <tol>|L] [,A|a]
+ //currently attribute option is not checked.
+ //-d max. distance deviation between facet and geometry
+ //-D no distance tolerance
+ // (default:0.001)
+ //-n max. normal angle deviation (degrees) between facet and geometry
+ // (default:5)
+ //-N no normal tolerance
+ //-l max. facet edge length
+ //-L no facet edge length maximum
+ // (default:0)
+ //-a force actuation of all CGM attributes
+ //-A disable all CGM attributes
MBErrorCode rval;
file_set = 0;
std::string filename( cgm_file_name );
cgmFile = filename;
+ std::string string;
+ rval = opts.get_str_option("cgm_opts", string );
+ if(MB_SUCCESS != rval)
+ {
+ readUtilIface->report_error("MBCN:: Problem reading file options.");
+ return MB_FAILURE;
+ }
+ std::vector< std::string > tokens;
+ tokenize(string, tokens,",");
+
+ int norm_tol = 5;
+ double faceting_tol = 0.001, len_tol = 0.0;
+ bool act_att = false;
+ //check for the options.
+ for(int i = 0 ; i < tokens.size(); i++)
+ {
+ std::string opt = tokens[i];
+ std::string opt_s (opt.substr(2));
+ switch(opt[0])
+ {
+ case('d'):
+ if(opt.length() < 3)
+ return MB_TYPE_OUT_OF_RANGE;
+ faceting_tol = atof( opt_s.c_str() );
+ break;
+ case('n'):
+ if(opt.length() < 3)
+ return MB_TYPE_OUT_OF_RANGE;
+ norm_tol = atoi( opt_s.c_str() );
+ if(norm_tol < 0)
+ return MB_TYPE_OUT_OF_RANGE;
+ break;
+ case('l'):
+ if(opt.length() < 3)
+ return MB_TYPE_OUT_OF_RANGE;
+ len_tol = atof( opt_s.c_str() );
+ break;
+ case('a'):
+ act_att = true;
+ }
+ }
+
// CGM data
std::map<RefEntity*,MBEntityHandle> entmap[5]; // one for each dim, and one for groups
std::map<RefEntity*,MBEntityHandle>::iterator ci;
@@ -119,6 +176,11 @@
// Initialize CGM
InitCGMA::initialize_cgma();
+ if (act_att) {
+ CGMApp::instance()->attrib_manager()->set_all_auto_read_flags( act_att );
+ CGMApp::instance()->attrib_manager()->set_all_auto_actuate_flags( act_att );
+ }
+
// Get CGM file type
const char* file_type = 0;
file_type = get_geom_file_type( cgm_file_name );
@@ -347,7 +409,6 @@
GeometryQueryEngine* gqe = curve->get_geometry_query_engine();
data.clean_out();
int count;
- double faceting_tol = 0.001;
CubitStatus s = gqe->get_graphics( curve, count, &data, faceting_tol);
if (CUBIT_SUCCESS != s)
return MB_FAILURE;
@@ -433,8 +494,6 @@
GeometryQueryEngine* gqe = surf->get_geometry_query_engine();
data.clean_out();
int nt, np, nf;
- int norm_tol = 5;
- double faceting_tol = 0.001, len_tol = 0.0;
CubitStatus s = gqe->get_graphics( surf, nt, np, nf, &data,
norm_tol, faceting_tol, len_tol);
if (CUBIT_SUCCESS != s)
@@ -634,3 +693,19 @@
fread(buffer, 6, 1, file) &&
!memcmp(buffer, "DBRep_", 6);
}
+
+void ReadCGM::tokenize( const std::string& str,
+ std::vector<std::string>& tokens,
+ const char* delimiters )
+{
+ std::string::size_type last = str.find_first_not_of( delimiters, 0 );
+ std::string::size_type pos = str.find_first_of( delimiters, last );
+ while (std::string::npos != pos && std::string::npos != last) {
+ tokens.push_back( str.substr( last, pos - last ) );
+ last = str.find_first_not_of( delimiters, pos );
+ pos = str.find_first_of( delimiters, last );
+ if(std::string::npos == pos)
+ pos = str.size();
+ }
+}
+
Modified: MOAB/trunk/ReadCGM.hpp
===================================================================
--- MOAB/trunk/ReadCGM.hpp 2009-03-13 14:16:05 UTC (rev 2714)
+++ MOAB/trunk/ReadCGM.hpp 2009-03-13 16:33:25 UTC (rev 2715)
@@ -45,6 +45,10 @@
static MBReaderIface* factory( MBInterface* );
+ void tokenize( const std::string& str,
+ std::vector<std::string>& tokens,
+ const char* delimiters );
+
//! load an ExoII file
MBErrorCode load_file(const char *cgm_file_name,
MBEntityHandle& file_set,
Modified: MOAB/trunk/ReadNCDF.hpp
===================================================================
--- MOAB/trunk/ReadNCDF.hpp 2009-03-13 14:16:05 UTC (rev 2714)
+++ MOAB/trunk/ReadNCDF.hpp 2009-03-13 16:33:25 UTC (rev 2715)
@@ -64,9 +64,9 @@
static MBReaderIface* factory( MBInterface* );
- static void tokenize( const std::string& str,
- std::vector<std::string>& tokens,
- const char* delimiters );
+ void tokenize( const std::string& str,
+ std::vector<std::string>& tokens,
+ const char* delimiters );
//! load an ExoII file
MBErrorCode load_file(const char *exodus_file_name,
More information about the moab-dev
mailing list