cgma
|
00001 #ifndef COMPOSITE_TOOL_HPP 00002 #define COMPOSITE_TOOL_HPP 00003 00004 #include "CubitDefines.h" 00005 #include "BasicTopologyEntity.hpp" 00006 #include "GeometryEntity.hpp" 00007 00008 #include "CompositeSurface.hpp" 00009 #include "CompositeCurve.hpp" 00010 #include "CompositePoint.hpp" 00011 00012 class RefEdge; 00013 class RefFace; 00014 class RefEdge; 00015 class RefFace; 00016 template <class X> class DLIList; 00017 class Loop; 00018 00019 class CompositeTool 00020 { 00021 friend class PartitionTool; 00022 public: 00023 00024 static CompositeTool* instance(); 00025 00026 virtual ~CompositeTool(); 00027 00028 virtual RefEdge* composite( DLIList<RefEdge*>& list, 00029 RefVertex* keep_vertex = NULL, 00030 RefEdge* survivor = NULL ); 00031 virtual RefFace* composite( DLIList<RefFace*>& list, 00032 RefFace* survivor = NULL ); 00033 virtual RefVolume* composite( DLIList<RefVolume*>& list, 00034 Body** composite_body = 0 ); 00035 virtual Body* composite( DLIList<Body*>& list ); 00036 //R- the composite, or NULL if error 00037 //I list 00038 //I- The list of entities to composite 00039 //I keep_vertex 00040 //I- vertex to keep if list forms a closed loop of curves 00041 //I composite_body 00042 //I- If non-null, a composite body will be created if necessary, 00043 //I- and composite_body will be set to point to the new body. 00044 //- create a composite 00045 //- 00046 //- NOTE: The 'survivor' argument is provided to meet 00047 //- special requirenments in supporting pre-version-8 save 00048 //- files. Once support for pre-version-8 save files has 00049 //- been dropped, this argument will be removed. 00050 00051 00052 00053 virtual CubitStatus uncomposite( RefEdge* composite_edge, 00054 DLIList<RefEdge*>* restored_edges = NULL ); 00055 virtual CubitStatus uncomposite( RefFace* composite_face, 00056 DLIList<RefFace*>* restored_faces = NULL, 00057 bool force_unmerge = false ); 00058 virtual CubitStatus uncomposite( RefVolume* composite_vol, 00059 DLIList<RefVolume*>* restored_vols = NULL ); 00060 virtual CubitStatus uncomposite( Body* composite_body, 00061 DLIList<Body*>* restored_bodies = NULL ); 00062 //Remove a composite entity. 00063 00064 CubitBoolean isComposite( const BasicTopologyEntity* bte_ptr ) const; 00065 CubitBoolean isComposite( const GeometryEntity* ge_ptr ) const; 00066 00067 CubitStatus composite( DLIList<RefEdge*>& edges_to_composite, 00068 DLIList<RefEdge*>& new_edge_list, 00069 DLIList<RefVertex*>* vertices_to_keep = NULL, 00070 double max_angle = 3.15 ); 00071 //R CubitStatus 00072 //I edges_to_composite 00073 //I- The list of RefEdges to composite. 00074 //O new_edge_list 00075 //O- The list of Composite RefEdges created. 00076 //I vertices_to_keep 00077 //I- If this list is passed, no composites will be created which 00078 //I- would result in the removal of any of these vertices. Or 00079 //I- if the curves to be composited form a closed loop, this may 00080 //I- be used to specify which vertex is kept. 00081 //I max_angle 00082 //I- The maximum angle between tangents at the point of intersection 00083 //I- for which curves can be composited. The default value (3.15) will 00084 //I- result in all possible curves being composited. A value of 0.0 00085 //I- will result in only C1-continous curves being composited. 00086 //- Create all possible composites from the passed list of RefEdges, 00087 //- within the constraints of topological validity, the list of 00088 //- vertices to keep, and the specified angle. 00089 00090 CubitStatus composite( DLIList<RefFace*>& faces_to_composite, 00091 DLIList<RefFace*>& result_faces, 00092 double max_angle = 4.0 /*radians*/); 00093 //R CubitStatus 00094 //R- CUBIT_SUCCESS/CUBIT_FAILURE 00095 //I facets_to_composite 00096 //I- A list of RefFaces to create composites from. 00097 //O result_facets 00098 //O- The resulting composite surfaces. 00099 //I max_angle 00100 //I- The largest angle between surfaces to composite over. 00101 //- Create all possible composites from the passed list of RefFaces, 00102 //- within the constraints of toopologal validity, and the 00103 //- specified angle. 00104 00105 00106 RefFace* composite( DLIList<RefFace*>& faces_to_composite, 00107 DLIList<RefEdge*>& result_edges, 00108 DLIList<RefVertex*>* vertices_to_keep = NULL, 00109 double max_vertex_angle = 0.26 /*radians*/ ); 00110 //R RefFace* 00111 //R- The resulting composite, or NULL if an error was encountered. 00112 //I faces_to_composite 00113 //I- The list of connected surfaces to composite. 00114 //O result_edges 00115 //O- The list of curves composited with the surface. 00116 //I vertices_to_keep 00117 //I- The list of vertices that should not be composited over when 00118 //I- creating composite curves. 00119 //I max_vertex_angle 00120 //I- The maximum angle between curves at their common vertex, for 00121 //I- which the vertex can be composited over. 00122 //- Create a single composite surface, and as many composite curves 00123 //- as possible on the boundary of that surface. 00124 00125 CubitStatus composite( DLIList<RefFace*>& faces_to_composite, 00126 DLIList<RefFace*>& result_faces, 00127 DLIList<RefEdge*>& result_edges, 00128 double max_curve_angle = 2.0 /*radians*/, 00129 DLIList<RefVertex*>* vertices_to_keep = NULL, 00130 double max_vtx_angle = 0.26 /*radians*/ ); 00131 //R CubitStatus 00132 //R- CUBIT_SUCCESS/CUBIT_FAILURE 00133 //I facets_to_composite 00134 //I- The list of surfaces to create composites from. 00135 //O result_faces 00136 //O- The composite surfaces created. 00137 //O result_edges 00138 //O- The composite curves created. 00139 //I max_curve_angle 00140 //I- The largest angle between surfaces (at a curve) that can 00141 //I- be composited over. 00142 //I vertices_to_keep 00143 //I- The list of vertices that should not be composited over 00144 //I- when creating composite curves. 00145 //I max_vtx_angle 00146 //I- The largest angle between curves (at a vertex) that can 00147 //I- be composited over. 00148 //- Create composite surfaces and curves. 00149 00150 00151 CubitBoolean okayToComposite( DLIList<BasicTopologyEntity*>& bte_list, 00152 DLIList<BasicTopologyEntity*>* boundary = NULL, 00153 DLIList<BasicTopologyEntity*>* internal = NULL, 00154 bool print_errors = true, 00155 bool force_same_parent = false ) const; 00156 //This function is public because it is also used in PartitionTool, 00157 //and because it is only a series of queries anyway. 00158 00159 static CubitStatus classify_children( DLIList<BasicTopologyEntity*>& bte_list, 00160 DLIList<BasicTopologyEntity*>& boundary_children, 00161 DLIList<BasicTopologyEntity*>& internal_children, 00162 DLIList<BasicTopologyEntity*>& unknown_children ); 00163 00164 RefEdge* remove_vertex( RefVertex* vertex, 00165 bool remove_partitions = false, 00166 bool update_dag = true, 00167 RefEdge* survivor = NULL ); 00168 RefFace* remove_edge( RefEdge* edge, 00169 bool remove_partitions = false, 00170 bool update_dag = true, 00171 RefFace* survivor = NULL ); 00172 00173 RefVolume* remove_face( RefFace* face, 00174 bool remove_partitions = false, 00175 bool update_dag = true ); 00176 00177 protected: 00178 00179 // These functions do nothing as implemented in CompositeTool. 00180 // They are provided for CompositeToolMesh to overload with 00181 // mesh-handling code. 00182 virtual CubitStatus update_combined_vols( RefVolume* keep, RefVolume* dead ); 00183 virtual CubitStatus update_combined_faces( RefFace* keep, RefEdge* dead, RefFace* delete_face ); 00184 virtual CubitStatus update_combined_edges( RefEdge* keep, RefEdge* dead,int keep_interval,double keep_size,FirmnessType keep_interval_type,SizeIntervalType keep_size_type); 00185 virtual CubitStatus determine_combined_edges_interval_or_size( RefEdge* edge_1, RefEdge* edge_2,int& result_interval,double& result_size,FirmnessType& interval_keep_type,SizeIntervalType& size_keep_type); 00186 00187 CompositeTool(); 00188 00189 //CubitStatus make_mergeable( GeometryEntity* bridge1, GeometryEntity* bridge2 ); 00190 00191 CubitStatus removeOldTopology( BasicTopologyEntity* composite ); 00192 00193 CubitVector tangent( RefEdge* edge_ptr, RefVertex* vtx_ptr ) const; 00194 //R CubitVector 00195 //R- The tangent vector 00196 //I edge_ptr 00197 //I- The RefEdge to get the tangent of. 00198 //I vtx_ptr 00199 //I- The RefVertex to get the tangent at. 00200 //- Return the tangent of the passed RefEdge at the location of 00201 //- the passed RefVertex. The tanget is reversed if the passed 00202 //- RefVertex is the end vertex of the RefEdge, such that the 00203 //- resulting tangent vector points along the edge away from the 00204 //- vertex. 00205 00206 00207 CubitStatus fast_edge_sort( DLIList<RefEdge*>& edge_list, 00208 bool valence2_vertices ) const; 00209 //R CubitStatus 00210 //R- CUBIT_SUCCESS if all edges form a single chain. 00211 //R- CUBIT_FAILURE otherwise 00212 //I edge_list 00213 //I- The list of edges to sort 00214 //O edge_list 00215 //O- The sorted list of edges 00216 //- This function sorts edges by common vertices. The result 00217 //- will be several consecutive sorted sets of edges, if all 00218 //- edges do not form a single chain. 00219 00220 00221 CubitStatus restore_merged_point( TBPoint* point, 00222 DLIList<RefFace*>& update, 00223 bool force = false ); 00224 00225 CubitStatus stitch_points( TBPoint* pt1, TBPoint* pt2 ); 00226 CubitStatus stitch_curves( Curve* cv1, Curve* cv2 ); 00227 00228 static CompositeTool* instance_; 00229 00230 private: 00231 00232 }; 00233 00234 inline CompositeTool* CompositeTool::instance() 00235 { 00236 return (instance_ != NULL ) ? instance_ : instance_ = new CompositeTool(); 00237 } 00238 00239 inline CubitBoolean CompositeTool:: 00240 isComposite( const GeometryEntity* ge_ptr ) const 00241 { 00242 if( dynamic_cast<const CompositeSurface*>(ge_ptr) || 00243 dynamic_cast<const CompositeCurve*>(ge_ptr) || 00244 dynamic_cast<const CompositePoint*>(ge_ptr) ) 00245 return CUBIT_TRUE; 00246 return CUBIT_FALSE; 00247 } 00248 00249 inline CubitBoolean CompositeTool:: 00250 isComposite( const BasicTopologyEntity* bte_ptr ) const 00251 { 00252 return bte_ptr ? isComposite(bte_ptr->get_geometry_entity_ptr()) : CUBIT_FALSE; 00253 } 00254 00255 00256 #endif