public void openAllPathsAndDuplicateStartVertex ( ) { _touch ( ) ; if ( m_bPolygon ) throw GeometryException . GeometryInternalError ( ) ; // do not call this // method on a // polygon if ( m_pathFlags == null ) // if (!m_pathFlags) throw GeometryException . GeometryInternalError ( ) ; _verifyAllStreams ( ) ; int closedPathCount = 0 ; int pathCount = getPathCount ( ) ; for ( int i = 0 ; i < pathCount ; i ++ ) { if ( m_pathFlags . read ( i ) == ( byte ) PathFlags . enumClosed ) { closedPathCount ++ ; } } for ( int iattr = 0 , nattr = m_description . getAttributeCount ( ) ; iattr < nattr ; iattr ++ ) { if ( m_vertexAttributes [ iattr ] != null ) { int semantics = m_description . _getSemanticsImpl ( iattr ) ; // int // semantics // = // m_description._getSemanticsImpl(iattr); int comp = VertexDescription . getComponentCount ( semantics ) ; int newSize = comp * ( m_pointCount + closedPathCount ) ; m_vertexAttributes [ iattr ] . resize ( newSize ) ; int offset = closedPathCount ; int ipath = pathCount ; for ( int i = m_pointCount - 1 ; i >= 0 ; i -- ) { if ( i + 1 == m_paths . read ( ipath ) ) { ipath -- ; if ( m_pathFlags . read ( ipath ) == ( byte ) PathFlags . enumClosed ) { int istart = m_paths . read ( ipath ) ; for ( int c = 0 ; c < comp ; c ++ ) { double v = m_vertexAttributes [ iattr ] . readAsDbl ( comp * istart + c ) ; m_vertexAttributes [ iattr ] . writeAsDbl ( comp * ( offset + i ) + c , v ) ; } if ( -- offset == 0 ) break ; } } for ( int c = 0 ; c < comp ; c ++ ) { double v = m_vertexAttributes [ iattr ] . readAsDbl ( comp * i + c ) ; m_vertexAttributes [ iattr ] . writeAsDbl ( comp * ( offset + i ) + c , v ) ; } } } } int offset = closedPathCount ; for ( int ipath = pathCount ; ipath > 0 ; ipath -- ) { int iend = m_paths . read ( ipath ) ; m_paths . write ( ipath , iend + offset ) ; if ( m_pathFlags . read ( ipath - 1 ) == ( byte ) PathFlags . enumClosed ) { m_pathFlags . clearBits ( ipath - 1 , ( byte ) PathFlags . enumClosed ) ; if ( -- offset == 0 ) { break ; } } } m_pointCount += closedPathCount ; }
Major Changes on 16th of January