예제 #1
0
        /**
         * Multiplies limbs if they are mirrored.
         */
        private void doubleMirroredParts(Dictionary <string, RawBodyPart> map)
        {
            // double mirrored parts
            Dictionary <string, RawBodyPart> newMap = new Dictionary <string, RawBodyPart>();

            foreach (RawBodyPart part in map.Values)
            {
                if (part.mirrored)
                {
                    RawBodyPart leftPart  = part.clone();             // copy parts
                    RawBodyPart rightPart = part.clone();
                    leftPart.name  = LEFT_PREFIX + leftPart.name;     // update name
                    rightPart.name = RIGHT_PREFIX + rightPart.name;
                    if (map[part.root].mirrored)                      // root is mirrored
                    {
                        leftPart.root  = LEFT_PREFIX + leftPart.root; // update root links
                        rightPart.root = RIGHT_PREFIX + rightPart.root;
                    }
                    newMap.Add(leftPart.name, leftPart);
                    newMap.Add(rightPart.name, rightPart);
                }
                else
                {
                    newMap.Add(part.name, part);
                }
            }
            map.Clear();
            foreach (var entry in newMap)
            {
                map.Add(entry.Key, entry.Value);
            }
        }
예제 #2
0
        public RawBodyPart clone()
        {
            RawBodyPart clone = new RawBodyPart();

            clone.name     = name;
            clone.root     = root;
            clone.mirrored = mirrored;
            clone.layers.AddRange(layers);
            clone.tags.AddRange(tags);
            clone.internalOrgans.AddRange(internalOrgans);
            clone.externalOrgans.AddRange(externalOrgans);
            return(clone);
        }
예제 #3
0
 /**
  * Observes limbs tree and copies mirroring flags from limbs to their children.
  * There should be only one flag on the path from root to leaf limb.
  */
 private void updateLimbsMirroringFlags(Dictionary <string, RawBodyPart> map)
 {
     map.Values
     .Where(rawBodyPart => !rawBodyPart.mirrored)
     .Where(rawBodyPart => {               // check if some of parent limbs is mirrored
         RawBodyPart limb = rawBodyPart;
         while (!limb.root.Equals("body")) // cycle to the root limb
         {
             if (map[limb.root].mirrored)
             {
                 return(true);
             }
             limb = map[limb.root];     // go to next limb
         }
         return(false);
     }).ToList().ForEach(rawBodyPart => rawBodyPart.mirrored = true);
 }