cgma
FacetProjectTool.hpp
Go to the documentation of this file.
00001 //-------------------------------------------------------------------------
00002 // Filename      : FacetProjectTool.hpp
00003 //
00004 // Purpose       : Project curve segments onto a facetted surface.
00005 //
00006 // Special Notes : Used for surface partitioning.
00007 //
00008 // Creator       : Jason Kraftcheck
00009 //
00010 // Creation Date : 05/08/02
00011 //-------------------------------------------------------------------------
00012 
00013 #ifndef FACET_PROJECT_TOOL_HPP
00014 #define FACET_PROJECT_TOOL_HPP
00015 
00016 #include <vector>
00017 
00018 #include "CubitDefines.h"
00019 #include "DLIList.hpp"
00020 
00021 class PST_Edge;
00022 class PST_CoEdge;
00023 class PST_Face;
00024 class PST_Point;
00025 class PST_Entity;
00026 
00027 class CubitVector;
00028 
00034 class FacetProjectTool
00035 {
00036   public:
00037 
00038   FacetProjectTool();
00039   ~FacetProjectTool();
00040   
00092   CubitStatus project(
00093     DLIList<CubitVector*>& segments,            // in
00094     const std::vector<double>& coordinates, // in
00095     const std::vector<int>& connections,      // in
00096     std::vector<int>& duddedFacets,           // out
00097     std::vector<int>& newFacets,                // out
00098     std::vector<int>& newFacetsIndex,           // out
00099     std::vector<double>& newPoints,           // out
00100     std::vector<int>& edges,                    // out
00101     std::vector<int>& segmentPoints,        // out
00102     const double *tolerance_length = NULL
00103   );
00104   
00105   void debug( DLIList<CubitVector*>& segments,
00106               std::vector<double>& coordinates,
00107               std::vector<int>& connections );
00108     
00109   protected:
00110   
00111   void cleanup();
00112   
00113   PST_Point* project( const CubitVector& point,
00114                       const double* tolerance_length = NULL );
00115     //- Project a single point into the surface facetting.
00116     //- Returns resulting facet point.  
00117     //- Used for creating point-curves on partition surfaces.
00118       
00119     //- Use get_result_set(..) to get the results of the projection.
00120   
00121   CubitStatus get_result_set( DLIList<PST_CoEdge*>& edges );
00122     //- Get one of multiple possible sections of projected curve
00123     //- from the above project() method.  Returns CUBIT_FAILURE
00124     //- when there are no more results available.
00125     
00126   CubitStatus do_projection( const DLIList<CubitVector*>& segments ,
00127                              CubitBoolean& point_changed,
00128                              const double *tolerance_length = NULL);
00129     //- Project a segmented curve onto the facetted surface.
00130     //- project(..) will return CUBIT_FAILURE if none of the
00131     //- segmentes projected onto the surface.
00132     //- Use get_result_set(..) to get the results of the projection.
00133 
00134   CubitStatus project( PST_Point* &start, PST_Point* &end );
00135     //- Given two points within the facet patch, project the
00136     //- connecting segment onto the facets.  Assumes the
00137     //- projected segment will not intersect the boundary of
00138     //- the patch anywhere except the passed points.
00139   
00140   PST_Face* closest_face( const CubitVector& position );
00141     //- Find the facet for which the projection of the
00142     //- passed position onto the facet lies within the
00143     //- boundary of the facet and is closest to the passed
00144     //- position.  May return NULL if the position projects
00145     //- into no facets.
00146   
00147   PST_Edge* closest_edge( const CubitVector& position );
00148     //- Find the edge for which the closest point on the line
00149     //- of the edge to the passed position lies within the
00150     //- bounded edge and is closest to the passed position.
00151     //- May return NULL if the projection of the position 
00152     //- lies outside of all bounded edges.
00153     
00154   PST_Point* closest_point( const CubitVector& position );
00155     //- Find the point closest to the passed position.  Does
00156     //- not check points on the boundary of the facet patch.
00157     //- Will return null if all points are on the boundary.
00158   
00159   static bool project_to_face( PST_Face* face, 
00160                                const CubitVector& position,
00161                                CubitVector& result ) ;
00162     //- Project the pasesd position onto the passed face.  Returns
00163     //- false and does not change result if the projection of the
00164     //- point onto the plane of the face lies outside the face.
00165     
00166   static bool inside_face( PST_Face* face, const CubitVector& position );
00167   
00168   PST_Point* insert_in_face( PST_Face* face, 
00169                              const CubitVector& position );
00170     //- Insert a point in the interior of a triangle, splitting 
00171     //- the triangle into three triangles.
00172                              
00173   PST_Point* split_edge( PST_Edge* edge, double t );
00174     //- Split an edge, creating a new point and edge.  Adjacent
00175     //- faces are split with an edge from the new point to
00176     //- the point opposite the original edge on the face.
00177                              
00178   static
00179   void closest_on_lines( const CubitVector& base1,
00180                          const CubitVector& direction1,
00181              const CubitVector& base2,
00182              const CubitVector& direction2,
00183              double& t1, double& t2 ); 
00184     //- Find the closest point on each of two skew lines to
00185     //- the other.  Result is returned as fraction of the 
00186     //- direction vector (from the base point) for each line.
00187     
00188   static
00189   double closest_on_line( const CubitVector& base,
00190                           const CubitVector& direction,
00191               const CubitVector& from_position );
00192     //- Find the closest point on a line from the passed position.
00193     //- Returns result location as a multiple of the direction vector
00194     //- from the base point.
00195   
00196   CubitStatus populate_data( const DLIList<PST_Face*>& facets );
00197     //- Used to be the class constructor.  Fills in the private data lists 
00198     //- and sets marks on facet entities
00199   
00200   static
00201   bool within_tolerance ( PST_Edge* edge, const CubitVector& point, double tolerance );
00202   
00203   //static
00204   CubitStatus next_around_point( PST_Point*& point,
00205                                  const CubitVector& segment_end,
00206                                  PST_Face*& closest_face,
00207                                  PST_Edge*& closest_edge,
00208                                  CubitBoolean & is_boundary_edge,
00209                                  PST_Edge *last_closest_edge);
00210   
00211   private:
00212   
00213   DLIList<PST_Face*> facetList;
00214   DLIList<PST_Edge*> edgeList;
00215   DLIList<PST_Point*> pointList;
00216     //- Lists of all entities in the facet patch
00217   
00218   DLIList<PST_Point*> segPoints;
00219     //- List of facet points corresponding to input segment points.
00220     //- Some entries may be NULL.
00221     
00222   DLIList<PST_Edge*> boundaryList;
00223     //- List of edges on the boundary of the facet patch
00224     
00225   DLIList<PST_CoEdge*> imprintResult;
00226     //- List of resulting imprinted edges.
00227 
00228   CubitStatus find_closest_int_point_with_boundary( 
00229     CubitVector &start_pt, 
00230     CubitVector &end_pt, 
00231     CubitVector &closest_pt );
00232 
00233   int point_on_facets( 
00234     CubitVector *pos,    
00235     double tolerance_sq );
00236 
00237   void finalize_results();
00238 };
00239 
00240 #endif
00241 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines