MCPcopy Create free account
hub / github.com/creatale/node-dv / SplitAt

Method SplitAt

deps/tesseract/textord/colpartition.cpp:831–866  ·  view source on GitHub ↗

Split this partition at the given x coordinate, returning the right half and keeping the left half in this.

Source from the content-addressed store, hash-verified

829// Split this partition at the given x coordinate, returning the right
830// half and keeping the left half in this.
831ColPartition* ColPartition::SplitAt(int split_x) {
832 if (split_x <= bounding_box_.left() || split_x >= bounding_box_.right())
833 return NULL; // There will be no change.
834 ColPartition* split_part = ShallowCopy();
835 split_part->set_owns_blobs(owns_blobs());
836 BLOBNBOX_C_IT it(&boxes_);
837 for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
838 BLOBNBOX* bbox = it.data();
839 ColPartition* prev_owner = bbox->owner();
840 ASSERT_HOST(!owns_blobs() || prev_owner == this || prev_owner == NULL);
841 const TBOX& box = bbox->bounding_box();
842 if (box.left() >= split_x) {
843 split_part->AddBox(it.extract());
844 if (owns_blobs() && prev_owner != NULL)
845 bbox->set_owner(split_part);
846 }
847 }
848 if (it.empty()) {
849 // Possible if split-x passes through the first blob.
850 it.add_list_after(&split_part->boxes_);
851 }
852 ASSERT_HOST(!it.empty());
853 if (split_part->IsEmpty()) {
854 // Split part ended up with nothing. Possible if split_x passes
855 // through the last blob.
856 delete split_part;
857 return NULL;
858 }
859 right_key_tab_ = false;
860 split_part->left_key_tab_ = false;
861 right_margin_ = split_x;
862 split_part->left_margin_ = split_x;
863 ComputeLimits();
864 split_part->ComputeLimits();
865 return split_part;
866}
867
868// Recalculates all the coordinate limits of the partition.
869void ColPartition::ComputeLimits() {

Callers 3

SplitCPHorMethod · 0.80
GridSplitPartitionsMethod · 0.80

Calls 14

set_owns_blobsMethod · 0.80
dataMethod · 0.80
ownerMethod · 0.80
AddBoxMethod · 0.80
set_ownerMethod · 0.80
ComputeLimitsMethod · 0.80
mark_cycle_ptMethod · 0.45
cycled_listMethod · 0.45
forwardMethod · 0.45
bounding_boxMethod · 0.45
extractMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected