mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
0025463: Visualization - MeshVS_ElementalColorPrsBuilder produces inefficient structures for elements with unique colors
Create array with per-node color assigned
This commit is contained in:
@@ -245,7 +245,58 @@ void MeshVS_ElementalColorPrsBuilder::Build ( const Handle(Prs3d_Presentation)&
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Draw elements with one color
|
// Draw elements with one color
|
||||||
for ( MeshVS_DataMapIteratorOfDataMapOfColorMapOfInteger aColIter ( aColorsOfElements ); aColIter.More();
|
Standard_Integer aNbFacePrimitives = 0;
|
||||||
|
for (it.Reset(); it.More(); it.Next())
|
||||||
|
{
|
||||||
|
if (!anElemColorMap->IsBound (it.Key()))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Standard_Integer aNbNodes = 0;
|
||||||
|
if (!aSource->GetGeom (it.Key(), Standard_True, aCoords, aNbNodes, aType))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (aType == MeshVS_ET_Face)
|
||||||
|
{
|
||||||
|
aNbFacePrimitives += aNbNodes - 2; // add face triangles
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Handle(Graphic3d_ArrayOfTriangles) aTriangles = new Graphic3d_ArrayOfTriangles (aNbFacePrimitives * 3, 0, Standard_False, Standard_True);
|
||||||
|
for (it.Reset(); it.More(); it.Next())
|
||||||
|
{
|
||||||
|
if (!anElemColorMap->IsBound (it.Key()))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Standard_Integer aNbNodes = 0;
|
||||||
|
if (!aSource->GetGeom (it.Key(), Standard_True, aCoords, aNbNodes, aType))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
const Quantity_Color& aColor = anElemColorMap->Find (it.Key());
|
||||||
|
if (aType == MeshVS_ET_Face)
|
||||||
|
{
|
||||||
|
for (Standard_Integer aNodeIdx = 0; aNodeIdx < aNbNodes - 2; ++aNodeIdx)
|
||||||
|
{
|
||||||
|
for (Standard_Integer anIdx = 0; anIdx < 3; ++anIdx)
|
||||||
|
{
|
||||||
|
aTriangles->AddVertex (gp_Pnt (aCoords (3 * (anIdx == 0 ? 0 : (aNodeIdx + anIdx)) + 1),
|
||||||
|
aCoords (3 * (anIdx == 0 ? 0 : (aNodeIdx + anIdx)) + 2),
|
||||||
|
aCoords (3 * (anIdx == 0 ? 0 : (aNodeIdx + anIdx)) + 3)),
|
||||||
|
aColor);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Handle(Graphic3d_Group) aTrisGroup = Prs3d_Root::NewGroup (Prs);
|
||||||
|
|
||||||
|
Handle(Graphic3d_AspectFillArea3d) aFillAspect = new Graphic3d_AspectFillArea3d (Aspect_IS_SOLID, Quantity_NOC_WHITE, anEdgeColor,
|
||||||
|
anEdgeType, anEdgeWidth, aMaterial[0], aMaterial[1]);
|
||||||
|
aFillAspect->SetDistinguishOff();
|
||||||
|
aFillAspect->SetEdgeOff();
|
||||||
|
aTrisGroup->SetGroupPrimitivesAspect (aFillAspect);
|
||||||
|
aTrisGroup->AddPrimitiveArray (aTriangles);
|
||||||
|
|
||||||
|
/**for ( MeshVS_DataMapIteratorOfDataMapOfColorMapOfInteger aColIter ( aColorsOfElements ); aColIter.More();
|
||||||
aColIter.Next() )
|
aColIter.Next() )
|
||||||
{
|
{
|
||||||
Standard_Integer aSize = aColIter.Value().Extent();
|
Standard_Integer aSize = aColIter.Value().Extent();
|
||||||
@@ -254,12 +305,9 @@ void MeshVS_ElementalColorPrsBuilder::Build ( const Handle(Prs3d_Presentation)&
|
|||||||
|
|
||||||
TColStd_PackedMapOfInteger aCustomElements;
|
TColStd_PackedMapOfInteger aCustomElements;
|
||||||
|
|
||||||
Prs3d_Root::NewGroup ( Prs );
|
Handle(Graphic3d_Group) aGGroup = Prs3d_Root::NewGroup (Prs);
|
||||||
Handle ( Graphic3d_Group ) aGGroup = Prs3d_Root::CurrentGroup ( Prs );
|
Handle(Graphic3d_Group) aLGroup = Prs3d_Root::NewGroup (Prs);
|
||||||
Prs3d_Root::NewGroup ( Prs );
|
Handle(Graphic3d_Group) aSGroup = Prs3d_Root::NewGroup (Prs);
|
||||||
Handle ( Graphic3d_Group ) aLGroup = Prs3d_Root::CurrentGroup ( Prs );
|
|
||||||
Prs3d_Root::NewGroup ( Prs );
|
|
||||||
Handle ( Graphic3d_Group ) aSGroup = Prs3d_Root::CurrentGroup ( Prs );
|
|
||||||
|
|
||||||
Standard_Integer aNbFacePrimitives = 0;
|
Standard_Integer aNbFacePrimitives = 0;
|
||||||
Standard_Integer aNbVolmPrimitives = 0;
|
Standard_Integer aNbVolmPrimitives = 0;
|
||||||
@@ -316,8 +364,7 @@ void MeshVS_ElementalColorPrsBuilder::Build ( const Handle(Prs3d_Presentation)&
|
|||||||
// cell rendering (normal interpolation is not always applicable - flat shading),
|
// cell rendering (normal interpolation is not always applicable - flat shading),
|
||||||
// elemental coloring (color interpolation is impossible)
|
// elemental coloring (color interpolation is impossible)
|
||||||
|
|
||||||
Handle (Graphic3d_ArrayOfTriangles) aFaceTriangles = new Graphic3d_ArrayOfTriangles (
|
Handle(Graphic3d_ArrayOfTriangles) aFaceTriangles = new Graphic3d_ArrayOfTriangles ((aNbFacePrimitives + aNbVolmPrimitives) * 3, 0, IsReflect);
|
||||||
(aNbFacePrimitives + aNbVolmPrimitives) * 3, 0, IsReflect );
|
|
||||||
Standard_Boolean IsPolyG = Standard_False;
|
Standard_Boolean IsPolyG = Standard_False;
|
||||||
|
|
||||||
Handle (Graphic3d_ArrayOfSegments) anEdgeSegments = new Graphic3d_ArrayOfSegments (aNbEdgePrimitives * 2);
|
Handle (Graphic3d_ArrayOfSegments) anEdgeSegments = new Graphic3d_ArrayOfSegments (aNbEdgePrimitives * 2);
|
||||||
@@ -640,7 +687,7 @@ void MeshVS_ElementalColorPrsBuilder::Build ( const Handle(Prs3d_Presentation)&
|
|||||||
aGroup2->SetGroupPrimitivesAspect (anAsp);
|
aGroup2->SetGroupPrimitivesAspect (anAsp);
|
||||||
aGroup3->AddPrimitiveArray (anEdgeSegments);
|
aGroup3->AddPrimitiveArray (anEdgeSegments);
|
||||||
aGroup3->SetGroupPrimitivesAspect (anEdgeAspect);
|
aGroup3->SetGroupPrimitivesAspect (anEdgeAspect);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
//================================================================
|
//================================================================
|
||||||
|
Reference in New Issue
Block a user