Skip to content

Commit ed7a447

Browse files
authored
Coding - Add conversion utilities for STEP geometrical and visual enumerations (#545)
- Introduced RWStepGeom_RWTransitionCode for converting StepGeom_TransitionCode to/from string representations. - Refactored RWStepGeom_RWTrimmedCurve to utilize RWStepGeom_RWTrimmingPreference for trimming preference conversions. - Created RWStepGeom_RWTrimmingPreference for handling StepGeom_TrimmingPreference enumerations. - Updated RWStepGeom_RWUniformCurve and related classes to use RWStepGeom_RWBSplineCurveForm for B-spline curve form conversions. - Added RWStepGeom_RWUniformSurface and related classes to use RWStepGeom_RWBSplineSurfaceForm for B-spline surface form conversions. - Implemented RWStepShape_RWBooleanOperator for boolean operator conversions in STEP shapes. - Refactored RWStepShape_RWBooleanResult to utilize RWStepShape_RWBooleanOperator for boolean operator handling. - Introduced RWStepVisual_RWCentralOrParallel for central or parallel projection type conversions. - Added RWStepVisual_RWSurfaceSide for surface side enumeration conversions. - Updated RWStepVisual_RWSurfaceStyleUsage to use RWStepVisual_RWSurfaceSide for handling surface side. - Created RWStepVisual_RWTextPath for text path enumeration conversions. - Refactored RWStepVisual_RWTextLiteral to utilize RWStepVisual_RWTextPath for text path handling. - Updated RWStepVisual_RWViewVolume to use RWStepVisual_RWCentralOrParallel for projection type conversions.
1 parent dfb3312 commit ed7a447

63 files changed

Lines changed: 1659 additions & 1968 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/DataExchange/TKDESTEP/RWStepBasic/FILES.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ set(OCCT_RWStepBasic_FILES
1414
RWStepBasic_RWActionRequestSolution.pxx
1515
RWStepBasic_RWAddress.cxx
1616
RWStepBasic_RWAddress.pxx
17+
RWStepBasic_RWAheadOrBehind.pxx
1718
RWStepBasic_RWApplicationContext.cxx
1819
RWStepBasic_RWApplicationContext.pxx
1920
RWStepBasic_RWApplicationContextElement.cxx
@@ -208,6 +209,7 @@ set(OCCT_RWStepBasic_FILES
208209
RWStepBasic_RWSecurityClassification.pxx
209210
RWStepBasic_RWSecurityClassificationLevel.cxx
210211
RWStepBasic_RWSecurityClassificationLevel.pxx
212+
RWStepBasic_RWSiPrefix.pxx
211213
RWStepBasic_RWSiUnit.cxx
212214
RWStepBasic_RWSiUnit.pxx
213215
RWStepBasic_RWSiUnitAndAreaUnit.cxx
@@ -228,10 +230,12 @@ set(OCCT_RWStepBasic_FILES
228230
RWStepBasic_RWSiUnitAndTimeUnit.pxx
229231
RWStepBasic_RWSiUnitAndVolumeUnit.cxx
230232
RWStepBasic_RWSiUnitAndVolumeUnit.pxx
233+
RWStepBasic_RWSiUnitName.pxx
231234
RWStepBasic_RWSolidAngleMeasureWithUnit.cxx
232235
RWStepBasic_RWSolidAngleMeasureWithUnit.pxx
233236
RWStepBasic_RWSolidAngleUnit.cxx
234237
RWStepBasic_RWSolidAngleUnit.pxx
238+
RWStepBasic_RWSource.pxx
235239
RWStepBasic_RWThermodynamicTemperatureUnit.cxx
236240
RWStepBasic_RWThermodynamicTemperatureUnit.pxx
237241
RWStepBasic_RWUncertaintyMeasureWithUnit.cxx
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// Copyright (c) 2025 OPEN CASCADE SAS
2+
//
3+
// This file is part of Open CASCADE Technology software library.
4+
//
5+
// This library is free software; you can redistribute it and/or modify it under
6+
// the terms of the GNU Lesser General Public License version 2.1 as published
7+
// by the Free Software Foundation, with special exception defined in the file
8+
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9+
// distribution for complete text of the license and disclaimer of any warranty.
10+
//
11+
// Alternatively, this file may be used under the terms of Open CASCADE
12+
// commercial license or contractual agreement.
13+
14+
#ifndef _RWStepBasic_RWAheadOrBehind_HeaderFile
15+
#define _RWStepBasic_RWAheadOrBehind_HeaderFile
16+
17+
#include <StepBasic_AheadOrBehind.hxx>
18+
#include <Standard_CString.hxx>
19+
20+
namespace RWStepBasic_RWAheadOrBehind
21+
{
22+
static constexpr char aobAhead[] = ".AHEAD.";
23+
static constexpr char aobExact[] = ".EXACT.";
24+
static constexpr char aobBehind[] = ".BEHIND.";
25+
26+
//! Convert StepBasic_AheadOrBehind to string
27+
//! @param theSourceEnum The StepBasic_AheadOrBehind value to convert
28+
//! @return The corresponding string representation or nullptr if not found
29+
inline const char* ConvertToString(const StepBasic_AheadOrBehind theSourceEnum)
30+
{
31+
switch (theSourceEnum)
32+
{
33+
case StepBasic_aobAhead:
34+
return aobAhead;
35+
case StepBasic_aobExact:
36+
return aobExact;
37+
case StepBasic_aobBehind:
38+
return aobBehind;
39+
}
40+
return nullptr;
41+
}
42+
43+
//! Convert string to StepBasic_AheadOrBehind
44+
//! @param theAheadOrBehindStr The string to convert
45+
//! @param theResultEnum The corresponding StepBasic_AheadOrBehind value
46+
//! @return Standard_True if the conversion was successful, Standard_False otherwise
47+
inline bool ConvertToEnum(const Standard_CString theAheadOrBehindStr,
48+
StepBasic_AheadOrBehind& theResultEnum)
49+
{
50+
if (IsEqual(theAheadOrBehindStr, aobAhead))
51+
{
52+
theResultEnum = StepBasic_aobAhead;
53+
}
54+
else if (IsEqual(theAheadOrBehindStr, aobExact))
55+
{
56+
theResultEnum = StepBasic_aobExact;
57+
}
58+
else if (IsEqual(theAheadOrBehindStr, aobBehind))
59+
{
60+
theResultEnum = StepBasic_aobBehind;
61+
}
62+
else
63+
{
64+
return Standard_False;
65+
}
66+
return Standard_True;
67+
}
68+
69+
} // namespace RWStepBasic_RWAheadOrBehind
70+
71+
#endif // _RWStepBasic_RWAheadOrBehind_HeaderFile

src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWCoordinatedUniversalTimeOffset.cxx

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@
1717
#include <StepData_StepWriter.hxx>
1818
#include <TCollection_AsciiString.hxx>
1919

20-
// --- Enum : AheadOrBehind ---
21-
static TCollection_AsciiString aobAhead(".AHEAD.");
22-
static TCollection_AsciiString aobExact(".EXACT.");
23-
static TCollection_AsciiString aobBehind(".BEHIND.");
20+
#include "RWStepBasic_RWAheadOrBehind.pxx"
2421

2522
RWStepBasic_RWCoordinatedUniversalTimeOffset::RWStepBasic_RWCoordinatedUniversalTimeOffset() {}
2623

@@ -63,14 +60,10 @@ void RWStepBasic_RWCoordinatedUniversalTimeOffset::ReadStep(
6360
if (data->ParamType(num, 3) == Interface_ParamEnum)
6461
{
6562
Standard_CString text = data->ParamCValue(num, 3);
66-
if (aobAhead.IsEqual(text))
67-
aSense = StepBasic_aobAhead;
68-
else if (aobExact.IsEqual(text))
69-
aSense = StepBasic_aobExact;
70-
else if (aobBehind.IsEqual(text))
71-
aSense = StepBasic_aobBehind;
72-
else
63+
if (!RWStepBasic_RWAheadOrBehind::ConvertToEnum(text, aSense))
64+
{
7365
ach->AddFail("Enumeration ahead_or_behind has not an allowed value");
66+
}
7467
}
7568
else
7669
ach->AddFail("Parameter #3 (sense) is not an enumeration");
@@ -103,16 +96,5 @@ void RWStepBasic_RWCoordinatedUniversalTimeOffset::WriteStep(
10396

10497
// --- own field : sense ---
10598

106-
switch (ent->Sense())
107-
{
108-
case StepBasic_aobAhead:
109-
SW.SendEnum(aobAhead);
110-
break;
111-
case StepBasic_aobExact:
112-
SW.SendEnum(aobExact);
113-
break;
114-
case StepBasic_aobBehind:
115-
SW.SendEnum(aobBehind);
116-
break;
117-
}
99+
SW.SendEnum(RWStepBasic_RWAheadOrBehind::ConvertToString(ent->Sense()));
118100
}

src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductDefinitionFormationWithSpecifiedSource.cxx

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@
2020
#include <StepData_StepWriter.hxx>
2121
#include <TCollection_AsciiString.hxx>
2222

23-
// --- Enum : Source ---
24-
static TCollection_AsciiString sBought(".BOUGHT.");
25-
static TCollection_AsciiString sNotKnown(".NOT_KNOWN.");
26-
static TCollection_AsciiString sMade(".MADE.");
23+
#include "RWStepBasic_RWSource.pxx"
2724

2825
RWStepBasic_RWProductDefinitionFormationWithSpecifiedSource::
2926
RWStepBasic_RWProductDefinitionFormationWithSpecifiedSource()
@@ -66,14 +63,10 @@ void RWStepBasic_RWProductDefinitionFormationWithSpecifiedSource::ReadStep(
6663
if (data->ParamType(num, 4) == Interface_ParamEnum)
6764
{
6865
Standard_CString text = data->ParamCValue(num, 4);
69-
if (sBought.IsEqual(text))
70-
aMakeOrBuy = StepBasic_sBought;
71-
else if (sNotKnown.IsEqual(text))
72-
aMakeOrBuy = StepBasic_sNotKnown;
73-
else if (sMade.IsEqual(text))
74-
aMakeOrBuy = StepBasic_sMade;
75-
else
66+
if (!RWStepBasic_RWSource::ConvertToEnum(text, aMakeOrBuy))
67+
{
7668
ach->AddFail("Enumeration source has not an allowed value");
69+
}
7770
}
7871
else
7972
ach->AddFail("Parameter #4 (make_or_buy) is not an enumeration");
@@ -102,18 +95,7 @@ void RWStepBasic_RWProductDefinitionFormationWithSpecifiedSource::WriteStep(
10295

10396
// --- own field : makeOrBuy ---
10497

105-
switch (ent->MakeOrBuy())
106-
{
107-
case StepBasic_sBought:
108-
SW.SendEnum(sBought);
109-
break;
110-
case StepBasic_sNotKnown:
111-
SW.SendEnum(sNotKnown);
112-
break;
113-
case StepBasic_sMade:
114-
SW.SendEnum(sMade);
115-
break;
116-
}
98+
SW.SendEnum(RWStepBasic_RWSource::ConvertToString(ent->MakeOrBuy()));
11799
}
118100

119101
void RWStepBasic_RWProductDefinitionFormationWithSpecifiedSource::Share(
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
// Copyright (c) 2025 OPEN CASCADE SAS
2+
//
3+
// This file is part of Open CASCADE Technology software library.
4+
//
5+
// This library is free software; you can redistribute it and/or modify it under
6+
// the terms of the GNU Lesser General Public License version 2.1 as published
7+
// by the Free Software Foundation, with special exception defined in the file
8+
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9+
// distribution for complete text of the license and disclaimer of any warranty.
10+
//
11+
// Alternatively, this file may be used under the terms of Open CASCADE
12+
// commercial license or contractual agreement.
13+
14+
#ifndef _RWStepBasic_RWSiPrefix_HeaderFile
15+
#define _RWStepBasic_RWSiPrefix_HeaderFile
16+
17+
#include <StepBasic_SiPrefix.hxx>
18+
#include <Standard_CString.hxx>
19+
20+
namespace RWStepBasic_RWSiPrefix
21+
{
22+
static constexpr char spExa[] = ".EXA.";
23+
static constexpr char spPico[] = ".PICO.";
24+
static constexpr char spMega[] = ".MEGA.";
25+
static constexpr char spFemto[] = ".FEMTO.";
26+
static constexpr char spAtto[] = ".ATTO.";
27+
static constexpr char spCenti[] = ".CENTI.";
28+
static constexpr char spNano[] = ".NANO.";
29+
static constexpr char spHecto[] = ".HECTO.";
30+
static constexpr char spMicro[] = ".MICRO.";
31+
static constexpr char spTera[] = ".TERA.";
32+
static constexpr char spGiga[] = ".GIGA.";
33+
static constexpr char spMilli[] = ".MILLI.";
34+
static constexpr char spPeta[] = ".PETA.";
35+
static constexpr char spDeci[] = ".DECI.";
36+
static constexpr char spKilo[] = ".KILO.";
37+
static constexpr char spDeca[] = ".DECA.";
38+
39+
//! Convert StepBasic_SiPrefix to string
40+
//! @param theSourceEnum The StepBasic_SiPrefix value to convert
41+
//! @return The corresponding string representation or nullptr if not found
42+
inline const char* ConvertToString(const StepBasic_SiPrefix theSourceEnum)
43+
{
44+
switch (theSourceEnum)
45+
{
46+
case StepBasic_spExa:
47+
return spExa;
48+
case StepBasic_spPico:
49+
return spPico;
50+
case StepBasic_spMega:
51+
return spMega;
52+
case StepBasic_spFemto:
53+
return spFemto;
54+
case StepBasic_spAtto:
55+
return spAtto;
56+
case StepBasic_spCenti:
57+
return spCenti;
58+
case StepBasic_spNano:
59+
return spNano;
60+
case StepBasic_spHecto:
61+
return spHecto;
62+
case StepBasic_spMicro:
63+
return spMicro;
64+
case StepBasic_spTera:
65+
return spTera;
66+
case StepBasic_spGiga:
67+
return spGiga;
68+
case StepBasic_spMilli:
69+
return spMilli;
70+
case StepBasic_spPeta:
71+
return spPeta;
72+
case StepBasic_spDeci:
73+
return spDeci;
74+
case StepBasic_spKilo:
75+
return spKilo;
76+
case StepBasic_spDeca:
77+
return spDeca;
78+
}
79+
return nullptr; // Default value
80+
}
81+
82+
//! Convert string to StepBasic_SiPrefix
83+
//! @param thePrefixStr The string to convert
84+
//! @param theResultEnum The corresponding StepBasic_SiPrefix value
85+
//! @return Standard_True if the conversion was successful, Standard_False otherwise
86+
inline bool ConvertToEnum(const Standard_CString thePrefixStr, StepBasic_SiPrefix& theResultEnum)
87+
{
88+
if (IsEqual(thePrefixStr, spExa))
89+
{
90+
theResultEnum = StepBasic_spExa;
91+
}
92+
else if (IsEqual(thePrefixStr, spPico))
93+
{
94+
theResultEnum = StepBasic_spPico;
95+
}
96+
else if (IsEqual(thePrefixStr, spMega))
97+
{
98+
theResultEnum = StepBasic_spMega;
99+
}
100+
else if (IsEqual(thePrefixStr, spFemto))
101+
{
102+
theResultEnum = StepBasic_spFemto;
103+
}
104+
else if (IsEqual(thePrefixStr, spAtto))
105+
{
106+
theResultEnum = StepBasic_spAtto;
107+
}
108+
else if (IsEqual(thePrefixStr, spCenti))
109+
{
110+
theResultEnum = StepBasic_spCenti;
111+
}
112+
else if (IsEqual(thePrefixStr, spNano))
113+
{
114+
theResultEnum = StepBasic_spNano;
115+
}
116+
else if (IsEqual(thePrefixStr, spHecto))
117+
{
118+
theResultEnum = StepBasic_spHecto;
119+
}
120+
else if (IsEqual(thePrefixStr, spMicro))
121+
{
122+
theResultEnum = StepBasic_spMicro;
123+
}
124+
else if (IsEqual(thePrefixStr, spTera))
125+
{
126+
theResultEnum = StepBasic_spTera;
127+
}
128+
else if (IsEqual(thePrefixStr, spGiga))
129+
{
130+
theResultEnum = StepBasic_spGiga;
131+
}
132+
else if (IsEqual(thePrefixStr, spMilli))
133+
{
134+
theResultEnum = StepBasic_spMilli;
135+
}
136+
else if (IsEqual(thePrefixStr, spPeta))
137+
{
138+
theResultEnum = StepBasic_spPeta;
139+
}
140+
else if (IsEqual(thePrefixStr, spDeci))
141+
{
142+
theResultEnum = StepBasic_spDeci;
143+
}
144+
else if (IsEqual(thePrefixStr, spKilo))
145+
{
146+
theResultEnum = StepBasic_spKilo;
147+
}
148+
else if (IsEqual(thePrefixStr, spDeca))
149+
{
150+
theResultEnum = StepBasic_spDeca;
151+
}
152+
else
153+
{
154+
return Standard_False;
155+
}
156+
return Standard_True;
157+
}
158+
159+
} // namespace RWStepBasic_RWSiPrefix
160+
161+
#endif // _RWStepBasic_RWSiPrefix_HeaderFile

0 commit comments

Comments
 (0)