public Segment startNewPart( @NotNull final PERPENDICULAR_DIRECTION direction ) throws IllegalStateException {
this.checkNotStarted();
if ( currentSegment != null ) {
segmentsList.put( new ImmutableSegment2D( (Segment) currentSegment ), currentDirection );
currentSegment = new MutableSegment2D( currentSegment.getXB(), currentSegment.getYB(), currentSegment.getXB(), currentSegment.getYB() );
totalLength += currentLength;
} else {
currentSegment = new MutableSegment2D( 0, 0, 0, 0 );
}
currentLength = 0;
currentDirection = direction;
return currentSegment;