//
//  (C) Copyright 1999-2008 by Autodesk, Inc.  All rights reserved.
//
// Permission to use, copy, modify, and distribute this software in
// object code form for any purpose and without fee is hereby granted, 
// provided that the above copyright notice appears in all copies and 
// that both that copyright notice and the limited warranty and
// restricted rights notice below appear in all supporting 
// documentation.
//
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS. 
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE.  AUTODESK, INC. 
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
// UNINTERRUPTED OR ERROR FREE.
//
// Use, duplication, or disclosure by the U.S. Government is subject to 
// restrictions set forth in FAR 52.227-19 (Commercial Computer
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
// (Rights in Technical Data and Computer Software), as applicable.
//

// DESCRIPTION: This file contains class and functions definitions for
//              MCADAPI geometry keys.
//
#ifndef AMIGEOM_H
#define AMIGEOM_H

// Includes
//
#include "mibase.h"
#include "AdAChar.h"

// Forward class declarations.
//
class AcGeEntity3d;
class AcGeSurface;
class AcGeCurveBoundary;
class AcBrEntity;
class AmiFeatKey;
class AmiConstrKey;
class AmiSketchKey;
class AmiPartKey;

// Constant definitions
#define AMI_FROMTHEBEGINNING -1
#define AMI_TOTHEEND -1

// Geometry key classes.
//
class AMIAPI AmiGeomKey : public AmiObjectKey
{
  public:

    MCADAPI_DECLARE_MEMBERS(AmiGeomKey);

  protected:

    AmiGeomKey() {}
};

class AMIAPI AmiPointKey : public AmiGeomKey
{
  public:

    MCADAPI_DECLARE_MEMBERS(AmiPointKey);
};

class AMIAPI AmiVectorKey : public AmiGeomKey
{
  public:

    MCADAPI_DECLARE_MEMBERS(AmiVectorKey);
};

class AMIAPI AmiCurveKey : public AmiGeomKey
{
  public:

    MCADAPI_DECLARE_MEMBERS(AmiCurveKey);
};

class AMIAPI AmiLineKey : public AmiCurveKey
{
  public:

    MCADAPI_DECLARE_MEMBERS(AmiLineKey);
};

class AMIAPI AmiArcKey : public AmiCurveKey
{
  public:

    MCADAPI_DECLARE_MEMBERS(AmiArcKey);
};

class AMIAPI AmiEllipseKey : public AmiCurveKey
{
  public:

    MCADAPI_DECLARE_MEMBERS(AmiEllipseKey);
};

class AMIAPI AmiSplineCrvKey : public AmiCurveKey
{
  public:

    MCADAPI_DECLARE_MEMBERS(AmiSplineCrvKey);
};

class AMIAPI AmiPolylineKey : public AmiCurveKey
{
  public:

    MCADAPI_DECLARE_MEMBERS(AmiPolylineKey);
};

class AMIAPI AmiAuglineKey : public AmiCurveKey
{
  public:

    MCADAPI_DECLARE_MEMBERS(AmiAuglineKey);
};

typedef AmiArray<AmiGeomKey>   AmiGeomKeyArray;
typedef AmiArray<AmiPointKey>  AmiPointKeyArray;
typedef AmiArray<AmiLineKey>   AmiLineKeyArray;

// Registration section for MCAD API geometry key functions.
//

// Description: Creates a geometric key of a specified type using information
//              passed in by pick objects.  The function can infer geometry
//              from other geometry. A point can be inferred as the endpoint
//              of an open curve, the midpoint of a picked line or the center
//              point of an arc or ellipse. A line can be inferred as the axis
//              through the center of a picked arc perpendicular to the plane
//              of the arc. A plane can be inferred as the plane of a picked
//              arc or by two coplanar lines that were picked. If the operation
//              cannot be completed a bad status is returned and pGeomKey is
//              set to NULL.  It is the caller’s responsibility to release the
//              key.
// Input      : type      - The type of the geometry to be created.
//              inferFlag - A flag set to true or false to allow or disallow
//                          geometry to be inferred from other picked geometry.
//                          if false, do not infer any geometry.
//              pickObj1  - Pick information.
//              pickObj2  - Additional pick information required to infer the
//                          final key when two picked entities are involved as
//                          in inferring a plane from two coplanar lines.
// Output     : pGeomKey  - The pointer to the new geometry key.
AMIAPI AmiStatus amiGetGeomKey( AmiKeyType type,
							    Adesk::Boolean inferFlag, AmiGeomKey*& pGeomKey,
							    AmiPickObj* pPickObj1, AmiPickObj* pPickObj2 = NULL );

// Description: Returns an AcGe entity copy of the geometric object referred
//              to by the specified key. The GeLib object that is returned
//              is a snapshot of the geometric object referred to by the key
//              at the time of the query. After its construction, the GeLib
//              object is not kept up-to-date by the MCAD API. After being
//              used, the GeLib object should be deleted.
// Input      : pGeomKey  - Pointer to geometry key that refers to the object
//                          for which an AcGe entity copy is needed.
// Output     : pGeEntity - A pointer to the new GeEntity.
//
// NOTE:  Free the memory allocated for GeEntity when it is no longer needed.
AMIAPI AmiStatus amiGetGeomData ( AmiGeomKey* pGeomKey, AcGeEntity3d*& pGeEntity );

//
// Description: Sets the data in the geometric object referred to by the
//              specified key to the data in the Ge entity passed in. This
//              call will be successful only if the geometry is directly
//              editable as defined by the result of a call to
//              amiIsDirectlyEditable.
// Input      : pGeomKey - Pointer to geometry key to entity to be set.
// Output     : pGeEntity - Pointer to Ge entity to be used in setting the
//                          geometric object.
AMIAPI AmiStatus amiSetGeometry ( AmiGeomKey* pGeomKey, AcGeEntity3d* pGeEntity );

//
// Description: Checks if the geometric object referenced by pGeomKey has
//              changed since last checked. By default, notification is reset
//              after the call, meaning that if a change is indicated in a
//              call, a second call indicates change only if another change
//              happened since the previous call. This resetting can be
//              avoided by passing the value of resetNotification as
//              Adesk::kFalse.
// Input      : pGeomKey - A pointer to geometry key to application geometry.
//              resetToNewState - If true, passive notification will be
//                         reset; if false, passive notification will not be
//                         reset.
// Output     : changed  - A value of true if the application object changed;
//                         otherwise, it is false.
AMIAPI AmiStatus amiObjectHasChanged ( AmiGeomKey* pGeomKey, Adesk::Boolean& changed,
                              Adesk::Boolean resetToNewState = Adesk::kTrue );

#endif  // AMIGEOM_H
