Doxygen Source Code Documentation
SUMA_gts.c File Reference
#include "SUMA_suma.h"
#include "SUMA_gts.h"
Go to the source code of this file.
Functions | |
GtsSurface * | SumaToGts (SUMA_SurfaceObject *SO) |
void | coarsen (GtsSurface *s, int stop) |
gboolean | stop_number (gdouble cost, guint number, guint *max) |
void | refine (GtsSurface *s, int stop) |
SUMA_SurfaceObject * | SUMA_Mesh_Resample (SUMA_SurfaceObject *SO, float edge_factor) |
resample a mesh so that the resultant surface has edge_factor as many edges as the original one | |
Variables | |
SUMA_CommonFields * | SUMAg_CF |
SUMA_DO * | SUMAg_DOv |
SUMA_SurfaceViewer * | SUMAg_SVv |
int | SUMAg_N_SVv |
int | SUMAg_N_DOv |
Function Documentation
|
coarsens with set parameters Definition at line 258 of file SUMA_gts.c. References fold(). Referenced by SUMA_Mesh_Resample().
00259 { 00260 GtsVolumeOptimizedParams params = { 0.5, 0.5, 0. }; 00261 gdouble fold = PI/180.; 00262 gts_surface_coarsen (s, 00263 (GtsKeyFunc) gts_volume_optimized_cost, 00264 ¶ms, 00265 (GtsCoarsenFunc) gts_volume_optimized_vertex, 00266 ¶ms, 00267 (GtsStopFunc) gts_coarsen_stop_number, 00268 &stop, 00269 fold); 00270 } |
|
coarsens with set parameters Definition at line 279 of file SUMA_gts.c. References stop_number(). Referenced by SUMA_Mesh_Resample().
00280 { 00281 gts_surface_refine(s, NULL, NULL, NULL, NULL, 00282 (GtsStopFunc)stop_number, &stop); 00283 } |
|
Definition at line 272 of file SUMA_gts.c. Referenced by refine().
00273 { 00274 if (number > *max) 00275 return TRUE; 00276 return FALSE; 00277 } |
|
resample a mesh so that the resultant surface has edge_factor as many edges as the original one
Definition at line 288 of file SUMA_gts.c. References coarsen(), SUMA_SurfaceObject::EL, SUMA_SurfaceObject::FaceSetDim, SUMA_SurfaceObject::FaceSetList, GTS_OUT, gts_surface_suma(), GTS_VTK_OUT, LocalHead, SUMA_EDGE_LIST::N_Distinct_Edges, SUMA_SurfaceObject::N_FaceSet, SUMA_SurfaceObject::N_Node, SUMA_SurfaceObject::NodeDim, SUMA_SurfaceObject::NodeList, refine(), SUMA_Alloc_SurfObject_Struct(), SUMA_Boolean, SUMA_ENTRY, SUMA_RETURN, SUMA_S_Err, SUMA_S_Note, SUMA_S_Warn, SUMA_SL_Err, SUMA_SurfaceMetrics(), and SumaToGts(). Referenced by main().
00289 { 00290 static char FuncName[]={"SUMA_Mesh_Resample"}; 00291 SUMA_SurfaceObject *S2=NULL; 00292 GtsSurface* s = NULL; 00293 SUMA_Boolean LocalHead = NOPE; 00294 00295 SUMA_ENTRY; 00296 00297 if (!SO) { 00298 SUMA_SL_Err("NULL SO"); 00299 SUMA_RETURN(S2); 00300 } 00301 if (!SO->EL) { 00302 SUMA_S_Warn("NULL Edge List, computing it"); 00303 if (!SUMA_SurfaceMetrics(SO, "EdgeList", NULL)) { 00304 SUMA_SL_Err("Failed to create EdgeList"); 00305 SUMA_RETURN(S2); 00306 } 00307 } 00308 /* create a GTS surface */ 00309 s = SumaToGts(SO); 00310 if (!s) { 00311 SUMA_S_Err("Failed to change SO to GTS surface"); 00312 SUMA_RETURN(S2); 00313 } 00314 if (LocalHead) { /* see if surface was created well in GTS format */ 00315 SUMA_S_Note("Writing initial surface in GTS form"); 00316 GTS_OUT("gtsout.surf",s); 00317 GTS_VTK_OUT("vtkout.surf",s); 00318 } 00319 00320 /* resample */ 00321 if (1) { 00322 SUMA_S_Note("Changing mesh density\n"); 00323 if (edge_factor < 1) 00324 coarsen(s, SO->EL->N_Distinct_Edges * edge_factor); 00325 else 00326 refine(s, SO->EL->N_Distinct_Edges * edge_factor); 00327 } else { 00328 SUMA_S_Note("Leaving surface untouched\n"); 00329 } 00330 if (!s) { 00331 SUMA_SL_Err("Failed to refine"); 00332 SUMA_RETURN(S2); 00333 } 00334 00335 /* change the surface back to SUMA */ 00336 S2 = SUMA_Alloc_SurfObject_Struct(1); 00337 gts_surface_suma (s, 00338 &(S2->NodeList), &(S2->N_Node), &(S2->NodeDim), 00339 &(S2->FaceSetList), &(S2->N_FaceSet), &(S2->FaceSetDim)); 00340 00341 gts_object_destroy((GtsObject*)s); s = NULL; 00342 00343 SUMA_RETURN(S2); 00344 } |
|
copies suma surface into a gts surface Definition at line 34 of file SUMA_gts.c. References SUMA_SurfaceObject::EL, SUMA_EDGE_LIST::EL, SUMA_EDGE_LIST::ELps, SUMA_SurfaceObject::FaceSetList, i, LocalHead, n1, n2, SUMA_EDGE_LIST::N_Distinct_Edges, SUMA_EDGE_LIST::N_EL, SUMA_SurfaceObject::N_FaceSet, SUMA_SurfaceObject::N_Node, SUMA_SurfaceObject::NodeList, SUMA_Boolean, SUMA_ENTRY, SUMA_FindEdge(), SUMA_LH, SUMA_Print_Surface_Object(), SUMA_RETURN, SUMA_SL_Err, and v1. Referenced by SUMA_Mesh_Resample().
00035 { 00036 static char FuncName[]={"SumaToGts"}; 00037 GtsSurface* s = NULL; 00038 GtsVertex ** vertices = NULL; 00039 GtsEdge ** edges = NULL; 00040 int i = 0; /*counters */ 00041 int n = 0; 00042 int *MapToGts = NULL; /*used to map EL vector to edge vector*/ 00043 SUMA_Boolean LocalHead = NOPE; 00044 00045 SUMA_ENTRY; 00046 00047 if (!SO->EL) { 00048 SUMA_SL_Err("Null Edgeist!"); 00049 SUMA_RETURN(s); 00050 } 00051 00052 SUMA_LH("In with "); 00053 if (LocalHead) SUMA_Print_Surface_Object(SO, stderr); 00054 00055 s = gts_surface_new( gts_surface_class (), 00056 gts_face_class (), 00057 gts_edge_class (), 00058 gts_vertex_class ()); 00059 vertices = (GtsVertex **)g_malloc (SO->N_Node * sizeof (GtsVertex *)); 00060 n = 0; 00061 for ( i=0; i< SO->N_Node*3; i+=3) 00062 { 00063 vertices[n] = gts_vertex_new( s->vertex_class, 00064 (gdouble)SO->NodeList[i], 00065 (gdouble)SO->NodeList[i+1], 00066 (gdouble)SO->NodeList[i+2]); 00067 if (LocalHead) 00068 fprintf(SUMA_STDERR, "Added vertex (%d/%d)%f %f %f\n" 00069 "Stored gts (fails for some reason, but surface is OK) %f %f %f\n" 00070 , n, SO->N_Node-1, SO->NodeList[i], SO->NodeList[i+1], SO->NodeList[i+2] 00071 , (float)(vertices[n]->p.x), (float)(vertices[n]->p.y), (float)(vertices[n]->p.z)); 00072 ++n; 00073 } 00074 edges = (GtsEdge**)g_malloc (SO->EL->N_Distinct_Edges * sizeof (GtsEdge*)); 00075 n = 0; 00076 MapToGts = (int *)g_malloc ( SO->EL->N_EL * sizeof(int)); 00077 for ( i=0; i< SO->EL->N_EL; i++) 00078 { 00079 if (SO->EL->ELps[i][2] > 0) 00080 { /* a unique edge*/ 00081 GtsVertex* v1 = vertices[SO->EL->EL[i][0]]; 00082 GtsVertex* v2 = vertices[SO->EL->EL[i][1]]; 00083 if (SO->EL->ELps[i][0] == 1) { 00084 edges[n++] = gts_edge_new ( s->edge_class, v2, v1 ); 00085 if (LocalHead) fprintf(SUMA_STDERR,"Added edge of vertices: %d %d \n", SO->EL->EL[i][1], SO->EL->EL[i][0]); 00086 } else { 00087 edges[n++] = gts_edge_new ( s->edge_class, v1, v2 ); 00088 if (LocalHead) fprintf(SUMA_STDERR,"Added edge of nodes: %d %d \n", SO->EL->EL[i][0], SO->EL->EL[i][1]); 00089 } 00090 } 00091 MapToGts[i] = n-1; /* n-1 bc n was just incremented */ 00092 if (LocalHead) fprintf(SUMA_STDERR,"SUMA edge %d is mapped to GTS edge %d\n", i, n-1); 00093 } 00094 00095 if (n != SO->EL->N_Distinct_Edges) 00096 { 00097 fprintf(SUMA_STDERR, "distinct edges didn't equal N_Distinct_Edges"); 00098 exit(1); 00099 } 00100 /* this loop isn't working, stupid tri_limb 00101 for ( i=0; i< SO->N_FaceSet; i++) 00102 { 00103 gts_surface_add_face(s, 00104 gts_face_new ( s->face_class, 00105 edges[MapToGts[SO->EL->Tri_limb[i][0]]], 00106 edges[MapToGts[SO->EL->Tri_limb[i][1]]], 00107 edges[MapToGts[SO->EL->Tri_limb[i][2]]])); 00108 } 00109 */ 00110 for ( i=0; i< SO->N_FaceSet*3; i+=3) 00111 { 00112 int n1 = SO->FaceSetList[i]; 00113 int n2 = SO->FaceSetList[i+1]; 00114 int n3 = SO->FaceSetList[i+2]; 00115 GtsEdge* e1 = edges[MapToGts[SUMA_FindEdge( SO->EL, n1, n2)]]; 00116 GtsEdge* e2 = edges[MapToGts[SUMA_FindEdge( SO->EL, n2, n3)]]; 00117 GtsEdge* e3 = edges[MapToGts[SUMA_FindEdge( SO->EL, n3, n1)]]; 00118 gts_surface_add_face(s, 00119 gts_face_new ( s->face_class, e1, e2, e3)); 00120 if (LocalHead) fprintf(SUMA_STDERR, "Added face of SUMA edges: %d %d %d\n" 00121 " MapToGTS : %d %d %d\n", 00122 SUMA_FindEdge( SO->EL, n1, n2), SUMA_FindEdge( SO->EL, n2, n3), SUMA_FindEdge( SO->EL, n3, n1), 00123 MapToGts[SUMA_FindEdge( SO->EL, n1, n2)], MapToGts[SUMA_FindEdge( SO->EL, n2, n3)], MapToGts[SUMA_FindEdge( SO->EL, n3, n1)]); 00124 } 00125 00126 g_free (vertices); 00127 g_free (edges); 00128 g_free (MapToGts); 00129 SUMA_RETURN( s ); 00130 } |
Variable Documentation
|
Global pointer to structure containing info common to all viewers Definition at line 24 of file SUMA_gts.c. |
|
Global pointer to Displayable Object structure vector Definition at line 25 of file SUMA_gts.c. |
|
Number of DOs stored in DOv Definition at line 28 of file SUMA_gts.c. |
|
Number of SVs stored in SVv Definition at line 27 of file SUMA_gts.c. |
|
Global pointer to the vector containing the various Surface Viewer Structures Definition at line 26 of file SUMA_gts.c. |