1
/***************************************************************************
2
* Copyright (c) 2007 Werner Mayer <wmayer[at]users.sourceforge.net> *
4
* This file is part of the FreeCAD CAx development system. *
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. *
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. *
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 *
21
***************************************************************************/
23
#include "PreCompiled.h"
36
Segment::Segment(const MeshObject* mesh, bool mod)
42
Segment::Segment(const MeshObject* mesh, const std::vector<FacetIndex>& inds, bool mod)
49
_mesh->updateMesh(inds);
53
void Segment::addIndices(const std::vector<FacetIndex>& inds)
55
_indices.insert(_indices.end(), inds.begin(), inds.end());
56
std::sort(_indices.begin(), _indices.end());
57
_indices.erase(std::unique(_indices.begin(), _indices.end()), _indices.end());
59
_mesh->updateMesh(inds);
63
void Segment::removeIndices(const std::vector<FacetIndex>& inds)
66
std::vector<FacetIndex> result;
67
std::set<FacetIndex> s1(_indices.begin(), _indices.end());
68
std::set<FacetIndex> s2(inds.begin(), inds.end());
69
std::set_difference(s1.begin(),
73
std::back_insert_iterator<std::vector<FacetIndex>>(result));
81
const std::vector<FacetIndex>& Segment::getIndices() const
86
Segment::Segment(const Segment& s) = default;
88
Segment::Segment(Segment&& s) = default;
90
Segment& Segment::operator=(const Segment& s)
92
// Do not copy the MeshObject pointer
94
this->_indices = s._indices;
102
Segment& Segment::operator=(Segment&& s)
104
// Do not copy the MeshObject pointer
106
this->_indices = s._indices;
114
bool Segment::operator==(const Segment& s) const
116
return this->_indices == s._indices;
119
// ----------------------------------------------------------------------------
122
Segment::const_facet_iterator::const_facet_iterator
123
(const Segment* segm, std::vector<FacetIndex>::const_iterator it)
124
: _segment(segm), _f_it(segm->_mesh->getKernel()), _it(it)
127
this->_f_it.Transform(_segment->_mesh->getTransform());
128
this->_facet.Mesh = _segment->_mesh;
131
Segment::const_facet_iterator::const_facet_iterator
132
(const Segment::const_facet_iterator& fi) = default;
134
Segment::const_facet_iterator::const_facet_iterator
135
(Segment::const_facet_iterator&& fi) = default;
137
Segment::const_facet_iterator::~const_facet_iterator() = default;
139
Segment::const_facet_iterator& Segment::const_facet_iterator::operator=
140
(const Segment::const_facet_iterator& fi) = default;
142
Segment::const_facet_iterator& Segment::const_facet_iterator::operator=
143
(Segment::const_facet_iterator&& fi) = default;
145
void Segment::const_facet_iterator::dereference() const
147
this->_f_it.Set(*_it);
148
this->_facet.MeshCore::MeshGeomFacet::operator = (*_f_it);
149
this->_facet.Index = *_it;
150
const MeshCore::MeshFacet& face = _f_it.GetReference();
151
for (int i=0; i<3;i++) {
152
this->_facet.PIndex[i] = face._aulPoints[i];
153
this->_facet.NIndex[i] = face._aulNeighbours[i];
157
const Facet& Segment::const_facet_iterator::operator*() const
163
const Facet* Segment::const_facet_iterator::operator->() const
166
return &(this->_facet);
169
bool Segment::const_facet_iterator::operator==(const Segment::const_facet_iterator& fi) const
171
return (this->_segment == fi._segment) && (this->_it == fi._it);
174
bool Segment::const_facet_iterator::operator!=(const Segment::const_facet_iterator& fi) const
176
return !operator==(fi);
179
Segment::const_facet_iterator& Segment::const_facet_iterator::operator++()
185
Segment::const_facet_iterator& Segment::const_facet_iterator::operator--()