FreeCAD

Форк
0
/
DatumFeature.cpp 
85 строк · 3.3 Кб
1
/***************************************************************************
2
 *   Copyright (c) 2013 Jan Rheinländer                                    *
3
 *                                <jrheinlaender[at]users.sourceforge.net> *
4
 *                                                                         *
5
 *   This file is part of the FreeCAD CAx development system.              *
6
 *                                                                         *
7
 *   This library is free software; you can redistribute it and/or         *
8
 *   modify it under the terms of the GNU Library General Public           *
9
 *   License as published by the Free Software Foundation; either          *
10
 *   version 2 of the License, or (at your option) any later version.      *
11
 *                                                                         *
12
 *   This library  is distributed in the hope that it will be useful,      *
13
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
14
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
15
 *   GNU Library General Public License for more details.                  *
16
 *                                                                         *
17
 *   You should have received a copy of the GNU Library General Public     *
18
 *   License along with this library; see the file COPYING.LIB. If not,    *
19
 *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
20
 *   Suite 330, Boston, MA  02111-1307, USA                                *
21
 *                                                                         *
22
 ***************************************************************************/
23

24
#include "PreCompiled.h"
25

26
#include "DatumFeature.h"
27
#include "OCCError.h"
28
#include "PartPyCXX.h"
29

30

31
using namespace Part;
32
using namespace Attacher;
33

34
PROPERTY_SOURCE_ABSTRACT_WITH_EXTENSIONS(Part::Datum, Part::Feature)
35

36
Datum::Datum()
37
{
38
    AttachExtension::initExtension(this);
39
    touch();
40
}
41

42
Datum::~Datum() = default;
43

44
void Datum::onDocumentRestored()
45
{
46
    // This seems to be the only way to make the ViewProvider display the datum feature
47
    AttachmentSupport.touch();
48
    Part::Feature::onDocumentRestored();
49
}
50

51
TopoDS_Shape Datum::getShape() const
52
{
53
    Part::TopoShape sh = Shape.getShape();
54
    sh.setPlacement(Placement.getValue());
55
    return sh.getShape();
56
}
57

58
App::DocumentObject *Datum::getSubObject(const char *subname,
59
        PyObject **pyObj, Base::Matrix4D *pmat, bool transform, int depth) const
60
{
61
    // For the sake of simplicity, we don't bother to check for subname, just
62
    // return the shape as it is, because a datum object only holds shape with
63
    // one single geometry element.
64
    (void)subname;
65
    (void)depth;
66

67
    if(pmat && transform)
68
        *pmat *= Placement.getValue().toMatrix();
69

70
    if(!pyObj)
71
        return const_cast<Datum*>(this);
72

73
    Base::PyGILStateLocker lock;
74
    PY_TRY {
75
        TopoShape ts(getShape().Located(TopLoc_Location()));
76
        if(pmat && !ts.isNull())
77
            ts.transformShape(*pmat,false,true);
78
        *pyObj =  Py::new_reference_to(shape2pyshape(ts.getShape()));
79
        return const_cast<Datum*>(this);
80
    } PY_CATCH_OCC
81
}
82

83
Base::Vector3d Datum::getBasePoint () const {
84
    return Placement.getValue().getPosition();
85
}
86

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.