/***************************************************************************
 *                          Zanoza Modeler v2.x                            *
 *      This is unpublished propietary source code of Zanoza Software.     *
 *      The copyright notice does not evidence any actual or intended      *
 *                    publication of such source code.                     *
 *                                                                         *
 *                   Copyright (c) 2002 Zanoza Software.                   *
 *                                                                         *
 *                        All rights reserved.                             *
 ***************************************************************************
 *--------------------------------------------------------------------------
 * @author:   Oleg M.
 *--------------------------------------------------------------------------
 * @purpose:  ZModeler's splines helpers
 *--------------------------------------------------------------------------
 * @histroy: 30.09.2003. Created
 */
#ifndef zsplineshelper_h_included
#define zsplineshelper_h_included

#include <zmodeler.h>
#include <scene/ISplineNode.h>
#include <core/ui/ISceneViewport.h>

namespace scene
{

  DLL_LINKAGE ZRESULT ZAPICALL createSpline(ISpline** ppSpline);
  DLL_LINKAGE ZRESULT ZAPICALL createSplineNode(ISplineNode** ppNode);//contains ISpline.
  DLL_LINKAGE ZRESULT ZAPICALL createControlPoint(IControlPoint** ppPoint);

  DLL_LINKAGE ZRESULT ZAPICALL getNearestSplinePoint(
                                    ISpline* pSpline, 
                                    ZLine3D& line, 
                                    IControlPoint** ppStartControl, 
                                    IControlPoint** ppEndControl,
                                    float* pU,
                                    float fPrecision);
  DLL_LINKAGE ZRESULT ZAPICALL splineHitTest(
                                    ISpline* pSpline, 
                                    ZMatrix& matSpline, //matrix from world to spline
                                    core::ui::IViewport* pVPort, 
                                    ZPoint& ptCursor, 
                                    float fPixelPrecision, 
                                    IControlPoint** ppStartControl, 
                                    IControlPoint** ppEndControl,
                                    float* pU);

  //-------------------------------------------------------
  // @name : findSplineWeldVertex
  // Function searches for weld-condition on certain vertex
  // @param core::IProcParams* pParams     : user-input and stuff
  // @param float fPrecision               : precision (in 3d space)
  // @param scene::IControlPoint* ptExclude : point to exclude.
  // @param scene::ISpline**      ppResSpline : ret-val
  // @param scene::ISplineNode**  ppResNode : ret-val
  // @param bool*                 pbHead   : ret-val
  //
  // @return ZRESULT : ZRESULT_OK on success
  //-------------------------------------------------------
  DLL_LINKAGE ZRESULT ZAPICALL findSplineWeldVertex(
                                    core::IProcParams*    pParams, 
                                    float                 fPrecision,
                                    scene::IControlPoint* ptExclude,
                                    scene::ISpline**      ppResSpline,
                                    scene::ISplineNode**  ppResNode,
                                    bool*                 pbHead);
};//scene

#endif //zsplineshelper_h_included

