// SPDX-License-Identifier: LGPL-2.1-or-later /*************************************************************************** * Copyright (c) 2013 Werner Mayer * * * * 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 * * * ***************************************************************************/ #ifndef IMPORT_IMPORTOCAF_H #define IMPORT_IMPORTOCAF_H #include #include #include #include #include #include #include #include #include #include #include #include class TDF_Label; class TopLoc_Location; namespace App { class Document; class DocumentObject; } // namespace App namespace Part { class Feature; } namespace Import { class ImportExport ImportOCAF { public: ImportOCAF(Handle(TDocStd_Document) h, App::Document* d, const std::string& name); virtual ~ImportOCAF(); void loadShapes(); void setMerge(bool); private: void loadShapes( const TDF_Label& label, const TopLoc_Location&, const std::string& partname, const std::string& assembly, bool isRef, std::vector& ); void createShape( const TDF_Label& label, const TopLoc_Location&, const std::string&, std::vector&, bool ); void createShape( const TopoDS_Shape& label, const TopLoc_Location&, const std::string&, std::vector& ); void loadColors(Part::Feature* part, const TopoDS_Shape& aShape); virtual void applyColors(Part::Feature*, const std::vector&) {} static void tryPlacementFromLoc(App::GeoFeature*, const TopLoc_Location&); static void tryPlacementFromMatrix(App::GeoFeature*, const Base::Matrix4D&); private: Handle(TDocStd_Document) pDoc; App::Document* doc; Handle(XCAFDoc_ShapeTool) aShapeTool; Handle(XCAFDoc_ColorTool) aColorTool; bool merge {true}; std::string default_name; std::set myRefShapes; }; class ImportExport ImportOCAFCmd: public ImportOCAF { public: ImportOCAFCmd(Handle(TDocStd_Document) h, App::Document* d, const std::string& name); std::map> getPartColorsMap() const { return partColors; } private: void applyColors(Part::Feature* part, const std::vector& colors) override; private: std::map> partColors; }; class ImportXCAF { public: ImportXCAF(Handle(TDocStd_Document) h, App::Document* d, const std::string& name); virtual ~ImportXCAF(); void loadShapes(); private: void createShape(const TopoDS_Shape& shape, bool perface = false, bool setname = false) const; void loadShapes(const TDF_Label& label); virtual void applyColors(Part::Feature*, const std::vector&) {} private: Handle(TDocStd_Document) hdoc; App::Document* doc; Handle(XCAFDoc_ShapeTool) aShapeTool; Handle(XCAFDoc_ColorTool) hColors; std::string default_name; std::map mySolids; std::map myShells; std::map myCompds; std::map myShapes; std::map myColorMap; std::map myNameMap; }; } // namespace Import #endif // IMPORT_IMPORTOCAF_H