00001 #include "ObjFile_inserter.h"
00002 #include <CGAL/Point_3.h>
00003 #include "set_point.h"
00004
00005
00006
00007 #define CHECK_INDICES 1
00008 #define REPORT_INDICES 0
00009
00010
00011
00012 void MNI::ObjFile_inserter::Quadmesh::operator() ( HDS& hds )
00013 {
00014
00015
00016 int m_points = qmesh.m;
00017 int n_points = qmesh.n;
00018 int n_vert = m_points * n_points;
00019
00020
00021
00022
00023
00024 int m_patches, n_patches;
00025 get_quadmesh_n_objects( &qmesh, &m_patches, &n_patches );
00026 int n_face = m_patches * n_patches;
00027
00028
00029
00030
00031
00032
00033
00034
00035 int n_hedge = 2 * ( m_points*n_patches + n_points*m_patches);
00036
00037
00038
00039
00040
00041 if ( split_patches ) {
00042 n_hedge += 2 * n_face;
00043 n_face *= 2;
00044 }
00045
00046 CGAL::Polyhedron_incremental_builder_3<HDS> B( hds, true );
00047
00048 B.begin_surface( n_vert, n_face, n_hedge );
00049
00050 HDS::Point p;
00051 for( int i = 0; i < n_vert; ++i ) {
00052 set_point( p, Point_x(qmesh.points[i]),
00053 Point_y(qmesh.points[i]),
00054 Point_z(qmesh.points[i]) );
00055 B.add_vertex( p );
00056 }
00057
00058 int facet_index[4];
00059 for( int i = 0; i < m_patches; ++i ) {
00060 for( int j = 0; j < n_patches; ++j ) {
00061 get_quadmesh_patch_indices( &qmesh, i, j, facet_index );
00062
00063
00064 CGAL_assertion( facet_index[0] != facet_index[1] );
00065 CGAL_assertion( facet_index[0] != facet_index[2] );
00066 CGAL_assertion( facet_index[0] != facet_index[3] );
00067 CGAL_assertion( facet_index[1] != facet_index[2] );
00068 CGAL_assertion( facet_index[1] != facet_index[3] );
00069 CGAL_assertion( facet_index[2] != facet_index[3] );
00070
00071 if ( split_patches ) {
00072 B.begin_facet();
00073 B.add_vertex_to_facet( facet_index[0] );
00074 B.add_vertex_to_facet( facet_index[1] );
00075 B.add_vertex_to_facet( facet_index[2] );
00076 B.end_facet();
00077 B.begin_facet();
00078 B.add_vertex_to_facet( facet_index[2] );
00079 B.add_vertex_to_facet( facet_index[3] );
00080 B.add_vertex_to_facet( facet_index[0] );
00081 B.end_facet();
00082 } else {
00083 B.begin_facet();
00084 B.add_vertex_to_facet( facet_index[0] );
00085 B.add_vertex_to_facet( facet_index[1] );
00086 B.add_vertex_to_facet( facet_index[2] );
00087 B.add_vertex_to_facet( facet_index[3] );
00088 B.end_facet();
00089
00090 }
00091 }
00092 }
00093
00094 B.end_surface();
00095 }