[cig-commits] commit: Add Cylinder as a SurfaceType
Mercurial
hg at geodynamics.org
Mon Mar 1 15:43:51 PST 2010
changeset: 590:1ded9c334df0
tag: tip
user: Walter Landry <wlandry at caltech.edu>
date: Mon Mar 01 15:25:55 2010 -0800
files: Mesh/src/SurfaceAdaptor.c Mesh/src/SurfaceAdaptor.h
description:
Add Cylinder as a SurfaceType
diff -r c08747efed34 -r 1ded9c334df0 Mesh/src/SurfaceAdaptor.c
--- a/Mesh/src/SurfaceAdaptor.c Tue Feb 23 16:35:10 2010 -0800
+++ b/Mesh/src/SurfaceAdaptor.c Mon Mar 01 15:25:55 2010 -0800
@@ -351,6 +351,35 @@ void _SurfaceAdaptor_AssignFromXML_Surfa
info->trig.freq =
Stg_ComponentFactory_GetDouble( cf, name,
(Dictionary_Entry_Key)strcat(temp,"Frequency"), 1.0 );
+ } else if( !strcmp( surfaceName, "cylinder" ) ) {
+ *surfaceType = SurfaceAdaptor_SurfaceType_Cylinder;
+ *deformFunc = SurfaceAdaptor_Cylinder ;
+ strcpy(temp,surface);
+ info->cylinder.origin[0] =
+ Stg_ComponentFactory_GetDouble( cf, name,
+ (Dictionary_Entry_Key)strcat(temp,"X0"), 0.0 );
+ strcpy(temp,surface);
+ info->cylinder.origin[1] =
+ Stg_ComponentFactory_GetDouble( cf, name,
+ (Dictionary_Entry_Key)strcat(temp,"Y0"), 0.0 );
+ strcpy(temp,surface);
+ info->cylinder.r =
+ Stg_ComponentFactory_GetDouble( cf, name,
+ (Dictionary_Entry_Key)strcat(temp,"Radius"), 0.0 );
+ strcpy(temp,surface);
+ info->cylinder.minX =
+ Stg_ComponentFactory_GetDouble( cf, name,
+ (Dictionary_Entry_Key)strcat(temp,"MinX"),
+ info->cylinder.origin[0] - info->cylinder.r);
+ strcpy(temp,surface);
+ info->cylinder.maxX =
+ Stg_ComponentFactory_GetDouble( cf, name,
+ (Dictionary_Entry_Key)strcat(temp,"MaxX"),
+ info->cylinder.origin[0] + info->cylinder.r);
+ strcpy(temp,surface);
+ info->cylinder.sign =
+ Stg_ComponentFactory_GetBool( cf, name,
+ (Dictionary_Entry_Key)strcat(temp,"Sign"), True );
}
else
Journal_Firewall(!strcmp(surfaceName,""),Journal_Register( Error_Type, name ),
@@ -624,4 +653,29 @@ double SurfaceAdaptor_Cosine( SurfaceAda
return info->trig.amp * cos( info->trig.freq * rad );
}
+double SurfaceAdaptor_Cylinder( SurfaceAdaptor_SurfaceInfo *info, Mesh* mesh,
+ unsigned* globalSize, unsigned vertex,
+ unsigned* vertexInds )
+{
+ double x, x0, minX, maxX, y0, r;
+ x = mesh->verts[vertex][0];
+ x0= info->cylinder.origin[0];
+ minX=info->cylinder.minX;
+ maxX=info->cylinder.maxX;
+
+ y0= info->cylinder.origin[1];
+ r = info->cylinder.r;
+ if(x<minX)
+ {
+ x=minX;
+ }
+ else if(x>maxX)
+ {
+ x=maxX;
+ }
+ return info->cylinder.sign ? y0+sqrt(r*r-(x-x0)*(x-x0))
+ : y0-sqrt(r*r-(x-x0)*(x-x0));
+}
+
+
diff -r c08747efed34 -r 1ded9c334df0 Mesh/src/SurfaceAdaptor.h
--- a/Mesh/src/SurfaceAdaptor.h Tue Feb 23 16:35:10 2010 -0800
+++ b/Mesh/src/SurfaceAdaptor.h Mon Mar 01 15:25:55 2010 -0800
@@ -53,6 +53,7 @@
SurfaceAdaptor_SurfaceType_Topo_Data,
SurfaceAdaptor_SurfaceType_Sine,
SurfaceAdaptor_SurfaceType_Cosine,
+ SurfaceAdaptor_SurfaceType_Cylinder,
SurfaceAdaptor_SurfaceType_Invalid
} SurfaceAdaptor_SurfaceType;
@@ -79,11 +80,19 @@
double freq;
} SurfaceAdaptor_TrigInfo;
+ typedef struct {
+ double origin[2];
+ double minX, maxX;
+ double r;
+ Bool sign;
+ } SurfaceAdaptor_CylinderInfo;
+
typedef union {
SurfaceAdaptor_WedgeInfo wedge;
SurfaceAdaptor_PlateauInfo plateau;
SurfaceAdaptor_Topo_DataInfo topo_data;
SurfaceAdaptor_TrigInfo trig;
+ SurfaceAdaptor_CylinderInfo cylinder;
} SurfaceAdaptor_SurfaceInfo;
typedef double (SurfaceAdaptor_DeformFunc)( SurfaceAdaptor_SurfaceInfo* self,
@@ -162,6 +171,10 @@
unsigned* globalSize, unsigned vertex, unsigned* vertexInds );
double SurfaceAdaptor_Cosine( SurfaceAdaptor_SurfaceInfo *info, Mesh* mesh,
unsigned* globalSize, unsigned vertex, unsigned* vertexInds );
+ double SurfaceAdaptor_Cylinder( SurfaceAdaptor_SurfaceInfo *info,
+ Mesh* mesh,
+ unsigned* globalSize, unsigned vertex,
+ unsigned* vertexInds );
#endif /* __StgDomain_Mesh_SurfaceAdaptor_h__ */
More information about the CIG-COMMITS
mailing list