Skip to content

Commit

Permalink
Merge branch 'main' into feature/offset_with_holes
Browse files Browse the repository at this point in the history
  • Loading branch information
romanarust committed Oct 3, 2024
2 parents 161a127 + 6522ee2 commit de8da47
Show file tree
Hide file tree
Showing 26 changed files with 82 additions and 156 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, windows-latest]
python: ["3.9", "3.10", "3.11", "3.12"]
os: [macos-latest]
python: ["3.10", "3.11", "3.12"]

steps:
- uses: compas-dev/compas-actions.build@v4
with:
invoke_lint: true
check_import: true
use_conda: true
check_import: true
python: ${{ matrix.python }}
4 changes: 2 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ on:

jobs:
docs:
runs-on: windows-latest
runs-on: ubuntu-latest
steps:
- uses: compas-dev/compas-actions.docs@v3
- uses: compas-dev/compas-actions.docs@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
use_conda: true
Expand Down
6 changes: 3 additions & 3 deletions docs/examples/straight_skeleton_2_holes.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
for edge in graph.edges():
line = graph.edge_line(edge)
if graph.edge_attribute(edge, "inner_bisector"):
viewer.add(line, linecolor=(1.0, 0.0, 0.0), linewidth=2)
viewer.scene.add(line, linecolor=(1.0, 0.0, 0.0), linewidth=2)
elif graph.edge_attribute(edge, "bisector"):
viewer.add(line, linecolor=(0.0, 0.0, 1.0))
viewer.scene.add(line, linecolor=(0.0, 0.0, 1.0))
else:
viewer.add(line, linecolor=(0.0, 0.0, 0.0))
viewer.scene.add(line, linecolor=(0.0, 0.0, 0.0))
viewer.show()
16 changes: 16 additions & 0 deletions env_linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: cgal-dev
channels:
- conda-forge
dependencies:
- python >=3.9
- pip >=19.0
- gmp
- mpfr
- scip >=9
- boost-cpp
- eigen =3.3
- cgal-cpp
- pybind11
- compas >=2.4
- pip:
- .[DEV]
12 changes: 6 additions & 6 deletions env_osx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ name: cgal-dev
channels:
- conda-forge
dependencies:
- python>=3.9
- pip>=19.0
- python >=3.9
- pip >=19.0
- gmp
- mpfr
- scip
- scip >=9
- boost-cpp
- eigen=3.3
- eigen =3.3
- cgal-cpp
- pybind11
- compas
- compas >=2.4
- pip:
- -e .[DEV]
- .[DEV]
12 changes: 6 additions & 6 deletions env_win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ name: cgal-dev
channels:
- conda-forge
dependencies:
- python>=3.6
- pip>=19.0
- python >=3.9
- pip >=19.0
- mpir
- mpfr
- scip
- scip >=9
- boost-cpp
- eigen=3.3
- eigen =3.3
- cgal-cpp
- pybind11
- compas
- compas >=2.4
- pip:
- -e .[DEV]
- .[DEV]
8 changes: 7 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,13 @@ where = ["src"]
minversion = "6.0"
testpaths = ["tests", "src/compas_cgal"]
python_files = ["test_*.py", "*_test.py", "test.py"]
addopts = ["-ra", "--strict-markers", "--doctest-glob=*.rst", "--tb=short"]
addopts = [
"-ra",
"--strict-markers",
"--doctest-glob=*.rst",
"--tb=short",
"--import-mode=importlib",
]
doctest_optionflags = [
"NORMALIZE_WHITESPACE",
"IGNORE_EXCEPTION_DETAIL",
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def get_scip_library():

ext_modules = [
Extension(
"compas_cgal._cgal",
"compas_cgal.cgal",
sorted(
[
"src/compas_cgal.cpp",
Expand Down
6 changes: 3 additions & 3 deletions src/compas_cgal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ void init_reconstruction(pybind11::module &);
void init_polygonal_surface_reconstruction(pybind11::module &);
void init_straight_skeleton_2(pybind11::module &);

// the first parameter here ("_cgal") will be the name of the "so" or "pyd" file that will be produced by PyBind11
// the first parameter here ("cgal") will be the name of the "so" or "pyd" file that will be produced by PyBind11
// which is the entry point from where all other modules will be accessible.
PYBIND11_MODULE(_cgal, m)
PYBIND11_MODULE(cgal, m)
{
m.doc() = "";

// here all modules of "_cgal" are initializied.
// here all modules of "cgal" are initializied.
init_meshing(m);
init_booleans(m);
init_slicer(m);
Expand Down
2 changes: 1 addition & 1 deletion src/compas_cgal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"compas_cgal.measure",
"compas_cgal.slicer",
"compas_cgal.triangulation",
"compas_cgal.straight_skeleton_2",
# "compas_cgal.straight_skeleton_2",
]

__all__ = ["HOME", "DATA", "DOCS", "TEMP"]
2 changes: 1 addition & 1 deletion src/compas_cgal/booleans.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import numpy as np
from compas.plugins import plugin

from compas_cgal._cgal import booleans
from compas_cgal.cgal import booleans

from .types import VerticesFaces
from .types import VerticesFacesNumpy
Expand Down
2 changes: 1 addition & 1 deletion src/compas_cgal/intersections.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
from compas.plugins import plugin

from compas_cgal._cgal import intersections
from compas_cgal.cgal import intersections

from .types import PolylinesNumpy
from .types import VerticesFaces
Expand Down
2 changes: 1 addition & 1 deletion src/compas_cgal/measure.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
from compas.plugins import plugin

from compas_cgal._cgal import measure
from compas_cgal.cgal import measure

from .types import VerticesFaces

Expand Down
2 changes: 1 addition & 1 deletion src/compas_cgal/meshing.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
from compas.plugins import plugin

from compas_cgal._cgal import meshing
from compas_cgal.cgal import meshing

from .types import VerticesFaces
from .types import VerticesFacesNumpy
Expand Down
2 changes: 1 addition & 1 deletion src/compas_cgal/polygonal_surface_reconstruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from compas.geometry import Point
from compas.geometry import Vector

from compas_cgal._cgal import polygonal_surface_reconstruction
from compas_cgal.cgal import polygonal_surface_reconstruction

from .types import FloatNx3

Expand Down
2 changes: 1 addition & 1 deletion src/compas_cgal/reconstruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from compas.geometry import Point
from compas.geometry import Vector

from compas_cgal._cgal import reconstruction
from compas_cgal.cgal import reconstruction

from .types import FloatNx3
from .types import IntNx3
Expand Down
2 changes: 1 addition & 1 deletion src/compas_cgal/skeletonization.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np

from compas_cgal._cgal import skeletonization
from compas_cgal.cgal import skeletonization

from .types import PolylinesNumpy
from .types import VerticesFaces
Expand Down
2 changes: 1 addition & 1 deletion src/compas_cgal/slicer.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
from compas.plugins import plugin

from compas_cgal._cgal import slicer
from compas_cgal.cgal import slicer

from .types import Planes
from .types import PolylinesNumpy
Expand Down
2 changes: 1 addition & 1 deletion src/compas_cgal/straight_skeleton_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from compas.geometry import normal_polygon
from compas.tolerance import TOL

from compas_cgal._cgal import straight_skeleton_2
from compas_cgal.cgal import straight_skeleton_2

from .types import IntNx1
from .types import IntNx2
Expand Down
2 changes: 1 addition & 1 deletion src/compas_cgal/subdivision.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np

from compas_cgal._cgal import subdivision
from compas_cgal.cgal import subdivision

from .types import VerticesFaces
from .types import VerticesFacesNumpy
Expand Down
2 changes: 1 addition & 1 deletion src/compas_cgal/triangulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from compas.geometry import Point
from compas.plugins import plugin

from compas_cgal._cgal import triangulations
from compas_cgal.cgal import triangulations

from .types import FacesNumpy
from .types import VerticesFacesNumpy
Expand Down
35 changes: 21 additions & 14 deletions src/straight_skeleton_2.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#include "straight_skeleton_2.h"
#include <CGAL/Polygon_2.h>
#include <CGAL/create_straight_skeleton_2.h>
Expand All @@ -21,8 +20,8 @@ typedef std::vector<PolygonPtr> PolygonPtrVector;
typedef boost::shared_ptr<Polygon_with_holes> PolygonWithHolesPtr;
typedef std::vector<PolygonWithHolesPtr> PolygonWithHolesPtrVector;


std::tuple<compas::RowMatrixXd, std::vector<int>, compas::RowMatrixXi, std::vector<int>> mesh_data_from_skeleton(boost::shared_ptr<Ss> &iss){
std::tuple<compas::RowMatrixXd, std::vector<int>, compas::RowMatrixXi, std::vector<int>> mesh_data_from_skeleton(boost::shared_ptr<Ss> &iss)
{
std::size_t v = iss->size_of_vertices();
std::size_t e = iss->size_of_halfedges() / 2; // halfedges are stored twice

Expand All @@ -32,7 +31,8 @@ std::tuple<compas::RowMatrixXd, std::vector<int>, compas::RowMatrixXi, std::vect
std::vector<int> Mei; // to save the edge type: 0: inner bisector, 1: bisector, 2: boundary

std::size_t i = 0;
for(auto hit = iss->vertices_begin(); hit != iss->vertices_end(); ++hit){
for (auto hit = iss->vertices_begin(); hit != iss->vertices_end(); ++hit)
{
const Vertex_const_handle vh = hit;
Mv(i, 0) = (double)vh->point().x();
Mv(i, 1) = (double)vh->point().y();
Expand All @@ -41,21 +41,27 @@ std::tuple<compas::RowMatrixXd, std::vector<int>, compas::RowMatrixXi, std::vect
i++;
}
i = 0;
for(auto hit = iss->halfedges_begin(); hit != iss->halfedges_end(); ++hit){
for (auto hit = iss->halfedges_begin(); hit != iss->halfedges_end(); ++hit)
{
const Halfedge_const_handle h = hit;
const Vertex_const_handle& v1 = h->vertex();
const Vertex_const_handle& v2 = h->opposite()->vertex();
const Vertex_const_handle &v1 = h->vertex();
const Vertex_const_handle &v2 = h->opposite()->vertex();

if(&*v1 < &*v2){
if (&*v1 < &*v2)
{
Me(i, 0) = (int)v1->id();
Me(i, 1) = (int)v2->id();

if(h->is_inner_bisector()){
if (h->is_inner_bisector())
{
Mei.push_back(0);
}
else if(h->is_bisector()){
else if (h->is_bisector())
{
Mei.push_back(1);
}else{
}
else
{
Mei.push_back(2);
}
i++;
Expand Down Expand Up @@ -179,7 +185,8 @@ std::vector<std::tuple<compas::RowMatrixXd, std::vector<compas::RowMatrixXd>>> p
std::vector<compas::RowMatrixXd> pmp_create_weighted_offset_polygons_2_inner(Eigen::Ref<const compas::RowMatrixXd> &V, double &offset, Eigen::Ref<const compas::RowMatrixXd> &weights){
Polygon_2 poly = data_to_polygon(V);
std::vector<double> weights_vec;
for (int i = 0; i < weights.rows(); i++){
for (int i = 0; i < weights.rows(); i++)
{
weights_vec.push_back(weights(i, 0));
}
SsPtr iss = CGAL::create_interior_weighted_straight_skeleton_2(poly, weights_vec);
Expand All @@ -196,7 +203,8 @@ std::vector<compas::RowMatrixXd> pmp_create_weighted_offset_polygons_2_inner(Eig
std::vector<compas::RowMatrixXd> pmp_create_weighted_offset_polygons_2_outer(Eigen::Ref<const compas::RowMatrixXd> &V, double &offset, Eigen::Ref<const compas::RowMatrixXd> &weights){
Polygon_2 poly = data_to_polygon(V);
std::vector<double> weights_vec;
for (int i = 0; i < weights.rows(); i++){
for (int i = 0; i < weights.rows(); i++)
{
weights_vec.push_back(weights(i, 0));
}
SsPtr iss = CGAL::create_exterior_weighted_straight_skeleton_2(offset, weights_vec, poly);
Expand Down Expand Up @@ -268,5 +276,4 @@ void init_straight_skeleton_2(pybind11::module &m)
pybind11::arg("V").noconvert(),
pybind11::arg("offset").noconvert(),
pybind11::arg("weights").noconvert());

};
45 changes: 0 additions & 45 deletions tests/_test_remeshing.py

This file was deleted.

Loading

0 comments on commit de8da47

Please sign in to comment.