diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 81d816e..73f806d 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,6 +1,7 @@
# -*- mode: cmake; -*-
# vi: set ft=cmake:
+
#
# src/CMakeLists.txt
# AVO2 Library
@@ -31,9 +32,11 @@
# Chapel Hill, N.C. 27599-3175
# United States of America
#
-#
+# https://gamma.cs.unc.edu/AVO/
#
+find_package(pybind11 REQUIRED)
+
add_library(${AVO_LIBRARY})
include(GenerateExportHeader)
@@ -53,7 +56,7 @@ target_sources(${AVO_LIBRARY}
Line.h
Simulator.h
Vector2.h
- PRIVATE
+ PRIVATE
Agent.cc
Agent.h
Export.cc
@@ -83,6 +86,13 @@ if(ENABLE_OPENMP AND OpenMP_FOUND)
target_link_libraries(${AVO_LIBRARY} PRIVATE OpenMP::OpenMP_CXX)
endif()
+# Python 바인딩 모듈 추가
+pybind11_add_module(avo2
+ python_bindings.cpp
+)
+
+target_link_libraries(avo2 PRIVATE ${AVO_LIBRARY})
+
export(TARGETS ${AVO_LIBRARY} NAMESPACE ${PROJECT_NAME}::
FILE "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake")
diff --git a/src/python_bindings.cpp b/src/python_bindings.cpp
new file mode 100644
index 0000000..a5283e4
--- /dev/null
+++ b/src/python_bindings.cpp
@@ -0,0 +1,49 @@
+#include
+#include
+
+#include "Vector2.h"
+#include "Simulator.h"
+
+namespace py = pybind11;
+
+PYBIND11_MODULE(avo2, m) {
+ m.doc() = "Python bindings for AVO2 library";
+
+ // Vector2 클래스 바인딩
+ py::class_(m, "Vector2")
+ .def(py::init<>()) // 기본 생성자
+ .def(py::init()) // (float x, float y) 생성자
+ .def_property("x", &AVO::Vector2::getX, &AVO::Vector2::setX)
+ .def_property("y", &AVO::Vector2::getY, &AVO::Vector2::setY)
+ // 추가로 연산자도 바인딩 가능 (필요 시)
+
+ ;
+
+ // Simulator 클래스 바인딩
+ py::class_(m, "Simulator")
+ .def(py::init<>())
+ // 오버로드된 addAgent 함수 각각 바인딩
+ .def("addAgent",
+ (std::size_t (AVO::Simulator::*)(const AVO::Vector2 &)) &AVO::Simulator::addAgent,
+ py::arg("position"))
+ .def("addAgent",
+ (std::size_t (AVO::Simulator::*)(const AVO::Vector2 &, float, std::size_t, float, float, float, float, float))
+ &AVO::Simulator::addAgent,
+ py::arg("position"), py::arg("neighborDist"), py::arg("maxNeighbors"),
+ py::arg("timeHorizon"), py::arg("radius"), py::arg("maxSpeed"),
+ py::arg("maxAccel"), py::arg("accelInterval"))
+ .def("addAgent",
+ (std::size_t (AVO::Simulator::*)(const AVO::Vector2 &, float, std::size_t, float, float, float, float, float, const AVO::Vector2 &))
+ &AVO::Simulator::addAgent,
+ py::arg("position"), py::arg("neighborDist"), py::arg("maxNeighbors"),
+ py::arg("timeHorizon"), py::arg("radius"), py::arg("maxSpeed"),
+ py::arg("maxAccel"), py::arg("accelInterval"), py::arg("velocity"))
+ // 주요 메서드 바인딩
+ .def("setTimeStep", &AVO::Simulator::setTimeStep)
+ .def("getTimeStep", &AVO::Simulator::getTimeStep)
+ .def("doStep", &AVO::Simulator::doStep)
+ .def("getAgentPosition", &AVO::Simulator::getAgentPosition)
+ .def("setAgentPrefVelocity", &AVO::Simulator::setAgentPrefVelocity)
+
+ ;
+}