//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D
//
//  This library is free software; you can redistribute it and/or
//  modify it under the terms of the GNU Lesser General Public
//  License as published by the Free Software Foundation; either
//  version 2.1 of the License.
//
//  This library is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//  Lesser General Public License for more details.
//
//  You should have received a copy of the GNU Lesser General Public
//  License along with this library; if not, write to the Free Software
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
//
//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//

// Partitioning/decimation module for the SALOME v3.2 platform
// MULTIPR.idl
// Interface CORBA for the MULTIPR module
// Author: Olivier LE ROUX - CS, Virtual Reality Dpt
// Date: 01/2007
//
#ifndef __MULTIPR_INTERFACE_CORBA__
#define __MULTIPR_INTERFACE_CORBA__

#include "SALOME_Exception.idl"
#include "SALOME_Component.idl"
#include "SALOME_GenericObj.idl"
#include "SALOMEDS.idl" // to access study


/*!  \ingroup MULTIPR
 *
 * This package contains the interface MULTIPR_ORB used for %MULTIPR component.
 */
module MULTIPR_ORB
{


typedef sequence<string> string_array;


//*************************************************************************
// Interface of the %MULTIPR component used to manage partition/decimation
//*************************************************************************

interface MULTIPR_Obj : SALOME::GenericObj
{

	//---------------------------------------------------------------------
	// Basic accessors/mutators
	//--------------------------------------------------------------------
	
    /*!
     * Reset the object.
     */
    void    reset();
    
	/*!
	 * Return true iff this obj represents a valid sequential MED file.
	 */
	boolean isValidSequentialMEDFile();
	
	/*!
	 * Return true iff this obj represents a valid distributed MED file.
	 */
	boolean isValidDistributedMEDFile();
	
	/*!
	 * Return the name of the associated MED file.
	 */
	string getFilename()
		raises (SALOME::SALOME_Exception);
	
    /*!
     * Return the name of the associated sequential MED file (for a distributed MED file).
     */
    string getSeqFilename()
        raises (SALOME::SALOME_Exception);
        
	/*!
	 * Set the mesh to be partitionned/decimated. 
	 * Assume sequential MED file.
	 */
	void setMesh(in string meshName)
		raises (SALOME::SALOME_Exception);

	/*!
	 * Set the boxing parameter used for decimation (100 by default).
	 */
	void setBoxing(in long boxing)
		raises (SALOME::SALOME_Exception);
	
	/*!
	 * Return the list of meshes contained in the associated MED file.
	 */
	string_array getMeshes()
		raises (SALOME::SALOME_Exception);
		
	/*!
	 * Return the list of fields contained in the current mesh of the associated MED file.
	 */
	string_array getFields(in string pPartList)
		raises (SALOME::SALOME_Exception);
	
	/*!
	 * Return the number of iterations for a given field.
	 */
	long getTimeStamps(in string pPartList, in string fieldName)
		raises (SALOME::SALOME_Exception);

    /*!
     * Get the minimum and maximum value of a part's field.
     */
    void getFieldMinMax(in string pPartName, in string pFieldName, inout float pMin, inout float pMax)
        raises (SALOME::SALOME_Exception);
        
	/*!
	 * Return the name of all partitions.
	 * Assume this object encapsulates a distributed MED file.
	 */
	string_array getParts()
		raises (SALOME::SALOME_Exception);

	/*!
	 * Return all information about a part.
	 * Assume this object encapsulates a distributed MED file.
	 */
	string getPartInfo(in string partName)
		raises (SALOME::SALOME_Exception);
	 
	//---------------------------------------------------------------------
	// Algorithms
	//--------------------------------------------------------------------
	
	/*!
	 * Create a distributed MED file (v2.3) by extracting all the groups from the 
     * current mesh of the current MED sequential MED file.
	 * Assume:
	 * - the file is in MED format and can be read using MED file v2.3.
	 * - the file is sequential (not a distributed MED).
	 * - the file only contains TETRA10 elements (dimension of space and mesh is 3).
	 * - the file have no profil.
	 * \return the name of each part.
	 */
	string_array partitionneDomaine()
		raises (SALOME::SALOME_Exception);
	
	/*! 
	 * Create a distributed MED file (V2.3) by splitting a group of a MED file 
     * previously created by partitionneDomaine.
	 * Assume:
	 * - the file is a distributed MED file, previously created by partitionneDomaine()
	 *   (=> each part only contain 1 mesh, TETRA10 elements only)
	 * - nbPart > 1
	 * - partitionner METIS=0 or SCOTCH=1
	 * \return the name of each part.
	 */
	string_array partitionneGroupe(
		in string partName, 
		in long   nbParts, 
		in long   partitionner)
		raises (SALOME::SALOME_Exception);
	
	/*!
	 * Create 3 resolutions of the given part of a distributed MED file (V2.3).
	 * Assume:
	 * - the file is a distributed MED file, previously created by 
     *   partitionneDomaine() or partitionneGrain()
	 *   (=> each part only contain 1 mesh, TETRA10 elements only)
	 */
	string_array decimePartition(
		in string partName,
		in string fieldName,
		in long   fieldIt,
		in string filterName,
		in string filterParams)
		raises (SALOME::SALOME_Exception);

	/*!
	 * Return useful information to configure decimation parameters.
	 * Depends on part, field and filter: generic operation.
	 */
	string evalDecimationParams(
		in string partName, 
		in string fieldName, 
		in long   fieldIt, 
		in string filterName,
		in string filterParams)
		raises (SALOME::SALOME_Exception);
	
	/*!
	 * Remove all the parts starting with the given prefix from the distributed MED file.
	 * Example: if prefixPartName="PART_4" => remove "PART_4" and all sub-parts "PART_4_*", 
     * but not "PART41".
	 * Assume this object encapsulates a distributed MED file.
	 */
	void removeParts(in string prefixPartName)
		raises (SALOME::SALOME_Exception);
	
	/*!
	 * Get mesh statistics.
	 */
	string getMEDInfo(
		in string partName)
		raises (SALOME::SALOME_Exception);
		
	//---------------------------------------------------------------------
	// i/o
	//--------------------------------------------------------------------
	
	/*!
	 * Save the current distributed MED file to disk.
	 */
	void save(in string path)
		raises (SALOME::SALOME_Exception);

    /*!
    * Check save progress.
    * \return current save progress in percents.
    */
    long getSaveProgress();

    /*!
    * Reset save progress to zero.
    */
    void resetSaveProgress();

}; // interface MULTIPR_Obj


//*************************************************************************
// Interface of the %MULTIPR component; used to create MULTIPR_Obj object 
// and to define high level API.
//*************************************************************************
interface MULTIPR_Gen : Engines::Component, SALOMEDS::Driver
{
	/*!
	 * Return the version of the MULTIPR library.
	 */
	string getVersion()
		raises (SALOME::SALOME_Exception);
	
	//------------------------------------------------------------------------
	// High level API
	// Directly apply one of the 3 main operations of the MULTIPR module on a MED file
	//------------------------------------------------------------------------	

	/*!         
	 * Create a distributed MED file (v2.3) by extracting all the groups from the 
     * mesh of a sequential MED file.
	 * High level function.
	 */
	void partitionneDomaine(
		in string medFilename, 
		in string meshName)
		raises (SALOME::SALOME_Exception);

	/*!         
	 * Create a distributed MED file (V2.3) by splitting a group of a MED file 
     * previously created by partitionneDomaine().
	 * High level function.
	 */
	void partitionneGroupe(
		in string medFilename, 
		in string partName, 
		in long   nbParts, 
		in long   partitionner) // 0=METIS 1=SCOTCH
		raises (SALOME::SALOME_Exception);

	/*!         
	 * Creates 3 resolutions of the given part of a distributed MED file (V2.3).
	 * High level function.
	 */
	void decimePartition(
		in string medFilename, 
		in string partName, 
		in string fieldName,
		in long   fieldIt,
		in string filterName,
		in string filterParams)
		raises (SALOME::SALOME_Exception);

	//------------------------------------------------------------------------
	// Low level API
	// Create an object to encapsulate a MED file.
	//------------------------------------------------------------------------
	
	/*!
	 * Create a MULTIPR_Obj object which encapsulate a MED file.
	 */
	MULTIPR_Obj getObject(in string medFilename)
		raises (SALOME::SALOME_Exception);

    //------------------------------------------------------------------------
    // Engine API
    // Methods to correctly serve Persistence and Dump Python.
    //------------------------------------------------------------------------

    /*!
     * Set the current study
     */
    void SetCurrentStudy (in SALOMEDS::Study theStudy);

    /*!
     * Get the current study
     */
    SALOMEDS::Study GetCurrentStudy();

        
}; // interface MULTIPR_Gen
 
  
}; // module MULTIPR_ORB

#endif // __MULTIPR_INTERFACE_CORBA__

