mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0025300: Visualization - Build wireframe representation consistent with the shape's triangulation
1) Remove duplicating presentation algorithms for shapes StdPrs_WFShape, StdPrs_WFDeflectionShape. 2) Rewrite Prs3d_WFShape to use deflection for non-triangulated shapes and rename it to StdPrs_WFShape. 3) Revise and correct references in code. 4) Rename StdPrs_ToolShadedShape to StdPrs_ToolTriangulatedShape (reused in StdPrs_WFShape, StdPrs_ShadedShape). 5) Add StdPrs_BndBox for drawing bounding box presentation. 6) Implemented on-triangulation isoline builder. 7) Add option -isoontriangulation to vaspects command to enable on-triangulation isoline builder for shape. 8) Drawer's maximum UV parameter value is taken into account in isolines calculation correctly. 9) Add option -setMaxParamValue to vaspects command to change drawer's maximum UV parameter value.
This commit is contained in:
@@ -577,7 +577,8 @@ static int visos (Draw_Interpretor& di, Standard_Integer argc, const char** argv
|
||||
TheAISContext()->IsoNumber(AIS_TOI_IsoV) << "\n";
|
||||
di << "IsoOnPlane mode is " <<
|
||||
(TheAISContext()->IsoOnPlane() ? "ON" : "OFF") << "\n";
|
||||
|
||||
di << "IsoOnTriangulation mode is " <<
|
||||
(TheAISContext()->IsoOnTriangulation() ? "ON" : "OFF") << "\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1468,6 +1469,11 @@ struct ViewerTest_AspectsChangeSet
|
||||
Standard_Integer ToSetFreeBoundaryColor;
|
||||
Quantity_Color FreeBoundaryColor;
|
||||
|
||||
Standard_Integer ToEnableIsoOnTriangulation;
|
||||
|
||||
Standard_Integer ToSetMaxParamValue;
|
||||
Standard_Real MaxParamValue;
|
||||
|
||||
//! Empty constructor
|
||||
ViewerTest_AspectsChangeSet()
|
||||
: ToSetVisibility (0),
|
||||
@@ -1482,11 +1488,14 @@ struct ViewerTest_AspectsChangeSet
|
||||
Transparency (0.0),
|
||||
ToSetMaterial (0),
|
||||
Material (Graphic3d_NOM_DEFAULT),
|
||||
ToSetShowFreeBoundary (0),
|
||||
ToSetFreeBoundaryWidth (0),
|
||||
FreeBoundaryWidth (1.0),
|
||||
ToSetFreeBoundaryColor (0),
|
||||
FreeBoundaryColor (DEFAULT_FREEBOUNDARY_COLOR) {}
|
||||
ToSetShowFreeBoundary (0),
|
||||
ToSetFreeBoundaryWidth (0),
|
||||
FreeBoundaryWidth (1.0),
|
||||
ToSetFreeBoundaryColor (0),
|
||||
FreeBoundaryColor (DEFAULT_FREEBOUNDARY_COLOR),
|
||||
ToEnableIsoOnTriangulation (-1),
|
||||
ToSetMaxParamValue (0),
|
||||
MaxParamValue (500000) {}
|
||||
|
||||
//! @return true if no changes have been requested
|
||||
Standard_Boolean IsEmpty() const
|
||||
@@ -1498,7 +1507,8 @@ struct ViewerTest_AspectsChangeSet
|
||||
&& ToSetMaterial == 0
|
||||
&& ToSetShowFreeBoundary == 0
|
||||
&& ToSetFreeBoundaryColor == 0
|
||||
&& ToSetFreeBoundaryWidth == 0;
|
||||
&& ToSetFreeBoundaryWidth == 0
|
||||
&& ToSetMaxParamValue == 0;
|
||||
}
|
||||
|
||||
//! @return true if properties are valid
|
||||
@@ -1540,6 +1550,11 @@ struct ViewerTest_AspectsChangeSet
|
||||
std::cout << "Error: the free boundary width should be within [1; 10] range (specified " << FreeBoundaryWidth << ")\n";
|
||||
isOk = Standard_False;
|
||||
}
|
||||
if (MaxParamValue < 0.0)
|
||||
{
|
||||
std::cout << "Error: the max parameter value should be greater than zero (specified " << MaxParamValue << ")\n";
|
||||
isOk = Standard_False;
|
||||
}
|
||||
return isOk;
|
||||
}
|
||||
|
||||
@@ -2069,6 +2084,42 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
|
||||
aChangeSet->ToSetFreeBoundaryWidth = -1;
|
||||
aChangeSet->FreeBoundaryWidth = 1.0;
|
||||
}
|
||||
else if (anArg == "-isoontriangulation"
|
||||
|| anArg == "-isoontriang")
|
||||
{
|
||||
if (++anArgIter >= theArgNb)
|
||||
{
|
||||
std::cout << "Error: wrong syntax at " << anArg << "\n";
|
||||
return 1;
|
||||
}
|
||||
TCollection_AsciiString aValue (theArgVec[anArgIter]);
|
||||
aValue.LowerCase();
|
||||
if (aValue == "on"
|
||||
|| aValue == "1")
|
||||
{
|
||||
aChangeSet->ToEnableIsoOnTriangulation = 1;
|
||||
}
|
||||
else if (aValue == "off"
|
||||
|| aValue == "0")
|
||||
{
|
||||
aChangeSet->ToEnableIsoOnTriangulation = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Error: wrong syntax at " << anArg << "\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if (anArg == "-setmaxparamvalue")
|
||||
{
|
||||
if (++anArgIter >= theArgNb)
|
||||
{
|
||||
std::cout << "Error: wrong syntax at " << anArg << "\n";
|
||||
return 1;
|
||||
}
|
||||
aChangeSet->ToSetMaxParamValue = 1;
|
||||
aChangeSet->MaxParamValue = Draw::Atof (theArgVec[anArgIter]);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Error: wrong syntax at " << anArg << "\n";
|
||||
@@ -2146,6 +2197,14 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
|
||||
{
|
||||
aDrawer->FreeBoundaryAspect()->SetColor (aChangeSet->FreeBoundaryColor);
|
||||
}
|
||||
if (aChangeSet->ToEnableIsoOnTriangulation != -1)
|
||||
{
|
||||
aDrawer->SetIsoOnTriangulation (aChangeSet->ToEnableIsoOnTriangulation == 1);
|
||||
}
|
||||
if (aChangeSet->ToSetMaxParamValue != 0)
|
||||
{
|
||||
aDrawer->SetMaximalParameterValue (aChangeSet->MaxParamValue);
|
||||
}
|
||||
|
||||
// redisplay all objects in context
|
||||
for (ViewTest_PrsIter aPrsIter (aNames); aPrsIter.More(); aPrsIter.Next())
|
||||
@@ -2229,6 +2288,11 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
|
||||
{
|
||||
aCtx->UnsetWidth (aPrs, Standard_False);
|
||||
}
|
||||
else if (aChangeSet->ToEnableIsoOnTriangulation != -1)
|
||||
{
|
||||
aCtx->IsoOnTriangulation (aChangeSet->ToEnableIsoOnTriangulation == 1, aPrs);
|
||||
toRedisplay = Standard_True;
|
||||
}
|
||||
if (!aDrawer.IsNull())
|
||||
{
|
||||
if (aChangeSet->ToSetShowFreeBoundary == 1)
|
||||
@@ -2268,6 +2332,10 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
|
||||
aDrawer->SeenLineAspect()->SetTypeOfLine (aChangeSet->TypeOfLine);
|
||||
toRedisplay = Standard_True;
|
||||
}
|
||||
if (aChangeSet->ToSetMaxParamValue != 0)
|
||||
{
|
||||
aDrawer->SetMaximalParameterValue (aChangeSet->MaxParamValue);
|
||||
}
|
||||
}
|
||||
|
||||
for (aChangesIter.Next(); aChangesIter.More(); aChangesIter.Next())
|
||||
@@ -2295,6 +2363,11 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
|
||||
{
|
||||
aColoredPrs->UnsetCustomAspects (aSubShape, Standard_True);
|
||||
}
|
||||
if (aChangeSet->ToSetMaxParamValue != 0)
|
||||
{
|
||||
Handle(AIS_ColoredDrawer) aCurColDrawer = aColoredPrs->CustomAspects (aSubShape);
|
||||
aCurColDrawer->SetMaximalParameterValue (aChangeSet->MaxParamValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (toDisplay)
|
||||
@@ -5465,6 +5538,8 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands)
|
||||
"\n\t\t: [-setFreeBoundaryWidth Width] [-unsetFreeBoundaryWidth]"
|
||||
"\n\t\t: [-setFreeBoundaryColor {ColorName | R G B}] [-unsetFreeBoundaryColor]"
|
||||
"\n\t\t: [-subshapes subname1 [subname2 [...]]]"
|
||||
"\n\t\t: [-isoontriangulation 0|1]"
|
||||
"\n\t\t: [-setMaxParamValue {value}]"
|
||||
"\n\t\t: Manage presentation properties of all, selected or named objects."
|
||||
"\n\t\t: When -subshapes is specified than following properties will be"
|
||||
"\n\t\t: assigned to specified sub-shapes."
|
||||
|
@@ -2755,7 +2755,7 @@ static int VDrawText (Draw_Interpretor& theDI,
|
||||
#include <TShort_HArray1OfShortReal.hxx>
|
||||
|
||||
#include <AIS_Triangulation.hxx>
|
||||
#include <StdPrs_ToolShadedShape.hxx>
|
||||
#include <StdPrs_ToolTriangulatedShape.hxx>
|
||||
#include <Poly_Connect.hxx>
|
||||
#include <TColgp_Array1OfDir.hxx>
|
||||
#include <Graphic3d_GraphicDriver.hxx>
|
||||
@@ -5848,7 +5848,7 @@ static Standard_Integer VPointCloud (Draw_Interpretor& theDI,
|
||||
for (TopExp_Explorer aFaceIt (aShape, TopAbs_FACE); aFaceIt.More(); aFaceIt.Next())
|
||||
{
|
||||
const TopoDS_Face& aFace = TopoDS::Face (aFaceIt.Current());
|
||||
Handle(Poly_Triangulation) aTriangulation = StdPrs_ToolShadedShape::Triangulation (aFace, aLocation);
|
||||
Handle(Poly_Triangulation) aTriangulation = BRep_Tool::Triangulation (aFace, aLocation);
|
||||
if (!aTriangulation.IsNull())
|
||||
{
|
||||
aNbPoints += aTriangulation->NbNodes();
|
||||
@@ -5864,7 +5864,7 @@ static Standard_Integer VPointCloud (Draw_Interpretor& theDI,
|
||||
for (TopExp_Explorer aFaceIt (aShape, TopAbs_FACE); aFaceIt.More(); aFaceIt.Next())
|
||||
{
|
||||
const TopoDS_Face& aFace = TopoDS::Face (aFaceIt.Current());
|
||||
Handle(Poly_Triangulation) aTriangulation = StdPrs_ToolShadedShape::Triangulation (aFace, aLocation);
|
||||
Handle(Poly_Triangulation) aTriangulation = BRep_Tool::Triangulation (aFace, aLocation);
|
||||
if (aTriangulation.IsNull())
|
||||
{
|
||||
continue;
|
||||
@@ -5878,7 +5878,7 @@ static Standard_Integer VPointCloud (Draw_Interpretor& theDI,
|
||||
if (hasNormals)
|
||||
{
|
||||
Poly_Connect aPolyConnect (aTriangulation);
|
||||
StdPrs_ToolShadedShape::Normal (aFace, aPolyConnect, aNormals);
|
||||
StdPrs_ToolTriangulatedShape::Normal (aFace, aPolyConnect, aNormals);
|
||||
}
|
||||
|
||||
for (Standard_Integer aNodeIter = aNodes.Lower(); aNodeIter <= aNodes.Upper(); ++aNodeIter)
|
||||
|
Reference in New Issue
Block a user