[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28936] branches/soc-2008-mxcurioni/source /blender/freestyle/intern: Made object names accessible from within style modules.
Tamito Kajiyama
rd6t-kjym at asahi-net.or.jp
Sun May 23 19:11:44 CEST 2010
Revision: 28936
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28936
Author: kjym3
Date: 2010-05-23 19:11:44 +0200 (Sun, 23 May 2010)
Log Message:
-----------
Made object names accessible from within style modules.
ViewShape objects in the view map, as well as SShape objects
that can be retrieved with ViewShape::sshape(), now have a
getName() method that returns the name of the object from
which each shape is created. For instance, visible feature
edges of specific mesh objects (e.g., Cube.001 and Cube.002)
can be selected using custom predicate ObjectNamesUP1D as
follows:
class ObjectNamesUP1D(UnaryPredicate1D):
def __init__(self, names):
UnaryPredicate1D.__init__(self)
self._names = names
def getName(self):
return "ObjectNamesUP1D"
def __call__(self, viewEdge):
return viewEdge.viewShape().getName() in self._names
upred = AndUP1D(QuantitativeInvisibilityUP1D(0),
ObjectNamesUP1D(["Cube.001", "Cube.002"]))
Operators.select(upred)
Modified Paths:
--------------
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_SShape.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_ViewShape.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/scene_graph/Rep.h
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/view_map/Silhouette.h
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/view_map/ViewMap.h
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/winged_edge/WEdge.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/winged_edge/WEdge.h
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/winged_edge/WXEdgeBuilder.cpp
Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp 2010-05-23 12:38:49 UTC (rev 28935)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp 2010-05-23 17:11:44 UTC (rev 28936)
@@ -411,6 +411,7 @@
0);
// sets the id of the rep
rep->setId(Id(id, 0));
+ rep->setName(obi->ob->id.name+2);
const BBox<Vec3r> bbox = BBox<Vec3r>(Vec3r(ls.minBBox[0], ls.minBBox[1], ls.minBBox[2]),
Vec3r(ls.maxBBox[0], ls.maxBBox[1], ls.maxBBox[2]));
Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_SShape.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_SShape.cpp 2010-05-23 12:38:49 UTC (rev 28935)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_SShape.cpp 2010-05-23 17:11:44 UTC (rev 28936)
@@ -229,6 +229,37 @@
Py_RETURN_NONE;
}
+static char SShape_getName___doc__[] =
+".. method:: getName()\n"
+"\n"
+" Returns the name of the SShape.\n"
+"\n"
+" :return: The name string.\n"
+" :rtype: str\n";
+
+static PyObject * SShape_getName( BPy_SShape *self ) {
+ return PyUnicode_FromString( self->ss->getName().c_str() );
+}
+
+static char SShape_setName___doc__[] =
+".. method:: setName(name)\n"
+"\n"
+" Sets the name of the SShape.\n"
+"\n"
+" :arg name: A name string.\n"
+" :type name: str\n";
+
+static PyObject * SShape_setName( BPy_SShape *self , PyObject *args) {
+ char *s;
+
+ if(!( PyArg_ParseTuple(args, "s", &s) ))
+ return NULL;
+
+ self->ss->setName(s);
+
+ Py_RETURN_NONE;
+}
+
// const Material & material (unsigned i) const
// const vector< Material > & materials () const
// void SetMaterials (const vector< Material > &iMaterials)
@@ -244,6 +275,8 @@
{"getEdgeList", ( PyCFunction ) SShape_getEdgeList, METH_NOARGS, SShape_getEdgeList___doc__},
{"getId", ( PyCFunction ) SShape_getId, METH_NOARGS, SShape_getId___doc__},
{"setId", ( PyCFunction ) SShape_setId, METH_VARARGS, SShape_setId___doc__},
+ {"getName", ( PyCFunction ) SShape_getName, METH_NOARGS, SShape_getName___doc__},
+ {"setName", ( PyCFunction ) SShape_setName, METH_VARARGS, SShape_setName___doc__},
{NULL, NULL, 0, NULL}
};
Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_ViewShape.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_ViewShape.cpp 2010-05-23 12:38:49 UTC (rev 28935)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_ViewShape.cpp 2010-05-23 17:11:44 UTC (rev 28936)
@@ -153,6 +153,18 @@
return BPy_Id_from_Id( id );
}
+static char ViewShape_getName___doc__[] =
+".. method:: getName()\n"
+"\n"
+" Returns the name of the ViewShape.\n"
+"\n"
+" :return: The name string.\n"
+" :rtype: str\n";
+
+static PyObject * ViewShape_getName( BPy_ViewShape *self ) {
+ return PyUnicode_FromString( self->vs->getName().c_str() );
+}
+
static char ViewShape_setSShape___doc__[] =
".. method:: setSShape(iSShape)\n"
"\n"
@@ -282,6 +294,7 @@
{"vertices", ( PyCFunction ) ViewShape_vertices, METH_NOARGS, ViewShape_vertices___doc__},
{"edges", ( PyCFunction ) ViewShape_edges, METH_NOARGS, ViewShape_edges___doc__},
{"getId", ( PyCFunction ) ViewShape_getId, METH_NOARGS, ViewShape_getId___doc__},
+ {"getName", ( PyCFunction ) ViewShape_getName, METH_NOARGS, ViewShape_getName___doc__},
{"setSShape", ( PyCFunction ) ViewShape_setSShape, METH_VARARGS, ViewShape_setSShape___doc__},
{"setVertices", ( PyCFunction ) ViewShape_setVertices, METH_VARARGS, ViewShape_setVertices___doc__},
{"setEdges", ( PyCFunction ) ViewShape_setEdges, METH_VARARGS, ViewShape_setEdges___doc__},
Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/scene_graph/Rep.h
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/scene_graph/Rep.h 2010-05-23 12:38:49 UTC (rev 28935)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/scene_graph/Rep.h 2010-05-23 17:11:44 UTC (rev 28936)
@@ -50,6 +50,7 @@
: BaseObject()
{
_Id = iBrother._Id;
+ _Name = iBrother._Name;
if(0 == iBrother._FrsMaterial)
_FrsMaterial = 0;
else
@@ -60,11 +61,13 @@
inline void swap(Rep& ioOther){
std::swap(_BBox,ioOther._BBox);
std::swap(_Id, ioOther._Id);
+ std::swap(_Name, ioOther._Name);
std::swap(_FrsMaterial,ioOther._FrsMaterial);
}
Rep& operator=(const Rep& iBrother){
if(&iBrother != this){
_Id = iBrother._Id;
+ _Name = iBrother._Name;
if(0 == iBrother._FrsMaterial)
_FrsMaterial = 0;
else{
@@ -108,11 +111,13 @@
/*! Returns the rep bounding box */
virtual const BBox<Vec3r>& bbox() const {return _BBox;}
inline Id getId() const {return _Id;}
+ inline const string& getName() const {return _Name;}
inline const FrsMaterial * frs_material() const {return _FrsMaterial;}
/*! Sets the Rep bounding box */
virtual void setBBox(const BBox<Vec3r>& iBox) {_BBox = iBox;}
inline void setId(const Id& id) {_Id = id;}
+ inline void setName(const string& name) {_Name = name;}
inline void setFrsMaterial(const FrsMaterial& iMaterial)
{
_FrsMaterial = new FrsMaterial(iMaterial);
@@ -121,6 +126,7 @@
private:
BBox<Vec3r> _BBox;
Id _Id;
+ string _Name;
FrsMaterial *_FrsMaterial;
};
Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/view_map/Silhouette.h
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/view_map/Silhouette.h 2010-05-23 12:38:49 UTC (rev 28935)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/view_map/Silhouette.h 2010-05-23 17:11:44 UTC (rev 28936)
@@ -936,6 +936,7 @@
vector<SVertex*> _verticesList; // list of all vertices
vector<FEdge*> _edgesList; // list of all edges
Id _Id;
+ string _Name;
BBox<Vec3r> _BBox;
vector<FrsMaterial> _FrsMaterials;
@@ -961,6 +962,7 @@
{
userdata = 0;
_Id = iBrother._Id;
+ _Name = iBrother._Name;
_BBox = iBrother.bbox();
_FrsMaterials = iBrother._FrsMaterials;
@@ -1416,10 +1418,14 @@
inline float importance() const {return _importance;}
/*! Returns the Id of the Shape. */
inline Id getId() const { return _Id; }
+ /*! Returns the name of the Shape. */
+ inline const string& getName() const { return _Name; }
/* Modififers */
/*! Sets the Id of the shape.*/
inline void setId(Id id) {_Id = id;}
+ /*! Sets the name of the shape.*/
+ inline void setName(const string& name) {_Name = name;}
/*! Sets the list of materials for the shape */
inline void setFrsMaterials(const vector<FrsMaterial>& iMaterials) {_FrsMaterials = iMaterials;}
inline void setViewShape(ViewShape *iShape) {_ViewShape = iShape;}
Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/view_map/ViewMap.h
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/view_map/ViewMap.h 2010-05-23 12:38:49 UTC (rev 28935)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/view_map/ViewMap.h 2010-05-23 17:11:44 UTC (rev 28936)
@@ -1252,6 +1252,8 @@
inline vector<ViewEdge*>& edges() {return _Edges;}
/*! Returns the ViewShape id. */
inline Id getId() const {return _SShape->getId();}
+ /*! Returns the ViewShape id. */
+ inline const string& getName() const {return _SShape->getName();}
/* modifiers */
/*! Sets the SShape on top of which the ViewShape is built. */
Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp 2010-05-23 12:38:49 UTC (rev 28935)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp 2010-05-23 17:11:44 UTC (rev 28936)
@@ -56,6 +56,7 @@
// create the embedding
psShape = new SShape;
psShape->setId((*it)->GetId());
+ psShape->setName((*it)->getName());
psShape->setFrsMaterials((*it)->frs_materials()); // FIXME
// create the view shape
Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/winged_edge/WEdge.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/winged_edge/WEdge.cpp 2010-05-23 12:38:49 UTC (rev 28935)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/winged_edge/WEdge.cpp 2010-05-23 17:11:44 UTC (rev 28936)
@@ -475,6 +475,7 @@
WShape::WShape(WShape& iBrother)
{
_Id = iBrother.GetId();
+ _Name = iBrother._Name;
_FrsMaterials = iBrother._FrsMaterials;
_meanEdgeSize = iBrother._meanEdgeSize;
iBrother.bbox(_min, _max);
Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/winged_edge/WEdge.h
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/winged_edge/WEdge.h 2010-05-23 12:38:49 UTC (rev 28935)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/winged_edge/WEdge.h 2010-05-23 17:11:44 UTC (rev 28936)
@@ -156,10 +156,10 @@
increment();
return *this;
}
- virtual incoming_edge_iterator operator++(int) // op\xE9rateur correspondant \xE0 i++
- { // c.a.d qui renvoie la valeur *puis* incr\xE9mente.
- incoming_edge_iterator tmp = *this; // C'est pour cela qu'on stocke la valeur
- increment(); // dans un temporaire.
+ virtual incoming_edge_iterator operator++(int) // operator corresponding to i++
+ {
+ incoming_edge_iterator tmp = *this;
+ increment();
return tmp;
}
@@ -231,10 +231,10 @@
increment();
return *this;
}
- virtual face_iterator operator++(int) // op\xE9rateur correspondant \xE0 i++
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list