cgma
PartSurfFacetTool.hpp
Go to the documentation of this file.
00001 //-------------------------------------------------------------------------
00002 // Filename      : PartSurfFacetTool.hpp
00003 //
00004 // Purpose       : Code for initializing PartitionSurface facetting and
00005 //                 other misc. facet-related code moved from PartitionSurf.
00006 //
00007 // Special Notes : 
00008 //
00009 // Creator       : Jason Kraftcheck
00010 //
00011 // Creation Date : 03/11/04
00012 //-------------------------------------------------------------------------
00013 
00014 
00015 #ifndef PART_SURF_FACET_TOOL_HPP
00016 #define PART_SURF_FACET_TOOL_HPP
00017 
00018 #include <set>
00019 #include <DLIList.hpp>
00020 
00021 class CubitVector;
00022 class Curve;
00023 
00024 class PartitionSurface;
00025 class PartitionCurve;
00026 class PartitionPoint;
00027 
00028 class CubitFacet;
00029 class CubitFacetEdge;
00030 class CubitPoint;
00031 
00032 class CubitFacetData;
00033 class CubitFacetEdgeData;
00034 class CubitPointData;
00035 
00036 class PartSurfFacetTool
00037 {
00038   
00039 public:
00040   
00043   PartSurfFacetTool(PartitionSurface* surface);
00044 
00045   CubitStatus init_facet_data( DLIList<CubitFacetData*>& facets );
00046   
00048   static void validate_facets(PartitionSurface* surf);
00049 
00054   static CubitStatus split_edge( CubitFacetEdge*    edge_to_split,
00055                                  const CubitVector& split_location,
00056                                  CubitFacet*        edge_facet,
00057                                  CubitPoint*&       new_split_point,
00058                                  CubitFacetEdge*&   new_edge,
00059                                  CubitFacet*&       new_facet );
00060   //- Split a facet edge and any adjacent facets.
00061   //I edge_to_split
00062   //I- The edge to split
00063   //I split_location
00064   //I- The location at which to split the edge
00065   //I edge_facet 
00066   //I- Optional argument - facet adjacent to edge
00067   //O new_split_point
00068   //O- The new point splitting the edge
00069   //O new_Edge
00070   //O- The new edge (from new_split_point to the original end point)
00071   //O new_facet
00072   //O- If edge_facet is not NULL, the new facet resulting from
00073   //O- splitting edge_facet.
00074                
00075                                  
00076   static CubitStatus collapse_edge( CubitPoint* keep_point,
00077                                     CubitPoint* dead_point,
00078                                     DLIList<CubitFacetData*>* unowned = 0 );
00079   //- Combine the two passed points, removing the edge connecting
00080   //- them and collapsing any facets adjacent to that edge.
00081 
00082   static CubitFacet* closest_facet( const CubitVector& input_position,
00083                                     const DLIList<CubitFacetData*>& facets,
00084                                     CubitVector& result_position );
00085   //- Find the facet and point on that facet closest to the passed position.
00086   //R CubitFacet*
00087   //R- The closest facet
00088   //I input_position
00089   //I- The location to test
00090   //O facets
00091   //O- The set of facets to test
00092   //O result_position
00093   //O- The closest position on the returned facet.
00094   
00095 
00096   static CubitStatus seam_curve( DLIList<CubitFacetEdgeData*>& new_edge_list,
00097                                  PartitionCurve *curve,
00098                                  DLIList <CubitFacetData*> &adjacent_facets,
00099                                  DLIList <CubitFacetEdgeData*>* dead_edge_ptrs = 0 );
00100   //- Given two lists of facet edges, the passed one and the one associated
00101   //- with the passed curve, split and merge edges to seam the two lists
00102   //- together.
00103   //I new_edge_list
00104   //I- The list of edges to seam
00105   //I curve
00106   //I- The curve who's edges are to be seamed with the input list.
00107   //I adjacent_facets
00108   //I- The list of un-owned facets which may need to be modified during
00109   //I- this operation.  For any owned facets, the owning PartitionSurface
00110   //I- will be updated appropriately.  For any un-owned facets, this list
00111   //I- will be updated. 
00112 
00113   static CubitPoint* split_edge_closest( CubitFacetEdgeData* edge,
00114                                          const CubitVector& pos,
00115                                          double tolerance,
00116                                          CubitFacetEdgeData*& new_edge,
00117                                          DLIList<CubitFacetData*>& new_facets );
00118   //- If the input position is sufficiently close to the end of the passed
00119   //- edge, return the corresponding end point of the edge.  Otherwise
00120   //- split the edge and any adjacent facets.
00121   //-
00122   //- Effects:  For each adjacent facet that is split, if the facet has
00123   //-           an owning PartitionSurface, the owning surface will be
00124   //-           updated for the facet split.  OTHERWISE the new facet
00125   //-           will be appended to new_facets.
00126   //-
00127   //- Notes:    The edge is always split such that the original edge
00128   //-           is between the original start point and the new point
00129   //-           and the new edge contains the new point and the 
00130   //-           original end point.
00131   //-
00132   //R CubitPoint*
00133   //R- The new point used to split the edge, or the closest edge end
00134   //R- point if the edge was not split.
00135   //I edge
00136   //I- The edge to split
00137   //I pos
00138   //I- The location at which to split the edge
00139   //O new_edge
00140   //O- The new edge, or NULL if the edge was not split.
00141   //O new_facets
00142   //O- New facets created by splitting un-owned facets adjacent to 
00143   //O- the input edge.
00144   
00145   static CubitStatus fix_move_point( CubitPoint* point,
00146                                      const CubitVector& new_pos,
00147                                      const DLIList<CubitFacetData*>& facets,
00148                                      DLIList<CubitFacetData*>& old_facets,
00149                                      DLIList<CubitFacetData*>& new_facets,
00150                                      PartitionSurface* owning_surf = 0 );
00151   //- Given a patch of facets, a point on the perimeter of that patch
00152   //- of facets and a new position for that point, check if any re-facetting
00153   //- is required keep from inverting facets, and if so refacet.
00154   //I point
00155   //I- The point to move
00156   //I new_pos
00157   //I- The desired new position for the point
00158   //I facets
00159   //I- The patch of facets
00160   //O old_facets
00161   //O- Facets removed during refacetting.
00162   //O new_facets
00163   //O- New facets created during refacetting.
00164   //I owning_surf
00165   //I- Optional argument.  If specified, function assumes that all
00166   //I- facets in passed list are owned by this surface.  Uses facet
00167   //I- owner rather than list search to see if facet is in list.
00168   
00169 
00170   
00171   static CubitStatus get_facet_points_and_edges( 
00172                          const DLIList<CubitFacetData*>& facets,
00173                          DLIList<CubitPoint*>& boundary_points,
00174                          DLIList<CubitPoint*>& interior_points,
00175                          DLIList<CubitFacetEdge*>& boundary_edges,
00176                          DLIList<CubitFacetEdge*>& interior_edges );
00177   //- Given a patch of facets, get all points and edges classified
00178   //- as either boundary or interior.
00179 
00180 
00181 private:
00182  
00183   static void edge_facets( CubitFacetEdge* edge,
00184                            const DLIList<CubitFacet*>& input_facets,
00185                            DLIList<CubitFacet*>& output_list );
00186   
00187   static void edge_facets( PartitionSurface* surface,
00188                            CubitFacetEdge* edge, 
00189                            DLIList<CubitFacet*>& facets );
00190 
00193   static void closest_pt_on_facet( CubitFacet* facet,
00194                                    const CubitVector& input_position,
00195                                    CubitVector& result_position );
00196 
00197   
00198   CubitStatus seam_curves( DLIList<PartitionCurve*>& curve_list,
00199                            DLIList<CubitFacetEdge*>& edge_list,
00200                            DLIList<CubitFacetData*>& adjacent_facets );
00201   //- Do seam_curve for the set of all partitions of a real curve.
00202   
00203   static CubitStatus associate_points( DLIList<CubitPoint*>& facet_points,
00204                                        DLIList<PartitionPoint*>& geom_points );
00205   //- For each pointin geom_points, find closest point in facet_points
00206   //- and attach that facet point to the geometric point.  If the geometric
00207   //- point already has an attached facet point, the facet points are merged
00208   //- such that the point from facet_points is destroyed during the merge.
00209   
00210   static Curve* get_real_curve( DLIList<PartitionCurve*>& curve_list,
00211                                 PartitionPoint*& start_point,
00212                                 PartitionPoint*& end_point );
00213   //- Verify that the passed set of curves are exactly the set of
00214   //- partitions of a single real curve.  Return the real curve and
00215   //- the PartitionPoints corresponding to the start and end of the
00216   //- real curve.
00217   
00218   CubitStatus get_boundary_chain( CubitPoint* start_point,
00219                                          CubitFacetEdge* start_edge,
00220                                          CubitPoint* end_point,
00221                                          DLIList<CubitFacetEdge*>& result );
00222   //- Helper function for init_facet_data().
00223   //- NOTE: expects marks on facet edges to be set by init_facet_data.().
00224   //-
00225   //- Given an edge and a point on that edge, find the chain of
00226   //- boundary edges beginning with the edge and ending at the passesd
00227   //- end point
00228   //- Assumes:  all boundary edges marked with a '1'.
00229   //-           chain of edges may not cross a vertex with more than
00230   //-            two adjacent boundaryt edges.
00231   //-           chain of edges may not corss a vertex owned by a 
00232   //-            partition point.
00233   
00234   CubitStatus seam_nonmanifold_curves( DLIList<PartitionCurve*>& partitions,
00235                                        DLIList<CubitFacetData*>& facet_list );
00236   //- Helper function for init_facet_data()
00237   //- Associate facet edges in the interior of the passed facet patch
00238   //- with the passed list of partitions of a real, non-manifold curve.
00239   //- NOTE: Assumes edges internal to the facet list have been marked
00240   //-       with a '2' by the caller.
00241 
00242 
00243   std::set<CubitFacetEdge*> boundary_set, interior_set;
00244   PartitionSurface *const mySurface;
00245 };
00246 
00247 inline PartSurfFacetTool::PartSurfFacetTool(PartitionSurface* surface)
00248   : mySurface(surface) {}
00249 
00250 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines