/*******************************************************************************
 *  Copyright 2017-2018 Centre for Development of Advanced Computing(C-DAC), Pune
 *  
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *  
 *   http://www.apache.org/licenses/LICENSE-2.0
 *  
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *******************************************************************************/
package cdac.medinfo.sdk.dcm30_04.baselibs;

import cdac.medinfo.sdk.dcm30_04.commoninterface.IDataElement;
import cdac.medinfo.sdk.dcm30_04.commoninterface.IDicomValue;
import cdac.medinfo.sdk.dcm30_04.commoninterface.IDictionaryReader;
import cdac.medinfo.sdk.dcm30_04.commoninterface.ITransferSyntax;
import cdac.medinfo.sdk.dcm30_04.enums.EnumFiniteVolume;
import cdac.medinfo.sdk.dcm30_04.enums.EnumManifold;
import cdac.medinfo.sdk.dcm30_04.enums.EnumRecommendedPresentationType;
import cdac.medinfo.sdk.dcm30_04.enums.EnumSurfaceProcessing;
import cdac.medinfo.sdk.dcm30_04.exceptions.InvalidItemException;
import cdac.medinfo.sdk.dcm30_04.exceptions.MandatoryMissingException;
import cdac.medinfo.sdk.dcm30_04.utils.DicomConfig;
import cdac.medinfo.sdk.dcm30_04.utils.DicomConstants;
import cdac.medinfo.sdk.dcm30_04.utils.DicomLogger;
/**
* This item class contains methods to validate, set and get the attributes of Surface Sequence .
 */

public class SurfaceSequenceItem extends Item   
{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	/**
	 * This constructor creates the item and internal code sequence macro with default TransferSyntax 
	 */
	SurfaceSequenceItem()
	{
		super();
	}


	/**
	 * This constructor creates the item and internal code sequence macro with specified TransferSyntax 
	 * and default DictionaryReader
	 * @param objITransferSyntax specifies the DICOM Standard defined TransfeSyntax
	 */
	SurfaceSequenceItem(ITransferSyntax objITransferSyntax)
	{
		super(objITransferSyntax);
	}

	/**
	 * This constructor creates SurfaceSequenceItem with specified TransferSyntax and
	 * specified DictionaryReader
	 * @param objTransferSyntax specifies the DICOM Standard defined TransfeSyntax
	 * @param objDictionaryReader specifies the DICOM Dictionary reader to be used 
	 */
	SurfaceSequenceItem(ITransferSyntax objTransferSyntax, IDictionaryReader objDictionaryReader)
	{
		super(objTransferSyntax,objDictionaryReader);
	}



	/**
	 * Validates all the attributes in SurfaceSequenceItem that are present in the DataSet
	 * @return boolean - Success -true, Failure - false
	 * @throws InvalidItemException throws InvalidItemException If Conditional element fails.
	 */
	public boolean validateForModule()  throws InvalidItemException
	{
		try
		{
			if(!contains(0x0066,0x0003))
				throw new MandatoryMissingException("0066,0003") ;
		}
		catch( MandatoryMissingException ce)
		{
			if(DicomConfig.createInstance().isLoggingOn())
			{
				DicomLogger.getLogger().log(ce.getMessage());
			}
			throw new InvalidItemException(this.getClass().getSimpleName(),ce); 
		}
		return true;
	}
	
	/**
	 * Sets Surface Number. 
	 * Identification number of the surface. 
	 * Uniquely identifies a surface within this SOP instance. 
	 * Shall start at a value of 1, and increase monotonically by 1.
	 * @param iSurfaceNumber long value of Surface Number.
	 */
	public void setSurfaceNumber(int iSurfaceNumber)
	{
		/* Accept the Surface Number of type UL.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)	
			objIDataElement = new ImplicitDE(0x0066,0x0003, iSurfaceNumber,objIDictionaryReader);
		else
			objIDataElement = new ExplicitDE(0x0066,0x0003,DicomConstants.DCM_DT_UL, iSurfaceNumber);
		//Add the DataElement to the Item
		addDataElement(objIDataElement);
	}

	/**
	 * Retrieves Surface Number.
	 * @return long - value of Surface Number.
	 */
	public int getSurfaceNumber()
	{
		Object objValue = getValue(0x0066,0x0003);
		if(objValue != null)
			return Integer.parseInt(objValue.toString());
		return DicomConstants.DCM_NO_VALUE;
	}
	
	/**
	 * Sets Surface Comments.
	 * @param strSurfaceComments String value of Surface Comments.
	 */
	public void setSurfaceComments(String strSurfaceComments)
	{
		/* Accept Surface Comments of type LT.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)
			objIDataElement = new ImplicitDE(0x0066,0x0004, strSurfaceComments,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0066,0x0004,DicomConstants.DCM_DT_LT, strSurfaceComments);

		addDataElement(objIDataElement);
	}

	/**
	 * Retrieves Surface Comments.
	 * @return String - value of Surface Comments.
	 */
	public String getSurfaceComments()
	{
		Object objValue = getValue(0x0066,0x0004);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	
	/**
	 * Sets Surface Processing.
	 * Defined Terms:
	 * 1) YES.
	 * 2) NO.
	 * @param enumSurfaceProcessing enum value of Surface Processing.
	 */
	public void setSurfaceProcessing(EnumSurfaceProcessing enumSurfaceProcessing)
	{
		/* Accept the Surface Processing in String format of type CS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)
			objIDataElement = new ImplicitDE(0x0066,0x0009, enumSurfaceProcessing.getValue(),getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0066,0x0009,DicomConstants.DCM_DT_CS, enumSurfaceProcessing.getValue());

		addDataElement(objIDataElement);


	}

	/**
	 * Return Surface Processing. 
	 * @return String - value of Surface Processing.
	 */
	public String getSurfaceProcessing()
	{
		Object objValue = getValue(0x0066,0x0009);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Sets the Surface Processing Ratio.
	 * @param fSurfaceProcessingRatio Float value of the Surface Processing Ratio.
	 */
	public void setSurfaceProcessingRatio( float fSurfaceProcessingRatio)
	{
		/*
		 * Accept the Surface Processing Ratio in String format of type FL.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)	
			objIDataElement = new ImplicitDE(0x0066,0x000A, fSurfaceProcessingRatio,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0066,0x000A,DicomConstants.DCM_DT_FL, fSurfaceProcessingRatio);

		addDataElement(objIDataElement);
	}
	/**
	 * Retrieves the Surface Processing Ratio.
	 * @return float - Float value of the Surface Processing Ratio.
	 */
	public float getSurfaceProcessingRatio()
	{
		Object objValue = getValue(0x0066,0x000A);
		if(objValue != null)
			return Float.parseFloat(objValue.toString());
		return DicomConstants.DCM_NO_VALUE;
	}
	
	/**
	 * Sets Surface Processing Description.
	 * @param strSurfaceProcessingDescription String value of Surface Processing Description.
	 */
	public void setSurfaceProcessingDescription(String strSurfaceProcessingDescription)
	{
		/* Accept the Surface Processing Description in String format of type LO.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)
			objIDataElement = new ImplicitDE(0x0066,0x000B, strSurfaceProcessingDescription,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0066,0x000B,DicomConstants.DCM_DT_LO, strSurfaceProcessingDescription);

		addDataElement(objIDataElement);
	}

	/**
	 * Return Surface Processing Description.
	 * @return String - value of Surface Processing Description.
	 */
	public String getSurfaceProcessingDescription()
	{
		Object objValue = getValue(0x0066,0x000B);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	
	/**
	 * Retrieves pre-initialized object of Surface Processing Algorithm Identification Sequence.If the module contains the sequence object
	 * it returns the same otherwise it creates the sequence adds to the module with proper initialization
	 * and then returns the object of sequence.
	 * @return SurfaceProcessingAlgorithmIdentificationSequence - instance of SurfaceProcessingAlgorithmIdentificationSequence. 
	 */
	public SurfaceProcessingAlgorithmIdentificationSequence getSurfaceProcessingAlgorithmIdentificationSequence()
	{
		SurfaceProcessingAlgorithmIdentificationSequence objSurfaceProcessingAlgorithmIdentificationSequence = null;
		IDataElement objIDataElement =  getDataForTag(0x0066, 0x0035);
		if(objIDataElement != null)
		{
			IDicomValue objIDicomValue = objIDataElement.getDicomValue();
			if(objIDicomValue != null)
				objSurfaceProcessingAlgorithmIdentificationSequence = (SurfaceProcessingAlgorithmIdentificationSequence)objIDicomValue;
		}
		else
		{
			DicomV3Factory objDicomV3Factory = DicomV3Factory.createInstance();
			int iVRTransferSyntax = objITransferSyntax.getVRTransferSyntax();
			objIDataElement = null;
			objSurfaceProcessingAlgorithmIdentificationSequence = (SurfaceProcessingAlgorithmIdentificationSequence)objDicomV3Factory.createSequence(0x0066, 0x0035, objITransferSyntax, objIDictionaryReader);

			if(iVRTransferSyntax == DicomConstants.DCM_VR_IMPLICIT)
				objIDataElement = new ImplicitDE(0x0066, 0x0035, objSurfaceProcessingAlgorithmIdentificationSequence.getValue(),objIDictionaryReader);
			else
				objIDataElement = new ExplicitDE(0x0066, 0x0035, DicomConstants.DCM_DT_SQ, objSurfaceProcessingAlgorithmIdentificationSequence.getValue());
			objIDataElement.setTransferSyntax(objITransferSyntax);
			if(objIDataElement != null)
				addDataElement(objIDataElement);
		}
		return objSurfaceProcessingAlgorithmIdentificationSequence;
	}
	
	/**
	 * Sets Recommended Display Grayscale Value
	 * @param shRecommendedDisplayGrayscaleValue short value of Recommended Display Grayscale Value
	 */
	public void setRecommendedDisplayGrayscaleValue(short shRecommendedDisplayGrayscaleValue)
	{
		/* Accept the Recommended Display Grayscale Value of type US.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)	
			objIDataElement = new ImplicitDE(0x0062,0x000C,shRecommendedDisplayGrayscaleValue,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0062,0x000C,DicomConstants.DCM_DT_US, shRecommendedDisplayGrayscaleValue);

		addDataElement(objIDataElement);
	}

	/**
	 * Retrieves Recommended Display Grayscale Value.
	 * @return short - short value of Recommended Display Grayscale Value.
	 */
	public short getRecommendedDisplayGrayscaleValue()
	{
		Object objValue = getValue(0x0062,0x000C);
		if(objValue != null)
			return Short.parseShort(objValue.toString());
		return DicomConstants.DCM_NO_VALUE;
	}
	
	/**
	 * Sets Recommended Display CIELab Value
	 * @param shRecommendedDisplayCIELabValue short value of Recommended Display CIELab Value
	 */
	public void setRecommendedDisplayCIELabValue(short shRecommendedDisplayCIELabValue)
	{
		/* Accept the Recommended Display CIELab Value of type US.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)	
			objIDataElement = new ImplicitDE(0x0062,0x000D,shRecommendedDisplayCIELabValue,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0062,0x000D,DicomConstants.DCM_DT_US, shRecommendedDisplayCIELabValue);

		addDataElement(objIDataElement);
	}

	/**
	 * Retrieves Recommended Display CIELab Value.
	 * @return short - short value of Recommended Display CIELab Value.
	 */
	public short getRecommendedDisplayCIELabValue()
	{
		Object objValue = getValue(0x0062,0x000D);
		if(objValue != null)
			return Short.parseShort(objValue.toString());
		return DicomConstants.DCM_NO_VALUE;
	}

	/**
	 * Sets the Recommended Presentation Opacity.
	 * @param fRecommendedPresentationOpacity Float value of the Recommended Presentation Opacity.
	 */
	public void setRecommendedPresentationOpacity( float fRecommendedPresentationOpacity)
	{
		/*
		 * Accept the Recommended Presentation Opacity in String format of type FL.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)	
			objIDataElement = new ImplicitDE(0x0066,0x000C, fRecommendedPresentationOpacity,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0066,0x000C,DicomConstants.DCM_DT_FL, fRecommendedPresentationOpacity);

		addDataElement(objIDataElement);
	}
	/**
	 * Retrieves the Recommended Presentation Opacity.
	 * @return float - Float value of the Recommended Presentation Opacity.
	 */
	public float getRecommendedPresentationOpacity()
	{
		Object objValue = getValue(0x0066,0x000C);
		if(objValue != null)
			return Float.parseFloat(objValue.toString());
		return DicomConstants.DCM_NO_VALUE;
	}
	
	/**
	 * Sets type of Recommended Presentation.
	 * Defined Terms:
	 * 1) SURFACE.
	 * 2) WIREFRAME.
	 * 3) POINTS
	 * @param enumRecommendedPresentationType enum value of Recommended Presentation Type.
	 */
	public void setRecommendedPresentationType(EnumRecommendedPresentationType enumRecommendedPresentationType)
	{
		/* Accept the Recommended Presentation Type in String format of type CS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)
			objIDataElement = new ImplicitDE(0x0066,0x000D, enumRecommendedPresentationType.getValue(),getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0066,0x000D,DicomConstants.DCM_DT_CS, enumRecommendedPresentationType.getValue());

		addDataElement(objIDataElement);

	}

	/**
	 * Return type of Recommended Presentation. 
	 * @return String - value of Recommended Presentation Type.
	 */
	public String getRecommendedPresentationType()
	{
		Object objValue = getValue(0x0066,0x000D);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	
	/**
	 * Sets the Recommended Point Radius.
	 * @param fRecommendedPointRadius Float value of the Recommended Point Radius
	 */
	public void setRecommendedPointRadius( float fRecommendedPointRadius)
	{
		/*
		 * Accept the Recommended Point Radius in String format of type FL.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)	
			objIDataElement = new ImplicitDE(0x0066,0x0037, fRecommendedPointRadius,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0066,0x0037,DicomConstants.DCM_DT_FL, fRecommendedPointRadius);

		addDataElement(objIDataElement);
	}
	/**
	 * Retrieves the Recommended Point Radius.
	 * @return float - Float value of the Recommended Point Radius
	 */
	public float getRecommendedPointRadius()
	{
		Object objValue = getValue(0x0066,0x0037);
		if(objValue != null)
			return Float.parseFloat(objValue.toString());
		return DicomConstants.DCM_NO_VALUE;
	}
	
	/**
	 * Sets the Recommended Line Thickness.
	 * @param fRecommendedLineThickness Float value of the Recommended Line Thickness
	 */
	public void setRecommendedLineThickness( float fRecommendedLineThickness)
	{
		/*
		 * Accept the Recommended Line Thickness in String format of type FL.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)	
			objIDataElement = new ImplicitDE(0x0066,0x0038, fRecommendedLineThickness,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0066,0x0038,DicomConstants.DCM_DT_FL, fRecommendedLineThickness);

		addDataElement(objIDataElement);
	}
	/**
	 * Retrieves the Recommended Line Thickness.
	 * @return float - Float value of the Recommended Line Thickness
	 */
	public float getRecommendedLineThickness()
	{
		Object objValue = getValue(0x0066,0x0038);
		if(objValue != null)
			return Float.parseFloat(objValue.toString());
		return DicomConstants.DCM_NO_VALUE;
	}
	
	/**
	 * Sets Finite Volume.
	 * Defined Terms:
	 * 1) YES.
	 * 2) NO.
	 * 3) UNKNOWN.
	 * @param enumFiniteVolume enum value of Finite Volume.
	 */
	public void setFiniteVolume(EnumFiniteVolume enumFiniteVolume)
	{
		/* Accept the Finite Volume in String format of type CS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)
			objIDataElement = new ImplicitDE(0x0066,0x000E, enumFiniteVolume.getValue(),getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0066,0x000E,DicomConstants.DCM_DT_CS, enumFiniteVolume.getValue());

		addDataElement(objIDataElement);


	}

	/**
	 * Return type of Finite Volume. 
	 * @return String - value of Finite Volume.
	 */
	public String getFiniteVolume()
	{
		Object objValue = getValue(0x0066,0x000E);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	
	/**
	 * Sets Manifold.
	 * Defined Terms:
	 * 1) YES.
	 * 2) NO.
	 * 3) UNKNOWN.
	 * @param enumManifold enum value of Manifold.
	 */
	public void setManifold(EnumManifold enumManifold)
	{
		/* Accept the Manifold in String format of type CS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)
			objIDataElement = new ImplicitDE(0x0066,0x0010, enumManifold.getValue(),getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0066,0x0010,DicomConstants.DCM_DT_CS, enumManifold.getValue());

		addDataElement(objIDataElement);


	}

	/**
	 * Return type of Manifold. 
	 * @return String - value of Manifold.
	 */
	public String getManifold()
	{
		Object objValue = getValue(0x0066,0x0010);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	
	/**
	 * Retrieves pre-initialized object of Surface Points Sequence.If the module contains the sequence object
	 * it returns the same otherwise it creates the sequence adds to the module with proper initialization
	 * and then returns the object of sequence.
	 * @return SurfacePointsSequence - instance of Surface Points Sequence. 
	 */
	public SurfacePointsSequence getSurfacePointsSequence()
	{
		SurfacePointsSequence objSurfacePointsSequence = null;
		IDataElement objIDataElement =  getDataForTag(0x0066, 0x0011);
		if(objIDataElement != null)
		{
			IDicomValue objIDicomValue = objIDataElement.getDicomValue();
			if(objIDicomValue != null)
				objSurfacePointsSequence = (SurfacePointsSequence)objIDicomValue;
		}
		else
		{
			DicomV3Factory objDicomV3Factory = DicomV3Factory.createInstance();
			int iVRTransferSyntax = objITransferSyntax.getVRTransferSyntax();
			objIDataElement = null;
			objSurfacePointsSequence = (SurfacePointsSequence)objDicomV3Factory.createSequence(0x0066, 0x0011, objITransferSyntax, objIDictionaryReader);

			if(iVRTransferSyntax == DicomConstants.DCM_VR_IMPLICIT)
				objIDataElement = new ImplicitDE(0x0066, 0x0011, objSurfacePointsSequence.getValue(),objIDictionaryReader);
			else
				objIDataElement = new ExplicitDE(0x0066, 0x0011, DicomConstants.DCM_DT_SQ, objSurfacePointsSequence.getValue());
			objIDataElement.setTransferSyntax(objITransferSyntax);
			if(objIDataElement != null)
				addDataElement(objIDataElement);
		}
		return objSurfacePointsSequence;
	}

	/**
	 * Retrieves pre-initialized object of Surface Points Normals Sequence.If the module contains the sequence object
	 * it returns the same otherwise it creates the sequence adds to the module with proper initialization
	 * and then returns the object of sequence.
	 * @return SurfacePointsNormalsSequence - instance of Surface Points Normals Sequence. 
	 */
	public SurfacePointsNormalsSequence getSurfacePointsNormalsSequence()
	{
		SurfacePointsNormalsSequence objSurfacePointsNormalsSequence = null;
		IDataElement objIDataElement =  getDataForTag(0x0066, 0x0012);
		if(objIDataElement != null)
		{
			IDicomValue objIDicomValue = objIDataElement.getDicomValue();
			if(objIDicomValue != null)
				objSurfacePointsNormalsSequence = (SurfacePointsNormalsSequence)objIDicomValue;
		}
		else
		{
			DicomV3Factory objDicomV3Factory = DicomV3Factory.createInstance();
			int iVRTransferSyntax = objITransferSyntax.getVRTransferSyntax();
			objIDataElement = null;
			objSurfacePointsNormalsSequence = (SurfacePointsNormalsSequence)objDicomV3Factory.createSequence(0x0066, 0x0012, objITransferSyntax, objIDictionaryReader);

			if(iVRTransferSyntax == DicomConstants.DCM_VR_IMPLICIT)
				objIDataElement = new ImplicitDE(0x0066, 0x0012, objSurfacePointsNormalsSequence.getValue(),objIDictionaryReader);
			else
				objIDataElement = new ExplicitDE(0x0066, 0x0012, DicomConstants.DCM_DT_SQ, objSurfacePointsNormalsSequence.getValue());
			objIDataElement.setTransferSyntax(objITransferSyntax);
			if(objIDataElement != null)
				addDataElement(objIDataElement);
		}
		return objSurfacePointsNormalsSequence;
	}
	
	/**
	 * Retrieves pre-initialized object of Surface Mesh Primitives Sequence.If the module contains the sequence object
	 * it returns the same otherwise it creates the sequence adds to the module with proper initialization
	 * and then returns the object of sequence.
	 * @return SurfaceMeshPrimitivesSequence - instance of Surface Mesh Primitives Sequence. 
	 */
	public SurfaceMeshPrimitivesSequence getSurfaceMeshPrimitivesSequence()
	{
		SurfaceMeshPrimitivesSequence objSurfaceMeshPrimitivesSequence = null;
		IDataElement objIDataElement =  getDataForTag(0x0066, 0x0013);
		if(objIDataElement != null)
		{
			IDicomValue objIDicomValue = objIDataElement.getDicomValue();
			if(objIDicomValue != null)
				objSurfaceMeshPrimitivesSequence = (SurfaceMeshPrimitivesSequence)objIDicomValue;
		}
		else
		{
			DicomV3Factory objDicomV3Factory = DicomV3Factory.createInstance();
			int iVRTransferSyntax = objITransferSyntax.getVRTransferSyntax();
			objIDataElement = null;
			objSurfaceMeshPrimitivesSequence = (SurfaceMeshPrimitivesSequence)objDicomV3Factory.createSequence(0x0066, 0x0013, objITransferSyntax, objIDictionaryReader);

			if(iVRTransferSyntax == DicomConstants.DCM_VR_IMPLICIT)
				objIDataElement = new ImplicitDE(0x0066, 0x0013, objSurfaceMeshPrimitivesSequence.getValue(),objIDictionaryReader);
			else
				objIDataElement = new ExplicitDE(0x0066, 0x0013, DicomConstants.DCM_DT_SQ, objSurfaceMeshPrimitivesSequence.getValue());
			objIDataElement.setTransferSyntax(objITransferSyntax);
			if(objIDataElement != null)
				addDataElement(objIDataElement);
		}
		return objSurfaceMeshPrimitivesSequence;
	}

}
