Skip to content

Commit

Permalink
make name not private
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvanmele committed Oct 2, 2024
1 parent 4622e43 commit aac7600
Show file tree
Hide file tree
Showing 13 changed files with 67 additions and 45 deletions.
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/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
84 changes: 53 additions & 31 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 @@ -18,8 +17,8 @@ typedef CGAL::Straight_skeleton_2<K>::Vertex_const_handle Vertex_const_handle;
typedef boost::shared_ptr<Polygon_2> PolygonPtr;
typedef std::vector<PolygonPtr> PolygonPtrVector;


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 @@ -29,7 +28,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 @@ -38,21 +38,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 @@ -95,26 +101,29 @@ std::tuple<compas::RowMatrixXd, std::vector<int>, compas::RowMatrixXi, std::vect
hole.push_back(Point(H(i, 0), H(i, 1)));
}
poly.add_hole(hole);

}

SsPtr iss = CGAL::create_interior_straight_skeleton_2(poly);
return mesh_data_from_skeleton(iss);
}

std::vector<compas::RowMatrixXd> pmp_create_offset_polygons_2_inner(Eigen::Ref<const compas::RowMatrixXd> &V, double &offset){
std::vector<compas::RowMatrixXd> pmp_create_offset_polygons_2_inner(Eigen::Ref<const compas::RowMatrixXd> &V, double &offset)
{
Polygon_2 poly;
for (int i = 0; i < V.rows(); i++){
for (int i = 0; i < V.rows(); i++)
{
poly.push_back(Point(V(i, 0), V(i, 1)));
}
PolygonPtrVector offset_polygons = CGAL::create_interior_skeleton_and_offset_polygons_2(offset, poly);

std::vector<compas::RowMatrixXd> result;
for(auto pi = offset_polygons.begin(); pi != offset_polygons.end(); ++pi){
for (auto pi = offset_polygons.begin(); pi != offset_polygons.end(); ++pi)
{
std::size_t n = (*pi)->size();
compas::RowMatrixXd points(n, 3);
int j = 0;
for (auto vi = (*pi)->vertices_begin(); vi != (*pi)->vertices_end(); ++vi){
for (auto vi = (*pi)->vertices_begin(); vi != (*pi)->vertices_end(); ++vi)
{
points(j, 0) = (double)(*vi).x();
points(j, 1) = (double)(*vi).y();
points(j, 2) = 0;
Expand All @@ -125,19 +134,23 @@ std::vector<compas::RowMatrixXd> pmp_create_offset_polygons_2_inner(Eigen::Ref<c
return result;
}

std::vector<compas::RowMatrixXd> pmp_create_offset_polygons_2_outer(Eigen::Ref<const compas::RowMatrixXd> &V, double &offset){
std::vector<compas::RowMatrixXd> pmp_create_offset_polygons_2_outer(Eigen::Ref<const compas::RowMatrixXd> &V, double &offset)
{
Polygon_2 poly;
for (int i = 0; i < V.rows(); i++){
for (int i = 0; i < V.rows(); i++)
{
poly.push_back(Point(V(i, 0), V(i, 1)));
}
PolygonPtrVector offset_polygons = CGAL::create_exterior_skeleton_and_offset_polygons_2(offset, poly);

std::vector<compas::RowMatrixXd> result;
for(auto pi = offset_polygons.begin(); pi != offset_polygons.end(); ++pi){
for (auto pi = offset_polygons.begin(); pi != offset_polygons.end(); ++pi)
{
std::size_t n = (*pi)->size();
compas::RowMatrixXd points(n, 3);
int j = 0;
for (auto vi = (*pi)->vertices_begin(); vi != (*pi)->vertices_end(); ++vi){
for (auto vi = (*pi)->vertices_begin(); vi != (*pi)->vertices_end(); ++vi)
{
points(j, 0) = (double)(*vi).x();
points(j, 1) = (double)(*vi).y();
points(j, 2) = 0;
Expand All @@ -148,24 +161,29 @@ std::vector<compas::RowMatrixXd> pmp_create_offset_polygons_2_outer(Eigen::Ref<c
return result;
}

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){
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;
for (int i = 0; i < V.rows(); i++){
for (int i = 0; i < V.rows(); i++)
{
poly.push_back(Point(V(i, 0), V(i, 1)));
}
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);
PolygonPtrVector offset_polygons = CGAL::create_offset_polygons_2<Polygon_2>(offset, *iss);

std::vector<compas::RowMatrixXd> result;
for(auto pi = offset_polygons.begin(); pi != offset_polygons.end(); ++pi){
for (auto pi = offset_polygons.begin(); pi != offset_polygons.end(); ++pi)
{
std::size_t n = (*pi)->size();
compas::RowMatrixXd points(n, 3);
int j = 0;
for (auto vi = (*pi)->vertices_begin(); vi != (*pi)->vertices_end(); ++vi){
for (auto vi = (*pi)->vertices_begin(); vi != (*pi)->vertices_end(); ++vi)
{
points(j, 0) = (double)(*vi).x();
points(j, 1) = (double)(*vi).y();
points(j, 2) = 0;
Expand All @@ -176,24 +194,29 @@ std::vector<compas::RowMatrixXd> pmp_create_weighted_offset_polygons_2_inner(Eig
return result;
}

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){
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;
for (int i = 0; i < V.rows(); i++){
for (int i = 0; i < V.rows(); i++)
{
poly.push_back(Point(V(i, 0), V(i, 1)));
}
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);
PolygonPtrVector offset_polygons = CGAL::create_offset_polygons_2<Polygon_2>(offset, *iss);

std::vector<compas::RowMatrixXd> result;
for(auto pi = offset_polygons.begin(); pi != offset_polygons.end(); ++pi){
for (auto pi = offset_polygons.begin(); pi != offset_polygons.end(); ++pi)
{
std::size_t n = (*pi)->size();
compas::RowMatrixXd points(n, 3);
int j = 0;
for (auto vi = (*pi)->vertices_begin(); vi != (*pi)->vertices_end(); ++vi){
for (auto vi = (*pi)->vertices_begin(); vi != (*pi)->vertices_end(); ++vi)
{
points(j, 0) = (double)(*vi).x();
points(j, 1) = (double)(*vi).y();
points(j, 2) = 0;
Expand Down Expand Up @@ -248,5 +271,4 @@ void init_straight_skeleton_2(pybind11::module &m)
pybind11::arg("V").noconvert(),
pybind11::arg("offset").noconvert(),
pybind11::arg("weights").noconvert());

};

0 comments on commit aac7600

Please sign in to comment.