Skip to content

Commit

Permalink
Merge pull request #14 from GenerateNU/features/tangent-vectors-geom_…
Browse files Browse the repository at this point in the history
…bspline

Features/tangent vectors geom bspline
  • Loading branch information
muneerlalji authored Feb 11, 2024
2 parents c4ad455 + 789324c commit 0b1f859
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 1 deletion.
59 changes: 59 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"files.associations": {
"__bit_reference": "cpp",
"__config": "cpp",
"__debug": "cpp",
"__errc": "cpp",
"__hash_table": "cpp",
"__locale": "cpp",
"__mutex_base": "cpp",
"__node_handle": "cpp",
"__split_buffer": "cpp",
"__threading_support": "cpp",
"__verbose_abort": "cpp",
"array": "cpp",
"atomic": "cpp",
"bitset": "cpp",
"cctype": "cpp",
"charconv": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"complex": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"exception": "cpp",
"fstream": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"ios": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"locale": "cpp",
"mutex": "cpp",
"new": "cpp",
"optional": "cpp",
"ostream": "cpp",
"ratio": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"string": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"typeinfo": "cpp",
"unordered_map": "cpp",
"variant": "cpp",
"vector": "cpp",
"algorithm": "cpp"
}
}
29 changes: 29 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: clang build active file",
"command": "/usr/bin/clang",
"args": [
"-fcolor-diagnostics",
"-fansi-escape-codes",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
1 change: 1 addition & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/*
3 changes: 2 additions & 1 deletion backend/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ include_directories(${OCE_INCLUDE_DIRS})
add_executable(cad_to_gcode src/cad_to_gcode.cpp)
add_executable(iges_to_topo src/iges_to_topo.cpp)
add_executable(shape_to_bspline src/shape_to_bspline.cpp)
add_executable(tangent_vectors_geom_bspline src/tangent_vectors_geom_bspline.cpp)
target_link_libraries(cad_to_gcode ${OpenCASCADE_LIBRARIES})
target_link_libraries(iges_to_topo ${OpenCASCADE_LIBRARIES})
target_link_libraries(shape_to_bspline ${OpenCASCADE_LIBRARIES})

target_link_libraries(tangent_vectors_geom_bspline ${OpenCASCADE_LIBRARIES})
28 changes: 28 additions & 0 deletions backend/src/tangent_vectors_geom_bspline.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

#include <Geom_Curve.hxx>
#include <Geom_BSplineCurve.hxx>
#include <GeomLProp_SLProps.hxx>
#include <gp_Pnt.hxx>
#include <gp_Vec.hxx>
#include <vector>
#include <iostream>

// outputs a list of vectors containing the tangents to the knots on the curve
std::vector<gp_Vec> calculate_tangent_vectors(const Handle(Geom_BSplineCurve)& bsplineCurve) {
std::vector<gp_Vec> tangentVectors;
gp_Vec tangentVector;
gp_Pnt point;
int knots = bsplineCurve->NbKnots();
Standard_Real step_size = 1 / knots;
Standard_Real first_parameter = bsplineCurve->FirstParameter();
Standard_Real last_parameter = bsplineCurve->LastParameter();
for (int u = first_parameter; u < last_parameter; u += step_size) {
bsplineCurve->D1(u, point, tangentVector);
tangentVectors.push_back(tangentVector);
}
return tangentVectors;
}

int main(int argc, char* argv[]) {
return 1;
}

0 comments on commit 0b1f859

Please sign in to comment.