31#include <unordered_map> 
   36#include <TopoDS_Shape.hxx> 
   37#include <TDocStd_Document.hxx> 
   38#include <Standard_Handle.hxx> 
   39#include <Graphic3d_Vec4.hxx> 
   40#include <Graphic3d_Vec3.hxx> 
   42#include <XCAFDoc_ShapeTool.hxx> 
   43#include <XCAFDoc_ColorTool.hxx> 
   44#include <XCAFDoc_VisMaterialTool.hxx> 
   49#include <wx/mstream.h> 
   54struct hash<Graphic3d_Vec4>
 
   58        size_t h1 = std::hash<float>{}( v.x() );
 
   59        size_t h2 = std::hash<float>{}( v.y() );
 
   60        size_t h3 = std::hash<float>{}( v.z() );
 
   61        size_t h4 = std::hash<float>{}( v.w() );
 
   62        return h1 ^ ( h2 << 1 ) ^ ( h3 << 2 ) ^ ( h4 << 3 );
 
 
 
  143        uint32_t colorIndex = 0;
 
 
  160        uint32_t colorIndex = 0;
 
 
 
  205    WRITER( 
const std::string& aFilename );
 
  207    bool Perform( 
const Handle( TDocStd_Document ) & aDocument );
 
  214    std::shared_ptr<DATA_BLOCK> 
getGroupNodeBlock( 
const std::string& aGroupNodeName,
 
  217    std::shared_ptr<DATA_BLOCK> 
getModelNodeBlock( 
const std::string&        aModelNodeName,
 
  218                                                   const std::string&        aParentNodeName,
 
  219                                                   const std::string&        aModelResourceName,
 
  220                                                   const std::vector<float>& aMat );
 
  223                                                         const std::string& aShaderName );
 
  225    std::shared_ptr<DATA_BLOCK>
 
  227                          const std::string& aParentNodeName, 
const std::string& aModelResourceName,
 
  228                          const std::string& aShaderName, 
const std::vector<float>& aMat );
 
  231    std::shared_ptr<DATA_BLOCK> 
getHeaderBlock( uint32_t aDeclSize, uint32_t aContSize );
 
  235                                                          const std::string& aMaterialName );
 
  239                                                          const Graphic3d_Vec4& aDiffuseColor,
 
  240                                                          const Graphic3d_Vec3& aSpecularColor );
 
  242    std::shared_ptr<DATA_BLOCK>
 
  244                                   const std::string& aMeshname );
 
  247                                                         const std::string& aMeshName );
 
  250                                                          const std::string& aMeshName );
 
  254                                                       const std::string& aLightResourceName );
 
  256    std::shared_ptr<DATA_BLOCK> 
getLightNodeBlock( 
const std::string& aLightNodeName,
 
  257                                                   const std::string& aLightResourceName );
 
  261    std::shared_ptr<DATA_BLOCK>
 
  263                               const std::vector<GROUP_NODE>& aGroupNodes );
 
  265    uint32_t 
writeDataBlock( std::shared_ptr<DATA_BLOCK> b, wxMemoryOutputStream& aStream );
 
  271                                   const Handle( XCAFDoc_ColorTool ) & colorTool,
 
  272                                   const Handle( XCAFDoc_VisMaterialTool ) & visMatTool,
 
  273                                   const gp_Trsf&    cumulativeTransform,
 
  274                                   const std::string& baseName,
 
  275                                   std::unordered_map<Graphic3d_Vec4, MESH*>& meshesByColor );
 
 
Implements the bit stream writer functionality.
 
Graphic3d_Vec3 specular_color
Specular color used if not using per-vertex color.
 
std::vector< uint32_t > normalIndices
Coordinate indices, maps vertex normal positions to triangles.
 
std::vector< uint32_t > specularColorIndices
Coordinate indices, maps each vertex to a specular color.
 
std::vector< VECTOR3D > normals
 
std::vector< Graphic3d_Vec4 > diffuse_colors
List of all unique diffuse colors.
 
std::unordered_map< Graphic3d_Vec4, uint32_t > specular_colors_index_map
Index map helps select the color index for a given vertex when creating the colorIndices.
 
uint32_t GetOrAddUniqueSpecularColor(const Graphic3d_Vec4 &aColor)
 
std::vector< uint32_t > coordIndices
Coordinate indices, maps vertex positions to triangles.
 
std::unordered_map< Graphic3d_Vec4, uint32_t > diffuse_colors_index_map
Index map helps select the color index for a given vertex when creating the colorIndices.
 
std::vector< uint32_t > diffuseColorIndices
Coordinate indices, maps each vertex to a diffuse color.
 
std::string name
The name of the mesh, this will be visible in U3D viewers.
 
std::vector< VECTOR3D > coords
 
uint32_t GetOrAddUniqueDiffuseColor(const Graphic3d_Vec4 &aColor)
 
Graphic3d_Vec4 diffuse_color
Diffuse color used if not using per-vertex color.
 
std::vector< Graphic3d_Vec4 > specular_colors
List of all unique specular colors.
 
std::string parentName
Parent name (if any) to group the mesh under.
 
std::vector< GROUP_NODE > m_groupNodes
 
std::shared_ptr< DATA_BLOCK > getHeaderBlock(uint32_t aDeclSize, uint32_t aContSize)
 
std::shared_ptr< DATA_BLOCK > getShadingModifierBlock(const std::string &aShadingModName, const std::string &aShaderName)
 
std::shared_ptr< DATA_BLOCK > getLitTextureShaderBlock(const std::string &aShaderName, const std::string &aMaterialName)
 
void writeMatrix(BIT_STREAM_WRITER &aBitStreamWriter, const std::vector< float > &aMat)
 
bool Perform(const Handle(TDocStd_Document) &aDocument)
 
std::shared_ptr< DATA_BLOCK > getModelNodeBlock(const std::string &aModelNodeName, const std::string &aParentNodeName, const std::string &aModelResourceName, const std::vector< float > &aMat)
 
void getMeshName(const TDF_Label &label, Handle(XCAFDoc_ShapeTool) shapeTool, MESH *mesh)
 
WRITER(const std::string &aFilename)
 
const uint32_t m_contextBaseShadingID
 
std::shared_ptr< DATA_BLOCK > getMeshContinuationBlock(const MESH *aMesh, const std::string &aMeshName)
 
void generateMeshesByAssembly(const Handle(TDocStd_Document) &doc)
 
std::shared_ptr< DATA_BLOCK > getLightNodeBlock(const std::string &aLightNodeName, const std::string &aLightResourceName)
 
std::shared_ptr< DATA_BLOCK > getModelResourceModifierChain(const std::string &aModifierChainName, const MESH *aMesh, const std::string &aMeshname)
 
std::shared_ptr< DATA_BLOCK > getMaterialResourceBlock(const std::string &aMaterialName, const Graphic3d_Vec4 &aDiffuseColor, const Graphic3d_Vec3 &aSpecularColor)
 
const VECTOR3D & GetCenter() const
 
std::shared_ptr< DATA_BLOCK > getGroupNodeModifierChain(const std::string &aModifierChainName, const std::vector< GROUP_NODE > &aGroupNodes)
 
std::vector< std::unique_ptr< MESH > > m_meshes
 
std::shared_ptr< DATA_BLOCK > getLightModifierChain(const std::string &aModifierChainName, const std::string &aLightResourceName)
 
void collectGeometryRecursive(const TDF_Label &label, const Handle(XCAFDoc_ShapeTool) &shapeTool, const Handle(XCAFDoc_ColorTool) &colorTool, const Handle(XCAFDoc_VisMaterialTool) &visMatTool, const gp_Trsf &cumulativeTransform, const std::string &baseName, std::unordered_map< Graphic3d_Vec4, MESH * > &meshesByColor)
 
std::shared_ptr< DATA_BLOCK > getLightResourceBlock(const std::string &aLightResourceName)
 
uint32_t writeDataBlock(std::shared_ptr< DATA_BLOCK > b, wxMemoryOutputStream &aStream)
 
std::map< std::string, int > m_meshDedupMap
 
std::shared_ptr< DATA_BLOCK > getNodeModifierChain(const std::string &aModifierChainName, const std::string &aModelNodeName, const std::string &aParentNodeName, const std::string &aModelResourceName, const std::string &aShaderName, const std::vector< float > &aMat)
 
std::shared_ptr< DATA_BLOCK > getGroupNodeBlock(const std::string &aGroupNodeName, const PARENT_NODE *aParentNode)
 
const Bnd_Box & GetMeshBoundingBox() const
 
Bnd_Box m_meshBoundingBox
 
std::shared_ptr< DATA_BLOCK > getMeshDeclarationBlock(const MESH *aMesh, const std::string &aMeshName)
 
Handle(KICAD3D_INFO) KICAD3D_INFO
 
std::vector< PARENT_NODE > parentNodes
List of parent nodes this group node belongs to.
 
std::string name
Name of this group node.
 
std::vector< float > mat
Transform matrix, 4x4, row major.
 
std::string name
Name of the parent node to link to.
 
size_t operator()(const Graphic3d_Vec4 &v) const
 
VECTOR3< double > VECTOR3D