home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-385-Vol-1of3.iso
/
i
/
iritsm3s.zip
/
cagd_lib
/
cagdedit.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-12-18
|
2KB
|
65 lines
/******************************************************************************
* CagdEdit.c - Editing tools of surfaces and Curves. *
*******************************************************************************
* Written by Gershon Elber, Sep. 91. *
******************************************************************************/
#include "cagd_loc.h"
/******************************************************************************
* Modify a single control point in the curve. *
******************************************************************************/
CagdCrvStruct *CagdEditSingleCrvPt(CagdCrvStruct *Crv, CagdCtlPtStruct *CtlPt,
int Index)
{
CagdBType
IsNotRational = !CAGD_IS_RATIONAL_CRV(Crv);
int i,
Length = Crv -> Length,
MaxCoord = CAGD_NUM_OF_PT_COORD(Crv -> PType);
CagdCrvStruct
*NewCrv = CagdCrvCopy(Crv);
CagdRType
**Points = NewCrv -> Points;
if (Crv -> PType != CtlPt -> PtType)
FATAL_ERROR(CAGD_ERR_PT_OR_LEN_MISMATCH);
if (Index < 0 || Index >= Length)
FATAL_ERROR(CAGD_ERR_INDEX_NOT_IN_MESH);
for (i = IsNotRational; i <= MaxCoord; i++)
Points[i][Index] = CtlPt -> Coords[i];
return NewCrv;
}
/*******************************************************************************
* Modify a single control point in the surface. *
******************************************************************************/
CagdSrfStruct *CagdEditSingleSrfPt(CagdSrfStruct *Srf, CagdCtlPtStruct *CtlPt,
int UIndex, int VIndex)
{
CagdBType
IsNotRational = !CAGD_IS_RATIONAL_SRF(Srf);
int i,
ULength = Srf -> ULength,
VLength = Srf -> VLength,
MaxCoord = CAGD_NUM_OF_PT_COORD(Srf -> PType);
CagdSrfStruct
*NewSrf = CagdSrfCopy(Srf);
CagdRType
**Points = NewSrf -> Points;
if (Srf -> PType != CtlPt -> PtType)
FATAL_ERROR(CAGD_ERR_PT_OR_LEN_MISMATCH);
if (UIndex < 0 || UIndex >= ULength ||
VIndex < 0 || VIndex >= VLength)
FATAL_ERROR(CAGD_ERR_INDEX_NOT_IN_MESH);
for (i = IsNotRational; i <= MaxCoord; i++)
Points[i][CAGD_MESH_UV(NewSrf, UIndex, VIndex)] =
CtlPt -> Coords[i];
return NewSrf;
}