Exemplo n.º 1
0
void TestMap()
{
    std::map<std::string, std::vector<std::string>> mapFamilies;

    addFamily(mapFamilies, "Zhang");
    addFamily(mapFamilies, "Li");
    addChild(mapFamilies, "Zhang", "San");
    addChild(mapFamilies, "Li", "Si");
    addChild(mapFamilies, "Wang", "Wu");

    for (auto m : mapFamilies)
    {
        std::cout << m.first << " family has the following child:" << std::endl;
        for (auto v : m.second)
        {
            std::cout << v << std::endl;
        }
    }
}
Exemplo n.º 2
0
/**
 * if @param family or @param person equals to "0", nothing will happen
 * or a family and/or a person will be created if needed
 */
int Pedigree::add(const std::string& family, const std::string& person) {
  if (family == "0" || person == "0") return 0;

  int fid, pid;
  fid = getFamilyID(family);
  pid = getPersonID(person);

  if (fid < 0 && pid < 0) {  // both new
    addFamily(family);
    addPerson(person);
    fid = getFamilyID(family);
    pid = getPersonID(person);
    this->family[fid].addPerson(pid);
    this->people[pid].setFamily(fid);
    return 0;
  } else if (fid < 0 && pid >= 0) {  // new fam, old indv,
    fprintf(stderr,
            "Duplicated person [ %s ] in a new family [ %s ], this is not a "
            "supported feature.\n",
            person.c_str(), family.c_str());
    return -1;
  } else if (fid >= 0 && pid < 0) {  // known fam, new indv
    addPerson(person);
    pid = getPersonID(person);
    this->family[fid].addPerson(pid);
    this->people[pid].setFamily(fid);
    return 0;
  } else {  // both known
    bool OK = this->family[fid].containPerson(pid) &&
              this->people[pid].getFamily() == fid;
    if (!OK) {
      // TODO: when different family have the same person id, then this line
      // will have problem
      // see: ~/rvtests.dev/test.meta/in.ped
      fprintf(stderr,
              "Duplicated person [ %s ] in the duplicated family [ %s ], but "
              "not consistent to previous entries\n",
              person.c_str(), family.c_str());
      return -1;
    }
    return 0;
  }
  return 0;
};
Exemplo n.º 3
0
Vertex* Mesh::getOrMakeVertex(Face* f, FaceVertex* from, FaceVertex* to){
	
	if(to->hasNext() && to->getNext()->isDivided()){
		Face* n = to->getNext();
		int shared = n->getVertexOnEdgeId(from->id, to->id);
		return vList[shared];
	}else{
		
		ofVec3f mid = (vList[(from->id)]->getPoint() + vList[(to->id)]->getPoint()) / 2.;
		Vertex* v = new Vertex(vList.size(), mid.x, mid.y, mid.z );
		//v->setIncidentEdge(6); //any subdivided edge will have 6 incident edges :: not the case with open meshes
		vList.push_back(v);
		twin_vertices.insert(pair<int, int> (v->getId(), v->getId())); //assume that its a base 

		addFamily(v->getId(), from->id, to->id);

		if(to->hasNext() && !to->getNext()->isDivided()) to_check.push(to->getNext());
		return v;
	}
	
}