* Copypaste ElementMap * Add MappedNameRef * Fix missing include * Copypaste `findTagInElementName` * fix error introduced _somewhere_ * refactor toponaming constants * Move `findTagInElementName` in `MappedName` * reintroduce workaround to compile ElementMap * Added missing functions copied from complexgeodata * fix last compile errors, reorder and format files * remove recursive refs to ComplexGeoData * Add more comments * fixed comments and added tests * added FIXME, make functions private, misc fixes * Move static functions from complexGeoData to PostfixStringReferences. Rename to ElementNamingUtils * Fix broken includes due to previous change * Revert constants from string to const char* * added childmap tests and made hasher public * Make functions private * Added remaining tests * removed bool return from `erase` functions * fix missing appexport Co-authored-by: John Dupuy <jdupuy98@gmail.com>
169 lines
5.2 KiB
C++
169 lines
5.2 KiB
C++
/***************************************************************************
|
|
* Copyright (c) 2002 Jürgen Riegel <juergen.riegel@web.de> *
|
|
* *
|
|
* This file is part of the FreeCAD CAx development system. *
|
|
* *
|
|
* This library is free software; you can redistribute it and/or *
|
|
* modify it under the terms of the GNU Library General Public *
|
|
* License as published by the Free Software Foundation; either *
|
|
* version 2 of the License, or (at your option) any later version. *
|
|
* *
|
|
* This library is distributed in the hope that it will be useful, *
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
* GNU Library General Public License for more details. *
|
|
* *
|
|
* You should have received a copy of the GNU Library General Public *
|
|
* License along with this library; see the file COPYING.LIB. If not, *
|
|
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
|
* Suite 330, Boston, MA 02111-1307, USA *
|
|
* *
|
|
***************************************************************************/
|
|
|
|
|
|
#include "PreCompiled.h"
|
|
|
|
#ifndef _PreComp_
|
|
# include <cstdlib>
|
|
#endif
|
|
|
|
#include <boost/regex.hpp>
|
|
|
|
#include "ComplexGeoData.h"
|
|
|
|
#include <Base/BoundBox.h>
|
|
#include <Base/Placement.h>
|
|
#include <Base/Rotation.h>
|
|
|
|
|
|
using namespace Data;
|
|
|
|
TYPESYSTEM_SOURCE_ABSTRACT(Data::Segment , Base::BaseClass)
|
|
|
|
|
|
TYPESYSTEM_SOURCE_ABSTRACT(Data::ComplexGeoData , Base::Persistence)
|
|
|
|
|
|
ComplexGeoData::ComplexGeoData()
|
|
:Tag(0)
|
|
{
|
|
}
|
|
|
|
ComplexGeoData::~ComplexGeoData() = default;
|
|
|
|
Data::Segment* ComplexGeoData::getSubElementByName(const char* name) const
|
|
{
|
|
int index = 0;
|
|
std::string element;
|
|
boost::regex ex("^([^0-9]*)([0-9]*)$");
|
|
boost::cmatch what;
|
|
|
|
if (boost::regex_match(name, what, ex)) {
|
|
element = what[1].str();
|
|
index = std::atoi(what[2].str().c_str());
|
|
}
|
|
|
|
return getSubElement(element.c_str(), static_cast<unsigned long>(index));
|
|
}
|
|
|
|
void ComplexGeoData::applyTransform(const Base::Matrix4D& rclTrf)
|
|
{
|
|
setTransform(rclTrf * getTransform());
|
|
}
|
|
|
|
void ComplexGeoData::applyTranslation(const Base::Vector3d& mov)
|
|
{
|
|
Base::Matrix4D mat;
|
|
mat.move(mov);
|
|
setTransform(mat * getTransform());
|
|
}
|
|
|
|
void ComplexGeoData::applyRotation(const Base::Rotation& rot)
|
|
{
|
|
Base::Matrix4D mat;
|
|
rot.getValue(mat);
|
|
setTransform(mat * getTransform());
|
|
}
|
|
|
|
void ComplexGeoData::setPlacement(const Base::Placement& rclPlacement)
|
|
{
|
|
setTransform(rclPlacement.toMatrix());
|
|
}
|
|
|
|
Base::Placement ComplexGeoData::getPlacement() const
|
|
{
|
|
Base::Matrix4D mat = getTransform();
|
|
|
|
return Base::Placement(Base::Vector3d(mat[0][3],
|
|
mat[1][3],
|
|
mat[2][3]),
|
|
Base::Rotation(mat));
|
|
}
|
|
|
|
double ComplexGeoData::getAccuracy() const
|
|
{
|
|
return 0.0;
|
|
}
|
|
|
|
void ComplexGeoData::getLinesFromSubElement(const Segment*,
|
|
std::vector<Base::Vector3d> &Points,
|
|
std::vector<Line> &lines) const
|
|
{
|
|
(void)Points;
|
|
(void)lines;
|
|
}
|
|
|
|
void ComplexGeoData::getFacesFromSubElement(const Segment*,
|
|
std::vector<Base::Vector3d> &Points,
|
|
std::vector<Base::Vector3d> &PointNormals,
|
|
std::vector<Facet> &faces) const
|
|
{
|
|
(void)Points;
|
|
(void)PointNormals;
|
|
(void)faces;
|
|
}
|
|
|
|
Base::Vector3d ComplexGeoData::getPointFromLineIntersection(const Base::Vector3f& base,
|
|
const Base::Vector3f& dir) const
|
|
{
|
|
(void)base;
|
|
(void)dir;
|
|
return Base::Vector3d();
|
|
}
|
|
|
|
void ComplexGeoData::getPoints(std::vector<Base::Vector3d> &Points,
|
|
std::vector<Base::Vector3d> &Normals,
|
|
double Accuracy, uint16_t flags) const
|
|
{
|
|
(void)Points;
|
|
(void)Normals;
|
|
(void)Accuracy;
|
|
(void)flags;
|
|
}
|
|
|
|
void ComplexGeoData::getLines(std::vector<Base::Vector3d> &Points,
|
|
std::vector<Line> &lines,
|
|
double Accuracy, uint16_t flags) const
|
|
{
|
|
(void)Points;
|
|
(void)lines;
|
|
(void)Accuracy;
|
|
(void)flags;
|
|
}
|
|
|
|
void ComplexGeoData::getFaces(std::vector<Base::Vector3d> &Points,
|
|
std::vector<Facet> &faces,
|
|
double Accuracy, uint16_t flags) const
|
|
{
|
|
(void)Points;
|
|
(void)faces;
|
|
(void)Accuracy;
|
|
(void)flags;
|
|
}
|
|
|
|
bool ComplexGeoData::getCenterOfGravity(Base::Vector3d&) const
|
|
{
|
|
return false;
|
|
}
|
|
|