Ejemplo n.º 1
0
int ON_DisplayMaterialRef::Compare(const ON_DisplayMaterialRef& other) const
{
  int i = ON_UuidCompare(m_viewport_id,other.m_viewport_id);
  if (0==i)
    i = ON_UuidCompare(m_display_material_id,other.m_display_material_id);
  return i;
}
Ejemplo n.º 2
0
BOOL ON_UserData::IsValid( ON_TextLog* text_log ) const
{
  if ( 0 == ON_UuidCompare( &m_userdata_uuid, &ON_nil_uuid ) )
  {
    if ( 0 != text_log )
    {
      text_log->Print("invalid userdata - m_userdata_uuid = nil\n");
    }
    return false;
  }

  if ( 0 == ON_UuidCompare( m_userdata_uuid, ON_UserData::ClassId()->Uuid() ) )
  {
    if ( 0 != text_log )
    {
      text_log->Print("invalid userdata - m_userdata_uuid in use. Use guidgen to get a unique id.\n");
    }
    return false;
  }

  if ( Archive() && 0 == ON_UuidCompare( ClassId()->Uuid(), ON_UserData::ClassId()->Uuid() ) )
  {
    // 8 January 2004 Dale Lear:
    //  I added this test to help developers remember to use
    //  the ON_DECLARE_OBJECT/ON_IMPLEMENT_OBJECT macros when
    //  they create user data that gets archived.
    if ( 0 != text_log )
    {
      text_log->Print("invalid userdata - classes derived from ON_UserData that get saved in 3dm archives must have a class id and name defined by ON_OBJECT_DECLARE/ON_OBJECT_IMPLEMENT.\n");
    }
    return false;
  }

  return true;
}
Ejemplo n.º 3
0
int ON__ClassIdDumpNode::CompareClassName( const class ON__ClassIdDumpNode& other ) const
{
  int rc = 0;
  const ON_ClassId* a = m_class_id;
  const ON_ClassId* b = other.m_class_id;
  if ( a != b )
  {
    if ( 0 == a )
    {
      rc = -1;
    }
    else if ( 0 == b )
      rc = 1;
    else
    {
      const char* a_name = a->ClassName();
      const char* b_name = b->ClassName();
      if ( 0 == a_name )
      {
        if ( 0 == b_name )
        {
          rc = b->Mark() - a->Mark();
          if ( 0 == rc )
            rc = ON_UuidCompare(a->Uuid(),b->Uuid());
        }
        else
          rc = -1;
      }
      else if ( 0 == b_name )
      {
        rc = 1;
      }
      else
      {
        rc = on_stricmp(a_name,b_name);
        if ( 0 == rc )
        {
          rc = strcmp(a_name,b_name);
          if ( 0 == rc )
          {
            rc = b->Mark() - a->Mark();
            if ( 0 == rc )
              rc = ON_UuidCompare(a->Uuid(),b->Uuid());
          }
        }
      }
    }
  }
  return rc;
}
Ejemplo n.º 4
0
ON_BOOL32 ON_Object::AttachUserData( ON_UserData* p )
{
  ON_BOOL32 rc = false;
  if ( p 
       && NULL == p->m_userdata_owner
       && ON_UuidCompare( &ON_nil_uuid, &p->m_userdata_uuid) 
       && NULL == GetUserData( p->m_userdata_uuid )
       ) {
    if ( p->IsUnknownUserData() ) {
      // make sure we have valid user data - the first beta release of Rhino 2.0 
      // created empty user data.
      ON_UnknownUserData* uud = ON_UnknownUserData::Cast(p);
      if (uud)
        rc = uud->IsValid();
      if ( !rc ) {
        ON_ERROR("ON_Object::AttachUserData() - attempt to attach invalid UnknownUserData.");
      }
    }
    else
      rc = true;
    if (rc) 
    {
      p->m_userdata_owner = this;
      p->m_userdata_next = m_userdata_list;
      m_userdata_list = p;
    }
  }
  return rc;
}
Ejemplo n.º 5
0
static int compareLayerPtrId(const void* A, const void*B)
{
  if ( 0 == A )
  {
    return 0 == B ? 0 : -1;
  }
  if ( 0 == B )
  {
    return 1;
  }

  const ON_Layer* a = (0!=A) ? ( *((ON_Layer**)A) ) : 0;
  const ON_Layer* b = (0!=B) ? ( *((ON_Layer**)B) ) : 0;
  if ( 0 == a )
  {
    return (0 == b) ? 0 : -1;
  }
  if ( 0 == b )
  {
    return 1;
  }

  // NOTE WELL:
  //   Compare only m_layer_id.  Other values may differ and
  //   adding compares to them will break the code that uses
  //   this function.
  return ON_UuidCompare(a->m_layer_id,b->m_layer_id);
}
void CRhGetRegionPoints::DynamicDraw( HDC hdc, CRhinoViewport& vp, const ON_3dPoint& point )
{
    if( 0 == ON_UuidCompare(m_viewport_id, vp.ViewportId()) )
    {
        const int point_count = m_points.Count();
        if( point_count > 0 )
        {
            CRhinoDisplayPipeline* dp = vp.DisplayPipeline();
            if( dp )
            {
                CPen pen( PS_SOLID, 1, RGB(0,0,0) );
                int i;
                for( i = 0; i < point_count - 1; i++ )
                    dp->Draw2dLine( m_points[i], m_points[i + 1], pen, true );
                if( m_temp_point != CPoint(-1, -1) )
                {
                    dp->Draw2dLine( m_points[point_count - 1], m_temp_point, pen, true );
                    if( point_count > 1 )
                        dp->Draw2dLine( m_temp_point, m_points[0], pen, true );
                }
                else
                    dp->Draw2dLine( m_points[point_count - 1], m_points[0], pen, true );
            }
        }
    }

    CRhinoGetPoint::DynamicDraw(hdc,vp,point);
}
bool CSampleLayerContextMenuExtension::ShouldExtendContextMenu( CRhinoContextMenuContext& context )
{
    // Extend the layer list's context menu
    if( 0 == ON_UuidCompare(context.m_uuid, CRhinoContextMenuExtension::UUIDLayerList()) )
        return true;
    return false;
}
Ejemplo n.º 8
0
int ON_UuidIndex::CompareId( const ON_UuidIndex* a, const ON_UuidIndex* b )
{
  if ( !a )
    return (b ? -1 : 0 );
  if ( !b )
    return 1;
  return ON_UuidCompare(&a->m_id,&b->m_id);
}
Ejemplo n.º 9
0
int ON_UuidPair::Compare(const class ON_UuidPair* a,const class ON_UuidPair* b)
{
  int i;
  if (!a)
  {
    return (b) ? -1 : 0;
  }
  if (!b)
  {
    return 1;
  }
  if ( 0 == (i = ON_UuidCompare(a->m_uuid[0],b->m_uuid[0])) )
  {
    i = ON_UuidCompare(a->m_uuid[1],b->m_uuid[1]);
  }
  return i;
}
Ejemplo n.º 10
0
char* ON_UuidToString( const ON_UUID& uuid, char* s)
{
  // s - [out]  The s[] char array must have length >= 37.  
  //            The returned char array will have a 36 
  //            character uuid in s[0..35] and a null in s[36].

  // NOTE WELL: 
  //   This code has to work on non-Windows OSs and on both big and
  //   little endian CPUs.  The result must satisfy
  //   uuid == ON_UuidFromString(ON_UuidToString(uuid,s))

  // 31 August 2005 Dale Lear
  //     Changed upper case to lower case so result is
  //     identical to the string returned by Windows' ::UuidToString().
  //static const char x[16] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
  static const char x[16] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
  static const int addhyphen[16] = {0,0,0,1, 0,1, 0,1, 0,1,  0, 0, 0, 0, 0, 0};
  const unsigned char* b = (const unsigned char*)&uuid;
  char* p;
  int i;
  
  static const int* rho = ( ON::big_endian == ON::Endian() ) 
                        ? big_endian_rho 
                        : little_endian_rho;

  // 5 December 2002 Dale Lear:
  //   There is either a bug in Purify (likely) or perhaps a bug in the 
  //   way Microsoft compiles  c>>4 when c is an unsigned char.  In any
  //   case, changing c to an unsigned int makes purify happy and should
  //   work just as well.
  //
  //unsigned char c;

  unsigned int c;

  if ( !s )
    return 0;
  p = s;
  for ( i = 0; i < 16; i++ ) {
    c = b[rho[i]];
    *p++ = x[c>>4];  // purify gripes here if c is an unsigned char - the code runs fine.
    *p++ = x[c&0x0F];
    if ( addhyphen[i] )
      *p++ = '-';
  }
  *p = 0;

#if defined(ON_DEBUG)
  {
    ON_UUID u = ON_UuidFromString(s);
    if ( ON_UuidCompare(&u,&uuid) ) {
      ON_ERROR("ON_UuidToString() bug"); // <- breakpoint here
    }
  }
#endif

  return s;
}
void CSampleLayerContextMenuExtension::ExtendContextMenu( CRhinoContextMenuContext& context, CRhinoContextMenu& context_menu )
{
    m_iAddItemID0 = m_iAddItemID1 = m_iAddItemID2 = -1;
    if( 0 == ON_UuidCompare(context.m_uuid, CRhinoContextMenuExtension::UUIDLayerList()) )
    {
        m_iAddItemID0 = context_menu.AddItem( L"Sample Context Menu Item 1" );
        m_iAddItemID1 = context_menu.AddItem( L"Sample Context Menu Item 2" );
        m_iAddItemID2 = context_menu.AddItem( L"Sample Context Menu Item 3" );
    }
}
CRhinoRectangleGrips* CRhinoRectangleGrips::RectangleGrips( CRhinoObjectGrips* grips )
{
  if( !grips )
    return 0;
  if( CRhinoGripObject::custom_grip != grips->m__grips_type )
    return 0;
  if( ON_UuidCompare(CRhinoRectangleGrips::m_rectangle_grips_id, grips->m_grips_id) )
    return 0;
  return static_cast<CRhinoRectangleGrips*>(grips);
}
Ejemplo n.º 13
0
BOOL ON_UnknownUserData::IsValid( ON_TextLog* text_log ) const
{
  BOOL rc = ON_UserData::IsValid(text_log);

  // valid unknown user data must have something in it
  if (rc)
    rc = (m_sizeof_buffer>0);
  if (rc)
    rc = (m_buffer != NULL);

  // the unknown class uuid cannot be nil
  if (rc)
    rc = ON_UuidCompare( &m_unknownclass_uuid, &ON_nil_uuid );

  // the unknown class uuid cannot be the ON_UnknownUserData class uuid
  if (rc) {
    ON_UUID ON_UnknownUserData_classuuid = ON_UnknownUserData::m_ON_UnknownUserData_class_id.Uuid();
    rc = ON_UuidCompare( &m_unknownclass_uuid, &ON_UnknownUserData_classuuid );
  }
  return rc?true:false;
}
Ejemplo n.º 14
0
int ON_UuidPair::CompareSecondUuid(const class ON_UuidPair* a,const class ON_UuidPair* b)
{
  if (!a)
  {
    return (b) ? -1 : 0;
  }
  if (!b)
  {
    return 1;
  }
  return ON_UuidCompare(a->m_uuid[1],b->m_uuid[1]);
}
Ejemplo n.º 15
0
int ON_UuidIndex::CompareIndexAndId( const ON_UuidIndex* a, const ON_UuidIndex* b )
{
  int i;
  if ( !a )
    return (b ? -1 : 0 );
  if ( !b )
    return 1;

  // compare index first
  if ( 0 == (i = a->m_i - b->m_i) )
    i = ON_UuidCompare(&a->m_id,&b->m_id);

  return i;
}
Ejemplo n.º 16
0
ON_UserData* ON_Object::GetUserData( const ON_UUID& userdata_uuid ) const
{
  ON_UserData* prev = NULL;
  ON_UserData* p;
  for ( p = m_userdata_list; p; prev = p, p = p->m_userdata_next ) 
  {
    if ( !ON_UuidCompare( &p->m_userdata_uuid, &userdata_uuid ) ) 
    {
      if ( p->IsUnknownUserData() ) 
      {
        // See if we can convert this unknown user data into something useful.
        // Unknown user data is created when a 3dm archive is read and
        // the definition of the specific user data class is not loaded.
        // If something is getting around to asking for a specific kind
        // of user data, the class definition has probably be dynamically
        // loaded.
        ON_UnknownUserData* uud = ON_UnknownUserData::Cast(p);
        if ( uud ) {
          ON_UserData* realp = uud->Convert();
          if ( realp ) 
          {
            // replace unknown user data with the real thing
            if ( prev )
              prev->m_userdata_next = realp;
            else if ( p == m_userdata_list ) 
            {
              // little white lie to attach the "real" user
              // data to the object in place of the unknown
              // user data.
              ON_Object* pNotConst = const_cast<ON_Object*>(this);
              pNotConst->m_userdata_list = realp;
              realp->m_userdata_owner = pNotConst; // Dale Lear added 22 Jan 2004 to fix I/O bug 
            }
            realp->m_userdata_next = p->m_userdata_next;
            p->m_userdata_next = 0;
            p->m_userdata_owner = 0;
            delete p;
            p = realp;
          }
        }
      }
      break;
    }
  }
  return p; 
}
Ejemplo n.º 17
0
ON_BOOL32 ON_InstanceRef::IsValid( ON_TextLog* text_log ) const
{
  if ( 0 == ON_UuidCompare( m_instance_definition_uuid, ON_nil_uuid) )
  {
    if ( text_log )
      text_log->Print("ON_InstanceRef has nil m_instance_definition_uuid.\n");
    return false;
  }

  ON_Xform tmp = m_xform.Inverse()*m_xform;
  if ( !tmp.IsIdentity( ON_InstanceRef::m_singular_xform_tol ) )
  {
    if ( text_log )
      text_log->Print("ON_InstanceRef has singular m_xform.\n");
    return false;
  }
  return true;
}
Ejemplo n.º 18
0
ON_BOOL32 ON_InstanceDefinition::IsValid( ON_TextLog* text_log ) const
{
  if ( 0 == ON_UuidCompare( m_uuid, ON_nil_uuid) )
  {
    if (text_log)
    {
      text_log->Print("ON_InstanceDefinition has nil uuid.\n");
    }
    return false;
  }
  if ( !m_bbox.IsValid() )
  {
    if (text_log)
    {
      text_log->Print("ON_InstanceDefinition has invalid bounding box.\n");
    }
    return false;
  }
  switch( m_idef_update_type)
  {
    case embedded_def:
    case linked_def:
    case linked_and_embedded_def:
      if( m_source_archive.IsEmpty())
      {
        if (text_log)
        {
          text_log->Print("ON_InstanceDefinition is linked or embedded but m_source_archive is empty.\n");
        }
        return false;
      }
      break;
    default:
      // do nothing on rest of cases
      break;
  }

  // TODO
  return true;
}
Ejemplo n.º 19
0
int ON__ClassIdDumpNode::CompareClassUuid( const class ON__ClassIdDumpNode& other ) const
{
  int rc = 0;
  const ON_ClassId* a = m_class_id;
  const ON_ClassId* b = other.m_class_id;
  if ( a != b )
  {
    if ( 0 == a )
    {
      rc = -1;
    }
    else if ( 0 == b )
      rc = 1;
    else
    {
      rc = ON_UuidCompare(a->Uuid(),b->Uuid());
      if ( 0 == rc )
      {
        rc = CompareClassName(other);
      }
    }
  }
  return rc;
}
Ejemplo n.º 20
0
bool ON_3dmObjectAttributes::operator==(const ON_3dmObjectAttributes& other) const
{
  if ( ON_UuidCompare( m_uuid, other.m_uuid ) )
    return false;
  if ( m_name.Compare(other.m_name) )
    return false;
  if ( m_url.Compare(other.m_url) )
    return false;
  if ( m_layer_index != other.m_layer_index )
    return false;
  if ( m_material_index != other.m_material_index )
    return false;
  if ( m_linetype_index != other.m_linetype_index )
    return false;
  if ( m_color != other.m_color )
    return false;
  if ( m_plot_color != other.m_plot_color )
    return false;
  if ( m_display_order != other.m_display_order )
    return false;
  if ( m_object_decoration != other.m_object_decoration )
    return false;
  if ( m_wire_density != other.m_wire_density )
    return false;
  if ( m_mode != other.m_mode )
    return false;
  if ( m_color_source != other.m_color_source )
    return false;
  if ( m_linetype_source != other.m_linetype_source )
    return false;
  if ( m_plot_color_source != other.m_plot_color_source )
    return false;
  if ( m_material_source != other.m_material_source )
    return false;
  if ( m_plot_weight_mm != other.m_plot_weight_mm )
    return false;
  if ( m_plot_weight_source != other.m_plot_weight_source )
    return false;

  int count = m_group.Count();
  if ( count != other.m_group.Count() )
    return false;
  if ( count > 0 )
  {
    const int* a = m_group.Array();
    const int* b = other.m_group.Array();
    if ( memcmp( a, b, count*sizeof(*a) ) )
      return false;
  }

  if ( m_bVisible != other.m_bVisible )
    return false;

  if ( m_rendering_attributes.Compare(other.m_rendering_attributes) )
    return false;

  if ( m_space != other.m_space)
    return false;

  if ( m_viewport_id != other.m_viewport_id )
    return false;

  if ( m_dmref != other.m_dmref )
    return false;

  return true;
}
Ejemplo n.º 21
0
ON_BOOL32 ON_3dmObjectAttributes::Read( ON_BinaryArchive& file )
{
  Default();
  if (    file.Archive3dmVersion() >= 5 
       && file.ArchiveOpenNURBSVersion() >= 200712190 )
  {
    return ReadV5Helper(file);
  }
  int i;
  int major_version = 0;
  int minor_version = 0;
  bool rc = file.Read3dmChunkVersion(&major_version,&minor_version);
  if ( rc && major_version == 1 ) 
  {
    if (rc) rc = file.ReadUuid(m_uuid);
    if (rc) rc = file.ReadInt(&m_layer_index);
    if (rc) rc = file.ReadInt(&m_material_index);
    if (rc) rc = file.ReadColor(m_color);
    
    while(rc)
    {
      // OBSOLETE if (rc) rc = file.ReadLineStyle(m_line_style); // 23 March 2005 Dale Lear
      // replaced with
      short s = 0;
      double x;
      rc = file.ReadShort(&s); 
      if (!rc) break;
      if ( file.Archive3dmVersion() < 4 || file.ArchiveOpenNURBSVersion() < 200503170 )
      {
        // ignore unused linestyle info in old files
        // This bit keeps the curve arrowheads from V3 showing up
        // in V4.
        m_object_decoration = ON::ObjectDecoration( (s & ON::both_arrowhead) );
      }
      rc = file.ReadShort(&s);
      if (!rc) break;
      rc = file.ReadDouble(&x);
      if (!rc) break;
      rc = file.ReadDouble(&x);
      break;
    }

    if (rc) rc = file.ReadInt(&m_wire_density);
    if (rc) rc = file.ReadChar(&m_mode);

    if (rc) rc = file.ReadChar(&m_color_source);
    if (rc) m_color_source = (unsigned char)ON::ObjectColorSource(m_color_source);

    if (rc) rc = file.ReadChar(&m_linetype_source);
    if (rc) m_linetype_source = (unsigned char)ON::ObjectLinetypeSource(m_linetype_source);

    if (rc) rc = file.ReadChar(&m_material_source);
    if (rc) m_material_source = (unsigned char)ON::ObjectMaterialSource(m_material_source);

    if (rc) rc = file.ReadString(m_name);
    if (rc) rc = file.ReadString(m_url);

    m_bVisible = (Mode() != ON::hidden_object);
    if ( rc && minor_version >= 1 ) 
    {
      rc = file.ReadArray( m_group );
      if ( rc && minor_version >= 2 )
      {
        rc = file.ReadBool(&m_bVisible);

        if ( rc && minor_version >= 3 )
        {
          rc = file.ReadArray(m_dmref);     

          if (rc && minor_version >= 4 )
          {
            // 23 March 2005 Dale Lear
            //    Added m_plot_color_source and m_plot_color
            i = 0;
            if (rc) rc = file.ReadInt(&i);
            if (rc) m_object_decoration = ON::ObjectDecoration(i);
            if (rc) rc = file.ReadChar(&m_plot_color_source);
            if (rc) m_plot_color_source = (unsigned char)ON::PlotColorSource(m_plot_color_source);
            if (rc) rc = file.ReadColor( m_plot_color );
            if (rc) rc = file.ReadChar(&m_plot_weight_source);
            if (rc) m_plot_weight_source = (unsigned char)ON::PlotWeightSource(m_plot_weight_source);
            if (rc) rc = file.ReadDouble(&m_plot_weight_mm);


            if (rc && minor_version >= 5 )
            {
              // version 1.5 fields 11 April 2005
              if (rc) rc = file.ReadInt(&m_linetype_index);

              // version 1.6 fields 2 September 2005
              if (rc && minor_version >= 6 )
              {
                unsigned char uc = 0;
                rc = file.ReadChar(&uc);
                if (rc)
                {
                  m_space = (1 == uc) ? ON::page_space : ON::model_space;
                  m_dmref.Empty();
                  int i, count=0;
                  rc = file.ReadInt(&count);
                  if (rc && count > 0)
                  {
                    m_dmref.SetCapacity(count);
                    for ( i = 0; i < count && rc; i++)
                    {
                      ON_DisplayMaterialRef& dmr = m_dmref.AppendNew();
                      rc = file.ReadUuid(dmr.m_viewport_id);
                      if (rc) rc = file.ReadUuid(dmr.m_display_material_id);
                      if ( rc )
                      {
                        // Assigning an object to a page started out as
                        // using dmrs.  The way the runtime info is saved
                        // has changed, but, at this point, I can't change
                        // the way the information is saved in the file and
                        // it doesn't matter.
                        if ( 0 == ON_UuidCompare(&ON_ObsoletePageSpaceObjectId,&dmr.m_display_material_id) )
                        {
                          m_viewport_id = dmr.m_viewport_id;
                          m_dmref.Remove();
                        }
                      }
                    }
                    if ( 0 == m_dmref.Count() )
                      m_dmref.Destroy();
                  }
                }

                if ( rc && minor_version >= 7 )
                {
                  // version 1.7 fields 6 June 2006
                  if (rc) rc = m_rendering_attributes.Read(file);
                }
              }
            }
          }
        }
      }
    }
  }
  else 
  {
    rc = false;
  }
  return rc;
}
Ejemplo n.º 22
0
int ON_UuidCompare( const ON_UUID& a, const ON_UUID& b)
{
  return ON_UuidCompare(&a,&b);
}
Ejemplo n.º 23
0
ON_BOOL32 ON_InstanceDefinition::IsValid( ON_TextLog* text_log ) const
{
  if ( 0 == ON_UuidCompare( m_uuid, ON_nil_uuid) )
  {
    if (text_log)
    {
      text_log->Print("ON_InstanceDefinition has nil uuid.\n");
    }
    return false;
  }
  if ( !m_bbox.IsValid() )
  {
    if (text_log)
    {
      text_log->Print("ON_InstanceDefinition has invalid bounding box.\n");
    }
    return false;
  }

  switch( m_idef_update_type)
  {
    case static_def:
      // no source archive information should be present
      if ( m_source_archive.Length() > 0 )
      {
        if (text_log)
        {
          text_log->Print("ON_InstanceDefinition is static but m_source_archive is not empty.\n");
        }
        return false;
      }
      if ( m_source_archive_checksum.IsSet() )
      {
        if (text_log)
        {
          text_log->Print("ON_InstanceDefinition is static but m_source_archive_checksum is set.\n");
        }
        return false;
      }

      if ( 0 != m_idef_layer_style )
      {
        if (text_log)
        {
          text_log->Print("ON_InstanceDefinition is static but m_idef_layer_style is not zero.\n");
        }
        return false;
      }
      break;

    case embedded_def: // embedded_def is obsolete - 
      if ( text_log )
      {
        text_log->Print("ON_InstanceDefinition.m_idef_update_type = obsolete \"embedded_idef\". Use \"static_def\" or \"linked_and_embedded_def\".\n");
      }
      return false;
      break;

    case linked_and_embedded_def:
    case linked_def:
      // source archive information is required
      if( m_source_archive.IsEmpty())
      {
        if (text_log)
        {
          text_log->Print("ON_InstanceDefinition is linked or embedded but m_source_archive is empty.\n");
        }
        return false;
      }
      if( !m_source_archive_checksum.IsSet())
      {
        if (text_log)
        {
          text_log->Print("ON_InstanceDefinition is linked or embedded but m_source_archive_checksum is zero.\n");
        }
        return false;
      }

      if ( linked_def == m_idef_update_type )
      {
        if ( 1 != m_idef_layer_style && 2 != m_idef_layer_style )
        {
          if (text_log)
          {
            text_log->Print("ON_InstanceDefinition is linked_def but m_idef_layer_style is not 1 or 2.\n");
          }
          return false;
        }
      }
      else
      {
        if ( 0 != m_idef_layer_style )
        {
          if (text_log)
          {
            text_log->Print("ON_InstanceDefinition is linked_and_embedded_def but m_idef_layer_style is not zero.\n");
          }
          return false;
        }
      }

      break;

    default:
      if ( text_log )
      {
        text_log->Print("ON_InstanceDefinition.m_idef_update_type value is invalid.\n");
      }
      return false;
      break;
  }

  // TODO
  return true;
}
Ejemplo n.º 24
0
const ON_ClassId* ON_ClassId::ClassId( ON_UUID uuid )
{
  // static member function
  // search list of class ids for one with a matching typecode
  const ON_ClassId* p;
  for(p = m_p0; p; p = p->m_pNext) 
  {
    if ( !ON_UuidCompare(&p->m_uuid,&uuid) )
      break;
  }

  if ( !p && !g_bDisableDemotion) 
  {
    // enable OpenNURBS toolkit to read files that contain old uuids even when
    // old class definitions are not loaded.

    // 5EAF1119-0B51-11d4-BFFE-0010830122F0 = TL_NurbsCurve
    ON_UUID nc0 = {0x5EAF1119,0x0B51,0x11d4,{0xBF,0xFE,  0x00,0x10,0x83,0x01,0x22,0xF0}};

    // 76A709D5-1550-11d4-8000-0010830122F0 = old nurbs curve
    ON_UUID nc1 = {0x76A709D5,0x1550,0x11d4,{0x80,0x00,  0x00,0x10,0x83,0x01,0x22,0xF0}};

    // 4760C817-0BE3-11d4-BFFE-0010830122F0 = TL_NurbsSurface
    ON_UUID ns0 = {0x4760C817,0x0BE3,0x11d4,{0xBF,0xFE,  0x00,0x10,0x83,0x01,0x22,0xF0}};

    // FA4FD4B5-1613-11d4-8000-0010830122F0 = old nurbs surface
    ON_UUID ns1 = {0xFA4FD4B5,0x1613,0x11d4,{0x80,0x00,  0x00,0x10,0x83,0x01,0x22,0xF0}};

    // EF638317-154B-11d4-8000-0010830122F0 = old poly curve
    ON_UUID pc0 = {0xEF638317,0x154B,0x11d4,{0x80,0x00,  0x00,0x10,0x83,0x01,0x22,0xF0}};

    // 0705FDEF-3E2A-11d4-800E-0010830122F0 = old trimmed surface
    ON_UUID br0 = {0x0705FDEF,0x3E2A,0x11d4,{0x80,0x0E,  0x00,0x10,0x83,0x01,0x22,0xF0}};

    // 2D4CFEDB-3E2A-11d4-800E-0010830122F0 = old b-rep
    ON_UUID br1 = {0x2D4CFEDB,0x3E2A,0x11d4,{0x80,0x0E,  0x00,0x10,0x83,0x01,0x22,0xF0}};

    // F06FC243-A32A-4608-9DD8-A7D2C4CE2A36 = TL_Brep
    ON_UUID br2 = {0xF06FC243,0xA32A,0x4608,{0x9D,0xD8, 0xA7,0xD2,0xC4,0xCE,0x2A,0x36}};

    // 0A8401B6-4D34-4b99-8615-1B4E723DC4E5 = TL_RevSurface
    ON_UUID revsrf = { 0xa8401b6, 0x4d34, 0x4b99, { 0x86, 0x15, 0x1b, 0x4e, 0x72, 0x3d, 0xc4, 0xe5 } };

    // 665F6331-2A66-4cce-81D0-B5EEBD9B5417 = TL_SumSurface
    ON_UUID sumsrf = { 0x665f6331, 0x2a66, 0x4cce, { 0x81, 0xd0, 0xb5, 0xee, 0xbd, 0x9b, 0x54, 0x17 } };

    if      ( !ON_UuidCompare( &uuid, &nc0 ) || !ON_UuidCompare( &uuid, &nc1 ) )
      p = &ON_NurbsCurve::m_ON_NurbsCurve_class_id;
    else if ( !ON_UuidCompare( &uuid, &ns0 ) || !ON_UuidCompare( &uuid, &ns1 ) )
      p = &ON_NurbsSurface::m_ON_NurbsSurface_class_id;
    else if ( !ON_UuidCompare( &uuid, &pc0 ) )
      p = &ON_PolyCurve::m_ON_PolyCurve_class_id;
    else if ( !ON_UuidCompare( &uuid, &br0 ) || !ON_UuidCompare( &uuid, &br1 ) || !ON_UuidCompare( &uuid, &br2 ) )
      p = &ON_Brep::m_ON_Brep_class_id;
    else if ( !ON_UuidCompare( &uuid, &revsrf ) )
      p = &ON_RevSurface::m_ON_RevSurface_class_id;
    else if ( !ON_UuidCompare( &uuid, &sumsrf ) )
      p = &ON_SumSurface::m_ON_SumSurface_class_id;
    else
      p = 0; // <- does nothing but it's a good place for debugger breakpoint
  }
  return p;
}