Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions src/DataExchange/TKDESTEP/StepData/StepData_DefaultGeneral.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,36 @@

IMPLEMENT_STANDARD_RTTIEXT(StepData_DefaultGeneral, StepData_GeneralModule)

// DefaultGeneral de StepData reconnait UN SEUL TYPE : UndefinedEntity
// StepData DefaultGeneral recognizes ONLY ONE TYPE: UndefinedEntity
StepData_DefaultGeneral::StepData_DefaultGeneral()
{
// Register this module globally with the StepData protocol
Interface_GeneralLib::SetGlobal(this, StepData::Protocol());
}

void StepData_DefaultGeneral::FillSharedCase(const Standard_Integer casenum,
const Handle(Standard_Transient)& ent,
Interface_EntityIterator& iter) const
{
// Fill iterator with shared entities from UndefinedEntity parameters
if (casenum != 1)
return;
return; // Only handles case 1 (UndefinedEntity)
DeclareAndCast(StepData_UndefinedEntity, undf, ent);
Handle(Interface_UndefinedContent) cont = undf->UndefinedContent();
Standard_Integer nb = cont->NbParams();
// Iterate through all parameters looking for entity references
for (Standard_Integer i = 1; i <= nb; i++)
{
Interface_ParamType ptype = cont->ParamType(i);
if (ptype == Interface_ParamSub)
{
// Handle sub-entity parameters recursively
DeclareAndCast(StepData_UndefinedEntity, subent, cont->ParamEntity(i));
FillSharedCase(casenum, cont->ParamEntity(i), iter);
}
else if (ptype == Interface_ParamIdent)
{
// Handle entity identifier parameters
iter.GetOneItem(cont->ParamEntity(i));
}
}
Expand All @@ -62,13 +67,14 @@ void StepData_DefaultGeneral::CheckCase(const Standard_Integer,
const Interface_ShareTool&,
Handle(Interface_Check)&) const
{
} // pas de Check sur une UndefinedEntity
} // No validation check performed on an UndefinedEntity

Standard_Boolean StepData_DefaultGeneral::NewVoid(const Standard_Integer CN,
Handle(Standard_Transient)& ent) const
{
// Create a new empty entity instance (only UndefinedEntity supported)
if (CN != 1)
return Standard_False;
return Standard_False; // Only case 1 supported
ent = new StepData_UndefinedEntity;
return Standard_True;
}
Expand All @@ -78,9 +84,10 @@ void StepData_DefaultGeneral::CopyCase(const Standard_Integer casenum
const Handle(Standard_Transient)& entto,
Interface_CopyTool& TC) const
{
// Copy content from source UndefinedEntity to target UndefinedEntity
if (casenum != 1)
return;
return; // Only handles case 1 (UndefinedEntity)
DeclareAndCast(StepData_UndefinedEntity, undfrom, entfrom);
DeclareAndCast(StepData_UndefinedEntity, undto, entto);
undto->GetFromAnother(undfrom, TC); // On pourrait rapatrier cela
undto->GetFromAnother(undfrom, TC); // We could optimize this operation
}
40 changes: 24 additions & 16 deletions src/DataExchange/TKDESTEP/StepData/StepData_ESDescr.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ IMPLEMENT_STANDARD_RTTIEXT(StepData_ESDescr, StepData_EDescr)
StepData_ESDescr::StepData_ESDescr(const Standard_CString name)
: thenom(name)
{
// Constructor for Simple Entity Descriptor with the given type name
}

void StepData_ESDescr::SetNbFields(const Standard_Integer nb)
{
// Set the number of fields for this entity descriptor, preserving existing field data
Standard_Integer minb, i, oldnb = NbFields();
thenames.Clear();
thenames.Clear(); // Clear name-to-index mapping
if (nb == 0)
{
thedescr.Nullify();
Expand All @@ -40,12 +42,13 @@ void StepData_ESDescr::SetNbFields(const Standard_Integer nb)
thedescr = li;
return;
}
// Copy existing field descriptors up to the minimum of old and new sizes
minb = (oldnb > nb ? nb : oldnb);
for (i = 1; i <= minb; i++)
{
DeclareAndCast(StepData_PDescr, pde, thedescr->Value(i));
if (!pde.IsNull())
thenames.Bind(pde->Name(), i);
thenames.Bind(pde->Name(), i); // Rebuild name-to-index mapping
li->SetValue(i, pde);
}
thedescr = li;
Expand All @@ -55,30 +58,32 @@ void StepData_ESDescr::SetField(const Standard_Integer num,
const Standard_CString name,
const Handle(StepData_PDescr)& descr)
{
// Set field descriptor at specified position with given name and parameter descriptor
if (num < 1 || num > NbFields())
return;
Handle(StepData_PDescr) pde = new StepData_PDescr;
pde->SetFrom(descr);
pde->SetName(name);
pde->SetFrom(descr); // Copy descriptor properties
pde->SetName(name); // Set field name
thedescr->SetValue(num, pde);
thenames.Bind(name, num);
thenames.Bind(name, num); // Update name-to-index mapping
}

void StepData_ESDescr::SetBase(const Handle(StepData_ESDescr)& base)
{
thebase = base;
// il faut CUMULER les fields de la base et ses supers
// Need to ACCUMULATE the fields from the base and its superclasses
}

void StepData_ESDescr::SetSuper(const Handle(StepData_ESDescr)& super)
{
// Set the superclass descriptor, handling inheritance hierarchy
Handle(StepData_ESDescr) sup = super->Base();
if (sup.IsNull())
sup = super;
if (!thebase.IsNull())
thebase->SetSuper(sup);
thebase->SetSuper(sup); // Delegate to base if exists
else
thesuper = sup;
thesuper = sup; // Otherwise set directly
}

Standard_CString StepData_ESDescr::TypeName() const
Expand All @@ -103,19 +108,20 @@ Handle(StepData_ESDescr) StepData_ESDescr::Super() const

Standard_Boolean StepData_ESDescr::IsSub(const Handle(StepData_ESDescr)& other) const
{
// Check if this descriptor is a subclass of the given descriptor
Handle(StepData_ESDescr) oth = other->Base();
if (oth.IsNull())
oth = other;
if (!thebase.IsNull())
return thebase->IsSub(oth);
return thebase->IsSub(oth); // Delegate to base if exists
Handle(Standard_Transient) t1 = this;
if (oth == t1)
return Standard_True;
return Standard_True; // Same descriptor
if (oth == thesuper)
return Standard_True;
return Standard_True; // Direct superclass
else if (thesuper.IsNull())
return Standard_False;
return thesuper->IsSub(oth);
return Standard_False; // No superclass
return thesuper->IsSub(oth); // Check recursively up the hierarchy
}

Standard_Integer StepData_ESDescr::NbFields() const
Expand Down Expand Up @@ -157,11 +163,12 @@ Handle(StepData_PDescr) StepData_ESDescr::NamedField(const Standard_CString name

Standard_Boolean StepData_ESDescr::Matches(const Standard_CString name) const
{
// Check if this descriptor matches the given type name (including inheritance)
if (thenom.IsEqual(name))
return Standard_True;
return Standard_True; // Direct match
if (thesuper.IsNull())
return Standard_False;
return thesuper->Matches(name);
return Standard_False; // No superclass to check
return thesuper->Matches(name); // Check superclass hierarchy
}

Standard_Boolean StepData_ESDescr::IsComplex() const
Expand All @@ -171,6 +178,7 @@ Standard_Boolean StepData_ESDescr::IsComplex() const

Handle(StepData_Described) StepData_ESDescr::NewEntity() const
{
// Create a new simple entity instance based on this descriptor
Handle(StepData_Simple) ent = new StepData_Simple(this);
return ent;
}
26 changes: 13 additions & 13 deletions src/DataExchange/TKDESTEP/StepData/StepData_Field.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
#include <TColStd_HArray2OfReal.hxx>
#include <TColStd_HArray2OfTransient.hxx>

// Le kind code le type de donnee, le mode d acces (direct ou via Select),
// l arite (simple, liste, carre)
// Valeurs pour Kind : 0 = Clear/Undefined
// The kind encodes the data type, access mode (direct or via Select),
// and arity (simple, list, square array)
// Values for Kind: 0 = Clear/Undefined
// KindInteger KindBoolean KindLogical KindEnum KindReal KindString KindEntity
// + KindSelect qui s y substitue et peut s y combiner
// + KindList et KindList2 qui peuvent s y combiner
// (sur masque KindArity et decalage ShiftArity)
// + KindSelect which substitutes and can combine with them
// + KindList and KindList2 which can combine with them
// (on KindArity mask and ShiftArity offset)
#define KindInteger 1
#define KindBoolean 2
#define KindLogical 3
Expand Down Expand Up @@ -160,13 +160,13 @@ void StepData_Field::CopyFrom(const StepData_Field& other)
low = ht->Lower();
up = ht->Upper();
Handle(TColStd_HArray1OfTransient) ht2 = new TColStd_HArray1OfTransient(low, up);
// faudrait reprendre les cas SelectMember ...
// Should handle SelectMember cases...
for (i = low; i <= up; i++)
ht2->SetValue(i, ht->Value(i));
return;
}
}
// Reste la liste 2 ...
// Remains the 2D list...
// if ((thekind & KindArity) == KindList2) {
// DeclareAndCast(TColStd_HArray2OfTransient,ht,theany);
// }
Expand Down Expand Up @@ -313,7 +313,7 @@ void StepData_Field::SetEntity()

void StepData_Field::SetList(const Standard_Integer size, const Standard_Integer first)
{
// ATTENTION, on ne traite pas l agrandissement ...
// WARNING: we don't handle expansion...

theint = size;
thereal = 0.0;
Expand Down Expand Up @@ -346,7 +346,7 @@ void StepData_Field::SetList2(const Standard_Integer siz1,
const Standard_Integer f1,
const Standard_Integer f2)
{
// ATTENTION, on ne traite pas l agrandissement ...
// WARNING: we don't handle expansion...

theint = siz1;
thereal = Standard_Real(siz2);
Expand Down Expand Up @@ -481,7 +481,7 @@ void StepData_Field::SetInt(const Standard_Integer num,
hi->SetValue(num, val);
return;
}
// Si deja commence sur autre chose, changer et mettre des select
// If already started with something else, change and put selects
DeclareAndCast(TColStd_HArray1OfTransient, ht, theany);
if (ht.IsNull())
return; // yena erreur, ou alors OfReal
Expand Down Expand Up @@ -544,7 +544,7 @@ void StepData_Field::SetReal(const Standard_Integer num, const Standard_Real val
hr->SetValue(num, val);
return;
}
// Si deja commence sur autre chose, changer et mettre des select
// If already started with something else, change and put selects
DeclareAndCast(TColStd_HArray1OfTransient, ht, theany);
if (ht.IsNull())
return; // yena erreur, ou alors OfInteger
Expand Down Expand Up @@ -680,7 +680,7 @@ Standard_Integer StepData_Field::ItemKind(const Standard_Integer n1,
Standard_Integer kind = TrueKind(thekind); // si Any, evaluer ...
if (kind != KindAny)
return kind;
// Sinon, chercher un Transient
// Otherwise, look for a Transient
Handle(Standard_Transient) item;
if ((thekind & KindArity) == KindList)
{
Expand Down
13 changes: 9 additions & 4 deletions src/DataExchange/TKDESTEP/StepData/StepData_FileProtocol.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,31 @@
IMPLEMENT_STANDARD_RTTIEXT(StepData_FileProtocol, StepData_Protocol)

// static TCollection_AsciiString thename("");
static Standard_CString thename = "";
static Standard_CString thename = ""; // Empty schema name for file protocols

// Protocol fabrique a la demande avec d autres Protocoles
// Protocol factory created on demand with other Protocols

StepData_FileProtocol::StepData_FileProtocol() {}

void StepData_FileProtocol::Add(const Handle(StepData_Protocol)& protocol)
{
// Add a protocol to the collection, avoiding duplicates of the same type
if (protocol.IsNull())
return;
Handle(Standard_Type) ptype = protocol->DynamicType();
Standard_Integer nb = thecomps.Length();
// Check if a protocol of the same type is already present
for (Standard_Integer i = 1; i <= nb; i++)
{
if (thecomps.Value(i)->IsInstance(ptype))
return;
return; // Protocol of this type already exists
}
thecomps.Append(protocol);
}

Standard_Integer StepData_FileProtocol::NbResources() const
{
// Return the number of component protocols in this file protocol
return thecomps.Length();
}

Expand All @@ -52,16 +55,18 @@ Handle(Interface_Protocol) StepData_FileProtocol::Resource(const Standard_Intege

Standard_Integer StepData_FileProtocol::TypeNumber(const Handle(Standard_Type)& /*atype*/) const
{
// FileProtocol doesn't recognize specific types directly (delegates to component protocols)
return 0;
}

Standard_Boolean StepData_FileProtocol::GlobalCheck(const Interface_Graph& G,
Handle(Interface_Check)& ach) const
{
// Perform global validation check across all component protocols
Standard_Boolean res = Standard_False;
Standard_Integer i, nb = NbResources();
for (i = 1; i <= nb; i++)
res |= Resource(i)->GlobalCheck(G, ach);
res |= Resource(i)->GlobalCheck(G, ach); // Aggregate results from all protocols
return res;
}

Expand Down
15 changes: 10 additions & 5 deletions src/DataExchange/TKDESTEP/StepData/StepData_FreeFormEntity.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ IMPLEMENT_STANDARD_RTTIEXT(StepData_FreeFormEntity, Standard_Transient)

void StepData_FreeFormEntity::SetStepType(const Standard_CString typenam)
{
// Set the STEP entity type name for this free-form entity
thetype.Clear();
thetype.AssignCat(typenam);
}
Expand Down Expand Up @@ -53,6 +54,7 @@ Handle(StepData_FreeFormEntity) StepData_FreeFormEntity::Next() const

Standard_Boolean StepData_FreeFormEntity::IsComplex() const
{
// A complex entity is one that has additional entity parts linked via 'next'
return (!thenext.IsNull());
}

Expand Down Expand Up @@ -81,26 +83,28 @@ Handle(TColStd_HSequenceOfAsciiString) StepData_FreeFormEntity::TypeList() const

Standard_Boolean StepData_FreeFormEntity::Reorder(Handle(StepData_FreeFormEntity)& ent)
{
// Reorder complex entities to ensure alphabetical sorting of entity types
if (ent.IsNull())
return Standard_False;
if (!ent->IsComplex())
return Standard_False;
Standard_Boolean afr = Standard_False;
Standard_Boolean afr = Standard_False; // flag: any reordering needed
Handle(StepData_FreeFormEntity) e1 = ent;
Handle(StepData_FreeFormEntity) e2 = ent->Next();
// Check if entities are already in alphabetical order
while (!e2.IsNull())
{
if (strcmp(e1->StepType(), e2->StepType()) > 0)
{
afr = Standard_True;
afr = Standard_True; // Found out-of-order pair
break;
}
e1 = e2;
e2 = e1->Next();
}
if (!afr)
return afr;
// remise en ordre avec un dictionnaire
// Reordering using a dictionary (map) to sort entity types alphabetically
e1 = ent;
e2.Nullify();
NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)> dic;
Expand All @@ -109,7 +113,7 @@ Standard_Boolean StepData_FreeFormEntity::Reorder(Handle(StepData_FreeFormEntity
dic.Bind(e1->StepType(), e1);
e1 = e1->Next();
}
// d abord effacer les next en cours ...
// First clear the current 'next' links to break the chain...
for (NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)>::Iterator iter(dic);
iter.More();
iter.Next())
Expand All @@ -118,7 +122,7 @@ Standard_Boolean StepData_FreeFormEntity::Reorder(Handle(StepData_FreeFormEntity
if (!e1.IsNull())
e1->SetNext(e2);
}
// ... puis les remettre dans l ordre
// ... then rebuild the chain in alphabetical order
e1.Nullify();
for (NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)>::Iterator iter(dic);
iter.More();
Expand All @@ -136,6 +140,7 @@ Standard_Boolean StepData_FreeFormEntity::Reorder(Handle(StepData_FreeFormEntity

void StepData_FreeFormEntity::SetNbFields(const Standard_Integer nb)
{
// Initialize the array of fields for this entity
if (nb <= 0)
thefields.Nullify();
else
Expand Down
Loading
Loading