yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #03752
[Branch ~yade-dev/yade/trunk] Rev 2117: 1. Fix compilation of deprecated attributes for gcc 4.3 (thanks Jerome for reporting)
------------------------------------------------------------
revno: 2117
committer: Václav Šmilauer <eudoxos@xxxxxxxx>
branch nick: trunk
timestamp: Tue 2010-03-30 12:51:31 +0200
message:
1. Fix compilation of deprecated attributes for gcc 4.3 (thanks Jerome for reporting)
2. Re-add facet rendering code.
3. Add docs to predicates.
modified:
lib/serialization/Serializable.hpp
pkg/common/RenderingEngine/Gl1_Facet.cpp
pkg/common/RenderingEngine/Gl1_Facet.hpp
py/pack/_packPredicates.cpp
--
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/serialization/Serializable.hpp'
--- lib/serialization/Serializable.hpp 2010-03-29 11:36:21 +0000
+++ lib/serialization/Serializable.hpp 2010-03-30 10:51:31 +0000
@@ -86,14 +86,14 @@
#define _PYATTR_DEF(x,thisClass,z) .def_readwrite(BOOST_PP_STRINGIZE(BOOST_PP_TUPLE_ELEM(2,0,z)),&thisClass::BOOST_PP_TUPLE_ELEM(2,0,z),BOOST_PP_TUPLE_ELEM(2,1,z))
// macros for deprecated attribute access
-// gcc<=4.2 is not able to compile this code; we will just not generate any code for deprecated attributes in such case
-#if defined(__GNUG__) && __GNUC__ <= 4 && __GNUC_MINOR__ <=2
+// gcc<=4.3 is not able to compile this code; we will just not generate any code for deprecated attributes in such case
+#if defined(__GNUG__) && __GNUC__ <= 4 && __GNUC_MINOR__ <=3
#define _PYSET_ATTR_DEPREC(x,y,z)
#define _PYATTR_DEPREC_DEF(x,y,z)
#define _PYHASKEY_ATTR_DEPREC(x,y,z)
#define _ACCESS_DEPREC(x,y,z)
#else
- // gcc < 4.2 && non-gcc compilers
+ // gcc > 4.3 && non-gcc compilers
#define _PYSET_ATTR_DEPREC(x,thisClass,z) if(key==BOOST_PP_STRINGIZE(_DEPREC_OLDNAME(z))){ _DEPREC_WARN(thisClass,z); _DEPREC_NEWNAME(z)=boost::python::extract<typeof(_DEPREC_NEWNAME(z))>(value); return; }
#define _PYATTR_DEPREC_DEF(x,thisClass,z) .add_property(BOOST_PP_STRINGIZE(_DEPREC_OLDNAME(z)),&thisClass::BOOST_PP_CAT(_getDeprec_,_DEPREC_OLDNAME(z)),&thisClass::BOOST_PP_CAT(_setDeprec_,_DEPREC_OLDNAME(z)),"|ydeprecated| alias for :yref:`" BOOST_PP_STRINGIZE(_DEPREC_NEWNAME(z)) "<" BOOST_PP_STRINGIZE(thisClass) "." BOOST_PP_STRINGIZE(_DEPREC_NEWNAME(z)) ">` (" _DEPREC_COMMENT(z) ")")
#define _PYHASKEY_ATTR_DEPREC(x,thisClass,z) if(key==BOOST_PP_STRINGIZE(_DEPREC_OLDNAME(z))) return true;
=== modified file 'pkg/common/RenderingEngine/Gl1_Facet.cpp'
--- pkg/common/RenderingEngine/Gl1_Facet.cpp 2009-12-13 20:30:13 +0000
+++ pkg/common/RenderingEngine/Gl1_Facet.cpp 2010-03-30 10:51:31 +0000
@@ -12,44 +12,47 @@
bool Gl1_Facet::normals=false;
-void Gl1_Facet::go(const shared_ptr<Shape>& cm, const shared_ptr<State>& ,bool,const GLViewInfo&)
+void Gl1_Facet::go(const shared_ptr<Shape>& cm, const shared_ptr<State>& ,bool wire,const GLViewInfo&)
{
- Facet* facet = static_cast<Facet*>(cm.get());
- const vector<Vector3r>& vertices = facet->vertices;
+ Facet* facet = static_cast<Facet*>(cm.get());
+ const vector<Vector3r>& vertices = facet->vertices;
const Vector3r* ne = facet->ne;
const Real& icr = facet->icr;
- // glDisable(GL_LIGHTING);
-
- // facet
- glBegin(GL_LINE_LOOP);
- glColor3(1.0,0.0,0.0);
- glVertex3v(vertices[0]);
- glVertex3v(vertices[1]);
- glVertex3v(vertices[2]);
- glEnd();
-
- if(!normals) return;
-
- // facet's normal
- glBegin(GL_LINES);
+ if(cm->wire || wire){
+ // facet
+ glBegin(GL_LINE_LOOP);
+ glColor3v(normals ? Vector3r(1,0,0): cm->color);
+ glVertex3v(vertices[0]);
+ glVertex3v(vertices[1]);
+ glVertex3v(vertices[2]);
+ glEnd();
+ if(!normals) return;
+ // facet's normal
+ glBegin(GL_LINES);
+ glColor3(0.0,0.0,1.0);
+ glVertex3(0.0,0.0,0.0);
+ glVertex3v(facet->nf);
+ glEnd();
+ // normal of edges
glColor3(0.0,0.0,1.0);
- glVertex3(0.0,0.0,0.0);
- glVertex3v(facet->nf);
- glEnd();
-
- // normal of edges
- glColor3(0.0,0.0,1.0);
- glBegin(GL_LINES);
- glVertex3(0.0,0.0,0.0);
- glVertex3v(icr*ne[0]);
-
- glVertex3(0.0,0.0,0.0);
- glVertex3v(icr*ne[1]);
-
- glVertex3(0.0,0.0,0.0);
- glVertex3v(icr*ne[2]);
- glEnd();
+ glBegin(GL_LINES);
+ glVertex3(0.0,0.0,0.0); glVertex3v(icr*ne[0]);
+ glVertex3(0.0,0.0,0.0); glVertex3v(icr*ne[1]);
+ glVertex3(0.0,0.0,0.0); glVertex3v(icr*ne[2]);
+ glEnd();
+ } else {
+ glDisable(GL_CULL_FACE);
+ glMaterialv(GL_FRONT,GL_AMBIENT_AND_DIFFUSE,cm->color); glColor3v(cm->color); // one of those necessary as well
+ glEnable(GL_LIGHTING); // important
+ Vector3r normal=(facet->vertices[1]-facet->vertices[0]).Cross(facet->vertices[2]-facet->vertices[1]); normal.Normalize();
+ glBegin(GL_TRIANGLES);
+ glNormal3v(normal); // this makes every triangle different WRT the light direction; important!
+ glVertex3v(facet->vertices[0]);
+ glVertex3v(facet->vertices[1]);
+ glVertex3v(facet->vertices[2]);
+ glEnd();
+ }
}
YADE_PLUGIN((Gl1_Facet));
=== modified file 'pkg/common/RenderingEngine/Gl1_Facet.hpp'
--- pkg/common/RenderingEngine/Gl1_Facet.hpp 2010-02-09 16:50:30 +0000
+++ pkg/common/RenderingEngine/Gl1_Facet.hpp 2010-03-30 10:51:31 +0000
@@ -16,7 +16,7 @@
virtual void go(const shared_ptr<Shape>&, const shared_ptr<State>&,bool,const GLViewInfo&);
RENDERS(Facet);
YADE_CLASS_BASE_DOC_STATICATTRS(Gl1_Facet,GlShapeFunctor,"Renders :yref:`Facet` object",
- ((bool,normals,false,"Also render facets' and edges' normals."))
+ ((bool,normals,false,"In wire mode, render normals of facets and edges; facet's :yref:`colors<Shape::color>` are disregarded in that case."))
);
};
=== modified file 'py/pack/_packPredicates.cpp'
--- py/pack/_packPredicates.cpp 2010-03-25 13:24:10 +0000
+++ py/pack/_packPredicates.cpp 2010-03-30 10:51:31 +0000
@@ -332,10 +332,10 @@
// boolean operations
python::class_<PredicateBoolean,python::bases<Predicate>,boost::noncopyable>("PredicateBoolean","Boolean operation on 2 predicates (abstract class)",python::no_init)
.add_property("A",&PredicateBoolean::getA).add_property("B",&PredicateBoolean::getB);
- python::class_<PredicateUnion,python::bases<PredicateBoolean> >("PredicateUnion","Union of 2 predicates",python::init<python::object,python::object>());
- python::class_<PredicateIntersection,python::bases<PredicateBoolean> >("PredicateIntersection","Intersection of 2 predicates",python::init<python::object,python::object >());
- python::class_<PredicateDifference,python::bases<PredicateBoolean> >("PredicateDifference","Difference of 2 predicates",python::init<python::object,python::object >());
- python::class_<PredicateSymmetricDifference,python::bases<PredicateBoolean> >("PredicateSymmetricDifference","SymmetricDifference of 2 predicates",python::init<python::object,python::object >());
+ python::class_<PredicateUnion,python::bases<PredicateBoolean> >("PredicateUnion","Union (non-exclusive disjunction) of 2 predicates. A point has to be inside any of the two predicates to be inside. Can be constructed using the ``|`` operator on predicates: ``pred1 | pred2``.",python::init<python::object,python::object>());
+ python::class_<PredicateIntersection,python::bases<PredicateBoolean> >("PredicateIntersection","Intersection (conjunction) of 2 predicates. A point has to be inside both predicates. Can be constructed using the ``&`` operator on predicates: ``pred1 & pred2``.",python::init<python::object,python::object >());
+ python::class_<PredicateDifference,python::bases<PredicateBoolean> >("PredicateDifference","Difference (conjunction with negative predicate) of 2 predicates. A point has to be inside the first and outside the second predicate. Can be constructed using the ``-`` operator on predicates: ``pred1 - pred2``.",python::init<python::object,python::object >());
+ python::class_<PredicateSymmetricDifference,python::bases<PredicateBoolean> >("PredicateSymmetricDifference","SymmetricDifference (exclusive disjunction) of 2 predicates. A point has to be in exactly one predicate of the two. Can be constructed using the ``^`` operator on predicates: ``pred1 ^ pred2``.",python::init<python::object,python::object >());
// primitive predicates
python::class_<inSphere,python::bases<Predicate> >("inSphere","Sphere predicate.",python::init<const Vector3r&,Real>(python::args("center","radius"),"Ctor taking center (as a 3-tuple) and radius"));
python::class_<inAlignedBox,python::bases<Predicate> >("inAlignedBox","Axis-aligned box predicate",python::init<const Vector3r&,const Vector3r&>(python::args("minAABB","maxAABB"),"Ctor taking minumum and maximum points of the box (as 3-tuples)."));