Rhino C++ API  8.13
Public Member Functions | Static Public Member Functions | Static Public Attributes | Friends | List of all members
ON_SubDHash Class Reference

ON_SubDHash provides a simple way to save a SubD's vertex, edge, and face SHA1 hashes. Typically it is used when a calculation needs to know if the current SubD has is geometrically identical to a previous SubD. When speed is not important, comparing the current value of ON_SubD::GeometryHash() to a previously save value of ON_SubD::GeometryHash() is functionally identical but typically much slower when the SubDs are different. More...

#include <opennurbs_subd.h>

Public Member Functions

 ON_SubDHash ()=default
 
 ON_SubDHash (const ON_SubDHash &)=default
 
 ~ON_SubDHash ()=default
 
void Dump (ON_TextLog &) const
 
unsigned int EdgeCount () const
 Copied from the SubD when the hash is created. More...
 
const ON_SHA1_Hash EdgeHash () const
 If two SubDs have identical EdgeHash() values, then the SubD edge information associated with HashType() is identical. More...
 
unsigned int FaceCount () const
 Copied from the SubD when the hash is created. More...
 
const ON_SHA1_Hash FaceHash () const
 If two SubDs have identical FaceHash() values, then the SubD face information associated with HashType() is identical. More...
 
ON_SubDHashType HashType () const
 
bool IsEmpty () const
 
bool IsNotEmpty () const
 
ON_SubDHashoperator= (const ON_SubDHash &)=default
 
bool Read (class ON_BinaryArchive &)
 
ON__UINT64 SubDGeometryContentSerialNumber () const
 The geometry content serial number can be used to quickly determine if a SubD is exactly the instance used to create this ON_SubDHash. If the geometry content serial numbers are equal, then the SubD is identical to the one use to create the hash. If the geometry content serial numbers differ, the current SubD hashes need to be checked against this to see what, if anything, changed. For example, moving a vertex will not change a topology hash. More...
 
const ON_SHA1_Hash SubDHash () const
 If two SubDs have identical SubDHash() values, then the SubD vertex, edge, and face information associated with HashType() is identical. More...
 
ON__UINT64 SubDRuntimeSerialNumber () const
 The runtime serial number can be used to identify the SubD that was hashed to created this ON_SubDHash. More...
 
unsigned int VertexCount () const
 Copied from the SubD when the hash is created. More...
 
const ON_SHA1_Hash VertexHash () const
 If two SubDs have identical VertexHash() values, then the SubD vertex information associated with HashType() is identical. More...
 
bool Write (class ON_BinaryArchive &) const
 

Static Public Member Functions

static int Compare (const ON_SubDHash &lhs, const ON_SubDHash &rhs)
 Dictionary compare of VertexCount(), EdgeCount(), FaceCount(), VertexHash(), EdgeHash(), and FaceHash() in that order. More...
 
static const ON_SubDHash Create (ON_SubDHashType hash_type, const class ON_SubD &subd)
 Saves the counts and hashes of the specified type. More...
 
static const ON_SubDHash Create (ON_SubDHashType hash_type, const class ON_SubDimple *subdimple)
 

Static Public Attributes

static const ON_SubDHash Empty
 All counts are zero and all hashes are ON_SHA1::EmptyContentHash. More...
 

Friends

class ON_SubDimple
 

Detailed Description

ON_SubDHash provides a simple way to save a SubD's vertex, edge, and face SHA1 hashes. Typically it is used when a calculation needs to know if the current SubD has is geometrically identical to a previous SubD. When speed is not important, comparing the current value of ON_SubD::GeometryHash() to a previously save value of ON_SubD::GeometryHash() is functionally identical but typically much slower when the SubDs are different.

Constructor & Destructor Documentation

◆ ON_SubDHash() [1/2]

ON_SubDHash::ON_SubDHash ( )
default

◆ ~ON_SubDHash()

ON_SubDHash::~ON_SubDHash ( )
default

◆ ON_SubDHash() [2/2]

ON_SubDHash::ON_SubDHash ( const ON_SubDHash )
default

Member Function Documentation

◆ Compare()

static int ON_SubDHash::Compare ( const ON_SubDHash lhs,
const ON_SubDHash rhs 
)
static

Dictionary compare of VertexCount(), EdgeCount(), FaceCount(), VertexHash(), EdgeHash(), and FaceHash() in that order.

NOTE WELL: SubDRuntimeSerialNumber() and SubdGeometryContentSerialNumber() are not compared because the reason this class exists is for it to be used to see if two different SubDs have identical content.

Parameters
lhs
rhs
Returns
-1: lhs < rhs 0: lhs == rsh 1: lhs > rhs

◆ Create() [1/2]

static const ON_SubDHash ON_SubDHash::Create ( ON_SubDHashType  hash_type,
const class ON_SubD subd 
)
static

Saves the counts and hashes of the specified type.

Saves the counts and hashes of the specified type.

Parameters
hash_type
subd
Returns

◆ Create() [2/2]

static const ON_SubDHash ON_SubDHash::Create ( ON_SubDHashType  hash_type,
const class ON_SubDimple subdimple 
)
static

◆ Dump()

void ON_SubDHash::Dump ( ON_TextLog ) const

◆ EdgeCount()

unsigned int ON_SubDHash::EdgeCount ( ) const

Copied from the SubD when the hash is created.

Returns
Number of hashed edges.

◆ EdgeHash()

const ON_SHA1_Hash ON_SubDHash::EdgeHash ( ) const

If two SubDs have identical EdgeHash() values, then the SubD edge information associated with HashType() is identical.

Returns
A SHA1 hash of the SubD's edge information associated with HashType().

◆ FaceCount()

unsigned int ON_SubDHash::FaceCount ( ) const

Copied from the SubD when the hash is created.

Returns
Number of hashed faces.

◆ FaceHash()

const ON_SHA1_Hash ON_SubDHash::FaceHash ( ) const

If two SubDs have identical FaceHash() values, then the SubD face information associated with HashType() is identical.

Returns
A SHA1 hash of the SubD's face information associated with HashType().

◆ HashType()

ON_SubDHashType ON_SubDHash::HashType ( ) const

◆ IsEmpty()

bool ON_SubDHash::IsEmpty ( ) const

Returns: True if vertex count is 0 or HashType is unset.

◆ IsNotEmpty()

bool ON_SubDHash::IsNotEmpty ( ) const

Returns: True if vertex count is > 0 and HashType is geometry or toplology.

◆ operator=()

ON_SubDHash& ON_SubDHash::operator= ( const ON_SubDHash )
default

◆ Read()

bool ON_SubDHash::Read ( class ON_BinaryArchive )

◆ SubDGeometryContentSerialNumber()

ON__UINT64 ON_SubDHash::SubDGeometryContentSerialNumber ( ) const

The geometry content serial number can be used to quickly determine if a SubD is exactly the instance used to create this ON_SubDHash. If the geometry content serial numbers are equal, then the SubD is identical to the one use to create the hash. If the geometry content serial numbers differ, the current SubD hashes need to be checked against this to see what, if anything, changed. For example, moving a vertex will not change a topology hash.

Returns
Returns: If this hash was created from an ON_SubD, then the value of subd.GeometryContentSerialNumber() at the at the instant this hash was created is returned. Otherwise, 0 is returned.

◆ SubDHash()

const ON_SHA1_Hash ON_SubDHash::SubDHash ( ) const

If two SubDs have identical SubDHash() values, then the SubD vertex, edge, and face information associated with HashType() is identical.

Returns
A SHA1 hash of the SubD's vertex, edge, and face information associated with HashType().

◆ SubDRuntimeSerialNumber()

ON__UINT64 ON_SubDHash::SubDRuntimeSerialNumber ( ) const

The runtime serial number can be used to identify the SubD that was hashed to created this ON_SubDHash.

Returns
If this hash was created from an ON_SubD, then the value of subd.RuntimeSerialNumber() is returned. Otherwise, 0 is returned.

◆ VertexCount()

unsigned int ON_SubDHash::VertexCount ( ) const

Copied from the SubD when the hash is created.

Returns
Number of hashed vertices.

◆ VertexHash()

const ON_SHA1_Hash ON_SubDHash::VertexHash ( ) const

If two SubDs have identical VertexHash() values, then the SubD vertex information associated with HashType() is identical.

Returns
A SHA1 hash of the SubD's vertex information associated with HashType().

◆ Write()

bool ON_SubDHash::Write ( class ON_BinaryArchive ) const

Friends And Related Function Documentation

◆ ON_SubDimple

friend class ON_SubDimple
friend

Member Data Documentation

◆ Empty

const ON_SubDHash ON_SubDHash::Empty
static

All counts are zero and all hashes are ON_SHA1::EmptyContentHash.