Skip to content

Commit

Permalink
Merge pull request #4 from joe-warren/migrate-to-finalizers
Browse files Browse the repository at this point in the history
Migrate to Finalizers, Add Queries
  • Loading branch information
joe-warren authored Feb 26, 2024
2 parents fee8569 + 28bbf99 commit e83a643
Show file tree
Hide file tree
Showing 63 changed files with 1,065 additions and 137 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,5 @@ Because OpenCASCADE is licensed under the LGPL version 2.1, I'm also using that
[![](images/offset.png)](waterfall-cad-examples/src/OffsetExample.hs)

[![](images/text.png)](waterfall-cad-examples/src/TextExample.hs)

[![](images/bounding_boxes.png)](waterfall-cad-examples/src/BoundingBoxExample.hs)
Binary file added images/bounding_boxes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions opencascade-hs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ and this project adheres to the

## Unreleased

### Added

- Added OpenCascade.BRepGProp
- Added OpenCascade.GProp.GProps
- Added OpenCascade.BRepBndLib
- Added OpenCascade.Bnd.Box
- Added OpenCascade.Bnd.OBB
- Added OpenCascade.GP.XYZ (just the barebones Constructor and Getter/Setter methods)
- Added `setDisplacement` to OpenCascade.GP.Trsf

## 0.1.2.2 - 2024-01-09

## 0.1.2.1 - 2024-01-09
Expand Down
14 changes: 14 additions & 0 deletions opencascade-hs/cpp/hs_BRepBndLib.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <BRepBndLib.hxx>
#include "hs_BRepBndLib.h"

void hs_BRepBndLib_add(TopoDS_Shape * shape, Bnd_Box * box, bool useTriangulation){
BRepBndLib::Add(*shape, *box, useTriangulation);
}

void hs_BRepBndLib_addOptimal(TopoDS_Shape * shape, Bnd_Box * box, bool useTriangulation, bool useShapeTolerance){
BRepBndLib::AddOptimal(*shape, *box, useTriangulation, useShapeTolerance);
}

void hs_BRepBndLib_addOBB(TopoDS_Shape *shape, Bnd_OBB * obb, bool isTriangulationUsed, bool isOptimal, bool isShapeToleranceUsed){
BRepBndLib::AddOBB(*shape, *obb, isTriangulationUsed, isOptimal, isShapeToleranceUsed);
}
20 changes: 20 additions & 0 deletions opencascade-hs/cpp/hs_BRepBndLib.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef HS_BREPBNDLIB_H
#define HS_BREPBNDLIB_H

#include "hs_types.h"

#ifdef __cplusplus
extern "C" {
#endif

void hs_BRepBndLib_add(TopoDS_Shape * shape, Bnd_Box * box, bool useTriangulation);

void hs_BRepBndLib_addOptimal(TopoDS_Shape * shape, Bnd_Box * box, bool useTriangulation, bool useShapeTolerance);

void hs_BRepBndLib_addOBB(TopoDS_Shape *shape, Bnd_OBB * obb, bool isTriangulationUsed, bool isOptimal, bool isShapeToleranceUsed);

#ifdef __cplusplus
}
#endif

#endif // HS_BREPBNDLIB_H
6 changes: 6 additions & 0 deletions opencascade-hs/cpp/hs_BRepGProp.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <BRepGProp.hxx>
#include "hs_BRepGProp.h"

void hs_BRepGProp_VolumeProperties(TopoDS_Shape *shape, GProp_GProps *props, bool onlyClosed, bool skipShared, bool useTriangulation ){
BRepGProp::VolumeProperties(*shape, *props, onlyClosed, skipShared, useTriangulation);
}
16 changes: 16 additions & 0 deletions opencascade-hs/cpp/hs_BRepGProp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef HS_BREPGPROP_H
#define HS_BREPGPROP_H

#include "hs_types.h"

#ifdef __cplusplus
extern "C" {
#endif

void hs_BRepGProp_VolumeProperties(TopoDS_Shape * shape, GProp_GProps * props, bool onlyClosed, bool skipShared, bool useTriangulation );

#ifdef __cplusplus
}
#endif

#endif // HS_BREPGPROP_H
18 changes: 18 additions & 0 deletions opencascade-hs/cpp/hs_Bnd_Box.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <Bnd_Box.hxx>
#include "hs_Bnd_Box.h"

Bnd_Box * hs_new_Bnd_Box(){
return new Bnd_Box();
}

void hs_delete_Bnd_Box(Bnd_Box * box){
delete box;
}

gp_Pnt * hs_Bnd_Box_cornerMin(Bnd_Box * box){
return new gp_Pnt(box->CornerMin());
}

gp_Pnt * hs_Bnd_Box_cornerMax(Bnd_Box * box){
return new gp_Pnt(box->CornerMax());
}
22 changes: 22 additions & 0 deletions opencascade-hs/cpp/hs_Bnd_Box.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#ifndef HS_BND_BOX_H
#define HS_BND_BOX_H

#include "hs_types.h"

#ifdef __cplusplus
extern "C" {
#endif

Bnd_Box * hs_new_Bnd_Box();

void hs_delete_Bnd_Box(Bnd_Box * box);

gp_Pnt * hs_Bnd_Box_cornerMin(Bnd_Box * box);

gp_Pnt * hs_Bnd_Box_cornerMax(Bnd_Box * box);

#ifdef __cplusplus
}
#endif

#endif // HS_BND_BOX_H
42 changes: 42 additions & 0 deletions opencascade-hs/cpp/hs_Bnd_OBB.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include <Bnd_OBB.hxx>
#include "hs_Bnd_OBB.h"

Bnd_OBB * hs_new_Bnd_OBB() {
return new Bnd_OBB();
}

void hs_delete_Bnd_OBB(Bnd_OBB * obb){
delete obb;
}

gp_XYZ * hs_Bnd_OBB_center(Bnd_OBB * obb){
return new gp_XYZ(obb->Center());
}

gp_XYZ * hs_Bnd_OBB_xDirection(Bnd_OBB * obb){
return new gp_XYZ(obb->XDirection());
}

gp_XYZ * hs_Bnd_OBB_yDirection(Bnd_OBB * obb){
return new gp_XYZ(obb->YDirection());
}

gp_XYZ * hs_Bnd_OBB_zDirection(Bnd_OBB * obb){
return new gp_XYZ(obb->ZDirection());
}

double hs_Bnd_OBB_xHSize(Bnd_OBB *obb){
return obb->XHSize();
}

double hs_Bnd_OBB_yHSize(Bnd_OBB *obb){
return obb->YHSize();
}

double hs_Bnd_OBB_zHSize(Bnd_OBB *obb){
return obb->ZHSize();
}

gp_Ax3 * hs_Bnd_OBB_position(Bnd_OBB *obb){
return new gp_Ax3(obb->Position());
}
34 changes: 34 additions & 0 deletions opencascade-hs/cpp/hs_Bnd_OBB.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#ifndef HS_BND_OBB_H
#define HS_BND_OBB_H

#include "hs_types.h"

#ifdef __cplusplus
extern "C" {
#endif

Bnd_OBB * hs_new_Bnd_OBB();

void hs_delete_Bnd_OBB(Bnd_OBB * obb);

gp_XYZ * hs_Bnd_OBB_center(Bnd_OBB * obb);

gp_XYZ * hs_Bnd_OBB_xDirection(Bnd_OBB * obb);

gp_XYZ * hs_Bnd_OBB_yDirection(Bnd_OBB * obb);

gp_XYZ * hs_Bnd_OBB_zDirection(Bnd_OBB * obb);

double hs_Bnd_OBB_xHSize(Bnd_OBB *obb);

double hs_Bnd_OBB_yHSize(Bnd_OBB *obb);

double hs_Bnd_OBB_zHSize(Bnd_OBB *obb);

gp_Ax3 * hs_Bnd_OBB_position(Bnd_OBB *obb);

#ifdef __cplusplus
}
#endif

#endif // HS_BND_OBB_H
26 changes: 26 additions & 0 deletions opencascade-hs/cpp/hs_GProp_GProps.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <GProp_GProps.hxx>
#include "hs_GProp_GProps.h"

GProp_GProps * hs_new_GProp_GProps(){
return new GProp_GProps();
}

GProp_GProps * hs_new_GProp_GProps_fromSystemLocation(gp_Pnt * pnt){
return new GProp_GProps(*pnt);
}

void hs_delete_GProp_GProps(GProp_GProps * props){
delete props;
}

double hs_GProp_GProps_mass(GProp_GProps * props){
return props->Mass();
}

gp_Pnt * hs_GProp_GProps_centreOfMass(GProp_GProps * props){
return new gp_Pnt(props->CentreOfMass());
}

double hs_GProp_GProps_momentOfInertia(GProp_GProps * props, gp_Ax1 * ax){
return props->MomentOfInertia(*ax);
}
26 changes: 26 additions & 0 deletions opencascade-hs/cpp/hs_GProp_GProps.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#ifndef HS_GPROP_GPROPS_H
#define HS_GPROP_GPROPS_H

#include "hs_types.h"

#ifdef __cplusplus
extern "C" {
#endif

GProp_GProps * hs_new_GProp_GProps();

GProp_GProps * hs_new_GProp_GProps_fromSystemLocation(gp_Pnt * pnt);

void hs_delete_GProp_GProps(GProp_GProps * props);

double hs_GProp_GProps_mass(GProp_GProps * props);

gp_Pnt * hs_GProp_GProps_centreOfMass(GProp_GProps * props);

double hs_GProp_GProps_momentOfInertia(GProp_GProps * props, gp_Ax1 * ax);

#ifdef __cplusplus
}
#endif

#endif // HS_GPROP_GPROPS
4 changes: 4 additions & 0 deletions opencascade-hs/cpp/hs_gp_Trsf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ void hs_gp_Trsf_SetScaleFactor(gp_Trsf * trsf, double s){
trsf->SetScaleFactor(s);
}

void hs_gp_Trsf_SetDisplacement(gp_Trsf * trsf, gp_Ax3 *from, gp_Ax3 * to){
trsf->SetDisplacement(*from, *to);
}

void hs_gp_Trsf_SetValues(gp_Trsf * trsf,
double a11, double a12, double a13, double a14,
double a21, double a22, double a23, double a24,
Expand Down
2 changes: 2 additions & 0 deletions opencascade-hs/cpp/hs_gp_Trsf.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ bool hs_gp_Trsf_IsNegative(gp_Trsf * trsf);

double hs_gp_Trsf_ScaleFactor(gp_Trsf * trsf);

void hs_gp_Trsf_SetDisplacement(gp_Trsf * trsf, gp_Ax3 *from, gp_Ax3 * to);

double hs_gp_Trsf_Value(gp_Trsf* trsf, int row, int col);

void hs_gp_Trsf_Invert(gp_Trsf* trsf);
Expand Down
39 changes: 39 additions & 0 deletions opencascade-hs/cpp/hs_gp_XYZ.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include <gp_XYZ.hxx>
#include "hs_gp_XYZ.h"

gp_XYZ * hs_new_gp_XYZ(){
return new gp_XYZ();
}

gp_XYZ * hs_new_gp_XYZ_fromDoubles(double x, double y, double z){
return new gp_XYZ(x, y, z);
}

void hs_delete_gp_XYZ(gp_XYZ * xyz){
delete xyz;
}

void hs_gp_XYZ_setX(gp_XYZ * xyz, double x){
xyz->SetX(x);
}

void hs_gp_XYZ_setY(gp_XYZ * xyz, double y){
xyz->SetY(y);
}

void hs_gp_XYZ_setZ(gp_XYZ * xyz, double z){
xyz->SetZ(z);
}

double hs_gp_XYZ_x(gp_XYZ * xyz){
return xyz->X();
}

double hs_gp_XYZ_y(gp_XYZ * xyz){
return xyz->Y();
}

double hs_gp_XYZ_z(gp_XYZ * xyz){
return xyz->Z();
}

33 changes: 33 additions & 0 deletions opencascade-hs/cpp/hs_gp_XYZ.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#ifndef HS_GP_XYZ_H
#define HS_GP_XYZ_H

#include "hs_types.h"

#ifdef __cplusplus
extern "C" {
#endif

gp_XYZ * hs_new_gp_XYZ();

gp_XYZ * hs_new_gp_XYZ_fromDoubles(double x, double y, double z);

void hs_delete_gp_XYZ(gp_XYZ * xyz);

void hs_gp_XYZ_setX(gp_XYZ * xyz, double x);

void hs_gp_XYZ_setY(gp_XYZ * xyz, double y);

void hs_gp_XYZ_setZ(gp_XYZ * xyz, double z);

double hs_gp_XYZ_x(gp_XYZ * xyz);

double hs_gp_XYZ_y(gp_XYZ * xyz);

double hs_gp_XYZ_z(gp_XYZ * xyz);

#ifdef __cplusplus
}
#endif

#endif // HS_GP_XYZ_H

4 changes: 4 additions & 0 deletions opencascade-hs/cpp/hs_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ typedef void gp_Vec2d;
typedef void gp_Trsf;
typedef void gp_GTrsf;
typedef void gp_Trsf2d;
typedef void gp_XYZ;
typedef void BRep_Builder;
typedef void BRepBuilderAPI_Transform;
typedef void BRepBuilderAPI_MakeWire;
Expand Down Expand Up @@ -62,6 +63,9 @@ typedef int Graphic3d_VerticalTextAlignment;
typedef void BRepOffsetAPI_MakeOffsetShape;
typedef int BRepOffset_Mode;
typedef int GeomAbs_JoinType;
typedef void GProp_GProps;
typedef void Bnd_Box;
typedef void Bnd_OBB;
#define Handle(X) void
#define ARRAY_1(X) void
#else // __cplusplus
Expand Down
Loading

0 comments on commit e83a643

Please sign in to comment.