mirror of
https://github.com/mcneel/opennurbs.git
synced 2026-03-23 19:01:03 +08:00
Sync changes from upstream repository
Co-authored-by: Alain <alain@mcneel.com> Co-authored-by: Andrew Le Bihan <andy@mcneel.com> Co-authored-by: Bozo <bozo@mcneel.com> Co-authored-by: chuck <chuck@mcneel.com> Co-authored-by: Dale Fugier <dale@mcneel.com> Co-authored-by: Giulio Piacentino <giulio@mcneel.com> Co-authored-by: John Croudy <croudyj@gmail.com> Co-authored-by: Mikko Oksanen <mikko@mcneel.com> Co-authored-by: Pierre Cuvilliers <pierre@mcneel.com> Co-authored-by: Steve Baer <steve@mcneel.com>
This commit is contained in:
@@ -1,121 +1,121 @@
|
||||
/* $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"
|
||||
|
||||
#if !defined(ON_COMPILING_OPENNURBS)
|
||||
// This check is included in all opennurbs source .c and .cpp files to insure
|
||||
// ON_COMPILING_OPENNURBS is defined when opennurbs source is compiled.
|
||||
// When opennurbs source is being compiled, ON_COMPILING_OPENNURBS is defined
|
||||
// and the opennurbs .h files alter what is declared and how it is declared.
|
||||
#error ON_COMPILING_OPENNURBS must be defined when compiling opennurbs
|
||||
#endif
|
||||
|
||||
ON_OBJECT_IMPLEMENT( ON_Group, ON_ModelComponent, "721D9F97-3645-44c4-8BE6-B2CF697D25CE" );
|
||||
|
||||
const ON_Group * ON_Group::FromModelComponentRef(
|
||||
const ON_ModelComponentReference & model_component_reference,
|
||||
const ON_Group * none_return_value
|
||||
)
|
||||
{
|
||||
const ON_Group* group = ON_Group::Cast(model_component_reference.ModelComponent());
|
||||
return (nullptr != group) ? group : none_return_value;
|
||||
}
|
||||
|
||||
ON_Group::ON_Group() ON_NOEXCEPT
|
||||
: ON_ModelComponent(ON_ModelComponent::Type::Group)
|
||||
{}
|
||||
|
||||
ON_Group::ON_Group(const ON_Group& src)
|
||||
: ON_ModelComponent(ON_ModelComponent::Type::Group, src)
|
||||
{}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// ON_Object overrides
|
||||
|
||||
bool ON_Group::IsValid( ON_TextLog* text_log ) const
|
||||
{
|
||||
return (IdIsNotNil() && NameIsSet() && Index() >= 0);
|
||||
}
|
||||
|
||||
void ON_Group::Dump( ON_TextLog& text_log ) const
|
||||
{
|
||||
ON_ModelComponent::Dump(text_log);
|
||||
}
|
||||
|
||||
bool ON_Group::Internal_WriteV5(
|
||||
ON_BinaryArchive& file // serialize definition to binary archive
|
||||
) const
|
||||
{
|
||||
bool rc = file.Write3dmChunkVersion(1,1);
|
||||
// version 1.0 fields
|
||||
if (rc) rc = file.Write3dmReferencedComponentIndex(ON_ModelComponent::Type::Group,Index());
|
||||
if (rc) rc = file.WriteString(Name());
|
||||
// version 1.1 fields
|
||||
if (rc) rc = file.WriteUuid(Id());
|
||||
return rc;
|
||||
}
|
||||
|
||||
bool ON_Group::Internal_ReadV5(
|
||||
ON_BinaryArchive& file // restore definition from binary archive
|
||||
)
|
||||
{
|
||||
*this = ON_Group::Unset;
|
||||
|
||||
int major_version = 0;
|
||||
int minor_version = 0;
|
||||
bool rc = file.Read3dmChunkVersion(&major_version,&minor_version);
|
||||
if ( major_version == 1 )
|
||||
{
|
||||
int group_index = Index();
|
||||
if (rc) rc = file.ReadInt( &group_index );
|
||||
if (rc) SetIndex(group_index);
|
||||
ON_wString group_name;
|
||||
if (rc) rc = file.ReadString( group_name );
|
||||
if (rc)
|
||||
SetName(group_name);
|
||||
if ( minor_version >= 1 )
|
||||
{
|
||||
ON_UUID group_id = ON_nil_uuid;
|
||||
if (rc) rc = file.ReadUuid( group_id );
|
||||
if (rc) SetId(group_id);
|
||||
}
|
||||
if (rc && IdIsNil() )
|
||||
{
|
||||
// modern times require unique ids.
|
||||
SetId();
|
||||
}
|
||||
}
|
||||
else
|
||||
rc = false;
|
||||
return rc;
|
||||
}
|
||||
|
||||
bool ON_Group::Write(
|
||||
ON_BinaryArchive& archive // serialize definition to binary archive
|
||||
) const
|
||||
{
|
||||
return Internal_WriteV5(archive);
|
||||
}
|
||||
|
||||
bool ON_Group::Read(
|
||||
ON_BinaryArchive& archive // restore definition from binary archive
|
||||
)
|
||||
{
|
||||
return Internal_ReadV5(archive);
|
||||
}
|
||||
|
||||
/* $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"
|
||||
|
||||
#if !defined(ON_COMPILING_OPENNURBS)
|
||||
// This check is included in all opennurbs source .c and .cpp files to insure
|
||||
// ON_COMPILING_OPENNURBS is defined when opennurbs source is compiled.
|
||||
// When opennurbs source is being compiled, ON_COMPILING_OPENNURBS is defined
|
||||
// and the opennurbs .h files alter what is declared and how it is declared.
|
||||
#error ON_COMPILING_OPENNURBS must be defined when compiling opennurbs
|
||||
#endif
|
||||
|
||||
ON_OBJECT_IMPLEMENT( ON_Group, ON_ModelComponent, "721D9F97-3645-44c4-8BE6-B2CF697D25CE" );
|
||||
|
||||
const ON_Group * ON_Group::FromModelComponentRef(
|
||||
const ON_ModelComponentReference & model_component_reference,
|
||||
const ON_Group * none_return_value
|
||||
)
|
||||
{
|
||||
const ON_Group* group = ON_Group::Cast(model_component_reference.ModelComponent());
|
||||
return (nullptr != group) ? group : none_return_value;
|
||||
}
|
||||
|
||||
ON_Group::ON_Group() ON_NOEXCEPT
|
||||
: ON_ModelComponent(ON_ModelComponent::Type::Group)
|
||||
{}
|
||||
|
||||
ON_Group::ON_Group(const ON_Group& src)
|
||||
: ON_ModelComponent(ON_ModelComponent::Type::Group, src)
|
||||
{}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// ON_Object overrides
|
||||
|
||||
bool ON_Group::IsValid( ON_TextLog* text_log ) const
|
||||
{
|
||||
return (IdIsNotNil() && NameIsSet() && Index() >= 0);
|
||||
}
|
||||
|
||||
void ON_Group::Dump( ON_TextLog& text_log ) const
|
||||
{
|
||||
ON_ModelComponent::Dump(text_log);
|
||||
}
|
||||
|
||||
bool ON_Group::Internal_WriteV5(
|
||||
ON_BinaryArchive& file // serialize definition to binary archive
|
||||
) const
|
||||
{
|
||||
bool rc = file.Write3dmChunkVersion(1,1);
|
||||
// version 1.0 fields
|
||||
if (rc) rc = file.Write3dmReferencedComponentIndex(ON_ModelComponent::Type::Group,Index());
|
||||
if (rc) rc = file.WriteString(Name());
|
||||
// version 1.1 fields
|
||||
if (rc) rc = file.WriteUuid(Id());
|
||||
return rc;
|
||||
}
|
||||
|
||||
bool ON_Group::Internal_ReadV5(
|
||||
ON_BinaryArchive& file // restore definition from binary archive
|
||||
)
|
||||
{
|
||||
*this = ON_Group::Unset;
|
||||
|
||||
int major_version = 0;
|
||||
int minor_version = 0;
|
||||
bool rc = file.Read3dmChunkVersion(&major_version,&minor_version);
|
||||
if ( major_version == 1 )
|
||||
{
|
||||
int group_index = Index();
|
||||
if (rc) rc = file.ReadInt( &group_index );
|
||||
if (rc) SetIndex(group_index);
|
||||
ON_wString group_name;
|
||||
if (rc) rc = file.ReadString( group_name );
|
||||
if (rc)
|
||||
SetName(group_name);
|
||||
if ( minor_version >= 1 )
|
||||
{
|
||||
ON_UUID group_id = ON_nil_uuid;
|
||||
if (rc) rc = file.ReadUuid( group_id );
|
||||
if (rc) SetId(group_id);
|
||||
}
|
||||
if (rc && IdIsNil() )
|
||||
{
|
||||
// modern times require unique ids.
|
||||
SetId();
|
||||
}
|
||||
}
|
||||
else
|
||||
rc = false;
|
||||
return rc;
|
||||
}
|
||||
|
||||
bool ON_Group::Write(
|
||||
ON_BinaryArchive& archive // serialize definition to binary archive
|
||||
) const
|
||||
{
|
||||
return Internal_WriteV5(archive);
|
||||
}
|
||||
|
||||
bool ON_Group::Read(
|
||||
ON_BinaryArchive& archive // restore definition from binary archive
|
||||
)
|
||||
{
|
||||
return Internal_ReadV5(archive);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user