10 changes: 10 additions & 0 deletions scripts/run_all_tests.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -47,11 +47,17 @@ geomPipeline.py ../data/test_geometry/test_geometry.stp -o test_geometry_result.
geomPipeline.py check ../data/test_geometry/test_geometry_manifest.json --verbosity WARNING
if [ ! $? -eq 0 ] ; then echo "Error during geometry test" ; exit 1 ; fi

# test scaling, output to a diff output folder
geomPipeline.py imprint ../data/test_geometry/test_geometry.stp -o /tmp/test_geometry_scaled.brep --output-unit M
geomPipeline.py imprint ../data/test_geometry/test_geometry.stp --working-dir /tmp/ -o test_geometry_scaled.stp --output-unit M
if [ ! $? -eq 0 ] ; then echo "Error during geometry output unit (scaling) test " ; exit 1 ; fi

# test single thread mode, only for non-coupled operations
geomPipeline.py check ../data/test_geometry/test_geometry.stp --thread-count 1 --verbosity WARNING
if [ ! $? -eq 0 ] ; then echo "Error during geometry test in single thread mode" ; exit 1 ; fi

# test_*.py has not been installed by package, so must be copied into this place
# todo: pytest to auto discover tests
cp ../../src/python/*.py ./
if [ $? -eq 0 ]
then
Expand All@@ -62,6 +68,10 @@ then
if [ $? -eq 0 ]; then
test_collision.py
fi

if [ $? -eq 0 ]; then
test_inscribedShape.py
fi
echo "test completed"
else
echo "geometry pipeline test failed"
Expand Down
1 change: 1 addition & 0 deletions src/Geom/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,7 @@ include_directories("third-party/SGeom/src/GEOMAlgo")
set(MyGeom_SOURCES
"OccUtils.cpp"
#"GeometryFixer.cpp"
"InscribedShapeBuilder.cpp"
"CollisionDetector.cpp"
"Geom.cpp"
"OpenCascadeAll.cpp"
Expand Down
3 changes: 3 additions & 0 deletions src/Geom/Geom.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,7 @@
#include "GeometryPropertyBuilder.h"
#include "GeometrySearchBuilder.h"
#include "GeometryShapeChecker.h"
#include "InscribedShapeBuilder.h"

#include "GeometryReader.h"
#include "GeometryWriter.h"
Expand All@@ -37,6 +38,7 @@ TYPESYSTEM_SOURCE(Geom::GeometryShapeChecker, Geom::GeometryProcessor);
TYPESYSTEM_SOURCE(Geom::GeometryPropertyBuilder, Geom::GeometryProcessor);
TYPESYSTEM_SOURCE(Geom::GeometrySearchBuilder, Geom::GeometryProcessor);
TYPESYSTEM_SOURCE(Geom::BoundBoxBuilder, Geom::GeometryProcessor);
TYPESYSTEM_SOURCE(Geom::InscribedShapeBuilder, Geom::GeometryProcessor);

TYPESYSTEM_SOURCE(Geom::CollisionDetector, Geom::GeometryProcessor);
TYPESYSTEM_SOURCE(Geom::GeometryImprinter, Geom::CollisionDetector);
Expand All@@ -60,6 +62,7 @@ namespace Geom
GeometryPropertyBuilder::init();
GeometrySearchBuilder::init();
BoundBoxBuilder::init();
InscribedShapeBuilder::init();
GeometryShapeChecker::init();
CollisionDetector::init();
GeometryImprinter::init();
Expand Down
4 changes: 2 additions & 2 deletions src/Geom/GeometryPropertyBuilder.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -76,8 +76,8 @@ namespace Geom
{
// max and min volume check!
double max_volume = 0;
double min_volume = 1e100;
double max_volume_threshold = 1e16; // todo: get from config
double min_volume = 1e100; // unit is mm^3
double max_volume_threshold = 1e16; // todo: get from config parameter
for (size_t i = 0; i < myInputData->itemCount(); i++)
{
const auto& p = myGeometryProperties[i];
Expand Down
26 changes: 24 additions & 2 deletions src/Geom/GeometryTypes.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,6 +22,15 @@ inline void from_json(const nlohmann::json& j, Bnd_Box& b)
b.Update(v[0], v[1], v[2], v[3], v[4], v[5]);
}

inline void to_json(nlohmann::json& j, const Bnd_Sphere& b)
{
gp_XYZ c = b.Center();
j = nlohmann::json{c.X(), c.Y(), c.Z(), b.Radius()};
}

/// OpenCASCADE has T::DumpJson(Standard_OStream & theOStream, Standard_Integer theDepth = -1 )
/// T::InitFromJson(const Standard_SStream & theSStream, Standard_Integer & theStreamPos)

/// RGBA float array, conmponent value range [0, 1.0]
inline void to_json(nlohmann::json& j, const Quantity_Color& p)
{
Expand All@@ -48,11 +57,16 @@ namespace Geom
typedef Standard_Integer ItemHashType;
static const ItemHashType ItemHashMax = INT_MAX;

typedef std::uint64_t UniqueIdType; // also define in PPP/UniqueId.h
typedef std::uint64_t UniqueIdType; /// defined in PPP/UniqueId.h
/// map has order (non contiguous in memory), can increase capacity
typedef MapType<ItemHashType, TopoDS_Shape> ItemContainerType;
typedef std::shared_ptr<ItemContainerType> ItemContainerPType;

typedef gp_Pnt PointType;
/// conventional C enum starting from zero, can be used as array index
typedef GeomAbs_SurfaceType SurfaceType;
const size_t SurfacTypeCount = 11; /// total count of SurfaceType enum elements

/**
* from OCCT to FreeCAD style better enum name
* integer value: ShapeType == TopAbs_ShapeEnum; but NOT compatible
Expand DownExpand Up@@ -152,7 +166,7 @@ namespace Geom
return ShapeErrorType::NoError;
}

class CollisionInfo
struct CollisionInfo
{
public:
ItemIndexType first;
Expand All@@ -161,6 +175,14 @@ namespace Geom
CollisionType type;

CollisionInfo() = default;
// C++20 prevents conversion form <brace-enclosed initializer list> to this type
CollisionInfo(ItemIndexType _first, ItemIndexType _second, double _value, CollisionType _type)
: first(_first)
, second(_second)
, value(_value)
, type(_type)
{
}
};
inline void to_json(json& j, const CollisionInfo& p)
{
Expand Down
49 changes: 43 additions & 6 deletions src/Geom/GeometryWriter.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -105,8 +105,26 @@ namespace Geom
LOG_F(INFO, "%s", sout.str().c_str());
}

// TODO: query inputData() metadata for inputUnit
/// return 1 which means no scaling is needed
/// not quite useful for
double calcOutputScale(const std::string& outputUnit)
{
const std::string inputUnit = "MM";
if (outputUnit == inputUnit)
return 1;
else if ("MM" == inputUnit && outputUnit == "M")
return 0.001;
else
{
LOG_F(ERROR, "scaling for input length unit %s and output unit %s is not supported", inputUnit.c_str(),
outputUnit.c_str());
return 1;
}
}

/// can export floating shapes which can not be compoSolid
void exportCompound(const std::string& file_name)
void exportCompound(const std::string& file_name, double scale = 1.0)
{
summary();

Expand All@@ -122,6 +140,10 @@ namespace Geom
LOG_F(INFO, "result is not merged (duplicated face removed) for result brep file");
finalShape = OccUtils::createCompound(*mySolids, myShapeErrors);
}

if (scale != 1) // double type has integer value can be compared with integer by ==
finalShape = OccUtils::scaleShape(finalShape, scale);

/// NOTE: exportMetaData() is done in the second GeometryPropertyBuilder processor
BRepTools::Write(finalShape, file_name.c_str()); // progress reporter can be the last arg
}
Expand All@@ -131,15 +153,19 @@ namespace Geom
* */
bool exportGeometry(const std::string file_name)
{
std::string defaultLengthUnit = "MM";
auto outputUnit = parameterValue<std::string>("outputUnit", defaultLengthUnit);
double scale = calcOutputScale(outputUnit);

if (Utilities::hasFileExt(file_name, "brp") || Utilities::hasFileExt(file_name, "brep"))
{
exportCompound(file_name);
exportCompound(file_name, scale);
return true;
}
else if (Utilities::hasFileExt(file_name, "stp") || Utilities::hasFileExt(file_name, "step"))
{
// LOG_F(INFO, "export Dataset pointed by member hDoc");
Handle(TDocStd_Document) aDoc = createDocument();
Handle(TDocStd_Document) aDoc = createDocument(scale);

/// the user can work with an already prepared WorkSession or create a new one
Standard_Boolean scratch = Standard_False;
Expand All@@ -150,15 +176,23 @@ namespace Geom
// recommended value, others shape mode are available
// Interface_Static::SetCVal("write.step.schema", "AP214IS");
Interface_Static::SetIVal("write.step.assembly", 1); // global variable
// Interface_Static::SetIVal ("write.step.nonmanifold", 1);
// "write.precision.val" = 0.0001 is the default value

if (outputUnit != defaultLengthUnit)
{
Interface_Static::SetCVal("xstep.cascade.unit", outputUnit.c_str());
Interface_Static::SetCVal("write.step.unit", outputUnit.c_str());
// all vertex coordinate will not be scaled during writing out, change unit,
// but it causes scaling at reading back
}

STEPCAFControl_Writer writer(WS, scratch);
// this writer contains a STEPControl_Writer class, not by inheritance
// writer.SetColorMode(mode);
if (!writer.Transfer(aDoc, mode))
{
LOG_F(ERROR, "The Dataset cannot be translated or gives no result");
// abandon ..
}

IFSelect_ReturnStatus stat = writer.Write(file_name.c_str());
Expand All@@ -173,7 +207,7 @@ namespace Geom
return false;
}

Handle(TDocStd_Document) createDocument()
Handle(TDocStd_Document) createDocument(double scale = 1)
{

Handle(XCAFApp_Application) hApp = XCAFApp_Application::GetApplication();
Expand All@@ -194,7 +228,10 @@ namespace Geom
for (auto& item : *mySolids)
{
TDF_Label partLabel = shapeTool->NewShape();
shapeTool->SetShape(partLabel, item.second);
if (scale != 1)
shapeTool->SetShape(partLabel, OccUtils::scaleShape(item.second, scale));
else
shapeTool->SetShape(partLabel, item.second);
colorTool->SetColor(partLabel, (*myColorMap)[item.first], XCAFDoc_ColorGen);
TDataStd_Name::Set(partLabel, TCollection_ExtendedString((*myNameMap)[item.first].c_str(), true));
/// Material not yet supported
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content
10 changes: 10 additions & 0 deletions scripts/run_all_tests.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -47,11 +47,17 @@ geomPipeline.py ../data/test_geometry/test_geometry.stp -o test_geometry_result.
geomPipeline.py check ../data/test_geometry/test_geometry_manifest.json --verbosity WARNING
if [ ! $? -eq 0 ] ; then echo "Error during geometry test" ; exit 1 ; fi

# test scaling, output to a diff output folder
geomPipeline.py imprint ../data/test_geometry/test_geometry.stp -o /tmp/test_geometry_scaled.brep --output-unit M
geomPipeline.py imprint ../data/test_geometry/test_geometry.stp --working-dir /tmp/ -o test_geometry_scaled.stp --output-unit M
if [ ! $? -eq 0 ] ; then echo "Error during geometry output unit (scaling) test " ; exit 1 ; fi

# test single thread mode, only for non-coupled operations
geomPipeline.py check ../data/test_geometry/test_geometry.stp --thread-count 1 --verbosity WARNING
if [ ! $? -eq 0 ] ; then echo "Error during geometry test in single thread mode" ; exit 1 ; fi

# test_*.py has not been installed by package, so must be copied into this place
# todo: pytest to auto discover tests
cp ../../src/python/*.py ./
if [ $? -eq 0 ]
then
Expand All@@ -62,6 +68,10 @@ then
if [ $? -eq 0 ]; then
test_collision.py
fi

if [ $? -eq 0 ]; then
test_inscribedShape.py
fi
echo "test completed"
else
echo "geometry pipeline test failed"
Expand Down
1 change: 1 addition & 0 deletions src/Geom/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,7 @@ include_directories("third-party/SGeom/src/GEOMAlgo")
set(MyGeom_SOURCES
"OccUtils.cpp"
#"GeometryFixer.cpp"
"InscribedShapeBuilder.cpp"
"CollisionDetector.cpp"
"Geom.cpp"
"OpenCascadeAll.cpp"
Expand Down
3 changes: 3 additions & 0 deletions src/Geom/Geom.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,7 @@
#include "GeometryPropertyBuilder.h"
#include "GeometrySearchBuilder.h"
#include "GeometryShapeChecker.h"
#include "InscribedShapeBuilder.h"

#include "GeometryReader.h"
#include "GeometryWriter.h"
Expand All@@ -37,6 +38,7 @@ TYPESYSTEM_SOURCE(Geom::GeometryShapeChecker, Geom::GeometryProcessor);
TYPESYSTEM_SOURCE(Geom::GeometryPropertyBuilder, Geom::GeometryProcessor);
TYPESYSTEM_SOURCE(Geom::GeometrySearchBuilder, Geom::GeometryProcessor);
TYPESYSTEM_SOURCE(Geom::BoundBoxBuilder, Geom::GeometryProcessor);
TYPESYSTEM_SOURCE(Geom::InscribedShapeBuilder, Geom::GeometryProcessor);

TYPESYSTEM_SOURCE(Geom::CollisionDetector, Geom::GeometryProcessor);
TYPESYSTEM_SOURCE(Geom::GeometryImprinter, Geom::CollisionDetector);
Expand All@@ -60,6 +62,7 @@ namespace Geom
GeometryPropertyBuilder::init();
GeometrySearchBuilder::init();
BoundBoxBuilder::init();
InscribedShapeBuilder::init();
GeometryShapeChecker::init();
CollisionDetector::init();
GeometryImprinter::init();
Expand Down
4 changes: 2 additions & 2 deletions src/Geom/GeometryPropertyBuilder.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -76,8 +76,8 @@ namespace Geom
{
// max and min volume check!
double max_volume = 0;
double min_volume = 1e100;
double max_volume_threshold = 1e16; // todo: get from config
double min_volume = 1e100; // unit is mm^3
double max_volume_threshold = 1e16; // todo: get from config parameter
for (size_t i = 0; i < myInputData->itemCount(); i++)
{
const auto& p = myGeometryProperties[i];
Expand Down
26 changes: 24 additions & 2 deletions src/Geom/GeometryTypes.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,6 +22,15 @@ inline void from_json(const nlohmann::json& j, Bnd_Box& b)
b.Update(v[0], v[1], v[2], v[3], v[4], v[5]);
}

inline void to_json(nlohmann::json& j, const Bnd_Sphere& b)
{
gp_XYZ c = b.Center();
j = nlohmann::json{c.X(), c.Y(), c.Z(), b.Radius()};
}

/// OpenCASCADE has T::DumpJson(Standard_OStream & theOStream, Standard_Integer theDepth = -1 )
/// T::InitFromJson(const Standard_SStream & theSStream, Standard_Integer & theStreamPos)

/// RGBA float array, conmponent value range [0, 1.0]
inline void to_json(nlohmann::json& j, const Quantity_Color& p)
{
Expand All@@ -48,11 +57,16 @@ namespace Geom
typedef Standard_Integer ItemHashType;
static const ItemHashType ItemHashMax = INT_MAX;

typedef std::uint64_t UniqueIdType; // also define in PPP/UniqueId.h
typedef std::uint64_t UniqueIdType; /// defined in PPP/UniqueId.h
/// map has order (non contiguous in memory), can increase capacity
typedef MapType<ItemHashType, TopoDS_Shape> ItemContainerType;
typedef std::shared_ptr<ItemContainerType> ItemContainerPType;

typedef gp_Pnt PointType;
/// conventional C enum starting from zero, can be used as array index
typedef GeomAbs_SurfaceType SurfaceType;
const size_t SurfacTypeCount = 11; /// total count of SurfaceType enum elements

/**
* from OCCT to FreeCAD style better enum name
* integer value: ShapeType == TopAbs_ShapeEnum; but NOT compatible
Expand DownExpand Up@@ -152,7 +166,7 @@ namespace Geom
return ShapeErrorType::NoError;
}

class CollisionInfo
struct CollisionInfo
{
public:
ItemIndexType first;
Expand All@@ -161,6 +175,14 @@ namespace Geom
CollisionType type;

CollisionInfo() = default;
// C++20 prevents conversion form <brace-enclosed initializer list> to this type
CollisionInfo(ItemIndexType _first, ItemIndexType _second, double _value, CollisionType _type)
: first(_first)
, second(_second)
, value(_value)
, type(_type)
{
}
};
inline void to_json(json& j, const CollisionInfo& p)
{
Expand Down
49 changes: 43 additions & 6 deletions src/Geom/GeometryWriter.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -105,8 +105,26 @@ namespace Geom
LOG_F(INFO, "%s", sout.str().c_str());
}

// TODO: query inputData() metadata for inputUnit
/// return 1 which means no scaling is needed
/// not quite useful for
double calcOutputScale(const std::string& outputUnit)
{
const std::string inputUnit = "MM";
if (outputUnit == inputUnit)
return 1;
else if ("MM" == inputUnit && outputUnit == "M")
return 0.001;
else
{
LOG_F(ERROR, "scaling for input length unit %s and output unit %s is not supported", inputUnit.c_str(),
outputUnit.c_str());
return 1;
}
}

/// can export floating shapes which can not be compoSolid
void exportCompound(const std::string& file_name)
void exportCompound(const std::string& file_name, double scale = 1.0)
{
summary();

Expand All@@ -122,6 +140,10 @@ namespace Geom
LOG_F(INFO, "result is not merged (duplicated face removed) for result brep file");
finalShape = OccUtils::createCompound(*mySolids, myShapeErrors);
}

if (scale != 1) // double type has integer value can be compared with integer by ==
finalShape = OccUtils::scaleShape(finalShape, scale);

/// NOTE: exportMetaData() is done in the second GeometryPropertyBuilder processor
BRepTools::Write(finalShape, file_name.c_str()); // progress reporter can be the last arg
}
Expand All@@ -131,15 +153,19 @@ namespace Geom
* */
bool exportGeometry(const std::string file_name)
{
std::string defaultLengthUnit = "MM";
auto outputUnit = parameterValue<std::string>("outputUnit", defaultLengthUnit);
double scale = calcOutputScale(outputUnit);

if (Utilities::hasFileExt(file_name, "brp") || Utilities::hasFileExt(file_name, "brep"))
{
exportCompound(file_name);
exportCompound(file_name, scale);
return true;
}
else if (Utilities::hasFileExt(file_name, "stp") || Utilities::hasFileExt(file_name, "step"))
{
// LOG_F(INFO, "export Dataset pointed by member hDoc");
Handle(TDocStd_Document) aDoc = createDocument();
Handle(TDocStd_Document) aDoc = createDocument(scale);

/// the user can work with an already prepared WorkSession or create a new one
Standard_Boolean scratch = Standard_False;
Expand All@@ -150,15 +176,23 @@ namespace Geom
// recommended value, others shape mode are available
// Interface_Static::SetCVal("write.step.schema", "AP214IS");
Interface_Static::SetIVal("write.step.assembly", 1); // global variable
// Interface_Static::SetIVal ("write.step.nonmanifold", 1);
// "write.precision.val" = 0.0001 is the default value

if (outputUnit != defaultLengthUnit)
{
Interface_Static::SetCVal("xstep.cascade.unit", outputUnit.c_str());
Interface_Static::SetCVal("write.step.unit", outputUnit.c_str());
// all vertex coordinate will not be scaled during writing out, change unit,
// but it causes scaling at reading back
}

STEPCAFControl_Writer writer(WS, scratch);
// this writer contains a STEPControl_Writer class, not by inheritance
// writer.SetColorMode(mode);
if (!writer.Transfer(aDoc, mode))
{
LOG_F(ERROR, "The Dataset cannot be translated or gives no result");
// abandon ..
}

IFSelect_ReturnStatus stat = writer.Write(file_name.c_str());
Expand All@@ -173,7 +207,7 @@ namespace Geom
return false;
}

Handle(TDocStd_Document) createDocument()
Handle(TDocStd_Document) createDocument(double scale = 1)
{

Handle(XCAFApp_Application) hApp = XCAFApp_Application::GetApplication();
Expand All@@ -194,7 +228,10 @@ namespace Geom
for (auto& item : *mySolids)
{
TDF_Label partLabel = shapeTool->NewShape();
shapeTool->SetShape(partLabel, item.second);
if (scale != 1)
shapeTool->SetShape(partLabel, OccUtils::scaleShape(item.second, scale));
else
shapeTool->SetShape(partLabel, item.second);
colorTool->SetColor(partLabel, (*myColorMap)[item.first], XCAFDoc_ColorGen);
TDataStd_Name::Set(partLabel, TCollection_ExtendedString((*myNameMap)[item.first].c_str(), true));
/// Material not yet supported
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
10 changes: 10 additions & 0 deletions scripts/run_all_tests.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -47,11 +47,17 @@ geomPipeline.py ../data/test_geometry/test_geometry.stp -o test_geometry_result.
geomPipeline.py check ../data/test_geometry/test_geometry_manifest.json --verbosity WARNING
if [ ! $? -eq 0 ] ; then echo "Error during geometry test" ; exit 1 ; fi

# test scaling, output to a diff output folder
geomPipeline.py imprint ../data/test_geometry/test_geometry.stp -o /tmp/test_geometry_scaled.brep --output-unit M
geomPipeline.py imprint ../data/test_geometry/test_geometry.stp --working-dir /tmp/ -o test_geometry_scaled.stp --output-unit M
if [ ! $? -eq 0 ] ; then echo "Error during geometry output unit (scaling) test " ; exit 1 ; fi

# test single thread mode, only for non-coupled operations
geomPipeline.py check ../data/test_geometry/test_geometry.stp --thread-count 1 --verbosity WARNING
if [ ! $? -eq 0 ] ; then echo "Error during geometry test in single thread mode" ; exit 1 ; fi

# test_*.py has not been installed by package, so must be copied into this place
# todo: pytest to auto discover tests
cp ../../src/python/*.py ./
if [ $? -eq 0 ]
then
Expand All@@ -62,6 +68,10 @@ then
if [ $? -eq 0 ]; then
test_collision.py
fi

if [ $? -eq 0 ]; then
test_inscribedShape.py
fi
echo "test completed"
else
echo "geometry pipeline test failed"
Expand Down
1 change: 1 addition & 0 deletions src/Geom/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,7 @@ include_directories("third-party/SGeom/src/GEOMAlgo")
set(MyGeom_SOURCES
"OccUtils.cpp"
#"GeometryFixer.cpp"
"InscribedShapeBuilder.cpp"
"CollisionDetector.cpp"
"Geom.cpp"
"OpenCascadeAll.cpp"
Expand Down
3 changes: 3 additions & 0 deletions src/Geom/Geom.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,7 @@
#include "GeometryPropertyBuilder.h"
#include "GeometrySearchBuilder.h"
#include "GeometryShapeChecker.h"
#include "InscribedShapeBuilder.h"

#include "GeometryReader.h"
#include "GeometryWriter.h"
Expand All@@ -37,6 +38,7 @@ TYPESYSTEM_SOURCE(Geom::GeometryShapeChecker, Geom::GeometryProcessor);
TYPESYSTEM_SOURCE(Geom::GeometryPropertyBuilder, Geom::GeometryProcessor);
TYPESYSTEM_SOURCE(Geom::GeometrySearchBuilder, Geom::GeometryProcessor);
TYPESYSTEM_SOURCE(Geom::BoundBoxBuilder, Geom::GeometryProcessor);
TYPESYSTEM_SOURCE(Geom::InscribedShapeBuilder, Geom::GeometryProcessor);

TYPESYSTEM_SOURCE(Geom::CollisionDetector, Geom::GeometryProcessor);
TYPESYSTEM_SOURCE(Geom::GeometryImprinter, Geom::CollisionDetector);
Expand All@@ -60,6 +62,7 @@ namespace Geom
GeometryPropertyBuilder::init();
GeometrySearchBuilder::init();
BoundBoxBuilder::init();
InscribedShapeBuilder::init();
GeometryShapeChecker::init();
CollisionDetector::init();
GeometryImprinter::init();
Expand Down
4 changes: 2 additions & 2 deletions src/Geom/GeometryPropertyBuilder.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -76,8 +76,8 @@ namespace Geom
{
// max and min volume check!
double max_volume = 0;
double min_volume = 1e100;
double max_volume_threshold = 1e16; // todo: get from config
double min_volume = 1e100; // unit is mm^3
double max_volume_threshold = 1e16; // todo: get from config parameter
for (size_t i = 0; i < myInputData->itemCount(); i++)
{
const auto& p = myGeometryProperties[i];
Expand Down
26 changes: 24 additions & 2 deletions src/Geom/GeometryTypes.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,6 +22,15 @@ inline void from_json(const nlohmann::json& j, Bnd_Box& b)
b.Update(v[0], v[1], v[2], v[3], v[4], v[5]);
}

inline void to_json(nlohmann::json& j, const Bnd_Sphere& b)
{
gp_XYZ c = b.Center();
j = nlohmann::json{c.X(), c.Y(), c.Z(), b.Radius()};
}

/// OpenCASCADE has T::DumpJson(Standard_OStream & theOStream, Standard_Integer theDepth = -1 )
/// T::InitFromJson(const Standard_SStream & theSStream, Standard_Integer & theStreamPos)

/// RGBA float array, conmponent value range [0, 1.0]
inline void to_json(nlohmann::json& j, const Quantity_Color& p)
{
Expand All@@ -48,11 +57,16 @@ namespace Geom
typedef Standard_Integer ItemHashType;
static const ItemHashType ItemHashMax = INT_MAX;

typedef std::uint64_t UniqueIdType; // also define in PPP/UniqueId.h
typedef std::uint64_t UniqueIdType; /// defined in PPP/UniqueId.h
/// map has order (non contiguous in memory), can increase capacity
typedef MapType<ItemHashType, TopoDS_Shape> ItemContainerType;
typedef std::shared_ptr<ItemContainerType> ItemContainerPType;

typedef gp_Pnt PointType;
/// conventional C enum starting from zero, can be used as array index
typedef GeomAbs_SurfaceType SurfaceType;
const size_t SurfacTypeCount = 11; /// total count of SurfaceType enum elements

/**
* from OCCT to FreeCAD style better enum name
* integer value: ShapeType == TopAbs_ShapeEnum; but NOT compatible
Expand DownExpand Up@@ -152,7 +166,7 @@ namespace Geom
return ShapeErrorType::NoError;
}

class CollisionInfo
struct CollisionInfo
{
public:
ItemIndexType first;
Expand All@@ -161,6 +175,14 @@ namespace Geom
CollisionType type;

CollisionInfo() = default;
// C++20 prevents conversion form <brace-enclosed initializer list> to this type
CollisionInfo(ItemIndexType _first, ItemIndexType _second, double _value, CollisionType _type)
: first(_first)
, second(_second)
, value(_value)
, type(_type)
{
}
};
inline void to_json(json& j, const CollisionInfo& p)
{
Expand Down
49 changes: 43 additions & 6 deletions src/Geom/GeometryWriter.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -105,8 +105,26 @@ namespace Geom
LOG_F(INFO, "%s", sout.str().c_str());
}

// TODO: query inputData() metadata for inputUnit
/// return 1 which means no scaling is needed
/// not quite useful for
double calcOutputScale(const std::string& outputUnit)
{
const std::string inputUnit = "MM";
if (outputUnit == inputUnit)
return 1;
else if ("MM" == inputUnit && outputUnit == "M")
return 0.001;
else
{
LOG_F(ERROR, "scaling for input length unit %s and output unit %s is not supported", inputUnit.c_str(),
outputUnit.c_str());
return 1;
}
}

/// can export floating shapes which can not be compoSolid
void exportCompound(const std::string& file_name)
void exportCompound(const std::string& file_name, double scale = 1.0)
{
summary();

Expand All@@ -122,6 +140,10 @@ namespace Geom
LOG_F(INFO, "result is not merged (duplicated face removed) for result brep file");
finalShape = OccUtils::createCompound(*mySolids, myShapeErrors);
}

if (scale != 1) // double type has integer value can be compared with integer by ==
finalShape = OccUtils::scaleShape(finalShape, scale);

/// NOTE: exportMetaData() is done in the second GeometryPropertyBuilder processor
BRepTools::Write(finalShape, file_name.c_str()); // progress reporter can be the last arg
}
Expand All@@ -131,15 +153,19 @@ namespace Geom
* */
bool exportGeometry(const std::string file_name)
{
std::string defaultLengthUnit = "MM";
auto outputUnit = parameterValue<std::string>("outputUnit", defaultLengthUnit);
double scale = calcOutputScale(outputUnit);

if (Utilities::hasFileExt(file_name, "brp") || Utilities::hasFileExt(file_name, "brep"))
{
exportCompound(file_name);
exportCompound(file_name, scale);
return true;
}
else if (Utilities::hasFileExt(file_name, "stp") || Utilities::hasFileExt(file_name, "step"))
{
// LOG_F(INFO, "export Dataset pointed by member hDoc");
Handle(TDocStd_Document) aDoc = createDocument();
Handle(TDocStd_Document) aDoc = createDocument(scale);

/// the user can work with an already prepared WorkSession or create a new one
Standard_Boolean scratch = Standard_False;
Expand All@@ -150,15 +176,23 @@ namespace Geom
// recommended value, others shape mode are available
// Interface_Static::SetCVal("write.step.schema", "AP214IS");
Interface_Static::SetIVal("write.step.assembly", 1); // global variable
// Interface_Static::SetIVal ("write.step.nonmanifold", 1);
// "write.precision.val" = 0.0001 is the default value

if (outputUnit != defaultLengthUnit)
{
Interface_Static::SetCVal("xstep.cascade.unit", outputUnit.c_str());
Interface_Static::SetCVal("write.step.unit", outputUnit.c_str());
// all vertex coordinate will not be scaled during writing out, change unit,
// but it causes scaling at reading back
}

STEPCAFControl_Writer writer(WS, scratch);
// this writer contains a STEPControl_Writer class, not by inheritance
// writer.SetColorMode(mode);
if (!writer.Transfer(aDoc, mode))
{
LOG_F(ERROR, "The Dataset cannot be translated or gives no result");
// abandon ..
}

IFSelect_ReturnStatus stat = writer.Write(file_name.c_str());
Expand All@@ -173,7 +207,7 @@ namespace Geom
return false;
}

Handle(TDocStd_Document) createDocument()
Handle(TDocStd_Document) createDocument(double scale = 1)
{

Handle(XCAFApp_Application) hApp = XCAFApp_Application::GetApplication();
Expand All@@ -194,7 +228,10 @@ namespace Geom
for (auto& item : *mySolids)
{
TDF_Label partLabel = shapeTool->NewShape();
shapeTool->SetShape(partLabel, item.second);
if (scale != 1)
shapeTool->SetShape(partLabel, OccUtils::scaleShape(item.second, scale));
else
shapeTool->SetShape(partLabel, item.second);
colorTool->SetColor(partLabel, (*myColorMap)[item.first], XCAFDoc_ColorGen);
TDataStd_Name::Set(partLabel, TCollection_ExtendedString((*myNameMap)[item.first].c_str(), true));
/// Material not yet supported
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
10 changes: 10 additions & 0 deletions scripts/run_all_tests.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -47,11 +47,17 @@ geomPipeline.py ../data/test_geometry/test_geometry.stp -o test_geometry_result.
geomPipeline.py check ../data/test_geometry/test_geometry_manifest.json --verbosity WARNING
if [ ! $? -eq 0 ] ; then echo "Error during geometry test" ; exit 1 ; fi

# test scaling, output to a diff output folder
geomPipeline.py imprint ../data/test_geometry/test_geometry.stp -o /tmp/test_geometry_scaled.brep --output-unit M
geomPipeline.py imprint ../data/test_geometry/test_geometry.stp --working-dir /tmp/ -o test_geometry_scaled.stp --output-unit M
if [ ! $? -eq 0 ] ; then echo "Error during geometry output unit (scaling) test " ; exit 1 ; fi

# test single thread mode, only for non-coupled operations
geomPipeline.py check ../data/test_geometry/test_geometry.stp --thread-count 1 --verbosity WARNING
if [ ! $? -eq 0 ] ; then echo "Error during geometry test in single thread mode" ; exit 1 ; fi

# test_*.py has not been installed by package, so must be copied into this place
# todo: pytest to auto discover tests
cp ../../src/python/*.py ./
if [ $? -eq 0 ]
then
Expand All@@ -62,6 +68,10 @@ then
if [ $? -eq 0 ]; then
test_collision.py
fi

if [ $? -eq 0 ]; then
test_inscribedShape.py
fi
echo "test completed"
else
echo "geometry pipeline test failed"
Expand Down
1 change: 1 addition & 0 deletions src/Geom/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,7 @@ include_directories("third-party/SGeom/src/GEOMAlgo")
set(MyGeom_SOURCES
"OccUtils.cpp"
#"GeometryFixer.cpp"
"InscribedShapeBuilder.cpp"
"CollisionDetector.cpp"
"Geom.cpp"
"OpenCascadeAll.cpp"
Expand Down
3 changes: 3 additions & 0 deletions src/Geom/Geom.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,7 @@
#include "GeometryPropertyBuilder.h"
#include "GeometrySearchBuilder.h"
#include "GeometryShapeChecker.h"
#include "InscribedShapeBuilder.h"

#include "GeometryReader.h"
#include "GeometryWriter.h"
Expand All@@ -37,6 +38,7 @@ TYPESYSTEM_SOURCE(Geom::GeometryShapeChecker, Geom::GeometryProcessor);
TYPESYSTEM_SOURCE(Geom::GeometryPropertyBuilder, Geom::GeometryProcessor);
TYPESYSTEM_SOURCE(Geom::GeometrySearchBuilder, Geom::GeometryProcessor);
TYPESYSTEM_SOURCE(Geom::BoundBoxBuilder, Geom::GeometryProcessor);
TYPESYSTEM_SOURCE(Geom::InscribedShapeBuilder, Geom::GeometryProcessor);

TYPESYSTEM_SOURCE(Geom::CollisionDetector, Geom::GeometryProcessor);
TYPESYSTEM_SOURCE(Geom::GeometryImprinter, Geom::CollisionDetector);
Expand All@@ -60,6 +62,7 @@ namespace Geom
GeometryPropertyBuilder::init();
GeometrySearchBuilder::init();
BoundBoxBuilder::init();
InscribedShapeBuilder::init();
GeometryShapeChecker::init();
CollisionDetector::init();
GeometryImprinter::init();
Expand Down
4 changes: 2 additions & 2 deletions src/Geom/GeometryPropertyBuilder.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -76,8 +76,8 @@ namespace Geom
{
// max and min volume check!
double max_volume = 0;
double min_volume = 1e100;
double max_volume_threshold = 1e16; // todo: get from config
double min_volume = 1e100; // unit is mm^3
double max_volume_threshold = 1e16; // todo: get from config parameter
for (size_t i = 0; i < myInputData->itemCount(); i++)
{
const auto& p = myGeometryProperties[i];
Expand Down
26 changes: 24 additions & 2 deletions src/Geom/GeometryTypes.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,6 +22,15 @@ inline void from_json(const nlohmann::json& j, Bnd_Box& b)
b.Update(v[0], v[1], v[2], v[3], v[4], v[5]);
}

inline void to_json(nlohmann::json& j, const Bnd_Sphere& b)
{
gp_XYZ c = b.Center();
j = nlohmann::json{c.X(), c.Y(), c.Z(), b.Radius()};
}

/// OpenCASCADE has T::DumpJson(Standard_OStream & theOStream, Standard_Integer theDepth = -1 )
/// T::InitFromJson(const Standard_SStream & theSStream, Standard_Integer & theStreamPos)

/// RGBA float array, conmponent value range [0, 1.0]
inline void to_json(nlohmann::json& j, const Quantity_Color& p)
{
Expand All@@ -48,11 +57,16 @@ namespace Geom
typedef Standard_Integer ItemHashType;
static const ItemHashType ItemHashMax = INT_MAX;

typedef std::uint64_t UniqueIdType; // also define in PPP/UniqueId.h
typedef std::uint64_t UniqueIdType; /// defined in PPP/UniqueId.h
/// map has order (non contiguous in memory), can increase capacity
typedef MapType<ItemHashType, TopoDS_Shape> ItemContainerType;
typedef std::shared_ptr<ItemContainerType> ItemContainerPType;

typedef gp_Pnt PointType;
/// conventional C enum starting from zero, can be used as array index
typedef GeomAbs_SurfaceType SurfaceType;
const size_t SurfacTypeCount = 11; /// total count of SurfaceType enum elements

/**
* from OCCT to FreeCAD style better enum name
* integer value: ShapeType == TopAbs_ShapeEnum; but NOT compatible
Expand DownExpand Up@@ -152,7 +166,7 @@ namespace Geom
return ShapeErrorType::NoError;
}

class CollisionInfo
struct CollisionInfo
{
public:
ItemIndexType first;
Expand All@@ -161,6 +175,14 @@ namespace Geom
CollisionType type;

CollisionInfo() = default;
// C++20 prevents conversion form <brace-enclosed initializer list> to this type
CollisionInfo(ItemIndexType _first, ItemIndexType _second, double _value, CollisionType _type)
: first(_first)
, second(_second)
, value(_value)
, type(_type)
{
}
};
inline void to_json(json& j, const CollisionInfo& p)
{
Expand Down
49 changes: 43 additions & 6 deletions src/Geom/GeometryWriter.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -105,8 +105,26 @@ namespace Geom
LOG_F(INFO, "%s", sout.str().c_str());
}

// TODO: query inputData() metadata for inputUnit
/// return 1 which means no scaling is needed
/// not quite useful for
double calcOutputScale(const std::string& outputUnit)
{
const std::string inputUnit = "MM";
if (outputUnit == inputUnit)
return 1;
else if ("MM" == inputUnit && outputUnit == "M")
return 0.001;
else
{
LOG_F(ERROR, "scaling for input length unit %s and output unit %s is not supported", inputUnit.c_str(),
outputUnit.c_str());
return 1;
}
}

/// can export floating shapes which can not be compoSolid
void exportCompound(const std::string& file_name)
void exportCompound(const std::string& file_name, double scale = 1.0)
{
summary();

Expand All@@ -122,6 +140,10 @@ namespace Geom
LOG_F(INFO, "result is not merged (duplicated face removed) for result brep file");
finalShape = OccUtils::createCompound(*mySolids, myShapeErrors);
}

if (scale != 1) // double type has integer value can be compared with integer by ==
finalShape = OccUtils::scaleShape(finalShape, scale);

/// NOTE: exportMetaData() is done in the second GeometryPropertyBuilder processor
BRepTools::Write(finalShape, file_name.c_str()); // progress reporter can be the last arg
}
Expand All@@ -131,15 +153,19 @@ namespace Geom
* */
bool exportGeometry(const std::string file_name)
{
std::string defaultLengthUnit = "MM";
auto outputUnit = parameterValue<std::string>("outputUnit", defaultLengthUnit);
double scale = calcOutputScale(outputUnit);

if (Utilities::hasFileExt(file_name, "brp") || Utilities::hasFileExt(file_name, "brep"))
{
exportCompound(file_name);
exportCompound(file_name, scale);
return true;
}
else if (Utilities::hasFileExt(file_name, "stp") || Utilities::hasFileExt(file_name, "step"))
{
// LOG_F(INFO, "export Dataset pointed by member hDoc");
Handle(TDocStd_Document) aDoc = createDocument();
Handle(TDocStd_Document) aDoc = createDocument(scale);

/// the user can work with an already prepared WorkSession or create a new one
Standard_Boolean scratch = Standard_False;
Expand All@@ -150,15 +176,23 @@ namespace Geom
// recommended value, others shape mode are available
// Interface_Static::SetCVal("write.step.schema", "AP214IS");
Interface_Static::SetIVal("write.step.assembly", 1); // global variable
// Interface_Static::SetIVal ("write.step.nonmanifold", 1);
// "write.precision.val" = 0.0001 is the default value

if (outputUnit != defaultLengthUnit)
{
Interface_Static::SetCVal("xstep.cascade.unit", outputUnit.c_str());
Interface_Static::SetCVal("write.step.unit", outputUnit.c_str());
// all vertex coordinate will not be scaled during writing out, change unit,
// but it causes scaling at reading back
}

STEPCAFControl_Writer writer(WS, scratch);
// this writer contains a STEPControl_Writer class, not by inheritance
// writer.SetColorMode(mode);
if (!writer.Transfer(aDoc, mode))
{
LOG_F(ERROR, "The Dataset cannot be translated or gives no result");
// abandon ..
}

IFSelect_ReturnStatus stat = writer.Write(file_name.c_str());
Expand All@@ -173,7 +207,7 @@ namespace Geom
return false;
}

Handle(TDocStd_Document) createDocument()
Handle(TDocStd_Document) createDocument(double scale = 1)
{

Handle(XCAFApp_Application) hApp = XCAFApp_Application::GetApplication();
Expand All@@ -194,7 +228,10 @@ namespace Geom
for (auto& item : *mySolids)
{
TDF_Label partLabel = shapeTool->NewShape();
shapeTool->SetShape(partLabel, item.second);
if (scale != 1)
shapeTool->SetShape(partLabel, OccUtils::scaleShape(item.second, scale));
else
shapeTool->SetShape(partLabel, item.second);
colorTool->SetColor(partLabel, (*myColorMap)[item.first], XCAFDoc_ColorGen);
TDataStd_Name::Set(partLabel, TCollection_ExtendedString((*myNameMap)[item.first].c_str(), true));
/// Material not yet supported
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content
10 changes: 10 additions & 0 deletions scripts/run_all_tests.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -47,11 +47,17 @@ geomPipeline.py ../data/test_geometry/test_geometry.stp -o test_geometry_result.
geomPipeline.py check ../data/test_geometry/test_geometry_manifest.json --verbosity WARNING
if [ ! $? -eq 0 ] ; then echo "Error during geometry test" ; exit 1 ; fi

# test scaling, output to a diff output folder
geomPipeline.py imprint ../data/test_geometry/test_geometry.stp -o /tmp/test_geometry_scaled.brep --output-unit M
geomPipeline.py imprint ../data/test_geometry/test_geometry.stp --working-dir /tmp/ -o test_geometry_scaled.stp --output-unit M
if [ ! $? -eq 0 ] ; then echo "Error during geometry output unit (scaling) test " ; exit 1 ; fi

# test single thread mode, only for non-coupled operations
geomPipeline.py check ../data/test_geometry/test_geometry.stp --thread-count 1 --verbosity WARNING
if [ ! $? -eq 0 ] ; then echo "Error during geometry test in single thread mode" ; exit 1 ; fi

# test_*.py has not been installed by package, so must be copied into this place
# todo: pytest to auto discover tests
cp ../../src/python/*.py ./
if [ $? -eq 0 ]
then
Expand All@@ -62,6 +68,10 @@ then
if [ $? -eq 0 ]; then
test_collision.py
fi

if [ $? -eq 0 ]; then
test_inscribedShape.py
fi
echo "test completed"
else
echo "geometry pipeline test failed"
Expand Down
1 change: 1 addition & 0 deletions src/Geom/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,7 @@ include_directories("third-party/SGeom/src/GEOMAlgo")
set(MyGeom_SOURCES
"OccUtils.cpp"
#"GeometryFixer.cpp"
"InscribedShapeBuilder.cpp"
"CollisionDetector.cpp"
"Geom.cpp"
"OpenCascadeAll.cpp"
Expand Down
3 changes: 3 additions & 0 deletions src/Geom/Geom.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,7 @@
#include "GeometryPropertyBuilder.h"
#include "GeometrySearchBuilder.h"
#include "GeometryShapeChecker.h"
#include "InscribedShapeBuilder.h"

#include "GeometryReader.h"
#include "GeometryWriter.h"
Expand All@@ -37,6 +38,7 @@ TYPESYSTEM_SOURCE(Geom::GeometryShapeChecker, Geom::GeometryProcessor);
TYPESYSTEM_SOURCE(Geom::GeometryPropertyBuilder, Geom::GeometryProcessor);
TYPESYSTEM_SOURCE(Geom::GeometrySearchBuilder, Geom::GeometryProcessor);
TYPESYSTEM_SOURCE(Geom::BoundBoxBuilder, Geom::GeometryProcessor);
TYPESYSTEM_SOURCE(Geom::InscribedShapeBuilder, Geom::GeometryProcessor);

TYPESYSTEM_SOURCE(Geom::CollisionDetector, Geom::GeometryProcessor);
TYPESYSTEM_SOURCE(Geom::GeometryImprinter, Geom::CollisionDetector);
Expand All@@ -60,6 +62,7 @@ namespace Geom
GeometryPropertyBuilder::init();
GeometrySearchBuilder::init();
BoundBoxBuilder::init();
InscribedShapeBuilder::init();
GeometryShapeChecker::init();
CollisionDetector::init();
GeometryImprinter::init();
Expand Down
4 changes: 2 additions & 2 deletions src/Geom/GeometryPropertyBuilder.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -76,8 +76,8 @@ namespace Geom
{
// max and min volume check!
double max_volume = 0;
double min_volume = 1e100;
double max_volume_threshold = 1e16; // todo: get from config
double min_volume = 1e100; // unit is mm^3
double max_volume_threshold = 1e16; // todo: get from config parameter
for (size_t i = 0; i < myInputData->itemCount(); i++)
{
const auto& p = myGeometryProperties[i];
Expand Down
26 changes: 24 additions & 2 deletions src/Geom/GeometryTypes.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,6 +22,15 @@ inline void from_json(const nlohmann::json& j, Bnd_Box& b)
b.Update(v[0], v[1], v[2], v[3], v[4], v[5]);
}

inline void to_json(nlohmann::json& j, const Bnd_Sphere& b)
{
gp_XYZ c = b.Center();
j = nlohmann::json{c.X(), c.Y(), c.Z(), b.Radius()};
}

/// OpenCASCADE has T::DumpJson(Standard_OStream & theOStream, Standard_Integer theDepth = -1 )
/// T::InitFromJson(const Standard_SStream & theSStream, Standard_Integer & theStreamPos)

/// RGBA float array, conmponent value range [0, 1.0]
inline void to_json(nlohmann::json& j, const Quantity_Color& p)
{
Expand All@@ -48,11 +57,16 @@ namespace Geom
typedef Standard_Integer ItemHashType;
static const ItemHashType ItemHashMax = INT_MAX;

typedef std::uint64_t UniqueIdType; // also define in PPP/UniqueId.h
typedef std::uint64_t UniqueIdType; /// defined in PPP/UniqueId.h
/// map has order (non contiguous in memory), can increase capacity
typedef MapType<ItemHashType, TopoDS_Shape> ItemContainerType;
typedef std::shared_ptr<ItemContainerType> ItemContainerPType;

typedef gp_Pnt PointType;
/// conventional C enum starting from zero, can be used as array index
typedef GeomAbs_SurfaceType SurfaceType;
const size_t SurfacTypeCount = 11; /// total count of SurfaceType enum elements

/**
* from OCCT to FreeCAD style better enum name
* integer value: ShapeType == TopAbs_ShapeEnum; but NOT compatible
Expand DownExpand Up@@ -152,7 +166,7 @@ namespace Geom
return ShapeErrorType::NoError;
}

class CollisionInfo
struct CollisionInfo
{
public:
ItemIndexType first;
Expand All@@ -161,6 +175,14 @@ namespace Geom
CollisionType type;

CollisionInfo() = default;
// C++20 prevents conversion form <brace-enclosed initializer list> to this type
CollisionInfo(ItemIndexType _first, ItemIndexType _second, double _value, CollisionType _type)
: first(_first)
, second(_second)
, value(_value)
, type(_type)
{
}
};
inline void to_json(json& j, const CollisionInfo& p)
{
Expand Down
49 changes: 43 additions & 6 deletions src/Geom/GeometryWriter.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -105,8 +105,26 @@ namespace Geom
LOG_F(INFO, "%s", sout.str().c_str());
}

// TODO: query inputData() metadata for inputUnit
/// return 1 which means no scaling is needed
/// not quite useful for
double calcOutputScale(const std::string& outputUnit)
{
const std::string inputUnit = "MM";
if (outputUnit == inputUnit)
return 1;
else if ("MM" == inputUnit && outputUnit == "M")
return 0.001;
else
{
LOG_F(ERROR, "scaling for input length unit %s and output unit %s is not supported", inputUnit.c_str(),
outputUnit.c_str());
return 1;
}
}

/// can export floating shapes which can not be compoSolid
void exportCompound(const std::string& file_name)
void exportCompound(const std::string& file_name, double scale = 1.0)
{
summary();

Expand All@@ -122,6 +140,10 @@ namespace Geom
LOG_F(INFO, "result is not merged (duplicated face removed) for result brep file");
finalShape = OccUtils::createCompound(*mySolids, myShapeErrors);
}

if (scale != 1) // double type has integer value can be compared with integer by ==
finalShape = OccUtils::scaleShape(finalShape, scale);

/// NOTE: exportMetaData() is done in the second GeometryPropertyBuilder processor
BRepTools::Write(finalShape, file_name.c_str()); // progress reporter can be the last arg
}
Expand All@@ -131,15 +153,19 @@ namespace Geom
* */
bool exportGeometry(const std::string file_name)
{
std::string defaultLengthUnit = "MM";
auto outputUnit = parameterValue<std::string>("outputUnit", defaultLengthUnit);
double scale = calcOutputScale(outputUnit);

if (Utilities::hasFileExt(file_name, "brp") || Utilities::hasFileExt(file_name, "brep"))
{
exportCompound(file_name);
exportCompound(file_name, scale);
return true;
}
else if (Utilities::hasFileExt(file_name, "stp") || Utilities::hasFileExt(file_name, "step"))
{
// LOG_F(INFO, "export Dataset pointed by member hDoc");
Handle(TDocStd_Document) aDoc = createDocument();
Handle(TDocStd_Document) aDoc = createDocument(scale);

/// the user can work with an already prepared WorkSession or create a new one
Standard_Boolean scratch = Standard_False;
Expand All@@ -150,15 +176,23 @@ namespace Geom
// recommended value, others shape mode are available
// Interface_Static::SetCVal("write.step.schema", "AP214IS");
Interface_Static::SetIVal("write.step.assembly", 1); // global variable
// Interface_Static::SetIVal ("write.step.nonmanifold", 1);
// "write.precision.val" = 0.0001 is the default value

if (outputUnit != defaultLengthUnit)
{
Interface_Static::SetCVal("xstep.cascade.unit", outputUnit.c_str());
Interface_Static::SetCVal("write.step.unit", outputUnit.c_str());
// all vertex coordinate will not be scaled during writing out, change unit,
// but it causes scaling at reading back
}

STEPCAFControl_Writer writer(WS, scratch);
// this writer contains a STEPControl_Writer class, not by inheritance
// writer.SetColorMode(mode);
if (!writer.Transfer(aDoc, mode))
{
LOG_F(ERROR, "The Dataset cannot be translated or gives no result");
// abandon ..
}

IFSelect_ReturnStatus stat = writer.Write(file_name.c_str());
Expand All@@ -173,7 +207,7 @@ namespace Geom
return false;
}

Handle(TDocStd_Document) createDocument()
Handle(TDocStd_Document) createDocument(double scale = 1)
{

Handle(XCAFApp_Application) hApp = XCAFApp_Application::GetApplication();
Expand All@@ -194,7 +228,10 @@ namespace Geom
for (auto& item : *mySolids)
{
TDF_Label partLabel = shapeTool->NewShape();
shapeTool->SetShape(partLabel, item.second);
if (scale != 1)
shapeTool->SetShape(partLabel, OccUtils::scaleShape(item.second, scale));
else
shapeTool->SetShape(partLabel, item.second);
colorTool->SetColor(partLabel, (*myColorMap)[item.first], XCAFDoc_ColorGen);
TDataStd_Name::Set(partLabel, TCollection_ExtendedString((*myNameMap)[item.first].c_str(), true));
/// Material not yet supported
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
10 changes: 10 additions & 0 deletions scripts/run_all_tests.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -47,11 +47,17 @@ geomPipeline.py ../data/test_geometry/test_geometry.stp -o test_geometry_result.
geomPipeline.py check ../data/test_geometry/test_geometry_manifest.json --verbosity WARNING
if [ ! $? -eq 0 ] ; then echo "Error during geometry test" ; exit 1 ; fi

# test scaling, output to a diff output folder
geomPipeline.py imprint ../data/test_geometry/test_geometry.stp -o /tmp/test_geometry_scaled.brep --output-unit M
geomPipeline.py imprint ../data/test_geometry/test_geometry.stp --working-dir /tmp/ -o test_geometry_scaled.stp --output-unit M
if [ ! $? -eq 0 ] ; then echo "Error during geometry output unit (scaling) test " ; exit 1 ; fi

# test single thread mode, only for non-coupled operations
geomPipeline.py check ../data/test_geometry/test_geometry.stp --thread-count 1 --verbosity WARNING
if [ ! $? -eq 0 ] ; then echo "Error during geometry test in single thread mode" ; exit 1 ; fi

# test_*.py has not been installed by package, so must be copied into this place
# todo: pytest to auto discover tests
cp ../../src/python/*.py ./
if [ $? -eq 0 ]
then
Expand All@@ -62,6 +68,10 @@ then
if [ $? -eq 0 ]; then
test_collision.py
fi

if [ $? -eq 0 ]; then
test_inscribedShape.py
fi
echo "test completed"
else
echo "geometry pipeline test failed"
Expand Down
1 change: 1 addition & 0 deletions src/Geom/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,7 @@ include_directories("third-party/SGeom/src/GEOMAlgo")
set(MyGeom_SOURCES
"OccUtils.cpp"
#"GeometryFixer.cpp"
"InscribedShapeBuilder.cpp"
"CollisionDetector.cpp"
"Geom.cpp"
"OpenCascadeAll.cpp"
Expand Down
3 changes: 3 additions & 0 deletions src/Geom/Geom.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,7 @@
#include "GeometryPropertyBuilder.h"
#include "GeometrySearchBuilder.h"
#include "GeometryShapeChecker.h"
#include "InscribedShapeBuilder.h"

#include "GeometryReader.h"
#include "GeometryWriter.h"
Expand All@@ -37,6 +38,7 @@ TYPESYSTEM_SOURCE(Geom::GeometryShapeChecker, Geom::GeometryProcessor);
TYPESYSTEM_SOURCE(Geom::GeometryPropertyBuilder, Geom::GeometryProcessor);
TYPESYSTEM_SOURCE(Geom::GeometrySearchBuilder, Geom::GeometryProcessor);
TYPESYSTEM_SOURCE(Geom::BoundBoxBuilder, Geom::GeometryProcessor);
TYPESYSTEM_SOURCE(Geom::InscribedShapeBuilder, Geom::GeometryProcessor);

TYPESYSTEM_SOURCE(Geom::CollisionDetector, Geom::GeometryProcessor);
TYPESYSTEM_SOURCE(Geom::GeometryImprinter, Geom::CollisionDetector);
Expand All@@ -60,6 +62,7 @@ namespace Geom
GeometryPropertyBuilder::init();
GeometrySearchBuilder::init();
BoundBoxBuilder::init();
InscribedShapeBuilder::init();
GeometryShapeChecker::init();
CollisionDetector::init();
GeometryImprinter::init();
Expand Down
4 changes: 2 additions & 2 deletions src/Geom/GeometryPropertyBuilder.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -76,8 +76,8 @@ namespace Geom
{
// max and min volume check!
double max_volume = 0;
double min_volume = 1e100;
double max_volume_threshold = 1e16; // todo: get from config
double min_volume = 1e100; // unit is mm^3
double max_volume_threshold = 1e16; // todo: get from config parameter
for (size_t i = 0; i < myInputData->itemCount(); i++)
{
const auto& p = myGeometryProperties[i];
Expand Down
26 changes: 24 additions & 2 deletions src/Geom/GeometryTypes.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,6 +22,15 @@ inline void from_json(const nlohmann::json& j, Bnd_Box& b)
b.Update(v[0], v[1], v[2], v[3], v[4], v[5]);
}

inline void to_json(nlohmann::json& j, const Bnd_Sphere& b)
{
gp_XYZ c = b.Center();
j = nlohmann::json{c.X(), c.Y(), c.Z(), b.Radius()};
}

/// OpenCASCADE has T::DumpJson(Standard_OStream & theOStream, Standard_Integer theDepth = -1 )
/// T::InitFromJson(const Standard_SStream & theSStream, Standard_Integer & theStreamPos)

/// RGBA float array, conmponent value range [0, 1.0]
inline void to_json(nlohmann::json& j, const Quantity_Color& p)
{
Expand All@@ -48,11 +57,16 @@ namespace Geom
typedef Standard_Integer ItemHashType;
static const ItemHashType ItemHashMax = INT_MAX;

typedef std::uint64_t UniqueIdType; // also define in PPP/UniqueId.h
typedef std::uint64_t UniqueIdType; /// defined in PPP/UniqueId.h
/// map has order (non contiguous in memory), can increase capacity
typedef MapType<ItemHashType, TopoDS_Shape> ItemContainerType;
typedef std::shared_ptr<ItemContainerType> ItemContainerPType;

typedef gp_Pnt PointType;
/// conventional C enum starting from zero, can be used as array index
typedef GeomAbs_SurfaceType SurfaceType;
const size_t SurfacTypeCount = 11; /// total count of SurfaceType enum elements

/**
* from OCCT to FreeCAD style better enum name
* integer value: ShapeType == TopAbs_ShapeEnum; but NOT compatible
Expand DownExpand Up@@ -152,7 +166,7 @@ namespace Geom
return ShapeErrorType::NoError;
}

class CollisionInfo
struct CollisionInfo
{
public:
ItemIndexType first;
Expand All@@ -161,6 +175,14 @@ namespace Geom
CollisionType type;

CollisionInfo() = default;
// C++20 prevents conversion form <brace-enclosed initializer list> to this type
CollisionInfo(ItemIndexType _first, ItemIndexType _second, double _value, CollisionType _type)
: first(_first)
, second(_second)
, value(_value)
, type(_type)
{
}
};
inline void to_json(json& j, const CollisionInfo& p)
{
Expand Down
49 changes: 43 additions & 6 deletions src/Geom/GeometryWriter.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -105,8 +105,26 @@ namespace Geom
LOG_F(INFO, "%s", sout.str().c_str());
}

// TODO: query inputData() metadata for inputUnit
/// return 1 which means no scaling is needed
/// not quite useful for
double calcOutputScale(const std::string& outputUnit)
{
const std::string inputUnit = "MM";
if (outputUnit == inputUnit)
return 1;
else if ("MM" == inputUnit && outputUnit == "M")
return 0.001;
else
{
LOG_F(ERROR, "scaling for input length unit %s and output unit %s is not supported", inputUnit.c_str(),
outputUnit.c_str());
return 1;
}
}

/// can export floating shapes which can not be compoSolid
void exportCompound(const std::string& file_name)
void exportCompound(const std::string& file_name, double scale = 1.0)
{
summary();

Expand All@@ -122,6 +140,10 @@ namespace Geom
LOG_F(INFO, "result is not merged (duplicated face removed) for result brep file");
finalShape = OccUtils::createCompound(*mySolids, myShapeErrors);
}

if (scale != 1) // double type has integer value can be compared with integer by ==
finalShape = OccUtils::scaleShape(finalShape, scale);

/// NOTE: exportMetaData() is done in the second GeometryPropertyBuilder processor
BRepTools::Write(finalShape, file_name.c_str()); // progress reporter can be the last arg
}
Expand All@@ -131,15 +153,19 @@ namespace Geom
* */
bool exportGeometry(const std::string file_name)
{
std::string defaultLengthUnit = "MM";
auto outputUnit = parameterValue<std::string>("outputUnit", defaultLengthUnit);
double scale = calcOutputScale(outputUnit);

if (Utilities::hasFileExt(file_name, "brp") || Utilities::hasFileExt(file_name, "brep"))
{
exportCompound(file_name);
exportCompound(file_name, scale);
return true;
}
else if (Utilities::hasFileExt(file_name, "stp") || Utilities::hasFileExt(file_name, "step"))
{
// LOG_F(INFO, "export Dataset pointed by member hDoc");
Handle(TDocStd_Document) aDoc = createDocument();
Handle(TDocStd_Document) aDoc = createDocument(scale);

/// the user can work with an already prepared WorkSession or create a new one
Standard_Boolean scratch = Standard_False;
Expand All@@ -150,15 +176,23 @@ namespace Geom
// recommended value, others shape mode are available
// Interface_Static::SetCVal("write.step.schema", "AP214IS");
Interface_Static::SetIVal("write.step.assembly", 1); // global variable
// Interface_Static::SetIVal ("write.step.nonmanifold", 1);
// "write.precision.val" = 0.0001 is the default value

if (outputUnit != defaultLengthUnit)
{
Interface_Static::SetCVal("xstep.cascade.unit", outputUnit.c_str());
Interface_Static::SetCVal("write.step.unit", outputUnit.c_str());
// all vertex coordinate will not be scaled during writing out, change unit,
// but it causes scaling at reading back
}

STEPCAFControl_Writer writer(WS, scratch);
// this writer contains a STEPControl_Writer class, not by inheritance
// writer.SetColorMode(mode);
if (!writer.Transfer(aDoc, mode))
{
LOG_F(ERROR, "The Dataset cannot be translated or gives no result");
// abandon ..
}

IFSelect_ReturnStatus stat = writer.Write(file_name.c_str());
Expand All@@ -173,7 +207,7 @@ namespace Geom
return false;
}

Handle(TDocStd_Document) createDocument()
Handle(TDocStd_Document) createDocument(double scale = 1)
{

Handle(XCAFApp_Application) hApp = XCAFApp_Application::GetApplication();
Expand All@@ -194,7 +228,10 @@ namespace Geom
for (auto& item : *mySolids)
{
TDF_Label partLabel = shapeTool->NewShape();
shapeTool->SetShape(partLabel, item.second);
if (scale != 1)
shapeTool->SetShape(partLabel, OccUtils::scaleShape(item.second, scale));
else
shapeTool->SetShape(partLabel, item.second);
colorTool->SetColor(partLabel, (*myColorMap)[item.first], XCAFDoc_ColorGen);
TDataStd_Name::Set(partLabel, TCollection_ExtendedString((*myNameMap)[item.first].c_str(), true));
/// Material not yet supported
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
10 changes: 10 additions & 0 deletions scripts/run_all_tests.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -47,11 +47,17 @@ geomPipeline.py ../data/test_geometry/test_geometry.stp -o test_geometry_result.
geomPipeline.py check ../data/test_geometry/test_geometry_manifest.json --verbosity WARNING
if [ ! $? -eq 0 ] ; then echo "Error during geometry test" ; exit 1 ; fi

# test scaling, output to a diff output folder
geomPipeline.py imprint ../data/test_geometry/test_geometry.stp -o /tmp/test_geometry_scaled.brep --output-unit M
geomPipeline.py imprint ../data/test_geometry/test_geometry.stp --working-dir /tmp/ -o test_geometry_scaled.stp --output-unit M
if [ ! $? -eq 0 ] ; then echo "Error during geometry output unit (scaling) test " ; exit 1 ; fi

# test single thread mode, only for non-coupled operations
geomPipeline.py check ../data/test_geometry/test_geometry.stp --thread-count 1 --verbosity WARNING
if [ ! $? -eq 0 ] ; then echo "Error during geometry test in single thread mode" ; exit 1 ; fi

# test_*.py has not been installed by package, so must be copied into this place
# todo: pytest to auto discover tests
cp ../../src/python/*.py ./
if [ $? -eq 0 ]
then
Expand All@@ -62,6 +68,10 @@ then
if [ $? -eq 0 ]; then
test_collision.py
fi

if [ $? -eq 0 ]; then
test_inscribedShape.py
fi
echo "test completed"
else
echo "geometry pipeline test failed"
Expand Down
1 change: 1 addition & 0 deletions src/Geom/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,7 @@ include_directories("third-party/SGeom/src/GEOMAlgo")
set(MyGeom_SOURCES
"OccUtils.cpp"
#"GeometryFixer.cpp"
"InscribedShapeBuilder.cpp"
"CollisionDetector.cpp"
"Geom.cpp"
"OpenCascadeAll.cpp"
Expand Down
3 changes: 3 additions & 0 deletions src/Geom/Geom.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,7 @@
#include "GeometryPropertyBuilder.h"
#include "GeometrySearchBuilder.h"
#include "GeometryShapeChecker.h"
#include "InscribedShapeBuilder.h"

#include "GeometryReader.h"
#include "GeometryWriter.h"
Expand All@@ -37,6 +38,7 @@ TYPESYSTEM_SOURCE(Geom::GeometryShapeChecker, Geom::GeometryProcessor);
TYPESYSTEM_SOURCE(Geom::GeometryPropertyBuilder, Geom::GeometryProcessor);
TYPESYSTEM_SOURCE(Geom::GeometrySearchBuilder, Geom::GeometryProcessor);
TYPESYSTEM_SOURCE(Geom::BoundBoxBuilder, Geom::GeometryProcessor);
TYPESYSTEM_SOURCE(Geom::InscribedShapeBuilder, Geom::GeometryProcessor);

TYPESYSTEM_SOURCE(Geom::CollisionDetector, Geom::GeometryProcessor);
TYPESYSTEM_SOURCE(Geom::GeometryImprinter, Geom::CollisionDetector);
Expand All@@ -60,6 +62,7 @@ namespace Geom
GeometryPropertyBuilder::init();
GeometrySearchBuilder::init();
BoundBoxBuilder::init();
InscribedShapeBuilder::init();
GeometryShapeChecker::init();
CollisionDetector::init();
GeometryImprinter::init();
Expand Down
4 changes: 2 additions & 2 deletions src/Geom/GeometryPropertyBuilder.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -76,8 +76,8 @@ namespace Geom
{
// max and min volume check!
double max_volume = 0;
double min_volume = 1e100;
double max_volume_threshold = 1e16; // todo: get from config
double min_volume = 1e100; // unit is mm^3
double max_volume_threshold = 1e16; // todo: get from config parameter
for (size_t i = 0; i < myInputData->itemCount(); i++)
{
const auto& p = myGeometryProperties[i];
Expand Down
26 changes: 24 additions & 2 deletions src/Geom/GeometryTypes.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,6 +22,15 @@ inline void from_json(const nlohmann::json& j, Bnd_Box& b)
b.Update(v[0], v[1], v[2], v[3], v[4], v[5]);
}

inline void to_json(nlohmann::json& j, const Bnd_Sphere& b)
{
gp_XYZ c = b.Center();
j = nlohmann::json{c.X(), c.Y(), c.Z(), b.Radius()};
}

/// OpenCASCADE has T::DumpJson(Standard_OStream & theOStream, Standard_Integer theDepth = -1 )
/// T::InitFromJson(const Standard_SStream & theSStream, Standard_Integer & theStreamPos)

/// RGBA float array, conmponent value range [0, 1.0]
inline void to_json(nlohmann::json& j, const Quantity_Color& p)
{
Expand All@@ -48,11 +57,16 @@ namespace Geom
typedef Standard_Integer ItemHashType;
static const ItemHashType ItemHashMax = INT_MAX;

typedef std::uint64_t UniqueIdType; // also define in PPP/UniqueId.h
typedef std::uint64_t UniqueIdType; /// defined in PPP/UniqueId.h
/// map has order (non contiguous in memory), can increase capacity
typedef MapType<ItemHashType, TopoDS_Shape> ItemContainerType;
typedef std::shared_ptr<ItemContainerType> ItemContainerPType;

typedef gp_Pnt PointType;
/// conventional C enum starting from zero, can be used as array index
typedef GeomAbs_SurfaceType SurfaceType;
const size_t SurfacTypeCount = 11; /// total count of SurfaceType enum elements

/**
* from OCCT to FreeCAD style better enum name
* integer value: ShapeType == TopAbs_ShapeEnum; but NOT compatible
Expand DownExpand Up@@ -152,7 +166,7 @@ namespace Geom
return ShapeErrorType::NoError;
}

class CollisionInfo
struct CollisionInfo
{
public:
ItemIndexType first;
Expand All@@ -161,6 +175,14 @@ namespace Geom
CollisionType type;

CollisionInfo() = default;
// C++20 prevents conversion form <brace-enclosed initializer list> to this type
CollisionInfo(ItemIndexType _first, ItemIndexType _second, double _value, CollisionType _type)
: first(_first)
, second(_second)
, value(_value)
, type(_type)
{
}
};
inline void to_json(json& j, const CollisionInfo& p)
{
Expand Down
49 changes: 43 additions & 6 deletions src/Geom/GeometryWriter.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -105,8 +105,26 @@ namespace Geom
LOG_F(INFO, "%s", sout.str().c_str());
}

// TODO: query inputData() metadata for inputUnit
/// return 1 which means no scaling is needed
/// not quite useful for
double calcOutputScale(const std::string& outputUnit)
{
const std::string inputUnit = "MM";
if (outputUnit == inputUnit)
return 1;
else if ("MM" == inputUnit && outputUnit == "M")
return 0.001;
else
{
LOG_F(ERROR, "scaling for input length unit %s and output unit %s is not supported", inputUnit.c_str(),
outputUnit.c_str());
return 1;
}
}

/// can export floating shapes which can not be compoSolid
void exportCompound(const std::string& file_name)
void exportCompound(const std::string& file_name, double scale = 1.0)
{
summary();

Expand All@@ -122,6 +140,10 @@ namespace Geom
LOG_F(INFO, "result is not merged (duplicated face removed) for result brep file");
finalShape = OccUtils::createCompound(*mySolids, myShapeErrors);
}

if (scale != 1) // double type has integer value can be compared with integer by ==
finalShape = OccUtils::scaleShape(finalShape, scale);

/// NOTE: exportMetaData() is done in the second GeometryPropertyBuilder processor
BRepTools::Write(finalShape, file_name.c_str()); // progress reporter can be the last arg
}
Expand All@@ -131,15 +153,19 @@ namespace Geom
* */
bool exportGeometry(const std::string file_name)
{
std::string defaultLengthUnit = "MM";
auto outputUnit = parameterValue<std::string>("outputUnit", defaultLengthUnit);
double scale = calcOutputScale(outputUnit);

if (Utilities::hasFileExt(file_name, "brp") || Utilities::hasFileExt(file_name, "brep"))
{
exportCompound(file_name);
exportCompound(file_name, scale);
return true;
}
else if (Utilities::hasFileExt(file_name, "stp") || Utilities::hasFileExt(file_name, "step"))
{
// LOG_F(INFO, "export Dataset pointed by member hDoc");
Handle(TDocStd_Document) aDoc = createDocument();
Handle(TDocStd_Document) aDoc = createDocument(scale);

/// the user can work with an already prepared WorkSession or create a new one
Standard_Boolean scratch = Standard_False;
Expand All@@ -150,15 +176,23 @@ namespace Geom
// recommended value, others shape mode are available
// Interface_Static::SetCVal("write.step.schema", "AP214IS");
Interface_Static::SetIVal("write.step.assembly", 1); // global variable
// Interface_Static::SetIVal ("write.step.nonmanifold", 1);
// "write.precision.val" = 0.0001 is the default value

if (outputUnit != defaultLengthUnit)
{
Interface_Static::SetCVal("xstep.cascade.unit", outputUnit.c_str());
Interface_Static::SetCVal("write.step.unit", outputUnit.c_str());
// all vertex coordinate will not be scaled during writing out, change unit,
// but it causes scaling at reading back
}

STEPCAFControl_Writer writer(WS, scratch);
// this writer contains a STEPControl_Writer class, not by inheritance
// writer.SetColorMode(mode);
if (!writer.Transfer(aDoc, mode))
{
LOG_F(ERROR, "The Dataset cannot be translated or gives no result");
// abandon ..
}

IFSelect_ReturnStatus stat = writer.Write(file_name.c_str());
Expand All@@ -173,7 +207,7 @@ namespace Geom
return false;
}

Handle(TDocStd_Document) createDocument()
Handle(TDocStd_Document) createDocument(double scale = 1)
{

Handle(XCAFApp_Application) hApp = XCAFApp_Application::GetApplication();
Expand All@@ -194,7 +228,10 @@ namespace Geom
for (auto& item : *mySolids)
{
TDF_Label partLabel = shapeTool->NewShape();
shapeTool->SetShape(partLabel, item.second);
if (scale != 1)
shapeTool->SetShape(partLabel, OccUtils::scaleShape(item.second, scale));
else
shapeTool->SetShape(partLabel, item.second);
colorTool->SetColor(partLabel, (*myColorMap)[item.first], XCAFDoc_ColorGen);
TDataStd_Name::Set(partLabel, TCollection_ExtendedString((*myNameMap)[item.first].c_str(), true));
/// Material not yet supported
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content
10 changes: 10 additions & 0 deletions scripts/run_all_tests.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -47,11 +47,17 @@ geomPipeline.py ../data/test_geometry/test_geometry.stp -o test_geometry_result.
geomPipeline.py check ../data/test_geometry/test_geometry_manifest.json --verbosity WARNING
if [ ! $? -eq 0 ] ; then echo "Error during geometry test" ; exit 1 ; fi

# test scaling, output to a diff output folder
geomPipeline.py imprint ../data/test_geometry/test_geometry.stp -o /tmp/test_geometry_scaled.brep --output-unit M
geomPipeline.py imprint ../data/test_geometry/test_geometry.stp --working-dir /tmp/ -o test_geometry_scaled.stp --output-unit M
if [ ! $? -eq 0 ] ; then echo "Error during geometry output unit (scaling) test " ; exit 1 ; fi

# test single thread mode, only for non-coupled operations
geomPipeline.py check ../data/test_geometry/test_geometry.stp --thread-count 1 --verbosity WARNING
if [ ! $? -eq 0 ] ; then echo "Error during geometry test in single thread mode" ; exit 1 ; fi

# test_*.py has not been installed by package, so must be copied into this place
# todo: pytest to auto discover tests
cp ../../src/python/*.py ./
if [ $? -eq 0 ]
then
Expand All@@ -62,6 +68,10 @@ then
if [ $? -eq 0 ]; then
test_collision.py
fi

if [ $? -eq 0 ]; then
test_inscribedShape.py
fi
echo "test completed"
else
echo "geometry pipeline test failed"
Expand Down
1 change: 1 addition & 0 deletions src/Geom/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,7 @@ include_directories("third-party/SGeom/src/GEOMAlgo")
set(MyGeom_SOURCES
"OccUtils.cpp"
#"GeometryFixer.cpp"
"InscribedShapeBuilder.cpp"
"CollisionDetector.cpp"
"Geom.cpp"
"OpenCascadeAll.cpp"
Expand Down
3 changes: 3 additions & 0 deletions src/Geom/Geom.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,7 @@
#include "GeometryPropertyBuilder.h"
#include "GeometrySearchBuilder.h"
#include "GeometryShapeChecker.h"
#include "InscribedShapeBuilder.h"

#include "GeometryReader.h"
#include "GeometryWriter.h"
Expand All@@ -37,6 +38,7 @@ TYPESYSTEM_SOURCE(Geom::GeometryShapeChecker, Geom::GeometryProcessor);
TYPESYSTEM_SOURCE(Geom::GeometryPropertyBuilder, Geom::GeometryProcessor);
TYPESYSTEM_SOURCE(Geom::GeometrySearchBuilder, Geom::GeometryProcessor);
TYPESYSTEM_SOURCE(Geom::BoundBoxBuilder, Geom::GeometryProcessor);
TYPESYSTEM_SOURCE(Geom::InscribedShapeBuilder, Geom::GeometryProcessor);

TYPESYSTEM_SOURCE(Geom::CollisionDetector, Geom::GeometryProcessor);
TYPESYSTEM_SOURCE(Geom::GeometryImprinter, Geom::CollisionDetector);
Expand All@@ -60,6 +62,7 @@ namespace Geom
GeometryPropertyBuilder::init();
GeometrySearchBuilder::init();
BoundBoxBuilder::init();
InscribedShapeBuilder::init();
GeometryShapeChecker::init();
CollisionDetector::init();
GeometryImprinter::init();
Expand Down
4 changes: 2 additions & 2 deletions src/Geom/GeometryPropertyBuilder.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -76,8 +76,8 @@ namespace Geom
{
// max and min volume check!
double max_volume = 0;
double min_volume = 1e100;
double max_volume_threshold = 1e16; // todo: get from config
double min_volume = 1e100; // unit is mm^3
double max_volume_threshold = 1e16; // todo: get from config parameter
for (size_t i = 0; i < myInputData->itemCount(); i++)
{
const auto& p = myGeometryProperties[i];
Expand Down
26 changes: 24 additions & 2 deletions src/Geom/GeometryTypes.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,6 +22,15 @@ inline void from_json(const nlohmann::json& j, Bnd_Box& b)
b.Update(v[0], v[1], v[2], v[3], v[4], v[5]);
}

inline void to_json(nlohmann::json& j, const Bnd_Sphere& b)
{
gp_XYZ c = b.Center();
j = nlohmann::json{c.X(), c.Y(), c.Z(), b.Radius()};
}

/// OpenCASCADE has T::DumpJson(Standard_OStream & theOStream, Standard_Integer theDepth = -1 )
/// T::InitFromJson(const Standard_SStream & theSStream, Standard_Integer & theStreamPos)

/// RGBA float array, conmponent value range [0, 1.0]
inline void to_json(nlohmann::json& j, const Quantity_Color& p)
{
Expand All@@ -48,11 +57,16 @@ namespace Geom
typedef Standard_Integer ItemHashType;
static const ItemHashType ItemHashMax = INT_MAX;

typedef std::uint64_t UniqueIdType; // also define in PPP/UniqueId.h
typedef std::uint64_t UniqueIdType; /// defined in PPP/UniqueId.h
/// map has order (non contiguous in memory), can increase capacity
typedef MapType<ItemHashType, TopoDS_Shape> ItemContainerType;
typedef std::shared_ptr<ItemContainerType> ItemContainerPType;

typedef gp_Pnt PointType;
/// conventional C enum starting from zero, can be used as array index
typedef GeomAbs_SurfaceType SurfaceType;
const size_t SurfacTypeCount = 11; /// total count of SurfaceType enum elements

/**
* from OCCT to FreeCAD style better enum name
* integer value: ShapeType == TopAbs_ShapeEnum; but NOT compatible
Expand DownExpand Up@@ -152,7 +166,7 @@ namespace Geom
return ShapeErrorType::NoError;
}

class CollisionInfo
struct CollisionInfo
{
public:
ItemIndexType first;
Expand All@@ -161,6 +175,14 @@ namespace Geom
CollisionType type;

CollisionInfo() = default;
// C++20 prevents conversion form <brace-enclosed initializer list> to this type
CollisionInfo(ItemIndexType _first, ItemIndexType _second, double _value, CollisionType _type)
: first(_first)
, second(_second)
, value(_value)
, type(_type)
{
}
};
inline void to_json(json& j, const CollisionInfo& p)
{
Expand Down
49 changes: 43 additions & 6 deletions src/Geom/GeometryWriter.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -105,8 +105,26 @@ namespace Geom
LOG_F(INFO, "%s", sout.str().c_str());
}

// TODO: query inputData() metadata for inputUnit
/// return 1 which means no scaling is needed
/// not quite useful for
double calcOutputScale(const std::string& outputUnit)
{
const std::string inputUnit = "MM";
if (outputUnit == inputUnit)
return 1;
else if ("MM" == inputUnit && outputUnit == "M")
return 0.001;
else
{
LOG_F(ERROR, "scaling for input length unit %s and output unit %s is not supported", inputUnit.c_str(),
outputUnit.c_str());
return 1;
}
}

/// can export floating shapes which can not be compoSolid
void exportCompound(const std::string& file_name)
void exportCompound(const std::string& file_name, double scale = 1.0)
{
summary();

Expand All@@ -122,6 +140,10 @@ namespace Geom
LOG_F(INFO, "result is not merged (duplicated face removed) for result brep file");
finalShape = OccUtils::createCompound(*mySolids, myShapeErrors);
}

if (scale != 1) // double type has integer value can be compared with integer by ==
finalShape = OccUtils::scaleShape(finalShape, scale);

/// NOTE: exportMetaData() is done in the second GeometryPropertyBuilder processor
BRepTools::Write(finalShape, file_name.c_str()); // progress reporter can be the last arg
}
Expand All@@ -131,15 +153,19 @@ namespace Geom
* */
bool exportGeometry(const std::string file_name)
{
std::string defaultLengthUnit = "MM";
auto outputUnit = parameterValue<std::string>("outputUnit", defaultLengthUnit);
double scale = calcOutputScale(outputUnit);

if (Utilities::hasFileExt(file_name, "brp") || Utilities::hasFileExt(file_name, "brep"))
{
exportCompound(file_name);
exportCompound(file_name, scale);
return true;
}
else if (Utilities::hasFileExt(file_name, "stp") || Utilities::hasFileExt(file_name, "step"))
{
// LOG_F(INFO, "export Dataset pointed by member hDoc");
Handle(TDocStd_Document) aDoc = createDocument();
Handle(TDocStd_Document) aDoc = createDocument(scale);

/// the user can work with an already prepared WorkSession or create a new one
Standard_Boolean scratch = Standard_False;
Expand All@@ -150,15 +176,23 @@ namespace Geom
// recommended value, others shape mode are available
// Interface_Static::SetCVal("write.step.schema", "AP214IS");
Interface_Static::SetIVal("write.step.assembly", 1); // global variable
// Interface_Static::SetIVal ("write.step.nonmanifold", 1);
// "write.precision.val" = 0.0001 is the default value

if (outputUnit != defaultLengthUnit)
{
Interface_Static::SetCVal("xstep.cascade.unit", outputUnit.c_str());
Interface_Static::SetCVal("write.step.unit", outputUnit.c_str());
// all vertex coordinate will not be scaled during writing out, change unit,
// but it causes scaling at reading back
}

STEPCAFControl_Writer writer(WS, scratch);
// this writer contains a STEPControl_Writer class, not by inheritance
// writer.SetColorMode(mode);
if (!writer.Transfer(aDoc, mode))
{
LOG_F(ERROR, "The Dataset cannot be translated or gives no result");
// abandon ..
}

IFSelect_ReturnStatus stat = writer.Write(file_name.c_str());
Expand All@@ -173,7 +207,7 @@ namespace Geom
return false;
}

Handle(TDocStd_Document) createDocument()
Handle(TDocStd_Document) createDocument(double scale = 1)
{

Handle(XCAFApp_Application) hApp = XCAFApp_Application::GetApplication();
Expand All@@ -194,7 +228,10 @@ namespace Geom
for (auto& item : *mySolids)
{
TDF_Label partLabel = shapeTool->NewShape();
shapeTool->SetShape(partLabel, item.second);
if (scale != 1)
shapeTool->SetShape(partLabel, OccUtils::scaleShape(item.second, scale));
else
shapeTool->SetShape(partLabel, item.second);
colorTool->SetColor(partLabel, (*myColorMap)[item.first], XCAFDoc_ColorGen);
TDataStd_Name::Set(partLabel, TCollection_ExtendedString((*myNameMap)[item.first].c_str(), true));
/// Material not yet supported
Expand Down
Loading