cgma
PeriodicParamTool.cpp
Go to the documentation of this file.
00001 //- Class: PeriodicParamTool
00002 //-------------------------------------------------------------------------
00003 // Filename      : PeriodicParamTool.cpp
00004 //
00005 // Purpose       : Handles surfaces that have a periodic parameterization
00006 //                 Uses, but modifies, the underlying engine parameterization
00007 //
00008 //
00009 // Creator       : Ray J. Meyers
00010 //
00011 // Creation Date : 12/15/2008
00012 //
00013 // Owner         : Ray J. Meyers
00014 //-------------------------------------------------------------------------
00015 
00016 #include "PeriodicParamTool.hpp"
00017 //#include "CastTo.hpp"
00018 #include "Surface.hpp"
00019 #include "CubitMessage.hpp"
00020 //#include "DLIList.hpp"
00021 
00022 //-------------------------------------------------------------------------
00023 // Function:    PeriodicParamTool
00024 // Description: constructor
00025 // Author:      chynes
00026 // Date:        7/10/2002
00027 //-------------------------------------------------------------------------
00028 PeriodicParamTool::PeriodicParamTool(Surface *surf) 
00029 {
00030     //- update private variables
00031     refSurf = surf;
00032     uOffset = 0.0;
00033     vOffset = 0.0;
00034   uPeriod = 0.0;
00035   vPeriod = 0.0;
00036   mirrorSurface = false;
00037 
00038 }
00039 
00040 //-------------------------------------------------------------------------
00041 // Function:    PeriodicParamTool
00042 // Description: deconstructor
00043 // Author:      chynes
00044 // Date:        7/10/2002
00045 //-------------------------------------------------------------------------
00046 PeriodicParamTool::~PeriodicParamTool() {}
00047 
00048 //===================================================================================
00049 // Function: set_up_space (Public)
00050 // Description: sets up space of flattening
00051 // Author: chynes
00052 // Date: 7/10/02
00053 //===================================================================================
00054 CubitStatus PeriodicParamTool::set_up_space(double u_period, double v_period, double u_offset, double v_offset)
00055 {
00056     // store the u and periods 
00057 
00058     uPeriod = u_period;
00059     vPeriod = v_period;
00060     uOffset = u_offset;
00061     vOffset = v_offset;
00062 
00063     
00064     CubitStatus rv = CUBIT_SUCCESS;
00065 
00066     return rv; 
00067 }
00068 
00069 //===================================================================================
00070 // Function: transform_to_uv (Public)
00071 // Description: same as title, the local sizing will be returned in the z coord 
00072 // Author: chynes
00073 // Date: 7/10/02
00074 //===================================================================================
00075 CubitStatus PeriodicParamTool::transform_to_uv(const CubitVector &xyz_location, CubitVector &uv_location) 
00076 {
00077      
00078     double u,v;
00079 
00080     CubitStatus rv = refSurf->u_v_from_position(xyz_location, u, v);
00081 
00082     // offset values to avoid parameter discontinuity
00083 
00084     if (uPeriod && u < uOffset)
00085     {
00086         u += uPeriod;
00087     }
00088   
00089   // mirror surface if required to get correct loop orientation
00090   if (mirrorSurface)
00091   {
00092     u = -u;
00093   }
00094 
00095     if (vPeriod && v < vOffset)
00096     {
00097         v += vPeriod;
00098     }
00099 
00100     uv_location.set(u,v,1.0);
00101 
00102 
00103     return rv;
00104 }
00105 
00106 //===================================================================================
00107 // Function: transform_to_xyz (Public)
00108 // Description: same as title
00109 // Author: chynes
00110 // Date: 7/10/02
00111 //===================================================================================
00112 CubitStatus PeriodicParamTool::transform_to_xyz(CubitVector &xyz_location, const CubitVector &uv_location) 
00113 {
00114     double u = uv_location.x(); 
00115   if (mirrorSurface)
00116   {
00117     u = -u;
00118   }
00119     if (u > uPeriod)
00120     {
00121         u = u - uPeriod;
00122     }
00123     double v = uv_location.y();
00124     if (v > vPeriod)
00125     {
00126         v = v - vPeriod;
00127     }
00128     xyz_location = refSurf->position_from_u_v(u,v);
00129 
00130 
00131     return CUBIT_SUCCESS;
00132 }
00133 
00134 void PeriodicParamTool::mirror_surface(bool true_false)
00135 {
00136   mirrorSurface = true_false;
00137   if (mirrorSurface)
00138     PRINT_INFO("Loops appear backwards, mirroring surface...\n");
00139  
00140 }
00141 
00142 CubitStatus PeriodicParamTool::uv_derivitives(double u_param, double v_param, 
00143                                               CubitVector &du, CubitVector &dv)
00144 {
00145   if (mirrorSurface)
00146     u_param = -u_param;
00147   if (u_param > uPeriod)
00148     u_param = u_param-uPeriod;
00149   if (v_param > vPeriod)
00150     v_param = v_param-vPeriod;
00151   refSurf->uv_derivitives(u_param, v_param, du, dv);
00152   return CUBIT_SUCCESS;
00153 }
00154 //EOF
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines