Skip to content

Commit

Permalink
Added BND_Extrusion::CreateWithPlane cite #636, cite #568
Browse files Browse the repository at this point in the history
  • Loading branch information
fraguada committed Nov 26, 2024
1 parent 0735f1a commit cc36835
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 7 deletions.
11 changes: 6 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,24 @@ diff:
- (js, py) DimensionStyle.Id
- (js, py) Several delete methods for File3dm Tables: File3dmMaterialTable::Delete, BND_File3dmLayerTable::Delete, BND_File3dmDimStyleTable::Delete
- (js, py) Added tests for various ::Delete methods.
- (js, py) Extrusion::CreateWithPlane #636
- (py) Added python 3.13 target #654
- (py) BND_MeshingParameters::Decode now supports more properties
- (js) Layer.Index #655
- (dotnet) Linux release builds in an Amazon Linux 2023 container
- (js) BND_PointCloud::CreateFromThreeJSON #642
- (py) BND_MeshingParameters::Decode now supports more properties

- (js) Added several methods and properties for Planes #568
- (dotnet) Linux release builds in an Amazon Linux 2023 container

### Changed

- (py) switching from pybind11 to nanobind. WIP. This affects a lot of the src/binding files, which now include many `#if defined()`. When the switch is complete these will be cleaned up.
- (js) File3dm.objects().deleteItem(id) -> File3dm.objects().delete(id)
- (py) File3dmObjectTable now accepts negative indexing #651 @StudioWEngineers
- (js) File3dm.objects().deleteItem(id) -> File3dm.objects().delete(id)

### Fixed

- (js, py) Changes to ViewInfo.Viewport would not set.
- (py) uuid conversion in c++ was broken
- (js, py) Changes to ViewInfo.Viewport would not set.
- (js) BND_Mesh::CreateFromThreeJSON did not pay attention to vertex colors #641
- (js) BND_PointCloud::CreateFromThreeJSON did not pay attention to RGBA (4 channel) colors #641

Expand Down
12 changes: 12 additions & 0 deletions src/bindings/bnd_beam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ BND_Extrusion* BND_Extrusion::Create(const BND_Curve& planarCurve, double height
return new BND_Extrusion(ext, nullptr);
}

BND_Extrusion* BND_Extrusion::CreateWithPlane(const BND_Curve& planarCurve, const class BND_Plane& plane, double height, bool cap)
{
const ON_Plane& on_plane_ref = plane.ToOnPlane();
const ON_Plane* on_plane = &on_plane_ref;
ON_Extrusion* ext = ON_Extrusion::CreateFrom3dCurve(*planarCurve.m_curve, on_plane, height, cap);
if (nullptr == ext)
return nullptr;
return new BND_Extrusion(ext, nullptr);
}

BND_Extrusion* BND_Extrusion::CreateBoxExtrusion(const BND_Box& box, bool cap)
{
if (!box.m_box.IsValid()) return nullptr;
Expand Down Expand Up @@ -197,6 +207,7 @@ void initExtrusionBindings(rh3dmpymodule& m)
{
py::class_<BND_Extrusion, BND_Surface>(m, "Extrusion")
.def_static("Create", &BND_Extrusion::Create, py::arg("planarCurve"), py::arg("height"), py::arg("cap"))
.def_static("CreateWithPlane", &BND_Extrusion::CreateWithPlane, py::arg("planarCurve"), py::arg("plane"), py::arg("height"), py::arg("cap"))
.def_static("CreateBoxExtrusion", &BND_Extrusion::CreateBoxExtrusion, py::arg("box"), py::arg("cap"))
.def_static("CreateCylinderExtrusion", &BND_Extrusion::CreateCylinderExtrusion, py::arg("cylinder"), py::arg("capBottom"), py::arg("capTop"))
.def_static("CreatePipeExtrusion", &BND_Extrusion::CreatePipeExtrusion, py::arg("cylinder"), py::arg("otherRadius"), py::arg("capBottom"), py::arg("capTop"))
Expand Down Expand Up @@ -240,6 +251,7 @@ void initExtrusionBindings(void*)
class_<BND_Extrusion, base<BND_Surface>>("Extrusion")
.constructor<>()
.class_function("create", &BND_Extrusion::Create, allow_raw_pointers())
.class_function("createWithPlane", &BND_Extrusion::CreateWithPlane, allow_raw_pointers())
.class_function("createBoxExtrusion", &BND_Extrusion::CreateBoxExtrusion, allow_raw_pointers())
.class_function("createCylinderExtrusion", &BND_Extrusion::CreateCylinderExtrusion, allow_raw_pointers())
.class_function("createPipeExtrusion", &BND_Extrusion::CreatePipeExtrusion, allow_raw_pointers())
Expand Down
1 change: 1 addition & 0 deletions src/bindings/bnd_beam.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class BND_Extrusion : public BND_Surface

public:
static BND_Extrusion* Create(const class BND_Curve& planarCurve, double height, bool cap);
static BND_Extrusion* CreateWithPlane(const class BND_Curve& planarCurve, const class BND_Plane& plane, double height, bool cap);
static BND_Extrusion* CreateBoxExtrusion(const class BND_Box& box, bool cap);
static BND_Extrusion* CreateCylinderExtrusion(const class BND_Cylinder& cylinder, bool capBottom, bool capTop);
static BND_Extrusion* CreatePipeExtrusion(const class BND_Cylinder& cylinder, double otherRadius, bool capTop, bool capBottom);
Expand Down
17 changes: 16 additions & 1 deletion src/bindings/bnd_plane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,22 @@ void initPlaneBindings(void*)
.field("zAxis", &BND_Plane::m_zaxis);

class_<BND_PlaneHelper>("Plane")
.class_function("worldXY", &BND_PlaneHelper::WorldXY);

.class_function("worldXY", &BND_Plane::WorldXY)
.class_function("worldYZ", &BND_Plane::WorldYZ)
.class_function("worldZX", &BND_Plane::WorldZX)
.class_function("unset", &BND_Plane::Unset)
.property("origin", &BND_Plane::m_origin)
.property("xAxis", &BND_Plane::m_xaxis)
.property("yAxis", &BND_Plane::m_yaxis)
.property("zAxis", &BND_Plane::m_zaxis)
.function("pointAtUV", &BND_Plane::PointAtUV)
.function("pointAtUVW", &BND_Plane::PointAtUVW)
.function("rotate", &BND_Plane::Rotate)
.function("toJSON", &BND_Plane::toJSON)
.function("encode", &BND_Plane::Encode)
.class_function("decode", &BND_Plane::Decode)
;

}
#endif
5 changes: 4 additions & 1 deletion src/bindings/bnd_plane.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class BND_Plane
ON_3dPoint PointAtUV(double u, double v) const;
ON_3dPoint PointAtUVW(double u, double v, double w) const;

#if defined(__EMSCRIPTEN__)
#if defined(ON_WASM_COMPILE)
emscripten::val toJSON(emscripten::val key);
emscripten::val Encode() const;
static BND_Plane* Decode(emscripten::val jsonObject);
Expand All @@ -50,5 +50,8 @@ class BND_PlaneHelper
{
public:
static BND_Plane WorldXY();
static BND_Plane WorldYZ();
static BND_Plane WorldZX();
static BND_Plane Unset();

};

0 comments on commit cc36835

Please sign in to comment.