20 #pragma warning( disable : 4786 )
54 assert( impl != NULL );
83 std::vector< WriteTemplate::MaterialSetData >::iterator iter;
85 for( iter = matset_info.begin(); iter != matset_info.end(); ++iter )
86 delete( *iter ).elements;
94 const std::vector< std::string >& ,
102 if( NULL == strstr( file_name,
".template" ) )
return MB_FAILURE;
104 std::vector< EntityHandle > matsets, dirsets, neusets;
115 std::copy( this_range.
begin(), this_range.
end(), std::back_inserter( matsets ) );
118 std::copy( this_range.
begin(), this_range.
end(), std::back_inserter( dirsets ) );
121 std::copy( this_range.
begin(), this_range.
end(), std::back_inserter( neusets ) );
126 for(
const EntityHandle* iter = ent_handles; iter < ent_handles + num_sets; ++iter )
129 matsets.push_back( *iter );
131 dirsets.push_back( *iter );
133 neusets.push_back( *iter );
140 std::vector< WriteTemplate::MaterialSetData > matset_info;
141 std::vector< WriteTemplate::DirichletSetData > dirset_info;
142 std::vector< WriteTemplate::NeumannSetData > neuset_info;
183 std::vector< WriteTemplate::MaterialSetData >& matset_info,
184 std::vector< WriteTemplate::NeumannSetData >& neuset_info,
185 std::vector< WriteTemplate::DirichletSetData >& dirset_info,
186 std::vector< EntityHandle >& matsets,
187 std::vector< EntityHandle >& neusets,
188 std::vector< EntityHandle >& dirsets )
190 std::vector< EntityHandle >::iterator vector_iter, end_vector_iter;
198 vector_iter = matsets.begin();
199 end_vector_iter = matsets.end();
203 std::vector< EntityHandle > parent_meshsets;
209 int highest_dimension_of_element_matsets = 0;
211 for( vector_iter = matsets.begin(); vector_iter != matsets.end(); ++vector_iter )
227 entity_iter = dummy_range.
begin();
231 if( entity_iter != dummy_range.
end() )
240 MB_SET_ERR( MB_FAILURE,
"Couldn't get matset id from a tag for an element matset" );
254 --end_elem_range_iter;
257 MB_SET_ERR( MB_FAILURE,
"Entities in matset " <<
id <<
" not of common type" );
262 if( dimension > highest_dimension_of_element_matsets ) highest_dimension_of_element_matsets = dimension;
267 std::vector< EntityHandle > tmp_conn;
274 MB_SET_ERR( MB_FAILURE,
"Element type in matset " <<
id <<
" didn't get set correctly" );
288 if( !neusets.empty() )
293 unsigned char bit = 0x1;
298 matset_info.push_back( matset_data );
305 if( highest_dimension_of_element_matsets < 2 )
308 mesh_info.
num_dim = highest_dimension_of_element_matsets;
313 end_range_iter = mesh_info.
nodes.
end();
319 vector_iter = dirsets.begin();
320 end_vector_iter = dirsets.end();
322 for( ; vector_iter != end_vector_iter; ++vector_iter )
331 MB_SET_ERR( MB_FAILURE,
"Couldn't get id tag for dirset " <<
id );
336 std::vector< EntityHandle > node_vector;
340 MB_SET_ERR( MB_FAILURE,
"Couldn't get nodes in dirset " <<
id );
343 std::vector< EntityHandle >::iterator iter, end_iter;
344 iter = node_vector.begin();
345 end_iter = node_vector.end();
347 unsigned char node_marked = 0;
349 for( ; iter != end_iter; ++iter )
354 if( 0x1 == node_marked ) dirset_data.
nodes.push_back( *iter );
358 dirset_info.push_back( dirset_data );
362 vector_iter = neusets.begin();
363 end_vector_iter = neusets.end();
365 for( ; vector_iter != end_vector_iter; ++vector_iter )
377 Range forward_elems, reverse_elems;
378 if(
get_neuset_elems( *vector_iter, 0, forward_elems, reverse_elems ) == MB_FAILURE )
return MB_FAILURE;
384 neuset_info.push_back( neuset_data );
394 unsigned char element_marked = 0;
401 if( 0x1 == element_marked )
403 neuset_data.
elements.push_back( *iter );
406 neuset_data.
side_numbers.push_back( ( sense == 1 ? 1 : 2 ) );
410 std::vector< EntityHandle > parents;
416 MB_SET_ERR( MB_FAILURE,
"Couldn't get adjacencies for neuset" );
419 if( !parents.empty() )
422 for(
unsigned int k = 0; k < parents.size(); k++ )
426 int side_no, this_sense, this_offset;
427 if( 0x1 == element_marked &&
429 this_sense == sense )
431 neuset_data.
elements.push_back( parents[k] );
439 MB_SET_ERR( MB_FAILURE,
"No parent element exists for element in neuset " << neuset_data.
id );
453 bool transform_needed =
true;
456 int num_coords_to_fill = transform_needed ? 3 : dimension;
458 std::vector< double* > coord_arrays( 3 );
459 coord_arrays[0] =
new double[num_nodes];
460 coord_arrays[1] =
new double[num_nodes];
461 coord_arrays[2] = NULL;
463 if( num_coords_to_fill == 3 ) coord_arrays[2] =
new double[num_nodes];
468 delete[] coord_arrays[0];
469 delete[] coord_arrays[1];
470 if( coord_arrays[2] )
delete[] coord_arrays[2];
474 if( transform_needed )
476 double trans_matrix[16];
480 for(
int i = 0; i < num_nodes; i++ )
485 vec2[0] = coord_arrays[0][i];
486 vec2[1] = coord_arrays[1][i];
487 vec2[2] = coord_arrays[2][i];
489 for(
int row = 0; row < 3; row++ )
492 for(
int col = 0; col < 3; col++ )
493 vec1[row] += ( trans_matrix[( row * 4 ) + col] * vec2[col] );
496 coord_arrays[0][i] = vec1[0];
497 coord_arrays[1][i] = vec1[1];
498 coord_arrays[2][i] = vec1[2];
507 delete[] coord_arrays[0];
508 delete[] coord_arrays[1];
509 if( coord_arrays[2] )
delete[] coord_arrays[2];
516 std::vector< WriteTemplate::MaterialSetData >& matset_data,
517 std::vector< WriteTemplate::NeumannSetData >& )
520 std::vector< int > connect;
526 connect.reserve( 31 );
530 for( i = 0; i < matset_data.size(); i++ )
532 matset = matset_data[i];
547 if(
false )
return MB_FAILURE;
558 int coord_size, ncoords;
560 coord_size = mesh_info.
num_dim;
561 std::cout <<
"Coord_size = " << coord_size << std::endl;
565 std::cout <<
"ncoords = " << ncoords << std::endl;
580 if( strlen( (
const char*)filename ) == 0 )
582 MB_SET_ERR( MB_FAILURE,
"Output filename not specified" );
590 MB_SET_ERR( MB_FAILURE,
"Cannot open " << filename );
598 Range& forward_elems,
599 Range& reverse_elems )
601 Range neuset_elems, neuset_meshsets;
610 if( MB_FAILURE == result )
return result;
618 if( range_iter != neuset_elems.
end() )
621 neuset_elems.
erase( range_iter, neuset_elems.
end() );
631 dum_it = neuset_elems.
begin();
635 if( current_sense == 1 || current_sense == 0 )
637 if( current_sense == -1 || current_sense == 0 )
642 for( range_iter = neuset_meshsets.
begin(); range_iter != neuset_meshsets.
end(); ++range_iter )
646 if( 0 == sense_tag || MB_FAILURE ==
mbImpl->
tag_get_data( sense_tag, &( *range_iter ), 1, &this_sense ) )
650 get_neuset_elems( *range_iter, this_sense * current_sense, forward_elems, reverse_elems );