| |
|
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| |
|
| |
|
| | #ifndef APP_COMPLEX_GEO_DATA_H
|
| | #define APP_COMPLEX_GEO_DATA_H
|
| |
|
| | #include <algorithm>
|
| | #include <optional>
|
| |
|
| | #include <Base/Handle.h>
|
| | #include <Base/Matrix.h>
|
| | #include <Base/Persistence.h>
|
| | #include "MappedName.h"
|
| | #include "MappedElement.h"
|
| | #include "ElementMap.h"
|
| | #include "StringHasher.h"
|
| |
|
| | #ifdef __GNUC__
|
| | #include <cstdint>
|
| | #endif
|
| |
|
| |
|
| | namespace Base
|
| | {
|
| | class Placement;
|
| | class Rotation;
|
| | template<class _Precision>
|
| | class BoundBox3;
|
| | using BoundBox3d = BoundBox3<double>;
|
| | }
|
| |
|
| | namespace Data
|
| | {
|
| |
|
| |
|
| |
|
| | enum class SearchOption
|
| | {
|
| |
|
| | CheckGeometry = 1,
|
| | SingleResult = 2,
|
| | };
|
| | typedef Base::Flags<SearchOption> SearchOptions;
|
| |
|
| | |
| | |
| | |
| |
|
| | class AppExport Segment: public Base::BaseClass
|
| | {
|
| | TYPESYSTEM_HEADER_WITH_OVERRIDE();
|
| |
|
| | public:
|
| | ~Segment() override = default;
|
| | virtual std::string getName() const = 0;
|
| | };
|
| |
|
| | enum ElementMapResetPolicy
|
| | {
|
| | AllowNoMap,
|
| | ForceEmptyMap
|
| | };
|
| |
|
| | |
| |
|
| | class AppExport ComplexGeoData: public Base::Persistence, public Base::Handled
|
| | {
|
| | TYPESYSTEM_HEADER_WITH_OVERRIDE();
|
| |
|
| | public:
|
| | struct Line
|
| | {
|
| | uint32_t I1;
|
| | uint32_t I2;
|
| | };
|
| | struct Facet
|
| | {
|
| | uint32_t I1;
|
| | uint32_t I2;
|
| | uint32_t I3;
|
| | };
|
| | struct Domain
|
| | {
|
| | std::vector<Base::Vector3d> points;
|
| | std::vector<Facet> facets;
|
| | };
|
| |
|
| |
|
| | ComplexGeoData();
|
| |
|
| | ~ComplexGeoData() override = default;
|
| |
|
| |
|
| |
|
| | |
| | |
| | |
| |
|
| | virtual std::vector<const char*> getElementTypes() const = 0;
|
| | virtual unsigned long countSubElements(const char* Type) const = 0;
|
| |
|
| |
|
| | static std::pair<std::string, unsigned long> getTypeAndIndex(const char* Name);
|
| |
|
| | virtual Segment* getSubElement(const char* Type, unsigned long) const = 0;
|
| |
|
| | virtual Segment* getSubElementByName(const char* Name) const;
|
| |
|
| | virtual void getLinesFromSubElement(const Segment*,
|
| | std::vector<Base::Vector3d>& Points,
|
| | std::vector<Line>& lines) const;
|
| |
|
| | virtual void getFacesFromSubElement(const Segment*,
|
| | std::vector<Base::Vector3d>& Points,
|
| | std::vector<Base::Vector3d>& PointNormals,
|
| | std::vector<Facet>& faces) const;
|
| |
|
| |
|
| |
|
| |
|
| |
|
| | void applyTransform(const Base::Matrix4D& rclTrf);
|
| |
|
| | void applyTranslation(const Base::Vector3d&);
|
| |
|
| | void applyRotation(const Base::Rotation&);
|
| | |
| | |
| |
|
| | void setPlacement(const Base::Placement& rclPlacement);
|
| | |
| | |
| |
|
| | Base::Placement getPlacement() const;
|
| | |
| | |
| | |
| |
|
| | virtual void setTransform(const Base::Matrix4D& rclTrf) = 0;
|
| | |
| | |
| | |
| |
|
| | virtual Base::Matrix4D getTransform() const = 0;
|
| |
|
| |
|
| |
|
| |
|
| |
|
| | virtual void transformGeometry(const Base::Matrix4D& rclMat) = 0;
|
| |
|
| |
|
| |
|
| |
|
| |
|
| | virtual double getAccuracy() const;
|
| |
|
| | virtual Base::BoundBox3d getBoundBox() const = 0;
|
| |
|
| | virtual Base::Vector3d getPointFromLineIntersection(const Base::Vector3f& base,
|
| | const Base::Vector3f& dir) const;
|
| |
|
| | virtual void getPoints(std::vector<Base::Vector3d>& Points,
|
| | std::vector<Base::Vector3d>& Normals,
|
| | double Accuracy,
|
| | uint16_t flags = 0) const;
|
| |
|
| | virtual void getLines(std::vector<Base::Vector3d>& Points,
|
| | std::vector<Line>& lines,
|
| | double Accuracy,
|
| | uint16_t flags = 0) const;
|
| |
|
| | virtual void getFaces(std::vector<Base::Vector3d>& Points,
|
| | std::vector<Facet>& faces,
|
| | double Accuracy,
|
| | uint16_t flags = 0) const;
|
| | |
| | |
| | |
| |
|
| | virtual bool getCenterOfGravity(Base::Vector3d& center) const;
|
| | virtual std::optional<Base::Vector3d> centerOfGravity() const;
|
| |
|
| |
|
| | static const std::string& elementMapPrefix();
|
| |
|
| |
|
| |
|
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | IndexedName getIndexedName(const MappedName& name, ElementIDRefs* sid = nullptr) const;
|
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | MappedName getMappedName(const IndexedName& element,
|
| | bool allowUnmapped = false,
|
| | ElementIDRefs* sid = nullptr) const;
|
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | MappedElement
|
| | getElementName(const char* name, ElementIDRefs* sid = nullptr, bool copy = false) const;
|
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | MappedName setElementName(const IndexedName& element,
|
| | const MappedName& name,
|
| | long masterTag,
|
| | const ElementIDRefs* sid = nullptr,
|
| | bool overwrite = false)
|
| | {
|
| | return _elementMap->setElementName(element, name, masterTag, sid, overwrite);
|
| | }
|
| |
|
| | bool hasElementMap() const
|
| | {
|
| | return _elementMap != nullptr;
|
| | }
|
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | std::vector<std::pair<MappedName, ElementIDRefs>>
|
| | getElementMappedNames(const IndexedName& element, bool needUnmapped = false) const;
|
| |
|
| |
|
| | void hashChildMaps();
|
| |
|
| |
|
| | bool hasChildElementMap() const;
|
| |
|
| |
|
| | virtual void
|
| | reTagElementMap(long tag, App::StringHasherRef hasher, const char* postfix = nullptr)
|
| | {
|
| | (void)tag;
|
| | (void)hasher;
|
| | (void)postfix;
|
| | }
|
| |
|
| |
|
| | long getElementHistory(const MappedName& name,
|
| | MappedName* original = nullptr,
|
| | std::vector<MappedName>* history = nullptr) const
|
| | {
|
| | if (_elementMap != nullptr) {
|
| | return _elementMap->getElementHistory(name, Tag, original, history);
|
| | }
|
| | return 0;
|
| | };
|
| |
|
| | void setMappedChildElements(const std::vector<Data::ElementMap::MappedChildElements>& children);
|
| | std::vector<Data::ElementMap::MappedChildElements> getMappedChildElements() const;
|
| |
|
| | char elementType(const Data::MappedName&) const;
|
| | char elementType(const Data::IndexedName&) const;
|
| | char elementType(const char* name) const;
|
| |
|
| | |
| | |
| | |
| | |
| | |
| |
|
| | virtual ElementMapPtr resetElementMap(ElementMapPtr elementMap = ElementMapPtr());
|
| |
|
| |
|
| | std::vector<MappedElement> getElementMap() const;
|
| |
|
| |
|
| | void setElementMap(const std::vector<MappedElement>& elements);
|
| |
|
| |
|
| | size_t getElementMapSize(bool flush = true) const;
|
| |
|
| |
|
| | virtual std::vector<IndexedName> getHigherElements(const char* name, bool silent = false) const;
|
| |
|
| |
|
| | virtual std::string getElementMapVersion() const;
|
| |
|
| |
|
| | virtual bool checkElementMapVersion(const char* ver) const;
|
| |
|
| |
|
| | static bool isElementName(const char* subName)
|
| | {
|
| | return (subName != nullptr) && (*subName != 0) && findElementName(subName) == subName;
|
| | }
|
| |
|
| | |
| | |
| | |
| | |
| | |
| |
|
| | void traceElement(const MappedName& name, TraceCallback cb) const
|
| | {
|
| | _elementMap->traceElement(name, Tag, std::move(cb));
|
| | }
|
| |
|
| |
|
| | virtual void flushElementMap() const;
|
| |
|
| |
|
| |
|
| |
|
| | void Save(Base::Writer& writer) const override;
|
| | void Restore(Base::XMLReader& reader) override;
|
| | void SaveDocFile(Base::Writer& writer) const override;
|
| | void RestoreDocFile(Base::Reader& reader) override;
|
| | unsigned int getMemSize() const override;
|
| | void setPersistenceFileName(const char* name) const;
|
| | virtual void beforeSave() const;
|
| | bool isRestoreFailed() const
|
| | {
|
| | return _restoreFailed;
|
| | }
|
| | void resetRestoreFailure() const
|
| | {
|
| | _restoreFailed = true;
|
| | }
|
| |
|
| |
|
| | |
| | |
| | |
| |
|
| | void dumpElementMap(std::ostream& stream) const;
|
| | |
| | |
| | |
| |
|
| | const std::string dumpElementMap() const;
|
| |
|
| | protected:
|
| |
|
| | inline Base::Vector3d transformPointToOutside(const Base::Vector3f& vec) const
|
| | {
|
| |
|
| | return getTransform() * Base::Vector3d(static_cast<double>(vec.x),
|
| | static_cast<double>(vec.y),
|
| | static_cast<double>(vec.z));
|
| |
|
| | }
|
| |
|
| | template<typename Vec>
|
| | inline std::vector<Base::Vector3d> transformPointsToOutside(const std::vector<Vec>& input) const
|
| | {
|
| |
|
| | std::vector<Base::Vector3d> output;
|
| | output.reserve(input.size());
|
| | Base::Matrix4D mat(getTransform());
|
| | std::transform(input.cbegin(), input.cend(), std::back_inserter(output),
|
| | [&mat](const Vec& vec) {
|
| | return mat * Base::Vector3d(static_cast<double>(vec.x),
|
| | static_cast<double>(vec.y),
|
| | static_cast<double>(vec.z));
|
| | });
|
| |
|
| | return output;
|
| |
|
| | }
|
| | inline Base::Vector3d transformVectorToOutside(const Base::Vector3f& vec) const
|
| | {
|
| |
|
| | Base::Matrix4D mat(getTransform());
|
| | mat.setCol(3, Base::Vector3d());
|
| | return mat * Base::Vector3d(static_cast<double>(vec.x),
|
| | static_cast<double>(vec.y),
|
| | static_cast<double>(vec.z));
|
| |
|
| | }
|
| | template<typename Vec>
|
| | std::vector<Base::Vector3d> transformVectorsToOutside(const std::vector<Vec>& input) const
|
| | {
|
| |
|
| | std::vector<Base::Vector3d> output;
|
| | output.reserve(input.size());
|
| | Base::Matrix4D mat(getTransform());
|
| | mat.setCol(3, Base::Vector3d());
|
| | std::transform(input.cbegin(), input.cend(), std::back_inserter(output),
|
| | [&mat](const Vec& vec) {
|
| | return mat * Base::Vector3d(static_cast<double>(vec.x),
|
| | static_cast<double>(vec.y),
|
| | static_cast<double>(vec.z));
|
| | });
|
| |
|
| | return output;
|
| |
|
| | }
|
| |
|
| | inline Base::Vector3f transformPointToInside(const Base::Vector3d& vec) const
|
| | {
|
| | Base::Matrix4D tmpM(getTransform());
|
| | tmpM.inverse();
|
| | Base::Vector3d tmp = tmpM * vec;
|
| | return Base::Vector3f(static_cast<float>(tmp.x),
|
| | static_cast<float>(tmp.y),
|
| | static_cast<float>(tmp.z));
|
| | }
|
| |
|
| | public:
|
| | mutable long Tag {0};
|
| |
|
| |
|
| | mutable App::StringHasherRef Hasher;
|
| |
|
| | protected:
|
| | void restoreStream(std::istream& stream, std::size_t count);
|
| | void readElements(Base::XMLReader& reader, size_t count);
|
| |
|
| |
|
| | inline Base::Vector3d transformToOutside(const Base::Vector3f& vec) const
|
| | {
|
| |
|
| | return getTransform() * Base::Vector3d(static_cast<double>(vec.x),
|
| | static_cast<double>(vec.y),
|
| | static_cast<double>(vec.z));
|
| |
|
| | }
|
| |
|
| | inline Base::Vector3f transformToInside(const Base::Vector3d& vec) const
|
| | {
|
| | Base::Matrix4D tmpM(getTransform());
|
| | tmpM.inverse();
|
| | Base::Vector3d tmp = tmpM * vec;
|
| | return Base::Vector3f(static_cast<float>(tmp.x),
|
| | static_cast<float>(tmp.y),
|
| | static_cast<float>(tmp.z));
|
| | }
|
| |
|
| | protected:
|
| | ElementMapPtr elementMap(bool flush = true) const;
|
| | ElementMapPtr ensureElementMap(bool flush = true);
|
| |
|
| | private:
|
| | ElementMapPtr _elementMap;
|
| |
|
| | protected:
|
| | mutable std::string _persistenceName;
|
| | mutable bool _restoreFailed = false;
|
| | };
|
| |
|
| | }
|
| |
|
| | ENABLE_BITMASK_OPERATORS(Data::SearchOption)
|
| | #endif
|
| |
|