mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0030854: Visualization, AIS_ViewCube - pack triangulations into common array(s)
Presentation computation has been modified to merge triangulations per box part type. Prs3d_Drawer::FaceBoundaryDraw() flag is now handled for drawing box sides edges. Graphic3d_ArrayOfPrimitives has been extended by auxiliary methods: - ::AddSegmentEdges(), ::AddTriangleEdges(), ::AddQuadEdges() raising exception on wrong primitive type. - ::AddQuadTriangleEdges() splitting quad into indexed triangulation; - ::AddTriangleStripEdges() splitting triangle strip into indexed triangulation; - ::AddTriangleFanEdges() splitting triangle fan into indexed triangulation; - ::AddPolylineEdges() splitting polyline into indexed segments.
This commit is contained in:
@@ -259,6 +259,79 @@ Standard_Integer Graphic3d_ArrayOfPrimitives::AddEdge (const Standard_Integer th
|
||||
return ++myIndices->NbElements;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : AddTriangleStripEdges
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_ArrayOfPrimitives::AddTriangleStripEdges (Standard_Integer theVertexLower,
|
||||
Standard_Integer theVertexUpper)
|
||||
{
|
||||
if (myType != Graphic3d_TOPA_TRIANGLES)
|
||||
{
|
||||
throw Standard_TypeMismatch ("Not array of triangles");
|
||||
}
|
||||
|
||||
Standard_Boolean isOdd = Standard_True;
|
||||
for (Standard_Integer aNodeIter = theVertexLower + 2; aNodeIter <= theVertexUpper; ++aNodeIter)
|
||||
{
|
||||
if (isOdd)
|
||||
{
|
||||
AddTriangleEdges (aNodeIter - 2, aNodeIter - 1, aNodeIter);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddTriangleEdges (aNodeIter - 1, aNodeIter - 2, aNodeIter);
|
||||
}
|
||||
isOdd = !isOdd;
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : AddTriangleFanEdges
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_ArrayOfPrimitives::AddTriangleFanEdges (Standard_Integer theVertexLower,
|
||||
Standard_Integer theVertexUpper,
|
||||
Standard_Boolean theToClose)
|
||||
{
|
||||
if (myType != Graphic3d_TOPA_TRIANGLES)
|
||||
{
|
||||
throw Standard_TypeMismatch ("Not array of triangles");
|
||||
}
|
||||
|
||||
for (Standard_Integer aNodeIter = theVertexLower + 1; aNodeIter <= theVertexUpper; ++aNodeIter)
|
||||
{
|
||||
AddTriangleEdges (theVertexLower, aNodeIter - 1, aNodeIter);
|
||||
}
|
||||
if (theToClose)
|
||||
{
|
||||
AddTriangleEdges (theVertexLower, theVertexUpper, theVertexLower + 1);
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : AddPolylineEdges
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_ArrayOfPrimitives::AddPolylineEdges (Standard_Integer theVertexLower,
|
||||
Standard_Integer theVertexUpper,
|
||||
Standard_Boolean theToClose)
|
||||
{
|
||||
if (myType != Graphic3d_TOPA_SEGMENTS)
|
||||
{
|
||||
throw Standard_TypeMismatch ("Not array of segments");
|
||||
}
|
||||
|
||||
for (Standard_Integer aNodeIter = theVertexLower; aNodeIter < theVertexUpper; ++aNodeIter)
|
||||
{
|
||||
AddSegmentEdges (aNodeIter, aNodeIter + 1);
|
||||
}
|
||||
if (theToClose)
|
||||
{
|
||||
AddSegmentEdges (theVertexUpper, theVertexLower);
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : StringType
|
||||
// purpose :
|
||||
|
@@ -23,6 +23,7 @@
|
||||
#include <gp_Dir.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <Standard_OutOfRange.hxx>
|
||||
#include <Standard_TypeMismatch.hxx>
|
||||
#include <Quantity_Color.hxx>
|
||||
|
||||
class Graphic3d_ArrayOfPrimitives;
|
||||
@@ -537,6 +538,16 @@ public: //! @name optional array of Indices/Edges for using shared Vertex data
|
||||
return AddEdge (theVertexIndex2);
|
||||
}
|
||||
|
||||
//! Convenience method, adds two vertex indices (a segment) in the range [1,VertexNumber()] in the array of segments (Graphic3d_TOPA_SEGMENTS).
|
||||
//! Raises exception if array is not of type Graphic3d_TOPA_SEGMENTS.
|
||||
//! @return the actual edges number
|
||||
Standard_Integer AddSegmentEdges (Standard_Integer theVertexIndex1,
|
||||
Standard_Integer theVertexIndex2)
|
||||
{
|
||||
Standard_TypeMismatch_Raise_if (myType != Graphic3d_TOPA_SEGMENTS, "Not array of segments");
|
||||
return AddEdges (theVertexIndex1, theVertexIndex2);
|
||||
}
|
||||
|
||||
//! Convenience method, adds three vertex indices (a triangle) in the range [1,VertexNumber()] in the array.
|
||||
//! @return the actual edges number
|
||||
Standard_Integer AddEdges (Standard_Integer theVertexIndex1,
|
||||
@@ -548,6 +559,35 @@ public: //! @name optional array of Indices/Edges for using shared Vertex data
|
||||
return AddEdge (theVertexIndex3);
|
||||
}
|
||||
|
||||
//! Convenience method, adds three vertex indices of triangle in the range [1,VertexNumber()] in the array of triangles.
|
||||
//! Raises exception if array is not of type Graphic3d_TOPA_TRIANGLES.
|
||||
//! @return the actual edges number
|
||||
Standard_Integer AddTriangleEdges (Standard_Integer theVertexIndex1,
|
||||
Standard_Integer theVertexIndex2,
|
||||
Standard_Integer theVertexIndex3)
|
||||
{
|
||||
Standard_TypeMismatch_Raise_if (myType != Graphic3d_TOPA_TRIANGLES, "Not array of triangles");
|
||||
return AddEdges (theVertexIndex1, theVertexIndex2, theVertexIndex3);
|
||||
}
|
||||
|
||||
//! Convenience method, adds three vertex indices of triangle in the range [1,VertexNumber()] in the array of triangles.
|
||||
//! Raises exception if array is not of type Graphic3d_TOPA_TRIANGLES.
|
||||
//! @return the actual edges number
|
||||
Standard_Integer AddTriangleEdges (const Graphic3d_Vec3i& theIndexes)
|
||||
{
|
||||
Standard_TypeMismatch_Raise_if (myType != Graphic3d_TOPA_TRIANGLES, "Not array of triangles");
|
||||
return AddEdges (theIndexes[0], theIndexes[1], theIndexes[2]);
|
||||
}
|
||||
|
||||
//! Convenience method, adds three vertex indices (4th component is ignored) of triangle in the range [1,VertexNumber()] in the array of triangles.
|
||||
//! Raises exception if array is not of type Graphic3d_TOPA_TRIANGLES.
|
||||
//! @return the actual edges number
|
||||
Standard_Integer AddTriangleEdges (const Graphic3d_Vec4i& theIndexes)
|
||||
{
|
||||
Standard_TypeMismatch_Raise_if (myType != Graphic3d_TOPA_TRIANGLES, "Not array of triangles");
|
||||
return AddEdges (theIndexes[0], theIndexes[1], theIndexes[2]);
|
||||
}
|
||||
|
||||
//! Convenience method, adds four vertex indices (a quad) in the range [1,VertexNumber()] in the array.
|
||||
//! @return the actual edges number
|
||||
Standard_Integer AddEdges (Standard_Integer theVertexIndex1,
|
||||
@@ -561,6 +601,66 @@ public: //! @name optional array of Indices/Edges for using shared Vertex data
|
||||
return AddEdge (theVertexIndex4);
|
||||
}
|
||||
|
||||
//! Convenience method, adds four vertex indices (a quad) in the range [1,VertexNumber()] in the array of quads.
|
||||
//! Raises exception if array is not of type Graphic3d_TOPA_QUADRANGLES.
|
||||
//! @return the actual edges number
|
||||
Standard_Integer AddQuadEdges (Standard_Integer theVertexIndex1,
|
||||
Standard_Integer theVertexIndex2,
|
||||
Standard_Integer theVertexIndex3,
|
||||
Standard_Integer theVertexIndex4)
|
||||
{
|
||||
Standard_TypeMismatch_Raise_if (myType != Graphic3d_TOPA_QUADRANGLES, "Not array of quads");
|
||||
return AddEdges (theVertexIndex1, theVertexIndex2, theVertexIndex3, theVertexIndex4);
|
||||
}
|
||||
|
||||
//! Convenience method, adds quad indices in the range [1,VertexNumber()] into array or triangles as two triangles.
|
||||
//! Raises exception if array is not of type Graphic3d_TOPA_TRIANGLES.
|
||||
//! @return the actual edges number
|
||||
Standard_Integer AddQuadTriangleEdges (Standard_Integer theVertexIndex1,
|
||||
Standard_Integer theVertexIndex2,
|
||||
Standard_Integer theVertexIndex3,
|
||||
Standard_Integer theVertexIndex4)
|
||||
{
|
||||
AddTriangleEdges (theVertexIndex3, theVertexIndex1, theVertexIndex2);
|
||||
return AddTriangleEdges (theVertexIndex1, theVertexIndex3, theVertexIndex4);
|
||||
}
|
||||
|
||||
//! Convenience method, adds quad indices in the range [1,VertexNumber()] into array or triangles as two triangles.
|
||||
//! Raises exception if array is not of type Graphic3d_TOPA_TRIANGLES.
|
||||
//! @return the actual edges number
|
||||
Standard_Integer AddQuadTriangleEdges (const Graphic3d_Vec4i& theIndexes)
|
||||
{
|
||||
return AddQuadTriangleEdges (theIndexes[0], theIndexes[1], theIndexes[2], theIndexes[3]);
|
||||
}
|
||||
|
||||
//! Add triangle strip into indexed triangulation array.
|
||||
//! N-2 triangles are added from N input nodes.
|
||||
//! Raises exception if array is not of type Graphic3d_TOPA_TRIANGLES.
|
||||
//! @param theVertexLower [in] index of first node defining triangle strip
|
||||
//! @param theVertexUpper [in] index of last node defining triangle strip
|
||||
Standard_EXPORT void AddTriangleStripEdges (Standard_Integer theVertexLower,
|
||||
Standard_Integer theVertexUpper);
|
||||
|
||||
//! Add triangle fan into indexed triangulation array.
|
||||
//! N-2 triangles are added from N input nodes (or N-1 with closed flag).
|
||||
//! Raises exception if array is not of type Graphic3d_TOPA_TRIANGLES.
|
||||
//! @param theVertexLower [in] index of first node defining triangle fun (center)
|
||||
//! @param theVertexUpper [in] index of last node defining triangle fun
|
||||
//! @param theToClose [in] close triangle fan (connect first and last points)
|
||||
Standard_EXPORT void AddTriangleFanEdges (Standard_Integer theVertexLower,
|
||||
Standard_Integer theVertexUpper,
|
||||
Standard_Boolean theToClose);
|
||||
|
||||
//! Add line strip (polyline) into indexed segments array.
|
||||
//! N-1 segments are added from N input nodes (or N with closed flag).
|
||||
//! Raises exception if array is not of type Graphic3d_TOPA_SEGMENTS.
|
||||
//! @param theVertexLower [in] index of first node defining line strip fun (center)
|
||||
//! @param theVertexUpper [in] index of last node defining triangle fun
|
||||
//! @param theToClose [in] close triangle fan (connect first and last points)
|
||||
Standard_EXPORT void AddPolylineEdges (Standard_Integer theVertexLower,
|
||||
Standard_Integer theVertexUpper,
|
||||
Standard_Boolean theToClose);
|
||||
|
||||
public: //! @name optional array of Bounds/Subgroups within primitive array (e.g. restarting primitives / assigning colors)
|
||||
|
||||
//! Returns optional bounds buffer.
|
||||
|
Reference in New Issue
Block a user