cgma
FBIntersect.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 [email protected]
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 _FACETEDBOOLEANINTERSECT
00028 #define _FACETEDBOOLEANINTERSECT
00029 #include <math.h>
00030 #include <vector>
00031 #include "FBDefines.hpp"
00032 #include "FBStructs.hpp"
00033 #include "CubitDefines.h"
00034 #include "FBClassify.hpp"
00035 
00036 class FBPolyhedron;
00037 class FBRetriangulate;
00038 
00039 class FBIntersect {
00040 
00041 public:
00042   FBIntersect();
00043 
00044   CubitStatus intersect(const std::vector<double>& Ticoords,
00045                         const std::vector<int>& Ticonnections,
00046                         const std::vector<double>& Tjcoords,
00047                         const std::vector<int>& Tjconnections,
00048                         std::vector<int>& duddedTiFacets, 
00049                         std::vector<int>& duddedTjFacets,
00050                         std::vector<int>& newTiFacets, 
00051                         std::vector<int>& newTjFacets,
00052                         std::vector<int>& newTiFacetsIndex,
00053                         std::vector<int>& newTjFacetsIndex,
00054                         std::vector<double>& newTiPoints, 
00055                         std::vector<double>& newTjPoints,
00056                         std::vector<int>& edgesTi, 
00057                         std::vector<int>& edgesTj
00058                         );
00059 
00060 
00061   CubitStatus intersect(const std::vector<double>& Ticoords,
00062                         const std::vector<int>& Ticonnections,
00063                         const std::vector<double>& Tjcoords,
00064                         const std::vector<int>& Tjconnections,
00065                         std::vector<int>& newTiFacets, 
00066                         std::vector<int>& newTjFacets,
00067                         std::vector<int> *indices1,
00068                         std::vector<int> *indices2                        
00069                         );
00070                      
00071   ~FBIntersect();
00072   void set_classify_flag(bool value);
00073   CubitStatus gather_by_boolean(std::vector<double>& out_coords,
00074                                 std::vector<int>& out_connections,
00075                                 std::vector<int> *out_surf_index,
00076                                 std::vector<int> *out_curve_index,
00077                                 std::vector<bool> *is_body_1,
00078                                 const CubitFacetboolOp op
00079                                 );
00080 
00081   CubitStatus update_surfs_and_curves(std::vector<double>& out_coords,
00082                                       std::vector<int>& out_connections,
00083                                       std::vector<int> *out_surf_index,
00084                                       std::vector<int> *out_curve_index,
00085                                       const int whichone
00086                                       );
00087 
00088   CubitStatus get_persistent_entity_info(bool *surfs_in,
00089                                          bool *curves_in,
00090                                          bool *surfs_out,
00091                                          bool *curves_out,
00092                                          const CubitFacetboolOp op,
00093                                          const int whichparent
00094                                          );
00095                                          
00096   
00097   void set_body1_planar();
00098   void set_body2_planar();
00099   void set_imprint();
00100    
00101 private:
00102   double linecoeff[3];
00103   double linept[3];
00104   FBPolyhedron *poly1, *poly2; 
00105   bool do_edges_only;
00106   bool do_classify;
00107   bool do_imprint;
00108   bool body1_is_plane, body2_is_plane;
00109   bool nothing_intersected;
00110   std::vector<int> *f_c_indices1, *f_c_indices2;
00111   FBClassify *classify1, *classify2;
00112   CubitStatus pair_intersect();
00113   int get_vertex(FBPolyhedron *poly, int vtx, 
00114                  IntegerHash *hashobj,
00115                  std::vector<double>& out_coords,
00116                  int &num_sofar);
00117   int makeahashvaluefrom_coord(double x, double y, double z);
00118   CubitStatus tri_tri_intersect(FB_Triangle *tri1,
00119                                 FB_Triangle *tri2);
00120   CubitStatus add_intersection_edges(FB_Triangle *tri1,
00121               FB_Triangle *tri2,
00122               double *tt,
00123               int *edge_vert_type);
00124   inline void get_point_from_parameter(double parameter,
00125               double *x, double *y, double *z);
00126   inline double get_distance_parameter(double *xc0,
00127               double *xc1,
00128               double d0, double d1);
00129   inline double get_distance_parameter_single(double *xc);
00130   int get_intersectionline_parameter_values(
00131                     double d0, 
00132                     double d1, 
00133                     double d2,
00134                     double *pt0,
00135                     double *pt1,
00136                     double *pt2,
00137                     double& t0,
00138                     double& t1,
00139                     int& vert_type_0,
00140                     int& vert_type_1);
00141   inline int determine_edge_vert_type(int vtype1, int vtype2)
00142   {
00143     if ( ( (vtype1 == VERTEX_0) && (vtype2 == VERTEX_1) ) ||
00144          ( (vtype1 == VERTEX_1) && (vtype2 == VERTEX_0) ) ) 
00145       return EDGE_0;
00146     else if ( ( (vtype1 == VERTEX_1) && (vtype2 == VERTEX_2) ) || 
00147               ( (vtype1 == VERTEX_2) && (vtype2 == VERTEX_1) ) ) 
00148       return EDGE_1;
00149     else if ( ( (vtype1 == VERTEX_2) && (vtype2 == VERTEX_0) ) ||
00150               ( (vtype1 == VERTEX_0) && (vtype2 == VERTEX_2) ) ) 
00151       return EDGE_2;
00152     else return INTERIOR_VERT;
00153   }  
00154   void  newplanecoefficients(FBPolyhedron *poly, FB_Triangle *tri);
00155 
00156   CubitStatus store_connectivity( std::vector<int>& out_connections,
00157                                   int vertnum1,
00158                                   int vertnum2,
00159                                   int vertnum3 );
00160 };
00161 
00162 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines