//    *
        //	 * Builds the mesh into the given TriangleBuffer
        //	 * @param buffer The TriangleBuffer on where to append the mesh.
        //	 * @exception Ogre::InvalidStateException Either shape or multishape must be defined!
        //	 * @exception Ogre::InvalidStateException Required parameter is zero!
        //
        //-----------------------------------------------------------------------
        //
        //ORIGINAL LINE: void addToTriangleBuffer(TriangleBuffer& buffer) const
        public override void addToTriangleBuffer(ref TriangleBuffer buffer)
        {
            if (mMultiShapeToExtrude.getShapeCount() == 0)
            {
                OGRE_EXCEPT("Ogre::Exception::ERR_INVALID_STATE", "At least one shape must be defined!", "Procedural::Extruder::addToTriangleBuffer(Procedural::TriangleBuffer)");
            }
            ;

            // Triangulate the begin and end caps
            if (mCapped && mMultiShapeToExtrude.isClosed())
            {
                GlobalMembers._extrudeCapImpl(ref buffer, mMultiShapeToExtrude, mMultiExtrusionPath, mScaleTracks, mRotationTracks);
            }

            // Extrude the paths contained in multiExtrusionPath
            for (uint j = 0; j < mMultiExtrusionPath.getPathCount(); ++j)
            {
                Path  extrusionPath = mMultiExtrusionPath.getPath((int)j);
                Track rotationTrack = null;
                if (mRotationTracks.find(j) != -1)                                        // mRotationTracks.end()) {
                {
                    rotationTrack = mRotationTracks[j];                                   //mRotationTracks.find(j).second;
                    extrusionPath = extrusionPath.mergeKeysWithTrack(mRotationTracks[j]); // (*mRotationTracks.find(j).second);
                }
                Track scaleTrack = null;
                if (mScaleTracks.find(j) != -1)                                        // mScaleTracks.end()) {
                {
                    rotationTrack = mScaleTracks[j];                                   //mScaleTracks.find(j).second;
                    extrusionPath = extrusionPath.mergeKeysWithTrack(mScaleTracks[j]); // (*mScaleTracks.find(j).second);
                }
                Track pathTextureTrack = null;
                if (mPathTextureTracks.find(j) != -1)                                           // mPathTextureTracks.end()) {
                {
                    pathTextureTrack = mPathTextureTracks[j];                                   //mPathTextureTracks.find(j).second;
                    extrusionPath    = extrusionPath.mergeKeysWithTrack(mPathTextureTracks[j]); //(*mPathTextureTracks.find(j).second);
                }

                std_vector <std_pair <uint, uint> > segs = mMultiExtrusionPath.getNoIntersectionParts(j);

                //for (List<std.pair<uint, uint>>.Enumerator it = segs.GetEnumerator(); it.MoveNext(); ++it) {
                foreach (var it in segs)
                {
                    for (uint i = 0; i < mMultiShapeToExtrude.getShapeCount(); i++)
                    {
                        Shape shapeToExtrude    = mMultiShapeToExtrude.getShape(i);
                        Track shapeTextureTrack = null;
                        if (mShapeTextureTracks.find(i) != -1)          // mShapeTextureTracks.end()) {
                        {
                            shapeTextureTrack = mShapeTextureTracks[i]; //mShapeTextureTracks.find(i).second;
                            shapeToExtrude.mergeKeysWithTrack(shapeTextureTrack);
                        }
                        GlobalMembers._extrudeBodyImpl(ref buffer, shapeToExtrude, extrusionPath, (int)it.first, (int)it.second, shapeTextureTrack, rotationTrack, scaleTrack, pathTextureTrack);
                    }
                }

                // Make the intersections
                //typedef std::vector<PathCoordinate> PathIntersection;
                std_vector <std_vector <MultiPath.PathCoordinate> > intersections = mMultiExtrusionPath.getIntersections();
                //for (List<MultiPath.PathIntersection>.Enumerator it = intersections.GetEnumerator(); it.MoveNext(); ++it) {
                foreach (var it in intersections)
                {
                    for (uint i = 0; i < mMultiShapeToExtrude.getShapeCount(); i++)
                    {
                        Track shapeTextureTrack = null;
                        if (mShapeTextureTracks.find(i) != -1)          // mShapeTextureTracks.end())
                        {
                            shapeTextureTrack = mShapeTextureTracks[i]; //mShapeTextureTracks.find(i).second;
                        }
                        GlobalMembers._extrudeIntersectionImpl(ref buffer, it, mMultiExtrusionPath, mMultiShapeToExtrude.getShape(i), shapeTextureTrack);
                    }
                }
            }
        }