Rhino C++ API  7.26
Public Member Functions | Public Attributes | List of all members
ON_HiddenLineDrawing Class Reference

#include <opennurbs_plus_hiddenline.h>

Public Member Functions

 ON_HiddenLineDrawing ()
 ON_HiddenLineDrawing (const ON_HiddenLineDrawing &)
 ON_HiddenLineDrawing (double absoluteTolerance)
 ~ON_HiddenLineDrawing ()
double AbsoluteTolerance () const
bool AddClippingPlane (ON_PlaneEquation clip, ON__UINT_PTR clip_id=0)
bool AddClippingPlanes (const ON_PlaneEquation *clip, const ON__UINT_PTR *clip_id, size_t count)
bool AddClippingPlanes (const ON_SimpleArray< ON_PlaneEquation > &clip, const ON_SimpleArray< ON__UINT_PTR > *clip_id=nullptr)
 Step 3. Optionally, Specify clipping planes or other options. More...
int AddObject (const ON_Geometry *geom, const ON_Xform *xform, ON_UUID uuid, ON__UINT_PTR m_id)
 Step IV - Add Objects that are to be drawn.
int AddObject (std::shared_ptr< const ON_Geometry > shr_geom_ptr, const ON_Xform *xform, ON_UUID uuid, ON__UINT_PTR m_id)
ON_3dVector CameraDirection (ON_3dPoint wp) const
 world camera direction ( increasing toward scene) at a world point More...
ON_3dVector CamLocDir () const
 returns camera location, if perspective, or else camera direction. More...
bool Draw (bool bAllowUseMP, ON_ProgressReporter *progress, ON_Terminator *terminator)
 Step V. Draw objects hidden line drawings. More...
void Dump (ON_TextLog &) const
void EmergencyDestroy ()
bool Flatten ()
ON_BoundingBox GetBoundingBox (bool include_hidden) const
 Get tight bounding box of the hidden line drawing. More...
const ON_SimpleArray< ON_PlaneEquation > & GetClippingPlanes () const
const ON_SimpleArray< ON_PlaneEquation > & GetClippingPlanes (ON_SimpleArray< ON__UINT_PTR > *clip_id) const
const ON_SimpleArray< const class ON_HLDPoint * > & GetHLDPoints ()
bool HasBeenFlattened () const
const ON_XformHiddenLine2World () const
 HLD to World coordinate System.
bool IncludeHiddenCurves (bool include)
void IncludeTangentEdges (bool include)
bool IncludeTangentSeams (bool include)
bool IsPerspective () const
bool IsValid (ON_TextLog *text_log=nullptr) const
bool Merge (ON_HiddenLineDrawing &OtherHLD, ON_Terminator *terminator)
int NumberDrawn () const
 Return number of objects present when the last Draw() operation was performed. More...
ON_HiddenLineDrawingoperator= (const ON_HiddenLineDrawing &)
bool SetAbsoluteTolerance (double absolute_tolerance)
void SetContext (const ON_HiddenLineDrawing &source)
bool SetParallelViewport (ON_3dVector CameraDirection, ON_3dVector CameraUp)
bool SetViewport (const ON_Viewport &v)
 Step II. Specify viewport. More...
const ON_ViewportViewport () const
const ON_XformWorld2HiddenLine () const
 World to HLD-coordinate System.

Public Attributes

const ON_SimpleArray< const class ON_HLDCurve * > & m_curve
const ON_SimpleArray< const class ON_HLDFullCurve * > & m_full_curve
const ON_SimpleArray< const class ON_HLD_Object * > & m_object
 m_object is the array of objects that that have been added and will be used in the Draw() operation. More...

Detailed Description


/ / Copyright (c) 1993-2013 Robert McNeel & Associates. All rights reserved. / OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert / McNeel & Associates. / / THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY. / ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF / MERCHANTABILITY ARE HEREBY DISCLAIMED. /
/ For complete openNURBS copyright information see http://www.opennurbs.org. / //////////////////////////////////////////////////////////////

Constructor & Destructor Documentation

◆ ON_HiddenLineDrawing() [1/3]

ON_HiddenLineDrawing::ON_HiddenLineDrawing ( double  absoluteTolerance)

Step I. Construct an empty hidden line drawing Absolute tolerance is used to decide if curves overlap or intersect.
A suggested value is to use CRhinoDoc::AbsoluteTolerance

◆ ON_HiddenLineDrawing() [2/3]

ON_HiddenLineDrawing::ON_HiddenLineDrawing ( )

◆ ~ON_HiddenLineDrawing()

ON_HiddenLineDrawing::~ON_HiddenLineDrawing ( )

◆ ON_HiddenLineDrawing() [3/3]

ON_HiddenLineDrawing::ON_HiddenLineDrawing ( const ON_HiddenLineDrawing )

Member Function Documentation

◆ AbsoluteTolerance()

double ON_HiddenLineDrawing::AbsoluteTolerance ( ) const

◆ AddClippingPlane()

bool ON_HiddenLineDrawing::AddClippingPlane ( ON_PlaneEquation  clip,
ON__UINT_PTR  clip_id = 0 

◆ AddClippingPlanes() [1/2]

bool ON_HiddenLineDrawing::AddClippingPlanes ( const ON_PlaneEquation clip,
const ON__UINT_PTR *  clip_id,
size_t  count 

◆ AddClippingPlanes() [2/2]

bool ON_HiddenLineDrawing::AddClippingPlanes ( const ON_SimpleArray< ON_PlaneEquation > &  clip,
const ON_SimpleArray< ON__UINT_PTR > *  clip_id = nullptr 

Step 3. Optionally, Specify clipping planes or other options.

Description: Specify clipping planes that are active for this view. Parameters: clip -[in] clipping plane or planes clip_id -[in] This is an optional parameter the user can use to identify the clipping plane. Returns: true if clipping planes have been set. Remarks: A point x in model space is visible if p(x)<=0 for each clipping plane p.

Only allowed before calling Draw. The clipping planes are append to the ON_HiddenLineDrawing::m_clipping_plane array. For perspective views SetViewport() will add 6 clipping planes from the viewport, and the the first clipping plane is the near plane of the view frustum.

◆ AddObject() [1/2]

int ON_HiddenLineDrawing::AddObject ( const ON_Geometry geom,
const ON_Xform xform,
ON_UUID  uuid,
ON__UINT_PTR  m_id 

Step IV - Add Objects that are to be drawn.

Each call to AddObjects with valid geometry will add a corresponding ON_HLD_Object to the m_object array. Results in the ON_HiddenLineDrawing will then refer back to these ON_HLD_Object as source objects.

Parameters: geom - [in] geometry to be drawn. returns -1 if geometry type is not supported by ON_HiddenLineDrawing. xform - [in] If not null this transformation is applied to geom to place it in the world coordinte system. The transform *xform is copied. uuid -[in] This parameter is copied into the ON_HLD_Object. m_id -[in] This parameter is copied into the ON_HLD_Object. Returns: Index into m_object array of the corresponding ON_HLD_Object, or -1 if the geometry type is not supported. Details: The only supported geometry types are ON_Brep, ON_Curve, ON_Mesh, ON_Point and ON_PointCloud. The uuid and m_id are fields for the user to cross-reference the geometry to other information in their application. When using the simple geom pointer it is the users responsibility to ensure the geometry exists for the lifetime of the ON_HiddenLineDrawing. Alternatively, the shr_geom_ptr parameter is a "smart pointer" that will ensure geometry persists untill the ON_HiddenLineDrawing is destroyed.

◆ AddObject() [2/2]

int ON_HiddenLineDrawing::AddObject ( std::shared_ptr< const ON_Geometry shr_geom_ptr,
const ON_Xform xform,
ON_UUID  uuid,
ON__UINT_PTR  m_id 

◆ CameraDirection()

ON_3dVector ON_HiddenLineDrawing::CameraDirection ( ON_3dPoint  wp) const

world camera direction ( increasing toward scene) at a world point

◆ CamLocDir()

ON_3dVector ON_HiddenLineDrawing::CamLocDir ( ) const

returns camera location, if perspective, or else camera direction.

◆ Draw()

bool ON_HiddenLineDrawing::Draw ( bool  bAllowUseMP,
ON_ProgressReporter progress,
ON_Terminator terminator 

Step V. Draw objects hidden line drawings.

Description: Makes a hidden line drawing for the the objects in m_obj Parameters: bAllowUseMP -[in] If true multiprocessors may be used to speed up the calculation. progress - [in] If not null this class can be used to see how much progress has been made while the computing. terminator - [in] Optional object to allow caller to terminate computation. Returns: true when drawing completes without error Remarks: If this ON_HiddenLineDrawing already contains a drawing of objects the result includes a composite drawing of old and new objects. However for best performance add all the objects then call Draw only once.

◆ Dump()

void ON_HiddenLineDrawing::Dump ( ON_TextLog ) const

◆ EmergencyDestroy()

void ON_HiddenLineDrawing::EmergencyDestroy ( )

Call EmergencyDestroy() if the memory used by the results of the any Draw operations, in particular any of the contents of m_full_curve and m_curve, has become invalid.

◆ Flatten()

bool ON_HiddenLineDrawing::Flatten ( )

Flatten() projects all m_full_curve to the x-y plane in HLD-coordninates. Since HLD_Curves are ProxyCurves with references in the m_full_curve array these are also flattened.

◆ GetBoundingBox()

ON_BoundingBox ON_HiddenLineDrawing::GetBoundingBox ( bool  include_hidden) const

Get tight bounding box of the hidden line drawing.

◆ GetClippingPlanes() [1/2]

const ON_SimpleArray< ON_PlaneEquation >& ON_HiddenLineDrawing::GetClippingPlanes ( ) const

Description: Get the array of clipping planes used in this hiddenline drawing, includes both user specified planes and frustum clipping planes for perspective views. Parameters: clip_id -[out] Optional parameter to get array of clipping plane ids. Returns: The array of clipping planes. Remarks: Frustum clipping planes, if they are present, are in positions 0 to 5 and have id==0. To get the associated clip

◆ GetClippingPlanes() [2/2]

const ON_SimpleArray< ON_PlaneEquation >& ON_HiddenLineDrawing::GetClippingPlanes ( ON_SimpleArray< ON__UINT_PTR > *  clip_id) const

◆ GetHLDPoints()

const ON_SimpleArray< const class ON_HLDPoint*>& ON_HiddenLineDrawing::GetHLDPoints ( )

◆ HasBeenFlattened()

bool ON_HiddenLineDrawing::HasBeenFlattened ( ) const

◆ HiddenLine2World()

const ON_Xform& ON_HiddenLineDrawing::HiddenLine2World ( ) const

HLD to World coordinate System.

◆ IncludeHiddenCurves()

bool ON_HiddenLineDrawing::IncludeHiddenCurves ( bool  include)

Include hidden curves in hidden line drawing Parameters: include -[in] true (default )to include hidden curves Returns: false if hidden curves are not included Note: Hidden curves are included by default. When hidden curves are not included curves can still be marked with visibility of hidden.

When hidden curves are included, all hidden curves are included unless they are duplicates of other hidden or visible curves.

If hidden curves are not needed in the output IncludeHiddenCurves(false) will improve performance.

◆ IncludeTangentEdges()

void ON_HiddenLineDrawing::IncludeTangentEdges ( bool  include)

Include tangent edges in hidden line drawing Parameters: include -[in] true to include tangent edges Note: By default tangent edges are included. To exclude tangent edges use IncludeTangentEdges( false )

◆ IncludeTangentSeams()

bool ON_HiddenLineDrawing::IncludeTangentSeams ( bool  include)

Include tangent seams in hidden line drawing Parameters: include -[in] true (default )to include tangent seams Returns: false if tangent seams are not included Note: This option is only valid if tangent edges are included. By default seams are not included. To include seams use IncludeTangentSeams( true );

◆ IsPerspective()

bool ON_HiddenLineDrawing::IsPerspective ( ) const

◆ IsValid()

bool ON_HiddenLineDrawing::IsValid ( ON_TextLog text_log = nullptr) const

◆ Merge()

bool ON_HiddenLineDrawing::Merge ( ON_HiddenLineDrawing OtherHLD,
ON_Terminator terminator 

Description: If OtherHLD and *this are hidden line drawings of different objects with the same context they can be be merged into a single hidden line drawing. Parameters: OtherHLD - [in] terminator -[in] Optional object to allow caller to terminate computation. Returns: true if *this is the merger of the two input hidden line drawings. Remarks: Hidden line drawings may be merged only if they have the same tolerances, viewports, clipping planes and options. When true is returned Other is left as an empty hidden line drawing.

◆ NumberDrawn()

int ON_HiddenLineDrawing::NumberDrawn ( ) const

Return number of objects present when the last Draw() operation was performed.

◆ operator=()

ON_HiddenLineDrawing& ON_HiddenLineDrawing::operator= ( const ON_HiddenLineDrawing )

◆ SetAbsoluteTolerance()

bool ON_HiddenLineDrawing::SetAbsoluteTolerance ( double  absolute_tolerance)

◆ SetContext()

void ON_HiddenLineDrawing::SetContext ( const ON_HiddenLineDrawing source)

Description: Set the HiddenLineDrawing context from another HiddenLine Drawing Parameters: Source - (in) Source of context information Details: copies, tolerance, view, clipping planes, tangent edges and seams options from source. This should be used on an empty drawing only.

◆ SetParallelViewport()

bool ON_HiddenLineDrawing::SetParallelViewport ( ON_3dVector  CameraDirection,
ON_3dVector  CameraUp 

Description: SetParallelView will set the viewport to a parallel projection.
Parameters: CameraDirection -[in] Camera direction ( pointing toward the scene) in world coordinates. CameraUp -[in] Direction, in world corrdinates, that corresponds to increasing y-direction in the hidden line drawing. Returns: true if the viewport has been set. false if the vectors are linearly dependent.

◆ SetViewport()

bool ON_HiddenLineDrawing::SetViewport ( const ON_Viewport v)

Step II. Specify viewport.

Description: Set the viewport for the hidden line drawing. The viewport supplies the projection that determines the visibility of curves, and the HiddenLineDrawing coordinate system in which the resulting ON_HLDCurve's are represented. The HLD-coordinate system is a right handed system for 3-d model space, in which the 3rd coordinate direction is the projection direction. In particular the z-coordinate direction points from the scene toward the camera. Parameters: v -[in] viewport. A copy of the viewport is made inside of ON_HiddenLineDrawing. Returns: true if viewport has been set Details: Only allowed before calling Draw(..).

For perspective views the "target depth" is used to determine the scale of the results. The target_depth, v.TargetDistance(false), defines the target plane that is the plane perpendicular to the camera axis at this distance from the camera location. The HLD-Coordinate system is scaled 1:1 to world coordinates on the target plane. The HLD_coordinate system is translated in the z-direction so that the target plane has z=0 in HLD-coordinates. If you have a viewport and don't want to think about the choice of target_depth you might want to try: double near = v.FrustumNear(); double far = v.FrustumFar(); double target_distance = .5*(near + far); bool rc = v.SetFrustumNearFar( near, far, 0.0, 0.0, target_distance); if( rc) HLD.SetViewport(v);

Another option is to leave the target_depth unset, or more explicity call v.SetTargetPoint( ON_UNSET_POINT) When the taget point is unset, a target_depth will be computed from the geometry and used to define the HLD coordintate system.

Perspective distortion ( on perspective views only) will scale objects in front (back) of the target plane to be larger (smaller) in HLD-coordinates than in world coordinates. The absolute tolerance is applied in HLD-coordinates so its effect depends on the target_depth setting.

If v is a parallel projection viewport the HLD-coordinate system is the camera coordinate system of v.

For perspective views the transformation from world coordinates to HLD-coordinates is a diagonal scaling of the view transformation from world to clip coordinates. Specifically [ W/2 ] World_to_HLD-coordinates = [ H/2 ] x World_to_clip_coordinates [ (f - n)/2 d ] [ 1.0 ]

where W and H are the width and depth of the view frustum at the target_depth and f and n are the distances to the far and near clipping plane in the viewport, d is chosen so that the target plane is represented as the plane z=0 in HLD-coordinates.

◆ Viewport()

const ON_Viewport& ON_HiddenLineDrawing::Viewport ( ) const

◆ World2HiddenLine()

const ON_Xform& ON_HiddenLineDrawing::World2HiddenLine ( ) const

World to HLD-coordinate System.

The ON_HiddenLineDrawing HLD-coordinate system is a right handed system in which the 3rd coordinate is the projection direction. In particular the z coordinate direction points from the sceene to the camera.

Member Data Documentation

◆ m_curve

const ON_SimpleArray< const class ON_HLDCurve*>& ON_HiddenLineDrawing::m_curve

◆ m_full_curve

const ON_SimpleArray< const class ON_HLDFullCurve*>& ON_HiddenLineDrawing::m_full_curve

Step VI. After Draw() the results are available as arrays of ON_HLDFullCurve, ON_HLDCurve and ON_HLDPoint. m_curve, m_full_curve and GetHLDPoints() are the results of the draw operation.

◆ m_object

const ON_SimpleArray<const class ON_HLD_Object*>& ON_HiddenLineDrawing::m_object

m_object is the array of objects that that have been added and will be used in the Draw() operation.