Browse Source

Replace more usages of some types removed/deprecated in OCCT 8.0.0

Fixes https://gitlab.com/kicad/code/kicad/-/work_items/24281


(cherry picked from commit 3d9ea9cb63)

Co-authored-by: Alex Shvartzkop <dudesuchamazing@gmail.com>
10.0
dsa-t 3 months ago
parent
commit
280acb0da7
  1. 38
      pcbnew/exporters/step/KI_XCAFDoc_AssemblyGraph.cxx
  2. 38
      pcbnew/exporters/step/KI_XCAFDoc_AssemblyGraph.hxx
  3. 20
      pcbnew/exporters/step/step_pcb_model.cpp
  4. 42
      pcbnew/exporters/u3d/writer.cpp
  5. 30
      pcbnew/exporters/u3d/writer.h
  6. 7
      plugins/3d/oce/loadmodel.cpp

38
pcbnew/exporters/step/KI_XCAFDoc_AssemblyGraph.cxx

@ -13,7 +13,7 @@
// commercial license or contractual agreement.
#include <Standard_NullObject.hxx>
#include <TColStd_MapIteratorOfPackedMapOfInteger.hxx>
#include <TColStd_PackedMapOfInteger.hxx>
#include <TDataStd_TreeNode.hxx>
#include <TDF_ChildIterator.hxx>
#include <TDF_Tool.hxx>
@ -59,8 +59,8 @@ KI_XCAFDoc_AssemblyGraph::KI_XCAFDoc_AssemblyGraph(const TDF_Label& theLabel)
// purpose : Checks if one node is the direct child of other one
// =======================================================================
bool KI_XCAFDoc_AssemblyGraph::IsDirectLink(const Standard_Integer theNode1,
const Standard_Integer theNode2) const
bool KI_XCAFDoc_AssemblyGraph::IsDirectLink(const int theNode1,
const int theNode2) const
{
if (!HasChildren(theNode1))
return false;
@ -74,7 +74,7 @@ bool KI_XCAFDoc_AssemblyGraph::IsDirectLink(const Standard_Integer theNode1,
// =======================================================================
KI_XCAFDoc_AssemblyGraph::NodeType
KI_XCAFDoc_AssemblyGraph::GetNodeType(const Standard_Integer theNode) const
KI_XCAFDoc_AssemblyGraph::GetNodeType(const int theNode) const
{
const NodeType* typePtr = myNodeTypes.Seek(theNode);
if (typePtr == NULL)
@ -88,9 +88,9 @@ KI_XCAFDoc_AssemblyGraph::GetNodeType(const Standard_Integer theNode) const
// purpose : Calculates and returns the number of links
// =======================================================================
Standard_Integer KI_XCAFDoc_AssemblyGraph::NbLinks() const
int KI_XCAFDoc_AssemblyGraph::NbLinks() const
{
Standard_Integer aNumLinks = 0;
int aNumLinks = 0;
for (AdjacencyMap::Iterator it(myAdjacencyMap); it.More(); it.Next())
{
aNumLinks += it.Value().Extent();
@ -103,9 +103,9 @@ Standard_Integer KI_XCAFDoc_AssemblyGraph::NbLinks() const
// purpose :
// =======================================================================
Standard_Integer KI_XCAFDoc_AssemblyGraph::NbOccurrences(const Standard_Integer theNode) const
int KI_XCAFDoc_AssemblyGraph::NbOccurrences(const int theNode) const
{
const Standard_Integer* aUsageOQPtr = myUsages.Seek(theNode);
const int* aUsageOQPtr = myUsages.Seek(theNode);
if (aUsageOQPtr == NULL)
return 0;
@ -120,13 +120,13 @@ Standard_Integer KI_XCAFDoc_AssemblyGraph::NbOccurrences(const Standard_Integer
void KI_XCAFDoc_AssemblyGraph::buildGraph(const TDF_Label& theLabel)
{
// We start from those shapes which are "free" in terms of XDE.
TDF_LabelSequence aRoots;
NCollection_Sequence<TDF_Label> aRoots;
if (theLabel.IsNull() || (myShapeTool->Label() == theLabel))
myShapeTool->GetFreeShapes(aRoots);
else
aRoots.Append(theLabel);
for (TDF_LabelSequence::Iterator it(aRoots); it.More(); it.Next())
for (NCollection_Sequence<TDF_Label>::Iterator it(aRoots); it.More(); it.Next())
{
TDF_Label aLabel = it.Value();
@ -134,7 +134,7 @@ void KI_XCAFDoc_AssemblyGraph::buildGraph(const TDF_Label& theLabel)
if (!myShapeTool->GetReferredShape(aLabel, anOriginal))
anOriginal = aLabel;
const Standard_Integer aRootId = addNode(anOriginal, 0);
const int aRootId = addNode(anOriginal, 0);
if (aRootId == 0)
continue;
@ -152,7 +152,7 @@ void KI_XCAFDoc_AssemblyGraph::buildGraph(const TDF_Label& theLabel)
// =======================================================================
void KI_XCAFDoc_AssemblyGraph::addComponents(const TDF_Label& theParent,
const Standard_Integer theParentId)
const int theParentId)
{
if (!myShapeTool->IsShape(theParent))
{
@ -168,7 +168,7 @@ void KI_XCAFDoc_AssemblyGraph::addComponents(const TDF_Label& theParent,
TDF_Label aComponent = anIt.Value();
// Add component
const Standard_Integer aComponentId = addNode(aComponent, theParentId);
const int aComponentId = addNode(aComponent, theParentId);
if (aComponentId == 0)
continue;
@ -186,7 +186,7 @@ void KI_XCAFDoc_AssemblyGraph::addComponents(const TDF_Label& theParent,
continue;
// Add child
const Standard_Integer aChildId = addNode(aChildOriginal, aComponentId);
const int aChildId = addNode(aChildOriginal, aComponentId);
if (aChildId == 0)
continue;
@ -200,8 +200,8 @@ void KI_XCAFDoc_AssemblyGraph::addComponents(const TDF_Label& theParent,
// purpose : Adds node into the graph
// =======================================================================
Standard_Integer KI_XCAFDoc_AssemblyGraph::addNode(const TDF_Label& theLabel,
const Standard_Integer theParentId)
int KI_XCAFDoc_AssemblyGraph::addNode(const TDF_Label& theLabel,
const int theParentId)
{
NodeType aNodeType = NodeType_UNDEFINED;
if (myShapeTool->IsAssembly(theLabel))
@ -228,13 +228,13 @@ Standard_Integer KI_XCAFDoc_AssemblyGraph::addNode(const TDF_Label& theLab
return 0;
// Get ID of the insertion-level node in the abstract assembly graph.
const Standard_Integer aChildId = myNodes.Add(theLabel);
const int aChildId = myNodes.Add(theLabel);
myNodeTypes.Bind(aChildId, aNodeType);
if (aNodeType != NodeType_Occurrence)
{
// Bind usage occurrences.
Standard_Integer* aUsageOQPtr = myUsages.ChangeSeek(aChildId);
int* aUsageOQPtr = myUsages.ChangeSeek(aChildId);
if (aUsageOQPtr == NULL)
aUsageOQPtr = myUsages.Bound(aChildId, 1);
else
@ -260,7 +260,7 @@ Standard_Integer KI_XCAFDoc_AssemblyGraph::addNode(const TDF_Label& theLab
// =======================================================================
KI_XCAFDoc_AssemblyGraph::Iterator::Iterator(const Handle(KI_XCAFDoc_AssemblyGraph)& theGraph,
const Standard_Integer theNode)
const int theNode)
{
Standard_NullObject_Raise_if(theGraph.IsNull(), "Null assembly graph!");
Standard_NullObject_Raise_if(theNode < 1, "Node ID must be positive one-based integer!");

38
pcbnew/exporters/step/KI_XCAFDoc_AssemblyGraph.hxx

@ -48,7 +48,7 @@ public:
//! \brief Type definition for graph adjacency matrix.
//! This is how parent-component links are realized in the assembly graph.
typedef NCollection_DataMap<Standard_Integer, TColStd_PackedMapOfInteger> AdjacencyMap;
typedef NCollection_DataMap<int, TColStd_PackedMapOfInteger> AdjacencyMap;
public:
@ -62,7 +62,7 @@ public:
//! \param [in] theGraph - assembly graph to iterate.
//! \param [in] theNode - graph node ID.
Standard_EXPORT Iterator(const Handle(KI_XCAFDoc_AssemblyGraph)& theGraph,
const Standard_Integer theNode = 1);
const int theNode = 1);
//! Checks if there are more graph nodes to iterate.
//! \return true/false.
@ -72,7 +72,7 @@ public:
}
//! \return 1-based ID of the current node.
Standard_Integer Current() const
int Current() const
{
return myCurrentIndex;
}
@ -86,7 +86,7 @@ public:
private:
Handle(KI_XCAFDoc_AssemblyGraph) myGraph; //!< Assembly graph to iterate.
Standard_Integer myCurrentIndex; //!< Current 1-based node ID.
int myCurrentIndex; //!< Current 1-based node ID.
};
@ -121,13 +121,13 @@ public:
//! \param [in] theNode1 - one-based ID of the first node.
//! \param [in] theNode2 - one-based ID of the second node.
//! \return true/false.
Standard_EXPORT bool IsDirectLink(const Standard_Integer theNode1,
const Standard_Integer theNode2) const;
Standard_EXPORT bool IsDirectLink(const int theNode1,
const int theNode2) const;
//! \brief Checks whether direct children exist for the given node.
//! \param [in] theNode - one-based node ID.
//! \return true/false.
bool HasChildren(const Standard_Integer theNode) const
bool HasChildren(const int theNode) const
{
return myAdjacencyMap.IsBound(theNode);
}
@ -135,7 +135,7 @@ public:
//! \brief Returns IDs of child nodes for the given node.
//! \param [in] theNode - one-based node ID.
//! \return set of child IDs.
const TColStd_PackedMapOfInteger& GetChildren(const Standard_Integer theNode) const
const TColStd_PackedMapOfInteger& GetChildren(const int theNode) const
{
return myAdjacencyMap(theNode);
}
@ -144,12 +144,12 @@ public:
//! \param [in] theNode - one-based node ID.
//! \return node type.
//! \sa NodeType
Standard_EXPORT NodeType GetNodeType(const Standard_Integer theNode) const;
Standard_EXPORT NodeType GetNodeType(const int theNode) const;
//! \brief returns object ID by node ID.
//! \param [in] theNode - one-based node ID.
//! \return persistent ID.
const TDF_Label& GetNode(const Standard_Integer theNode) const
const TDF_Label& GetNode(const int theNode) const
{
return myNodes(theNode);
}
@ -163,7 +163,7 @@ public:
//! \brief Returns the number of graph nodes.
//! \return number of graph nodes.
Standard_Integer NbNodes() const
int NbNodes() const
{
return myNodes.Extent();
}
@ -177,12 +177,12 @@ public:
//! \brief Returns the number of graph links.
//! \return number of graph links.
Standard_EXPORT Standard_Integer NbLinks() const;
Standard_EXPORT int NbLinks() const;
//! Returns quantity of part usage occurrences.
//! \param [in] theNode - one-based part ID.
//! \return usage occurrence quantity.
Standard_EXPORT Standard_Integer NbOccurrences(const Standard_Integer theNode) const;
Standard_EXPORT int NbOccurrences(const int theNode) const;
private:
@ -196,14 +196,14 @@ private:
//! the parent object in the assembly graph
//! being populated.
Standard_EXPORT void addComponents(const TDF_Label& theParent,
const Standard_Integer theParentId);
const int theParentId);
//! Adds node into the graph.
//! \param [in] theLabel - label at insertion level.
//! \param [in] theParentId - parent one-based node IDS.
//! \return one-based internal ID of the node.
Standard_EXPORT Standard_Integer addNode(const TDF_Label& theLabel,
const Standard_Integer theParentId);
Standard_EXPORT int addNode(const TDF_Label& theLabel,
const int theParentId);
private:
@ -211,9 +211,9 @@ private:
TColStd_PackedMapOfInteger myRoots; //!< IDs of the root nodes.
TDF_LabelIndexedMap myNodes; //!< Maps assembly/part entries to graph node IDs.
AdjacencyMap myAdjacencyMap; //!< "Part-of" relations.
NCollection_DataMap<Standard_Integer, NodeType> myNodeTypes; //!< Node types.
NCollection_DataMap<Standard_Integer,
Standard_Integer> myUsages; //!< Occurrences usage.
NCollection_DataMap<int, NodeType> myNodeTypes; //!< Node types.
NCollection_DataMap<int,
int> myUsages; //!< Occurrences usage.
};

20
pcbnew/exporters/step/step_pcb_model.cpp

@ -87,7 +87,7 @@
#include <TDataStd_Name.hxx>
#include <TDataStd_TreeNode.hxx>
#include <TDF_ChildIterator.hxx>
#include <TDF_LabelSequence.hxx>
#include <NCollection_Sequence.hxx>
#include <TDF_Tool.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
@ -502,7 +502,7 @@ static SHAPE_LINE_CHAIN approximateLineChainWithArcs( const SHAPE_LINE_CHAIN& aS
static TopoDS_Shape getOneShape( Handle( XCAFDoc_ShapeTool ) aShapeTool )
{
TDF_LabelSequence theLabels;
NCollection_Sequence<TDF_Label> theLabels;
aShapeTool->GetFreeShapes( theLabels );
TopoDS_Shape aShape;
@ -514,7 +514,7 @@ static TopoDS_Shape getOneShape( Handle( XCAFDoc_ShapeTool ) aShapeTool )
BRep_Builder aBuilder;
aBuilder.MakeCompound( aCompound );
for( TDF_LabelSequence::Iterator anIt( theLabels ); anIt.More(); anIt.Next() )
for( NCollection_Sequence<TDF_Label>::Iterator anIt( theLabels ); anIt.More(); anIt.Next() )
{
TopoDS_Shape aFreeShape;
@ -575,7 +575,7 @@ static bool rescaleShapes( const TDF_Label& theLabel, const gp_XYZ& aScale )
BRepBuilderAPI_GTransform aBRepTrsf( aGTrsf );
for( Standard_Integer idx = 1; idx <= aG->NbNodes(); idx++ )
for( int idx = 1; idx <= aG->NbNodes(); idx++ )
{
const KI_XCAFDoc_AssemblyGraph::NodeType aNodeType = aG->GetNodeType( idx );
@ -605,9 +605,9 @@ static bool rescaleShapes( const TDF_Label& theLabel, const gp_XYZ& aScale )
aShapeTool->SetShape( aLabel, aScaledShape );
// Update sub-shapes
TDF_LabelSequence aSubshapes;
NCollection_Sequence<TDF_Label> aSubshapes;
aShapeTool->GetSubShapes( aLabel, aSubshapes );
for( TDF_LabelSequence::Iterator anItSs( aSubshapes ); anItSs.More(); anItSs.Next() )
for( NCollection_Sequence<TDF_Label>::Iterator anItSs( aSubshapes ); anItSs.More(); anItSs.Next() )
{
const TDF_Label& aLSs = anItSs.Value();
const TopoDS_Shape aSs = aShapeTool->GetShape( aLSs );
@ -793,7 +793,7 @@ static bool prefixNames( const TDF_Label& aLabel,
bool anIsDone = true;
for( Standard_Integer idx = 1; idx <= aG->NbNodes(); idx++ )
for( int idx = 1; idx <= aG->NbNodes(); idx++ )
{
const TDF_Label& lbl = aG->GetNode( idx );
Handle( TDataStd_Name ) nameHandle;
@ -3737,7 +3737,7 @@ TDF_Label STEP_PCB_MODEL::transferModel( Handle( TDocStd_Document ) & source,
{
Handle( XCAFDoc_ShapeTool ) s_assy = XCAFDoc_DocumentTool::ShapeTool( source->Main() );
TDF_LabelSequence frshapes;
NCollection_Sequence<TDF_Label> frshapes;
s_assy->GetFreeShapes( frshapes );
Handle( XCAFDoc_ShapeTool ) d_assy = XCAFDoc_DocumentTool::ShapeTool( dest->Main() );
@ -3766,14 +3766,14 @@ TDF_Label STEP_PCB_MODEL::transferModel( Handle( TDocStd_Document ) & source,
bool STEP_PCB_MODEL::performMeshing( Handle( XCAFDoc_ShapeTool ) & aShapeTool )
{
TDF_LabelSequence freeShapes;
NCollection_Sequence<TDF_Label> freeShapes;
aShapeTool->GetFreeShapes( freeShapes );
m_reporter->Report( wxT( "Meshing model" ), RPT_SEVERITY_DEBUG );
// GLTF is a mesh format, we have to trigger opencascade to mesh the shapes we composited into the asesmbly
// To mesh models, lets just grab the free shape root and execute on them
for( Standard_Integer i = 1; i <= freeShapes.Length(); ++i )
for( int i = 1; i <= freeShapes.Length(); ++i )
{
TDF_Label label = freeShapes.Value( i );
TopoDS_Shape shape;

42
pcbnew/exporters/u3d/writer.cpp

@ -291,14 +291,14 @@ void WRITER::collectGeometryRecursive( const TDF_Label& label, const Handle( XCA
const Handle( XCAFDoc_VisMaterialTool ) & visMatTool,
const gp_Trsf& cumulativeTransform,
const std::string& baseName,
std::unordered_map<Graphic3d_Vec4, MESH*>& meshesByColor )
std::unordered_map<NCollection_Vec4<float>, MESH*>& meshesByColor )
{
if( label.IsNull() )
return;
if( shapeTool->IsAssembly( label ) || shapeTool->IsReference( label ) )
{
TDF_LabelSequence childrenOrComponents;
NCollection_Sequence<TDF_Label> childrenOrComponents;
TDF_Label referencedLabel;
gp_Trsf currentTransform = cumulativeTransform;
bool isRef = shapeTool->IsReference( label );
@ -321,7 +321,7 @@ void WRITER::collectGeometryRecursive( const TDF_Label& label, const Handle( XCA
else
{
shapeTool->GetComponents( label, childrenOrComponents );
for( Standard_Integer i = 1; i <= childrenOrComponents.Length(); ++i )
for( int i = 1; i <= childrenOrComponents.Length(); ++i )
{
TDF_Label compLabel = childrenOrComponents.Value( i );
TopLoc_Location compLocation;
@ -353,8 +353,8 @@ void WRITER::collectGeometryRecursive( const TDF_Label& label, const Handle( XCA
if( triangulation.IsNull() )
continue;
Graphic3d_Vec4 aColorF = faceIter.FaceColor();
Graphic3d_Vec4 specularColor( 0.2f );
NCollection_Vec4<float> aColorF = faceIter.FaceColor();
NCollection_Vec4<float> specularColor( 0.2f );
MESH* mesh = nullptr;
auto it = meshesByColor.find( aColorF );
@ -378,7 +378,7 @@ void WRITER::collectGeometryRecursive( const TDF_Label& label, const Handle( XCA
uint32_t numberTriangles = 0;
uint32_t numberNodes = 0;
const Standard_Integer aNodeUpper = faceIter.NodeUpper();
const int aNodeUpper = faceIter.NodeUpper();
numberNodes += faceIter.NbNodes();
numberTriangles += faceIter.NbTriangles();
@ -391,7 +391,7 @@ void WRITER::collectGeometryRecursive( const TDF_Label& label, const Handle( XCA
mesh->normals.reserve( mesh->normals.size() + numberNodes );
}
for( Standard_Integer aNodeIter = faceIter.NodeLower(); aNodeIter <= aNodeUpper; ++aNodeIter )
for( int aNodeIter = faceIter.NodeLower(); aNodeIter <= aNodeUpper; ++aNodeIter )
{
const gp_Dir aNormal = faceIter.NormalTransformed( aNodeIter );
gp_XYZ vertex = faceIter.NodeTransformed( aNodeIter ).XYZ();
@ -405,14 +405,14 @@ void WRITER::collectGeometryRecursive( const TDF_Label& label, const Handle( XCA
m_meshBoundingBox.Update( vertex.X(), vertex.Y(), vertex.Z() );
}
const Standard_Integer anElemLower = faceIter.ElemLower();
const Standard_Integer anElemUpper = faceIter.ElemUpper();
for( Standard_Integer anElemIter = anElemLower; anElemIter <= anElemUpper; ++anElemIter )
const int anElemLower = faceIter.ElemLower();
const int anElemUpper = faceIter.ElemUpper();
for( int anElemIter = anElemLower; anElemIter <= anElemUpper; ++anElemIter )
{
const Poly_Triangle aTri = faceIter.TriangleOriented( anElemIter );
Graphic3d_Vec3i vec =
Graphic3d_Vec3i( aTri( 1 ), aTri( 2 ), aTri( 3 ) ) - Graphic3d_Vec3i( anElemLower );
NCollection_Vec3<int> vec =
NCollection_Vec3<int>( aTri( 1 ), aTri( 2 ), aTri( 3 ) ) - NCollection_Vec3<int>( anElemLower );
mesh->coordIndices.emplace_back( vec.x() + nodesExistingSum );
mesh->coordIndices.emplace_back( vec.y() + nodesExistingSum );
@ -451,8 +451,8 @@ void WRITER::generateMeshesByAssembly( const Handle( TDocStd_Document ) & doc )
return;
}
TDF_LabelSequence meshableLabels;
TDF_LabelSequence rootLabels;
NCollection_Sequence<TDF_Label> meshableLabels;
NCollection_Sequence<TDF_Label> rootLabels;
shapeTool->GetFreeShapes( rootLabels );
/*
@ -469,16 +469,16 @@ void WRITER::generateMeshesByAssembly( const Handle( TDocStd_Document ) & doc )
return;
}
TDF_LabelSequence childrenOrComponents;
NCollection_Sequence<TDF_Label> childrenOrComponents;
shapeTool->GetComponents( label, childrenOrComponents );
for( Standard_Integer i = 1; i <= childrenOrComponents.Length(); ++i )
for( int i = 1; i <= childrenOrComponents.Length(); ++i )
recurseFindKiCadElements( childrenOrComponents.Value( i ) );
};
for( Standard_Integer i = 1; i <= rootLabels.Length(); ++i )
for( int i = 1; i <= rootLabels.Length(); ++i )
recurseFindKiCadElements( rootLabels.Value( i ) );
for( Standard_Integer i = 1; i <= meshableLabels.Length(); ++i )
for( int i = 1; i <= meshableLabels.Length(); ++i )
{
TDF_Label meshLabel = meshableLabels.Value( i );
if( !( shapeTool->IsAssembly( meshLabel ) || shapeTool->IsShape( meshLabel ) ) )
@ -507,7 +507,7 @@ void WRITER::generateMeshesByAssembly( const Handle( TDocStd_Document ) & doc )
}
m_groupNodes.push_back( gn );
std::unordered_map<Graphic3d_Vec4, MESH*> meshesByColor;
std::unordered_map<NCollection_Vec4<float>, MESH*> meshesByColor;
gp_Trsf initialTransform; // identity
collectGeometryRecursive( meshLabel, shapeTool, colorTool, visMatTool, initialTransform,
topName, meshesByColor );
@ -716,8 +716,8 @@ std::shared_ptr<DATA_BLOCK> WRITER::getLitTextureShaderBlock( const std::string&
std::shared_ptr<DATA_BLOCK> WRITER::getMaterialResourceBlock( const std::string& aMaterialName,
const Graphic3d_Vec4& aDiffuseColor,
const Graphic3d_Vec3& aSpecularColor )
const NCollection_Vec4<float>& aDiffuseColor,
const NCollection_Vec3<float>& aSpecularColor )
{
BIT_STREAM_WRITER w;

30
pcbnew/exporters/u3d/writer.h

@ -36,8 +36,8 @@
#include <TopoDS_Shape.hxx>
#include <TDocStd_Document.hxx>
#include <Standard_Handle.hxx>
#include <Graphic3d_Vec4.hxx>
#include <Graphic3d_Vec3.hxx>
#include <NCollection_Vec4.hxx>
#include <NCollection_Vec3.hxx>
#include <Bnd_Box.hxx>
#include <XCAFDoc_ShapeTool.hxx>
#include <XCAFDoc_ColorTool.hxx>
@ -51,9 +51,9 @@
namespace std
{
template <>
struct hash<Graphic3d_Vec4>
struct hash<NCollection_Vec4<float>>
{
size_t operator()( const Graphic3d_Vec4& v ) const
size_t operator()( const NCollection_Vec4<float>& v ) const
{
size_t h1 = std::hash<float>{}( v.x() );
size_t h2 = std::hash<float>{}( v.y() );
@ -76,20 +76,20 @@ public:
/**
* List of all unique diffuse colors
*/
std::vector<Graphic3d_Vec4> diffuse_colors;
std::vector<NCollection_Vec4<float>> diffuse_colors;
/**
* List of all unique specular colors
*/
std::vector<Graphic3d_Vec4> specular_colors;
std::vector<NCollection_Vec4<float>> specular_colors;
/**
* Index map helps select the color index for a given vertex when creating the colorIndices
*/
std::unordered_map<Graphic3d_Vec4, uint32_t> diffuse_colors_index_map;
std::unordered_map<NCollection_Vec4<float>, uint32_t> diffuse_colors_index_map;
/**
* Index map helps select the color index for a given vertex when creating the colorIndices
*/
std::unordered_map<Graphic3d_Vec4, uint32_t> specular_colors_index_map;
std::unordered_map<NCollection_Vec4<float>, uint32_t> specular_colors_index_map;
/**
* Coordinate indices, maps vertex positions to triangles
@ -114,12 +114,12 @@ public:
/**
* Diffuse color used if not using per-vertex color
*/
Graphic3d_Vec4 diffuse_color;
NCollection_Vec4<float> diffuse_color;
/**
* Specular color used if not using per-vertex color
*/
Graphic3d_Vec3 specular_color;
NCollection_Vec3<float> specular_color;
/**
* The name of the mesh, this will be visible in U3D viewers
@ -138,7 +138,7 @@ public:
return coords.empty() || coordIndices.empty();
}
uint32_t GetOrAddUniqueDiffuseColor( const Graphic3d_Vec4& aColor )
uint32_t GetOrAddUniqueDiffuseColor( const NCollection_Vec4<float>& aColor )
{
uint32_t colorIndex = 0;
if( diffuse_colors_index_map.find( aColor ) != diffuse_colors_index_map.end() )
@ -155,7 +155,7 @@ public:
return colorIndex;
}
uint32_t GetOrAddUniqueSpecularColor( const Graphic3d_Vec4& aColor )
uint32_t GetOrAddUniqueSpecularColor( const NCollection_Vec4<float>& aColor )
{
uint32_t colorIndex = 0;
if( specular_colors_index_map.find( aColor ) != specular_colors_index_map.end() )
@ -236,8 +236,8 @@ private:
std::shared_ptr<DATA_BLOCK> getMaterialResourceBlock( const std::string& aMaterialName,
const Graphic3d_Vec4& aDiffuseColor,
const Graphic3d_Vec3& aSpecularColor );
const NCollection_Vec4<float>& aDiffuseColor,
const NCollection_Vec3<float>& aSpecularColor );
std::shared_ptr<DATA_BLOCK>
getModelResourceModifierChain( const std::string& aModifierChainName, const MESH* aMesh,
@ -272,7 +272,7 @@ private:
const Handle( XCAFDoc_VisMaterialTool ) & visMatTool,
const gp_Trsf& cumulativeTransform,
const std::string& baseName,
std::unordered_map<Graphic3d_Vec4, MESH*>& meshesByColor );
std::unordered_map<NCollection_Vec4<float>, MESH*>& meshesByColor );
void getMeshName( const TDF_Label& label, Handle( XCAFDoc_ShapeTool ) shapeTool, MESH* mesh );

7
plugins/3d/oce/loadmodel.cpp

@ -76,7 +76,8 @@
#include <Poly_PolygonOnTriangulation.hxx>
#include <Precision.hxx>
#include <TDF_LabelSequence.hxx>
#include <NCollection_Sequence.hxx>
#include <TDF_Label.hxx>
#include <TDF_ChildIterator.hxx>
#include <TDF_Tool.hxx>
#include <TDataStd_Name.hxx>
@ -745,7 +746,7 @@ SCENEGRAPH* LoadModel( char const* filename )
}
// retrieve all free shapes
TDF_LabelSequence frshapes;
NCollection_Sequence<TDF_Label> frshapes;
data.m_assy->GetFreeShapes( frshapes );
bool ret = false;
@ -754,7 +755,7 @@ SCENEGRAPH* LoadModel( char const* filename )
IFSG_TRANSFORM topNode( true );
data.scene = topNode.GetRawPtr();
for( Standard_Integer i = 1; i <= frshapes.Length(); i++ )
for( int i = 1; i <= frshapes.Length(); i++ )
{
const TDF_Label& label = frshapes.Value( i );

Loading…
Cancel
Save