#include "./Headers/UserDefinedPrimitiveDLLInclude.h"
// User's own utility function prototypes
long CreatePath(struct UDPFunctionLib* functionLib, void* callbackData, double* paramValues, struct UDPPosition* startPt, struct UDPPosition* endPt);
long CreateProfile(struct UDPFunctionLib* functionLib, void* callbackData, double* paramValues);
void NameEntities(struct UDPFunctionLib* functionLib, void* callbackData, double* paramValues, struct UDPPosition* startPt, struct UDPPosition* endPt);
static struct UDPPrimitiveTypeInfo primitiveInfo =
{
"Rectangular Spiral",
"Create a Rectangular Spiral in XY plane",
". Corporation",
"09-25-2006",
"1.0"
};
extern "C" DLLEXPORT
struct UDPPrimitiveTypeInfo* GetPrimitiveTypeInfo()
{
return &primitiveInfo;
}
struct UDPPrimitiveParameterDefinition primParams[] =
{
{"Xpos", "X Position of start point", kUDPLengthUnit, 0},
{"Ypos", "Y Position of start point", kUDPLengthUnit, 0},
{"Dist", "Distance between turns", kUDPLengthUnit, 5},
{"Turns", "Number of turns", kUDPNoUnit, 2},
{"Width", "Width of the spiral", kUDPLengthUnit, 2},
{"Thickness", "Thickness/height of the spiral", kUDPLengthUnit, 1},
{"Radius", "Radius of inner turn", kUDPLengthUnit, 10}
};
static int numOfParameters = sizeof(primParams)/sizeof(primParams[0]);
extern "C" DLLEXPORT
int GetPrimitiveParametersDefinition(struct UDPPrimitiveParameterDefinition** paramDefinition)
{
*paramDefinition = primParams;
return numOfParameters;
}
extern "C" DLLEXPORT
char* GetLengthParameterUnits()
{
return "mm";
}
char* registeredFaceNames[] = { "InnerEndFace", "OuterEndFace"};
static int numOfFaceNames = sizeof(registeredFaceNames)/sizeof(char*);
extern "C" DLLEXPORT
int GetRegisteredFaceNames(char*** faceNames)
{
*faceNames = registeredFaceNames;
return numOfFaceNames;
}
char* registeredEdgeNames[] = { "Inner-B", "Inner-L", "Inner-T", "Inner-R",
"Outer-B", "Outer-L", "Outer-T", "Outer-R"};
static int numOfEdgeNames = sizeof(registeredEdgeNames)/sizeof(char*);
extern "C" DLLEXPORT
int GetRegisteredEdgeNames(char*** edgeNames)
{
*edgeNames = registeredEdgeNames;
return numOfEdgeNames;
}
char* registeredVertexNames[] = { "Inner-B-L", "Inner-L-T", "Inner-T-R", "Inner-R-B",
"Outer-B-L", "Outer-L-T", "Outer-T-R", "Outer-R-B"};
static int numOfVertexNames = sizeof(registeredVertexNames)/sizeof(char*);
extern "C" DLLEXPORT
int GetRegisteredVertexNames(char*** vertexNames)
{
*vertexNames = registeredVertexNames;
return numOfVertexNames;
}
// Incase of error this function should return 0
extern "C" DLLEXPORT
int AreParameterValuesValid(char ** error, double* paramValues)
{
int noOfTurns = (int)paramValues[3];
double dist = paramValues[2];
double width = paramValues[4];
double height = paramValues[5];
double radius = paramValues[6];
// Number of turns cannot be0
if (dist0
if (width0
if (heightwidth
if (disthalf width
if (radius addMessage(kUDPErrorMessage, "Could not create path", callbackData);
return 0;
}
// The profile
long profile = CreateProfile(functionLib, callbackData, paramValues);
// Is profile valid?
if (profile == -1)
{
functionLib->addMessage(kUDPErrorMessage, "Could not create profile", callbackData);
return 0;
}
struct UDPSweepOptions sweepOptions = {kUDPRoundDraft, 0.0, 0.0};
long success = functionLib->sweepAlongPath(profile, path, &sweepOptions, callbackData);
// Did the sweep operation succeed?
if (success == 0)
{
functionLib->addMessage(kUDPErrorMessage, "Could not sweep profile along path", callbackData);
return 0;
}
NameEntities(functionLib, callbackData, paramValues, &startPt, &endPt);
return success;
}
// User defined extra functions
long CreatePath(struct UDPFunctionLib* functionLib, void* callbackData, double* paramValues, struct UDPPosition* startPt, struct UDPPosition* endPt)
{
double xStart = paramValues[0];
double yStart = paramValues[1];
double CONST_Z = 0.0;
double dist = paramValues[2];
int noOfTurns = (int)paramValues[3];
double radius = paramValues[6];
int noOfPoints = 2 + 4*noOfTurns;
int noOfSegments = noOfPoints-1;
struct UDPPosition*arrayOfPositions = new UDPPosition[noOfPoints];
int i=0;
for (i=0; icreatePolyline(&polylineDefinition, callbackData);
*startPt = arrayOfPositions[0];
*endPt = arrayOfPositions[noOfPoints-1];
delete[] arrayOfPositions;
delete[] arrayOfSegmentDefinition;
// Did the polyline operation failed?
//assert(path == -1);
return path;
}
long CreateProfile(struct UDPFunctionLib* functionLib, void* callbackData, double* paramValues)
{
double xStartPos = paramValues[0];
double yStartPos = paramValues[1]-paramValues[6];
double CONST_Z = 0.0;
double width = paramValues[4];
double height = paramValues[5];
int noOfPoints = 5;
int noOfSegments = noOfPoints-1;
struct UDPPosition*arrayOfProfPositions = new UDPPosition[noOfPoints];
arrayOfProfPositions[0].x = xStartPos;
arrayOfProfPositions[0].y = yStartPos-(width/2.0);
arrayOfProfPositions[0].z = -height/2.0;
arrayOfProfPositions[1].x = xStartPos;
arrayOfProfPositions[1].y = yStartPos+(width/2.0);
arrayOfProfPositions[1].z = -height/2.0;
arrayOfProfPositions[2].x = xStartPos;
arrayOfProfPositions[2].y = yStartPos+(width/2.0);
arrayOfProfPositions[2].z = height/2.0;
arrayOfProfPositions[3].x = xStartPos;
arrayOfProfPositions[3].y = yStartPos-(width/2.0);
arrayOfProfPositions[3].z = height/2.0;
arrayOfProfPositions[4].x = xStartPos;
arrayOfProfPositions[4].y = yStartPos-(width/2.0);
arrayOfProfPositions[4].z = -height/2.0;
struct UDPPolylineSegmentDefinition*arrayOfSegmentDefinition = new UDPPolylineSegmentDefinition[noOfSegments];
for (int i=0; icreatePolyline(&polylineDefinition, callbackData);
delete[] arrayOfProfPositions;
delete[] arrayOfSegmentDefinition;
// Did the polyline operation failed?
//assert(profile == -1);
return profile;
}
void NameEntities(struct UDPFunctionLib* functionLib, void* callbackData, double* paramValues, struct UDPPosition* startPt, struct UDPPosition* endPt)
{
// Name faces
functionLib->nameAFace(startPt, registeredFaceNames[0], callbackData);
functionLib->nameAFace(endPt, registeredFaceNames[1], callbackData);
double width = paramValues[4];
double height = paramValues[5];
struct UDPPosition posOnEdge[8]; //numOfEdgeNames=8
// Inner face edges
// Inner face edge - Bottom
posOnEdge[0].x = (*startPt).x;
posOnEdge[0].y = (*startPt).y;
posOnEdge[0].z = (*startPt).z - height/2.0;
// Inner face edge - Left
posOnEdge[1].x = (*startPt).x;
posOnEdge[1].y = (*startPt).y - width/2.0;
posOnEdge[1].z = (*startPt).z;
// Inner face edge - Top
posOnEdge[2].x = (*startPt).x;
posOnEdge[2].y = (*startPt).y;
posOnEdge[2].z = (*startPt).z + height/2.0;
// Inner face edge - Right
posOnEdge[3].x = (*startPt).x;
posOnEdge[3].y = (*startPt).y + width/2.0;
posOnEdge[3].z = (*startPt).z;
// Outer face edges
// Outer face edge - Bottom
posOnEdge[4].x = (*endPt).x;
posOnEdge[4].y = (*endPt).y;
posOnEdge[4].z = (*endPt).z - height/2.0;
// Outer face edge - Left
posOnEdge[5].x = (*endPt).x;
posOnEdge[5].y = (*endPt).y - width/2.0;
posOnEdge[5].z = (*endPt).z;
// Outer face edge - Top
posOnEdge[6].x = (*endPt).x;
posOnEdge[6].y = (*endPt).y;
posOnEdge[6].z = (*endPt).z + height/2.0;
// Outer face edge - Right
posOnEdge[7].x = (*endPt).x;
posOnEdge[7].y = (*endPt).y + width/2.0;
posOnEdge[7].z = (*endPt).z;
struct UDPPosition posOnVertex[8]; //numOfVertexNames=8
// Inner face vertexs
// Inner face vertex - (common to Bottom & Left edge)
posOnVertex[0].x = (*startPt).x;
posOnVertex[0].y = (*startPt).y - width/2.0;
posOnVertex[0].z = (*startPt).z - height/2.0;
// Inner face vertex - (common to Left & Top edge)
posOnVertex[1].x = (*startPt).x;
posOnVertex[1].y = (*startPt).y - width/2.0;
posOnVertex[1].z = (*startPt).z + height/2.0;
// Inner face vertex - (common to Top & Right edge)
posOnVertex[2].x = (*startPt).x;
posOnVertex[2].y = (*startPt).y + width/2.0;
posOnVertex[2].z = (*startPt).z + height/2.0;
// Inner face vertex - (common to Right & Bottom edge)
posOnVertex[3].x = (*startPt).x;
posOnVertex[3].y = (*startPt).y + width/2.0;
posOnVertex[3].z = (*startPt).z - height/2.0;
// Outer face vertexs
// Outer face vertex - (common to Bottom & Left edge)
posOnVertex[4].x = (*endPt).x;
posOnVertex[4].y = (*endPt).y - width/2.0;
posOnVertex[4].z = (*endPt).z - height/2.0;
// Outer face vertex - (common to Left & Top edge)
posOnVertex[5].x = (*endPt).x;
posOnVertex[5].y = (*endPt).y - width/2.0;
posOnVertex[5].z = (*endPt).z + height/2.0;
// Outer face vertex - (common to Top & Right edge)
posOnVertex[6].x = (*endPt).x;
posOnVertex[6].y = (*endPt).y + width/2.0;
posOnVertex[6].z = (*endPt).z + height/2.0;
// Outer face vertex - (common to Right & Bottom edge)
posOnVertex[7].x = (*endPt).x;
posOnVertex[7].y = (*endPt).y + width/2.0;
posOnVertex[7].z = (*endPt).z - height/2.0;
for (int i=0; inameAEdge(&(posOnEdge[i]), registeredEdgeNames[i], callbackData);
functionLib->nameAVertex(&(posOnVertex[i]), registeredVertexNames[i], callbackData);
}
}
厉害,这么多的内容
看不懂
什么东东啊。俺也不懂啊..
UDP画电感?看起来像C语言啊。不过没有找到main函数。哈哈。
这到底是什么?
hfss里面用c语言生成可参数化的复杂结构在draw->User Defined Primitives下面有个例子
确实厉害啊,是不是可以用他来设计电容,电感啊.具体用这种方法有什么用,还望楼主指点哈.
唯一的功能就是生成复杂的图形,需要变动的值可以做成参数,熟悉VB就用VBS,熟悉C语言就用这个
hfss v10内有画螺旋体的工具。
我用这工具做了电感但计算的电感量感觉比实际大。
看不懂,有些深奥。
声明:网友回复良莠不齐,仅供参考。如需更专业、系统的学习HFSS,可以购买本站资深专家讲授的HFSS视频培训课程。