MOAB: Mesh Oriented datABase  (version 5.5.0)
intx_in_plane_test.cpp File Reference
#include <iostream>
#include <sstream>
#include <ctime>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include "moab/Core.hpp"
#include "moab/Interface.hpp"
#include "moab/IntxMesh/Intx2MeshInPlane.hpp"
#include "moab/IntxMesh/IntxUtils.hpp"
#include "TestUtil.hpp"
#include <cmath>
+ Include dependency graph for intx_in_plane_test.cpp:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 21 of file intx_in_plane_test.cpp.

22 {
23  // check command line arg
24  const char* filename_mesh1 = STRINGIFY( MESHDIR ) "/mbcslam/m1.vtk";
25  const char* filename_mesh2 = STRINGIFY( MESHDIR ) "/mbcslam/m2.vtk";
26  const char* newFile = "intx1.vtk";
27  const char* edgesFile = "polyWithEdges.vtk";
28  if( argc == 4 )
29  {
30  filename_mesh1 = argv[1];
31  filename_mesh2 = argv[2];
32  newFile = argv[3];
33  }
34  else
35  {
36  printf( "Usage: %s <mesh_filename1> <mesh_filename2> <newFile>\n", argv[0] );
37  if( argc != 1 ) return 1;
38  printf( "No files specified. Defaulting to: %s %s %s\n", filename_mesh1, filename_mesh2, newFile );
39  }
40 
41  // read meshes in 2 file sets
42  Core moab;
43  Interface* mb = &moab; // global
44  EntityHandle sf1, sf2;
45  ErrorCode rval = mb->create_meshset( MESHSET_SET, sf1 );
46  if( MB_SUCCESS != rval ) return 1;
47  rval = mb->create_meshset( MESHSET_SET, sf2 );
48  if( MB_SUCCESS != rval ) return 1;
49  rval = mb->load_file( filename_mesh1, &sf1 );
50  if( MB_SUCCESS != rval ) return 1;
51  rval = mb->load_file( filename_mesh2, &sf2 );
52  if( MB_SUCCESS != rval ) return 1;
53 
54  EntityHandle outputSet;
55  rval = mb->create_meshset( MESHSET_SET, outputSet );
56  if( MB_SUCCESS != rval ) return 1;
57 
58  Intx2MeshInPlane worker( mb );
59  IntxAreaUtils areaAdaptor;
60  rval = areaAdaptor.positive_orientation( mb, sf1, -1 );MB_CHK_ERR( rval );
61  rval = areaAdaptor.positive_orientation( mb, sf2, -1 );MB_CHK_ERR( rval );
62 
63  worker.set_error_tolerance( 1.e-5 );
64  rval = worker.FindMaxEdges( sf1, sf2 );MB_CHK_ERR( rval );
65  // worker.enable_debug();
66  rval = worker.intersect_meshes( sf1, sf2, outputSet );
67  if( MB_SUCCESS != rval ) return 1;
68  rval = mb->write_mesh( newFile, &outputSet, 1 );
69  if( MB_SUCCESS != rval ) return 1;
70 
71  // retrieve polygons and get adjacent edges
72  Range polygons;
73  rval = mb->get_entities_by_type( outputSet, MBPOLYGON, polygons );
74  if( MB_SUCCESS != rval ) return 1;
75 
76  Range edges;
77  rval = mb->get_adjacencies( polygons, 1, true, edges, Interface::UNION );
78  if( MB_SUCCESS != rval ) return 1;
79 
80  std::cout << "number of edges:" << edges.size() << "\n";
81  // add edges to the output set
82  rval = mb->add_entities( outputSet, edges );
83  if( MB_SUCCESS != rval ) return 1;
84  rval = mb->write_mesh( edgesFile, &outputSet, 1 );
85  if( MB_SUCCESS != rval ) return 1;
86  return 0;
87 }

References moab::Core::add_entities(), moab::Core::create_meshset(), ErrorCode, moab::Intx2Mesh::FindMaxEdges(), moab::Core::get_adjacencies(), moab::Core::get_entities_by_type(), moab::Intx2Mesh::intersect_meshes(), moab::Core::load_file(), mb, MB_CHK_ERR, MB_SUCCESS, MBPOLYGON, MESHSET_SET, moab::IntxAreaUtils::positive_orientation(), moab::Intx2Mesh::set_error_tolerance(), moab::Range::size(), STRINGIFY, moab::Interface::UNION, and moab::Core::write_mesh().