cgma
FacetCurve.cpp
Go to the documentation of this file.
00001 //-------------------------------------------------------------------------
00002 // Filename      : FacetCurve.cpp
00003 //
00004 // Purpose       : 
00005 //
00006 // Special Notes :
00007 //
00008 // Creator       : Steven J. Owen
00009 //
00010 // Creation Date : 07/14/00
00011 //
00012 // Owner         : Steven J. Owen
00013 //-------------------------------------------------------------------------
00014 
00015 // ********** BEGIN STANDARD INCLUDES      **********
00016 
00017 // ********** END STANDARD INCLUDES        **********
00018 
00019 // ********** BEGIN CUBIT INCLUDES         **********
00020 
00021 #include "CastTo.hpp"
00022 #include "CubitVector.hpp"
00023 #include "CubitBox.hpp"
00024 #include "GeometryDefines.h"
00025 #include "FacetCurve.hpp"
00026 #include "FacetAttrib.hpp"
00027 #include "FacetEvalTool.hpp"
00028 #include "CurveFacetEvalTool.hpp"
00029 #include "GeometryQueryEngine.hpp"
00030 #include "FacetQueryEngine.hpp"
00031 #include "CoEdgeSM.hpp"
00032 #include "CubitPoint.hpp"
00033 
00034 #include "FacetBody.hpp"
00035 #include "FacetLump.hpp"
00036 #include "FacetShell.hpp"
00037 #include "FacetSurface.hpp"
00038 #include "FacetLoop.hpp"
00039 #include "FacetCoEdge.hpp"
00040 #include "FacetPoint.hpp"
00041 
00042 // ********** END CUBIT INCLUDES           **********
00043 
00044 // ********** BEGIN FORWARD DECLARATIONS   **********
00045 // ********** END FORWARD DECLARATIONS     **********
00046 
00047 // ********** BEGIN STATIC DECLARATIONS    **********
00048 // ********** END STATIC DECLARATIONS      **********
00049 
00050 // ********** BEGIN PUBLIC FUNCTIONS       **********
00051 
00052 //-------------------------------------------------------------------------
00053 // Purpose       : The default constructor
00054 //
00055 // Special Notes :
00056 //
00057 // Creator:      : Steve Owen
00058 //
00059 // Creation Date : 07/14/00
00060 //-------------------------------------------------------------------------
00061 FacetCurve::FacetCurve(CurveFacetEvalTool *curve_facet_tool,
00062                        TBPoint *start_ptr, TBPoint *end_ptr,
00063                        DLIList<CoEdgeSM*> &coedge_list )
00064                        : sense_(CUBIT_FORWARD)
00065 {
00066   static int counter = 0;
00067   myId = counter++;
00068     // Calculate a bounding box if there isn't one already
00069   curveFacetEvalTool = curve_facet_tool; 
00070   myStartPoint = start_ptr;
00071   myEndPoint = end_ptr;
00072   myCoEdges += coedge_list;
00073   periodic = start_ptr == end_ptr;
00074 }
00075 
00076 //-------------------------------------------------------------------------
00077 // Purpose       : Another constructor
00078 //
00079 // Special Notes : Implemented for save/restore
00080 //
00081 // Creator:      : Corey Ernst 
00082 //
00083 // Creation Date : 02/03/03
00084 //-------------------------------------------------------------------------
00085 FacetCurve::FacetCurve(CurveFacetEvalTool *curve_facet_tool,
00086                        TBPoint *start_ptr, TBPoint *end_ptr,
00087                        CubitSense sense )
00088 {
00089   static int counter = 0;
00090   myId = counter++;
00091     // Calculate a bounding box if there isn't one already
00092   curveFacetEvalTool = curve_facet_tool; 
00093   myStartPoint = start_ptr;
00094   myEndPoint = end_ptr;
00095   periodic = start_ptr == end_ptr;
00096   sense_ = sense;
00097 }
00098 //-------------------------------------------------------------------------
00099 // Purpose       : The destructor. 
00100 //
00101 // Special Notes :
00102 //
00103 // Creator       : Steve Owen
00104 //
00105 // Creation Date : 07/14/00
00106 //-------------------------------------------------------------------------
00107 FacetCurve::~FacetCurve() 
00108 {
00109     if(this->curveFacetEvalTool)
00110         delete this->curveFacetEvalTool;
00111   
00112 }
00113 
00114 //-------------------------------------------------------------------------
00115 // Purpose       : The purpose of this function is to append a
00116 //                 attribute to the GE. The name is attached to the 
00117 //                 underlying solid model entity this one points to.
00118 //
00119 //
00120 // Special Notes : 
00121 //
00122 // Creator       : Steve Owen
00123 //
00124 // Creation Date : 07/14/00
00125 //-------------------------------------------------------------------------
00126 void FacetCurve::append_simple_attribute_virt(const CubitSimpleAttrib &csa)
00127   { attribSet.append_attribute(csa); }
00128 
00129 //-------------------------------------------------------------------------
00130 // Purpose       : The purpose of this function is to remove a simple 
00131 //                 attribute attached to this geometry entity. The name is 
00132 //                 removed from the underlying BODY this points to.
00133 //
00134 // Special Notes : 
00135 //
00136 // Creator       : Steve Owen
00137 //
00138 // Creation Date : 07/14/00
00139 //-------------------------------------------------------------------------
00140 void FacetCurve::remove_simple_attribute_virt(const CubitSimpleAttrib &csa)
00141   { attribSet.remove_attribute(csa); }
00142 
00143 //-------------------------------------------------------------------------
00144 // Purpose       : The purpose of this function is to remove all simple 
00145 //                 attributes attached to this geometry entity.  Also
00146 //                 removes lingering GTC attributes.
00147 //
00148 //
00149 // Special Notes : 
00150 //
00151 // Creator       : Steve Owen
00152 //
00153 // Creation Date : 07/14/00
00154 //-------------------------------------------------------------------------
00155 void FacetCurve::remove_all_simple_attribute_virt()
00156   { attribSet.remove_all_attributes(); }
00157 
00158 //-------------------------------------------------------------------------
00159 // Purpose       : The purpose of this function is to get the  
00160 //                 attributes attached to this geometry entity. The name is 
00161 //                 attached to the underlying BODY this points to.
00162 //
00163 // Special Notes : 
00164 //
00165 // Creator       : Steve Owen
00166 //
00167 // Creation Date : 07/14/00
00168 //-------------------------------------------------------------------------
00169 CubitStatus FacetCurve::get_simple_attribute(DLIList<CubitSimpleAttrib>&
00170                                                csa_list)
00171   { return attribSet.get_attributes(csa_list); }
00172   
00173 CubitStatus FacetCurve::get_simple_attribute( const CubitString& name,
00174                                       DLIList<CubitSimpleAttrib>& csa_list)
00175   { return attribSet.get_attributes( name, csa_list ); }
00176 
00177 
00178 CubitStatus FacetCurve::save_attribs( FILE *file_ptr )
00179   { return attribSet.save_attributes(file_ptr); }
00180 
00181 CubitStatus FacetCurve::restore_attribs( FILE *file_ptr, unsigned int endian )
00182   { return attribSet.restore_attributes(file_ptr, endian); }
00183 
00184 
00185 
00186 //-------------------------------------------------------------------------
00187 // Purpose       : Get geometry modeling engine: FacetQueryEngine
00188 //
00189 // Special Notes :
00190 //
00191 // Creator       : Steve Owen
00192 //
00193 // Creation Date : 07/14/00
00194 //-------------------------------------------------------------------------
00195 GeometryQueryEngine* FacetCurve::get_geometry_query_engine() const
00196 {
00197   return FacetQueryEngine::instance();
00198 }                 
00199 
00200 //-------------------------------------------------------------------------
00201 // Purpose       : Get the bounding box of the object.
00202 //
00203 // Special Notes :
00204 //
00205 // Creator       : Steve Owen
00206 //
00207 // Creation Date : 10/23/96
00208 //-------------------------------------------------------------------------
00209 CubitBox FacetCurve::bounding_box() const 
00210 {
00211   return curveFacetEvalTool->bounding_box();
00212 }
00213 
00214 
00215 //-------------------------------------------------------------------------
00216 // Purpose       : Return the length of the curve.
00217 //
00218 // Special Notes :
00219 //
00220 // Creator       : Steve Owen
00221 //
00222 // Creation Date : 07/14/00
00223 //-------------------------------------------------------------------------
00224 double FacetCurve::measure()
00225 {
00226   return curveFacetEvalTool->length();
00227 }
00228 
00229 //-------------------------------------------------------------------------
00230 // Purpose       : Return the arc length along the Curve starting from
00231 //                 the point represented by the parameter1 going to the 
00232 //                 point represented by parameter2.
00233 //
00234 // Special Notes : Parameter1 and parameter2 are with respect to the EDGE.
00235 //
00236 // Creator       : Steve Owen
00237 //
00238 // Creation Date : 07/14/00
00239 //-------------------------------------------------------------------------
00240 double FacetCurve::length_from_u( double parameter1, double parameter2 )
00241 {
00242 
00243     //Don't perform the periodic adjustment so that
00244     // this function will satisfy the properties of
00245     // the function as defined in RefEdge.hpp.
00246     // Also, take the fabs of the arc length for the same reason.
00247   //if( periodic )
00248   //{
00249   //  adjust_periodic_parameter( parameter1 );
00250   //  adjust_periodic_parameter( parameter2 );
00251   //}
00252   return curveFacetEvalTool->length_from_u( parameter1, parameter2 );
00253 }
00254 
00255 //-------------------------------------------------------------------------
00256 // Purpose       : Returns CUBIT_TRUE and the associated period value. Not
00257 //                 implemented yet
00258 //
00259 // Special Notes :  
00260 //
00261 // Creator       : Steve Owen
00262 //
00263 // Creation Date : 07/14/00
00264 //-------------------------------------------------------------------------
00265 CubitBoolean FacetCurve::is_periodic(double& period)
00266 {
00267   if( periodic )
00268   {
00269     period = 1.0;
00270     return CUBIT_TRUE;
00271   }
00272   return CUBIT_FALSE;
00273 }
00274 
00275 //------------------------------------------------------------------
00276 // Purpose: Returns CUBIT_TRUE and the associated parametric values, 
00277 //          if the facet curve associated with the first EDGE is 
00278 //          parametric.
00279 //          Otherwise returns CUBIT_FALSE and the values of 
00280 //          the lower and upper parametric bounds are undetermined.
00281 //          NOT IMPLEMENTED YET
00282 //
00283 // Creator       : Steve Owen
00284 //
00285 // Creation Date : 07/14/00
00286 //-------------------------------------------------------------------
00287 CubitBoolean FacetCurve::get_param_range( double& lower_bound,
00288                                           double& upper_bound )
00289 {
00290   lower_bound = 0.0;
00291   upper_bound = 1.0;
00292   return CUBIT_TRUE;
00293 }
00294 
00295 //------------------------------------------------------------------
00296 // Purpose:        Finds the extrema along this Curve. 
00297 //
00298 // Special Notes : It is the responsibility of the
00299 //                 calling code to delete the CubitVectors added to 
00300 //                 interior_points!
00301 //
00302 // Creator       : Jason Kraftcheck
00303 //
00304 // Creation Date : 05/29/01
00305 //-------------------------------------------------------------------
00306 CubitStatus FacetCurve::get_interior_extrema(
00307   DLIList<CubitVector*>& interior_points,
00308   CubitSense& return_sense )
00309 {
00310   // Need curveFacetEvalTool to get point list
00311   if( ! curveFacetEvalTool ) 
00312     return CUBIT_FAILURE;
00313   
00314   // Get list of points defining this curve
00315   DLIList<CubitPoint*> point_list;
00316   get_points( point_list );
00317   
00318   // If there are only 2 points, then the curve is a line and there
00319   // are no interior extrema
00320   if( point_list.size() < 3 )
00321     return CUBIT_SUCCESS;
00322   
00323   // Return sense is whatever the sense of this curve is.
00324   return_sense = sense_;
00325   
00326   // Get a vector between the first two points
00327   point_list.reset();
00328   CubitVector prev_pt = point_list.get_and_step()->coordinates();
00329   CubitVector curr_pt = point_list.get_and_step()->coordinates();
00330   CubitVector prev_vct = curr_pt - prev_pt;
00331   CubitVector next_vct;
00332   
00333   for( int i = point_list.size(); i > 2; i-- )
00334   {
00335     // Get a vector between the next two points
00336     next_vct = point_list.get()->coordinates() - curr_pt;
00337     
00338     // In Curve::get_interior_extrema, the extrema seem to
00339     // be evaluated with respect to the principle axes, so do
00340     // the same here.  The extrema are points at which the
00341     // derivitive in the specified direction (principle axis)
00342     // is zero.  So look for a sign change in the slope across
00343     // a point wrt each principle direction.
00344     if( (prev_vct.x() * next_vct.x() < 0.) ||  // x extrema
00345         (prev_vct.y() * next_vct.y() < 0.) ||  // y extrema
00346         (prev_vct.z() * next_vct.z() < 0.)  )  // z extrema
00347       interior_points.append( new CubitVector( curr_pt ) );
00348     
00349     // Advance to next point.
00350     prev_vct = next_vct;
00351     curr_pt = point_list.get_and_step()->coordinates();
00352   }
00353   
00354   return CUBIT_SUCCESS;
00355 }
00356 
00357 //-------------------------------------------------------------------------
00358 // Purpose       : This function computes the point on the curve closest 
00359 //                 to the input location.  Optionally, it can also compute
00360 //                 the tangent and curvature on the Curve at the point on
00361 //                 on the Curve closest to the input location.
00362 //
00363 // Special Notes : The tangent direction is always in the positive direction of the 
00364 //                 owning RefEdge, regardless of the positive direction of the
00365 //                 underlying solid model entities.
00366 //
00367 //                 If the calling code needs the tangent and/or the curvature,
00368 //                 it is responsible for allocating the memory for these
00369 //                 CubitVector(s) and sending in the relevant non-NULL
00370 //                 pointers to this routine.
00371 //
00372 // Creator       : Steve Owen
00373 //
00374 // Creation Date : 07/14/00
00375 //-------------------------------------------------------------------------
00376 CubitStatus FacetCurve::closest_point( 
00377   CubitVector const& location, 
00378   CubitVector& closest_location,
00379   CubitVector* tangent_ptr,
00380   CubitVector* curvature_ptr,
00381   double* param)
00382 {  
00383     // Only the closest point is required
00384   if (tangent_ptr == NULL && curvature_ptr == NULL)
00385   {
00386     CubitVector temp = location;
00387     curveFacetEvalTool->closest_point( temp,
00388                                        closest_location, NULL, NULL, param );
00389   }
00390   
00391     // The closest point and the tangent are required
00392   else if (tangent_ptr != NULL && curvature_ptr == NULL)
00393   {
00394     CubitVector temp = location;
00395     curveFacetEvalTool->closest_point( temp, closest_location, tangent_ptr, NULL, param );
00396   }
00397   
00398     // Everything is required
00399     // NOTE: If the curvature is required but not the tangent, the tangent,
00400     //       too, will be computed.
00401   else
00402   {
00403     CubitVector temp = location;
00404     curveFacetEvalTool->closest_point( temp, closest_location, tangent_ptr, curvature_ptr, param );
00405   }
00406   
00407   if (tangent_ptr != NULL)
00408   {
00409     if (sense_ == CUBIT_REVERSED)
00410       *tangent_ptr = -(*tangent_ptr);
00411   }
00412   
00413     // Set the curvature, if necessary
00414   if (curvature_ptr != NULL)
00415   {
00416       // get the sense wrt the  curve, consists of 2 sense values
00417     if (sense_ == CUBIT_REVERSED)
00418       *curvature_ptr = -(*curvature_ptr);
00419   }
00420   
00421   if (param != NULL)
00422   {
00423     adjust_periodic_parameter(*param);
00424   }
00425   
00426   return CUBIT_SUCCESS;
00427 }
00428 
00429 
00430 //------------------------------------------------------------------
00431 // Purpose: This function returns the coordinate of a point in the local
00432 //          parametric (u) space that corresponds to the input position 
00433 //          in global (world) space.  The input point is first moved to 
00434 //          the closest point on the Curve and the parameter value of 
00435 //          that point is determined. 
00436 //
00437 // Creator       : Steve Owen
00438 //
00439 // Creation Date : 07/14/00
00440 //-------------------------------------------------------------------
00441 CubitStatus FacetCurve::position_from_u (double u_value,
00442                                         CubitVector& output_position)
00443 {
00444   
00445   CubitStatus status = CUBIT_SUCCESS;
00446   
00447     // Get the parameter range of this Curve
00448   double lower_bound, upper_bound;
00449   this->get_param_range( lower_bound, upper_bound );
00450   double param_interval = upper_bound - lower_bound;
00451   
00452     // Make sure the requested u_value is either within the range or, if
00453     // the Curve is periodic, then reduce the input value down to the
00454     // fundamental range
00455   if (u_value > upper_bound || u_value < lower_bound)
00456   {
00457     adjust_periodic_parameter(u_value);
00458   }
00459   
00460     // Now that we have a "valid" parameter value, get its global location
00461     // on the Curve
00462   
00463     // Now we assume that the u_value is with respect to the
00464     // EDGE, we must switch it according the the EDGE->curve sense.
00465   
00466   if (sense_ == CUBIT_REVERSED)
00467   {
00468     u_value = -(u_value);
00469   }
00470     //now the u_value is with respect to curve so we are safe in
00471     //passing this parameter for evaluation on the curve.
00472 
00473   double fraction = (u_value - lower_bound) / param_interval;
00474   status = curveFacetEvalTool->position_from_fraction( fraction, output_position );
00475 
00476   return status;
00477 }
00478 
00479 //-------------------------------------------------------------------------
00480 // Purpose       : This function returns the coordinate of a point in the local
00481 //                 parametric (u) space that corresponds to the input position 
00482 //                 in global (world) space.  The input point is first moved to 
00483 //                 the closest point on the Curve and the parameter value of 
00484 //                 that point is determined. 
00485 //
00486 // Special Notes : 
00487 //
00488 // Creator       : Malcolm J. Panthaki
00489 //
00490 // Creation Date : 2/25/97
00491 //-------------------------------------------------------------------------
00492 double FacetCurve::u_from_position (const CubitVector& input_position)
00493 {
00494     // Get the closest point on the Curve to the input position
00495   CubitVector closest_point;
00496   double u_val;
00497   this->closest_point(input_position, closest_point,
00498                       NULL, NULL, &u_val);
00499     // closest_point already makes adjustments for sense and periodicity
00500   
00501   return u_val;
00502 }
00503 
00504 //------------------------------------------------------------------
00505 // Purpose: This function returns the parameter value of the point 
00506 //          that is "arc_length" away from the root point, in the
00507 //          positive sense direction of the owning RefEdge.
00508 //
00509 // Special Notes : 
00510 //   If arc_length is negative, the new point (whose parameter value
00511 //   is being computed) is in the negative sense direction (along
00512 //   the RefEdge) from the root point (whose parameter value is
00513 //   root_param).
00514 //
00515 //   If the curve is not periodic and the new point, "arc_length"
00516 //   away from the root point in the appropriate direction, goes
00517 //   beyond the end point of the first EDGE, that end point is used
00518 //   to generate the returned parameter value.
00519 //
00520 // If the curve is periodic and the new point, "arc_length" away
00521 // from the root point in the appropriate direction, goes beyond
00522 // the end point of the first EDGE, wrap around is done.  After
00523 // wrap around, the point is treated as with other curves
00524 //
00525 // NOTE:
00526 // The important assumption that is made in this routine is that
00527 // the end points of the RefEdge that owns this Curve are the
00528 // same as the end points of the first  EDGE in the list of EDGEs
00529 // associated with this Curve.
00530 //
00531 // Assume that the parameter root_param is with respect to the
00532 // RefEdge as well as arc_length.  Before calling the  "curve",
00533 // we need to get them with respect to the curve.   
00534 //
00535 // Creator       : Malcolm J. Panthaki
00536 //
00537 // Creation Date : 2/28/97
00538 //------------------------------------------------------------------
00539 double FacetCurve::u_from_arc_length ( double root_param,
00540                                        double arc_length )
00541 {
00542 
00543   if (!curveFacetEvalTool)
00544   {
00545     PRINT_ERROR("curve facet evaluation tool not defined in FacetCurve::u_from_arc_length\n");
00546     return 0.0;
00547   }
00548   return curveFacetEvalTool->u_from_arc_length( root_param, arc_length );
00549 
00550 }
00551 
00552 //-------------------------------------------------------------------------
00553 // Purpose       : This function tests the passed in position to see if
00554 //                 is on the underlying curve. 
00555 //
00556 // Special Notes :
00557 //
00558 // Creator       : Steve Owen
00559 //
00560 // Creation Date : 07/14/00
00561 //-------------------------------------------------------------------------
00562 CubitBoolean FacetCurve::is_position_on( const CubitVector &test_position )
00563 {
00564   CubitVector new_point;
00565   CubitStatus stat = closest_point(test_position, new_point, NULL,NULL,NULL);
00566 
00567   if ( !stat )
00568     return CUBIT_FALSE;
00569   CubitVector result_vec = test_position - new_point;
00570   if ( result_vec.length_squared() < GEOMETRY_RESABS )
00571     return CUBIT_TRUE;
00572   return CUBIT_FALSE;
00573 }
00574 
00575 //-------------------------------------------------------------------------
00576 // Purpose       : This function returns the type of underlying curve. 
00577 //
00578 // Special Notes : It checks to see if *any* of the  curves associated
00579 //                 with the EDGEs in the list of EDGEs of this Curve is of
00580 //                 a particular type and returns the appropriate value
00581 //                 of the enum, CurveType.
00582 //
00583 // Creator       : Steve Owen
00584 //
00585 // Creation Date : 07/14/00
00586 //-------------------------------------------------------------------------
00587 GeometryType FacetCurve::geometry_type()
00588 {
00589   return SEGMENTED_CURVE_TYPE;
00590 }
00591 
00592 //-------------------------------------------------------------------------
00593 // Purpose       : Return direction of point on curve
00594 //
00595 // Special Notes : not currently implemented
00596 //
00597 // Creator       : Steve Owen
00598 //
00599 // Creation Date : 07/14/00
00600 //-------------------------------------------------------------------------
00601 CubitStatus FacetCurve::get_point_direction( CubitVector& point, 
00602                                              CubitVector& direction )
00603 {
00604   point = point;
00605   direction = direction;
00606   PRINT_DEBUG_122("FacetCurve::get_point_direction currently not implemented.\n");
00607   return CUBIT_FAILURE;
00608 }
00609 
00610 //-------------------------------------------------------------------------
00611 // Purpose       : Return the center and radius of an arc
00612 //
00613 // Special Notes : not currently implemented
00614 //
00615 // Creator       : Steve Owen
00616 //
00617 // Creation Date : 07/14/00
00618 //-------------------------------------------------------------------------
00619 CubitStatus FacetCurve::get_center_radius( CubitVector& /* center */,
00620                                            double& /* radius */ )
00621 {
00622   PRINT_DEBUG_122("FacetCurve::get_center_radius currently not implemented.\n");
00623   return CUBIT_FAILURE;
00624 }
00625 
00626 //-------------------------------------------------------------------------
00627 // Purpose       : This function returns the start parameter.
00628 //
00629 // Special Notes : The start param is with respect to the ref_edge.
00630 //
00631 // Creator       : Steve Owen
00632 //
00633 // Creation Date : 07/14/00
00634 //-------------------------------------------------------------------------
00635 double FacetCurve::start_param()
00636 {
00637    double start = 0.0, end = 0.0;
00638    
00639    get_param_range( start, end );
00640    return start;
00641 }
00642 
00643 //-------------------------------------------------------------------------
00644 // Purpose       : This function returns the end parameter.
00645 //
00646 // Special Notes : The end param is with respect to the ref_edge.
00647 //
00648 // Creator       : Steve Owen
00649 //
00650 // Creation Date : 07/14/00
00651 //-------------------------------------------------------------------------
00652 double FacetCurve::end_param()
00653 {
00654    double start = 0.0, end = 0.0;
00655    
00656    get_param_range( start, end );
00657    return end;
00658 }
00659 
00660 /*
00661 void FacetCurve::bodysms(DLIList<BodySM*> &bodies)
00662 {
00663   int ii;
00664   for ( ii = myCoEdges.size(); ii > 0; ii-- )
00665   {
00666     myCoEdges.get_and_step()->bodysms(bodies);
00667   }
00668 }
00669 
00670 void FacetCurve::lumps(DLIList<Lump*> &lumps)
00671 {
00672   int ii;
00673   for ( ii = myCoEdges.size(); ii > 0; ii-- )
00674   {
00675     myCoEdges.get_and_step()->lumps(lumps);
00676   }
00677 }
00678 
00679 void FacetCurve::shellsms(DLIList<ShellSM*> &shellsms)
00680 {
00681   int ii;
00682   for ( ii = myCoEdges.size(); ii > 0; ii-- )
00683   {
00684     myCoEdges.get_and_step()->shellsms(shellsms);
00685   }
00686 }
00687 
00688 void FacetCurve::surfaces(DLIList<Surface*> &surfaces)
00689 {
00690   int ii;
00691   for ( ii = myCoEdges.size(); ii > 0; ii-- )
00692   {
00693     myCoEdges.get_and_step()->surfaces(surfaces);
00694   }
00695 }
00696 
00697 void FacetCurve::loopsms(DLIList<LoopSM*> &loopsms)
00698 {
00699   int ii; 
00700   for ( ii = myCoEdges.size(); ii > 0; ii-- )
00701   {
00702     myCoEdges.get_and_step()->loopsms(loopsms);
00703   }
00704 }
00705 
00706 
00707 void FacetCurve::coedgesms(DLIList<CoEdgeSM*> &coedgesms)
00708 {
00709   int ii; 
00710   for ( ii = myCoEdges.size(); ii > 0; ii-- )
00711   {
00712     coedgesms.append_unique( myCoEdges.get_and_step() );
00713   } 
00714 }
00715 
00716 void FacetCurve::curves(DLIList<Curve*> &curves)
00717 {
00718   curves.append_unique( this );
00719 }
00720 
00721 void FacetCurve::points(DLIList<TBPoint*> &points)
00722 {
00723   points.append_unique( myStartPoint );
00724   points.append_unique( myEndPoint );
00725 }
00726 */
00727 
00728 
00729 void FacetCurve::get_parents_virt( DLIList<TopologyBridge*>& parents ) 
00730   { CAST_LIST_TO_PARENT( myCoEdges, parents ); }
00731 void FacetCurve::get_children_virt( DLIList<TopologyBridge*>& children ) 
00732   { 
00733     children.append( myStartPoint ); 
00734     if( myStartPoint != myEndPoint )
00735       children.append( myEndPoint );
00736   }
00737   
00738 
00739 
00740 
00741 //-------------------------------------------------------------------------
00742 // Purpose       : Check for G1 discontinuity
00743 //
00744 // Special Notes : not implemented
00745 //
00746 // Creator       : Steve Owen
00747 //
00748 // Creation Date : 07/14/00
00749 //-------------------------------------------------------------------------
00750 CubitBoolean FacetCurve::G1_discontinuous( 
00751       double param, CubitVector* mtan, CubitVector* ptan )
00752 { 
00753   DLIList<CubitPoint*> point_list;
00754   curveFacetEvalTool->get_points( point_list );
00755   CubitVector position;
00756   position_from_u( param, position );
00757   point_list.reset();
00758   CubitPoint* prev = point_list.get_and_step();
00759   for( int i = point_list.size(); i > 2; i--)
00760   {
00761     CubitPoint* point = point_list.get_and_step();
00762     if( (point->coordinates() - position).length_squared() < 
00763         (GEOMETRY_RESABS*GEOMETRY_RESABS) )
00764     {
00765       if( mtan )
00766       {
00767         *mtan = point->coordinates() - prev->coordinates();
00768       }
00769       if( ptan )
00770       {
00771         *ptan = point_list.get()->coordinates() - point->coordinates();
00772       }
00773       return CUBIT_TRUE;
00774     }
00775   }
00776   return CUBIT_FALSE;
00777 }
00778 
00779 //-------------------------------------------------------------------------
00780 // Purpose       : retreive the facet edge list for this curve
00781 //
00782 // Special Notes :
00783 //
00784 // Creator       : Steve J. Owen
00785 //
00786 // Creation Date : 12/10/00
00787 //-------------------------------------------------------------------------
00788 void FacetCurve::get_facets(DLIList<CubitFacetEdge*>& facet_list)
00789 {
00790   if (curveFacetEvalTool)
00791   {
00792     curveFacetEvalTool->get_facets(facet_list);
00793   }
00794   else
00795   {
00796     PRINT_ERROR("curve facet evaluation tool not defined for FacetCurve\n");
00797   }
00798 }
00799 
00800 //-------------------------------------------------------------------------
00801 // Purpose       : retreive the facet point list for this curve
00802 //
00803 // Special Notes :
00804 //
00805 // Creator       : Steve J. Owen
00806 //
00807 // Creation Date : 12/10/00
00808 //-------------------------------------------------------------------------
00809 void FacetCurve::get_points(DLIList<CubitPoint*>& point_list)
00810 {
00811   if (curveFacetEvalTool)
00812   {
00813     curveFacetEvalTool->get_points(point_list);
00814   }
00815   else
00816   {
00817     PRINT_ERROR("curve facet evaluation tool not defined for FacetCurve\n");
00818   }
00819 }
00820 
00821 //-------------------------------------------------------------------------
00822 // Purpose       : set the facetLength in the CurveFacetEvalTool
00823 //
00824 // Special Notes :
00825 //
00826 // Creator       : Steve J. Owen
00827 //
00828 // Creation Date : 03/19/02
00829 //-------------------------------------------------------------------------
00830 void FacetCurve::reset_length()
00831 {
00832   if (curveFacetEvalTool)
00833   {
00834     curveFacetEvalTool->set_length();
00835   }
00836   else
00837   {
00838     PRINT_ERROR("curve facet evaluation tool not defined for FacetCurve\n");
00839   }
00840 }
00841 
00842 
00843 void FacetCurve::get_lumps( DLIList<FacetLump*>& result_list )
00844 {
00845   DLIList<FacetShell*> shell_list;
00846   get_shells( shell_list );
00847   shell_list.reset();
00848   for ( int i = shell_list.size(); i--; )
00849   {
00850     FacetShell* shell = shell_list.get_and_step();
00851     shell->get_lumps( result_list );
00852     FacetLump* lump = dynamic_cast<FacetLump*>(shell->get_lump());
00853     if (lump)
00854       result_list.append_unique(lump);
00855   }
00856 }
00857 
00858 void FacetCurve::get_shells( DLIList<FacetShell*>& result_list )
00859 {
00860   DLIList<FacetSurface*> surface_list;
00861   DLIList<FacetShell*> temp_list;
00862   get_surfaces( surface_list );
00863   surface_list.reset();
00864   for ( int i = surface_list.size(); i--; )
00865   {
00866     FacetSurface* surface = surface_list.get_and_step();
00867     temp_list.clean_out();
00868     surface->get_shells( temp_list );
00869     result_list.merge_unique( temp_list );
00870   }
00871 }
00872 
00873 void FacetCurve::get_surfaces( DLIList<FacetSurface*>& result_list )
00874 {
00875   DLIList<FacetLoop*> loop_list;
00876   get_loops( loop_list );
00877   loop_list.reset();
00878   for ( int i = loop_list.size(); i--; )
00879   {
00880     FacetLoop* loop = loop_list.get_and_step();
00881     FacetSurface* surface = dynamic_cast<FacetSurface*>(loop->get_surface());
00882     if (surface)
00883       result_list.append_unique(surface);
00884   }
00885 }
00886 
00887 void FacetCurve::get_loops( DLIList<FacetLoop*>& result_list )
00888 {
00889   DLIList<FacetCoEdge*> coedge_list;
00890   get_coedges( coedge_list );
00891   coedge_list.reset();
00892   for ( int i = coedge_list.size(); i--; )
00893   {
00894     FacetCoEdge* coedge = coedge_list.get_and_step();
00895     FacetLoop* loop = dynamic_cast<FacetLoop*>(coedge->get_loop());
00896     if (loop)
00897       result_list.append_unique(loop);
00898   }
00899 }
00900 
00901 void FacetCurve::get_coedges( DLIList<FacetCoEdge*>& result_list )
00902 {
00903   myCoEdges.reset();
00904   for ( int i = 0; i < myCoEdges.size(); i++ )
00905     if ( FacetCoEdge* coedge = dynamic_cast<FacetCoEdge*>(myCoEdges.next(i)) )
00906       result_list.append(coedge);
00907 }
00908 
00909 void FacetCurve::get_points( DLIList<FacetPoint*>& result_list )
00910 {
00911   FacetPoint* point;
00912   if ( (point = dynamic_cast<FacetPoint*>(myStartPoint)) )
00913     result_list.append( point );
00914   if ( (myStartPoint != myEndPoint) &&
00915        (point = dynamic_cast<FacetPoint*>(myEndPoint)) )
00916     result_list.append( point );
00917 }
00918 
00919 
00920 // ********** END PUBLIC FUNCTIONS         **********
00921 
00922 // ********** BEGIN PROTECTED FUNCTIONS    **********
00923 // ********** END PROTECTED FUNCTIONS      **********
00924 
00925 // ********** BEGIN PRIVATE FUNCTIONS      **********
00926 
00927 
00928 //----------------------------------------------------------------
00929 // Adjusts the input parameter so that it falls within the
00930 // parameter range of this Curve, if possible.  Necessary for
00931 // periodic curves.
00932 //----------------------------------------------------------------
00933 void FacetCurve::adjust_periodic_parameter(double& param)
00934 {
00935     // Adjustment only legal if this is a periodic curve.
00936   double period;
00937   if ( this->is_periodic(period) && (fabs(period) > CUBIT_RESABS))
00938   {
00939     double upper_bound, lower_bound;
00940     this->get_param_range( lower_bound, upper_bound );
00941     assert((upper_bound - lower_bound) > CUBIT_RESABS * 100);
00942 
00943     lower_bound -= CUBIT_RESABS;
00944     upper_bound += CUBIT_RESABS;
00945     
00946       // Make sure period is positive
00947     if (period < 0.)
00948       period = -period;
00949 
00950       // Move the parameter above the low param
00951     while (param < lower_bound)
00952       param += period;
00953       // Move the parameter below the high param
00954     while (param > upper_bound)
00955       param -= period;
00956   }
00957 }
00958 CubitPointContainment FacetCurve::point_containment( const CubitVector &/*point*/ )
00959 {
00960    return CUBIT_PNT_UNKNOWN;
00961 }
00962 CubitPointContainment FacetCurve::point_containment( double /*u_param*/, 
00963                                                        double /*v_param*/ )
00964 {
00965   return CUBIT_PNT_UNKNOWN; 
00966 }
00967 CubitPointContainment FacetCurve::point_containment( CubitVector &/*point*/, 
00968                                                        double /*u_param*/,
00969                                                        double /*v_param*/ )
00970 {
00971    return CUBIT_PNT_UNKNOWN;
00972 }
00973 
00974 //-------------------------------------------------------------------------
00975 // Purpose       : Tear down topology
00976 //
00977 // Special Notes : 
00978 //
00979 // Creator       : Jason Kraftcheck
00980 //
00981 // Creation Date : 09/29/03
00982 //-------------------------------------------------------------------------
00983 CubitStatus FacetCurve::disconnect_coedge( FacetCoEdge* coedge )
00984 {
00985   if (!myCoEdges.move_to(coedge))
00986     return CUBIT_FAILURE;
00987   myCoEdges.remove();
00988 
00989   assert(coedge->curve() == this);
00990   coedge->remove_curve();
00991   
00992   return CUBIT_SUCCESS;
00993 }
00994 
00995 CubitStatus FacetCurve::get_spline_params
00996 (
00997   bool &rational,    // return true/false
00998   int &degree,       // the degree of this spline
00999   DLIList<CubitVector> &cntrl_pts,  // xyz position of controlpoints
01000   DLIList<double> &cntrl_pt_weights, // if rational, a weight for each cntrl point.
01001   DLIList<double> &knots,   // There should be order+cntrl_pts.size()-2 knots
01002   bool &spline_is_reversed
01003 ) const
01004 {
01005   PRINT_ERROR("Currently, Cubit is unable to determine spline parameters for FacetCurves.\n");
01006   return CUBIT_FAILURE;
01007 }
01008 
01009 CubitStatus FacetCurve::get_ellipse_params
01010 (
01011   CubitVector &center_vec,
01012   CubitVector &normal,
01013   CubitVector &major_axis,
01014   double &radius_ratio
01015 ) const
01016 {
01017   PRINT_ERROR("Currently, Cubit is unable to determine ellipse parameters for FacetCurves.\n");
01018   return CUBIT_FAILURE;
01019 }
01020 
01021 // ********** END PRIVATE FUNCTIONS        **********
01022 
01023 // ********** BEGIN HELPER CLASSES         **********
01024 // ********** END HELPER CLASSES           **********
01025 
01026 // ********** BEGIN EXTERN FUNCTIONS       **********
01027 // ********** END EXTERN FUNCTIONS         **********
01028 
01029 // ********** BEGIN STATIC FUNCTIONS       **********
01030 // ********** END STATIC FUNCTIONS         **********
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines