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