[brlcad-commits] SF.net SVN: brlcad:[38374] brlcad/trunk/src/conv/obj-g_new.c
Open Source Solid Modeling CAD
Brought to you by:
brlcad
From: <r_...@us...> - 2010-04-07 22:26:05
|
Revision: 38374 http://brlcad.svn.sourceforge.net/brlcad/?rev=38374&view=rev Author: r_weiss Date: 2010-04-07 22:25:58 +0000 (Wed, 07 Apr 2010) Log Message: ----------- more nmg creating logic testing Modified Paths: -------------- brlcad/trunk/src/conv/obj-g_new.c Modified: brlcad/trunk/src/conv/obj-g_new.c =================================================================== --- brlcad/trunk/src/conv/obj-g_new.c 2010-04-07 19:34:58 UTC (rev 38373) +++ brlcad/trunk/src/conv/obj-g_new.c 2010-04-07 22:25:58 UTC (rev 38374) @@ -187,9 +187,6 @@ int grp_mode, size_t grp_indx, fastf_t conversion_factor, - struct model *m, - struct nmgregion *r, - struct shell *s, struct bn_tol *tol, int *empty) { @@ -202,6 +199,9 @@ size_t groupid = 0; size_t numNorTriangles_in_current_bot = 0; /* NMG2s */ + struct model *m = (struct model *)NULL; + struct nmgregion *r = (struct nmgregion *)NULL; + struct shell *s = (struct shell *)NULL; const size_t (**index_arr_nv_faces_history)[2]; /* used by nv_faces */ const size_t (**index_arr_nv_faces_history_tmp)[2]; /* used by nv_faces */ size_t *size_history = NULL ; @@ -324,6 +324,15 @@ size = obj_polygonal_nv_face_vertices(ga->contents,i,&index_arr_nv_faces); } + if ( found && !numNorPolygons_in_current_shell) { + m = nmg_mm(); + r = nmg_mrsv(m); + s = BU_LIST_FIRST(shell, &r->s_hd); + NMG_CK_MODEL(m); + NMG_CK_REGION(r); + NMG_CK_SHELL(s); + } + /* test for and force the skip of degenerate faces */ /* in this case degenerate faces are those with duplicate vertices */ if ( found && skip_degenerate_faces ) { @@ -345,6 +354,17 @@ i+1, (index_arr_nv_faces[vert][0])+1, (index_arr_nv_faces[vert2][0])+1); + } else { + /* test distance between vertices, any vertices closer + than 0.5mm is too close */ + fastf_t distance_between_vertices = 0.0 ; + distance_between_vertices = \ + DIST_PT_PT(ga->vert_list[index_arr_nv_faces[vert][0]], \ + ga->vert_list[index_arr_nv_faces[vert2][0]]) ; + if ( (distance_between_vertices * conversion_factor) < 0.5 ) { + found = 0; /* i.e. unfind this face */ + degenerate_face = 1; + } } vert2++; } @@ -826,8 +846,16 @@ nmg_rebound(m, tol); #endif + +#if 0 bu_log("about to mk_bot_from_nmg\n"); mk_bot_from_nmg(outfp, bu_vls_addr(&outputObjectName), s); +#endif + bu_log("about to mk_nmg\n"); + if (mk_nmg(outfp, bu_vls_addr(&outputObjectName), m)) { + bu_log("mk_nmg failed\n"); + } + nmg_km(m); } else { bu_log("Object %s has no faces\n", bu_vls_addr(&outputObjectName)); } @@ -889,9 +917,8 @@ int parse_err = 0; /* NMG2s */ - struct model *m ; - struct nmgregion *r ; - struct shell *s ; + rt_g.NMG_debug = rt_g.NMG_debug & DEBUG_TRI ; + struct bn_tol tol_struct ; struct bn_tol *tol ; @@ -899,16 +926,8 @@ tol = &tol_struct; - m = nmg_mm(); - r = nmg_mrsv(m); - s = BU_LIST_FIRST(shell, &r->s_hd); - - NMG_CK_MODEL(m); - NMG_CK_REGION(r); - NMG_CK_SHELL(s); - tol->magic = BN_TOL_MAGIC; - tol->dist = 0.00005; + tol->dist = 0.0005; tol->dist_sq = tol->dist * tol->dist; tol->perp = 1e-6; tol->para = 1 - tol->perp; @@ -1023,15 +1042,15 @@ } #endif - empty = 0 ; /* set to false to force first region and - shell of model to be created */ + empty = 0 ; /* set to false to force the model/region/shell + to be created for the next grouping */ switch (grouping_option) { case 'g': bu_log("ENTERED 'g' PROCESSING\n"); for (i = 0 ; i < ga.numGroups ; i++) { bu_log("(%lu) current group name is (%s)\n", i, ga.str_arr_obj_groups[i]); - weiss_result = process_nv_faces(&ga, fd_out, GRP_GROUP, i, 1000.00, m, r, s, tol, &empty); + weiss_result = process_nv_faces(&ga, fd_out, GRP_GROUP, i, 1000.00, tol, &empty); } bu_log("EXITED 'g' PROCESSING\n"); break; @@ -1046,17 +1065,8 @@ for (i = 0 ; i < ga.numObjects ; i++) { bu_log("(%lu) current object group name is (%s)\n", i, ga.str_arr_obj_objects[i]); - /* if when process_nv_faces finished and the shell was not empty - then create a new region and shell for the next run of - process_nv_faces */ - if ( !empty ) { - r = nmg_mrsv(m); - s = BU_LIST_FIRST(shell, &r->s_hd); + weiss_result = process_nv_faces(&ga, fd_out, GRP_OBJECT, i, 1000.00, tol, &empty); - } - - weiss_result = process_nv_faces(&ga, fd_out, GRP_OBJECT, i, 1000.00, m, r, s, tol, &empty); - } /* numObjects loop */ /* if the last shell is empty, need to delete it */ @@ -1068,14 +1078,14 @@ for (i = 0 ; i < ga.numMaterials ; i++) { bu_log("(%lu) current object group name is (%s)\n", i, ga.str_arr_obj_materials[i]); - weiss_result = process_nv_faces(&ga, fd_out, GRP_MATERIAL, i, 1000.00, m, r, s, tol, &empty); + weiss_result = process_nv_faces(&ga, fd_out, GRP_MATERIAL, i, 1000.00, tol, &empty); } /* numMaterials loop */ bu_log("EXITED 'm' PROCESSING\n"); break; case 't': bu_log("ENTERED 't' PROCESSING\n"); - weiss_result = process_nv_faces(&ga, fd_out, GRP_TEXTURE, i, 1000.00, m, r, s, tol, &empty); + weiss_result = process_nv_faces(&ga, fd_out, GRP_TEXTURE, i, 1000.00, tol, &empty); bu_log("EXITED 't' PROCESSING\n"); break; default: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |