← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-dev/yade/trunk] Rev 2526: - Add python wrapping for python use of TesselationWrapper (+ a few fixes and formating)

 

------------------------------------------------------------
revno: 2526
committer: Bruno Chareyre <bruno.chareyre@xxxxxxxxxxx>
branch nick: yade
timestamp: Tue 2010-11-02 17:23:44 +0100
message:
  - Add python wrapping for python use of TesselationWrapper (+ a few fixes and formating) 
modified:
  lib/triangulation/Tesselation.cpp
  lib/triangulation/Tesselation.h
  pkg/dem/TesselationWrapper.cpp
  pkg/dem/TesselationWrapper.hpp


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

Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-dev/yade/trunk/+edit-subscription
=== modified file 'lib/triangulation/Tesselation.cpp'
--- lib/triangulation/Tesselation.cpp	2010-08-15 04:19:57 +0000
+++ lib/triangulation/Tesselation.cpp	2010-11-02 16:23:44 +0000
@@ -133,20 +133,11 @@
 
 Point Tesselation::Dual ( const Cell_handle &cell )
 {
-	//Sphere S0 = cell->vertex(0)->point();
-	//Plan P12 = PlanRadical(S0 , cell->vertex(1)->point());
-	//Plan P13 = PlanRadical(S0 , cell->vertex(2)->point());
-	//Plan P14 = PlanRadical(S0 , cell->vertex(3)->point());
-	//std::cout << std::endl << "Plans : " << std::endl << P12 << std::endl << P13 << std::endl << P14 << std::endl << std::endl;
-	//cell->info() = Intersect(P12, P13, P14);
-	//std::cout << "voro calcule : " << cell->info() << std::endl;
 	return cell->info();
 }
 
 void Tesselation::Compute ()
 {
-
-//  std::cout << "Tesselation::Compute ()" << std::endl;
 	redirect();
 	Finite_cells_iterator cell_end = Tri->finite_cells_end();
 	for ( Finite_cells_iterator cell = Tri->finite_cells_begin(); cell != cell_end; cell++ )
@@ -157,10 +148,6 @@
 		const Sphere& S2 = cell->vertex ( 2 )->point();
 		const Sphere& S3 = cell->vertex ( 3 )->point();
 		Real x,y,z;
-//   Plan P12 = PlanRadical(S0 , cell->vertex(1)->point());
-//   Plan P13 = PlanRadical(S0 , cell->vertex(2)->point());
-//   Plan P14 = PlanRadical(S0 , cell->vertex(3)->point());
-//   cell->info() = Intersect(P12, P13, P14);
 		CGAL::weighted_circumcenterC3 (
 			S0.point().x(), S0.point().y(), S0.point().z(), S0.weight(),
 			S1.point().x(), S1.point().y(), S1.point().z(), S1.weight(),
@@ -168,13 +155,7 @@
 			S3.point().x(), S3.point().y(), S3.point().z(), S3.weight(),
 			x, y, z );
 		cell->info() =Point ( x,y,z );
-		//cout << "voronoi cell : " <<  cell->vertex(0)->info().id() << " "
-		//  <<  cell->vertex(1)->info().id() << " "
-		//  <<  cell->vertex(2)->info().id() << " "
-		//  <<  cell->vertex(3)->info().id() << "(center : " << (Point) cell->info() << ")" << endl;
 	}
-
-	
 	computed = true;
 }
 
@@ -446,7 +427,6 @@
 	{
 		AssignPartialVolume ( ed_it );
 	}
-
 	//Delete volume for spheres on the boarders of the packing
 	//FIXME: find a way to compute a volume correctly for spheres of the boarders.
 

=== modified file 'lib/triangulation/Tesselation.h'
--- lib/triangulation/Tesselation.h	2010-08-15 04:19:57 +0000
+++ lib/triangulation/Tesselation.h	2010-11-02 16:23:44 +0000
@@ -70,7 +70,7 @@
 	static Plan	Dual	(Vertex_handle S1, Vertex_handle S2);
 	static Segment  Dual	(Finite_facets_iterator &facet);	//G�n�re le segment dual d'une facette finie
 	static Real	Volume	(Finite_cells_iterator cell);
-	inline void 		AssignPartialVolume	(Finite_edges_iterator& ed_it);
+	inline void 	AssignPartialVolume	(Finite_edges_iterator& ed_it);
 	void		ResetVCellVolumes	(void);
 	void		ComputeVolumes		(void);//Compute volume each voronoi cell
 	void		ComputePorosity		(void);//Compute volume and porosity of each voronoi cell

=== modified file 'pkg/dem/TesselationWrapper.cpp'
--- pkg/dem/TesselationWrapper.cpp	2010-10-13 16:23:08 +0000
+++ pkg/dem/TesselationWrapper.cpp	2010-11-02 16:23:44 +0000
@@ -154,11 +154,10 @@
 //  facet_it = Tes->Triangulation().finite_edges_end ();
 }
 
-bool TesselationWrapper::insertSceneSpheres(const Scene* scene)
+void TesselationWrapper::insertSceneSpheres(const Scene* scene)
 {
 	const shared_ptr<BodyContainer>& bodies = scene->bodies;
 	build_triangulation_with_ids(bodies, *this);
-	return 1;
 }
 
 double TesselationWrapper::Volume(unsigned int id) {return Tes->Volume(id);}

=== modified file 'pkg/dem/TesselationWrapper.hpp'
--- pkg/dem/TesselationWrapper.hpp	2010-10-13 16:23:08 +0000
+++ pkg/dem/TesselationWrapper.hpp	2010-11-02 16:23:44 +0000
@@ -20,11 +20,16 @@
  * \brief Handle the triangulation of spheres in a scene, build tesselation on request, and give access to computed quantities : currently volume and porosity of each Voronoï sphere.
  * More accessors in course of implementation. Feel free to suggest new ones.
  *
- * Usage :
- * TW.setState(0)
- * O.run(1000); O.wait()
- * TW.setState(1)
- * array = TW.getVolPoroDef(True) //syntax here?
+ * Example usage script :
+ *
+ *tt=TriaxialTest()
+ *tt.generate("test.xml")
+ *O.load("test.xml")
+ *O.run(100) //for unknown reasons, this procedure crashes at iteration 0
+ *TW=TesselationWrapper()
+ *TW.triangulate(O._sceneObj()) //compute regular Delaunay triangulation, don't construct tesselation
+ *TW.computeVolumes() //will silently tesselate the packing, then assign volumes to each Voronoi cell
+ *TW.volume(10) //get volume associated to sphere of id 10
  * 
  */
 
@@ -44,7 +49,7 @@
     	/// Insert a sphere, "id" will be used by some getters to retrieve spheres
     	bool insert(double x, double y, double z, double rad, unsigned int id);
 	/// A faster version of insert, inserting all spheres in scene
-	bool insertSceneSpheres(const Scene* scene);
+	void insertSceneSpheres(const Scene* scene);
 	/// Move one sphere to the new position (x,y,z) and maintain triangulation (invalidates the tesselation)
 	bool move (double x, double y, double z, double rad, unsigned int id);
 	
@@ -98,7 +103,10 @@
 	facet_it = Tes->Triangulation().finite_edges_begin();
 	inf=1e10;
 	,/*py*/
+	.def("triangulate",&TesselationWrapper::insertSceneSpheres,"triangulate spheres of the packing")
  	.def("setState",&TesselationWrapper::setState,(python::arg("state")=0),"Make the current state the initial (0) or final (1) configuration for the definition of displacement increments, use only state=0 if you just want to get only volmumes and porosity.")
+ 	.def("volume",&TesselationWrapper::Volume,(python::arg("id")=0),"Returns the volume of Voronoi's cell of a sphere.")
+ 	.def("computeVolumes",&TesselationWrapper::ComputeVolumes,"Compute volumes of all Voronoi's cells.")
 	.def("getVolPoroDef",&TesselationWrapper::getVolPoroDef,(python::arg("deformation")=false),"Return a table with per-sphere computed quantities. Include deformations on the increment defined by states 0 and 1 if deformation=True (make sure to define states 0 and 1 consistently).")
 	);	
 	DECLARE_LOGGER;