opennurbs_3dm_attributes.h
Go to the documentation of this file.
00001 /* $NoKeywords: $ */
00002 /*
00003 //
00004 // Copyright (c) 1993-2012 Robert McNeel & Associates. All rights reserved.
00005 // OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
00006 // McNeel & Associates.
00007 //
00008 // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
00009 // ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
00010 // MERCHANTABILITY ARE HEREBY DISCLAIMED.
00011 //                              
00012 // For complete openNURBS copyright information see <http://www.opennurbs.org>.
00013 //
00015 */
00016 
00018 //
00019 //   defines ON_3dmObjectAttributes
00020 //
00022 
00023 #if !defined(OPENNURBS_3DM_ATTRIBUTES_INC_)
00024 #define OPENNURBS_3DM_ATTRIBUTES_INC_
00025 
00026 
00027 /*
00028 Description: 
00029   Top level OpenNURBS objects have geometry and attributes.  The
00030   geometry is stored in some class derived from ON_Geometry and 
00031   the attributes are stored in an ON_3dmObjectAttributes class.
00032   Examples of attributes are object name, object id, display 
00033   attributes, group membership, layer membership, and so on.
00034 
00035 Remarks:
00036   7 January 2003 Dale Lear
00037     Derived from ON_Object so ON_UserData can be attached
00038     to ON_3dmObjectAttributes.
00039 */
00040 
00041 class ON_CLASS ON_3dmObjectAttributes : public ON_Object
00042 {
00043   ON_OBJECT_DECLARE(ON_3dmObjectAttributes);
00044 
00045 public:
00046   // ON_Object virtual interface.  See ON_Object
00047   // for details.
00048 
00049   // virtual
00050   ON_BOOL32 IsValid( ON_TextLog* text_log = NULL ) const;
00051   // virtual
00052   void Dump( ON_TextLog& ) const;
00053   // virtual
00054   unsigned int SizeOf() const;
00055   // virtual
00056   ON_BOOL32 Write(ON_BinaryArchive&) const;
00057   // virtual
00058   ON_BOOL32 Read(ON_BinaryArchive&);
00059 
00060   /*
00061   Returns:
00062     True if successful.
00063     (xform is invertable or didn't need to be).
00064   */
00065   bool Transform( const ON_Xform& xform );
00066 
00067   // attributes of geometry and dimension table objects
00068 public:
00069   ON_3dmObjectAttributes();
00070   ~ON_3dmObjectAttributes();
00071 
00072   // Default C++ copy constructor and operator= work fine
00073   // Do not provide custom versions
00074   // NO // ON_3dmObjectAttributes(const ON_3dmObjectAttributes&);
00075   // NO // ON_3dmObjectAttributes& operator=(const ON_3dmObjectAttributes&);
00076 
00077   bool operator==(const ON_3dmObjectAttributes&) const;
00078   bool operator!=(const ON_3dmObjectAttributes&) const;
00079 
00080   // Initializes all attributes to the default values.
00081   void Default();
00082 
00083   // Interface ////////////////////////////////////////////////////////
00084 
00085   // An OpenNURBS object must be in one of three modes: normal, locked
00086   // or hidden.  If an object is in normal mode, then the object's layer
00087   // controls visibility and selectability.  If an object is locked, then
00088   // the object's layer controls visibility by the object cannot be selected.
00089   // If the object is hidden, it is not visible and it cannot be selected.
00090   ON::object_mode Mode() const;
00091   void SetMode( ON::object_mode ); // See Mode().
00092 
00093   /*
00094   Description:
00095     Use this query to determine if an object is part of an 
00096     instance definition.
00097   Returns:
00098     True if the object is part of an instance definition.
00099   */
00100   bool IsInstanceDefinitionObject() const;
00101 
00102   /*
00103   Returns:
00104     Returns true if object is visible.
00105   See Also:
00106     ON_3dmObjectAttributes::SetVisible
00107   */
00108   bool IsVisible() const;
00109 
00110   /*
00111   Description:
00112     Controls object visibility
00113   Parameters:
00114     bVisible - [in] true to make object visible, 
00115                     false to make object invisible
00116   See Also:
00117     ON_3dmObjectAttributes::IsVisible
00118   */
00119   void SetVisible( bool bVisible );
00120 
00121   // The Linetype used to display an OpenNURBS object is specified in one of two ways.
00122   // If LinetypeSource() is ON::linetype_from_layer, then the object's layer 
00123   // ON_Layer::Linetype() is used.
00124   // If LinetypeSource() is ON::linetype_from_object, then value of m_linetype is used.
00125   ON::object_linetype_source LinetypeSource() const;
00126   void SetLinetypeSource( ON::object_linetype_source ); // See LinetypeSource().
00127 
00128   // The color used to display an OpenNURBS object is specified in one of three ways.
00129   // If ColorSource() is ON::color_from_layer, then the object's layer 
00130   // ON_Layer::Color() is used.
00131   // If ColorSource() is ON::color_from_object, then value of m_color is used.
00132   // If ColorSource() is ON::color_from_material, then the diffuse color of the object's
00133   // render material is used.  See ON_3dmObjectAttributes::MaterialSource() to
00134   // determine where to get the definition of the object's render material.
00135   ON::object_color_source ColorSource() const;
00136   void SetColorSource( ON::object_color_source ); // See ColorSource().
00137 
00138   // The color used to plot an OpenNURBS object on paper is specified 
00139   // in one of three ways.
00140   // If PlotColorSource() is ON::plot_color_from_layer, then the object's layer 
00141   // ON_Layer::PlotColor() is used.
00142   // If PlotColorSource() is ON::plot_color_from_object, then value of PlotColor() is used.
00143   ON::plot_color_source PlotColorSource() const;
00144   void SetPlotColorSource( ON::plot_color_source ); // See PlotColorSource().
00145 
00146   ON::plot_weight_source PlotWeightSource() const;
00147   void SetPlotWeightSource( ON::plot_weight_source );
00148 
00149 
00150   // OpenNURBS objects can be displayed in one of three ways: wireframe,
00151   // shaded, or render preview.  If the display mode is ON::default_display,
00152   // then the display mode of the viewport detrmines how the object
00153   // is displayed.  If the display mode is ON::wireframe_display,
00154   // ON::shaded_display, or ON::renderpreview_display, then the object is
00155   // forced to display in that mode.
00156   ON::display_mode DisplayMode() const;
00157   void SetDisplayMode( ON::display_mode  ); // See DisplayMode().
00158 
00159   /*
00160   Description:
00161     If "this" has attributes (color, plot weight, ...) with 
00162     "by parent" sources, then the values of those attributes 
00163     on parent_attributes are copied.
00164   Parameters:
00165     parent_attributes - [in]
00166     parent_layer - [in]
00167     control_limits - [in]
00168       The bits in control_limits determine which attributes may
00169       may be copied.
00170                 1: visibility
00171                 2: color
00172                 4: render material
00173                 8: plot color
00174             0x10: plot weight
00175             0x20: linetype
00176             0x40: display order
00177 
00178   Returns:
00179      The bits in the returned integer indicate which attributes were
00180      actually modified.
00181 
00182                 1: visibility
00183                 2: color
00184                 4: render material
00185                 8: plot color
00186             0x10: plot weight
00187             0x20: linetype
00188             0x40: display order
00189   */
00190   ON_DEPRECATED unsigned int ApplyParentalControl( 
00191          const ON_3dmObjectAttributes& parent_attributes,
00192          unsigned int control_limits = 0xFFFFFFFF
00193          );
00194 
00195   unsigned int ApplyParentalControl( 
00196          const ON_3dmObjectAttributes& parent_attributes,
00197          const ON_Layer& parent_layer,
00198          unsigned int control_limits = 0xFFFFFFFF
00199          );
00200 
00201   // Every OpenNURBS object has a UUID (universally unique identifier).  The
00202   // default value is NULL.  When an OpenNURBS object is added to a model, the
00203   // value is checked.  If the value is NULL, a new UUID is created.  If the
00204   // value is not NULL but it is already used by another object in the model,
00205   // a new UUID is created.  If the value is not NULL and it is not used by 
00206   // another object in the model, then that value persists. When an object
00207   // is updated, by a move for example, the value of m_uuid persists.
00208   ON_UUID m_uuid;
00209 
00210   // OpenNURBS object have optional text names.  More than one object in
00211   // a model can have the same name and some objects may have no name.
00212   ON_wString m_name;
00213 
00214   // OpenNURBS objects may have an URL.  There are no restrictions on what
00215   // value this URL may have.  As an example, if the object came from a
00216   // commercial part library, the URL might point to the definition of that
00217   // part.
00218   ON_wString m_url;
00219 
00220   // Layer definitions in an OpenNURBS model are stored in a layer table.
00221   // The layer table is conceptually an array of ON_Layer classes.  Every
00222   // OpenNURBS object in a model is on some layer.  The object's layer
00223   // is specified by zero based indicies into the ON_Layer array.
00224   int m_layer_index;
00225 
00226   // Linetype definitions in an OpenNURBS model are stored in a linetype table.
00227   // The linetype table is conceptually an array of ON_Linetype classes.  Every
00228   // OpenNURBS object in a model references some linetype.  The object's linetype
00229   // is specified by zero based indicies into the ON_Linetype array.
00230   // index 0 is reserved for continuous linetype (no pattern)
00231   int m_linetype_index;
00232 
00233   // Rendering material:
00234   //   If you want something simple and fast, set 
00235   //   m_material_index to the index of the rendering material 
00236   //   and ignore m_rendering_attributes.
00237   //   If you are developing a high quality plug-in renderer, 
00238   //   and a user is assigning one of your fabulous rendering 
00239   //   materials to this object, then add rendering material 
00240   //   information to the  m_rendering_attributes.m_materials[] 
00241   //   array. 
00242   //
00243   // Developers:
00244   //   As soon as m_rendering_attributes.m_materials[] is not empty,
00245   //   rendering material queries slow down.  Do not populate
00246   //   m_rendering_attributes.m_materials[] when setting 
00247   //   m_material_index will take care of your needs.
00248   int m_material_index;
00249   ON_ObjectRenderingAttributes m_rendering_attributes;
00250 
00252   //
00253   // BEGIN: Per object mesh parameter support
00254   //
00255 
00256   /*
00257   Parameters:
00258     mp - [in]
00259       per object mesh parameters
00260   Returns:
00261     True if successful.
00262   */
00263   bool SetCustomRenderMeshParameters(const class ON_MeshParameters& mp);
00264 
00265   /*
00266   Parameters:
00267     bEnable - [in]
00268       true to enable use of the per object mesh parameters.
00269       false to disable use of the per object mesh parameters.
00270   Returns:
00271     False if the object doe not have per object mesh parameters
00272     and bEnable was true.  Use SetMeshParameters() to set
00273     per object mesh parameters.
00274   Remarks:
00275     Sets the value of ON_MeshParameters::m_bCustomSettingsDisabled 
00276     to !bEnable
00277   */
00278   bool EnableCustomRenderMeshParameters(bool bEnable);
00279 
00280   /*
00281   Returns:
00282     Null or a pointer to fragile mesh parameters.
00283     If a non-null pointer is returned, copy it and use the copy.
00284     * DO NOT SAVE THIS POINTER FOR LATER USE. A call to 
00285       DeleteMeshParameters() will delete the class.
00286     * DO NOT const_cast the returned pointer and change its
00287       settings.  You must use either SetMeshParameters()
00288       or EnableMeshParameters() to change settings.
00289   Remarks:
00290     If the value of ON_MeshParameters::m_bCustomSettingsDisabled is
00291     true, then do no use these parameters to make a render mesh.
00292   */
00293   const ON_MeshParameters* CustomRenderMeshParameters() const;
00294 
00295   /*
00296   Description:
00297     Deletes any per object mesh parameters.
00298   */
00299   void DeleteCustomRenderMeshParameters();
00300 
00301   //
00302   // END: Per object mesh parameter support
00303   //
00305 
00306 
00307   /*
00308   Description:
00309     Determine if the simple material should come from
00310     the object or from it's layer.
00311     High quality rendering plug-ins should use m_rendering_attributes.
00312   Returns:
00313     Where to get material information if you do are too lazy
00314     to look in m_rendering_attributes.m_materials[].
00315   */
00316   ON::object_material_source MaterialSource() const;
00317 
00318   /*
00319   Description:
00320     Specifies if the simple material should be the one
00321     indicated by the material index or the one indicated
00322     by the object's layer.
00323   Parameters:
00324     ms - [in]
00325   */
00326   void SetMaterialSource( ON::object_material_source ms );
00327 
00328   // If ON::color_from_object == ColorSource(), then m_color is the object's
00329   // display color.
00330   ON_Color      m_color;
00331 
00332   // If ON::plot_color_from_object == PlotColorSource(), then m_color is the object's
00333   // display color.
00334   ON_Color      m_plot_color;
00335 
00336   // Display order used to force objects to be drawn on top or behind each other
00337   // 0  = draw object in standard depth buffered order
00338   // <0 = draw object behind "normal" draw order objects
00339   // >0 = draw object on top of "noraml" draw order objects
00340   // Larger number draws on top of smaller number.
00341   int m_display_order;
00342 
00343   // Plot weight in millimeters.
00344   //   =0.0 means use the default width
00345   //   <0.0 means don't plot (visible for screen display, but does not show on plot)
00346   double m_plot_weight_mm;
00347 
00348   // Used to indicate an object has a decoration (like an arrowhead on a curve)
00349   ON::object_decoration  m_object_decoration;
00350 
00351   // When a surface object is displayed in wireframe, m_wire_density controls
00352   // how many isoparametric wires are used.
00353   //
00354   //   @table
00355   //   value    number of isoparametric wires
00356   //   -1       boundary wires
00357   //    0       boundary and knot wires 
00358   //    1       boundary and knot wires and, if there are no
00359   //            interior knots, a single interior wire.
00360   //   N>=2     boundary and knot wires and (N-1) interior wires
00361   int m_wire_density;
00362 
00363 
00364   // If m_viewport_id is nil, the object is active in
00365   // all viewports. If m_viewport_id is not nil, then 
00366   // this object is only active in a specific view.  
00367   // This field is primarily used to assign page space
00368   // objects to a specific page, but it can also be used 
00369   // to restrict model space to a specific view.
00370   ON_UUID m_viewport_id;
00371 
00372   // Starting with V4, objects can be in either model space
00373   // or page space.  If an object is in page space, then
00374   // m_viewport_id is not nil and identifies the page it 
00375   // is on.
00376   ON::active_space m_space;
00377 
00378 private:
00379   bool m_bVisible;
00380   unsigned char m_mode;               // (m_mode % 16) = ON::object_mode values
00381                                       // (m_mode / 16) = ON::display_mode values
00382   unsigned char m_color_source;       // ON::object_color_source values
00383   unsigned char m_plot_color_source;  // ON::plot_color_source values
00384   unsigned char m_plot_weight_source; // ON::plot_weight_source values
00385   unsigned char m_material_source;    // ON::object_material_source values
00386   unsigned char m_linetype_source;    // ON::object_linetype_source values
00387   
00388   unsigned char m_reserved_0;
00389   
00390   ON_SimpleArray<int> m_group; // array of zero based group indices
00391 public:
00392 
00393   // group interface
00394 
00395   // returns number of groups object belongs to
00396   int GroupCount() const;
00397 
00398   // Returns and array an array of GroupCount() zero based 
00399   // group indices.  If GroupCount() is zero, then GroupList()
00400   // returns NULL.
00401   const int* GroupList() const;
00402 
00403   // Returns GroupCount() and puts a list of zero based group indices 
00404   // into the array.
00405   int GetGroupList(ON_SimpleArray<int>&) const;
00406 
00407   // Returns the index of the last group in the group list
00408   // or -1 if the object is not in any groups
00409   int TopGroup() const;
00410 
00411   // Returns true if object is in group with the specified index
00412   ON_BOOL32 IsInGroup(
00413     int // zero based group index
00414     ) const;
00415 
00416   // Returns true if the object is in any of the groups in the list
00417   ON_BOOL32 IsInGroups(
00418     int,       // group_list_count
00419     const int* // group_list[] array
00420     ) const;
00421 
00422   // Returns true if object is in any of the groups in the list
00423   ON_BOOL32 IsInGroups(
00424     const ON_SimpleArray<int>& // group_list[] array
00425     ) const;
00426 
00427   // Adds object to the group with specified index by appending index to
00428   // group list (If the object is already in group, nothing is changed.)
00429   void AddToGroup(
00430     int // zero based group index
00431     );
00432 
00433   // Removes object from the group with specified index.  If the 
00434   // object is not in the group, nothing is changed.
00435   void RemoveFromGroup(
00436     int // zero based group index
00437     );
00438 
00439   // removes the object from the last group in the group list
00440   void RemoveFromTopGroup();
00441 
00442   // Removes object from all groups.
00443   void RemoveFromAllGroups();
00444 
00445 
00446   // display material references
00447 
00448   /*
00449   Description:
00450     Searches for a matching display material.  For a given
00451     viewport id, there is at most one display material.
00452     For a given display material id, there can be multiple
00453     viewports.  If there is a display reference in the
00454     list with a nil viewport id, then the display material
00455     will be used in all viewports that are not explictly
00456     referenced in other ON_DisplayMaterialRefs.
00457 
00458   Parameters:
00459     search_material - [in] 
00460     found_material - [out]
00461     
00462     If FindDisplayMaterialRef(), the input value of search_material
00463     is never changed.  If FindDisplayMaterialRef() returns true, 
00464     the chart shows the output value of display_material.  When
00465     there are multiple possibilities for a match, the matches
00466     at the top of the chart have higher priority.
00467 
00468     search_material  found_material
00469     input value      output value
00470 
00471     (nil,nil)        (nil,did) if (nil,did) is in the list.
00472     (nil,did)        (vid,did) if (vid,did) is in the list.
00473     (nil,did)        (nil,did) if (nil,did) is in the list.
00474     (vid,nil)        (vid,did) if (vid,did) is in the list
00475     (vid,nil)        (vid,did) if (nil,did) is in the list
00476     (vid,did)        (vid,did) if (vid,did) is in the list.
00477 
00478   Example:
00479     ON_UUID display_material_id = ON_nil_uuid;
00480     ON_Viewport vp = ...;
00481     ON_DisplayMaterialRef search_dm;
00482     search_dm.m_viewport_id = vp.ViewportId();
00483     ON_DisplayMaterialRef found_dm;
00484     if ( attributes.FindDisplayMaterial(search_dm, &found_dm) )
00485     {
00486       display_material_id = found_dm.m_display_material_id;
00487     }
00488 
00489   Returns:
00490     True if a matching display material is found.
00491   See Also:
00492     ON_3dmObjectAttributes::AddDisplayMaterialRef
00493     ON_3dmObjectAttributes::RemoveDisplayMaterialRef
00494   */
00495   bool FindDisplayMaterialRef(
00496       const ON_DisplayMaterialRef& search_material,
00497       ON_DisplayMaterialRef* found_material = NULL
00498     ) const;
00499 
00500   /*
00501   Description:
00502     Quick way to see if a viewport has a special material.
00503   Parameters:
00504     viewport_id - [in]
00505     display_material_id - [out]
00506   Returns:
00507     True if a material_id is assigned.
00508   */
00509   bool FindDisplayMaterialId( 
00510         const ON_UUID& viewport_id, 
00511         ON_UUID* display_material_id = NULL
00512         ) const;
00513      
00514   /*
00515   Description:
00516     Add a display material reference to the attributes.  If
00517     there is an existing entry with a matching viewport id,
00518     the existing entry is replaced.
00519   Parameters:
00520     display_material - [in]
00521   Returns:
00522     True if input is valid (material id != nil)
00523   See Also:
00524     ON_3dmObjectAttributes::FindDisplayMaterialRef
00525     ON_3dmObjectAttributes::RemoveDisplayMaterialRef
00526   */
00527   bool AddDisplayMaterialRef(
00528     ON_DisplayMaterialRef display_material
00529     );
00530 
00531   /*
00532   Description:
00533     Remove a display material reference from the list.
00534   Parameters:
00535     viewport_id - [in] Any display material references
00536       with this viewport id will be removed.  If nil,
00537       then viewport_id is ignored.
00538     display_material_id - [in]
00539       Any display material references that match the
00540       viewport_id and have this display_material_id
00541       will be removed.  If nil, then display_material_id
00542       is ignored.
00543   Returns:
00544     True if a display material reference was removed.
00545   See Also:
00546     ON_3dmObjectAttributes::FindDisplayMaterialRef
00547     ON_3dmObjectAttributes::AddDisplayMaterialRef
00548   */
00549   bool RemoveDisplayMaterialRef(
00550     ON_UUID viewport_id,
00551     ON_UUID display_material_id = ON_nil_uuid
00552     );
00553 
00554   /*
00555   Description:
00556     Remove a the entire display material reference list.
00557   */
00558   void RemoveAllDisplayMaterialRefs();
00559 
00560   /*
00561   Returns:
00562     Number of diplay material refences.
00563   */
00564   int DisplayMaterialRefCount() const;
00565 
00566   ON_SimpleArray<ON_DisplayMaterialRef> m_dmref;
00567 
00568 private:
00569   bool WriteV5Helper( ON_BinaryArchive& file ) const;
00570   bool ReadV5Helper( ON_BinaryArchive& file );
00571 };
00572 
00573 #endif


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:26:58