yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #12557
[Branch ~yade-pkg/yade/git-trunk] Rev 3804: vtkExporter: increase number of leading zeros to 8
------------------------------------------------------------
revno: 3804
committer: Anton Gladky <gladky.anton@xxxxxxxxx>
timestamp: Tue 2016-03-08 10:18:20 +0100
message:
vtkExporter: increase number of leading zeros to 8
Minor formatting fixes
modified:
pkg/dem/Polyhedra.cpp
pkg/dem/Polyhedra.hpp
pkg/dem/Polyhedra_Ig2.cpp
pkg/dem/Polyhedra_Ig2.hpp
py/export.py
--
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-22 10:13:18 +0000
+++ pkg/dem/Polyhedra.cpp 2016-03-08 09:18:20 +0000
@@ -17,7 +17,7 @@
/* some code in cpp (this file): */
#ifdef YADE_OPENGL
(Gl1_Polyhedra) (Gl1_PolyhedraGeom) (Gl1_PolyhedraPhys)
- #endif
+ #endif
);
//*********************************************************************************
@@ -56,7 +56,7 @@
v.clear();
for (Polyhedron::Vertex_iterator vIter = P.vertices_begin(); vIter != P.vertices_end(); ++vIter, i++){
v.push_back(Vector3r(vIter->point().x(),vIter->point().y(),vIter->point().z()));
- }
+ }
//list surface triangles for plotting
faceTri.clear();
@@ -82,7 +82,7 @@
seed = rand();
Initialize();
}
- Vector3r translation((-1)*centroid);
+ Vector3r translation((-1)*centroid);
//set centroid to be [0,0,0]
for(int i=0;i<N;i++) {
@@ -93,10 +93,10 @@
Vector3r origin(0,0,0);
//move and rotate also the CGAL structure Polyhedron
- Transformation t_trans(1.,0.,0.,translation[0],0.,1.,0.,translation[1],0.,0.,1.,translation[2],1.);
- std::transform( P.points_begin(), P.points_end(), P.points_begin(), t_trans);
+ Transformation t_trans(1.,0.,0.,translation[0],0.,1.,0.,translation[1],0.,0.,1.,translation[2],1.);
+ std::transform( P.points_begin(), P.points_end(), P.points_begin(), t_trans);
- //compute inertia
+ //compute inertia
Real vtet;
Vector3r ctet;
Matrix3r Itet1, Itet2;
@@ -111,7 +111,7 @@
-ctet[0]*ctet[1], ctet[0]*ctet[0]+ctet[2]*ctet[2], -ctet[2]*ctet[1],
-ctet[0]*ctet[2], -ctet[2]*ctet[1], ctet[1]*ctet[1]+ctet[0]*ctet[0];
inertia_tensor = inertia_tensor + Itet1 + Itet2*vtet;
- }
+ }
if(std::abs(inertia_tensor(0,1))+std::abs(inertia_tensor(0,2))+std::abs(inertia_tensor(1,2)) < 1E-13){
// no need to rotate, inertia already diagonal
@@ -142,9 +142,9 @@
Vector3r third = (I_rot.col(0)).cross(I_rot.col(1));
I_rot(0,2) = third[0];
I_rot(1,2) = third[1];
- I_rot(2,2) = third[2];
-
-
+ I_rot(2,2) = third[2];
+
+
inertia = Vector3r(I_new(0,0),I_new(1,1),I_new(2,2));
orientation = Quaternionr(I_rot);
//rotate the voronoi cell so that x - is maximal inertia axis and z - is minimal inertia axis
@@ -152,7 +152,7 @@
for(int i=0; i< (int) v.size();i++) {
v[i] = orientation.conjugate()*v[i];
}
-
+
//rotate also the CGAL structure Polyhedron
Matrix3r rot_mat = (orientation.conjugate()).toRotationMatrix();
Transformation t_rot(rot_mat(0,0),rot_mat(0,1),rot_mat(0,2),rot_mat(1,0),rot_mat(1,1),rot_mat(1,2),rot_mat(2,0),rot_mat(2,1),rot_mat(2,2),1.);
@@ -167,12 +167,12 @@
/* Generator of randomly shaped polyhedron based on Voronoi tessellation*/
void Polyhedra::GenerateRandomGeometry(){
- srand(seed);
+ srand(seed);
vector<CGALpoint> nuclei;
nuclei.push_back(CGALpoint(5.,5.,5.));
CGALpoint trial;
- int iter = 0;
+ unsigned int iter = 0;
bool isOK;
//fill box 5x5x5 with randomly located nuclei with restricted minimal mutual distance 0.75 which gives approximate mean mutual distance 1;
Real dist_min2 = 0.75*0.75;
@@ -184,32 +184,29 @@
isOK = pow(nuclei[i].x()-trial.x(),2)+pow(nuclei[i].y()-trial.y(),2)+pow(nuclei[i].z()-trial.z(),2) > dist_min2;
if (!isOK) break;
}
-
if(isOK){
iter = 0;
nuclei.push_back(trial);
- }
- }
-
-
- //perform Voronoi tessellation
- nuclei.erase(nuclei.begin());
+ }
+ }
+
+ //perform Voronoi tessellation
+ nuclei.erase(nuclei.begin());
Triangulation dt(nuclei.begin(), nuclei.end());
Triangulation::Vertex_handle zero_point = dt.insert(CGALpoint(5.,5.,5.));
v.clear();
- std::vector<Triangulation::Cell_handle> ch_cells;
- dt.incident_cells(zero_point,std::back_inserter(ch_cells));
- for(std::vector<Triangulation::Cell_handle>::iterator ci = ch_cells.begin(); ci !=ch_cells.end(); ++ci){
- v.push_back(FromCGALPoint(dt.dual(*ci))-Vector3r(5.,5.,5.));
+ std::vector<Triangulation::Cell_handle> ch_cells;
+ dt.incident_cells(zero_point,std::back_inserter(ch_cells));
+ for(auto ci = ch_cells.begin(); ci !=ch_cells.end(); ++ci){
+ v.push_back(FromCGALPoint(dt.dual(*ci))-Vector3r(5.,5.,5.));
}
-
//resize and rotate the voronoi cell
Quaternionr Rot(Real(rand())/RAND_MAX,Real(rand())/RAND_MAX,Real(rand())/RAND_MAX,Real(rand())/RAND_MAX);
Rot.normalize();
for(int i=0; i< (int) v.size();i++) {
v[i] = Rot*(Vector3r(v[i][0]*size[0],v[i][1]*size[1],v[i][2]*size[2]));
- }
+ }
//to avoid patological cases (that should not be present, but CGAL works somehow unpredicable)
if (v.size() < 8) {
=== modified file 'pkg/dem/Polyhedra.hpp'
--- pkg/dem/Polyhedra.hpp 2015-06-06 12:45:20 +0000
+++ pkg/dem/Polyhedra.hpp 2016-03-08 09:18:20 +0000
@@ -104,7 +104,7 @@
.def("GetSurfaceTriangulation",&Polyhedra::GetSurfaceTriangulation,"triangulation of facets (for plotting)")
.def("GetSurfaces",&Polyhedra::GetSurfaces,"get indices of surfaces' vertices (for postprocessing)")
.def("setVertices",&Polyhedra::setVertices,"set vertices and update receiver")
- );
+ );
REGISTER_CLASS_INDEX(Polyhedra,Shape);
};
REGISTER_SERIALIZABLE(Polyhedra);
=== modified file 'pkg/dem/Polyhedra_Ig2.cpp'
--- pkg/dem/Polyhedra_Ig2.cpp 2016-03-07 08:38:44 +0000
+++ pkg/dem/Polyhedra_Ig2.cpp 2016-03-08 09:18:20 +0000
@@ -396,58 +396,4 @@
return true;
}
-/*
-bool Ig2_Sphere_Polyhedra_PolyhedraGeom::go(const shared_ptr<Shape>& shape1,const shared_ptr<Shape>& shape2,const State& state1,const State& state2, const Vector3r& shift2, const bool& force, const shared_ptr<Interaction>& interaction){
-
- const Se3r& se31=state1.se3;
- const Se3r& se32=state2.se3;
- Polyhedra* B = static_cast<Polyhedra*>(shape2.get());
- const Real& r=shape1->cast<Sphere>().radius;
-
- //cout << "Sphere x Polyhedra" << endl;
-
- bool isNew = !interaction->geom;
-
- //move and rotate 1st the CGAL structure Polyhedron
- Matrix3r rot_mat = (se32.orientation).toRotationMatrix();
- Vector3r trans_vec = se32.position;
- Transformation t_rot_trans(rot_mat(0,0),rot_mat(0,1),rot_mat(0,2), trans_vec[0],rot_mat(1,0),rot_mat(1,1),rot_mat(1,2),trans_vec[1],rot_mat(2,0),rot_mat(2,1),rot_mat(2,2),trans_vec[2],1.);
- Polyhedron PB = B->GetPolyhedron();
- std::transform( PB.points_begin(), PB.points_end(), PB.points_begin(), t_rot_trans);
- std::transform( PB.facets_begin(), PB.facets_end(), PB.planes_begin(),Plane_equation());
-
- shared_ptr<PolyhedraGeom> bang;
- if (isNew) {
- // new interaction
- bang=shared_ptr<PolyhedraGeom>(new PolyhedraGeom());
- bang->isShearNew = true;
- interaction->geom = bang;
- }else{
- // use data from old interaction
- bang=YADE_PTR_CAST<PolyhedraGeom>(interaction->geom);
- }
-
- //volume and centroid of intersection
- Real volume, area;
- CGALvector normalCGAL;
- CGALpoint centroidCGAL=ToCGALPoint(se32.position);
- Sphere_Polyhedron_intersection(PB, r, ToCGALPoint(se31.position), centroidCGAL, volume, normalCGAL, area);
- if(isnan(volume) || volume<=1E-25 || volume > B->GetVolume()) {bang->equivalentPenetrationDepth=0; return true;}
- Vector3r centroid = FromCGALPoint(centroidCGAL);
- Vector3r normal = FromCGALVector(normalCGAL);
-
-
-
- // store calculated stuff in bang; some is redundant
- bang->equivalentCrossSection=area;
- bang->contactPoint=centroid;
- bang->penetrationVolume=volume;
- bang->equivalentPenetrationDepth=volume/area;
- bang->precompute(state1,state2,scene,interaction,normal,bang->isShearNew,shift2);
- bang->normal=normal;
-
- return true;
-}
-*/
-
#endif // YADE_CGAL
=== modified file 'pkg/dem/Polyhedra_Ig2.hpp'
--- pkg/dem/Polyhedra_Ig2.hpp 2014-10-22 10:13:18 +0000
+++ pkg/dem/Polyhedra_Ig2.hpp 2016-03-08 09:18:20 +0000
@@ -72,20 +72,4 @@
REGISTER_SERIALIZABLE(Ig2_Sphere_Polyhedra_ScGeom);
//***************************************************************************
-/*! Create Polyhedra (collision geometry) from colliding Sphere & Polyhedra. */
-/*
-class Ig2_Sphere_Polyhedra_PolyhedraGeom: public IGeomFunctor
-{
- public:
- virtual ~Ig2_Sphere_Polyhedra_PolyhedraGeom(){};
- virtual bool go(const shared_ptr<Shape>& shape1, const shared_ptr<Shape>& shape2, const State& state1, const State& state2, const Vector3r& shift2, const bool& force, const shared_ptr<Interaction>& c);
- FUNCTOR2D(Sphere,Polyhedra);
- DEFINE_FUNCTOR_ORDER_2D(Sphere,Polyhedra);
- YADE_CLASS_BASE_DOC(Ig2_Sphere_Polyhedra_PolyhedraGeom,IGeomFunctor,"Create/update geometry of collision between Sphere and Polyhedra");
- DECLARE_LOGGER;
- private:
-};
-REGISTER_SERIALIZABLE(Ig2_Sphere_Polyhedra_PolyhedraGeom);
-*/
-
#endif // YADE_CGAL
=== modified file 'py/export.py'
--- py/export.py 2014-12-09 23:14:45 +0000
+++ py/export.py 2016-03-08 09:18:20 +0000
@@ -326,7 +326,7 @@
piece.appendChild(cell_data)
# Write to file and exit
- outFile = open(self.baseName+'%04d'%self.snapCount+'.vtu', 'w')
+ outFile = open(self.baseName+'%08d'%self.snapCount+'.vtu', 'w')
# xml.dom.ext.PrettyPrint(doc, file)
doc.writexml(outFile, newl='\n')
outFile.close()
@@ -414,7 +414,7 @@
if not bodies: return
nBodies = len(bodies)
# output file
- fName = self.baseName+'-spheres-%04d'%(numLabel if numLabel else self.spheresSnapCount)+'.vtk'
+ fName = self.baseName+'-spheres-%08d'%(numLabel if numLabel else self.spheresSnapCount)+'.vtk'
outFile = open(fName, 'w')
# head
outFile.write("# vtk DataFile Version 3.0.\n%s\nASCII\n\nDATASET POLYDATA\nPOINTS %d double\n"%(comment,nBodies))
@@ -463,7 +463,7 @@
if not bodies: return
nBodies = len(bodies)
# output file
- fName = self.baseName+'-facets-%04d'%(numLabel if numLabel else self.facetsSnapCount)+'.vtk'
+ fName = self.baseName+'-facets-%08d'%(numLabel if numLabel else self.facetsSnapCount)+'.vtk'
outFile = open(fName, 'w')
# head
outFile.write("# vtk DataFile Version 3.0.\n%s\nASCII\n\nDATASET POLYDATA\nPOINTS %d double\n"%(comment,3*nBodies))
@@ -543,7 +543,7 @@
nodes[e[1]] = pt2
nodes[e[2]] = pt3
# output file
- fName = self.baseName+'-facets-%04d'%(numLabel if numLabel else self.facetsSnapCount)+'.vtk'
+ fName = self.baseName+'-facets-%08d'%(numLabel if numLabel else self.facetsSnapCount)+'.vtk'
outFile = open(fName, 'w')
# head
outFile.write("# vtk DataFile Version 3.0.\n%s\nASCII\n\nDATASET POLYDATA\nPOINTS %d double\n"%(comment,len(nodes)))
@@ -592,7 +592,7 @@
return
nIntrs = len(intrs)
# output file
- fName = self.baseName+'-intrs-%04d'%(numLabel if numLabel else self.intrsSnapCount)+'.vtk'
+ fName = self.baseName+'-intrs-%08d'%(numLabel if numLabel else self.intrsSnapCount)+'.vtk'
outFile = open(fName, 'w')
# head
outFile.write("# vtk DataFile Version 3.0.\n%s\nASCII\n\nDATASET POLYDATA\nPOINTS %d double\n"%(comment,2*nIntrs))
@@ -713,7 +713,7 @@
return
nIntrs = len(intrs)
# output file
- fName = self.baseName+'-cps-%04d'%(numLabel if numLabel else self.contactPointsSnapCount)+'.vtk'
+ fName = self.baseName+'-cps-%08d'%(numLabel if numLabel else self.contactPointsSnapCount)+'.vtk'
outFile = open(fName, 'w')
# head
outFile.write("# vtk DataFile Version 3.0.\n%s\nASCII\n\nDATASET POLYDATA\nPOINTS %d double\n"%(comment,nIntrs))
@@ -774,7 +774,7 @@
self._warn("exportPeriodicCell: scene is not periodic, no export...")
return
hSize = O.cell.hSize
- fName = self.baseName+'-periCell-%04d'%(numLabel if numLabel else self.intrsSnapCount)+'.vtk'
+ fName = self.baseName+'-periCell-%08d'%(numLabel if numLabel else self.intrsSnapCount)+'.vtk'
outFile = open(fName, 'w')
outFile.write("# vtk DataFile Version 3.0.\n%s\nASCII\n\nDATASET UNSTRUCTURED_GRID\nPOINTS 8 double\n"%(comment))
vertices = [
@@ -820,7 +820,7 @@
bodyFaces.append(ff)
# output file
nFaces = sum(len(f) for f in bodyFaces)
- fName = self.baseName+'-polyhedra-%04d'%(numLabel if numLabel else self.polyhedraSnapCount)+'.vtk'
+ fName = self.baseName+'-polyhedra-%08d'%(numLabel if numLabel else self.polyhedraSnapCount)+'.vtk'
outFile = open(fName, 'w')
# head
outFile.write("# vtk DataFile Version 3.0.\n%s\nASCII\n\nDATASET POLYDATA\nPOINTS %d double\n"%(comment,nVertices))