//----------------------------------------------------------------------- /// <summary> /// 查找交集 /// </summary> public void _calcIntersections() { mIntersectionsMap.Clear(); mIntersections.Clear(); //std::map<Ogre::Vector3, PathIntersection, Vector3Comparator> pointSet; std_map <Vector3, std_vector <PathCoordinate> > pointSet = new std_map <Vector3, std_vector <PathCoordinate> >(new Vector3Comparator()); // for (std::vector<Path>::iterator it = mPaths.begin(); it!= mPaths.end(); ++it) uint it_index = 0; foreach (var it in mPaths) { uint it_point_index = 0; //for (std::vector<Ogre::Vector3>::const_iterator it2 = it->getPoints().begin(); it2 != it->getPoints().end(); ++it2) foreach (var it2 in it._getPoints()) { //PathCoordinate pc(it-mPaths.begin(), it2-it->getPoints().begin()); PathCoordinate pc = new PathCoordinate(it_index, it_point_index); //if (pointSet.find(*it2)==pointSet.end()) if (!pointSet.ContainsKey(it2)) { std_vector <PathCoordinate> pi = new std_vector <PathCoordinate>(); pi.Add(pc); //pointSet[it2] = pi; pointSet.Add(it2, pi); } else { pointSet[it2].push_back(pc); } it_point_index++; } it_index++; } //for (std::map<Ogre::Vector3, PathIntersection, Vector3Comparator>::iterator it = pointSet.begin(); it != pointSet.end(); ++it) foreach (var it_ps in pointSet) { if (it_ps.Value.size() > 1) { foreach (var it2 in it_ps.Value) { //mIntersectionsMap[*it2] = it->second; if (mIntersectionsMap.ContainsKey(it2)) { mIntersectionsMap[it2] = it_ps.Value; } else { mIntersectionsMap.Add(it2, it_ps.Value); } } mIntersections.push_back(it_ps.Value); } } // }
/// Inserts a new Key/Value couple anywhere on the track (it is auto-sorted anyway) public Track addKeyFrame(float pos, float @value) { if (mKeyFrames.ContainsKey(pos)) { mKeyFrames[pos] = @value; } else { mKeyFrames.Add(pos, value); } return(this); }
//----------------------------------------------------------------------- /// <summary> /// 查找交集 /// </summary> public void _calcIntersections() { mIntersectionsMap.Clear(); mIntersections.Clear(); //std::map<Ogre::Vector3, PathIntersection, Vector3Comparator> pointSet; std_map<Vector3, std_vector<PathCoordinate>> pointSet = new std_map<Vector3, std_vector<PathCoordinate>>(new Vector3Comparator()); // for (std::vector<Path>::iterator it = mPaths.begin(); it!= mPaths.end(); ++it) uint it_index = 0; foreach (var it in mPaths) { uint it_point_index = 0; //for (std::vector<Ogre::Vector3>::const_iterator it2 = it->getPoints().begin(); it2 != it->getPoints().end(); ++it2) foreach (var it2 in it._getPoints()) { //PathCoordinate pc(it-mPaths.begin(), it2-it->getPoints().begin()); PathCoordinate pc = new PathCoordinate(it_index, it_point_index); //if (pointSet.find(*it2)==pointSet.end()) if (!pointSet.ContainsKey(it2)) { std_vector<PathCoordinate> pi = new std_vector<PathCoordinate>(); pi.Add(pc); //pointSet[it2] = pi; pointSet.Add(it2, pi); } else { pointSet[it2].push_back(pc); } it_point_index++; } it_index++; } //for (std::map<Ogre::Vector3, PathIntersection, Vector3Comparator>::iterator it = pointSet.begin(); it != pointSet.end(); ++it) foreach (var it_ps in pointSet) { if (it_ps.Value.size() > 1) { foreach (var it2 in it_ps.Value) { //mIntersectionsMap[*it2] = it->second; if (mIntersectionsMap.ContainsKey(it2)) { mIntersectionsMap[it2] = it_ps.Value; } else { mIntersectionsMap.Add(it2, it_ps.Value); } } mIntersections.push_back(it_ps.Value); } } // }