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

Method BuildFromShape

deps/tesseract/classify/shapetable.cpp:423–446  ·  view source on GitHub ↗

Expands all the classes/fonts in the shape individually to build a ShapeTable.

Source from the content-addressed store, hash-verified

421// Expands all the classes/fonts in the shape individually to build
422// a ShapeTable.
423int ShapeTable::BuildFromShape(const Shape& shape,
424 const ShapeTable& master_shapes) {
425 BitVector shape_map(master_shapes.NumShapes());
426 for (int u_ind = 0; u_ind < shape.size(); ++u_ind) {
427 for (int f_ind = 0; f_ind < shape[u_ind].font_ids.size(); ++f_ind) {
428 int c = shape[u_ind].unichar_id;
429 int f = shape[u_ind].font_ids[f_ind];
430 int master_id = master_shapes.FindShape(c, f);
431 if (master_id >= 0) {
432 shape_map.SetBit(master_id);
433 } else if (FindShape(c, f) < 0) {
434 AddShape(c, f);
435 }
436 }
437 }
438 int num_masters = 0;
439 for (int s = 0; s < master_shapes.NumShapes(); ++s) {
440 if (shape_map[s]) {
441 AddShape(master_shapes.GetShape(s));
442 ++num_masters;
443 }
444 }
445 return num_masters;
446}
447
448// Returns true if the shapes are already merged.
449bool ShapeTable::AlreadyMerged(int shape_id1, int shape_id2) const {

Callers

nothing calls this directly

Calls 3

FindShapeMethod · 0.80
SetBitMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected