Skip to content

Commit

Permalink
WIP: pnpm build
Browse files Browse the repository at this point in the history
  • Loading branch information
thewtex committed Feb 23, 2024
1 parent dc4ac5c commit 1c889e1
Show file tree
Hide file tree
Showing 11 changed files with 162 additions and 60 deletions.
16 changes: 6 additions & 10 deletions itkwasm-sub-mesh/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.16)
project(sub-mesh)
project(itkwasm-sub-mesh LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)

set(io_components)
if(NOT EMSCRIPTEN)
Expand All @@ -15,12 +15,8 @@ find_package(ITK REQUIRED
)
include(${ITK_USE_FILE})

add_executable(sub-mesh sub-mesh.cxx)
target_link_libraries(sub-mesh PUBLIC ${ITK_LIBRARIES})

enable_testing()
add_test(NAME sub-mesh
COMMAND sub-mesh ${CMAKE_CURRENT_SOURCE_DIR}/cow.vtk
${CMAKE_CURRENT_SOURCE_DIR}/cow-cells-to-extract.json
${CMAKE_CURRENT_BINARY_DIR}/sub-cow.vtk
)

# Begin create-itk-wasm added pipelines.
add_subdirectory(sub-mesh)
# End create-itk-wasm added pipelines.
2 changes: 1 addition & 1 deletion itkwasm-sub-mesh/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# itkwasm-sub-mesh

Extract subset of a mesh given by the cell identifiers.
Extract a subset of a mesh given by the cell identifiers.
1 change: 1 addition & 0 deletions itkwasm-sub-mesh/cow-cells-to-extract.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199]
9 changes: 9 additions & 0 deletions itkwasm-sub-mesh/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: itkwasm-sub-mesh
channels:
- conda-forge
dependencies:
- pytest
- python=3.11
- pip
- pip:
- hatch
48 changes: 48 additions & 0 deletions itkwasm-sub-mesh/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"name": "itkwasm-sub-mesh-build",
"version": "0.1.0",
"private": true,
"packageManager": "[email protected]",
"description": "Scripts to generate itkwasm-sub-mesh itk-wasm artifacts.",
"type": "module",
"itk-wasm": {
"package-description": "Extract a subset of a mesh given by the cell identifiers.",
"typescript-package-name": "@itk-wasm/sub-mesh",
"python-package-name": "itkwasm-sub-mesh",
"repository": "https://github.com/uncbiag/OAI_analysis_2"
},
"license": "Apache-2.0",
"scripts": {
"build": "pnpm build:gen:typescript && pnpm build:gen:python",
"build:emscripten": "itk-wasm pnpm-script build:emscripten",
"build:emscripten:debug": "itk-wasm pnpm-script build:emscripten:debug",
"build:wasi": "itk-wasm pnpm-script build:wasi",
"build:wasi:debug": "itk-wasm pnpm-script build:wasi:debug",
"build:python:wasi": "itk-wasm pnpm-script build:python:wasi",
"bindgen:typescript": "itk-wasm pnpm-script bindgen:typescript",
"bindgen:python": "itk-wasm pnpm-script bindgen:python",
"build:gen:typescript": "itk-wasm pnpm-script build:gen:typescript",
"build:gen:python": "itk-wasm pnpm-script build:gen:python",
"build:micromamba": "itk-wasm pnpm-script build:micromamba",
"build:python:versionSync": "itk-wasm pnpm-script build:python:versionSync",
"publish:python": "itk-wasm pnpm-script publish:python",
"test": "pnpm test:data:download && pnpm build:gen:python && pnpm test:python",
"test:data:download": "dam download test/data test/data.tar.gz bafkreigpkk3pqcoqzjzcauogw6dml52yig3ksmcrobau5pkoictymizzri https://github.com/InsightSoftwareConsortium/itk-wasm/releases/download/itk-wasm-v1.0.0-b.163/create-itk-wasm-test-data.tar.gz https://bafybeiczuxeuma5cjuli5mtapqnjqypeaum5ikd45zcmfhtt2emp365tca.ipfs.w3s.link/ipfs/bafybeiczuxeuma5cjuli5mtapqnjqypeaum5ikd45zcmfhtt2emp365tca/create-itk-wasm-test-data.tar.gz https://ipfs.filebase.io/ipfs/QmcxyvUKnaoTTwUqEPXwp1sdcbrFh3XnnwckLKVRpctJx9",
"test:data:pack": "dam pack test/data test/data.tar.gz",
"test:python:wasi": "itk-wasm pnpm-script test:python:wasi",
"test:python:emscripten": "itk-wasm pnpm-script test:python:emscripten",
"test:python:dispatch": "itk-wasm pnpm-script test:python:emscripten",
"test:python": "itk-wasm pnpm-script test:python",
"test:wasi": "itk-wasm pnpm-script test:wasi"
},
"devDependencies": {
"@itk-wasm/dam": "^1.1.1",
"@thewtex/setup-micromamba": "^1.9.7",
"itk-wasm": "1.0.0-b.167"
},
"author": "Matt McCormick",
"repository": {
"type": "git",
"url": "https://github.com/uncbiag/OAI_analysis_2"
}
}
2 changes: 2 additions & 0 deletions itkwasm-sub-mesh/pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
packages:
- 'typescript'
49 changes: 0 additions & 49 deletions itkwasm-sub-mesh/sub-mesh.cxx

This file was deleted.

4 changes: 4 additions & 0 deletions itkwasm-sub-mesh/sub-mesh/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
add_executable(sub-mesh sub-mesh.cxx)
target_link_libraries(sub-mesh PUBLIC ${ITK_LIBRARIES})

add_test(NAME sub-mesh-help COMMAND sub-mesh --help)
Empty file.
File renamed without changes.
91 changes: 91 additions & 0 deletions itkwasm-sub-mesh/sub-mesh/sub-mesh.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*=========================================================================
* Copyright NumFOCUS
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/

#include "itkPipeline.h"
#include "itkInputMesh.h"
#include "itkInputTextStream.h"
#include "itkOutputMesh.h"
#include "itkSupportInputMeshTypes.h"

#include "itkTriangleCell.h"
#include "itkVertexCell.h"
#include "itkQuadrilateralCell.h"
#include "itkTetrahedronCell.h"
#include "itkHexahedronCell.h"

#include "itkAutomaticTopologyMeshSource.h"

template <typename TMesh>
int subMesh(itk::wasm::Pipeline &pipeline, const TMesh *mesh)
{
using MeshType = TMesh;
constexpr unsigned int Dimension = MeshType::PointDimension;
using PixelType = typename MeshType::PixelType;

pipeline.get_option("mesh")->required()->type_name("INPUT_MESH");

std::vector< uint32_t > cellIdentifiers;
pipeline.add_option("cell-identifiers", cellIdentifiers, "Cell identifiers for output mesh.")->required();

itk::wasm::OutputMesh<MeshType> subMesh;
pipeline.add_option("sub-mesh", subMesh, "Sub mesh.")->required()->type_name("OUTPUT_MESH");

ITK_WASM_PARSE(pipeline);

std::set< itk::IdentifierType > usedPoints;
for (auto cellIdentifier : cellIdentifiers)
{
const typename MeshType::CellType * cell = mesh->GetCell(cellIdentifier);

// meshSource->AddCellIdentifier(cellIdentifier);
}

using MeshSourceType = itk::AutomaticTopologyMeshSource< MeshType >;
auto meshSource = MeshSourceType::New();

subMesh.Set(mesh);

return EXIT_SUCCESS;
}

template <typename TMesh>
class PipelineFunctor
{
public:
int operator()(itk::wasm::Pipeline &pipeline)
{
using MeshType = TMesh;

itk::wasm::InputMesh<MeshType> mesh;
pipeline.add_option("mesh", mesh, "Full mesh")->type_name("INPUT_MESH");

ITK_WASM_PRE_PARSE(pipeline);

typename MeshType::ConstPointer meshRef = mesh.Get();
return subMesh<MeshType>(pipeline, meshRef);
}
};

int main(int argc, char * argv[])
{
itk::wasm::Pipeline pipeline("sub-mesh", "Extract a subset of a mesh given by the cell identifiers.", argc, argv);

return itk::wasm::SupportInputMeshTypes<PipelineFunctor,
uint8_t, uint16_t, int16_t, float, double>
::Dimensions<3U>("mesh", pipeline);
}

0 comments on commit 1c889e1

Please sign in to comment.