Эх сурвалжийг харах

Finalized tutorial 704

Former-commit-id: a507397d12fbfec8bbbe9d3ee97a94bd347b84dd
Sebastian Koch 9 жил өмнө
parent
commit
b523d56718

+ 2 - 0
python/py_vector.cpp

@@ -173,6 +173,7 @@ py::class_<Type> bind_eigen_2(py::module &m, const char *name,
         .def("cwiseQuotient", [](const Type &m1, const Type &m2) -> Type { return m1.cwiseQuotient(m2); })
 
         /* Row and column-wise operations */
+        .def("rowwiseSet", [](Type &m, const Type &m2) {return Type(m.rowwise() = Eigen::Matrix<Scalar, 1, Eigen::Dynamic>(m2));} )
         .def("rowwiseSum", [](const Type &m) {return Type(m.rowwise().sum());} )
         .def("rowwiseProd", [](const Type &m) {return Type(m.rowwise().prod());} )
         .def("rowwiseMean", [](const Type &m) {return Type(m.rowwise().mean());} )
@@ -181,6 +182,7 @@ py::class_<Type> bind_eigen_2(py::module &m, const char *name,
         .def("rowwiseMinCoeff", [](const Type &m) {return Type(m.rowwise().minCoeff());} )
         .def("rowwiseMaxCoeff", [](const Type &m) {return Type(m.rowwise().maxCoeff());} )
 
+        .def("colwiseSet", [](Type &m, const Type &m2) {return Type(m.colwise() = Eigen::Matrix<Scalar, Eigen::Dynamic, 1>(m2));} )
         .def("colwiseSum", [](const Type &m) {return Type(m.colwise().sum());} )
         .def("colwiseProd", [](const Type &m) {return Type(m.colwise().prod());} )
         .def("colwiseMean", [](const Type &m) {return Type(m.colwise().mean());} )

+ 5 - 3
python/tutorial/704_SignedDistance.py

@@ -32,11 +32,13 @@ viewer = igl.viewer.Viewer()
 
 def append_mesh(C_vis, F_vis, V_vis, V, F, color):
     F_vis.conservativeResize(F_vis.rows() + F.rows(), 3)
-    # F_vis.setBottomRows(F.rows(), F + V_vis.rows())
+    F_vis.setBottomRows(F.rows(), F + V_vis.rows())
     V_vis.conservativeResize(V_vis.rows() + V.rows(), 3)
-    # V_vis.setBottomRows(V.rows(), V)
+    V_vis.setBottomRows(V.rows(), V)
     C_vis.conservativeResize(C_vis.rows() + V.rows(), 3)
-    # C_vis.setBottomRows(V.rows(), color)
+    colorM = igl.eigen.MatrixXd(V.rows(), C_vis.cols())
+    colorM.rowwiseSet(color)
+    C_vis.setBottomRows(V.rows(), colorM)
 
 
 def update_visualization(viewer):