FreeCAD

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

23
#include "PreCompiled.h"
24
#ifndef _PreComp_
25
#include <sstream>
26
#endif
27

28
#include "Facet.h"
29
#include "Mesh.h"
30

31

32
using namespace Mesh;
33

34
Facet::Facet(const MeshCore::MeshFacet& face,  // NOLINT
35
             const MeshObject* obj,
36
             MeshCore::FacetIndex index)
37
    : Index(index)
38
    , Mesh(obj)
39
{
40
    for (int i = 0; i < 3; i++) {
41
        PIndex[i] = face._aulPoints[i];
42
        NIndex[i] = face._aulNeighbours[i];
43
    }
44
    if (Mesh.isValid() && index != MeshCore::FACET_INDEX_MAX) {
45
        for (int i = 0; i < 3; i++) {
46
            Base::Vector3d vert = Mesh->getPoint(PIndex[i]);
47
            _aclPoints[i].Set((float)vert.x, (float)vert.y, (float)vert.z);
48
        }
49
    }
50
}
51

52
Facet::Facet(const Facet& f)  // NOLINT
53
    : MeshCore::MeshGeomFacet(f)
54
    , Index(f.Index)
55
    , Mesh(f.Mesh)
56
{
57
    for (int i = 0; i < 3; i++) {
58
        PIndex[i] = f.PIndex[i];
59
        NIndex[i] = f.NIndex[i];
60
    }
61
}
62

63
Facet::Facet(Facet&& f)  // NOLINT
64
    : MeshCore::MeshGeomFacet(f)
65
    , Index(f.Index)
66
    , Mesh(f.Mesh)
67
{
68
    for (int i = 0; i < 3; i++) {
69
        PIndex[i] = f.PIndex[i];
70
        NIndex[i] = f.NIndex[i];
71
    }
72
}
73

74
Facet::~Facet() = default;
75

76
Facet& Facet::operator=(const Facet& f)
77
{
78
    MeshCore::MeshGeomFacet::operator=(f);
79
    Mesh = f.Mesh;
80
    Index = f.Index;
81
    for (int i = 0; i < 3; i++) {
82
        PIndex[i] = f.PIndex[i];
83
        NIndex[i] = f.NIndex[i];
84
    }
85

86
    return *this;
87
}
88

89
Facet& Facet::operator=(Facet&& f)
90
{
91
    MeshCore::MeshGeomFacet::operator=(f);
92
    Mesh = f.Mesh;
93
    Index = f.Index;
94
    for (int i = 0; i < 3; i++) {
95
        PIndex[i] = f.PIndex[i];
96
        NIndex[i] = f.NIndex[i];
97
    }
98

99
    return *this;
100
}
101

102
Edge Facet::getEdge(int index) const
103
{
104
    index = index % 3;
105
    Edge edge;
106
    // geometric coordinates
107
    edge._aclPoints[0] = this->_aclPoints[index];
108
    edge._aclPoints[1] = this->_aclPoints[(index + 1) % 3];
109

110
    // indices
111
    edge.Index = index;
112
    edge.PIndex[0] = this->PIndex[index];
113
    edge.PIndex[1] = this->PIndex[(index + 1) % 3];
114
    edge.NIndex[0] = this->Index;
115
    edge.NIndex[1] = this->NIndex[index];
116
    edge._bBorder = (this->NIndex[index] == MeshCore::FACET_INDEX_MAX);
117

118
    edge.Mesh = this->Mesh;
119
    return edge;
120
}
121

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

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

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

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