#include "makechop.h"
#include "render.h"
#include "structures.h"
Go to the source code of this file.
Split this blob into two blobs by applying the splits included in the seam description.
Definition at line 39 of file makechop.cpp.
References CHAR_SAMPLE::blob(), check_outline_mem(), divide_blobs(), seam_record::location, make_double_split(), make_split_blobs(), make_triple_split(), NULL, seam_record::split1, seam_record::split2, and seam_record::split3.
Referenced by attempt_blob_chop().
00039 { 00040 check_outline_mem(); 00041 if (seam->split1 == NULL) { 00042 divide_blobs (blob, other_blob, seam->location); 00043 } 00044 else if (seam->split2 == NULL) { 00045 make_split_blobs(blob, other_blob, seam); 00046 } 00047 else if (seam->split3 == NULL) { 00048 make_double_split(blob, other_blob, seam); 00049 } 00050 else { 00051 make_triple_split(blob, other_blob, seam); 00052 } 00053 00054 check_outline_mem(); 00055 }
Create two blobs by grouping the outlines in the appropriate blob.
The outlines that are beyond the location point are moved to the other blob. The ones whose x location is less than that point are retained in the original blob.
Definition at line 66 of file makechop.cpp.
References CHAR_SAMPLE::blob(), olinestruct::botright, olinestruct::next, NULL, blobstruct::outlines, olinestruct::topleft, and TPOINT::x.
Referenced by apply_seam(), and form_two_blobs().
00066 { 00067 TESSLINE *outline; 00068 TESSLINE *outline1 = NULL; 00069 TESSLINE *outline2 = NULL; 00070 00071 outline = blob->outlines; 00072 blob->outlines = NULL; 00073 00074 while (outline != NULL) { 00075 if ((outline->topleft.x + outline->botright.x) / 2 < location) { 00076 /* Outline is in 1st blob */ 00077 if (outline1) { 00078 outline1->next = outline; 00079 } 00080 else { 00081 blob->outlines = outline; 00082 } 00083 outline1 = outline; 00084 } 00085 else { 00086 /* Outline is in 2nd blob */ 00087 if (outline2) { 00088 outline2->next = outline; 00089 } 00090 else { 00091 other_blob->outlines = outline; 00092 } 00093 outline2 = outline; 00094 } 00095 00096 outline = outline->next; 00097 } 00098 00099 if (outline1) 00100 outline1->next = NULL; 00101 if (outline2) 00102 outline2->next = NULL; 00103 }
Group the outlines from the first blob into both of them based on information about the split.
Definition at line 111 of file makechop.cpp.
References CHAR_SAMPLE::blob(), chop_debug, correct_blob_order(), Cyan, display_blob(), divide_blobs(), eliminate_duplicate_outlines(), Red, and setup_blob_outlines().
Referenced by make_double_split(), make_split_blobs(), and make_triple_split().
00111 { 00112 setup_blob_outlines(blob); 00113 00114 divide_blobs(blob, other_blob, location); 00115 00116 eliminate_duplicate_outlines(blob); 00117 eliminate_duplicate_outlines(other_blob); 00118 00119 correct_blob_order(blob, other_blob); 00120 00121 #ifndef GRAPHICS_DISABLED 00122 if (chop_debug) { 00123 display_blob(blob, Red); 00124 #ifdef __UNIX__ 00125 sleep (1); 00126 #endif 00127 display_blob(other_blob, Cyan); 00128 } 00129 #endif 00130 }
Create two blobs out of one by splitting the original one in half.
Return the resultant blobs for classification.
Definition at line 139 of file makechop.cpp.
References CHAR_SAMPLE::blob(), form_two_blobs(), seam_record::location, make_single_split(), seam_record::split1, and seam_record::split2.
Referenced by apply_seam().
00139 { 00140 make_single_split (blob->outlines, seam->split1); 00141 make_single_split (blob->outlines, seam->split2); 00142 form_two_blobs (blob, other_blob, seam->location); 00143 }
Create two outlines out of one by splitting the original one in half.
Return the resultant outlines.
Definition at line 152 of file makechop.cpp.
References assert(), olinestruct::child, olinestruct::loop, newoutline(), olinestruct::next, NULL, split_record::point1, split_record::point2, setup_outline(), and split_outline().
Referenced by make_double_split(), make_split_blobs(), and make_triple_split().
00152 { 00153 assert (outlines != NULL); 00154 00155 split_outline (split->point1, split->point2); 00156 00157 while (outlines->next != NULL) 00158 outlines = outlines->next; 00159 00160 outlines->next = newoutline (); 00161 outlines->next->loop = split->point1; 00162 outlines->next->child = NULL; 00163 setup_outline (outlines->next); 00164 00165 outlines = outlines->next; 00166 00167 outlines->next = newoutline (); 00168 outlines->next->loop = split->point2; 00169 outlines->next->child = NULL; 00170 setup_outline (outlines->next); 00171 00172 outlines->next->next = NULL; 00173 }
Create two blobs out of one by splitting the original one in half.
Return the resultant blobs for classification.
Definition at line 182 of file makechop.cpp.
References CHAR_SAMPLE::blob(), form_two_blobs(), seam_record::location, make_single_split(), and seam_record::split1.
Referenced by apply_seam().
00182 { 00183 make_single_split (blob->outlines, seam->split1); 00184 00185 form_two_blobs (blob, other_blob, seam->location); 00186 }
Create two blobs out of one by splitting the original one in half.
This splitting is accomplished by applying three separate splits on the outlines. Three of the starting outlines will produce two ending outlines. Return the resultant blobs for classification.
Definition at line 197 of file makechop.cpp.
References CHAR_SAMPLE::blob(), form_two_blobs(), seam_record::location, make_single_split(), seam_record::split1, seam_record::split2, and seam_record::split3.
Referenced by apply_seam().
00197 { 00198 make_single_split (blob->outlines, seam->split1); 00199 make_single_split (blob->outlines, seam->split2); 00200 make_single_split (blob->outlines, seam->split3); 00201 00202 form_two_blobs (blob, other_blob, seam->location); 00203 }
Remove the seam between these two blobs.
Produce one blob as a result. The seam may consist of one, two, or three splits. Each of these split must be removed from the outlines.
Definition at line 213 of file makechop.cpp.
References CHAR_SAMPLE::blob(), check_outline_mem(), eliminate_duplicate_outlines(), olinestruct::next, NULL, oldblob(), blobstruct::outlines, setup_blob_outlines(), seam_record::split1, seam_record::split2, seam_record::split3, and undo_single_split().
Referenced by attempt_blob_chop().
00213 { 00214 TESSLINE *outline; 00215 00216 if (!seam) 00217 return; /* Append other blob outlines */ 00218 if (blob->outlines == NULL) { 00219 blob->outlines = other_blob->outlines; 00220 other_blob->outlines = NULL; 00221 } 00222 00223 outline = blob->outlines; 00224 while (outline->next) 00225 outline = outline->next; 00226 outline->next = other_blob->outlines; 00227 oldblob(other_blob); 00228 00229 if (seam->split1 == NULL) { 00230 } 00231 else if (seam->split2 == NULL) { 00232 undo_single_split (blob, seam->split1); 00233 } 00234 else if (seam->split3 == NULL) { 00235 undo_single_split (blob, seam->split1); 00236 undo_single_split (blob, seam->split2); 00237 } 00238 else { 00239 undo_single_split (blob, seam->split3); 00240 undo_single_split (blob, seam->split2); 00241 undo_single_split (blob, seam->split1); 00242 } 00243 00244 setup_blob_outlines(blob); 00245 eliminate_duplicate_outlines(blob); 00246 00247 check_outline_mem(); 00248 }
Undo a seam that is made by a single split.
Perform the correct magic to reconstruct the appropriate set of outline data structures.
Definition at line 258 of file makechop.cpp.
References CHAR_SAMPLE::blob(), olinestruct::child, olinestruct::loop, newoutline(), olinestruct::next, NULL, split_record::point1, split_record::point2, and unsplit_outlines().
Referenced by undo_seam().
00258 { 00259 TESSLINE *outline1; 00260 TESSLINE *outline2; 00261 /* Modify edge points */ 00262 unsplit_outlines (split->point1, split->point2); 00263 00264 outline1 = newoutline (); 00265 outline1->next = blob->outlines; 00266 blob->outlines = outline1; 00267 outline1->loop = split->point1; 00268 outline1->child = NULL; 00269 00270 outline2 = newoutline (); 00271 outline2->next = blob->outlines; 00272 blob->outlines = outline2; 00273 outline2->loop = split->point2; 00274 outline2->child = NULL; 00275 }