Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# syntax=docker/dockerfile:1.4
FROM --platform=linux/amd64 python:3.9 as base

RUN python -m pip install --upgrade pip

FROM base as dev

# Insgtall OCC requirements
RUN apt-get update
RUN apt-get install -y ffmpeg libsm6 libxext6

# Install conda
RUN mkdir -p ~/miniconda3 && \
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda3/miniconda.sh && \
bash ~/miniconda3/miniconda.sh -b -u -p /miniconda3 && \
rm -rf ~/miniconda3/miniconda.sh && \
/miniconda3/bin/conda init bash

ARG PROJ_DIR=/proj
ARG PIP_CACHE=/root/.cache/pip
WORKDIR ${PROJ_DIR}

# Create conda environment
COPY environment.yml .
RUN --mount=type=cache,target=/miniconda3/pkgs,id=conda \
/miniconda3/bin/conda env create -f environment.yml
SHELL ["conda", "run", "--no-capture-output", "-n", "occwl_dev", "/bin/bash", "-c"]

# Install Python dependencies
# COPY setup.py .
# RUN mkdir -p ${PROJ_DIR}/src
# RUN --mount=type=cache,target=${PIP_CACHE},id=pip \
# /miniconda3/bin/conda run -n occwl_dev python -m \
# pip install -v --cache-dir ${PIP_CACHE} -e .

ENTRYPOINT [ "/bin/bash", "-c" ]
47 changes: 47 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/alpine
{
"name": "Alpine",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
// "image": "occ_dev:7.8.1",
"build": {
// this requires ../docker/Dockerfile to be built to brep_directgen:dev tag.
"dockerfile": "Dockerfile",
"context": ".."
},
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "uname -a",
// Configure tool-specific properties.
"customizations": {
"vscode": {
"extensions": [
"charliermarsh.ruff",
"eamodio.gitlens",
"github.vscode-pull-request-github",
"ms-python.debugpy",
"ms-python.python",
"ms-toolsai.jupyter",
"streetsidesoftware.code-spell-checker",
"ms-azuretools.vscode-docker",
"github.copilot"
],
"settings": {
"extensions.verifySignature": false,
"[python]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": "explicit",
"source.organizeImports": "explicit"
},
"editor.defaultFormatter": "charliermarsh.ruff"
}
}
}
},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ OCCWL is a simple, lightweight Pythonic wrapper around pythonocc (python binding
## Installing our conda package

```
conda create --name=myoccwlenv python=3.7
conda create --name=myoccwlenv python=3.9
source activate myoccwlenv
conda install -c lambouj -c conda-forge occwl
```
Expand Down
4 changes: 2 additions & 2 deletions ci/conda/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% set name = "occwl" %}
{% set version = "2.1.0" %}
{% set version = "3.0.0" %}

package:
name: "{{ name|lower }}"
Expand All @@ -20,7 +20,7 @@ requirements:
- setuptools
run:
- python >=3.7
- pythonocc-core =7.5.1
- pythonocc-core =7.8.1
- numpy
- pyqt >=5
- wxpython >=4
Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ channels:
dependencies:
- python=3.9
- numpy
- pythonocc-core=7.5.1
- pythonocc-core=7.8.1
- networkx
- wxPython
- pydeprecate
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setuptools.setup(
name="occwl", # package name
version="2.1.0",
version="3.0.0",
author="Pradeep Kumar Jayaraman, Joseph G. Lambourne",
author_email="[email protected], [email protected]",
description="Lightweight Pythonic wrapper around pythonocc",
Expand Down
25 changes: 9 additions & 16 deletions src/occwl/base.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
import numpy as np

from OCC.Core.gp import gp_Pnt, gp_Dir, gp_Pnt2d, gp_Ax2
from OCC.Core.Bnd import Bnd_Box
from OCC.Core.BRepBndLib import brepbndlib_Add, brepbndlib_AddOptimal
from OCC.Extend import TopologyUtils
from OCC.Core.BRepGProp import (
brepgprop_LinearProperties,
brepgprop_SurfaceProperties,
brepgprop_VolumeProperties,
)
from OCC.Core.BRepBndLib import brepbndlib
from OCC.Core.BRepGProp import brepgprop
from OCC.Core.BRepMesh import BRepMesh_IncrementalMesh
from OCC.Core.GProp import GProp_GProps
from OCC.Core.gp import gp_Pnt, gp_Dir, gp_Ax1, gp_Vec, gp_Trsf
from OCC.Core.gp import gp_Pnt, gp_Ax1, gp_Vec, gp_Trsf
from OCC.Core.ShapeUpgrade import ShapeUpgrade_ShapeDivideClosed
from OCC.Core.ShapeUpgrade import ShapeUpgrade_ShapeDivideClosedEdges
from OCC.Core.BRepBuilderAPI import BRepBuilderAPI_Transform


class VertexContainerMixin:
Expand Down Expand Up @@ -498,7 +491,7 @@ def area(self):
float: Area
"""
geometry_properties = GProp_GProps()
brepgprop_SurfaceProperties(self.topods_shape(), geometry_properties)
brepgprop.SurfaceProperties(self.topods_shape(), geometry_properties)
return geometry_properties.Mass()


Expand All @@ -517,7 +510,7 @@ def volume(self, tolerance=1e-9):
float: Volume
"""
props = GProp_GProps()
brepgprop_VolumeProperties(self.topods_shape(), props, tolerance)
brepgprop.VolumeProperties(self.topods_shape(), props, tolerance)
return props.Mass()

def center_of_mass(self, tolerance=1e-9):
Expand All @@ -532,7 +525,7 @@ def center_of_mass(self, tolerance=1e-9):
"""
from occwl.geometry import geom_utils
props = GProp_GProps()
brepgprop_VolumeProperties(self.topods_shape(), props, tolerance)
brepgprop.VolumeProperties(self.topods_shape(), props, tolerance)
com = props.CentreOfMass()
return geom_utils.gp_to_numpy(com)

Expand All @@ -550,7 +543,7 @@ def moment_of_inertia(self, point, direction, tolerance=1e-9):
"""
from occwl.geometry import geom_utils
props = GProp_GProps()
brepgprop_VolumeProperties(self.topods_shape(), props, tolerance)
brepgprop.VolumeProperties(self.topods_shape(), props, tolerance)
axis = gp_Ax1(
geom_utils.numpy_to_gp(point), geom_utils.numpy_to_gp_dir(direction)
)
Expand All @@ -571,7 +564,7 @@ def box(self):
"""
from occwl.geometry import geom_utils
b = Bnd_Box()
brepbndlib_Add(self.topods_shape(), b)
brepbndlib.Add(self.topods_shape(), b)
return geom_utils.box_to_geometry(b)

def exact_box(self, use_shapetolerance=False):
Expand All @@ -588,7 +581,7 @@ def exact_box(self, use_shapetolerance=False):
from occwl.geometry import geom_utils
b = Bnd_Box()
use_triangulation = True
brepbndlib_AddOptimal(self.topods_shape(), b, use_triangulation, use_shapetolerance)
brepbndlib.AddOptimal(self.topods_shape(), b, use_triangulation, use_shapetolerance)
return geom_utils.box_to_geometry(b)

def scale_to_box(self, box_side, copy=True):
Expand Down
3 changes: 0 additions & 3 deletions src/occwl/batch/render_multiview.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
from multiprocessing import Pool
from occwl.compound import Compound
from occwl.viewer import OffscreenRenderer
from OCC.Core.gp import gp_Dir, gp_Vec
from OCC.Core.V3d import V3d_DirectionalLight
from OCC.Core.Quantity import Quantity_Color, Quantity_TOC_RGB, Quantity_NOC_WHITE
from tqdm import tqdm


Expand Down
20 changes: 7 additions & 13 deletions src/occwl/edge.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import numpy as np

from OCC.Core.gp import gp_Pnt, gp_Dir, gp_Vec, gp_Pnt2d, gp_Ax2, gp_Circ
from OCC.Core.BRep import BRep_Tool, BRep_Tool_Curve, BRep_Tool_Continuity
from OCC.Core.gp import gp_Pnt, gp_Vec, gp_Ax2, gp_Circ
from OCC.Core.BRep import BRep_Tool
from OCC.Core.BRepAdaptor import BRepAdaptor_Curve
from OCC.Core.BRepGProp import brepgprop_LinearProperties
from OCC.Core.BRepGProp import brepgprop
from OCC.Core.GC import GC_MakeArcOfCircle
from OCC.Core.GProp import GProp_GProps
from OCC.Core.GeomAbs import (
Expand All @@ -17,11 +17,7 @@
GeomAbs_OffsetCurve,
GeomAbs_OtherCurve,
)
from OCC.Core.TopAbs import TopAbs_REVERSED
from OCC.Extend import TopologyUtils
from OCC.Core.TopoDS import TopoDS_Edge
from OCC.Core.GCPnts import GCPnts_AbscissaPoint
from OCC.Core.BRepAdaptor import BRepAdaptor_Curve
from OCC.Core.ShapeAnalysis import ShapeAnalysis_Edge
from OCC.Core.BRepBuilderAPI import BRepBuilderAPI_MakeEdge
from OCC.Core.GCPnts import (
Expand All @@ -35,8 +31,6 @@
from occwl.geometry.interval import Interval
from occwl.shape import Shape
from occwl.base import VertexContainerMixin, BoundingBoxMixin
from deprecate import deprecated
import logging


class Edge(Shape, VertexContainerMixin, BoundingBoxMixin):
Expand Down Expand Up @@ -217,7 +211,7 @@ def length(self):
if not self.has_curve():
return 0.0
geometry_properties = GProp_GProps()
brepgprop_LinearProperties(self.topods_shape(), geometry_properties)
brepgprop.LinearProperties(self.topods_shape(), geometry_properties)
return geometry_properties.Mass()

def curve(self):
Expand All @@ -227,7 +221,7 @@ def curve(self):
Returns:
OCC.Geom.Handle_Geom_Curve: Interface to all curve geometry
"""
return BRep_Tool_Curve(self.topods_shape())[0]
return BRep_Tool.Curve(self.topods_shape())[0]

def specific_curve(self):
"""
Expand Down Expand Up @@ -278,7 +272,7 @@ def u_bounds(self):
if not self.has_curve():
# Return an empty interval
return Interval()
_, umin, umax = BRep_Tool_Curve(self.topods_shape())
_, umin, umax = BRep_Tool.Curve(self.topods_shape())
return Interval(umin, umax)

def reversed_edge(self):
Expand Down Expand Up @@ -363,7 +357,7 @@ def continuity(self, face1, face2):
Returns:
GeomAbs_Shape: enum describing the continuity order
"""
return BRep_Tool_Continuity(
return BRep_Tool.Continuity(
self.topods_shape(), face1.topods_shape(), face2.topods_shape()
)

Expand Down
6 changes: 2 additions & 4 deletions src/occwl/edge_data_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@
import numpy as np

# OCC
from OCC.Core.BRepAdaptor import BRepAdaptor_Curve2d, BRepAdaptor_Surface
from OCC.Core.gp import gp_Pnt2d, gp_Identity
from OCC.Core.BRepAdaptor import BRepAdaptor_Curve2d
from OCC.Core.gp import gp_Pnt2d

# occwl
from occwl.geometry.interval import Interval
from occwl.geometry.arc_length_param_finder import ArcLengthParamFinder
import occwl.geometry.geom_utils as geom_utils

class EdgeConvexity(Enum):
CONCAVE = 1
Expand Down
Loading