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

Function icvReadGraph

deps/opencv/modules/core/src/persistence.cpp:4592–4785  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4590
4591
4592static void*
4593icvReadGraph( CvFileStorage* fs, CvFileNode* node )
4594{
4595 void* ptr = 0;
4596 char* read_buf = 0;
4597 CvGraphVtx** vtx_buf = 0;
4598 CvGraph* graph;
4599 CvFileNode *header_node, *vtx_node, *edge_node;
4600 int flags, vtx_count, edge_count;
4601 int vtx_size = sizeof(CvGraphVtx), edge_size, header_size = sizeof(CvGraph);
4602 int src_vtx_size = 0, src_edge_size;
4603 int fmt_pairs[CV_FS_MAX_FMT_PAIRS], fmt_pair_count;
4604 int vtx_items_per_elem = 0, edge_items_per_elem = 0;
4605 int edge_user_align = sizeof(float);
4606 int read_buf_size;
4607 int i, k;
4608 const char* flags_str;
4609 const char* header_dt;
4610 const char* vtx_dt;
4611 const char* edge_dt;
4612 char* endptr = 0;
4613
4614 flags_str = cvReadStringByName( fs, node, "flags", 0 );
4615 vtx_dt = cvReadStringByName( fs, node, "vertex_dt", 0 );
4616 edge_dt = cvReadStringByName( fs, node, "edge_dt", 0 );
4617 vtx_count = cvReadIntByName( fs, node, "vertex_count", -1 );
4618 edge_count = cvReadIntByName( fs, node, "edge_count", -1 );
4619
4620 if( !flags_str || vtx_count == -1 || edge_count == -1 || !edge_dt )
4621 CV_Error( CV_StsError, "Some of essential graph attributes are absent" );
4622
4623 flags = CV_SET_MAGIC_VAL + CV_GRAPH;
4624
4625 if( isxdigit(flags_str[0]) )
4626 {
4627 const int OLD_SEQ_ELTYPE_BITS = 9;
4628 const int OLD_SEQ_KIND_BITS = 3;
4629 const int OLD_SEQ_FLAG_SHIFT = OLD_SEQ_KIND_BITS + OLD_SEQ_ELTYPE_BITS;
4630 const int OLD_GRAPH_FLAG_ORIENTED = 1 << OLD_SEQ_FLAG_SHIFT;
4631
4632 int flags0 = (int)strtol( flags_str, &endptr, 16 );
4633 if( endptr == flags_str || (flags0 & CV_MAGIC_MASK) != CV_SET_MAGIC_VAL )
4634 CV_Error( CV_StsError, "The sequence flags are invalid" );
4635 if( flags0 & OLD_GRAPH_FLAG_ORIENTED )
4636 flags |= CV_GRAPH_FLAG_ORIENTED;
4637 }
4638 else
4639 {
4640 if( strstr(flags_str, "oriented") )
4641 flags |= CV_GRAPH_FLAG_ORIENTED;
4642 }
4643
4644 header_dt = cvReadStringByName( fs, node, "header_dt", 0 );
4645 header_node = cvGetFileNodeByName( fs, node, "header_user_data" );
4646
4647 if( (header_dt != 0) ^ (header_node != 0) )
4648 CV_Error( CV_StsError,
4649 "One of \"header_dt\" and \"header_user_data\" is there, while the other is not" );

Callers

nothing calls this directly

Calls 14

cvReadStringByNameFunction · 0.85
cvReadIntByNameFunction · 0.85
cvGetFileNodeByNameFunction · 0.85
icvCalcElemSizeFunction · 0.85
icvDecodeFormatFunction · 0.85
cv_isdigitFunction · 0.85
cvCreateGraphFunction · 0.85
cvReadRawDataFunction · 0.85
cvAllocFunction · 0.85
cvStartReadRawDataFunction · 0.85
cvReadRawDataSliceFunction · 0.85
cvGraphAddVtxFunction · 0.85

Tested by

no test coverage detected