Rhino C++ API  7.21
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
ONX_ModelTest Class Reference

#include <opennurbs_extensions.h>

Public Types

enum  Result : unsigned char {
  Result::Unset = 0, Result::Fail = 1, Result::Errors = 2, Result::Warnings = 3,
  Result::Pass = 4, Result::Skip = 5
}
 ONX_ModelTest::Result reports the result of a test. More...
 
enum  Type : unsigned char {
  Type::Unset = 0, Type::Read = 1, Type::ReadWrite = 2, Type::ReadWriteRead = 3,
  Type::ReadWriteReadCompare = 4
}
 ONX_ModelTest::Type identifies the type of file reading test to perform. More...
 

Public Member Functions

 ONX_ModelTest ()=default
 
 ONX_ModelTest (const ONX_ModelTest &)=default
 
 ~ONX_ModelTest ()=default
 
void Dump (ON_TextLog &text_log) const
 
bool DumpReadWriteReadModel () const
 
bool DumpReadWriteReadModel (const wchar_t *text_file_full_path) const
 
bool DumpReadWriteReadModel (ON_TextLog &text_log) const
 
bool DumpSourceModel () const
 
bool DumpSourceModel (const wchar_t *text_file_full_path) const
 
bool DumpSourceModel (ON_TextLog &text_log) const
 
ONX_ErrorCounter ErrorCounter () const
 
ONX_ErrorCounter ErrorCounter (ONX_ModelTest::Type test_type) const
 
ONX_ModelTestoperator= (const ONX_ModelTest &)=default
 
bool ReadTest (const char *file_path, ONX_ModelTest::Type test_type, bool bKeepModels, const char *text_log_file_path, ON_TextLog *text_log)
 
bool ReadTest (const wchar_t *file_path, ONX_ModelTest::Type test_type, bool bKeepModels, const wchar_t *text_log_file_path, ON_TextLog *text_log)
 
bool ReadTest (FILE *fp, ONX_ModelTest::Type test_type, bool bKeepModels, const wchar_t *text_log_file_path, ON_TextLog *text_log)
 
bool ReadTest (ON_BinaryArchive &archive, ONX_ModelTest::Type test_type, bool bKeepModels, const wchar_t *text_log_file_path, ON_TextLog *text_log)
 
std::shared_ptr< ONX_ModelReadWriteReadModel () const
 
const ON_SHA1_Hash ReadWriteReadModelHash ()
 
const ON_wString Source3dmFilePath () const
 
unsigned int Source3dmFileVersion () const
 
std::shared_ptr< ONX_ModelSourceModel () const
 
const ON_SHA1_Hash SourceModelHash ()
 
ONX_ModelTest::Result TestResult () const
 
ONX_ModelTest::Result TestResult (ONX_ModelTest::Type test_type)
 
ONX_ModelTest::Type TestType () const
 Test that was performed. More...
 
const ON_wString TextLogSource3dmFilePath () const
 

Static Public Member Functions

static bool DumpModel (const ONX_Model *model, ON_TextLog &text_log)
 
static ONX_ModelTest::Result ResultFromErrorCounter (ONX_ErrorCounter error_count, ONX_ModelTest::Result no_errors_result)
 
static const char * ResultToString (ONX_ModelTest::Result result)
 
static const wchar_t * ResultToWideString (ONX_ModelTest::Result result)
 
static bool SkipCompare (unsigned int source_3dm_file_version)
 
static const char * TestTypeToString (ONX_ModelTest::Type test_type)
 
static const wchar_t * TestTypeToWideString (ONX_ModelTest::Type test_type)
 
static ONX_ModelTest::Result WorstResult (ONX_ModelTest::Result a, ONX_ModelTest::Result b)
 

Static Public Attributes

static const ONX_ModelTest Unset
 

Member Enumeration Documentation

◆ Result

enum ONX_ModelTest::Result : unsigned char
strong

ONX_ModelTest::Result reports the result of a test.

Enumerator
Unset 

summary> Test result is not set. /summary> summary> Test failed to complete. /summary>

Fail 

summary> Test was performed and completed, but at least one ON_ERROR occured. /summary>

Errors 

summary> Test was performed and completed, but at least one ON_WARNING occured. /summary>

Warnings 

summary> Test was performed and passed. /summary>

Pass 

summary> Test was not perfomed because the input did not satisfy prerequisites or an earlier test failed. For example, if a ONX_ModelReadTest::TestType::ReadWriteReadCompare test is requested and the source file is a Rhino 1 file, the compare test is skipped. For example, if a ONX_ModelReadTest::TestType::ReadWriteRead test is requested and the Write test failes, the second Read test is skipped. /summary>

Skip 

◆ Type

enum ONX_ModelTest::Type : unsigned char
strong

ONX_ModelTest::Type identifies the type of file reading test to perform.

< XXRH_C_SHARED_ENUM ///< [ONX_ModelTest::Type] [Rhino.Geometry.Something.Type] [nested:byte]

Enumerator
Unset 

summary> Read the source 3dm file. /summary>

Read 

summary> Read the source 3dm file and write one or two temporary 3dm files. The original source file is not modified. If the 3dm version of the source file is < ON_BinaryArchive::CurrentArchiveVersion(), then two temporary 3dm files are written, the first with 3dm version = ON_BinaryArchive::CurrentArchiveVersion()-10 and the second with 3dm version = ON_BinaryArchive::CurrentArchiveVersion(). For example, if Rhino 6 is the current version of Rhino and a file written by Rhino 5 is read, then both a temporary Rhino 5 and a temporary Rhino 6 3dm file are written. /summary>

ReadWrite 

summary> Perform the ReadWrite test and read the temporary files. /summary>

ReadWriteRead 

summary> Perform the ReadWriteRead test. If one of the temporary files has the same 3dm version as the original source file, verify that the ONX_Models created by reading the original 3dm file and the temporary 3dm file with the same version have identical values of ONX_Model::ContentHash(). /summary>

ReadWriteReadCompare 

Constructor & Destructor Documentation

◆ ONX_ModelTest() [1/2]

ONX_ModelTest::ONX_ModelTest ( )
default

◆ ~ONX_ModelTest()

ONX_ModelTest::~ONX_ModelTest ( )
default

◆ ONX_ModelTest() [2/2]

ONX_ModelTest::ONX_ModelTest ( const ONX_ModelTest )
default

Member Function Documentation

◆ Dump()

void ONX_ModelTest::Dump ( ON_TextLog text_log) const

Description: Prints test results.

◆ DumpModel()

static bool ONX_ModelTest::DumpModel ( const ONX_Model model,
ON_TextLog text_log 
)
static

Description: Prints the model context to text_log.

◆ DumpReadWriteReadModel() [1/3]

bool ONX_ModelTest::DumpReadWriteReadModel ( ) const

Description: Prints the model obtained from the last read in the read-write-read test to with the file ONX_ModelText_copy<PLATFORM>.txt appended to the original source file name. Remark: Call after test is completed.

◆ DumpReadWriteReadModel() [2/3]

bool ONX_ModelTest::DumpReadWriteReadModel ( const wchar_t *  text_file_full_path) const

Description: Prints the model obtained from the last read in the read-write-read test to with the file ONX_ModelText_copy<PLATFORM>.txt appended to a text file with the specified name. Remark: Call after test is completed.

◆ DumpReadWriteReadModel() [3/3]

bool ONX_ModelTest::DumpReadWriteReadModel ( ON_TextLog text_log) const

Description: Prints the model obtained from the last read in the read-write-read test to with the file ONX_ModelText_copy<PLATFORM>.txt appended to the text_log. Remark: Call after test is completed.

◆ DumpSourceModel() [1/3]

bool ONX_ModelTest::DumpSourceModel ( ) const

Description: Prints the source model context to text file next to the source file with the file ONX_ModelText_original<PLATFORM>.txt appended to the source file name. Remark: Call after test is completed.

◆ DumpSourceModel() [2/3]

bool ONX_ModelTest::DumpSourceModel ( const wchar_t *  text_file_full_path) const

Description: Prints the source model context to text_log. Remark: Call after test is completed.

◆ DumpSourceModel() [3/3]

bool ONX_ModelTest::DumpSourceModel ( ON_TextLog text_log) const

Description: Prints the source model context to text_log. Remark: Call after test is completed.

◆ ErrorCounter() [1/2]

ONX_ErrorCounter ONX_ModelTest::ErrorCounter ( ) const

Returns: Total number of failures, errors, and warnings for all tests that were performed.

◆ ErrorCounter() [2/2]

ONX_ErrorCounter ONX_ModelTest::ErrorCounter ( ONX_ModelTest::Type  test_type) const

Returns: Total number of failures, errors, and warnings for all tests that were performed.

◆ operator=()

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

◆ ReadTest() [1/4]

bool ONX_ModelTest::ReadTest ( const char *  file_path,
ONX_ModelTest::Type  test_type,
bool  bKeepModels,
const char *  text_log_file_path,
ON_TextLog text_log 
)

Description: Test ONX_Model::Read() and ONX_Model::Write(). Parameters: file_path - [in] file path test_type - [in] test to perform. bKeepModels - [in] If true, then the ONX_Models created by reading 3dm archives are saved so the can be examined after the tests complete. text_log_file_path - [in] If not empty, the string to use for file_path in the output text_log. This is used to create logs on different computers that can be compared. text_log - [in] If text_log is not nullptr, then a summary of the test is sent to text_log. Returns: True if every test passed with no warnings or errors. False if a test failed or warnings or errors occured.

◆ ReadTest() [2/4]

bool ONX_ModelTest::ReadTest ( const wchar_t *  file_path,
ONX_ModelTest::Type  test_type,
bool  bKeepModels,
const wchar_t *  text_log_file_path,
ON_TextLog text_log 
)

Description: ONX_Model::ReadTest() can be used to test reading a specific file. Parameters: file_path - [in] file path test_type - [in] test to perform. bKeepModels - [in] If true, then the ONX_Models created by reading 3dm archives are saved so the can be examined after the tests complete. text_log_file_path - [in] If not empty, the string to use for file_path in the output text_log. This is used to create logs on different computers that can be compared. text_log - [in] If text_log is not nullptr, then a summary of the test is sent to text_log. Returns: True if every test passed with no warnings or errors. False if a test failed or warnings or errors occured.

◆ ReadTest() [3/4]

bool ONX_ModelTest::ReadTest ( FILE *  fp,
ONX_ModelTest::Type  test_type,
bool  bKeepModels,
const wchar_t *  text_log_file_path,
ON_TextLog text_log 
)

Description: ONX_Model::ReadTest() can be used to test reading a specific file. Parameters: fp - [in] fp pointer to a file opened with ON_FileStream::Opent(...,"rb"); test_type - [in] test to perform. bKeepModels - [in] If true, then the ONX_Models created by reading 3dm archives are saved so the can be examined after the tests complete. text_log_file_path - [in] If not empty, the string to use for file_path in the output text_log. This is used to create logs on different computers that can be compared. text_log - [in] If text_log is not nullptr, then a summary of the test is sent to text_log. Returns: True if every test passed with no warnings or errors. False if a test failed or warnings or errors occured.

◆ ReadTest() [4/4]

bool ONX_ModelTest::ReadTest ( ON_BinaryArchive archive,
ONX_ModelTest::Type  test_type,
bool  bKeepModels,
const wchar_t *  text_log_file_path,
ON_TextLog text_log 
)

Description: ONX_Model::Test() can be used to test reading a specific file. Parameters: archive - [in]
test_type - [in] test to perform. bKeepModels - [in] If true, then the ONX_Models created by reading 3dm archives are saved so the can be examined after the tests complete. text_log_file_path - [in] If not empty, the string to use for file_path in the output text_log. This is used to create logs on different computers that can be compared. text_log - [in] If text_log is not nullptr, then a summary of the test is sent to text_log. Returns: True if every test passed with no warnings or errors. False if a test failed or warnings or errors occured.

◆ ReadWriteReadModel()

std::shared_ptr<ONX_Model> ONX_ModelTest::ReadWriteReadModel ( ) const

Returns: nullptr if the read write read test was not performed or was run with bKeepModels=false. Otherwise, a pointer to the result of the read write read test.

◆ ReadWriteReadModelHash()

const ON_SHA1_Hash ONX_ModelTest::ReadWriteReadModelHash ( )

◆ ResultFromErrorCounter()

static ONX_ModelTest::Result ONX_ModelTest::ResultFromErrorCounter ( ONX_ErrorCounter  error_count,
ONX_ModelTest::Result  no_errors_result 
)
static

Parameters: error_count - [in] no_errors_result - [in] result to return when 0 = error_count.TotalCount().

◆ ResultToString()

static const char* ONX_ModelTest::ResultToString ( ONX_ModelTest::Result  result)
static

◆ ResultToWideString()

static const wchar_t* ONX_ModelTest::ResultToWideString ( ONX_ModelTest::Result  result)
static

◆ SkipCompare()

static bool ONX_ModelTest::SkipCompare ( unsigned int  source_3dm_file_version)
static

◆ Source3dmFilePath()

const ON_wString ONX_ModelTest::Source3dmFilePath ( ) const

Returns: The name of the source 3dm file.

◆ Source3dmFileVersion()

unsigned int ONX_ModelTest::Source3dmFileVersion ( ) const

Returns: Version of the 3dm fie, 1,2,3,4,5,50,60,...

◆ SourceModel()

std::shared_ptr<ONX_Model> ONX_ModelTest::SourceModel ( ) const

Returns: nullptr if the test was run with bKeepModels=false or the source archive could not be read. Otherwise, a pointer to the source model.

◆ SourceModelHash()

const ON_SHA1_Hash ONX_ModelTest::SourceModelHash ( )

◆ TestResult() [1/2]

ONX_ModelTest::Result ONX_ModelTest::TestResult ( ) const

Returns: Worst result for any test that was attempted.

◆ TestResult() [2/2]

ONX_ModelTest::Result ONX_ModelTest::TestResult ( ONX_ModelTest::Type  test_type)

Parameters: test_type - [in] Returns: Result of the test identified by the test_type parameter.

◆ TestType()

ONX_ModelTest::Type ONX_ModelTest::TestType ( ) const

Test that was performed.

◆ TestTypeToString()

static const char* ONX_ModelTest::TestTypeToString ( ONX_ModelTest::Type  test_type)
static

◆ TestTypeToWideString()

static const wchar_t* ONX_ModelTest::TestTypeToWideString ( ONX_ModelTest::Type  test_type)
static

XXRH_C_SHARED_ENUM ///< [ONX_ModelTest::Result] [Rhino.Geometry.Something.Result] [nested:byte]

◆ TextLogSource3dmFilePath()

const ON_wString ONX_ModelTest::TextLogSource3dmFilePath ( ) const

Returns: The string used in the output log to identify the source 3dm file.

◆ WorstResult()

static ONX_ModelTest::Result ONX_ModelTest::WorstResult ( ONX_ModelTest::Result  a,
ONX_ModelTest::Result  b 
)
static

Member Data Documentation

◆ Unset

const ONX_ModelTest ONX_ModelTest::Unset
static