cgma
CurveFacetEvalTool.hpp
Go to the documentation of this file.
00001 //- Class: CurveFacetEvalTool
00002 //- Description:  The CurveFacetEvalTool is a general purpose tool that uses a set
00003 //-               of facets to determine certain geometry computations.  This
00004 //-               class can be used to define a curve or do fast bounding box
00005 //-               calculations, or determine point inside or outside.
00006 //- Assumptions:  It is assumed/required that the facets be continuous through
00007 //-               the set.  In other words they must shared nodes and be conected
00008 //-               through each other.  The algorithms assume, for efficient searching,
00009 //-               that from one facet, you can get to any other facet in the set.
00010 //- Owner: Steven J. Owen
00011 //- Checked by: 
00012 
00013 #ifndef CURVE_FACET_EVAL_TOOL_HPP
00014 #define CURVE_FACET_EVAL_TOOL_HPP
00015 
00016 #include "DLIList.hpp"
00017 #include <map>
00018 
00019 class CubitBox;
00020 class CubitPoint;
00021 class CubitVector;
00022 class FacetEvalTool;
00023 class CubitFacetEdge;
00024 class FacetCurve;
00025 
00026 class CurveFacetEvalTool
00027 {
00028 private:
00029   int toolID;
00030   int interpOrder;
00031     //- interpolation order 0=linear, 1=gradient, 2=quadratic, 
00032     //                      3=least_squares, 4=spline
00033   DLIList<CubitFacetEdge*> myEdgeList;
00034   DLIList<CubitPoint*> myPointList;
00035   CubitBox *myBBox;
00036   FacetEvalTool *surfFacetEvalTool;
00037   double facetLength;
00038   CubitSense curvSense;
00039   CubitBoolean goodCurveData;
00040   int output_id;
00041 
00042   void draw_edges(int color = -1);
00043   void draw_edge(CubitFacetEdge *edge, int color);
00044   void draw_line(CubitVector &begin, CubitVector &end, int color = -1);
00045   void draw_location(CubitVector &loc, int color = -1 );
00046 
00047   void destroy_facets();
00048     //- Destroys the facets, and points.
00049 
00050   CubitStatus get_segments_from_loops(
00051     DLIList<DLIList<CubitFacetEdge*>*> *facet_loop_list,
00052     CubitVector &start, CubitVector &end,
00053     DLIList<CubitFacetEdge*> &edge_list,
00054     DLIList<CubitPoint*> &point_list,
00055     CubitSense owrts );
00056   CubitStatus get_segments_from_loops(
00057     DLIList<DLIList<CubitFacetEdge*>*> *facet_loop_list,
00058     CubitPoint *start_pt, CubitPoint *end_pt,
00059     DLIList<CubitFacetEdge*> &edge_list,
00060     DLIList<CubitPoint*> &point_list,
00061     CubitSense owrts );
00062     // generate a list of edges and points from the loop list
00063     // for this curve
00064 
00065   CubitStatus get_segments_from_positions( 
00066     std::vector<CubitVector> &positions,
00067     CubitVector &start_pt,
00068     DLIList<CubitFacetEdge*> &edge_list, 
00069     DLIList<CubitPoint*> &point_list );
00070       // generate a list of edges and points from the loop list
00071     // for this curve
00072   
00073   /*
00074   CubitStatus project_to_facet_edge(CubitVector &this_point,
00075                                     CubitVector &closest_point,
00076                                     CubitVector *tangent_ptr,
00077                                     CubitVector *curvature_ptr,
00078                                     double *param,
00079                                     int *outside );
00080 
00081     // project to the facet edge
00082   CubitStatus project_to_linear_facet_edge(CubitVector &this_point,
00083                                            CubitVector &closest_point,
00084                                            CubitVector *tangent_ptr,
00085                                            CubitVector *curvature_ptr,
00086                                            double *param,
00087                                            int *outside );
00088     // same as above except assumes linear representation AND
00089     // surfFacetEvalTool does notexist
00090 */
00091   // evaluates a fractional length onto a Bezier edge 
00092   CubitStatus evaluate_bezier_edge(CubitFacetEdge *edge,
00093                                    int index0,
00094                                    int index1,
00095                                    double fraction,
00096                                    CubitVector &location_on_curve,
00097                                    double *tangent);
00098 
00099   // projects a point onto a Bezier edge 
00100   CubitStatus project_to_bezier_edge(CubitFacetEdge *edge,
00101                         CubitVector &point, CubitVector &projected_point,
00102                         double *tangent, double *tval);                                   
00103                                         
00104   double u_on_facet_edge( CubitFacetEdge *edge_at_pt, 
00105                           CubitVector pt );
00106     // return the u param on the facet curve given a point on the
00107     // curve and the facet edge it is on
00108 
00109 //  CubitStatus project_to_edge_line( CubitFacetEdge *edge, 
00110 //                                    CubitVector &this_point, 
00111 //                                    CubitVector &pt_on_edge, 
00112 //                                    double &dist_to_edge );
00113     // project to the line defined by the edge
00114 
00115   CubitStatus fix_point_edge_order();
00116 
00117   CubitSense find_curv_sense( CubitPoint *start_ptr );
00118   CubitSense find_curv_sense( CubitVector &start );
00119 
00120 public:
00121 
00122   CurveFacetEvalTool();
00123   ~CurveFacetEvalTool();
00124 
00125   // Called immediately after the constructor to initialize the data.
00126   CubitStatus initialize( DLIList<CubitFacetEdge*> &edge_list,
00127                           DLIList<CubitPoint*> &point_list,
00128                           FacetEvalTool* surf_eval = NULL);
00129   CubitStatus initialize( FacetEvalTool *surf_eval_tool,
00130                           CubitPoint *start_point,
00131                           CubitPoint *end_point,
00132                           CubitSense orientation );
00133   CubitStatus initialize( FacetEvalTool *surf_eval_tool,
00134                           CubitVector &start,
00135                           CubitVector &end,                          
00136                           CubitSense orientation );
00137   CubitStatus initialize( FacetEvalTool *surf_eval_tool,
00138                           CubitVector &start,
00139                           std::vector<CubitVector> &positions );
00140 
00141   CubitStatus save(FILE *fp);
00142     // save to a cubit file
00143   CubitStatus restore(FILE *fp,
00144                       unsigned int endian,
00145                       int num_edges, 
00146                       int num_points,
00147                       CubitFacetEdge **edges, 
00148                       CubitPoint **points,
00149                       int num_fets,
00150                       FacetEvalTool **fet_list);
00151 
00152   int get_output_id() { return output_id; }
00153   void set_output_id( int id ) { output_id = id; }
00154 
00155   CubitBox bounding_box();
00156     //- Returns the bounding box for the set of facetedges (based on the points
00157     //- used in the faceted set.
00158 
00159   CubitStatus closest_point(CubitVector &this_point, 
00160                             CubitVector &closest_point_ptr,
00161                             CubitVector *normal_ptr = NULL,
00162                             CubitVector *curvature_ptr = NULL,
00163                             double *param = NULL);
00164     //- Finds the closest point from the vector (this_point) to the
00165     //- set of facets that lies on the set of facets.  If the point
00166     //- lies outside this set, the closest point will be on the plane
00167     //- of the closest facet.  The closest_point is set to be that point.
00168 
00169   // replace del_pnt with keep_pnt in point list
00170   CubitBoolean replace_point( CubitPoint *del_pnt, CubitPoint *keep_pnt );
00171 
00172   CubitBoolean replace_facets( DLIList< CubitFacetEdge *> &curv_edges );
00173 
00174   void remove_facets( DLIList<CubitFacetEdge*> &facet_edges);
00175 
00176   CubitStatus position_from_fraction( double fraction, // between 0 and 1
00177                                       CubitVector &location_on_curve );
00178     //- computes the location on the curve based on a fraction of the
00179     //- distance along the curve and the RefEdge sense
00180 
00181   double u_from_arc_length( double root_param, double arc_length );
00182   double length_from_u ( double root_param, double end_param );
00183 
00184   double length() { return facetLength; };
00185     //- return the length of the facet edges
00186 
00187   CubitSense sense() { return curvSense; };
00188     //- return the sense of the curve
00189 
00190   void get_facets(DLIList<CubitFacetEdge*>& facet_list)
00191     { facet_list +=  myEdgeList; }
00192     // append the edge facets for this curve onto facet_list
00193   void get_points(DLIList<CubitPoint*>& point_list)
00194     { point_list +=  myPointList; }
00195     // apend the points for this curve onto point_list
00196 
00197   FacetEvalTool *get_surf_eval_tool() { return surfFacetEvalTool; } 
00198   void set_facet_eval_tool(FacetEvalTool *surf_eval_tool_ptr) 
00199    { surfFacetEvalTool = surf_eval_tool_ptr;} 
00200     // get and set the associated surface facet eval tool 
00201 
00202   void set_length();
00203     // initialize the curve length
00204   
00205   CubitBoolean has_good_curve_data(){return goodCurveData;}
00206   
00207   void debug_draw_facet_edges(int color = -1 );
00208 
00209    
00210 };
00211 
00212 #endif // CURVE_FACET_EVAL_TOOL_HPP
00213 
00214 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines