cgma
FBPolyhedron.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 _FBPOLYHEDRON
00028 #define _FBPOLYHEDRON
00029 #include <vector>
00030 #include <map>
00031 #include "FBStructs.hpp"
00032 #include "IntegerHash.hpp"
00033 #include "CubitDefines.h"
00034 #include "KdTree.hpp"
00035 
00036 class FBPolyhedron {
00037 
00038 friend class FBIntersect;
00039 friend class FBClassify;
00040 friend class FBImprint;
00041 
00042 public:
00043   FBPolyhedron();
00044   ~FBPolyhedron();
00045   CubitStatus makepoly(const std::vector<double>& coords,
00046                        const std::vector<int>& connections,
00047                        std::vector<int> *f_c_indices);
00048   bool boxintersection(FBPolyhedron *otherpoly);
00049   CubitStatus retriangulate(std::vector<int>& newfacets, 
00050                             std::vector<int>& newfacetsindex);
00051   CubitStatus retriangulate(std::vector<int>& newfacets);
00052 bool edge_exists_in_tri(FB_Triangle& tri, int v0, int v1);
00053 
00054 private:
00055   std::vector<FB_Coord *> verts;
00056   std::vector<FB_Triangle *> tris;
00057   std::vector<FB_Edge *> intersection_edges;
00058   std::vector<FB_Triangle*> dudded_tris;
00059   std::vector<FB_Edge*> orphaned_edges;   // edges that need deletion but are not connected to tris
00060   std::multimap<unsigned int,unsigned int> edgmmap;
00061   double polyxmin, polyxmax, polyymin, polyymax, polyzmin, polyzmax;
00062   IntegerHash *hashobj;
00063   int makeahashvaluefrom_coord(double x, double y, double z);
00064   int addavertex(double x, double y, double z);
00065   unsigned int numpts, numtris;
00066   void putnewpoints(std::vector<double>& newpoints);
00067   void putedges(std::vector<int>& newedges); 
00068   bool edge_exists(int v0, int v1); 
00069   KDTree *kdtree;
00070   int original_numtris;
00071 //  void putnewtriangles(std::vector<int>& newFacets);
00072   void add_new_triangle_data();
00073   void make_tri_plane_coeffs(FB_Triangle *tri);
00074   void make_tri_boundingbox(FB_Triangle *tri);
00075   void removeduddedtriangles();
00076   
00077     //debug functions
00079   bool min_max_angles_in_fb_triangle(FB_Triangle *tri, double& min_angle,
00080                                     double& max_angle );
00083   bool min_max_angles_in_polyhedron(double& min_angle, double& max_angle);
00085   void debug_draw_fb_triangle(FB_Triangle *tri);
00088   void debug_draw_boundary_edges(int color);
00091   bool remove_small_angles_in_triangle_range(int lower_index,
00092                                              int upper_index);
00093   
00094 };
00095 
00096 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines