← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-pkg/yade/git-trunk] Rev 3487: added Polyhedra::GetSurfaces function

 

------------------------------------------------------------
revno: 3487
committer: Jan Stransky <jan.stransky@xxxxxxxxxxx>
timestamp: Fri 2014-10-17 17:57:30 +0200
message:
  added Polyhedra::GetSurfaces function
modified:
  pkg/dem/Polyhedra.cpp
  pkg/dem/Polyhedra.hpp
  py/wrapper/customConverters.cpp


--
lp:yade
https://code.launchpad.net/~yade-pkg/yade/git-trunk

Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-pkg/yade/git-trunk/+edit-subscription
=== modified file 'pkg/dem/Polyhedra.cpp'
--- pkg/dem/Polyhedra.cpp	2014-10-15 06:44:01 +0000
+++ pkg/dem/Polyhedra.cpp	2014-10-17 15:57:30 +0000
@@ -220,6 +220,20 @@
 	}
 }
 
+//**************************************************************************
+/* Get polyhdral surfaces */
+vector<vector<int>> Polyhedra::GetSurfaces() const {
+	vector<vector<int>> ret(P.size_of_facets());
+	int i=0;
+	for (Polyhedron::Facet_const_iterator f = P.facets_begin(); f != P.facets_end(); f++, i++){
+		Polyhedron::Halfedge_around_facet_const_circulator h=f->facet_begin();
+		do {
+			ret[i].push_back(std::distance(P.vertices_begin(), h->vertex()));
+		} while (++h != f->facet_begin());
+	}
+	return ret;
+}
+
 
 //****************************************************************************************
 /* Destructor */

=== modified file 'pkg/dem/Polyhedra.hpp'
--- pkg/dem/Polyhedra.hpp	2014-10-15 06:44:01 +0000
+++ pkg/dem/Polyhedra.hpp	2014-10-17 15:57:30 +0000
@@ -54,6 +54,7 @@
 		Vector3r GetCentroid(){Initialize(); return centroid;}
 		Vector3r GetInertia(){Initialize(); return inertia;}
 		vector<int> GetSurfaceTriangulation(){Initialize(); return faceTri;}
+		vector<vector<int>> GetSurfaces() const;
 		void Initialize();		
 		bool IsInitialized(){return init;}
 		std::vector<Vector3r> GetOriginalVertices();
@@ -93,6 +94,7 @@
 			.def("GetOri",&Polyhedra::GetOri,"return polyhedra's orientation")
 			.def("GetCentroid",&Polyhedra::GetCentroid,"return polyhedra's centroid")
 			.def("GetSurfaceTriangulation",&Polyhedra::GetSurfaceTriangulation,"triangulation of facets (for plotting)")
+			.def("GetSurfaces",&Polyhedra::GetSurfaces,"get indices of surfaces' vertices (for postprocessing)")
 		);		
 		REGISTER_CLASS_INDEX(Polyhedra,Shape);
 };

=== modified file 'py/wrapper/customConverters.cpp'
--- py/wrapper/customConverters.cpp	2014-10-15 06:44:01 +0000
+++ py/wrapper/customConverters.cpp	2014-10-17 15:57:30 +0000
@@ -168,6 +168,7 @@
 	// register from-python converter and to-python converter
 
 	boost::python::to_python_converter<std::vector<std::vector<std::string> >,custom_vvector_to_list<std::string> >();
+	boost::python::to_python_converter<std::vector<std::vector<int> >,custom_vvector_to_list<int> >();
 	//boost::python::to_python_converter<std::list<shared_ptr<Functor> >, custom_list_to_list<shared_ptr<Functor> > >();
 	//boost::python::to_python_converter<std::list<shared_ptr<Functor> >, custom_list_to_list<shared_ptr<Functor> > >();