Skip to content

Commit

Permalink
Merge pull request #39 from nickcastel50/build_process_optimization
Browse files Browse the repository at this point in the history
WASM Build process optimization + web_ifc_native ifc types fix + updated for conway refactor
  • Loading branch information
ConorStokes authored Jun 29, 2023
2 parents 0207f5d + 020bc32 commit cfdb138
Show file tree
Hide file tree
Showing 12 changed files with 422 additions and 203 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ gmake/
.vscode/
.DS_Store
**/.DS_Store
Dist/
Dist/
dependencies/libdraco.a
dependencies/libgltfsdk.a
dependencies/libmanifold.a
33 changes: 25 additions & 8 deletions build_osx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ case "${1}" in
wasm_config=releaseemscripten
;;
*)
echo "$0 <clean | debug | release | test>" 1>&2
echo "$0 <clean | debug | release | test> <native | wasm>" 1>&2
exit 1
;;
esac
Expand Down Expand Up @@ -57,20 +57,37 @@ fi

if [ "$1" = "test" ]; then
# Your code for the 'test' case goes here
( cd gmake && \
make config=${native_config} conway_geom_native_tests && \
( cd gmake &&
make config=${native_config} conway_geom_native_tests &&
../bin/64/debug/conway_geom_native_tests
)
if [ $? -ne 0 ]; then
echo "! Build failed" 1>&2
exit 1
fi
else
# Your code for other cases goes here
( cd gmake && \
make config=${native_config} conway_geom_native webifc_native && \
make config=${wasm_config} ConwayGeomWasm ConwayGeomWasm_mt
)
if [ -z "$2" ]; then
echo "No platform specified, building for native + wasm"
# Your code for other cases goes here
( cd gmake &&
make config=${native_config} conway_geom_native webifc_native &&
make config=${wasm_config} ConwayGeomWasm )
else
echo $2
if [ "$2" = "native" ]; then
( cd gmake &&
make config=${native_config} conway_geom_native webifc_native )
elif [ "$2" = "wasm" ]; then
( cd gmake &&
make config=${wasm_config} ConwayGeomWasm )
else
echo "Platform invalid, building for native + wasm"
# Your code for other cases goes here
( cd gmake &&
make config=${native_config} conway_geom_native webifc_native &&
make config=${wasm_config} ConwayGeomWasm )
fi
fi
if [ $? -ne 0 ]; then
echo "! Build failed" 1>&2
exit 1
Expand Down
41 changes: 28 additions & 13 deletions build_win.bat
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,37 @@ if /i "%1"=="clean" (
exit /b 1
)

if "%1"=="test" (
rem Your code for the 'test' case goes here
cd gmake && (
make config=!native_config! conway_geom_native_tests && ..\bin\64\debug\conway_geom_native_tests
)
if errorlevel 1 (
echo ! Build failed 1>&2
IF "%1"=="test" (
cd gmake
make config=%native_config% conway_geom_native_tests
..\bin\64\debug\conway_geom_native_tests
if %errorlevel% neq 0 (
echo "! Build failed" >&2
exit /b 1
)
) else (
rem Your code for other cases goes here
cd gmake && (
make config=!native_config! conway_geom_native webifc_native && make config=!wasm_config! ConwayGeomWasm ConwayGeomWasm_mt
) ELSE (
IF "%2"=="" (
echo "No platform specified, building for native + wasm"
cd gmake
make config=%native_config% conway_geom_native webifc_native
make config=%wasm_config% ConwayGeomWasm
) ELSE (
echo %2
IF "%2"=="native" (
cd gmake
make config=%native_config% conway_geom_native webifc_native
) ELSE IF "%2"=="wasm" (
cd gmake
make config=%wasm_config% ConwayGeomWasm
) ELSE (
echo "Platform invalid, building for native + wasm"
cd gmake
make config=%native_config% conway_geom_native webifc_native
make config=%wasm_config% ConwayGeomWasm
)
)
if errorlevel 1 (
echo ! Build failed 1>&2
if %errorlevel% neq 0 (
echo "! Build failed" >&2
exit /b 1
)
)
Expand Down
83 changes: 44 additions & 39 deletions conway-api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@

#include "conway_geometry/ConwayGeometryProcessor.h"

std::map<uint32_t, std::unique_ptr<conway::geometry::ConwayGeometryProcessor>>
processors;

uint32_t GLOBAL_MODEL_ID_COUNTER = 0;
std::unique_ptr<conway::geometry::ConwayGeometryProcessor> processor;

#ifdef __EMSCRIPTEN_PTHREADS__
constexpr bool MT_ENABLED = true;
Expand All @@ -22,72 +19,77 @@ constexpr bool MT_ENABLED = false;
#endif

// use to construct API placeholders
int main() {
processors.emplace();

return 0;
}
int main() { return 0; }

// taken from web ifc obj dump code
glm::dmat4 NormalizeMat(glm::dvec4(1, 0, 0, 0), glm::dvec4(0, 0, -1, 0),
glm::dvec4(0, 1, 0, 0), glm::dvec4(0, 0, 0, 1));

conway::geometry::ConwayGeometryProcessor::ResultsGltf GeometryToGltf(
uint32_t modelID, conway::geometry::IfcGeometry geom, bool isGlb,
conway::geometry::IfcGeometry geom, bool isGlb,
bool outputDraco, std::string filePath) {
auto& conwayProcessor = processors[modelID];

conway::geometry::ConwayGeometryProcessor::ResultsGltf results =
conwayProcessor->GeometryToGltf(geom, isGlb, outputDraco, filePath, false,
NormalizeMat);
conway::geometry::ConwayGeometryProcessor::ResultsGltf results;
if (processor) {
results = processor->GeometryToGltf(geom, isGlb, outputDraco, filePath,
false, NormalizeMat);
}

return results;
}

std::string GeometryToObj(uint32_t modelID, conway::geometry::IfcGeometry geom,
std::string GeometryToObj(conway::geometry::IfcGeometry geom,
size_t offset) {
auto& conwayProcessor = processors[modelID];
return conwayProcessor->GeometryToObj(geom, offset, NormalizeMat);
std::string result;
if (processor) {
return processor->GeometryToObj(geom, offset, NormalizeMat);
} else {
return result;
}
}

conway::geometry::IfcGeometry GetGeometry(
uint32_t modelID,
conway::geometry::ConwayGeometryProcessor::ParamsGetPolygonalFaceSetGeometry
parameters) {
auto& conwayProcessor = processors[modelID];
return conwayProcessor->getPolygonalFaceSetGeometry(parameters);
conway::geometry::IfcGeometry geom;

if (processor) {
return processor->getPolygonalFaceSetGeometry(parameters);
} else {
return geom;
}
}

glm::dmat4 GetLocalPlacement(
uint32_t modelID,
conway::geometry::ConwayGeometryProcessor::ParamsLocalPlacement
parameters) {
auto& conwayProcessor = processors[modelID];
// printf("parameters.useRelPlacement: %s", (parameters.useRelPlacement) ?
// "True" : "False");
return conwayProcessor->GetLocalPlacement(parameters);
glm::dmat4 resultMat;
if (processor) {
resultMat = processor->GetLocalPlacement(parameters);
}

return resultMat;
}

glm::dmat4 GetAxis2Placement3D(
uint32_t modelID,
conway::geometry::ConwayGeometryProcessor::ParamsAxis2Placement3D
parameters) {
auto& conwayProcessor = processors[modelID];

return conwayProcessor->GetAxis2Placement3D(parameters);
glm::dmat4 resultMat;
if (processor) {
resultMat = processor->GetAxis2Placement3D(parameters);
}

return resultMat;
}

uint32_t InitializeGeometryProcessor() {
uint32_t modelID = GLOBAL_MODEL_ID_COUNTER++;
auto conwayProcessor =
std::make_unique<conway::geometry::ConwayGeometryProcessor>();
processors.emplace(modelID, std::move(conwayProcessor));
bool InitializeGeometryProcessor() {
processor = std::make_unique<conway::geometry::ConwayGeometryProcessor>();

return modelID;
return true;
}

bool FreeGeometryProcessor(uint32_t modelID) {
processors.erase(modelID);
bool FreeGeometryProcessor() {
processor.release();
return true;
}

Expand Down Expand Up @@ -128,9 +130,12 @@ EMSCRIPTEN_BINDINGS(my_module) {
.function("getIndexData", &conway::geometry::IfcGeometry::GetIndexData)
.function("getIndexDataSize",
&conway::geometry::IfcGeometry::GetIndexDataSize)
.function("appendGeometry", &conway::geometry::IfcGeometry::AppendGeometry)
.function("appendGeometry",
&conway::geometry::IfcGeometry::AppendGeometry)
.function("applyTransform",
&conway::geometry::IfcGeometry::ApplyTransform);
&conway::geometry::IfcGeometry::ApplyTransform)
.function("clone",
&conway::geometry::IfcGeometry::Clone);

emscripten::value_object<glm::dvec4>("dvec4")
.field("x", &glm::dvec4::x)
Expand Down
Loading

0 comments on commit cfdb138

Please sign in to comment.