From d6f69073e07b213a22dcf75afe4b877569e94b40 Mon Sep 17 00:00:00 2001 From: Angelos Mantzaflaris Date: Thu, 25 Jul 2024 12:28:29 +0200 Subject: [PATCH] add slice --- examples/geometry_cexample.c | 18 ++++++++++++++++++ src/gsCGeometry.cpp | 14 ++++++++++++-- src/gsCGeometry.h | 2 ++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/examples/geometry_cexample.c b/examples/geometry_cexample.c index b78b6b7..34cbbe7 100644 --- a/examples/geometry_cexample.c +++ b/examples/geometry_cexample.c @@ -91,6 +91,24 @@ int main(int argc, char* argv[]) if (irow==2) { printf("\n"); } } + + gsCMatrix * tMat = gsMatrix_create(); + gsCVector * tVec = gsVector_create(); + gsCGeometryTransform * tr = gsGeometryTransform_create(G, tMat, tVec); + destroy(tr); + destroy(tMat); + destroy(tVec); + + gsCGeometry * isoparam = gsTensorBSpline2_slice(G, 0, 0.5); + print(isoparam); + destroy(isoparam); + + + // tb.slice(dir, param, result); + //equidistant sampling. arc length curve (+surface..) + // + + destroy(uvm); destroy(out_d); destroy(G); diff --git a/src/gsCGeometry.cpp b/src/gsCGeometry.cpp index 664bb85..5737e86 100644 --- a/src/gsCGeometry.cpp +++ b/src/gsCGeometry.cpp @@ -25,7 +25,7 @@ GISMO_EXPORT gsCGeometry* gsTensorBSpline2_create(gsCBasis* b, gsCMatrix * coefs auto * m = RICAST_M(coefs); return RICAST_CG(new gismo::gsTensorBSpline<2,double>(*basis_ptr,*m)); } - + GISMO_EXPORT gsCGeometry* gsTensorBSpline3_create(gsCBasis* b, gsCMatrix * coefs) { gismo::gsTensorBSplineBasis<3,double>* basis_ptr = reinterpret_cast< gismo::gsTensorBSplineBasis<3,double>* >(b); @@ -96,6 +96,16 @@ GISMO_EXPORT gsCGeometry* gsHBSpline4_create(gsCBasis* b, gsCMatrix * coefs) return RICAST_CG(new gismo::gsHBSpline<4,double>(*basis_ptr,*m)); } +GISMO_EXPORT gsCGeometry* gsTensorBSpline2_slice(gsCGeometry * g, int direction, double parameter) +{ + auto * g_ptr = reinterpret_cast< gismo::gsTensorBSpline<2,double>* >(g); + typedef typename gsTensorBSpline<2,double>::BoundaryGeometryType GeometryBdr; + GeometryBdr * bdr = new GeometryBdr(); + g_ptr->slice(direction, parameter, *bdr); + return RICAST_CG(bdr); +} + + GISMO_EXPORT gsCBasis* gsGeometry_basis(gsCGeometry * g) { return RICAST_CB(&RICAST_G(g)->basis()); } @@ -163,4 +173,4 @@ GISMO_EXPORT double gsGeometry_closestPointTo(gsCGeometry * fs, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/src/gsCGeometry.h b/src/gsCGeometry.h index faa5b31..f02866a 100644 --- a/src/gsCGeometry.h +++ b/src/gsCGeometry.h @@ -23,6 +23,8 @@ extern "C" GISMO_EXPORT gsCGeometry* gsHBSpline3_create(gsCBasis* b, gsCMatrix * coef); GISMO_EXPORT gsCGeometry* gsHBSpline4_create(gsCBasis* b, gsCMatrix * coef); + GISMO_EXPORT gsCGeometry* gsTensorBSpline2_slice(gsCGeometry * g, int direction, double parameter); + GISMO_EXPORT gsCBasis* gsGeometry_basis(gsCGeometry * g); GISMO_EXPORT void gsGeometry_coefs_into(gsCGeometry * g, gsCMatrix * coef);