Skip to content

Commit 613b8d4

Browse files
committed
Rename length unit to linear unit.
1 parent 0de27d1 commit 613b8d4

File tree

6 files changed

+38
-38
lines changed

6 files changed

+38
-38
lines changed

dist/occt-import-js.wasm

0 Bytes
Binary file not shown.

occt-import-js/src/importer-xcaf.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -372,20 +372,20 @@ Importer::Result ImporterXcaf::LoadFile (const std::vector<std::uint8_t>& fileCo
372372
document = new TDocStd_Document ("XmlXCAF");
373373

374374
UnitsMethods_LengthUnit lengthUnit = UnitsMethods_LengthUnit_Millimeter;
375-
switch (params.lengthUnit) {
376-
case ImportParams::LengthUnit::Millimeter:
375+
switch (params.linearUnit) {
376+
case ImportParams::LinearUnit::Millimeter:
377377
lengthUnit = UnitsMethods_LengthUnit_Millimeter;
378378
break;
379-
case ImportParams::LengthUnit::Centimeter:
379+
case ImportParams::LinearUnit::Centimeter:
380380
lengthUnit = UnitsMethods_LengthUnit_Centimeter;
381381
break;
382-
case ImportParams::LengthUnit::Meter:
382+
case ImportParams::LinearUnit::Meter:
383383
lengthUnit = UnitsMethods_LengthUnit_Meter;
384384
break;
385-
case ImportParams::LengthUnit::Inch:
385+
case ImportParams::LinearUnit::Inch:
386386
lengthUnit = UnitsMethods_LengthUnit_Inch;
387387
break;
388-
case ImportParams::LengthUnit::Foot:
388+
case ImportParams::LinearUnit::Foot:
389389
lengthUnit = UnitsMethods_LengthUnit_Foot;
390390
break;
391391
default:

occt-import-js/src/importer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Node::~Node ()
4949
}
5050

5151
ImportParams::ImportParams () :
52-
lengthUnit (LengthUnit::Millimeter),
52+
linearUnit (LinearUnit::Millimeter),
5353
linearDeflectionType (LinearDeflectionType::BoundingBoxRatio),
5454
linearDeflection (0.001),
5555
angularDeflection (0.5)

occt-import-js/src/importer.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,7 @@ class Node
6262
class ImportParams
6363
{
6464
public:
65-
enum class LinearDeflectionType
66-
{
67-
BoundingBoxRatio,
68-
AbsoluteValue
69-
};
70-
71-
enum class LengthUnit
65+
enum class LinearUnit
7266
{
7367
Millimeter,
7468
Centimeter,
@@ -77,9 +71,15 @@ class ImportParams
7771
Foot
7872
};
7973

74+
enum class LinearDeflectionType
75+
{
76+
BoundingBoxRatio,
77+
AbsoluteValue
78+
};
79+
8080
ImportParams ();
8181

82-
LengthUnit lengthUnit;
82+
LinearUnit linearUnit;
8383
LinearDeflectionType linearDeflectionType;
8484
double linearDeflection;
8585
double angularDeflection;

occt-import-js/src/js-interface.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -176,19 +176,19 @@ static ImportParams GetImportParams (const emscripten::val& paramsVal)
176176
return params;
177177
}
178178

179-
if (paramsVal.hasOwnProperty ("lengthUnit")) {
180-
emscripten::val lengthUnit = paramsVal["lengthUnit"];
181-
std::string lengthUnitStr = lengthUnit.as<std::string> ();
182-
if (lengthUnitStr == "millimeter") {
183-
params.lengthUnit = ImportParams::LengthUnit::Millimeter;
184-
} else if (lengthUnitStr == "centimeter") {
185-
params.lengthUnit = ImportParams::LengthUnit::Centimeter;
186-
} else if (lengthUnitStr == "meter") {
187-
params.lengthUnit = ImportParams::LengthUnit::Meter;
188-
} else if (lengthUnitStr == "inch") {
189-
params.lengthUnit = ImportParams::LengthUnit::Inch;
190-
} else if (lengthUnitStr == "foot") {
191-
params.lengthUnit = ImportParams::LengthUnit::Foot;
179+
if (paramsVal.hasOwnProperty ("linearUnit")) {
180+
emscripten::val linearUnit = paramsVal["linearUnit"];
181+
std::string linearUnitStr = linearUnit.as<std::string> ();
182+
if (linearUnitStr == "millimeter") {
183+
params.linearUnit = ImportParams::LinearUnit::Millimeter;
184+
} else if (linearUnitStr == "centimeter") {
185+
params.linearUnit = ImportParams::LinearUnit::Centimeter;
186+
} else if (linearUnitStr == "meter") {
187+
params.linearUnit = ImportParams::LinearUnit::Meter;
188+
} else if (linearUnitStr == "inch") {
189+
params.linearUnit = ImportParams::LinearUnit::Inch;
190+
} else if (linearUnitStr == "foot") {
191+
params.linearUnit = ImportParams::LinearUnit::Foot;
192192
}
193193
}
194194

test/test.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,8 @@ it ('Manual deflection with absolute value', function () {
292292
});
293293

294294
it ('Manual deflection with absolute value and units', function () {
295-
CheckVertexParamCount ({ lengthUnit : 'millimeter', linearDeflectionType : 'absolute_value', linearDeflection : 10 }, 162);
296-
CheckVertexParamCount ({ lengthUnit : 'meter', linearDeflectionType : 'absolute_value', linearDeflection : 0.01 }, 162);
295+
CheckVertexParamCount ({ linearUnit : 'millimeter', linearDeflectionType : 'absolute_value', linearDeflection : 10 }, 162);
296+
CheckVertexParamCount ({ linearUnit : 'meter', linearDeflectionType : 'absolute_value', linearDeflection : 0.01 }, 162);
297297
});
298298

299299
});
@@ -322,17 +322,17 @@ it ('Default unit is mm', function () {
322322
});
323323

324324
it ('Convert to m', function () {
325-
CheckXSize ({ lengthUnit : 'meter' }, 'cube-m.step', 1.0);
326-
CheckXSize ({ lengthUnit : 'meter' }, 'cube-mm.step', 1.0);
327-
CheckXSize ({ lengthUnit : 'meter' }, 'cube-in.step', 1.0);
325+
CheckXSize ({ linearUnit : 'meter' }, 'cube-m.step', 1.0);
326+
CheckXSize ({ linearUnit : 'meter' }, 'cube-mm.step', 1.0);
327+
CheckXSize ({ linearUnit : 'meter' }, 'cube-in.step', 1.0);
328328
});
329329

330330
it ('Convert to other units', function () {
331-
CheckXSize ({ lengthUnit : 'millimeter' }, 'cube-m.step', 1000.0);
332-
CheckXSize ({ lengthUnit : 'centimeter' }, 'cube-m.step', 100.0);
333-
CheckXSize ({ lengthUnit : 'meter' }, 'cube-m.step', 1.0);
334-
CheckXSize ({ lengthUnit : 'inch' }, 'cube-m.step', 39.37007);
335-
CheckXSize ({ lengthUnit : 'foot' }, 'cube-m.step', 3.28084);
331+
CheckXSize ({ linearUnit : 'millimeter' }, 'cube-m.step', 1000.0);
332+
CheckXSize ({ linearUnit : 'centimeter' }, 'cube-m.step', 100.0);
333+
CheckXSize ({ linearUnit : 'meter' }, 'cube-m.step', 1.0);
334+
CheckXSize ({ linearUnit : 'inch' }, 'cube-m.step', 39.37007);
335+
CheckXSize ({ linearUnit : 'foot' }, 'cube-m.step', 3.28084);
336336
});
337337

338338
});

0 commit comments

Comments
 (0)