Loading files
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <Interface_Check.hxx>
#include <Standard_Type.hxx>
#include <StepData_EDescr.hxx>
#include <StepData_Field.hxx>
#include <StepData_PDescr.hxx>
IMPLEMENT_STANDARD_RTTIEXT(StepData_PDescr, Standard_Transient)
StepData_PDescr::StepData_PDescr()
: thesel(0),
thekind(StepData_Field::FieldKind::Undefined),
thearit(0),
theopt(false),
theder(false),
thefnum(0)
{
}
void StepData_PDescr::SetName(const char* const name)
{
thename.Clear();
thename.AssignCat(name);
}
const char* StepData_PDescr::Name() const
{
return thename.ToCString();
}
StepData_Field::FieldKind StepData_PDescr::Kind() const
{
return thekind;
}
void StepData_PDescr::SetSelect()
{
thesel = 4;
}
void StepData_PDescr::AddMember(const occ::handle<StepData_PDescr>& member)
{
if (member.IsNull())
{
return;
}
if (thenext.IsNull())
{
thenext = member;
}
else
{
thenext->AddMember(member);
}
if (thesel == 3)
{
return;
}
if (thekind < StepData_Field::FieldKind::Entity
&& thenext->Kind() >= StepData_Field::FieldKind::Entity)
{
thesel = 3;
}
else if (thekind < StepData_Field::FieldKind::Entity && (thesel == 2 || thesel == 4))
{
thesel = 3;
}
else if (thekind >= StepData_Field::FieldKind::Entity && (thesel == 1 || thesel == 4))
{
thesel = 2;
}
}
void StepData_PDescr::SetMemberName(const char* const memname)
{
thesnam.Clear();
thesnam.AssignCat(memname);
}
void StepData_PDescr::SetInteger()
{
thekind = StepData_Field::FieldKind::Integer;
}
void StepData_PDescr::SetReal()
{
thekind = StepData_Field::FieldKind::Real;
}
void StepData_PDescr::SetString()
{
thekind = StepData_Field::FieldKind::String;
}
void StepData_PDescr::SetBoolean()
{
thekind = StepData_Field::FieldKind::Boolean;
}
void StepData_PDescr::SetLogical()
{
thekind = StepData_Field::FieldKind::Logical;
}
void StepData_PDescr::SetEnum()
{
thekind = StepData_Field::FieldKind::Enum;
}
void StepData_PDescr::AddEnumDef(const char* const enumdef)
{
theenum.AddDefinition(enumdef);
}
void StepData_PDescr::SetType(const occ::handle<Standard_Type>& atype)
{
thekind = StepData_Field::FieldKind::Entity;
thetype = atype;
thednam.Clear();
}
void StepData_PDescr::SetDescr(const char* const dscnam)
{
thekind = StepData_Field::FieldKind::Entity;
thetype.Nullify();
thednam.Clear();
thednam.AssignCat(dscnam);
}
void StepData_PDescr::AddArity(const int arity)
{
thearit += arity;
}
void StepData_PDescr::SetArity(const int arity)
{
thearit = arity;
}
void StepData_PDescr::SetFrom(const occ::handle<StepData_PDescr>& other)
{
if (other.IsNull())
{
return;
}
thekind = other->Kind();
int i, maxenum = other->EnumMax();
for (i = 0; i <= maxenum; i++)
{
AddEnumDef(other->EnumText(i));
}
// SELECT types are not copied
thetype = other->Type();
thearit = other->Arity();
thefrom = other;
theopt = other->IsOptional();
theder = other->IsDerived();
thefnam.Clear();
thefnam.AssignCat(other->FieldName());
thefnum = other->FieldRank();
}
void StepData_PDescr::SetOptional(const bool opt)
{
theopt = opt;
}
void StepData_PDescr::SetDerived(const bool der)
{
theder = der;
}
void StepData_PDescr::SetField(const char* const name, const int rank)
{
thefnam.Clear();
thefnam.AssignCat(name);
thefnum = rank;
}
// ###### INTERRO ######
bool StepData_PDescr::IsSelect() const
{
if (!thefrom.IsNull())
{
return thefrom->IsSelect();
}
return (thesel > 0);
}
occ::handle<StepData_PDescr> StepData_PDescr::Member(const char* const name) const
{
if (!thefrom.IsNull())
{
return thefrom->Member(name);
}
occ::handle<StepData_PDescr> descr;
if (thesnam.IsEqual(name))
{
return this;
}
if (thenext.IsNull())
{
return descr; // null
}
return thenext->Member(name);
}
bool StepData_PDescr::IsInteger() const
{
return (thekind == StepData_Field::FieldKind::Integer);
}
bool StepData_PDescr::IsReal() const
{
return (thekind == StepData_Field::FieldKind::Real);
}
bool StepData_PDescr::IsString() const
{
return (thekind == StepData_Field::FieldKind::String);
}
bool StepData_PDescr::IsBoolean() const
{
return (thekind == StepData_Field::FieldKind::Boolean
|| thekind == StepData_Field::FieldKind::Logical);
}
bool StepData_PDescr::IsLogical() const
{
return (thekind == StepData_Field::FieldKind::Logical);
}
bool StepData_PDescr::IsEnum() const
{
return (thekind == StepData_Field::FieldKind::Enum);
}
int StepData_PDescr::EnumMax() const
{
return theenum.MaxValue();
}
int StepData_PDescr::EnumValue(const char* const name) const
{
return theenum.Value(name);
}
const char* StepData_PDescr::EnumText(const int val) const
{
return theenum.Text(val).ToCString();
}
bool StepData_PDescr::IsEntity() const
{
return (thekind == StepData_Field::FieldKind::Entity);
}
bool StepData_PDescr::IsType(const occ::handle<Standard_Type>& atype) const
{
if (atype.IsNull())
{
return false;
}
if (!thetype.IsNull())
{
if (atype->SubType(thetype))
{
return true;
}
}
if (!thenext.IsNull())
{
return thenext->IsType(atype);
}
if (!thefrom.IsNull())
{
return thefrom->IsType(atype);
}
return false;
}
occ::handle<Standard_Type> StepData_PDescr::Type() const
{
return thetype;
}
bool StepData_PDescr::IsDescr(const occ::handle<StepData_EDescr>& descr) const
{
if (descr.IsNull())
{
return false;
}
if (thednam.Length() > 0)
{
if (descr->Matches(thednam.ToCString()))
{
return true;
}
}
if (!thenext.IsNull())
{
return thenext->IsDescr(descr);
}
if (!thefrom.IsNull())
{
return thefrom->IsDescr(descr);
}
return false;
}
const char* StepData_PDescr::DescrName() const
{
return thednam.ToCString();
}
int StepData_PDescr::Arity() const
{
return thearit;
}
occ::handle<StepData_PDescr> StepData_PDescr::Simple() const
{
if (thearit == 0)
{
return this;
}
if (thefrom.IsNull())
{
return this;
}
return thefrom;
}
bool StepData_PDescr::IsOptional() const
{
return theopt;
}
bool StepData_PDescr::IsDerived() const
{
return theder;
}
bool StepData_PDescr::IsField() const
{
return (thefnum > 0);
}
const char* StepData_PDescr::FieldName() const
{
return thefnam.ToCString();
}
int StepData_PDescr::FieldRank() const
{
return thefnum;
}
void StepData_PDescr::Check(const StepData_Field& /*afild*/,
occ::handle<Interface_Check>& /*ach*/) const
{
// For now...
}
3d097a032This file is pinned to the selected release. Download the original to open it in your design tool.