cgma
FBDataUtil.hpp
Go to the documentation of this file.
00001 /*
00002  *
00003  *
00004  * Copyright (C) 2004 Sandia Corporation.  Under the terms of Contract DE-AC04-94AL85000
00005  * with Sandia Corporation, the U.S. Government retains certain rights in this software.
00006  *
00007  * This file is part of facetbool--contact via cubit@sandia.gov
00008  *
00009  * This library is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU Lesser General Public
00011  * License as published by the Free Software Foundation; either
00012  * version 2.1 of the License, or (at your option) any later version.
00013  *
00014  * This library is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017  * Lesser General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU Lesser General Public
00020  * License along with this library; if not, write to the Free Software
00021  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022  *
00023  *
00024  *
00025  */
00026 
00027 #ifndef _FBDATAUTIL
00028 #define _FBDATAUTIL
00029 #include <vector>
00030 #include "CubitBox.hpp"
00031 #include "CubitVector.hpp"
00032 #include "CubitDefines.h"
00033 #include "DLIList.hpp"
00034 
00035 //===========================================================================
00036 //  Arguments:
00037 //  bbox (INPUT) the bounding box to intersect the plane with
00038 //  v0 (INPUT) the coordinates of the first point in the plane
00039 //  v1 (INPUT) the coordinates of the second point in the plane
00040 //  v2 (INPUT) the coordinates of the third point in the plane
00041 //  intersection_points (INPUT/OUTPUT) the array of points, up to six, that
00042 //  are the intersections of the box edges with the plane
00043 //  Returnn Value:  the number of intersection points
00044 //===========================================================================
00045 class FBDataUtil {
00046 
00047 public:
00048 
00049 static void intersect_plane_with_boundingbox(CubitBox &bbox, 
00050                                             const CubitVector &v0, 
00051                                             const CubitVector &v1,
00052                                             const CubitVector &v2,
00053                                             DLIList<CubitVector> &intersection_points); 
00054 
00055 //===========================================================================
00056 //  Arguments:
00057 //  verts (INPUT/OUTPUT) the array of vertex coordinates (xyz,xyz,etc.)
00058 //  coords (INPUT/OUTPUT) the array of connections
00059 //  xsize (INPUT) the length in the x direction
00060 //  ysize (INPUT) the length in the y direction
00061 //  numx (INPUT) the number of points along the x direction, at least 2
00062 //  numy (INPUT) the number of points along the y direction, at least 2
00063 //  makes 2*(numx-1)*(numy-1) triangles in the x-y plane centered on the origin
00064 //===========================================================================
00065 static CubitStatus FBmake_xy_plane(std::vector<double>& verts, 
00066                                    std::vector<int>& coords, 
00067                                    double xsize, 
00068                                    double ysize, 
00069                                    int numx, 
00070                                    int numy);
00071 
00072 //===========================================================================
00073 //  Arguments:
00074 //  verts (INPUT/OUTPUT) the array of vertex coordinates (xyz,xyz,etc.)
00075 //  NormalDir (INPUT) the direction to rotate the z-axis into
00076 //  CenterPt (INPUT) the location that (0,0,0) will be translated to
00077 //===========================================================================
00078 static CubitStatus rotate_FB_object(std::vector<double>& verts, 
00079                              CubitVector &NormalDir, 
00080                              CubitVector &CenterPt);
00081 
00082 static int makeahashvaluefrom_coord(double x, double y, double z, 
00083                                                 int numhashbins);
00084 
00085 //===========================================================================
00086 //  Arguments:
00087 //  verts (INPUT/OUTPUT) the array of vertex coordinates (xyz,xyz,etc.)
00088 //  coords (INPUT/OUTPUT) the array of connections
00089 //  radius (INPUT) the radius
00090 //  length (INPUT) the length in the z direction
00091 //  nr (INPUT) the number of points along the radial direction
00092 //  nz (INPUT) the number of points along the z direction
00093 //  
00094 //===========================================================================
00095 static CubitStatus FBmake_cylinder(std::vector<double>& verts, 
00096                                    std::vector<int>& coords, 
00097                                    double radius, 
00098                                    double length, 
00099                                    int nr, 
00100                                    int nz);
00101 
00102 //===========================================================================
00103 //  Arguments:
00104 //  point (INPUT) point coordinates
00105 //  a, b, c, d (INPUT) plane coefficients
00106 //  projected_pt (outPUT) projection of the point onto the plane
00107 //  Returns signed distance of point to plane.
00108 //===========================================================================
00109 static double project_point_to_plane(double *point, double a, double b, 
00110                                      double c, double d, 
00111                                      double *projected_pt);
00112 
00113 //===========================================================================
00114 //  Finds closest distance between two 3-D line segments.  Also returns parametric
00115 //  distance along each segment where the shortest line joining the two segments
00116 //  intersects the segments.  And a boolean that says whether the segments are
00117 //  parallel or not.  If parallel, *s and *t are undefined.
00118 //  Arguments:
00119 //  p0 (INPUT) beginning coordinates of first segment
00120 //  d0 (INPUT) coordinates of end of first segment minus beginning
00121 //  p1 (INPUT) beginning coordinates of second segment
00122 //  d1 (INPUT) coordinates of end of second segment minus beginning
00123 //  s (OUTPUT) Clipped parametric distance along first segment.  0. <= s <= 1.
00124 //  t (OUTPUT) Clipped parametric distance along second segment.  0. <= s <= 1.
00125 //  sunclipped (OUTPUT) parametric distance along first segment.  May be outside range.
00126 //  tunclipped (OUTPUT) parametric distance along second segment.  May be outside range.
00127 //  parallel (OUTPUT) true if segments are parallel; otherwise, false.
00128 //  
00129 //===========================================================================
00130 static double closest_seg_seg_dist(double *p0, double *d0, 
00131                              double *p1, double *d1, double *s, double *t, 
00132                              double *sunclipped, double *tunclipped, 
00133                              bool *parallel);
00134 
00135 //===========================================================================
00136 //  Finds closest distance between two 3-D line segments.  Also returns parametric
00137 //  distance along each segment where the shortest line joining the two segments
00138 //  intersects the segments.  And a boolean that says whether the segments are
00139 //  parallel or not.  If parallel, *s and *t are undefined.
00140 //  Arguments:
00141 //  p0 (INPUT) beginning coordinates of first segment
00142 //  d0 (INPUT) coordinates of end of first segment minus beginning
00143 //  p1 (INPUT) beginning coordinates of second segment
00144 //  d1 (INPUT) coordinates of end of second segment minus beginning
00145 //  s (OUTPUT) Clipped parametric distance along first segment.  0. <= s <= 1.
00146 //  t (OUTPUT) Clipped parametric distance along second segment.  0. <= s <= 1.
00147 //  sunclipped (OUTPUT) parametric distance along first segment.  May be outside range.
00148 //  tunclipped (OUTPUT) parametric distance along second segment.  May be outside range.
00149 //  parallel (OUTPUT) true if segments are parallel; otherwise, false.
00150 //  
00151 //===========================================================================
00152                              
00153                              
00154 private:
00155 
00156 //===========================================================================
00157 //Function Name: add_unique_point
00158 //Description:   Given a point and a list of points, add the point to the list
00159 //               unless it is already in the list within GEOMETRY_RESABS.
00160 //Author:
00161 //Date: 3/2005
00162 //===========================================================================
00163 static void add_unique_point( DLIList<CubitVector > &points,
00164                               const CubitVector &pt );
00165 
00166 
00167 };
00168 
00169 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines