cgma
FacetCurve.hpp
Go to the documentation of this file.
00001 //-------------------------------------------------------------------------
00002 // Filename      : FacetCurve.hpp
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 #ifndef CURVE_FACET_HPP
00016 #define CURVE_FACET_HPP
00017 
00018 // ********** BEGIN STANDARD INCLUDES      **********
00019 // ********** END STANDARD INCLUDES        **********
00020 
00021 // ********** BEGIN CUBIT INCLUDES         **********
00022 #include "CubitDefines.h"
00023 #include "Curve.hpp"
00024 #include "FacetAttribSet.hpp"
00025 // ********** END CUBIT INCLUDES           **********
00026 
00027 // ********** BEGIN FORWARD DECLARATIONS   **********
00028 class TopologyEntity;
00029 class CurveFacetEvalTool;
00030 class FacetEvalTool;
00031 class FacetAttrib;
00032 class CurveFacetEvalTool;
00033 class TBPoint;
00034 class CubitPoint;
00035 class CubitFacetEdge;
00036 class CubitFacetEdge;
00037 
00038 class FacetBody;
00039 class FacetLump;
00040 class FacetShell;
00041 class FacetSurface;
00042 class FacetLoop;
00043 class FacetCoEdge;
00044 class FacetPoint;
00045 
00046 // ********** END FORWARD DECLARATIONS     **********
00047 
00048 class FacetCurve : public Curve
00049 {
00050 public :
00051   
00052   FacetCurve( CurveFacetEvalTool *curve_facet_tool,
00053               TBPoint *fp0, TBPoint *fp1,
00054               DLIList<CoEdgeSM*> &coedgelist );
00055     //I- curve_facet_eval_tool_ptr pointer
00056     //I- A pointer to the set of facet edges that define this curve.
00057   
00058   FacetCurve( CurveFacetEvalTool *curve_facet_tool,
00059               TBPoint *fp0, TBPoint *fp1,
00060               CubitSense sense );
00061     //I- curve_facet_eval_tool_ptr pointer
00062     //I- start and end points 
00063     //I- Sense of curve 
00064   
00065   virtual ~FacetCurve() ;
00066     //- The destructor
00067 
00068     
00069   virtual void append_simple_attribute_virt(const CubitSimpleAttrib&);
00070     //R void
00071     //I 
00072     //I- 
00073     //I- that is to be appended to this OSME object.
00074     //- The purpose of this function is to append a 
00075     //- attribute to the OSME. The  is attached to each of the 
00076     //- underlying solid model entities this one points to.
00077   
00078   virtual void remove_simple_attribute_virt(const CubitSimpleAttrib&);
00079     //R void
00080     //I CubitSimpleAttrib*
00081     //I- A reference to a CubitSimpleAttrib object which is the object
00082     //I- that is to be removed to this OSME object.
00083     //- The purpose of this function is to remove a simple
00084     //- attribute from the OSME. The attribute is attached to each of the
00085     //- underlying solid model entities this one points to.
00086   
00087   virtual void remove_all_simple_attribute_virt();
00088     //R void
00089     //I-
00090     //- The purpose of this function is to remove all simple
00091     //- attributes from the OSME. 
00092   
00093   virtual CubitStatus get_simple_attribute(DLIList<CubitSimpleAttrib>&);
00094   virtual CubitStatus get_simple_attribute(const CubitString& name,
00095                                            DLIList<CubitSimpleAttrib>&);
00096     //R CubitSimpleAttrib*
00097     //R- the returned cubit simple attribute.
00098     //- The purpose of this function is to get the attributes
00099     //- of the geometry entity. The name is attached to the underlying solid
00100     //- model entity(ies) this one points to.
00101     //- MJP Note:
00102     //- This is the code that implements the requirement that names
00103     //- of VGI Entities propagate across solid model boolean
00104     //- operations.  The success of this relies, of course, on the underlying
00105     //- solid modeler being able to propagate attributes across
00106     //- such operations on its entities. If it cannot, then "names"
00107     //- of VGI entities will not propagate.
00108   
00109   virtual CubitBox bounding_box() const ;
00110     //- see comments in GeometryEntity.hpp
00111   
00112   virtual GeometryQueryEngine* 
00113   get_geometry_query_engine() const;
00114     //R GeometryQueryEngine*
00115     //R- A pointer to the geometric modeling engine associated with
00116     //R- the object.
00117     //- This function returns a pointer to the geometric modeling engine
00118     //- associated with the object.
00119   
00120   virtual double measure();
00121     //R double
00122     //R- The numeric value of the measure (its units depend on the dimension
00123     //R- of the RefEntity being "measured")
00124     //- A generic geometric extent function.
00125     //- Returns volume for Lump, area for Surface, length for Curve and 
00126     //- 1.0 for Point
00127     //-
00128     //- If there is an error computing the length a value of -1.0 is
00129     //- returned.
00130   
00131   virtual double length_from_u( double parameter1,
00132                                 double parameter2 );
00133     //R double
00134     //R- Returned length value
00135     //I parameter1
00136     //I- The first parameter value
00137     //I parameter2
00138     //I- The second parameter value
00139     //- This function returns the arc length along the Curve starting from
00140     //- the point represented by the parameter1 going to the point represented
00141     //- by parameter2.
00142   
00143   virtual CubitBoolean is_periodic( double& period);
00144     //R CubitBoolean
00145     //R- CUBIT_TRUE/CUBIT_FALSE
00146     //O period
00147     //O- Returned period value
00148     //- This function determines whether the underlying geometry of the
00149     //- Curve is periodic or not.  Returns CUBIT_TRUE if it is and 
00150     //- CUBIT_FALSE if it is not.
00151     //-
00152     //- If it is periodic, then it returns the period in the input
00153     //- reference variable, "period". This value is set to 0.0 if
00154     //- the Curve is not periodic.
00155     //- 
00156   
00157   virtual CubitBoolean get_param_range( double& lower_bound,
00158                                         double& upper_bound );
00159     //R CubitBoolean
00160     //R- CUBIT_TRUE/CUBIT_FALSE
00161     //O lower_bound
00162     //O- The lower bound of the parametric range.
00163     //O upper_bound
00164     //O- The upper bound of the parametric range.
00165     //- Returns the lower and upper parametric bounds of the 
00166     //- Curve.
00167     //-
00168     //- IMPORTANT NOTE:
00169     //- Note that the lower bound is the parameter value of the start
00170     //- location of the RefEdge that uses this Curve and the upper
00171     //- bound is the parameter value of the end location of the RefEdge
00172     //- that uses this Curve.  This takes into account the sense of the
00173     //- RefEdge with respect to the Curve (which could be REVERSED).
00174     //- Hence, the numerical value of the lower parameter bound could be
00175     //- greater than that of the upper parameter bound.
00176   
00177   virtual CubitStatus get_interior_extrema(DLIList<CubitVector*>& interior_points,
00178                                            CubitSense& return_sense);
00179     //- Finds the extrema along this RefEdge.  An extremum is defined as
00180     //- a local min or max in the direction of one of the primary axial directions.
00181     //- O-interior_points: list of coordinates where the extrema occur.
00182     //- O-return_sense: Whether the interior extrema are ordered in the
00183     //-                 FORWARD or REVERSED direction of this RefEdge.
00184     //-
00185     //- ***IMPORTANT!!!***
00186     //-    This function dynamically allocates the CubitVectors appended to
00187     //-    interior_points.  It is the responsibility of the calling code to
00188     //-    delete these CubitVectors (or in the case of RefEdge, to make sure
00189     //-    that *it's* calling code knows that it should delete the CubitVectors)!
00190   
00191   virtual CubitStatus closest_point( CubitVector const& location, 
00192                                      CubitVector& closest_location,
00193                                      CubitVector* tangent_ptr = NULL,
00194                                      CubitVector* curvature_ptr = NULL,
00195                                      double *param = NULL);
00196     //R void
00197     //I location
00198     //I- The point to which the closest point on the Curve is desired.
00199     //O closest_location
00200     //O- The point on the Curve, closest to the input location which
00201     //O- might not be on the Curve.  This is input as a reference 
00202     //O- so that the function can modify its contents.
00203     //O tangent_ptr
00204     //O- The tangent to the Curve (output as a unit vector) at the 
00205     //O- closest_location.
00206     //O curvature_ptr
00207     //O- The curvature of the Curve at the closest_location.
00208     //- This function computes the point on the Curve closest to the input 
00209     //- location.
00210     //-
00211     //- If the tangent and/or curvature is required, then the calling code
00212     //- is responsible for allocating space for the CubitVector(s) and
00213     //- sending in the relevant non-NULL pointers.  If either of these
00214     //- pointers is NULL, the related quantity is not computed.
00215     //-
00216     //- Notes:
00217     //- The tangent direction is always in the positive direction of the 
00218     //- *owning RefEdge*, regardless of the positive direction of the
00219     //- underlying solid model entities.
00220   
00221   virtual CubitStatus position_from_u (double u_value,
00222                                        CubitVector& output_position);
00223     //R CubitStatus
00224     //R- CUBIT_SUCCESS/FAILURE
00225     //I u_value
00226     //I- The input u parameter value
00227     //O output_position
00228     //O- The output position
00229     //- This function returns the coordinates of a point in the global
00230     //- (world) space that corresponds to the input parametric position 
00231     //- in the local space.
00232     //-
00233     //- If the input parameter value is not defined for the Curve, then 
00234     //- the input CubitVector is not modified and CUBIT_FAILURE is
00235     //- returned. Otherwise, position is appropriately modified and
00236     //- CUBIT_SUCCESS is returned.
00237     //-
00238     //- If the curve is periodic, the input u_value is first "normalized"
00239     //- to the fundamental period of the Curve before its position
00240     //- in global space is determined.
00241   
00242   double u_from_position (const CubitVector& input_position);
00243   
00244   virtual double u_from_arc_length ( double root_param,
00245                                      double arc_length );
00246     //R double
00247     //R- Returned parameter value
00248     //I root_param
00249     //I- The parameter value of the "root point"
00250     //I arc_length
00251     //I- A distance along the Curve
00252     //- This function returns the parameter value of the point that is
00253     //- "arc_length" away from the root point in the
00254     //- positive sense direction of the owning RefEdge.
00255     //-
00256     //- If arc_length is negative, the new point (whose parameter value is
00257     //- being computed) is in the negative sense direction (along the 
00258     //- RefEdge) from the root point (whose parameter value is root_param).
00259   
00260   virtual CubitBoolean is_position_on( const CubitVector &test_position );
00261     //R CubitBoolean
00262     //R- CUBIT_TRUE/CUBIT_FALSE
00263     //I CubitVector
00264     //I- position, point where we want to test, whether or not it
00265     //- is on the curve.
00266   
00267   GeometryType geometry_type();
00268     //R GeometryType (enum)
00269     //R- The enumerated type of the geometric representation
00270   
00271   CubitStatus get_point_direction( CubitVector& origin, CubitVector& direction );
00272   //- Only valid for straight lines
00273   //- Finds the underlying line's origin and direction unit vector
00274   //- Returns CUBIT_FAILURE if curve is not a line
00275 
00276   CubitStatus get_center_radius( CubitVector& center, double& radius );
00277   //- Only valid for arcs
00278   //- Finds the underlying arc's center point and radius
00279   //- Returns CUBIT_FAILURE if curve is not an arc
00280 
00281   virtual double start_param();
00282     //R double parameter
00283     //R- start parameter of curve with respect to refEdge.
00284   
00285   virtual double end_param();
00286     //R double parameter
00287     //R- start parameter of curve with respect to refEdge.
00288     
00289   virtual CubitBoolean G1_discontinuous( double param,
00290                                          CubitVector* minus_tangent = NULL,
00291                                          CubitVector* plus_tangent = NULL );
00292   
00293   virtual CubitPointContainment point_containment( const CubitVector &point );
00294   virtual CubitPointContainment point_containment( double u, double v );
00295   virtual CubitPointContainment point_containment( CubitVector &point, 
00296                                                    double u, double v );
00297     //R CubitPointContainment - is the point outside, inside or on the boundary?
00298     //R- CUBIT_PNT_OUTSIDE, CUBIT_PNT_INSIDE, CUBIT_PNT_BOUNDARY, 
00299     //   CUBIT_PNT_UNKNOWN
00300     //I CubitVector
00301     //I- position to check, known to be on the Surface
00302     //I double
00303     //I- u coordinate, if known (significantly faster, if this is known - however
00304     //                           if not known let the function figure it out)
00305     //I double
00306     //I- v coordinate, if known (significantly faster, if this is known - however
00307     //                           if not known let the function figure it out)
00308     // NOTE: POINT MUST LIE ON THE SURFACE FOR THIS FUNCTION TO WORK PROPERLY.
00309 
00310   CubitStatus save_attribs( FILE* file_ptr );
00311     // Write FactAttribs out to file
00312 
00313   CubitStatus restore_attribs( FILE* file_ptr, unsigned int endian );
00314     // Read FactAttribs from file
00315   
00316   void get_lumps   ( DLIList<FacetLump   *>& lumps    );
00317   void get_shells  ( DLIList<FacetShell  *>& shells   );
00318   void get_surfaces( DLIList<FacetSurface*>& surfaces );
00319   void get_loops   ( DLIList<FacetLoop   *>& loops    );
00320   void get_coedges ( DLIList<FacetCoEdge *>& coedges  );
00321   void get_points  ( DLIList<FacetPoint  *>& points   );
00322 
00323   void get_parents_virt( DLIList<TopologyBridge*>& parents );
00324   void get_children_virt( DLIList<TopologyBridge*>& children );
00325 
00326   void add_coedge( CoEdgeSM *coedge_ptr )
00327     { myCoEdges.append_unique( coedge_ptr ); }
00328     //- associate this curve with a coedge
00329 
00330   void get_facets(DLIList<CubitFacetEdge*>& facet_list);
00331     //- Gets the list of facets describing this curve.
00332   void get_points(DLIList<CubitPoint*>& point_list);
00333     //- Gets the list of points describing this curve.
00334 
00335   void reset_length();
00336     //- update the length of the facet curve
00337 
00338   CurveFacetEvalTool *get_eval_tool()
00339     { return curveFacetEvalTool; }
00340     //- return the curve evaluation tool
00341 
00342   void set_eval_tool( CurveFacetEvalTool *eval_tool)
00343     { curveFacetEvalTool = eval_tool; } 
00344     //- set the curve evaluation tool
00345 
00346   TBPoint *start_point()
00347     { return myStartPoint; }
00348   TBPoint *end_point()
00349     { return myEndPoint; }
00350   CubitSense get_sense() { return sense_; }
00351 
00352   CubitStatus disconnect_coedge( FacetCoEdge* coedge );
00353   
00354   void remove_start_point() { myStartPoint = 0; }
00355   void remove_end_point() { myEndPoint = 0; }
00356   
00357   bool has_parent_coedge() { return myCoEdges.size() > 0; }
00358 
00359   //R CubitStatus
00360   //O- true or false if spline is rational or not.
00361   //O- the degree of this spline
00362   //O- the control points
00363   //O- If rational, weight for each control point
00364   //O- the knots
00365   //O- whether underlying spline is reversed
00366   virtual CubitStatus get_spline_params( bool &rational,
00367                                          int &degree,
00368                                          DLIList<CubitVector> &cntrl_pts,
00369                                          DLIList<double> &cntrl_pt_weights,
00370                                          DLIList<double> &knots,
00371                                          bool &spline_is_reversed
00372                                        ) const;
00373   //R CubitStatus
00374   //O- center - ellipse center point
00375   //O- normal - normal of the plane of the ellipse
00376   //O- major_axis - major axis of the ellipse
00377   //O- radius_ratio - ratio of the length of the major to minor axis.
00378   virtual CubitStatus get_ellipse_params( CubitVector &center,
00379                                           CubitVector &normal,
00380                                           CubitVector &major_axis,
00381                                           double &radius_ratio ) const;
00382 
00383   int id() {return myId;}
00384 
00385 protected: 
00386   
00387 private:
00388   
00389   CubitSense get_relative_curve_sense();
00390     //R CubitSense
00391     //R- Returned sense value
00392     //- Returns the sense of the RefEdge with respect to the underlying
00393     //- facet curve.
00394   
00395   void adjust_periodic_parameter(double& param);
00396   
00397   CubitSense sense_;
00398     //- The sense of the RefEdge that owns this Curve with respect
00399     //- to the positive sense of the first EDGE in EDGEPtrList_.
00400     //- When a Curve is first constructed, this value is arbitrarily
00401     //- set to CUBIT_FORWARD.
00402     //- MJP NOTE:
00403     //- Not only does the RefEdge have a sense wrt its Curve, but each
00404     //-  EDGE has a sense wrt its underlying "curve" object.
00405   
00406   FacetAttribSet attribSet;
00407     //List of FacetAttrib*'s instead of CubitSimpleAttribs 
00408   
00409   friend void run_test_function();
00410 
00411   CurveFacetEvalTool *curveFacetEvalTool;
00412   TBPoint *myStartPoint;
00413   TBPoint *myEndPoint;
00414   DLIList<CoEdgeSM*> myCoEdges;
00415   int myId;
00416   bool periodic;
00417 };
00418 
00419 // ********** BEGIN INLINE FUNCTIONS       **********
00420 // ********** END INLINE FUNCTIONS         **********
00421 
00422 // ********** BEGIN FRIEND FUNCTIONS       **********
00423 // ********** END FRIEND FUNCTIONS         **********
00424 
00425 // ********** BEGIN EXTERN FUNCTIONS       **********
00426 // ********** END EXTERN FUNCTIONS         **********
00427 
00428 #endif
00429 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines