Skip to content

Commit

Permalink
Merge pull request #10 from joe-warren/add-lofts
Browse files Browse the repository at this point in the history
Add Lofts
  • Loading branch information
joe-warren authored Aug 4, 2024
2 parents 6c6333c + 57ac0f8 commit c268fc3
Show file tree
Hide file tree
Showing 45 changed files with 613 additions and 43 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,5 @@ If you've found the project useful, or interesting, or if you've built anything
[![](images/text.png)](waterfall-cad-examples/src/TextExample.hs)

[![](images/bounding_boxes.png)](waterfall-cad-examples/src/BoundingBoxExample.hs)

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

## Unreleased

- Add `OpenCascade.BRepBuilderAPI.MakeVertex`
- Add `OpenCascade.BRepBuilderAPI.MakeWire.vertex`
- Add `OpenCascade.BRepOffsetAPI.ThruSections`
- Add `OpenCascade.BRep.Tool.pnt`
- Add `OpenCascade.Geom.Curve` methods `reversedParameter` and `reversed`
- Add `OpenCascade.ShapeExtend.WireData`
- Add `Show` instance to `OpenCascade.BRepBuilderAPI.WireError`

## 0.3.0.1

## 0.3.0.0
Expand Down
15 changes: 15 additions & 0 deletions opencascade-hs/cpp/hs_BRepBuilderAPI_MakeVertex.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <BRepBuilderAPI_MakeVertex.hxx>
#include "hs_BRepBuilderAPI_MakeVertex.h"
#include <TopoDS_Vertex.hxx>

BRepBuilderAPI_MakeVertex * hs_new_BRepBuilderAPI_MakeVertex_fromPnt(gp_Pnt* pnt){
return new BRepBuilderAPI_MakeVertex(*pnt);
}

void hs_delete_BRepBuilderAPI_MakeVertex(BRepBuilderAPI_MakeVertex* builder){
delete builder;
}

TopoDS_Vertex * hs_BRepBuilderAPI_MakeVertex_vertex(BRepBuilderAPI_MakeVertex * builder){
return new TopoDS_Vertex(builder->Vertex());
}
20 changes: 20 additions & 0 deletions opencascade-hs/cpp/hs_BRepBuilderAPI_MakeVertex.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef HS_BREPBUILDERAPI_MAKEVERTEX_H
#define HS_BREPBUILDERAPI_MAKEVERTEX_H

#include "hs_types.h"

#ifdef __cplusplus
extern "C" {
#endif

BRepBuilderAPI_MakeVertex * hs_new_BRepBuilderAPI_MakeVertex_fromPnt(gp_Pnt* pnt);

void hs_delete_BRepBuilderAPI_MakeVertex(BRepBuilderAPI_MakeVertex* builder);

TopoDS_Vertex * hs_BRepBuilderAPI_MakeVertex_vertex(BRepBuilderAPI_MakeVertex * builder);

#ifdef __cplusplus
}
#endif

#endif // HS_BREPBUILDERAPI_MAKEVERTEX_H
4 changes: 4 additions & 0 deletions opencascade-hs/cpp/hs_BRepBuilderAPI_MakeWire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ TopoDS_Wire * hs_BRepBuilderAPI_MakeWire_Wire(BRepBuilderAPI_MakeWire* builder){
return new TopoDS_Wire(builder->Wire());
}

TopoDS_Vertex * hs_BRepBuilderAPI_MakeWire_Vertex(BRepBuilderAPI_MakeWire* builder){
return new TopoDS_Vertex(builder->Vertex());
}

bool hs_BRepBuilderAPI_MakeWire_IsDone(BRepBuilderAPI_MakeWire* builder){
return builder->IsDone();
}
Expand Down
2 changes: 2 additions & 0 deletions opencascade-hs/cpp/hs_BRepBuilderAPI_MakeWire.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ void hs_BRepBuilderAPI_MakeWire_AddListOfShape(BRepBuilderAPI_MakeWire* builder,

TopoDS_Wire * hs_BRepBuilderAPI_MakeWire_Wire(BRepBuilderAPI_MakeWire* builder);

TopoDS_Vertex * hs_BRepBuilderAPI_MakeWire_Vertex(BRepBuilderAPI_MakeWire* builder);

bool hs_BRepBuilderAPI_MakeWire_IsDone(BRepBuilderAPI_MakeWire* builder);

BRepBuilderAPI_WireError hs_BRepBuilderAPI_MakeWire_Error(BRepBuilderAPI_MakeWire* builder);
Expand Down
18 changes: 18 additions & 0 deletions opencascade-hs/cpp/hs_BRepOffsetAPI_ThruSections.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <BRepOffsetAPI_ThruSections.hxx>
#include "hs_BRepOffsetAPI_ThruSections.h"

BRepOffsetAPI_ThruSections * hs_new_BRepOffsetAPI_ThruSections(bool isSolid, bool ruled, double pres3d){
return new BRepOffsetAPI_ThruSections(isSolid, ruled, pres3d);
}

void hs_delete_BRepOffsetAPI_ThruSections(BRepOffsetAPI_ThruSections* thruSections){
delete thruSections;
}

void hs_BRepOffsetAPI_ThruSections_addWire(BRepOffsetAPI_ThruSections* thruSections, TopoDS_Wire * wire){
thruSections->AddWire(*wire);
}

void hs_BRepOffsetAPI_ThruSections_addVertex(BRepOffsetAPI_ThruSections* thruSections, TopoDS_Vertex* vertex){
thruSections->AddVertex(*vertex);
}
23 changes: 23 additions & 0 deletions opencascade-hs/cpp/hs_BRepOffsetAPI_ThruSections.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

#ifndef HS_BREPOFFSETAPI_THRUSECTIONS_H
#define HS_BREPOFFSETAPI_THRUSECTIONS_H

#include "hs_types.h"

#ifdef __cplusplus
extern "C" {
#endif

BRepOffsetAPI_ThruSections * hs_new_BRepOffsetAPI_ThruSections(bool isSolid, bool ruled, double pres3d);

void hs_delete_BRepOffsetAPI_ThruSections(BRepOffsetAPI_ThruSections* thruSections);

void hs_BRepOffsetAPI_ThruSections_addWire(BRepOffsetAPI_ThruSections* thruSections, TopoDS_Wire * wire);

void hs_BRepOffsetAPI_ThruSections_addVertex(BRepOffsetAPI_ThruSections* thruSections, TopoDS_Vertex* vertex);

#ifdef __cplusplus
}
#endif

#endif // HS_BREPOFFSETAPI_THRUSECTIONS_H
4 changes: 4 additions & 0 deletions opencascade-hs/cpp/hs_BRep_Tool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ double hs_BRep_Tool_curveParamLast(TopoDS_Edge * edge){
double s, e;
BRep_Tool::Curve(*edge, s, e);
return e;
}

gp_Pnt * hs_BRep_Tool_pnt(TopoDS_Vertex * vertex){
return new gp_Pnt(BRep_Tool::Pnt(*vertex));
}

Handle(Poly_Triangulation) * hs_BRep_Tool_triangulation(TopoDS_Face * face, TopLoc_Location * loc){
Expand Down
2 changes: 2 additions & 0 deletions opencascade-hs/cpp/hs_BRep_Tool.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ double hs_BRep_Tool_curveParamFirst(TopoDS_Edge * edge);

double hs_BRep_Tool_curveParamLast(TopoDS_Edge * edge);

gp_Pnt * hs_BRep_Tool_pnt(TopoDS_Vertex * vertex);

Handle(Poly_Triangulation) * hs_BRep_Tool_triangulation(TopoDS_Face * face, TopLoc_Location * loc);

#ifdef __cplusplus
Expand Down
8 changes: 8 additions & 0 deletions opencascade-hs/cpp/hs_Geom_Curve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,11 @@ gp_Pnt * hs_Geom_Curve_value(Handle(Geom_Curve) * curve, double u){
gp_Vec * hs_Geom_Curve_dn(Handle (Geom_Curve) * curve, double u, int n){
return new gp_Vec((*curve)->DN(u, n));
}

double hs_Geom_Curve_reversedParameter(Handle (Geom_Curve) * curve, double parameter){
return (*curve)->ReversedParameter(parameter);
}

Handle (Geom_Curve) * hs_Geom_Curve_reversed(Handle (Geom_Curve) * curve){
return new opencascade::handle<Geom_Curve>((*curve)->Reversed());
}
5 changes: 5 additions & 0 deletions opencascade-hs/cpp/hs_Geom_Curve.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ void hs_delete_Handle_Geom_Curve(Handle(Geom_Curve) * handle);
gp_Pnt * hs_Geom_Curve_value(Handle(Geom_Curve) * curve, double u);

gp_Vec * hs_Geom_Curve_dn(Handle (Geom_Curve) * curve, double u, int n);

double hs_Geom_Curve_reversedParameter(Handle (Geom_Curve) * curve, double parameter);

Handle (Geom_Curve) * hs_Geom_Curve_reversed(Handle (Geom_Curve) * curve);

#ifdef __cplusplus
}
#endif
Expand Down
25 changes: 25 additions & 0 deletions opencascade-hs/cpp/hs_ShapeExtend_WireData.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <ShapeExtend_WireData.hxx>
#include "hs_ShapeExtend_WireData.h"

#include <TopoDS_Wire.hxx>

ShapeExtend_WireData * hs_new_ShapeExtend_WireData_fromWireChainedAndManifold(TopoDS_Wire* wire, bool chained, bool manifoldMode){
return new ShapeExtend_WireData(*wire, chained, manifoldMode);
}

void hs_delete_ShapeExtend_WireData(ShapeExtend_WireData * wireData){
delete wireData;
}

void hs_ShapeExtend_WireData_reverse(ShapeExtend_WireData * wireData){
wireData->Reverse();
}

TopoDS_Wire * hs_ShapeExtend_WireData_wire(ShapeExtend_WireData * wireData){
return new TopoDS_Wire(wireData->Wire());
}


TopoDS_Wire * hs_ShapeExtend_WireData_wireAPIMake(ShapeExtend_WireData * wireData){
return new TopoDS_Wire(wireData->WireAPIMake());
}
24 changes: 24 additions & 0 deletions opencascade-hs/cpp/hs_ShapeExtend_WireData.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#ifndef HS_SHAPEEXTEND_WIREDATA_H
#define HS_SHAPEEXTEND_WIREDATA_H

#include "hs_types.h"

#ifdef __cplusplus
extern "C" {
#endif

ShapeExtend_WireData * hs_new_ShapeExtend_WireData_fromWireChainedAndManifold(TopoDS_Wire* wire, bool chained, bool manifoldMode);

void hs_delete_ShapeExtend_WireData(ShapeExtend_WireData * wireData);

void hs_ShapeExtend_WireData_reverse(ShapeExtend_WireData * wireData);

TopoDS_Wire * hs_ShapeExtend_WireData_wire(ShapeExtend_WireData * wireData);

TopoDS_Wire * hs_ShapeExtend_WireData_wireAPIMake(ShapeExtend_WireData * wireData);

#ifdef __cplusplus
}
#endif

#endif // HS_SHAPEEXTEND_WIREDATA_H
2 changes: 2 additions & 0 deletions opencascade-hs/cpp/hs_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ typedef void gp_Trsf2d;
typedef void gp_XYZ;
typedef void BRep_Builder;
typedef void BRepBuilderAPI_Transform;
typedef void BRepBuilderAPI_MakeVertex;
typedef void BRepBuilderAPI_MakeWire;
typedef void BRepBuilderAPI_MakeFace;
typedef void BRepBuilderAPI_MakeSolid;
Expand Down Expand Up @@ -82,6 +83,7 @@ typedef void TDF_Label;
typedef void TDocStd_Document;
typedef void XCAFDoc_ShapeTool;
typedef void ShapeFix_Solid;
typedef void ShapeExtend_WireData;
typedef int ShapeExtend_Status;
typedef void Poly_Triangulation;
typedef void Poly_Triangle;
Expand Down
11 changes: 11 additions & 0 deletions opencascade-hs/opencascade-hs.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ extra-source-files:
cpp/hs_BRepBuilderAPI_MakePolygon.h
cpp/hs_BRepBuilderAPI_MakeShape.h
cpp/hs_BRepBuilderAPI_MakeSolid.h
cpp/hs_BRepBuilderAPI_MakeVertex.h
cpp/hs_BRepBuilderAPI_MakeWire.h
cpp/hs_BRepBuilderAPI_Sewing.h
cpp/hs_BRepBuilderAPI_Transform.h
Expand All @@ -44,6 +45,7 @@ extra-source-files:
cpp/hs_BRepMesh_IncrementalMesh.h
cpp/hs_BRepOffsetAPI_MakeOffsetShape.h
cpp/hs_BRepOffsetAPI_MakePipe.h
cpp/hs_BRepOffsetAPI_ThruSections.h
cpp/hs_BRepPrimAPI_MakeBox.h
cpp/hs_BRepPrimAPI_MakeCone.h
cpp/hs_BRepPrimAPI_MakeCylinder.h
Expand Down Expand Up @@ -83,6 +85,7 @@ extra-source-files:
cpp/hs_RWMesh_CafReader.h
cpp/hs_RWObj_CafReader.h
cpp/hs_RWObj_CafWriter.h
cpp/hs_ShapeExtend_WireData.h
cpp/hs_ShapeFix_Solid.h
cpp/hs_STEPControl_Reader.h
cpp/hs_STEPControl_Writer.h
Expand Down Expand Up @@ -134,6 +137,7 @@ library
OpenCascade.BRepBuilderAPI.MakePolygon
OpenCascade.BRepBuilderAPI.MakeShape
OpenCascade.BRepBuilderAPI.MakeSolid
OpenCascade.BRepBuilderAPI.MakeVertex
OpenCascade.BRepBuilderAPI.MakeWire
OpenCascade.BRepBuilderAPI.Sewing
OpenCascade.BRepBuilderAPI.Transform
Expand All @@ -154,6 +158,7 @@ library
OpenCascade.BRepOffsetAPI.Internal.Destructors
OpenCascade.BRepOffsetAPI.MakeOffsetShape
OpenCascade.BRepOffsetAPI.MakePipe
OpenCascade.BRepOffsetAPI.ThruSections
OpenCascade.BRepOffsetAPI.Types
OpenCascade.BRepPrimAPI
OpenCascade.BRepPrimAPI.Internal.Destructors
Expand Down Expand Up @@ -228,7 +233,10 @@ library
OpenCascade.RWObj.CafWriter
OpenCascade.RWObj.Internal.Destructors
OpenCascade.RWObj.Types
OpenCascade.ShapeExtend.Internal.Destructors
OpenCascade.ShapeExtend.Status
OpenCascade.ShapeExtend.Types
OpenCascade.ShapeExtend.WireData
OpenCascade.ShapeFix.Internal.Destructors
OpenCascade.ShapeFix.Solid
OpenCascade.ShapeFix.Types
Expand Down Expand Up @@ -310,6 +318,7 @@ library
cpp/hs_BRepBuilderAPI_MakePolygon.cpp
cpp/hs_BRepBuilderAPI_MakeShape.cpp
cpp/hs_BRepBuilderAPI_MakeSolid.cpp
cpp/hs_BRepBuilderAPI_MakeVertex.cpp
cpp/hs_BRepBuilderAPI_MakeWire.cpp
cpp/hs_BRepBuilderAPI_Sewing.cpp
cpp/hs_BRepBuilderAPI_Transform.cpp
Expand All @@ -319,6 +328,7 @@ library
cpp/hs_BRepMesh_IncrementalMesh.cpp
cpp/hs_BRepOffsetAPI_MakeOffsetShape.cpp
cpp/hs_BRepOffsetAPI_MakePipe.cpp
cpp/hs_BRepOffsetAPI_ThruSections.cpp
cpp/hs_BRepPrimAPI_MakeBox.cpp
cpp/hs_BRepPrimAPI_MakeCone.cpp
cpp/hs_BRepPrimAPI_MakeCylinder.cpp
Expand Down Expand Up @@ -358,6 +368,7 @@ library
cpp/hs_RWMesh_CafReader.cpp
cpp/hs_RWObj_CafReader.cpp
cpp/hs_RWObj_CafWriter.cpp
cpp/hs_ShapeExtend_WireData.cpp
cpp/hs_ShapeFix_Solid.cpp
cpp/hs_STEPControl_Reader.cpp
cpp/hs_STEPControl_Writer.cpp
Expand Down
8 changes: 8 additions & 0 deletions opencascade-hs/src/OpenCascade/BRep/Tool.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@ module OpenCascade.BRep.Tool
( curve
, curveParamFirst
, curveParamLast
, pnt
, triangulation
) where

import qualified OpenCascade.Geom as Geom
import qualified OpenCascade.TopoDS as TopoDS
import qualified OpenCascade.GP as GP

import qualified OpenCascade.TopLoc.Types as TopLoc
import qualified OpenCascade.Poly.Types as Poly
import OpenCascade.Poly.Internal.Destructors (deleteHandleTriangulation)
import OpenCascade.Handle (Handle)
import OpenCascade.Geom.Internal.Destructors (deleteHandleCurve)
import OpenCascade.GP.Internal.Destructors (deletePnt)
import Foreign.Ptr
import Foreign.C
import Data.Coerce
Expand All @@ -34,6 +37,11 @@ foreign import capi unsafe "hs_BRep_Tool.h hs_BRep_Tool_curveParamLast" rawCurve
curveParamLast :: Ptr TopoDS.Edge -> IO Double
curveParamLast = coerce rawCurveParamLast

foreign import capi unsafe "hs_BRep_Tool.h hs_BRep_Tool_pnt" rawPnt :: Ptr (TopoDS.Vertex) -> IO (Ptr GP.Pnt)

pnt :: Ptr TopoDS.Vertex -> Acquire (Ptr GP.Pnt)
pnt v = mkAcquire (rawPnt v) deletePnt

foreign import capi unsafe "hs_BRep_Tool.h hs_BRep_Tool_triangulation" rawTriangulation :: Ptr (TopoDS.Face) -> Ptr TopLoc.Location -> IO(Ptr (Handle Poly.Triangulation))

triangulation :: Ptr TopoDS.Face -> Ptr TopLoc.Location -> Acquire (Ptr (Handle Poly.Triangulation))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{-# LANGUAGE CApiFFI #-}
module OpenCascade.BRepBuilderAPI.Internal.Destructors
( deleteMakeWire
( deleteMakeVertex
, deleteMakeWire
, deleteMakeFace
, deleteMakeSolid
, deleteSewing
Expand All @@ -10,6 +11,7 @@ import OpenCascade.BRepBuilderAPI.Types

import Foreign.Ptr

foreign import capi unsafe "hs_BRepBuilderAPI_MakeVertex.h hs_delete_BRepBuilderAPI_MakeVertex" deleteMakeVertex :: Ptr MakeVertex -> IO ()
foreign import capi unsafe "hs_BRepBuilderAPI_MakeWire.h hs_delete_BRepBuilderAPI_MakeWire" deleteMakeWire :: Ptr MakeWire -> IO ()
foreign import capi unsafe "hs_BRepBuilderAPI_MakeFace.h hs_delete_BRepBuilderAPI_MakeFace" deleteMakeFace :: Ptr MakeFace -> IO ()
foreign import capi unsafe "hs_BRepBuilderAPI_MakeSolid.h hs_delete_BRepBuilderAPI_MakeSolid" deleteMakeSolid :: Ptr MakeSolid -> IO ()
Expand Down
26 changes: 26 additions & 0 deletions opencascade-hs/src/OpenCascade/BRepBuilderAPI/MakeVertex.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{-# LANGUAGE CApiFFI #-}
module OpenCascade.BRepBuilderAPI.MakeVertex
( MakeVertex
, fromPnt
, vertex
) where

import OpenCascade.BRepBuilderAPI.Types (MakeVertex)
import OpenCascade.BRepBuilderAPI.Internal.Destructors (deleteMakeVertex)
import qualified OpenCascade.GP as GP
import qualified OpenCascade.TopoDS as TopoDS
import qualified OpenCascade.TopoDS.Internal.Destructors as TopoDS.Destructors
import Foreign.Ptr (Ptr)
import Data.Acquire (Acquire, mkAcquire)
import OpenCascade.Inheritance (upcast)

foreign import capi unsafe "hs_BRepBuilderAPI_MakeVertex.h hs_new_BRepBuilderAPI_MakeVertex_fromPnt" rawFromPnt :: Ptr GP.Pnt -> IO (Ptr MakeVertex)

fromPnt :: Ptr GP.Pnt -> Acquire (Ptr MakeVertex)
fromPnt pnt = mkAcquire (rawFromPnt pnt) (deleteMakeVertex)


foreign import capi unsafe "hs_BRepBuilderAPI_MakeVertex.h hs_BRepBuilderAPI_MakeVertex_vertex" rawVertex :: Ptr MakeVertex -> IO (Ptr TopoDS.Vertex)

vertex :: Ptr MakeVertex -> Acquire (Ptr TopoDS.Vertex)
vertex builder = mkAcquire (rawVertex builder) (TopoDS.Destructors.deleteShape . upcast)
Loading

0 comments on commit c268fc3

Please sign in to comment.