UDPBase.h
// File: UDPBase.h
#if !defined (UDP_BASE_H)
#define UDP_BASE_H
#include <math.h>
#include <string.h>
#include <stdio.h>
#include "../Headers/UserDefinedPrimitiveDLLInclude.h"
//***************************************
// Basic functions
//***************************************
// get version number * 100
int getVerNum(char *ver);
// get the distance of two points
double getDistance(UDPPosition p0, UDPPosition p1);
// filter segments with length < minD from a polyline
void purifyPolyline(UDPPolylineDefinition& polylineDefinition, double minD);
//***************************************
// Base class for any UDP
//***************************************
class CUDPBase
{
protected:
double minD;
int numOfParams;
double *oriParams;
double *paramValues;
bool checkOK; // 1: check OK; 0: check failed
UDPFunctionLib* functionLib;
void* callbackData;
protected:
bool GetValue(int i, char *s, double& v);
bool PutValue(int i, char *s, double& v);
bool GetValue(int i, char *s, int& v);
bool PutValue(int i, char *s, int& v);
bool GetValue(int i, char *s, bool& v);
bool PutValue(int i, char *s, bool& v);
virtual void GetParameters() = 0;
virtual void PutParameters() = 0;
virtual char *ValidateParameters() = 0; // return NULL if initialize OK
void SetFunctionLib(UDPFunctionLib* functionLib0, void* callbackData0);
// display messages
void DisplayInfo(char *msg=0);
// create lines
long CreateLine(UDPPosition startPos, UDPPosition endPos);
long CreatePolyLine(UDPPosition *pos, int numPos);
long CreateZAxisPath(double z0, double z1);
// create sheets
long CreateSheet(UDPPosition *pos, int numPos, int isSheet=1);
// create solids
long SweepAlongAxis(long obj, UDPCoordinateSystemAxis axis, double v0, double v1);
long SweepAroundAxis(long obj, UDPCoordinateSystemAxis axis, double angle);
// edit objects
long RotateAroundZVector(long obj, double angle, double x0=0, double y0=0);
long DuplicateAroundAxis(long obj, UDPCoordinateSystemAxis axis, int num,
double angle=0);
long AddObject(long objBase, long objAdd);
long SubObject(long objBase, long objSub);
public:
CUDPBase();
~CUDPBase() {delete[] paramValues;}
void IniParameters(double* paramValues0, int num);
void SetParameterPointer(double* paramValues0) {oriParams = paramValues0;}
void MapParameters(UDPPrimitiveParameterDefinition* params, int oldNum);
void SetDefaultParameter(double *returnParam, char *key, double defVal);
int AreParametersValid(char ** error);
virtual long CreatePrimitive(UDPFunctionLib* functionLib, void* callbackData) = 0;
};
#endif //if !defined (UDP_BASE_H)