~ubuntu-branches/ubuntu/maverick/freecad/maverick

« back to all changes in this revision

Viewing changes to src/Mod/Part/App/PropertyTopoShape.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Adam C. Powell, IV
  • Date: 2010-01-11 08:48:33 UTC
  • mfrom: (3.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20100111084833-4g9vgdqbkw8u34zb
Tags: 0.9.2646.5-1
* New upstream version (closes: #561696).
* Added swig to Build-Depends (closes: #563523, #563772).
* Removed python-opencv from Build-Depends and Recommends (closes: #560768).

Show diffs side-by-side

added added

removed removed

Lines of Context:
124
124
    _Shape.getFaces(aPoints, aTopo, accuracy, flags);
125
125
}
126
126
 
127
 
void PropertyPartShape::transform(const Base::Matrix4D &rclTrf)
 
127
void PropertyPartShape::transformGeometry(const Base::Matrix4D &rclTrf)
128
128
{
129
 
    gp_Trsf mat;
130
 
    mat.SetValues(rclTrf[0][0],rclTrf[0][1],rclTrf[0][2],rclTrf[0][3],
131
 
                  rclTrf[1][0],rclTrf[1][1],rclTrf[1][2],rclTrf[1][3],
132
 
                  rclTrf[2][0],rclTrf[2][1],rclTrf[2][2],rclTrf[2][3],
133
 
                  0.00001,0.00001);
134
 
    mat.SetScaleFactor(rclTrf[3][3]);
135
 
    // geometric transformation
136
 
    BRepBuilderAPI_GTransform mkTrsf(this->_Shape._Shape, gp_GTrsf(mat));
137
 
    setValue(mkTrsf.Shape());
 
129
    setValue(_Shape.transformGeometry(rclTrf));
138
130
}
139
131
 
140
132
PyObject *PropertyPartShape::getPyObject(void)
269
261
 
270
262
// -------------------------------------------------------------------------
271
263
 
272
 
TYPESYSTEM_SOURCE(Part::PropertyFilletContour , App::PropertyLists);
273
 
 
274
 
PropertyFilletContour::PropertyFilletContour()
275
 
{
276
 
}
277
 
 
278
 
PropertyFilletContour::~PropertyFilletContour()
279
 
{
280
 
}
281
 
 
282
 
void PropertyFilletContour::setValue(int id, double r1, double r2)
 
264
TYPESYSTEM_SOURCE(Part::PropertyFilletEdges , App::PropertyLists);
 
265
 
 
266
PropertyFilletEdges::PropertyFilletEdges()
 
267
{
 
268
}
 
269
 
 
270
PropertyFilletEdges::~PropertyFilletEdges()
 
271
{
 
272
}
 
273
 
 
274
void PropertyFilletEdges::setValue(int id, double r1, double r2)
283
275
{
284
276
    aboutToSetValue();
285
277
    _lValueList.resize(1);
286
 
    _lValueList[0].hashval = id;
 
278
    _lValueList[0].edgeid = id;
287
279
    _lValueList[0].radius1 = r1;
288
280
    _lValueList[0].radius2 = r2;
289
281
    hasSetValue();
290
282
}
291
283
 
292
 
void PropertyFilletContour::setValues(const std::vector<FilletElement>& values)
 
284
void PropertyFilletEdges::setValues(const std::vector<FilletElement>& values)
293
285
{
294
286
    aboutToSetValue();
295
287
    _lValueList = values;
296
288
    hasSetValue();
297
289
}
298
290
 
299
 
PyObject *PropertyFilletContour::getPyObject(void)
 
291
PyObject *PropertyFilletEdges::getPyObject(void)
300
292
{
301
293
    Py::List list(getSize());
302
294
    std::vector<FilletElement>::const_iterator it;
303
295
    int index = 0;
304
296
    for (it = _lValueList.begin(); it != _lValueList.end(); ++it) {
305
297
        Py::Tuple ent(3);
306
 
        ent.setItem(0, Py::Int(it->hashval));
 
298
        ent.setItem(0, Py::Int(it->edgeid));
307
299
        ent.setItem(1, Py::Float(it->radius1));
308
300
        ent.setItem(2, Py::Float(it->radius2));
309
301
        list[index++] = ent;
312
304
    return Py::new_reference_to(list);
313
305
}
314
306
 
315
 
void PropertyFilletContour::setPyObject(PyObject *value)
 
307
void PropertyFilletEdges::setPyObject(PyObject *value)
316
308
{
317
309
    Py::List list(value);
318
310
    std::vector<FilletElement> values;
320
312
    for (Py::List::iterator it = list.begin(); it != list.end(); ++it) {
321
313
        FilletElement fe;
322
314
        Py::Tuple ent(*it);
323
 
        fe.hashval = (int)Py::Int(ent.getItem(0));
 
315
        fe.edgeid = (int)Py::Int(ent.getItem(0));
324
316
        fe.radius1 = (double)Py::Float(ent.getItem(1));
325
317
        fe.radius2 = (double)Py::Float(ent.getItem(2));
326
318
        values.push_back(fe);
329
321
    setValues(values);
330
322
}
331
323
 
332
 
void PropertyFilletContour::Save (Base::Writer &writer) const
 
324
void PropertyFilletEdges::Save (Base::Writer &writer) const
333
325
{
334
326
    if (!writer.isForceXML()) {
335
 
        writer.Stream() << writer.ind() << "<FilletContour file=\"" << writer.addFile(getName(), this) << "\"/>" << std::endl;
 
327
        writer.Stream() << writer.ind() << "<FilletEdges file=\"" << writer.addFile(getName(), this) << "\"/>" << std::endl;
336
328
    }
337
329
}
338
330
 
339
 
void PropertyFilletContour::Restore(Base::XMLReader &reader)
 
331
void PropertyFilletEdges::Restore(Base::XMLReader &reader)
340
332
{
341
 
    reader.readElement("FilletContour");
 
333
    reader.readElement("FilletEdges");
342
334
    std::string file (reader.getAttribute("file") );
343
335
 
344
336
    if (!file.empty()) {
347
339
    }
348
340
}
349
341
 
350
 
void PropertyFilletContour::SaveDocFile (Base::Writer &writer) const
 
342
void PropertyFilletEdges::SaveDocFile (Base::Writer &writer) const
351
343
{
352
344
    Base::OutputStream str(writer.Stream());
353
345
    uint32_t uCt = (uint32_t)getSize();
354
346
    str << uCt;
355
347
    for (std::vector<FilletElement>::const_iterator it = _lValueList.begin(); it != _lValueList.end(); ++it) {
356
 
        str << it->hashval << it->radius1 << it->radius2;
 
348
        str << it->edgeid << it->radius1 << it->radius2;
357
349
    }
358
350
}
359
351
 
360
 
void PropertyFilletContour::RestoreDocFile(Base::Reader &reader)
 
352
void PropertyFilletEdges::RestoreDocFile(Base::Reader &reader)
361
353
{
362
354
    Base::InputStream str(reader);
363
355
    uint32_t uCt=0;
364
356
    str >> uCt;
365
357
    std::vector<FilletElement> values(uCt);
366
358
    for (std::vector<FilletElement>::iterator it = values.begin(); it != values.end(); ++it) {
367
 
        str >> it->hashval >> it->radius1 >> it->radius2;
 
359
        str >> it->edgeid >> it->radius1 >> it->radius2;
368
360
    }
369
361
    setValues(values);
370
362
}
371
363
 
372
 
App::Property *PropertyFilletContour::Copy(void) const
 
364
App::Property *PropertyFilletEdges::Copy(void) const
373
365
{
374
 
    PropertyFilletContour *p= new PropertyFilletContour();
 
366
    PropertyFilletEdges *p= new PropertyFilletEdges();
375
367
    p->_lValueList = _lValueList;
376
368
    return p;
377
369
}
378
370
 
379
 
void PropertyFilletContour::Paste(const Property &from)
 
371
void PropertyFilletEdges::Paste(const Property &from)
380
372
{
381
373
    aboutToSetValue();
382
 
    _lValueList = dynamic_cast<const PropertyFilletContour&>(from)._lValueList;
 
374
    _lValueList = dynamic_cast<const PropertyFilletEdges&>(from)._lValueList;
383
375
    hasSetValue();
384
376
}