-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathopennurbs_group.cpp
118 lines (102 loc) · 2.74 KB
/
opennurbs_group.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/* $NoKeywords: $ */
/*
//
// Copyright (c) 1993-2012 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>.
//
////////////////////////////////////////////////////////////////
*/
#include "opennurbs.h"
ON_OBJECT_IMPLEMENT( ON_Group, ON_Object, "721D9F97-3645-44c4-8BE6-B2CF697D25CE" );
ON_Group::ON_Group() : m_group_index(-1)
{
memset(&m_group_id,0,sizeof(m_group_id));
}
ON_Group::~ON_Group()
{
}
//////////////////////////////////////////////////////////////////////
//
// ON_Object overrides
ON_BOOL32 ON_Group::IsValid( ON_TextLog* text_log ) const
{
return ( m_group_name.Length() > 0 && m_group_index >= 0 );
}
void ON_Group::Dump( ON_TextLog& dump ) const
{
const wchar_t* name = GroupName();
if ( !name )
name = L"";
dump.Print("group index = %d\n",m_group_index);
dump.Print("group name = \"%ls\"\n",name);
}
ON_BOOL32 ON_Group::Write(
ON_BinaryArchive& file // serialize definition to binary archive
) const
{
ON_BOOL32 rc = file.Write3dmChunkVersion(1,1);
// version 1.0 fields
if (rc) rc = file.WriteInt(m_group_index);
if (rc) rc = file.WriteString(m_group_name);
// version 1.1 fields
if (rc) rc = file.WriteUuid(m_group_id);
return rc;
}
ON_BOOL32 ON_Group::Read(
ON_BinaryArchive& file // restore definition from binary archive
)
{
m_group_index = -1;
m_group_name.Empty();
memset(&m_group_id,0,sizeof(m_group_id));
int major_version = 0;
int minor_version = 0;
ON_BOOL32 rc = file.Read3dmChunkVersion(&major_version,&minor_version);
if ( major_version == 1 )
{
if (rc) rc = file.ReadInt( &m_group_index );
if (rc) rc = file.ReadString( m_group_name );
if ( minor_version >= 1 )
{
if (rc) rc = file.ReadUuid( m_group_id );
}
}
else
rc = false;
return rc;
}
//////////////////////////////////////////////////////////////////////
//
// Interface
void ON_Group::SetGroupName( const wchar_t* s )
{
m_group_name = s;
}
void ON_Group::SetGroupName( const char* s )
{
m_group_name = s;
}
void ON_Group::GetGroupName( ON_wString& s ) const
{
s = m_group_name;
}
const wchar_t* ON_Group::GroupName() const
{
const wchar_t* s = m_group_name;
return s;
}
void ON_Group::SetGroupIndex(int i )
{
m_group_index = i;
}
int ON_Group::GroupIndex() const
{
return m_group_index;
}