KiCad PCB EDA Suite
Loading...
Searching...
No Matches
loadmodel.cpp File Reference
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <map>
#include <vector>
#include <wx/filename.h>
#include <wx/log.h>
#include <wx/stdpaths.h>
#include <wx/string.h>
#include <wx/utils.h>
#include <wx/wfstream.h>
#include <wx/zipstrm.h>
#include <advanced_config.h>
#include <decompress.hpp>
#include <TDocStd_Document.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <Quantity_Color.hxx>
#include <XCAFApp_Application.hxx>
#include <AIS_Shape.hxx>
#include <IGESControl_Reader.hxx>
#include <IGESCAFControl_Reader.hxx>
#include <Interface_Static.hxx>
#include <STEPControl_Reader.hxx>
#include <STEPCAFControl_Reader.hxx>
#include <XCAFDoc_DocumentTool.hxx>
#include <XCAFDoc_ColorTool.hxx>
#include <XCAFDoc_ShapeTool.hxx>
#include <BRep_Tool.hxx>
#include <BRepMesh_IncrementalMesh.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Compound.hxx>
#include <TopExp_Explorer.hxx>
#include <Poly_Triangulation.hxx>
#include <Poly_PolygonOnTriangulation.hxx>
#include <Precision.hxx>
#include <TDF_LabelSequence.hxx>
#include <TDF_ChildIterator.hxx>
#include <TDF_Tool.hxx>
#include <TDataStd_Name.hxx>
#include <Standard_Version.hxx>
#include "plugins/3dapi/ifsg_all.h"

Go to the source code of this file.

Classes

struct  DATA
 

Macros

#define MASK_OCE   wxT( "PLUGIN_OCE" )
 
#define MASK_OCE_EXTRA   wxT( "PLUGIN_OCE_EXTRA" )
 
#define OCC_COLOR_SPACE   Quantity_TOC_RGB
 

Typedefs

typedef std::map< std::size_t, SGNODE * > COLORMAP
 
typedef std::map< std::string, SGNODE * > FACEMAP
 
typedef std::map< std::string, std::vector< SGNODE * > > NODEMAP
 
typedef std::pair< std::string, std::vector< SGNODE * > > NODEITEM
 

Enumerations

enum  FormatType { FMT_NONE = 0 , FMT_STEP , FMT_STPZ , FMT_IGES }
 

Functions

bool processLabel (const TDF_Label &aLabel, DATA &aData, SGNODE *aParent, std::vector< SGNODE * > *aItems)
 
bool processFace (const TopoDS_Face &face, DATA &data, SGNODE *parent, std::vector< SGNODE * > *items, Quantity_ColorRGBA *color)
 
FormatType fileType (const char *aFileName)
 
void getTag (const TDF_Label &aLabel, std::string &aTag)
 Gets the absolute tag string for a given label in the form of ##:##:##:##.
 
static wxString getLabelName (const TDF_Label &aLabel)
 
std::string getShapeName (TopAbs_ShapeEnum aShape)
 Gets a string for a given TopAbs_ShapeEnum element.
 
static int colorFloatToDecimal (float aVal)
 
static std::ostream & operator<< (std::ostream &aOStream, const Quantity_ColorRGBA &aColor)
 
static void printLabel (TDF_Label aLabel, Handle(XCAFDoc_ShapeTool) aShapeTool, Handle(XCAFDoc_ColorTool) aColorTool, const char *aPreMsg=nullptr)
 Gets a string for a given TopAbs_ShapeEnum element.
 
static void dumpLabels (TDF_Label aLabel, Handle(XCAFDoc_ShapeTool) aShapeTool, Handle(XCAFDoc_ColorTool) aColorTool, int aDepth=0)
 Dumps a label and the entire tree underneath it.
 
bool getColor (DATA &data, TDF_Label label, Quantity_ColorRGBA &color)
 
void addItems (SGNODE *parent, std::vector< SGNODE * > *lp)
 
bool readIGES (Handle(TDocStd_Document) &m_doc, const char *fname)
 
bool readSTEP (Handle(TDocStd_Document)&m_doc, const char *fname)
 
bool readSTEPZ (Handle(TDocStd_Document)&m_doc, const char *aFileName)
 
SCENEGRAPHLoadModel (char const *filename)
 
bool processShell (const TopoDS_Shape &shape, DATA &data, SGNODE *parent, std::vector< SGNODE * > *items, Quantity_ColorRGBA *color)
 
bool processSolidOrShell (const TopoDS_Shape &shape, DATA &data, SGNODE *parent, std::vector< SGNODE * > *items)
 

Macro Definition Documentation

◆ MASK_OCE

#define MASK_OCE   wxT( "PLUGIN_OCE" )

Definition at line 89 of file loadmodel.cpp.

◆ MASK_OCE_EXTRA

#define MASK_OCE_EXTRA   wxT( "PLUGIN_OCE_EXTRA" )

Definition at line 90 of file loadmodel.cpp.

◆ OCC_COLOR_SPACE

#define OCC_COLOR_SPACE   Quantity_TOC_RGB

Definition at line 109 of file loadmodel.cpp.

Typedef Documentation

◆ COLORMAP

typedef std::map<std::size_t, SGNODE*> COLORMAP

Definition at line 92 of file loadmodel.cpp.

◆ FACEMAP

typedef std::map<std::string, SGNODE*> FACEMAP

Definition at line 93 of file loadmodel.cpp.

◆ NODEITEM

typedef std::pair<std::string, std::vector<SGNODE*> > NODEITEM

Definition at line 95 of file loadmodel.cpp.

◆ NODEMAP

typedef std::map<std::string, std::vector<SGNODE*> > NODEMAP

Definition at line 94 of file loadmodel.cpp.

Enumeration Type Documentation

◆ FormatType

enum FormatType
Enumerator
FMT_NONE 
FMT_STEP 
FMT_STPZ 
FMT_IGES 

Definition at line 275 of file loadmodel.cpp.

Function Documentation

◆ addItems()

void addItems ( SGNODE parent,
std::vector< SGNODE * > *  lp 
)

Definition at line 507 of file loadmodel.cpp.

References S3D::AddSGNodeChild(), S3D::AddSGNodeRef(), and S3D::GetSGNodeParent().

Referenced by processSolidOrShell().

◆ colorFloatToDecimal()

static int colorFloatToDecimal ( float  aVal)
static

Definition at line 396 of file loadmodel.cpp.

Referenced by operator<<().

◆ dumpLabels()

static void dumpLabels ( TDF_Label  aLabel,
Handle(XCAFDoc_ShapeTool)  aShapeTool,
Handle(XCAFDoc_ColorTool)  aColorTool,
int  aDepth = 0 
)
static

Dumps a label and the entire tree underneath it.

Parameters
aLabelLabel to convert
aShapeToolHandle to shape tool being used
aColorToolHandle to color tool being used
aDepthIndentation level to offset labels (used recursively by dumpLabels)

Definition at line 475 of file loadmodel.cpp.

References dumpLabels(), and printLabel().

Referenced by dumpLabels(), and LoadModel().

◆ fileType()

FormatType fileType ( const char *  aFileName)

Definition at line 284 of file loadmodel.cpp.

References FMT_IGES, FMT_NONE, FMT_STEP, and FMT_STPZ.

Referenced by LoadModel().

◆ getColor()

bool getColor ( DATA data,
TDF_Label  label,
Quantity_ColorRGBA &  color 
)

Definition at line 486 of file loadmodel.cpp.

References color, and DATA::GetColor().

Referenced by processSolidOrShell().

◆ getLabelName()

static wxString getLabelName ( const TDF_Label &  aLabel)
static

Definition at line 355 of file loadmodel.cpp.

References name.

Referenced by printLabel().

◆ getShapeName()

std::string getShapeName ( TopAbs_ShapeEnum  aShape)

Gets a string for a given TopAbs_ShapeEnum element.

Parameters
aShapeenum value to convert

Definition at line 378 of file loadmodel.cpp.

Referenced by printLabel().

◆ getTag()

void getTag ( const TDF_Label &  aLabel,
std::string &  aTag 
)

Gets the absolute tag string for a given label in the form of ##:##:##:##.

Parameters
aLabelis the label to get the string for
aTagis the resulting tag string based by reference

Definition at line 331 of file loadmodel.cpp.

References MASK_OCE.

Referenced by processFace(), processLabel(), and processSolidOrShell().

◆ LoadModel()

◆ operator<<()

static std::ostream & operator<< ( std::ostream &  aOStream,
const Quantity_ColorRGBA &  aColor 
)
inlinestatic

Definition at line 402 of file loadmodel.cpp.

References colorFloatToDecimal().

◆ printLabel()

static void printLabel ( TDF_Label  aLabel,
Handle(XCAFDoc_ShapeTool)  aShapeTool,
Handle(XCAFDoc_ColorTool)  aColorTool,
const char *  aPreMsg = nullptr 
)
static

Gets a string for a given TopAbs_ShapeEnum element.

Parameters
aLabelLabel to convert
aShapeToolHandle to shape tool being used
aColorToolHandle to color tool being used
aPregMsgAny prefixed message to insert (used for indentation in dump)

Definition at line 422 of file loadmodel.cpp.

References getLabelName(), getShapeName(), and MASK_OCE.

Referenced by dumpLabels().

◆ processFace()

◆ processLabel()

bool processLabel ( const TDF_Label &  aLabel,
DATA aData,
SGNODE aParent,
std::vector< SGNODE * > *  aItems 
)

◆ processShell()

bool processShell ( const TopoDS_Shape &  shape,
DATA data,
SGNODE parent,
std::vector< SGNODE * > *  items,
Quantity_ColorRGBA *  color 
)

Definition at line 790 of file loadmodel.cpp.

References color, MASK_OCE, and processFace().

Referenced by processSolidOrShell().

◆ processSolidOrShell()

bool processSolidOrShell ( const TopoDS_Shape &  shape,
DATA data,
SGNODE parent,
std::vector< SGNODE * > *  items 
)

◆ readIGES()

bool readIGES ( Handle(TDocStd_Document) &  m_doc,
const char *  fname 
)

Definition at line 530 of file loadmodel.cpp.

Referenced by LoadModel().

◆ readSTEP()

bool readSTEP ( Handle(TDocStd_Document)&  m_doc,
const char *  fname 
)

Definition at line 569 of file loadmodel.cpp.

References ADVANCED_CFG::GetCfg(), and MASK_OCE.

Referenced by LoadModel(), and readSTEPZ().

◆ readSTEPZ()

bool readSTEPZ ( Handle(TDocStd_Document)&  m_doc,
const char *  aFileName 
)

Definition at line 613 of file loadmodel.cpp.

References readSTEP().

Referenced by LoadModel().