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:
@@ -1,3 +1,5 @@
|
||||
StdPrs_BndBox.cxx
|
||||
StdPrs_BndBox.hxx
|
||||
StdPrs_Curve.cxx
|
||||
StdPrs_Curve.hxx
|
||||
StdPrs_DeflectionCurve.cxx
|
||||
@@ -8,6 +10,8 @@ StdPrs_HLRShape.cxx
|
||||
StdPrs_HLRShape.hxx
|
||||
StdPrs_HLRToolShape.cxx
|
||||
StdPrs_HLRToolShape.hxx
|
||||
StdPrs_Isolines.cxx
|
||||
StdPrs_Isolines.hxx
|
||||
StdPrs_Plane.cxx
|
||||
StdPrs_Plane.hxx
|
||||
StdPrs_Point.hxx
|
||||
@@ -21,21 +25,24 @@ StdPrs_ToolPoint.cxx
|
||||
StdPrs_ToolPoint.hxx
|
||||
StdPrs_ToolRFace.cxx
|
||||
StdPrs_ToolRFace.hxx
|
||||
StdPrs_ToolShadedShape.cxx
|
||||
StdPrs_ToolShadedShape.hxx
|
||||
StdPrs_ToolTriangulatedShape.cxx
|
||||
StdPrs_ToolTriangulatedShape.cxx
|
||||
StdPrs_ToolTriangulatedShape.hxx
|
||||
StdPrs_ToolTriangulatedShape.hxx
|
||||
StdPrs_ToolVertex.cxx
|
||||
StdPrs_ToolVertex.hxx
|
||||
StdPrs_Vertex.hxx
|
||||
StdPrs_Volume.hxx
|
||||
StdPrs_WFDeflectionRestrictedFace.cxx
|
||||
StdPrs_WFDeflectionRestrictedFace.hxx
|
||||
StdPrs_WFDeflectionShape.hxx
|
||||
StdPrs_WFDeflectionSurface.cxx
|
||||
StdPrs_WFDeflectionSurface.hxx
|
||||
StdPrs_WFPoleSurface.cxx
|
||||
StdPrs_WFPoleSurface.hxx
|
||||
StdPrs_WFRestrictedFace.cxx
|
||||
StdPrs_WFRestrictedFace.cxx
|
||||
StdPrs_WFRestrictedFace.hxx
|
||||
StdPrs_WFShape.cxx
|
||||
StdPrs_WFShape.hxx
|
||||
StdPrs_WFSurface.cxx
|
||||
StdPrs_WFSurface.hxx
|
||||
|
65
src/StdPrs/StdPrs_BndBox.cxx
Normal file
65
src/StdPrs/StdPrs_BndBox.cxx
Normal file
@@ -0,0 +1,65 @@
|
||||
// Created on: 2014-10-14
|
||||
// Created by: Anton POLETAEV
|
||||
// Copyright (c) 2013-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <StdPrs_BndBox.hxx>
|
||||
|
||||
#include <Aspect_TypeOfLine.hxx>
|
||||
#include <Graphic3d_AspectLine3d.hxx>
|
||||
#include <Graphic3d_ArrayOfPolylines.hxx>
|
||||
#include <Prs3d_LineAspect.hxx>
|
||||
#include <Quantity_Color.hxx>
|
||||
|
||||
namespace
|
||||
{
|
||||
static const Standard_Integer THE_INDICES[][3] =
|
||||
{ { 0, 0, 0 }, { 1, 0, 0 }, { 1, 0, 1 }, { 0, 0, 1 },
|
||||
{ 0, 1, 1 }, { 1, 1, 1 }, { 1, 1, 0 }, { 0, 1, 0 },
|
||||
{ 0, 0, 0 }, { 0, 0, 1 }, { 1, 0, 1 }, { 1, 1, 1 },
|
||||
{ 0, 1, 1 }, { 0, 1, 0 }, { 1, 1, 0 }, { 1, 0, 0 } };
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void StdPrs_BndBox::Add (const Handle(Prs3d_Presentation)& thePresentation,
|
||||
const Bnd_Box& theBndBox,
|
||||
const Handle(Prs3d_Drawer)& theDrawer)
|
||||
{
|
||||
if (theBndBox.IsVoid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Standard_Real X[2], Y[2], Z[2];
|
||||
theBndBox.Get (X[0], Y[0], Z[0], X[1], Y[1], Z[1]);
|
||||
|
||||
Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (thePresentation);
|
||||
Quantity_Color aColor;
|
||||
Aspect_TypeOfLine aDummyLineType;
|
||||
Standard_Real aWidth = 1.0;
|
||||
theDrawer->LineAspect()->Aspect()->Values (aColor, aDummyLineType, aWidth);
|
||||
|
||||
aGroup->SetGroupPrimitivesAspect (new Graphic3d_AspectLine3d (aColor, Aspect_TOL_DOTDASH, aWidth));
|
||||
|
||||
Handle(Graphic3d_ArrayOfPolylines) aPolyline = new Graphic3d_ArrayOfPolylines(16);
|
||||
for(Standard_Integer aVertIter = 0; aVertIter < 16; ++aVertIter)
|
||||
{
|
||||
aPolyline->AddVertex (X[THE_INDICES[aVertIter][0]],
|
||||
Y[THE_INDICES[aVertIter][1]],
|
||||
Z[THE_INDICES[aVertIter][2]]);
|
||||
}
|
||||
aGroup->AddPrimitiveArray (aPolyline);
|
||||
}
|
38
src/StdPrs/StdPrs_BndBox.hxx
Normal file
38
src/StdPrs/StdPrs_BndBox.hxx
Normal file
@@ -0,0 +1,38 @@
|
||||
// Created on: 2014-10-14
|
||||
// Created by: Anton POLETAEV
|
||||
// Copyright (c) 2013-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _StdPrs_BndBox_H__
|
||||
#define _StdPrs_BndBox_H__
|
||||
|
||||
#include <Prs3d_Root.hxx>
|
||||
#include <Prs3d_Drawer.hxx>
|
||||
#include <Prs3d_Presentation.hxx>
|
||||
#include <Bnd_Box.hxx>
|
||||
|
||||
//! Tool for computing bounding box presentation.
|
||||
class StdPrs_BndBox : public Prs3d_Root
|
||||
{
|
||||
public:
|
||||
|
||||
//! Computes presentation of a bounding box.
|
||||
//! @param thePresentation [in] the presentation.
|
||||
//! @param theBndBox [in] the bounding box.
|
||||
//! @param theDrawer [in] the drawer.
|
||||
Standard_EXPORT static void Add (const Handle(Prs3d_Presentation)& thePresentation,
|
||||
const Bnd_Box& theBndBox,
|
||||
const Handle(Prs3d_Drawer)& theDrawer);
|
||||
};
|
||||
|
||||
#endif // _StdPrs_BndBox_H__
|
@@ -244,11 +244,10 @@ void StdPrs_Curve::Add (const Handle (Prs3d_Presentation)& aPresentation,
|
||||
// purpose:
|
||||
//==================================================================
|
||||
void StdPrs_Curve::Add (const Handle (Prs3d_Presentation)& aPresentation,
|
||||
const Adaptor3d_Curve& aCurve,
|
||||
const Quantity_Length /*aDeflection*/,
|
||||
const Adaptor3d_Curve& aCurve,
|
||||
const Handle(Prs3d_Drawer)& aDrawer,
|
||||
TColgp_SequenceOfPnt& Points,
|
||||
const Standard_Boolean drawCurve)
|
||||
TColgp_SequenceOfPnt& Points,
|
||||
const Standard_Boolean drawCurve)
|
||||
{
|
||||
Standard_Real V1, V2;
|
||||
FindLimits(aCurve, aDrawer->MaximalParameterValue(), V1, V2);
|
||||
@@ -257,24 +256,21 @@ void StdPrs_Curve::Add (const Handle (Prs3d_Presentation)& aPresentation,
|
||||
DrawCurve(aCurve,Prs3d_Root::CurrentGroup(aPresentation),NbPoints,V1,V2,Points,drawCurve);
|
||||
}
|
||||
|
||||
|
||||
//==================================================================
|
||||
// function: Add
|
||||
// purpose:
|
||||
//==================================================================
|
||||
void StdPrs_Curve::Add (const Handle (Prs3d_Presentation)& aPresentation,
|
||||
const Adaptor3d_Curve& aCurve,
|
||||
const Adaptor3d_Curve& aCurve,
|
||||
const Standard_Real U1,
|
||||
const Standard_Real U2,
|
||||
const Quantity_Length /*aDeflection*/,
|
||||
TColgp_SequenceOfPnt& Points,
|
||||
const Standard_Integer NbPoints,
|
||||
const Standard_Boolean drawCurve)
|
||||
const Standard_Boolean drawCurve)
|
||||
{
|
||||
DrawCurve(aCurve,Prs3d_Root::CurrentGroup(aPresentation),NbPoints,U1,U2,Points,drawCurve);
|
||||
}
|
||||
|
||||
|
||||
//==================================================================
|
||||
// function: Add
|
||||
// purpose:
|
||||
|
@@ -64,7 +64,7 @@ public:
|
||||
//! If drawCurve equals Standard_False the curve will not be displayed,
|
||||
//! it is used if the curve is a part of some shape and PrimitiveArray
|
||||
//! visualization approach is activated (it is activated by default).
|
||||
Standard_EXPORT static void Add (const Handle(Prs3d_Presentation)& aPresentation, const Adaptor3d_Curve& aCurve, const Quantity_Length aDeflection, const Handle(Prs3d_Drawer)& aDrawer, TColgp_SequenceOfPnt& Points, const Standard_Boolean drawCurve = Standard_True);
|
||||
Standard_EXPORT static void Add (const Handle(Prs3d_Presentation)& aPresentation, const Adaptor3d_Curve& aCurve, const Handle(Prs3d_Drawer)& aDrawer, TColgp_SequenceOfPnt& Points, const Standard_Boolean drawCurve = Standard_True);
|
||||
|
||||
//! adds to the presentation aPresentation the drawing of the curve
|
||||
//! aCurve.
|
||||
@@ -76,7 +76,7 @@ public:
|
||||
//! If drawCurve equals Standard_False the curve will not be displayed,
|
||||
//! it is used if the curve is a part of some shape and PrimitiveArray
|
||||
//! visualization approach is activated (it is activated by default).
|
||||
Standard_EXPORT static void Add (const Handle(Prs3d_Presentation)& aPresentation, const Adaptor3d_Curve& aCurve, const Standard_Real U1, const Standard_Real U2, const Quantity_Length aDeflection, TColgp_SequenceOfPnt& Points, const Standard_Integer aNbPoints = 30, const Standard_Boolean drawCurve = Standard_True);
|
||||
Standard_EXPORT static void Add (const Handle(Prs3d_Presentation)& aPresentation, const Adaptor3d_Curve& aCurve, const Standard_Real U1, const Standard_Real U2, TColgp_SequenceOfPnt& Points, const Standard_Integer aNbPoints = 30, const Standard_Boolean drawCurve = Standard_True);
|
||||
|
||||
//! returns true if the distance between the point (X,Y,Z) and the
|
||||
//! drawing of the curve is less than aDistance.
|
||||
|
753
src/StdPrs/StdPrs_Isolines.cxx
Normal file
753
src/StdPrs/StdPrs_Isolines.cxx
Normal file
@@ -0,0 +1,753 @@
|
||||
// Created on: 2014-10-14
|
||||
// Created by: Anton POLETAEV
|
||||
// Copyright (c) 2013-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <StdPrs_Isolines.hxx>
|
||||
|
||||
#include <Adaptor3d_IsoCurve.hxx>
|
||||
#include <BRepTools.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <ElCLib.hxx>
|
||||
#include <ElSLib.hxx>
|
||||
#include <GCE2d_MakeLine.hxx>
|
||||
#include <gce_MakeLin2d.hxx>
|
||||
#include <gce_MakePln.hxx>
|
||||
#include <gce_MakeLin.hxx>
|
||||
#include <GCPnts_AbscissaPoint.hxx>
|
||||
#include <GCPnts_QuasiUniformDeflection.hxx>
|
||||
#include <Geom_BezierSurface.hxx>
|
||||
#include <Geom_BSplineSurface.hxx>
|
||||
#include <Geom_Plane.hxx>
|
||||
#include <Geom_Line.hxx>
|
||||
#include <Geom2d_Line.hxx>
|
||||
#include <Geom2dAdaptor_Curve.hxx>
|
||||
#include <Geom2dInt_GInter.hxx>
|
||||
#include <GeomAdaptor_Curve.hxx>
|
||||
#include <GeomAPI_IntCS.hxx>
|
||||
#include <GeomLib.hxx>
|
||||
#include <GeomLib_Tool.hxx>
|
||||
#include <gp_Lin2d.hxx>
|
||||
#include <Graphic3d_ArrayOfSegments.hxx>
|
||||
#include <Graphic3d_ArrayOfPolylines.hxx>
|
||||
#include <Hatch_Hatcher.hxx>
|
||||
#include <IntRes2d_IntersectionPoint.hxx>
|
||||
#include <NCollection_List.hxx>
|
||||
#include <NCollection_QuickSort.hxx>
|
||||
#include <ProjLib.hxx>
|
||||
#include <Prs3d_IsoAspect.hxx>
|
||||
#include <Prs3d_NListOfSequenceOfPnt.hxx>
|
||||
#include <Prs3d_NListIteratorOfListOfSequenceOfPnt.hxx>
|
||||
#include <Poly_Array1OfTriangle.hxx>
|
||||
#include <Poly_Triangulation.hxx>
|
||||
#include <StdPrs_DeflectionCurve.hxx>
|
||||
#include <StdPrs_ToolRFace.hxx>
|
||||
#include <TColgp_Array1OfPnt.hxx>
|
||||
#include <TColgp_SequenceOfPnt2d.hxx>
|
||||
#include <Standard_ErrorHandler.hxx>
|
||||
|
||||
typedef NCollection_Sequence<Handle(TColgp_HSequenceOfPnt)> Prs3d_NSequenceOfSequenceOfPnt;
|
||||
|
||||
namespace
|
||||
{
|
||||
const gp_Lin2d isoU (const Standard_Real theU) { return gp_Lin2d (gp_Pnt2d (theU, 0.0), gp::DY2d()); }
|
||||
const gp_Lin2d isoV (const Standard_Real theV) { return gp_Lin2d (gp_Pnt2d (0.0, theV), gp::DX2d()); }
|
||||
|
||||
//! Assembles array of primitives for sequence of polyine points.
|
||||
//! @param thePoints [in] the polyline points.
|
||||
//! @return array of primitives.
|
||||
template <typename T>
|
||||
inline Handle(T) primitivesForPolyline (const Prs3d_NSequenceOfSequenceOfPnt& thePoints)
|
||||
{
|
||||
if (thePoints.IsEmpty())
|
||||
{
|
||||
return Handle(T)();
|
||||
}
|
||||
|
||||
Standard_Integer aNbBounds = thePoints.Size();
|
||||
Standard_Integer aNbVertices = 0;
|
||||
for (Prs3d_NSequenceOfSequenceOfPnt::Iterator anIt (thePoints); anIt.More(); anIt.Next())
|
||||
{
|
||||
aNbVertices += anIt.Value()->Length();
|
||||
}
|
||||
Handle(T) aPrimitives = new T (aNbVertices, aNbBounds);
|
||||
for (NCollection_Sequence<Handle(TColgp_HSequenceOfPnt)>::Iterator anIt (thePoints); anIt.More(); anIt.Next())
|
||||
{
|
||||
const Handle(TColgp_HSequenceOfPnt)& aPoints = anIt.Value();
|
||||
aPrimitives->AddBound (aPoints->Length());
|
||||
for (Standard_Integer anI = 1; anI <= aPoints->Length(); ++anI)
|
||||
{
|
||||
aPrimitives->AddVertex (aPoints->Value (anI));
|
||||
}
|
||||
}
|
||||
|
||||
return aPrimitives;
|
||||
}
|
||||
|
||||
//! Reoder and adjust to the limit a curve's parameter values.
|
||||
//! @param theCurve [in] the curve.
|
||||
//! @param theLimit [in] the parameter limit value.
|
||||
//! @param theFirst [in/out] the first parameter value.
|
||||
//! @param theLast [in/out] the last parameter value.
|
||||
static void findLimits (const Adaptor3d_Curve& theCurve,
|
||||
const Standard_Real theLimit,
|
||||
Standard_Real& theFirst,
|
||||
Standard_Real& theLast)
|
||||
{
|
||||
theFirst = Max (theCurve.FirstParameter(), theFirst);
|
||||
theLast = Min (theCurve.LastParameter(), theLast);
|
||||
|
||||
Standard_Boolean isFirstInf = Precision::IsNegativeInfinite (theFirst);
|
||||
Standard_Boolean isLastInf = Precision::IsPositiveInfinite (theLast);
|
||||
|
||||
if (!isFirstInf && !isLastInf)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
gp_Pnt aP1, aP2;
|
||||
Standard_Real aDelta = 1.0;
|
||||
if (isFirstInf && isLastInf)
|
||||
{
|
||||
do
|
||||
{
|
||||
aDelta *= 2.0;
|
||||
theFirst = -aDelta;
|
||||
theLast = aDelta;
|
||||
theCurve.D0 (theFirst, aP1);
|
||||
theCurve.D0 (theLast, aP2);
|
||||
}
|
||||
while (aP1.Distance (aP2) < theLimit);
|
||||
}
|
||||
else if (isFirstInf)
|
||||
{
|
||||
theCurve.D0 (theLast, aP2);
|
||||
do
|
||||
{
|
||||
aDelta *= 2.0;
|
||||
theFirst = theLast - aDelta;
|
||||
theCurve.D0 (theFirst, aP1);
|
||||
}
|
||||
while (aP1.Distance (aP2) < theLimit);
|
||||
}
|
||||
else if (isLastInf)
|
||||
{
|
||||
theCurve.D0 (theFirst, aP1);
|
||||
do
|
||||
{
|
||||
aDelta *= 2.0;
|
||||
theLast = theFirst + aDelta;
|
||||
theCurve.D0 (theLast, aP2);
|
||||
}
|
||||
while (aP1.Distance (aP2) < theLimit);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//==================================================================
|
||||
// function : AddOnTriangulation
|
||||
// purpose :
|
||||
//==================================================================
|
||||
void StdPrs_Isolines::AddOnTriangulation (const Handle(Prs3d_Presentation)& thePresentation,
|
||||
const TopoDS_Face& theFace,
|
||||
const Handle(Prs3d_Drawer)& theDrawer)
|
||||
{
|
||||
const Standard_Integer aNbIsoU = theDrawer->UIsoAspect()->Number();
|
||||
const Standard_Integer aNbIsoV = theDrawer->VIsoAspect()->Number();
|
||||
if (aNbIsoU < 1 && aNbIsoV < 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Evalute parameters for uv isolines.
|
||||
TColStd_SequenceOfReal aUIsoParams;
|
||||
TColStd_SequenceOfReal aVIsoParams;
|
||||
UVIsoParameters (theFace, aNbIsoU, aNbIsoV, theDrawer->MaximalParameterValue(), aUIsoParams, aVIsoParams);
|
||||
|
||||
// Access surface definition.
|
||||
TopLoc_Location aLocSurface;
|
||||
Handle(Geom_Surface) aSurface = BRep_Tool::Surface (theFace, aLocSurface);
|
||||
|
||||
// Access triangulation.
|
||||
TopLoc_Location aLocTriangulation;
|
||||
const Handle(Poly_Triangulation)& aTriangulation = BRep_Tool::Triangulation (theFace, aLocTriangulation);
|
||||
if (aTriangulation.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Setup equal location for surface and triangulation.
|
||||
if (!aLocTriangulation.IsEqual (aLocSurface))
|
||||
{
|
||||
aSurface = Handle (Geom_Surface)::DownCast (
|
||||
aSurface->Transformed ((aLocSurface / aLocTriangulation).Transformation()));
|
||||
}
|
||||
|
||||
AddOnTriangulation (thePresentation,
|
||||
aTriangulation,
|
||||
aSurface,
|
||||
aLocTriangulation,
|
||||
theDrawer,
|
||||
aUIsoParams,
|
||||
aVIsoParams);
|
||||
}
|
||||
|
||||
//==================================================================
|
||||
// function : AddOnTriangulation
|
||||
// purpose :
|
||||
//==================================================================
|
||||
void StdPrs_Isolines::AddOnTriangulation (const Handle(Prs3d_Presentation)& thePresentation,
|
||||
const Handle(Poly_Triangulation)& theTriangulation,
|
||||
const Handle(Geom_Surface)& theSurface,
|
||||
const TopLoc_Location& theLocation,
|
||||
const Handle(Prs3d_Drawer)& theDrawer,
|
||||
const TColStd_SequenceOfReal& theUIsoParams,
|
||||
const TColStd_SequenceOfReal& theVIsoParams)
|
||||
{
|
||||
const Standard_Integer aNbIsoU = theUIsoParams.Length();
|
||||
const Standard_Integer aNbIsoV = theVIsoParams.Length();
|
||||
|
||||
Prs3d_NSequenceOfSequenceOfPnt aUPolylines;
|
||||
Prs3d_NSequenceOfSequenceOfPnt aVPolylines;
|
||||
|
||||
const Poly_Array1OfTriangle& aTriangles = theTriangulation->Triangles();
|
||||
const TColgp_Array1OfPnt& aNodes = theTriangulation->Nodes();
|
||||
const TColgp_Array1OfPnt2d& aUVNodes = theTriangulation->UVNodes();
|
||||
|
||||
TColStd_Array1OfInteger aUIsoIndexes (1, aNbIsoU);
|
||||
TColStd_Array1OfInteger aVIsoIndexes (1, aNbIsoV);
|
||||
aUIsoIndexes.Init (-1);
|
||||
aVIsoIndexes.Init (-1);
|
||||
|
||||
for (Standard_Integer anI = aTriangles.Lower(); anI <= aTriangles.Upper(); ++anI)
|
||||
{
|
||||
Standard_Integer aNodeIdxs[3];
|
||||
aTriangles.Value (anI).Get (aNodeIdxs[0], aNodeIdxs[1],aNodeIdxs[2]);
|
||||
const gp_Pnt aNodesXYZ[3] = { aNodes.Value (aNodeIdxs[0]),
|
||||
aNodes.Value (aNodeIdxs[1]),
|
||||
aNodes.Value (aNodeIdxs[2]) };
|
||||
const gp_Pnt2d aNodesUV[3] = { aUVNodes.Value (aNodeIdxs[0]),
|
||||
aUVNodes.Value (aNodeIdxs[1]),
|
||||
aUVNodes.Value (aNodeIdxs[2]) };
|
||||
|
||||
// Evaluate polyline points for u isolines.
|
||||
for (Standard_Integer anIsoIdx = 1; anIsoIdx <= aNbIsoU; ++anIsoIdx)
|
||||
{
|
||||
gp_Pnt aSegment[2];
|
||||
const gp_Lin2d anIsolineUV = isoU (theUIsoParams.Value (anIsoIdx));
|
||||
|
||||
// Find intersections with triangle in uv space and its projection on triangulation.
|
||||
if (!findSegmentOnTriangulation (theSurface, anIsolineUV, aNodesXYZ, aNodesUV, aSegment))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (aUIsoIndexes.Value (anIsoIdx) == -1)
|
||||
{
|
||||
aUPolylines.Append (new TColgp_HSequenceOfPnt());
|
||||
aUIsoIndexes.SetValue (anIsoIdx, aUPolylines.Size());
|
||||
}
|
||||
|
||||
Handle(TColgp_HSequenceOfPnt) anIsoPnts = aUPolylines.ChangeValue (aUIsoIndexes.Value (anIsoIdx));
|
||||
anIsoPnts->Append (theLocation.IsIdentity() ? aSegment[0] : aSegment[0].Transformed (theLocation));
|
||||
anIsoPnts->Append (theLocation.IsIdentity() ? aSegment[1] : aSegment[1].Transformed (theLocation));
|
||||
}
|
||||
|
||||
// Evaluate polyline points for v isolines.
|
||||
for (Standard_Integer anIsoIdx = 1; anIsoIdx <= aNbIsoV; ++anIsoIdx)
|
||||
{
|
||||
gp_Pnt aSegment[2];
|
||||
const gp_Lin2d anIsolineUV = isoV (theVIsoParams.Value (anIsoIdx));
|
||||
|
||||
if (!findSegmentOnTriangulation (theSurface, anIsolineUV, aNodesXYZ, aNodesUV, aSegment))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (aVIsoIndexes.Value (anIsoIdx) == -1)
|
||||
{
|
||||
aVPolylines.Append (new TColgp_HSequenceOfPnt());
|
||||
aVIsoIndexes.SetValue (anIsoIdx, aVPolylines.Size());
|
||||
}
|
||||
|
||||
Handle(TColgp_HSequenceOfPnt) anIsoPnts = aVPolylines.ChangeValue (aVIsoIndexes.Value (anIsoIdx));
|
||||
anIsoPnts->Append (theLocation.IsIdentity() ? aSegment[0] : aSegment[0].Transformed (theLocation));
|
||||
anIsoPnts->Append (theLocation.IsIdentity() ? aSegment[1] : aSegment[1].Transformed (theLocation));
|
||||
}
|
||||
}
|
||||
|
||||
// Add primitive arrays for isoline segments.
|
||||
Handle(Graphic3d_ArrayOfSegments) aUPrimitives = primitivesForPolyline<Graphic3d_ArrayOfSegments> (aUPolylines);
|
||||
Handle(Graphic3d_ArrayOfSegments) aVPrimitives = primitivesForPolyline<Graphic3d_ArrayOfSegments> (aVPolylines);
|
||||
|
||||
if (!aUPrimitives.IsNull())
|
||||
{
|
||||
Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup (thePresentation);
|
||||
aGroup->SetPrimitivesAspect (theDrawer->UIsoAspect()->Aspect());
|
||||
aGroup->AddPrimitiveArray (aUPrimitives);
|
||||
}
|
||||
|
||||
if (!aVPrimitives.IsNull())
|
||||
{
|
||||
Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup (thePresentation);
|
||||
aGroup->SetPrimitivesAspect (theDrawer->VIsoAspect()->Aspect());
|
||||
aGroup->AddPrimitiveArray (aVPrimitives);
|
||||
}
|
||||
}
|
||||
|
||||
//==================================================================
|
||||
// function : AddOnSurface
|
||||
// purpose :
|
||||
//==================================================================
|
||||
void StdPrs_Isolines::AddOnSurface (const Handle(Prs3d_Presentation)& thePresentation,
|
||||
const TopoDS_Face& theFace,
|
||||
const Handle(Prs3d_Drawer)& theDrawer,
|
||||
const Standard_Real theDeflection)
|
||||
{
|
||||
const Standard_Integer aNbIsoU = theDrawer->UIsoAspect()->Number();
|
||||
const Standard_Integer aNbIsoV = theDrawer->VIsoAspect()->Number();
|
||||
if (aNbIsoU < 1 && aNbIsoV < 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Evalute parameters for uv isolines.
|
||||
TColStd_SequenceOfReal aUIsoParams;
|
||||
TColStd_SequenceOfReal aVIsoParams;
|
||||
UVIsoParameters (theFace, aNbIsoU, aNbIsoV, theDrawer->MaximalParameterValue(), aUIsoParams, aVIsoParams);
|
||||
|
||||
BRepAdaptor_Surface aSurface (theFace);
|
||||
AddOnSurface (thePresentation,
|
||||
new BRepAdaptor_HSurface (aSurface),
|
||||
theDrawer,
|
||||
theDeflection,
|
||||
aUIsoParams,
|
||||
aVIsoParams);
|
||||
}
|
||||
|
||||
//==================================================================
|
||||
// function : AddOnSurface
|
||||
// purpose :
|
||||
//==================================================================
|
||||
void StdPrs_Isolines::AddOnSurface (const Handle(Prs3d_Presentation)& thePresentation,
|
||||
const Handle(BRepAdaptor_HSurface)& theSurface,
|
||||
const Handle(Prs3d_Drawer)& theDrawer,
|
||||
const Standard_Real theDeflection,
|
||||
const TColStd_SequenceOfReal& theUIsoParams,
|
||||
const TColStd_SequenceOfReal& theVIsoParams)
|
||||
{
|
||||
// Choose a deflection for sampling edge uv curves.
|
||||
Standard_Real aUVLimit = theDrawer->MaximalParameterValue();
|
||||
Standard_Real aUmin = Max (theSurface->FirstUParameter(), -aUVLimit);
|
||||
Standard_Real aUmax = Min (theSurface->LastUParameter(), aUVLimit);
|
||||
Standard_Real aVmin = Max (theSurface->FirstVParameter(), -aUVLimit);
|
||||
Standard_Real aVmax = Min (theSurface->LastVParameter(), aUVLimit);
|
||||
Standard_Real aSamplerDeflection = Max (aUmax - aUmin, aVmax - aVmin) * theDrawer->DeviationCoefficient();
|
||||
Standard_Real aHatchingTolerance = RealLast();
|
||||
Prs3d_NSequenceOfSequenceOfPnt aUPolylines;
|
||||
Prs3d_NSequenceOfSequenceOfPnt aVPolylines;
|
||||
|
||||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS
|
||||
// Determine edge points for trimming uv hatch region.
|
||||
TColgp_SequenceOfPnt2d aTrimPoints;
|
||||
StdPrs_ToolRFace anEdgeTool (theSurface);
|
||||
for (anEdgeTool.Init(); anEdgeTool.More(); anEdgeTool.Next())
|
||||
{
|
||||
TopAbs_Orientation anOrientation = anEdgeTool.Orientation();
|
||||
if (anOrientation != TopAbs_FORWARD && anOrientation != TopAbs_REVERSED)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Adaptor2d_Curve2dPtr anEdgeCurve = anEdgeTool.Value();
|
||||
if (anEdgeCurve->GetType() != GeomAbs_Line)
|
||||
{
|
||||
GCPnts_QuasiUniformDeflection aSampler (*anEdgeCurve, aSamplerDeflection);
|
||||
if (!aSampler.IsDone())
|
||||
{
|
||||
#ifdef OCCT_DEBUG
|
||||
std::cout << "Cannot evaluate curve on surface" << std::endl;
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
|
||||
Standard_Integer aNumberOfPoints = aSampler.NbPoints();
|
||||
if (aNumberOfPoints < 2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (Standard_Integer anI = 1; anI < aNumberOfPoints; ++anI)
|
||||
{
|
||||
gp_Pnt2d aP1 (aSampler.Value (anI ).X(), aSampler.Value (anI ).Y());
|
||||
gp_Pnt2d aP2 (aSampler.Value (anI + 1).X(), aSampler.Value (anI + 1).Y());
|
||||
|
||||
aHatchingTolerance = Min (aP1.SquareDistance (aP2), aHatchingTolerance);
|
||||
|
||||
aTrimPoints.Append (anOrientation == TopAbs_FORWARD ? aP1 : aP2);
|
||||
aTrimPoints.Append (anOrientation == TopAbs_FORWARD ? aP2 : aP1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Standard_Real aU1 = anEdgeCurve->FirstParameter();
|
||||
Standard_Real aU2 = anEdgeCurve->LastParameter();
|
||||
|
||||
// MSV 17.08.06 OCC13144: U2 occured less than U1, to overcome it
|
||||
// ensure that distance U2-U1 is not greater than aLimit*2,
|
||||
// if greater then choose an origin and use aLimit to define
|
||||
// U1 and U2 anew.
|
||||
Standard_Real anOrigin = 0.0;
|
||||
|
||||
if (!Precision::IsNegativeInfinite (aU1) || !Precision::IsPositiveInfinite(aU2))
|
||||
{
|
||||
if (Precision::IsNegativeInfinite (aU1))
|
||||
{
|
||||
anOrigin = aU2 - aUVLimit;
|
||||
}
|
||||
else if (Precision::IsPositiveInfinite (aU2))
|
||||
{
|
||||
anOrigin = aU1 + aUVLimit;
|
||||
}
|
||||
else
|
||||
{
|
||||
anOrigin = (aU1 + aU2) * 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
aU1 = Max (anOrigin - aUVLimit, aU1);
|
||||
aU2 = Min (anOrigin + aUVLimit, aU2);
|
||||
|
||||
gp_Pnt2d aP1 = anEdgeCurve->Value (aU1);
|
||||
gp_Pnt2d aP2 = anEdgeCurve->Value (aU2);
|
||||
|
||||
aHatchingTolerance = Min (aP1.SquareDistance(aP2), aHatchingTolerance);
|
||||
|
||||
aTrimPoints.Append (anOrientation == TopAbs_FORWARD ? aP1 : aP2);
|
||||
aTrimPoints.Append (anOrientation == TopAbs_FORWARD ? aP2 : aP1);
|
||||
}
|
||||
}
|
||||
|
||||
// Compute a hatching tolerance.
|
||||
aHatchingTolerance *= 0.1;
|
||||
aHatchingTolerance = Max (Precision::Confusion(), aHatchingTolerance);
|
||||
aHatchingTolerance = Min (1.0E-5, aHatchingTolerance);
|
||||
|
||||
// Load isolines into hatcher.
|
||||
Hatch_Hatcher aHatcher (aHatchingTolerance, anEdgeTool.IsOriented());
|
||||
|
||||
for (Standard_Integer anIso = 1; anIso <= theUIsoParams.Length(); ++anIso)
|
||||
{
|
||||
aHatcher.AddXLine (theUIsoParams.Value (anIso));
|
||||
}
|
||||
for (Standard_Integer anIso = 1; anIso <= theVIsoParams.Length(); ++anIso)
|
||||
{
|
||||
aHatcher.AddYLine (theVIsoParams.Value (anIso));
|
||||
}
|
||||
|
||||
// Trim hatching region.
|
||||
for (Standard_Integer anI = 1; anI <= aTrimPoints.Length(); anI += 2)
|
||||
{
|
||||
aHatcher.Trim (aTrimPoints (anI), aTrimPoints (anI + 1));
|
||||
}
|
||||
|
||||
// Use surface definition for evaluation of Bezier, B-spline surface.
|
||||
// Use isoline adapter for other types of surfaces.
|
||||
GeomAbs_SurfaceType aSurfType = theSurface->GetType();
|
||||
Handle(Geom_Surface) aBSurface;
|
||||
GeomAdaptor_Curve aBSurfaceCurve;
|
||||
Adaptor3d_IsoCurve aCanonicalCurve;
|
||||
if (aSurfType == GeomAbs_BezierSurface)
|
||||
{
|
||||
aBSurface = theSurface->Bezier();
|
||||
}
|
||||
else if (aSurfType == GeomAbs_BSplineSurface)
|
||||
{
|
||||
aBSurface = theSurface->BSpline();
|
||||
}
|
||||
else
|
||||
{
|
||||
aCanonicalCurve.Load (theSurface);
|
||||
}
|
||||
|
||||
// For each isoline: compute its segments.
|
||||
for (Standard_Integer anI = 1; anI <= aHatcher.NbLines(); anI++)
|
||||
{
|
||||
Standard_Real anIsoParam = aHatcher.Coordinate (anI);
|
||||
Standard_Boolean isIsoU = aHatcher.IsXLine (anI);
|
||||
|
||||
// For each isoline's segment: evaluate its points.
|
||||
for (Standard_Integer aJ = 1; aJ <= aHatcher.NbIntervals (anI); aJ++)
|
||||
{
|
||||
Standard_Real aSegmentP1 = aHatcher.Start (anI, aJ);
|
||||
Standard_Real aSegmentP2 = aHatcher.End (anI, aJ);
|
||||
|
||||
if (!aBSurface.IsNull())
|
||||
{
|
||||
aBSurfaceCurve.Load (isIsoU ? aBSurface->UIso (anIsoParam) : aBSurface->VIso (anIsoParam));
|
||||
|
||||
findLimits (aBSurfaceCurve, aUVLimit, aSegmentP1, aSegmentP2);
|
||||
|
||||
if (aSegmentP2 - aSegmentP1 <= Precision::Confusion())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
aCanonicalCurve.Load (isIsoU ? GeomAbs_IsoU : GeomAbs_IsoV, anIsoParam, aSegmentP1, aSegmentP2);
|
||||
|
||||
findLimits (aCanonicalCurve, aUVLimit, aSegmentP1, aSegmentP2);
|
||||
|
||||
if (aSegmentP2 - aSegmentP1 <= Precision::Confusion())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
Adaptor3d_Curve* aCurve = aBSurface.IsNull() ? (Adaptor3d_Curve*) &aCanonicalCurve
|
||||
: (Adaptor3d_Curve*) &aBSurfaceCurve;
|
||||
|
||||
Handle(TColgp_HSequenceOfPnt) aPoints = new TColgp_HSequenceOfPnt();
|
||||
StdPrs_DeflectionCurve::Add (thePresentation,
|
||||
*aCurve,
|
||||
aSegmentP1,
|
||||
aSegmentP2,
|
||||
theDeflection,
|
||||
aPoints->ChangeSequence(),
|
||||
theDrawer->DeviationAngle(),
|
||||
Standard_False);
|
||||
if (aPoints->IsEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isIsoU)
|
||||
{
|
||||
aUPolylines.Append (aPoints);
|
||||
}
|
||||
else
|
||||
{
|
||||
aVPolylines.Append (aPoints);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Standard_Failure)
|
||||
{
|
||||
// ...
|
||||
}
|
||||
|
||||
// Add primitive arrays for isoline segments.
|
||||
Handle(Graphic3d_ArrayOfPolylines) aUPrimitives = primitivesForPolyline<Graphic3d_ArrayOfPolylines> (aUPolylines);
|
||||
Handle(Graphic3d_ArrayOfPolylines) aVPrimitives = primitivesForPolyline<Graphic3d_ArrayOfPolylines> (aVPolylines);
|
||||
|
||||
if (!aUPrimitives.IsNull())
|
||||
{
|
||||
Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup (thePresentation);
|
||||
aGroup->SetPrimitivesAspect (theDrawer->UIsoAspect()->Aspect());
|
||||
aGroup->AddPrimitiveArray (aUPrimitives);
|
||||
}
|
||||
|
||||
if (!aVPrimitives.IsNull())
|
||||
{
|
||||
Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup (thePresentation);
|
||||
aGroup->SetPrimitivesAspect (theDrawer->VIsoAspect()->Aspect());
|
||||
aGroup->AddPrimitiveArray (aVPrimitives);
|
||||
}
|
||||
}
|
||||
|
||||
//==================================================================
|
||||
// function : UVIsoParameters
|
||||
// purpose :
|
||||
//==================================================================
|
||||
void StdPrs_Isolines::UVIsoParameters (const TopoDS_Face& theFace,
|
||||
const Standard_Integer theNbIsoU,
|
||||
const Standard_Integer theNbIsoV,
|
||||
const Standard_Real theUVLimit,
|
||||
TColStd_SequenceOfReal& theUIsoParams,
|
||||
TColStd_SequenceOfReal& theVIsoParams)
|
||||
{
|
||||
Standard_Real aUmin = 0.0;
|
||||
Standard_Real aUmax = 0.0;
|
||||
Standard_Real aVmin = 0.0;
|
||||
Standard_Real aVmax = 0.0;
|
||||
|
||||
BRepTools::UVBounds (theFace, aUmin, aUmax, aVmin, aVmax);
|
||||
|
||||
aUmin = Max (aUmin, -theUVLimit);
|
||||
aUmax = Min (aUmax, theUVLimit);
|
||||
aVmin = Max (aVmin, -theUVLimit);
|
||||
aVmax = Min (aVmax, theUVLimit);
|
||||
|
||||
TopLoc_Location aLocation;
|
||||
Handle(Geom_Surface) aSurface = BRep_Tool::Surface (theFace, aLocation);
|
||||
|
||||
const Standard_Boolean isUClosed = aSurface->IsUClosed();
|
||||
const Standard_Boolean isVClosed = aSurface->IsVClosed();
|
||||
|
||||
if (!isUClosed)
|
||||
{
|
||||
aUmin = aUmin + (aUmax - aUmin) / 1000.0;
|
||||
aUmax = aUmax - (aUmax - aUmin) / 1000.0;
|
||||
}
|
||||
|
||||
if (!isVClosed)
|
||||
{
|
||||
aVmin = aVmin + (aVmax - aVmin) / 1000.0;
|
||||
aVmax = aVmax - (aVmax - aVmin) / 1000.0;
|
||||
}
|
||||
|
||||
Standard_Real aUstep = (aUmax - aUmin) / (1 + theNbIsoU);
|
||||
Standard_Real aVstep = (aVmax - aVmin) / (1 + theNbIsoV);
|
||||
|
||||
for (Standard_Integer anIso = 1; anIso <= theNbIsoU; ++anIso)
|
||||
{
|
||||
theUIsoParams.Append (aUmin + aUstep * anIso);
|
||||
}
|
||||
|
||||
for (Standard_Integer anIso = 1; anIso <= theNbIsoV; ++anIso)
|
||||
{
|
||||
theVIsoParams.Append (aVmin + aVstep * anIso);
|
||||
}
|
||||
}
|
||||
|
||||
//==================================================================
|
||||
// function : FindSegmentOnTriangulation
|
||||
// purpose :
|
||||
//==================================================================
|
||||
Standard_Boolean StdPrs_Isolines::findSegmentOnTriangulation (const Handle(Geom_Surface)& theSurface,
|
||||
const gp_Lin2d& theIsoline,
|
||||
const gp_Pnt* theNodesXYZ,
|
||||
const gp_Pnt2d* theNodesUV,
|
||||
gp_Pnt* theSegment)
|
||||
{
|
||||
Standard_Integer aNPoints = 0;
|
||||
|
||||
for (Standard_Integer aLinkIter = 0; aLinkIter < 3 && aNPoints < 2; ++aLinkIter)
|
||||
{
|
||||
// ...
|
||||
// Check that uv isoline crosses the triangulation link in parametric space
|
||||
// ...
|
||||
|
||||
const gp_Pnt2d& aNodeUV1 = theNodesUV[aLinkIter];
|
||||
const gp_Pnt2d& aNodeUV2 = theNodesUV[(aLinkIter + 1) % 3];
|
||||
const gp_Pnt& aNode1 = theNodesXYZ[aLinkIter];
|
||||
const gp_Pnt& aNode2 = theNodesXYZ[(aLinkIter + 1) % 3];
|
||||
|
||||
// Compute distance of uv points to isoline taking into consideration their relative
|
||||
// location against the isoline (left or right). Null value for a node means that the
|
||||
// isoline crosses the node. Both positive or negative means that the isoline does not
|
||||
// cross the segment.
|
||||
Standard_Boolean isLeftUV1 = (theIsoline.Direction().XY() ^ gp_Vec2d (theIsoline.Location(), aNodeUV1).XY()) > 0.0;
|
||||
Standard_Boolean isLeftUV2 = (theIsoline.Direction().XY() ^ gp_Vec2d (theIsoline.Location(), aNodeUV2).XY()) > 0.0;
|
||||
Standard_Real aDistanceUV1 = isLeftUV1 ? theIsoline.Distance (aNodeUV1) : -theIsoline.Distance (aNodeUV1);
|
||||
Standard_Real aDistanceUV2 = isLeftUV2 ? theIsoline.Distance (aNodeUV2) : -theIsoline.Distance (aNodeUV2);
|
||||
|
||||
// Isoline crosses first point of an edge.
|
||||
if (Abs (aDistanceUV1) < Precision::PConfusion())
|
||||
{
|
||||
theSegment[aNPoints++] = aNode1;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Isoline crosses second point of an edge.
|
||||
if (Abs (aDistanceUV2) < Precision::PConfusion())
|
||||
{
|
||||
theSegment[aNPoints++] = aNode2;
|
||||
aLinkIter++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Isoline does not cross the triangle link.
|
||||
if (aDistanceUV1 * aDistanceUV2 > 0.0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Isoline crosses degenerated link.
|
||||
if (aNode1.SquareDistance (aNode2) < Precision::PConfusion())
|
||||
{
|
||||
theSegment[aNPoints++] = aNode1;
|
||||
continue;
|
||||
}
|
||||
|
||||
// ...
|
||||
// Derive cross-point from parametric coordinates
|
||||
// ...
|
||||
|
||||
Standard_Real anAlpha = Abs (aDistanceUV1) / (Abs (aDistanceUV1) + Abs (aDistanceUV2));
|
||||
|
||||
gp_Pnt aCross (0.0, 0.0, 0.0);
|
||||
|
||||
// Is surface definition available?
|
||||
if (theSurface.IsNull())
|
||||
{
|
||||
// Do linear interpolation of point coordinates using
|
||||
// triangulation nodes.
|
||||
aCross.SetX (aNode1.X() + anAlpha * (aNode2.X() - aNode1.X()));
|
||||
aCross.SetY (aNode1.Y() + anAlpha * (aNode2.Y() - aNode1.Y()));
|
||||
aCross.SetZ (aNode1.Z() + anAlpha * (aNode2.Z() - aNode1.Z()));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Do linear interpolation of point coordinates by triangulation nodes.
|
||||
Standard_Real aCrossU = aNodeUV1.X() + anAlpha * (aNodeUV2.X() - aNodeUV1.X());
|
||||
Standard_Real aCrossV = aNodeUV1.Y() + anAlpha * (aNodeUV2.Y() - aNodeUV1.Y());
|
||||
|
||||
// Get 3d point on surface.
|
||||
Handle(Geom_Curve) anIso1, anIso2, anIso3;
|
||||
Standard_Real aPntOnNode1Iso = 0.0;
|
||||
Standard_Real aPntOnNode2Iso = 0.0;
|
||||
Standard_Real aPntOnNode3Iso = 0.0;
|
||||
|
||||
if (theIsoline.Direction().X() == 0.0)
|
||||
{
|
||||
aPntOnNode1Iso = aNodeUV1.X();
|
||||
aPntOnNode2Iso = aNodeUV2.X();
|
||||
aPntOnNode3Iso = aCrossU;
|
||||
anIso1 = theSurface->VIso (aNodeUV1.Y());
|
||||
anIso2 = theSurface->VIso (aNodeUV2.Y());
|
||||
anIso3 = theSurface->VIso (aCrossV);
|
||||
}
|
||||
else if (theIsoline.Direction().Y() == 0.0)
|
||||
{
|
||||
aPntOnNode1Iso = aNodeUV1.Y();
|
||||
aPntOnNode2Iso = aNodeUV2.Y();
|
||||
aPntOnNode3Iso = aCrossV;
|
||||
anIso1 = theSurface->UIso (aNodeUV1.X());
|
||||
anIso2 = theSurface->UIso (aNodeUV2.X());
|
||||
anIso3 = theSurface->UIso (aCrossU);
|
||||
}
|
||||
|
||||
GeomAdaptor_Curve aCurveAdaptor1 (anIso1);
|
||||
GeomAdaptor_Curve aCurveAdaptor2 (anIso2);
|
||||
GeomAdaptor_Curve aCurveAdaptor3 (anIso3);
|
||||
Standard_Real aLength1 = GCPnts_AbscissaPoint::Length (aCurveAdaptor1, aPntOnNode1Iso, aPntOnNode3Iso, 1e-2);
|
||||
Standard_Real aLength2 = GCPnts_AbscissaPoint::Length (aCurveAdaptor2, aPntOnNode2Iso, aPntOnNode3Iso, 1e-2);
|
||||
if (Abs (aLength1) < Precision::Confusion() || Abs (aLength2) < Precision::Confusion())
|
||||
{
|
||||
theSegment[aNPoints++] = (aNode2.XYZ() - aNode1.XYZ()) * anAlpha + aNode1.XYZ();
|
||||
continue;
|
||||
}
|
||||
|
||||
aCross = (aNode2.XYZ() - aNode1.XYZ()) * (aLength1 / (aLength1 + aLength2)) + aNode1.XYZ();
|
||||
}
|
||||
|
||||
theSegment[aNPoints++] = aCross;
|
||||
}
|
||||
|
||||
return aNPoints == 2;
|
||||
}
|
150
src/StdPrs/StdPrs_Isolines.hxx
Normal file
150
src/StdPrs/StdPrs_Isolines.hxx
Normal file
@@ -0,0 +1,150 @@
|
||||
// Created on: 2014-10-14
|
||||
// Created by: Anton POLETAEV
|
||||
// Copyright (c) 2013-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _StdPrs_Isolines_H__
|
||||
#define _StdPrs_Isolines_H__
|
||||
|
||||
#include <BRepAdaptor_HSurface.hxx>
|
||||
#include <Geom_Surface.hxx>
|
||||
#include <Prs3d_Drawer.hxx>
|
||||
#include <Prs3d_Presentation.hxx>
|
||||
#include <Prs3d_LineAspect.hxx>
|
||||
#include <Prs3d_Root.hxx>
|
||||
#include <Prs3d_NListOfSequenceOfPnt.hxx>
|
||||
#include <Poly_Triangulation.hxx>
|
||||
#include <StdPrs_ToolTriangulatedShape.hxx>
|
||||
#include <TColStd_Array1OfInteger.hxx>
|
||||
#include <TColgp_Array1OfPnt2d.hxx>
|
||||
#include <TColStd_SequenceOfReal.hxx>
|
||||
|
||||
class Poly_Triangle;
|
||||
class TopoDS_Face;
|
||||
class TopLoc_Location;
|
||||
|
||||
//! Tool for computing isoline representation for a face or surface.
|
||||
//! Depending on a flags set to the given Prs3d_Drawer instance, on-surface (is used
|
||||
//! by default) or on-triangulation isoline builder algorithm will be used.
|
||||
//! If the given shape is not triangulated, on-surface isoline builder will be applied
|
||||
//! regardless of Prs3d_Drawer flags.
|
||||
class StdPrs_Isolines : public Prs3d_Root
|
||||
{
|
||||
public:
|
||||
|
||||
//! Computes isolines presentation for a TopoDS face.
|
||||
//! This method chooses proper version of isoline builder algorithm : on triangulation
|
||||
//! or surface depending on the flag passed from Prs3d_Drawer attributes.
|
||||
//! This method is a default way to display isolines for a given TopoDS face.
|
||||
//! @param thePresentation [in] the presentation.
|
||||
//! @param theFace [in] the face.
|
||||
//! @param theDrawer [in] the display settings.
|
||||
//! @param theDeflection [in] the deflection for isolines-on-surface version.
|
||||
inline static void Add (const Handle(Prs3d_Presentation)& thePresentation,
|
||||
const TopoDS_Face& theFace,
|
||||
const Handle(Prs3d_Drawer)& theDrawer,
|
||||
const Standard_Real theDeflection)
|
||||
{
|
||||
if (theDrawer->IsoOnTriangulation() && StdPrs_ToolTriangulatedShape::IsTriangulated (theFace))
|
||||
{
|
||||
AddOnTriangulation (thePresentation, theFace, theDrawer);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddOnSurface (thePresentation, theFace, theDrawer, theDeflection);
|
||||
}
|
||||
}
|
||||
|
||||
//! Computes isolines on triangulation and adds them to a presentation.
|
||||
//! @param thePresentation [in] the presentation.
|
||||
//! @param theFace [in] the face.
|
||||
//! @param theDrawer [in] the display settings.
|
||||
Standard_EXPORT static void AddOnTriangulation (const Handle(Prs3d_Presentation)& thePresentation,
|
||||
const TopoDS_Face& theFace,
|
||||
const Handle(Prs3d_Drawer)& theDrawer);
|
||||
|
||||
//! Computes isolines on triangulation and adds them to a presentation.
|
||||
//! @param thePresentation [in] the presentation.
|
||||
//! @param theTriangulation [in] the triangulation.
|
||||
//! @param theSurface [in] the definition of triangulated surface. The surface
|
||||
//! adapter is used to precisely evaluate isoline points using surface
|
||||
//! law and fit them on triangulation. If NULL is passed, the method will
|
||||
//! use linear interpolation of triangle node's UV coordinates to evaluate
|
||||
//! isoline points.
|
||||
//! @param theLocation [in] the location transformation defined for triangulation (surface).
|
||||
//! @param theDrawer [in] the display settings.
|
||||
//! @param theUIsoParams [in] the parameters of u isolines to compute.
|
||||
//! @param theVIsoParams [in] the parameters of v isolines to compute.
|
||||
Standard_EXPORT static void AddOnTriangulation (const Handle(Prs3d_Presentation)& thePresentation,
|
||||
const Handle(Poly_Triangulation)& theTriangulation,
|
||||
const Handle(Geom_Surface)& theSurface,
|
||||
const TopLoc_Location& theLocation,
|
||||
const Handle(Prs3d_Drawer)& theDrawer,
|
||||
const TColStd_SequenceOfReal& theUIsoParams,
|
||||
const TColStd_SequenceOfReal& theVIsoParams);
|
||||
|
||||
//! Computes isolines on surface and adds them to presentation.
|
||||
//! @param thePresentation [in] the presentation.
|
||||
//! @param theFace [in] the face.
|
||||
//! @param theDrawer [in] the display settings.
|
||||
//! @param theDeflection [in] the deflection value.
|
||||
Standard_EXPORT static void AddOnSurface (const Handle(Prs3d_Presentation)& thePresentation,
|
||||
const TopoDS_Face& theFace,
|
||||
const Handle(Prs3d_Drawer)& theDrawer,
|
||||
const Standard_Real theDeflection);
|
||||
|
||||
//! Computes isolines on surface and adds them to presentation.
|
||||
//! @param thePresentation [in] the presentation.
|
||||
//! @param theSurface [in] the surface.
|
||||
//! @param theDrawer [in] the display settings.
|
||||
//! @param theDeflection [in] the deflection value.
|
||||
//! @param theUIsoParams [in] the parameters of u isolines to compute.
|
||||
//! @param theVIsoParams [in] the parameters of v isolines to compute.
|
||||
Standard_EXPORT static void AddOnSurface (const Handle(Prs3d_Presentation)& thePresentation,
|
||||
const Handle(BRepAdaptor_HSurface)& theSurface,
|
||||
const Handle(Prs3d_Drawer)& theDrawer,
|
||||
const Standard_Real theDeflection,
|
||||
const TColStd_SequenceOfReal& theUIsoParams,
|
||||
const TColStd_SequenceOfReal& theVIsoParams);
|
||||
|
||||
//! Evalute sequence of parameters for drawing uv isolines for a given face.
|
||||
//! @param theFace [in] the face.
|
||||
//! @param theNbIsoU [in] the number of u isolines.
|
||||
//! @param theNbIsoV [in] the number of v isolines.
|
||||
//! @param theUVLimit [in] the u, v parameter value limit.
|
||||
//! @param theUIsoParams [out] the sequence of u isoline parameters.
|
||||
//! @param theVIsoParams [out] the sequence of v isoline parameters.
|
||||
Standard_EXPORT static void UVIsoParameters (const TopoDS_Face& theFace,
|
||||
const Standard_Integer theNbIsoU,
|
||||
const Standard_Integer theNbIsoV,
|
||||
const Standard_Real theUVLimit,
|
||||
TColStd_SequenceOfReal& theUIsoParams,
|
||||
TColStd_SequenceOfReal& theVIsoParams);
|
||||
|
||||
private:
|
||||
|
||||
//! Find isoline segment on a triangle.
|
||||
//! @param theSurface [in] the surface.
|
||||
//! @param theIsoline [in] the isoline in uv coordinates.
|
||||
//! @param theNodesXYZ [in] the XYZ coordinates of triangle nodes.
|
||||
//! @param theNodesUV [in] the UV coordinates of triangle nodes.
|
||||
//! @param theSegment [out] the XYZ points of crossed triangle's links.
|
||||
//! @return TRUE if the isoline passes through the triangle.
|
||||
Standard_EXPORT static Standard_Boolean findSegmentOnTriangulation (const Handle(Geom_Surface)& theSurface,
|
||||
const gp_Lin2d& theIsoline,
|
||||
const gp_Pnt* theNodesXYZ,
|
||||
const gp_Pnt2d* theNodesUV,
|
||||
gp_Pnt* theSegment);
|
||||
};
|
||||
|
||||
#endif // _StdPrs_Isolines_H__
|
@@ -17,11 +17,10 @@
|
||||
#include <StdPrs_ShadedShape.hxx>
|
||||
|
||||
#include <Bnd_Box.hxx>
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <BRepBndLib.hxx>
|
||||
#include <BRepMesh_DiscretFactory.hxx>
|
||||
#include <BRepMesh_DiscretRoot.hxx>
|
||||
#include <BRepTools.hxx>
|
||||
#include <BRepBndLib.hxx>
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <Graphic3d_ArrayOfSegments.hxx>
|
||||
#include <Graphic3d_ArrayOfTriangles.hxx>
|
||||
#include <Graphic3d_AspectFillArea3d.hxx>
|
||||
@@ -31,7 +30,6 @@
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <NCollection_List.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <Prs3d.hxx>
|
||||
#include <Prs3d_Drawer.hxx>
|
||||
#include <Prs3d_IsoAspect.hxx>
|
||||
#include <Prs3d_LineAspect.hxx>
|
||||
@@ -40,8 +38,7 @@
|
||||
#include <Poly_Connect.hxx>
|
||||
#include <Poly_PolygonOnTriangulation.hxx>
|
||||
#include <Poly_Triangulation.hxx>
|
||||
#include <StdPrs_ToolShadedShape.hxx>
|
||||
#include <StdPrs_WFDeflectionShape.hxx>
|
||||
#include <StdPrs_ToolTriangulatedShape.hxx>
|
||||
#include <StdPrs_WFShape.hxx>
|
||||
#include <TopExp.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
@@ -74,7 +71,7 @@ namespace
|
||||
if (!aShapeIter.More())
|
||||
{
|
||||
// compound contains no shaded elements at all
|
||||
StdPrs_WFDeflectionShape::Add (thePrs, theShape, theDrawer);
|
||||
StdPrs_WFShape::Add (thePrs, theShape, theDrawer);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -103,7 +100,7 @@ namespace
|
||||
}
|
||||
if (hasElement)
|
||||
{
|
||||
StdPrs_WFDeflectionShape::Add (thePrs, aCompoundWF, theDrawer);
|
||||
StdPrs_WFShape::Add (thePrs, aCompoundWF, theDrawer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +133,7 @@ namespace
|
||||
theDrawer->UIsoAspect()->SetNumber (5);
|
||||
theDrawer->VIsoAspect()->SetNumber (5);
|
||||
|
||||
StdPrs_WFDeflectionShape::Add (thePrs, aCompoundWF, theDrawer);
|
||||
StdPrs_WFShape::Add (thePrs, aCompoundWF, theDrawer);
|
||||
|
||||
theDrawer->UIsoAspect()->SetNumber (aPrevUIsoNb);
|
||||
theDrawer->VIsoAspect()->SetNumber (aPrevVIsoNb);
|
||||
@@ -163,7 +160,7 @@ namespace
|
||||
for (; aFaceIt.More(); aFaceIt.Next())
|
||||
{
|
||||
const TopoDS_Face& aFace = TopoDS::Face(aFaceIt.Current());
|
||||
aT = StdPrs_ToolShadedShape::Triangulation (aFace, aLoc);
|
||||
aT = BRep_Tool::Triangulation (aFace, aLoc);
|
||||
if (!aT.IsNull())
|
||||
{
|
||||
aNbTriangles += aT->NbTriangles();
|
||||
@@ -181,7 +178,7 @@ namespace
|
||||
for (aFaceIt.Init (theShape, TopAbs_FACE); aFaceIt.More(); aFaceIt.Next())
|
||||
{
|
||||
const TopoDS_Face& aFace = TopoDS::Face(aFaceIt.Current());
|
||||
aT = StdPrs_ToolShadedShape::Triangulation (aFace, aLoc);
|
||||
aT = BRep_Tool::Triangulation (aFace, aLoc);
|
||||
if (aT.IsNull())
|
||||
{
|
||||
continue;
|
||||
@@ -196,7 +193,7 @@ namespace
|
||||
const TColgp_Array1OfPnt& aNodes = aT->Nodes();
|
||||
const TColgp_Array1OfPnt2d& aUVNodes = aT->UVNodes();
|
||||
TColgp_Array1OfDir aNormals (aNodes.Lower(), aNodes.Upper());
|
||||
StdPrs_ToolShadedShape::Normal (aFace, aPolyConnect, aNormals);
|
||||
StdPrs_ToolTriangulatedShape::Normal (aFace, aPolyConnect, aNormals);
|
||||
|
||||
if (theHasTexels)
|
||||
{
|
||||
@@ -456,7 +453,7 @@ void StdPrs_ShadedShape::ExploreSolids (const TopoDS_Shape& theShape,
|
||||
const TopoDS_Shape& aSubShape = anIter.Value();
|
||||
const Standard_Boolean isClosed = aSubShape.ShapeType() == TopAbs_SHELL &&
|
||||
BRep_Tool::IsClosed (aSubShape) &&
|
||||
StdPrs_ToolShadedShape::IsTriangulated (aSubShape);
|
||||
StdPrs_ToolTriangulatedShape::IsTriangulated (aSubShape);
|
||||
theBuilder.Add (isClosed ? theClosed : theOpened, aSubShape);
|
||||
}
|
||||
return;
|
||||
@@ -497,30 +494,6 @@ void StdPrs_ShadedShape::Add (const Handle(Prs3d_Presentation)& thePrs,
|
||||
Standard_False, aDummy, aDummy, aDummy, theVolume);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Tessellate
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void StdPrs_ShadedShape::Tessellate (const TopoDS_Shape& theShape,
|
||||
const Handle (Prs3d_Drawer)& theDrawer)
|
||||
{
|
||||
// Check if it is possible to avoid unnecessary recomputation of shape triangulation
|
||||
Standard_Real aDeflection = Prs3d::GetDeflection (theShape, theDrawer);
|
||||
if (BRepTools::Triangulation (theShape, aDeflection))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// retrieve meshing tool from Factory
|
||||
Handle(BRepMesh_DiscretRoot) aMeshAlgo = BRepMesh_DiscretFactory::Get().Discret (theShape,
|
||||
aDeflection,
|
||||
theDrawer->HLRAngle());
|
||||
if (!aMeshAlgo.IsNull())
|
||||
{
|
||||
aMeshAlgo->Perform();
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Add
|
||||
// purpose :
|
||||
@@ -546,7 +519,7 @@ void StdPrs_ShadedShape::Add (const Handle (Prs3d_Presentation)& thePrs,
|
||||
if (theDrawer->IsAutoTriangulation())
|
||||
{
|
||||
// Triangulation completeness is important for "open-closed" analysis - perform tessellation beforehand
|
||||
Tessellate (theShape, theDrawer);
|
||||
StdPrs_ToolTriangulatedShape::Tessellate (theShape, theDrawer);
|
||||
}
|
||||
|
||||
// add special wireframe presentation for faces without triangulation
|
||||
|
@@ -52,9 +52,6 @@ public:
|
||||
//! or to perform Autodetection (would split input shape into two groups)
|
||||
Standard_EXPORT static void Add (const Handle(Prs3d_Presentation)& thePresentation, const TopoDS_Shape& theShape, const Handle(Prs3d_Drawer)& theDrawer, const Standard_Boolean theHasTexels, const gp_Pnt2d& theUVOrigin, const gp_Pnt2d& theUVRepeat, const gp_Pnt2d& theUVScale, const StdPrs_Volume theVolume = StdPrs_Volume_Autodetection);
|
||||
|
||||
//! Validates triangulation within the shape and performs tessellation if necessary.
|
||||
Standard_EXPORT static void Tessellate (const TopoDS_Shape& theShape, const Handle(Prs3d_Drawer)& theDrawer);
|
||||
|
||||
//! Searches closed and unclosed subshapes in shape structure and puts them
|
||||
//! into two compounds for separate processing of closed and unclosed sub-shapes
|
||||
Standard_EXPORT static void ExploreSolids (const TopoDS_Shape& theShape, const BRep_Builder& theBuilder, TopoDS_Compound& theClosed, TopoDS_Compound& theOpened, const Standard_Boolean theIgnore1DSubShape);
|
||||
|
@@ -1,50 +0,0 @@
|
||||
// Copyright (c) 2013 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _StdPrs_ToolShadedShape_HeaderFile
|
||||
#define _StdPrs_ToolShadedShape_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Macro.hxx>
|
||||
#include <TColgp_Array1OfDir.hxx>
|
||||
|
||||
class TopoDS_Shape;
|
||||
class Poly_Triangulation;
|
||||
class TopoDS_Face;
|
||||
class TopLoc_Location;
|
||||
class Poly_Connect;
|
||||
|
||||
class StdPrs_ToolShadedShape
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
//! Similar to BRepTools::Triangulation() but without extra checks.
|
||||
//! @return true if all faces within shape are triangulated.
|
||||
Standard_EXPORT static Standard_Boolean IsTriangulated (const TopoDS_Shape& theShape);
|
||||
|
||||
//! Checks back faces visibility for specified shape (to activate back-face culling). <br>
|
||||
//! @return true if shape is closed manifold Solid or compound of such Solids. <br>
|
||||
Standard_EXPORT static Standard_Boolean IsClosed(const TopoDS_Shape& theShape);
|
||||
|
||||
Standard_EXPORT static Handle(Poly_Triangulation) Triangulation(const TopoDS_Face& aFace,
|
||||
TopLoc_Location& loc);
|
||||
|
||||
Standard_EXPORT static void Normal(const TopoDS_Face& aFace,
|
||||
Poly_Connect& PC,
|
||||
TColgp_Array1OfDir& Nor);
|
||||
};
|
||||
|
||||
#endif
|
@@ -14,32 +14,35 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <StdPrs_ToolShadedShape.hxx>
|
||||
#include <StdPrs_ToolTriangulatedShape.hxx>
|
||||
|
||||
#include <BRepMesh_DiscretFactory.hxx>
|
||||
#include <BRepMesh_DiscretRoot.hxx>
|
||||
#include <BRepTools.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <BRepAdaptor_Surface.hxx>
|
||||
#include <GeomAbs_SurfaceType.hxx>
|
||||
#include <GeomLib.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
#include <gp_XYZ.hxx>
|
||||
#include <Poly_Connect.hxx>
|
||||
#include <Poly_Triangulation.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <TColgp_HArray1OfPnt.hxx>
|
||||
#include <Prs3d.hxx>
|
||||
#include <Prs3d_Drawer.hxx>
|
||||
#include <TColgp_Array1OfPnt.hxx>
|
||||
#include <TColgp_Array1OfPnt2d.hxx>
|
||||
#include <TopAbs_Orientation.hxx>
|
||||
#include <TopLoc_Location.hxx>
|
||||
#include <TShort_HArray1OfShortReal.hxx>
|
||||
#include <TShort_Array1OfShortReal.hxx>
|
||||
#include <TColgp_Array1OfDir.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Face.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : isTriangulated
|
||||
//function : IsTriangulated
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean StdPrs_ToolShadedShape::IsTriangulated (const TopoDS_Shape& theShape)
|
||||
Standard_Boolean StdPrs_ToolTriangulatedShape::IsTriangulated (const TopoDS_Shape& theShape)
|
||||
{
|
||||
TopLoc_Location aLocDummy;
|
||||
for (TopExp_Explorer aFaceIter (theShape, TopAbs_FACE); aFaceIter.More(); aFaceIter.Next())
|
||||
@@ -58,7 +61,7 @@ Standard_Boolean StdPrs_ToolShadedShape::IsTriangulated (const TopoDS_Shape& the
|
||||
//function : IsClosed
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean StdPrs_ToolShadedShape::IsClosed (const TopoDS_Shape& theShape)
|
||||
Standard_Boolean StdPrs_ToolTriangulatedShape::IsClosed (const TopoDS_Shape& theShape)
|
||||
{
|
||||
if (theShape.IsNull())
|
||||
{
|
||||
@@ -127,23 +130,13 @@ Standard_Boolean StdPrs_ToolShadedShape::IsClosed (const TopoDS_Shape& theShape)
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Triangulation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(Poly_Triangulation) StdPrs_ToolShadedShape::Triangulation (const TopoDS_Face& theFace,
|
||||
TopLoc_Location& theLoc)
|
||||
{
|
||||
return BRep_Tool::Triangulation (theFace, theLoc);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Normal
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void StdPrs_ToolShadedShape::Normal (const TopoDS_Face& theFace,
|
||||
Poly_Connect& thePolyConnect,
|
||||
TColgp_Array1OfDir& theNormals)
|
||||
void StdPrs_ToolTriangulatedShape::Normal (const TopoDS_Face& theFace,
|
||||
Poly_Connect& thePolyConnect,
|
||||
TColgp_Array1OfDir& theNormals)
|
||||
{
|
||||
const Handle(Poly_Triangulation)& aPolyTri = thePolyConnect.Triangulation();
|
||||
const TColgp_Array1OfPnt& aNodes = aPolyTri->Nodes();
|
||||
@@ -220,3 +213,42 @@ void StdPrs_ToolShadedShape::Normal (const TopoDS_Face& theFace,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsTessellated
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean StdPrs_ToolTriangulatedShape::IsTessellated (const TopoDS_Shape& theShape,
|
||||
const Handle(Prs3d_Drawer)& theDrawer)
|
||||
{
|
||||
return BRepTools::Triangulation (theShape, Prs3d::GetDeflection (theShape, theDrawer));
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Tessellate
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean StdPrs_ToolTriangulatedShape::Tessellate (const TopoDS_Shape& theShape,
|
||||
const Handle(Prs3d_Drawer)& theDrawer)
|
||||
{
|
||||
Standard_Boolean wasRecomputed = Standard_False;
|
||||
// Check if it is possible to avoid unnecessary recomputation of shape triangulation
|
||||
if (IsTessellated (theShape, theDrawer))
|
||||
{
|
||||
return wasRecomputed;
|
||||
}
|
||||
|
||||
Standard_Real aDeflection = Prs3d::GetDeflection (theShape, theDrawer);
|
||||
|
||||
// retrieve meshing tool from Factory
|
||||
Handle(BRepMesh_DiscretRoot) aMeshAlgo = BRepMesh_DiscretFactory::Get().Discret (theShape,
|
||||
aDeflection,
|
||||
theDrawer->HLRAngle());
|
||||
if (!aMeshAlgo.IsNull())
|
||||
{
|
||||
aMeshAlgo->Perform();
|
||||
wasRecomputed = Standard_True;
|
||||
}
|
||||
|
||||
return wasRecomputed;
|
||||
}
|
64
src/StdPrs/StdPrs_ToolTriangulatedShape.hxx
Normal file
64
src/StdPrs/StdPrs_ToolTriangulatedShape.hxx
Normal file
@@ -0,0 +1,64 @@
|
||||
// Copyright (c) 2013 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _StdPrs_ToolTriangulatedShape_HeaderFile
|
||||
#define _StdPrs_ToolTriangulatedShape_HeaderFile
|
||||
|
||||
#include <Poly_Triangulation.hxx>
|
||||
#include <Prs3d_Drawer.hxx>
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_Macro.hxx>
|
||||
#include <TColgp_Array1OfDir.hxx>
|
||||
|
||||
class TopoDS_Face;
|
||||
class TopLoc_Location;
|
||||
class TopoDS_Shape;
|
||||
class Prs3d_Drawer;
|
||||
class Poly_Triangulation;
|
||||
class Poly_Connect;
|
||||
|
||||
class StdPrs_ToolTriangulatedShape
|
||||
{
|
||||
public:
|
||||
|
||||
//! Similar to BRepTools::Triangulation() but without extra checks.
|
||||
//! @return true if all faces within shape are triangulated.
|
||||
Standard_EXPORT static Standard_Boolean IsTriangulated (const TopoDS_Shape& theShape);
|
||||
|
||||
//! Checks back faces visibility for specified shape (to activate back-face culling). <br>
|
||||
//! @return true if shape is closed manifold Solid or compound of such Solids. <br>
|
||||
Standard_EXPORT static Standard_Boolean IsClosed (const TopoDS_Shape& theShape);
|
||||
|
||||
//! Evaluate normals for a triangle of a face.
|
||||
//! @param theFace [in] the face.
|
||||
//! @param thePolyConnect [in] the definition of a face triangulation.
|
||||
//! @param theNormal [out] the array of normals for each triangle.
|
||||
Standard_EXPORT static void Normal (const TopoDS_Face& theFace,
|
||||
Poly_Connect& thePolyConnect,
|
||||
TColgp_Array1OfDir& theNormals);
|
||||
|
||||
//! Checks whether the shape is properly triangulated for a given display settings.
|
||||
//! @param theShape [in] the shape.
|
||||
//! @param theDrawer [in] the display settings.
|
||||
Standard_EXPORT static Standard_Boolean IsTessellated (const TopoDS_Shape& theShape,
|
||||
const Handle(Prs3d_Drawer)& theDrawer);
|
||||
|
||||
//! Validates triangulation within the shape and performs tessellation if necessary.
|
||||
//! @param theShape [in] the shape.
|
||||
//! @param theDrawer [in] the display settings.
|
||||
//! @return true if tesselation was recomputed and false otherwise.
|
||||
Standard_EXPORT static Standard_Boolean Tessellate (const TopoDS_Shape& theShape,
|
||||
const Handle(Prs3d_Drawer)& theDrawer);
|
||||
};
|
||||
|
||||
#endif
|
@@ -89,7 +89,7 @@ static void FindLimits(const Adaptor3d_Curve& aCurve,
|
||||
aCurve.D0(Last,P2);
|
||||
} while (P1.Distance(P2) < aLimit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -632,46 +632,3 @@ Standard_Boolean StdPrs_WFDeflectionRestrictedFace::MatchVIso
|
||||
aDrawer->UIsoAspect()->Number(),
|
||||
aDrawer->VIsoAspect()->Number());
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
static const Standard_Integer THE_INDICES[][3] =
|
||||
{ { 0, 0, 0 }, { 1, 0, 0 }, { 1, 0, 1 }, { 0, 0, 1 },
|
||||
{ 0, 1, 1 }, { 1, 1, 1 }, { 1, 1, 0 }, { 0, 1, 0 },
|
||||
{ 0, 0, 0 }, { 0, 0, 1 }, { 1, 0, 1 }, { 1, 1, 1 },
|
||||
{ 0, 1, 1 }, { 0, 1, 0 }, { 1, 1, 0 }, { 1, 0, 0 } };
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AddBox
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void StdPrs_WFDeflectionRestrictedFace::AddBox (const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Bnd_Box& theBndBox,
|
||||
const Handle(Prs3d_Drawer)& theDrawer)
|
||||
{
|
||||
if (theBndBox.IsVoid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Standard_Real X[2], Y[2], Z[2];
|
||||
theBndBox.Get (X[0], Y[0], Z[0], X[1], Y[1], Z[1]);
|
||||
|
||||
Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (thePrs);
|
||||
Quantity_Color aColor;
|
||||
Aspect_TypeOfLine aDummyLineType;
|
||||
Standard_Real aWidth = 1.0;
|
||||
theDrawer->LineAspect()->Aspect()->Values (aColor, aDummyLineType, aWidth);
|
||||
|
||||
aGroup->SetGroupPrimitivesAspect (new Graphic3d_AspectLine3d (aColor, Aspect_TOL_DOTDASH, aWidth));
|
||||
|
||||
Handle(Graphic3d_ArrayOfPolylines) aPolyline = new Graphic3d_ArrayOfPolylines(16);
|
||||
for(Standard_Integer aVertIter = 0; aVertIter < 16; ++aVertIter)
|
||||
{
|
||||
aPolyline->AddVertex (X[THE_INDICES[aVertIter][0]],
|
||||
Y[THE_INDICES[aVertIter][1]],
|
||||
Z[THE_INDICES[aVertIter][2]]);
|
||||
}
|
||||
aGroup->AddPrimitiveArray (aPolyline);
|
||||
}
|
||||
|
@@ -112,9 +112,6 @@ public:
|
||||
//! visualization approach is activated (it is activated by default).
|
||||
Standard_EXPORT static void Add (const Handle(Prs3d_Presentation)& aPresentation, const Handle(BRepAdaptor_HSurface)& aFace, const Standard_Boolean DrawUIso, const Standard_Boolean DrawVIso, const Quantity_Length Deflection, const Standard_Integer NBUiso, const Standard_Integer NBViso, const Handle(Prs3d_Drawer)& aDrawer, Prs3d_NListOfSequenceOfPnt& Curves);
|
||||
|
||||
//! Adds box as polyline to the presentation object
|
||||
Standard_EXPORT static void AddBox (const Handle(Prs3d_Presentation)& thePrs, const Bnd_Box& theBndBox, const Handle(Prs3d_Drawer)& theDrawer);
|
||||
|
||||
Standard_EXPORT static Standard_Boolean Match (const Quantity_Length X, const Quantity_Length Y, const Quantity_Length Z, const Quantity_Length aDistance, const Handle(BRepAdaptor_HSurface)& aFace, const Handle(Prs3d_Drawer)& aDrawer);
|
||||
|
||||
Standard_EXPORT static Standard_Boolean MatchUIso (const Quantity_Length X, const Quantity_Length Y, const Quantity_Length Z, const Quantity_Length aDistance, const Handle(BRepAdaptor_HSurface)& aFace, const Handle(Prs3d_Drawer)& aDrawer);
|
||||
|
@@ -1,130 +0,0 @@
|
||||
// Copyright (c) 2013-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _StdPrs_WFDeflectionShape_H__
|
||||
#define _StdPrs_WFDeflectionShape_H__
|
||||
|
||||
#include <Prs3d_Presentation.hxx>
|
||||
#include <Prs3d_WFShape.hxx>
|
||||
#include <Prs3d_Drawer.hxx>
|
||||
#include <Prs3d_Root.hxx>
|
||||
#include <StdPrs_WFDeflectionRestrictedFace.hxx>
|
||||
#include <StdPrs_DeflectionCurve.hxx>
|
||||
#include <StdPrs_Vertex.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TopTools_HSequenceOfShape.hxx>
|
||||
|
||||
// Computes the wireframe presentation of surfaces
|
||||
// by displaying planar sections.
|
||||
|
||||
class StdPrs_WFDeflectionShape : public Prs3d_Root
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//! Add shape to presentation
|
||||
static inline void Add (const Handle (Prs3d_Presentation)& thePrs,
|
||||
const TopoDS_Shape& theShape,
|
||||
const Handle (Prs3d_Drawer)& theDrawer)
|
||||
{
|
||||
Face aFaceAlgo;
|
||||
Curve aCurveAlgo;
|
||||
Prs3d_WFShape anAlgo (aFaceAlgo, aCurveAlgo);
|
||||
anAlgo.Add (thePrs, theShape, theDrawer);
|
||||
}
|
||||
|
||||
static inline Handle(TopTools_HSequenceOfShape) PickCurve
|
||||
(const Quantity_Length theX,
|
||||
const Quantity_Length theY,
|
||||
const Quantity_Length theZ,
|
||||
const Quantity_Length theDistance,
|
||||
const TopoDS_Shape& theShape,
|
||||
const Handle (Prs3d_Drawer)& theDrawer)
|
||||
{
|
||||
Face aFaceAlgo;
|
||||
Curve aCurveAlgo;
|
||||
Prs3d_WFShape anAlgo (aFaceAlgo, aCurveAlgo);
|
||||
return anAlgo.PickCurve (theX, theY, theZ, theDistance, theShape, theDrawer);
|
||||
}
|
||||
|
||||
static inline Handle(TopTools_HSequenceOfShape) PickPatch
|
||||
(const Quantity_Length theX,
|
||||
const Quantity_Length theY,
|
||||
const Quantity_Length theZ,
|
||||
const Quantity_Length theDistance,
|
||||
const TopoDS_Shape& theShape,
|
||||
const Handle(Prs3d_Drawer)& theDrawer)
|
||||
{
|
||||
Face aFaceAlgo;
|
||||
Curve aCurveAlgo;
|
||||
Prs3d_WFShape anAlgo (aFaceAlgo, aCurveAlgo);
|
||||
return anAlgo.PickPatch (theX, theY, theZ, theDistance, theShape, theDrawer);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
class Face : public Prs3d_WFShape::Face
|
||||
{
|
||||
public:
|
||||
virtual void Add (const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Handle(BRepAdaptor_HSurface)& theFace,
|
||||
const Standard_Boolean theToDrawUIso,
|
||||
const Standard_Boolean theToDrawVIso,
|
||||
const Quantity_Length theDeflection,
|
||||
const Standard_Integer theNBUiso,
|
||||
const Standard_Integer theNBViso,
|
||||
const Handle(Prs3d_Drawer)& theDrawer,
|
||||
Prs3d_NListOfSequenceOfPnt& theCurves) const
|
||||
{
|
||||
StdPrs_WFDeflectionRestrictedFace::Add (thePrs, theFace, theToDrawUIso, theToDrawVIso, theDeflection,
|
||||
theNBUiso, theNBViso, theDrawer, theCurves);
|
||||
}
|
||||
|
||||
virtual Standard_Boolean Match (const Quantity_Length theX,
|
||||
const Quantity_Length theY,
|
||||
const Quantity_Length theZ,
|
||||
const Quantity_Length theDistance,
|
||||
const Handle(BRepAdaptor_HSurface)& theFace,
|
||||
const Handle(Prs3d_Drawer)& theDrawer) const
|
||||
{
|
||||
return StdPrs_WFDeflectionRestrictedFace::Match (theX, theY, theZ, theDistance, theFace, theDrawer);
|
||||
}
|
||||
};
|
||||
|
||||
class Curve : public Prs3d_WFShape::Curve
|
||||
{
|
||||
public:
|
||||
virtual void Add (const Handle(Prs3d_Presentation)& thePrs,
|
||||
Adaptor3d_Curve& theCurve,
|
||||
const Quantity_Length theDeflection,
|
||||
const Handle(Prs3d_Drawer)& theDrawer,
|
||||
TColgp_SequenceOfPnt& thePoints,
|
||||
const Standard_Boolean theToDrawCurve) const
|
||||
{
|
||||
StdPrs_DeflectionCurve::Add (thePrs, theCurve, theDeflection, theDrawer, thePoints, theToDrawCurve);
|
||||
}
|
||||
|
||||
virtual Standard_Boolean Match (const Quantity_Length theX,
|
||||
const Quantity_Length theY,
|
||||
const Quantity_Length theZ,
|
||||
const Quantity_Length theDistance,
|
||||
const Adaptor3d_Curve& theCurve,
|
||||
const Handle(Prs3d_Drawer)& theDrawer) const
|
||||
{
|
||||
return StdPrs_DeflectionCurve::Match (theX, theY, theZ, theDistance, theCurve, theDrawer);
|
||||
}
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif // _StdPrs_WFDeflectionShape_H__
|
@@ -39,7 +39,6 @@ void StdPrs_WFRestrictedFace::Add
|
||||
const Handle(BRepAdaptor_HSurface)& theFace,
|
||||
const Standard_Boolean theDrawUIso,
|
||||
const Standard_Boolean theDrawVIso,
|
||||
const Quantity_Length theDeflection,
|
||||
const Standard_Integer theNbUIso,
|
||||
const Standard_Integer theNBVIso,
|
||||
const Handle(Prs3d_Drawer)& theDrawer,
|
||||
@@ -180,26 +179,32 @@ void StdPrs_WFRestrictedFace::Add
|
||||
Handle(TColgp_HSequenceOfPnt) aPoints = new TColgp_HSequenceOfPnt;
|
||||
if (!aGeomBSurface.IsNull())
|
||||
{
|
||||
if (anIsoBuild.IsXLine(anI))
|
||||
aBCurve = aGeomBSurface->UIso(anIsoCoord);
|
||||
else
|
||||
aBCurve = aGeomBSurface->VIso(anIsoCoord);
|
||||
if (anIsoBuild.IsXLine (anI))
|
||||
{
|
||||
aBCurve = aGeomBSurface->UIso (anIsoCoord);
|
||||
}
|
||||
else
|
||||
{
|
||||
aBCurve = aGeomBSurface->VIso (anIsoCoord);
|
||||
}
|
||||
|
||||
//Note that the isos are the part of the shape, it will be displayed after a computation the whole shape
|
||||
//NbPoints = 30 - default parameter for computation of such curves
|
||||
StdPrs_Curve::Add (thePresentation, GeomAdaptor_Curve(aBCurve), b1, b2, theDeflection,
|
||||
aPoints->ChangeSequence(), 30, Standard_False);
|
||||
theCurves.Append(aPoints);
|
||||
StdPrs_Curve::Add (thePresentation, GeomAdaptor_Curve (aBCurve), b1, b2, aPoints->ChangeSequence(), 30, Standard_False);
|
||||
theCurves.Append (aPoints);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (anIsoBuild.IsXLine(anI))
|
||||
anIsoCurve.Load(GeomAbs_IsoU,anIsoCoord,b1,b2);
|
||||
if (anIsoBuild.IsXLine (anI))
|
||||
{
|
||||
anIsoCurve.Load (GeomAbs_IsoU, anIsoCoord, b1, b2);
|
||||
}
|
||||
else
|
||||
anIsoCurve.Load(GeomAbs_IsoV,anIsoCoord,b1,b2);
|
||||
StdPrs_Curve::Add (thePresentation, anIsoCurve, theDeflection, theDrawer,
|
||||
aPoints->ChangeSequence(), Standard_False);
|
||||
theCurves.Append(aPoints);
|
||||
{
|
||||
anIsoCurve.Load(GeomAbs_IsoV, anIsoCoord, b1, b2);
|
||||
}
|
||||
StdPrs_Curve::Add (thePresentation, anIsoCurve, theDrawer, aPoints->ChangeSequence(), Standard_False);
|
||||
theCurves.Append (aPoints);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -392,7 +397,6 @@ void StdPrs_WFRestrictedFace::Add
|
||||
theFace,
|
||||
Standard_True,
|
||||
Standard_True,
|
||||
theDrawer->MaximalChordialDeviation(),
|
||||
theDrawer->UIsoAspect()->Number(),
|
||||
theDrawer->VIsoAspect()->Number(),
|
||||
theDrawer,
|
||||
@@ -415,7 +419,6 @@ void StdPrs_WFRestrictedFace::AddUIso
|
||||
theFace,
|
||||
Standard_True,
|
||||
Standard_False,
|
||||
theDrawer->MaximalChordialDeviation(),
|
||||
theDrawer->UIsoAspect()->Number(),
|
||||
theDrawer->VIsoAspect()->Number(),
|
||||
theDrawer,
|
||||
@@ -438,7 +441,6 @@ void StdPrs_WFRestrictedFace::AddVIso
|
||||
theFace,
|
||||
Standard_False,
|
||||
Standard_True,
|
||||
theDrawer->MaximalChordialDeviation(),
|
||||
theDrawer->UIsoAspect()->Number(),
|
||||
theDrawer->VIsoAspect()->Number(),
|
||||
theDrawer,
|
||||
|
@@ -36,7 +36,6 @@ public:
|
||||
const Handle(BRepAdaptor_HSurface)& theFace,
|
||||
const Standard_Boolean theDrawUIso,
|
||||
const Standard_Boolean theDrawVIso,
|
||||
const Quantity_Length theDeflection,
|
||||
const Standard_Integer theNbUIso,
|
||||
const Standard_Integer theNbVIso,
|
||||
const Handle(Prs3d_Drawer)& theDrawer,
|
||||
|
381
src/StdPrs/StdPrs_WFShape.cxx
Normal file
381
src/StdPrs/StdPrs_WFShape.cxx
Normal file
@@ -0,0 +1,381 @@
|
||||
// Created on: 2014-10-14
|
||||
// Created by: Anton POLETAEV
|
||||
// Copyright (c) 2013-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <StdPrs_WFShape.hxx>
|
||||
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <BRepAdaptor_Curve.hxx>
|
||||
#include <BRepAdaptor_Surface.hxx>
|
||||
#include <BRepAdaptor_HSurface.hxx>
|
||||
#include <StdPrs_DeflectionCurve.hxx>
|
||||
#include <StdPrs_ToolTriangulatedShape.hxx>
|
||||
#include <StdPrs_Isolines.hxx>
|
||||
#include <Standard_ErrorHandler.hxx>
|
||||
#include <Prs3d_ShapeTool.hxx>
|
||||
#include <Prs3d_IsoAspect.hxx>
|
||||
#include <Prs3d_NListOfSequenceOfPnt.hxx>
|
||||
#include <Prs3d_NListIteratorOfListOfSequenceOfPnt.hxx>
|
||||
#include <Prs3d.hxx>
|
||||
#include <Poly_Connect.hxx>
|
||||
#include <Poly_PolygonOnTriangulation.hxx>
|
||||
#include <Poly_Polygon3D.hxx>
|
||||
#include <Poly_Triangulation.hxx>
|
||||
#include <Graphic3d_AspectLine3d.hxx>
|
||||
#include <Graphic3d_ArrayOfPolylines.hxx>
|
||||
#include <Graphic3d_ArrayOfSegments.hxx>
|
||||
#include <Graphic3d_ArrayOfPoints.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <TColgp_HSequenceOfPnt.hxx>
|
||||
#include <TColStd_Array1OfInteger.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Face.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
||||
#include <NCollection_List.hxx>
|
||||
|
||||
namespace
|
||||
{
|
||||
typedef NCollection_List<Handle(TColgp_HSequenceOfPnt)> ListOfSequenceOfPnt;
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// function : Add
|
||||
// purpose :
|
||||
// =========================================================================
|
||||
void StdPrs_WFShape::Add (const Handle (Prs3d_Presentation)& thePresentation,
|
||||
const TopoDS_Shape& theShape,
|
||||
const Handle (Prs3d_Drawer)& theDrawer)
|
||||
{
|
||||
if (theShape.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Prs3d_ShapeTool aTool (theShape, theDrawer->VertexDrawMode() == Prs3d_VDM_All);
|
||||
|
||||
// Explore shape elements.
|
||||
TopTools_ListOfShape aLFree, aLUnFree, aLWire;
|
||||
for (aTool.InitCurve(); aTool.MoreCurve(); aTool.NextCurve())
|
||||
{
|
||||
const TopoDS_Edge& anEdge = aTool.GetCurve();
|
||||
switch (aTool.Neighbours())
|
||||
{
|
||||
case 0: aLWire.Append (anEdge); break;
|
||||
case 1: aLFree.Append (anEdge); break;
|
||||
default: aLUnFree.Append (anEdge); break;
|
||||
}
|
||||
}
|
||||
|
||||
TColgp_SequenceOfPnt aShapeVertices;
|
||||
for (aTool.InitVertex(); aTool.MoreVertex(); aTool.NextVertex())
|
||||
{
|
||||
aShapeVertices.Append (BRep_Tool::Pnt (aTool.GetVertex()));
|
||||
}
|
||||
|
||||
Standard_Real aShapeDeflection = Prs3d::GetDeflection (theShape, theDrawer);
|
||||
|
||||
// Draw shape elements.
|
||||
TopTools_ListOfShape aDiscreteFaces;
|
||||
for (aTool.InitFace(); aTool.MoreFace(); aTool.NextFace())
|
||||
{
|
||||
if (!aTool.HasSurface())
|
||||
{
|
||||
aDiscreteFaces.Append (aTool.GetFace());
|
||||
}
|
||||
}
|
||||
addEdgesOnTriangulation (thePresentation, aDiscreteFaces, theDrawer->FreeBoundaryAspect());
|
||||
|
||||
if (!aLWire.IsEmpty() && theDrawer->WireDraw())
|
||||
{
|
||||
addEdges (thePresentation, aLWire, theDrawer->WireAspect(), theDrawer, aShapeDeflection);
|
||||
}
|
||||
|
||||
if (!aLFree.IsEmpty() && theDrawer->FreeBoundaryDraw())
|
||||
{
|
||||
addEdges (thePresentation, aLFree, theDrawer->FreeBoundaryAspect(), theDrawer, aShapeDeflection);
|
||||
}
|
||||
|
||||
if (!aLUnFree.IsEmpty() && theDrawer->UnFreeBoundaryDraw())
|
||||
{
|
||||
addEdges (thePresentation, aLUnFree, theDrawer->UnFreeBoundaryAspect(), theDrawer, aShapeDeflection);
|
||||
}
|
||||
|
||||
if (!aShapeVertices.IsEmpty())
|
||||
{
|
||||
addVertices (thePresentation, aShapeVertices, theDrawer->PointAspect());
|
||||
}
|
||||
|
||||
// Draw isolines.
|
||||
for (aTool.InitFace(); aTool.MoreFace(); aTool.NextFace())
|
||||
{
|
||||
if (aTool.IsPlanarFace() && !theDrawer->IsoOnPlane())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
StdPrs_Isolines::Add (thePresentation, aTool.GetFace(), theDrawer, aShapeDeflection);
|
||||
}
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// function : AddEdges
|
||||
// purpose :
|
||||
// =========================================================================
|
||||
void StdPrs_WFShape::addEdges (const Handle (Prs3d_Presentation)& thePresentation,
|
||||
const TopTools_ListOfShape& theEdges,
|
||||
const Handle (Prs3d_LineAspect)& theAspect,
|
||||
const Handle (Prs3d_Drawer)& theDrawer,
|
||||
const Standard_Real theShapeDeflection)
|
||||
{
|
||||
ListOfSequenceOfPnt aPointsOfEdges;
|
||||
|
||||
TopTools_ListIteratorOfListOfShape anEdgesIter;
|
||||
for (anEdgesIter.Initialize (theEdges); anEdgesIter.More(); anEdgesIter.Next())
|
||||
{
|
||||
const TopoDS_Edge& anEdge = TopoDS::Edge (anEdgesIter.Value());
|
||||
if (BRep_Tool::Degenerated (anEdge))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Handle(TColgp_HSequenceOfPnt) aPoints = new TColgp_HSequenceOfPnt;
|
||||
|
||||
TopLoc_Location aLocation;
|
||||
Handle(Poly_Triangulation) aTriangulation;
|
||||
Handle(Poly_PolygonOnTriangulation) anEdgeIndicies;
|
||||
BRep_Tool::PolygonOnTriangulation (anEdge, anEdgeIndicies, aTriangulation, aLocation);
|
||||
Handle(Poly_Polygon3D) aPolygon;
|
||||
|
||||
if (!anEdgeIndicies.IsNull())
|
||||
{
|
||||
// Presentation based on triangulation of a face.
|
||||
const TColStd_Array1OfInteger& anIndices = anEdgeIndicies->Nodes();
|
||||
const TColgp_Array1OfPnt& aNodes = aTriangulation->Nodes();
|
||||
|
||||
Standard_Integer anIndex = anIndices.Lower();
|
||||
if (aLocation.IsIdentity())
|
||||
{
|
||||
for (; anIndex <= anIndices.Upper(); ++anIndex)
|
||||
{
|
||||
aPoints->Append (aNodes (anIndices (anIndex)));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (; anIndex <= anIndices.Upper(); ++anIndex)
|
||||
{
|
||||
aPoints->Append (aNodes (anIndices (anIndex)).Transformed (aLocation));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!(aPolygon = BRep_Tool::Polygon3D (anEdge, aLocation)).IsNull())
|
||||
{
|
||||
// Presentation based on triangulation of the free edge on a surface.
|
||||
const TColgp_Array1OfPnt& aNodes = aPolygon->Nodes();
|
||||
Standard_Integer anIndex = aNodes.Lower();
|
||||
if (aLocation.IsIdentity())
|
||||
{
|
||||
for (; anIndex <= aNodes.Upper(); ++anIndex)
|
||||
{
|
||||
aPoints->Append (aNodes.Value (anIndex));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (; anIndex <= aNodes.Upper(); ++anIndex)
|
||||
{
|
||||
aPoints->Append (aNodes.Value (anIndex).Transformed (aLocation));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (BRep_Tool::IsGeometric (anEdge))
|
||||
{
|
||||
// Default presentation for edges without triangulation.
|
||||
BRepAdaptor_Curve aCurve (anEdge);
|
||||
StdPrs_DeflectionCurve::Add (thePresentation,
|
||||
aCurve,
|
||||
theShapeDeflection,
|
||||
theDrawer,
|
||||
aPoints->ChangeSequence(),
|
||||
Standard_False);
|
||||
}
|
||||
|
||||
if (!aPoints->IsEmpty())
|
||||
{
|
||||
aPointsOfEdges.Append (aPoints);
|
||||
}
|
||||
}
|
||||
|
||||
Standard_Integer aNbBounds = aPointsOfEdges.Size();
|
||||
Standard_Integer aNbVertices = 0;
|
||||
|
||||
ListOfSequenceOfPnt::Iterator aPolylineIter;
|
||||
for (aPolylineIter.Initialize (aPointsOfEdges); aPolylineIter.More(); aPolylineIter.Next())
|
||||
{
|
||||
aNbVertices += aPolylineIter.Value()->Length();
|
||||
}
|
||||
|
||||
if (aNbBounds < 1 || aNbVertices < 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Construct array of primitives.
|
||||
Handle(Graphic3d_ArrayOfPolylines) aPrimitiveArray = new Graphic3d_ArrayOfPolylines (aNbVertices, aNbBounds);
|
||||
for (aPolylineIter.Initialize (aPointsOfEdges); aPolylineIter.More(); aPolylineIter.Next())
|
||||
{
|
||||
const Handle(TColgp_HSequenceOfPnt)& aPoints = aPolylineIter.Value();
|
||||
aPrimitiveArray->AddBound (aPoints->Length());
|
||||
for (Standard_Integer anI = 1; anI <= aPoints->Length(); ++anI)
|
||||
{
|
||||
aPrimitiveArray->AddVertex (aPoints->Value (anI));
|
||||
}
|
||||
}
|
||||
|
||||
// Add array of primitives to presentation.
|
||||
Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup (thePresentation);
|
||||
aGroup->SetPrimitivesAspect (theAspect->Aspect());
|
||||
aGroup->AddPrimitiveArray (aPrimitiveArray);
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// function : AddEdgesOnTriangulation
|
||||
// purpose :
|
||||
// =========================================================================
|
||||
void StdPrs_WFShape::addEdgesOnTriangulation (const Handle(Prs3d_Presentation)& thePresentation,
|
||||
const TopTools_ListOfShape& theFaces,
|
||||
const Handle (Prs3d_LineAspect)& theAspect)
|
||||
{
|
||||
TColgp_SequenceOfPnt aSurfPoints;
|
||||
|
||||
TopLoc_Location aLocation;
|
||||
TopTools_ListIteratorOfListOfShape aFaceIter;
|
||||
for (aFaceIter.Initialize (theFaces); aFaceIter.More(); aFaceIter.Next())
|
||||
{
|
||||
const TopoDS_Face& aFace = TopoDS::Face (aFaceIter.Value());
|
||||
|
||||
Handle(Poly_Triangulation) T = BRep_Tool::Triangulation (aFace, aLocation);
|
||||
if (T.IsNull())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const TColgp_Array1OfPnt& aNodes = T->Nodes();
|
||||
|
||||
// Build the connect tool.
|
||||
Poly_Connect aPolyConnect (T);
|
||||
|
||||
Standard_Integer aNbTriangles = T->NbTriangles();
|
||||
Standard_Integer aT[3];
|
||||
Standard_Integer aN[3];
|
||||
|
||||
// Count the free edges.
|
||||
Standard_Integer aNbFree = 0;
|
||||
for (Standard_Integer anI = 1; anI <= aNbTriangles; ++anI)
|
||||
{
|
||||
aPolyConnect.Triangles (anI, aT[0], aT[1], aT[2]);
|
||||
for (Standard_Integer aJ = 0; aJ < 3; ++aJ)
|
||||
{
|
||||
if (aT[aJ] == 0)
|
||||
{
|
||||
++aNbFree;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Allocate the arrays.
|
||||
TColStd_Array1OfInteger aFree (1, 2 * aNbFree);
|
||||
Standard_Integer aNbInternal = (3 * aNbTriangles - aNbFree) / 2;
|
||||
TColStd_Array1OfInteger anInternal (0, 2 * aNbInternal);
|
||||
|
||||
Standard_Integer aFreeIndex = 1, anIntIndex = 1;
|
||||
const Poly_Array1OfTriangle& aTriangles = T->Triangles();
|
||||
for (Standard_Integer anI = 1; anI <= aNbTriangles; ++anI)
|
||||
{
|
||||
aPolyConnect.Triangles (anI, aT[0], aT[1], aT[2]);
|
||||
aTriangles (anI).Get (aN[0], aN[1], aN[2]);
|
||||
for (Standard_Integer aJ = 0; aJ < 3; aJ++)
|
||||
{
|
||||
Standard_Integer k = (aJ + 1) % 3;
|
||||
if (aT[aJ] == 0)
|
||||
{
|
||||
aFree (aFreeIndex) = aN[aJ];
|
||||
aFree (aFreeIndex + 1) = aN[k];
|
||||
aFreeIndex += 2;
|
||||
}
|
||||
// internal edge if this triangle has a lower index than the adjacent.
|
||||
else if (anI < aT[aJ])
|
||||
{
|
||||
anInternal (anIntIndex) = aN[aJ];
|
||||
anInternal (anIntIndex + 1) = aN[k];
|
||||
anIntIndex += 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// free edges
|
||||
Standard_Integer aFreeHalfNb = aFree.Length() / 2;
|
||||
for (Standard_Integer anI = 1; anI <= aFreeHalfNb; ++anI)
|
||||
{
|
||||
gp_Pnt aPoint1 = aNodes (aFree (2 * anI - 1)).Transformed (aLocation);
|
||||
gp_Pnt aPoint2 = aNodes (aFree (2 * anI )).Transformed (aLocation);
|
||||
aSurfPoints.Append (aPoint1);
|
||||
aSurfPoints.Append (aPoint2);
|
||||
}
|
||||
}
|
||||
|
||||
if (aSurfPoints.Length() < 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Standard_Integer aNbVertices = aSurfPoints.Length();
|
||||
Standard_Integer aNbBounds = aNbVertices / 2;
|
||||
Handle(Graphic3d_ArrayOfSegments) aSurfArray = new Graphic3d_ArrayOfSegments (aNbVertices, aNbBounds);
|
||||
for (Standard_Integer anI = 1; anI <= aNbVertices; anI += 2)
|
||||
{
|
||||
aSurfArray->AddBound (2);
|
||||
aSurfArray->AddVertex (aSurfPoints.Value (anI));
|
||||
aSurfArray->AddVertex (aSurfPoints.Value (anI + 1));
|
||||
}
|
||||
Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup (thePresentation);
|
||||
aGroup->SetPrimitivesAspect (theAspect->Aspect());
|
||||
aGroup->AddPrimitiveArray (aSurfArray);
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// function : AddPoints
|
||||
// purpose :
|
||||
// =========================================================================
|
||||
void StdPrs_WFShape::addVertices (const Handle (Prs3d_Presentation)& thePresentation,
|
||||
const TColgp_SequenceOfPnt& theVertices,
|
||||
const Handle (Prs3d_PointAspect)& theAspect)
|
||||
{
|
||||
Standard_Integer aNbVertices = theVertices.Length();
|
||||
if (aNbVertices < 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Handle(Graphic3d_ArrayOfPoints) aVertexArray = new Graphic3d_ArrayOfPoints (aNbVertices);
|
||||
for (Standard_Integer anI = 1; anI <= aNbVertices; ++anI)
|
||||
{
|
||||
aVertexArray->AddVertex (theVertices.Value (anI));
|
||||
}
|
||||
|
||||
Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup (thePresentation);
|
||||
aGroup->SetPrimitivesAspect (theAspect->Aspect());
|
||||
aGroup->AddPrimitiveArray (aVertexArray);
|
||||
}
|
@@ -15,113 +15,57 @@
|
||||
#define _StdPrs_WFShape_H__
|
||||
|
||||
#include <Prs3d_Root.hxx>
|
||||
#include <Prs3d_Presentation.hxx>
|
||||
#include <Prs3d_Drawer.hxx>
|
||||
#include <TopTools_HSequenceOfShape.hxx>
|
||||
#include <Quantity_Length.hxx>
|
||||
#include <Prs3d_WFShape.hxx>
|
||||
#include <StdPrs_WFRestrictedFace.hxx>
|
||||
#include <StdPrs_Curve.hxx>
|
||||
#include <StdPrs_Vertex.hxx>
|
||||
#include <Prs3d_Presentation.hxx>
|
||||
#include <Prs3d_PointAspect.hxx>
|
||||
#include <Prs3d_LineAspect.hxx>
|
||||
#include <TColgp_SequenceOfPnt.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TopTools_ListOfShape.hxx>
|
||||
|
||||
//! Tool for computing wireframe presentation of a TopoDS_Shape.
|
||||
class StdPrs_WFShape : public Prs3d_Root
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//! Add shape to presentation
|
||||
static inline void Add (const Handle (Prs3d_Presentation)& thePrs,
|
||||
const TopoDS_Shape& theShape,
|
||||
const Handle (Prs3d_Drawer)& theDrawer)
|
||||
{
|
||||
Face aFaceAlgo;
|
||||
Curve aCurveAlgo;
|
||||
Prs3d_WFShape anAlgo (aFaceAlgo, aCurveAlgo);
|
||||
anAlgo.Add (thePrs, theShape, theDrawer);
|
||||
}
|
||||
|
||||
static inline Handle(TopTools_HSequenceOfShape) PickCurve
|
||||
(const Quantity_Length theX,
|
||||
const Quantity_Length theY,
|
||||
const Quantity_Length theZ,
|
||||
const Quantity_Length theDistance,
|
||||
const TopoDS_Shape& theShape,
|
||||
const Handle (Prs3d_Drawer)& theDrawer)
|
||||
{
|
||||
Face aFaceAlgo;
|
||||
Curve aCurveAlgo;
|
||||
Prs3d_WFShape anAlgo (aFaceAlgo, aCurveAlgo);
|
||||
return anAlgo.PickCurve (theX, theY, theZ, theDistance, theShape, theDrawer);
|
||||
}
|
||||
|
||||
static inline Handle(TopTools_HSequenceOfShape) PickPatch
|
||||
(const Quantity_Length theX,
|
||||
const Quantity_Length theY,
|
||||
const Quantity_Length theZ,
|
||||
const Quantity_Length theDistance,
|
||||
const TopoDS_Shape& theShape,
|
||||
const Handle(Prs3d_Drawer)& theDrawer)
|
||||
{
|
||||
Face aFaceAlgo;
|
||||
Curve aCurveAlgo;
|
||||
Prs3d_WFShape anAlgo (aFaceAlgo, aCurveAlgo);
|
||||
return anAlgo.PickPatch (theX, theY, theZ, theDistance, theShape, theDrawer);
|
||||
}
|
||||
//! Computes wireframe presentation of a shape.
|
||||
//! @param thePresentation [in] the presentation.
|
||||
//! @param theShape [in] the shape.
|
||||
//! @param theDrawer [in] the draw settings.
|
||||
Standard_EXPORT static void Add (const Handle (Prs3d_Presentation)& thePresentation,
|
||||
const TopoDS_Shape& theShape,
|
||||
const Handle (Prs3d_Drawer)& theDrawer);
|
||||
|
||||
private:
|
||||
|
||||
class Face : public Prs3d_WFShape::Face
|
||||
{
|
||||
public:
|
||||
virtual void Add (const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Handle(BRepAdaptor_HSurface)& theFace,
|
||||
const Standard_Boolean theToDrawUIso,
|
||||
const Standard_Boolean theToDrawVIso,
|
||||
const Quantity_Length theDeflection,
|
||||
const Standard_Integer theNBUiso,
|
||||
const Standard_Integer theNBViso,
|
||||
const Handle(Prs3d_Drawer)& theDrawer,
|
||||
Prs3d_NListOfSequenceOfPnt& theCurves) const
|
||||
{
|
||||
StdPrs_WFRestrictedFace::Add (thePrs, theFace, theToDrawUIso, theToDrawVIso, theDeflection,
|
||||
theNBUiso, theNBViso, theDrawer, theCurves);
|
||||
}
|
||||
//! Compute edge presentations for a shape.
|
||||
//! @param thePresentation [in] the presentation.
|
||||
//! @param theEdges [in] the list of edges.
|
||||
//! @param theAspect [in] the edge drawing aspect.
|
||||
//! @param theDrawer [in] the drawer settings.
|
||||
//! @param theShapeDeflection [in] the deflection for the wireframe shape.
|
||||
static void addEdges (const Handle (Prs3d_Presentation)& thePresentation,
|
||||
const TopTools_ListOfShape& theEdges,
|
||||
const Handle (Prs3d_LineAspect)& theAspect,
|
||||
const Handle (Prs3d_Drawer)& theDrawer,
|
||||
const Standard_Real theShapeDeflection);
|
||||
|
||||
virtual Standard_Boolean Match (const Quantity_Length theX,
|
||||
const Quantity_Length theY,
|
||||
const Quantity_Length theZ,
|
||||
const Quantity_Length theDistance,
|
||||
const Handle(BRepAdaptor_HSurface)& theFace,
|
||||
const Handle(Prs3d_Drawer)& theDrawer) const
|
||||
{
|
||||
return StdPrs_WFRestrictedFace::Match (theX, theY, theZ, theDistance, theFace, theDrawer);
|
||||
}
|
||||
};
|
||||
|
||||
class Curve : public Prs3d_WFShape::Curve
|
||||
{
|
||||
public:
|
||||
virtual void Add (const Handle(Prs3d_Presentation)& thePrs,
|
||||
Adaptor3d_Curve& theCurve,
|
||||
const Quantity_Length theDeflection,
|
||||
const Handle(Prs3d_Drawer)& theDrawer,
|
||||
TColgp_SequenceOfPnt& thePoints,
|
||||
const Standard_Boolean theToDrawCurve) const
|
||||
{
|
||||
StdPrs_Curve::Add (thePrs, theCurve, theDeflection, theDrawer, thePoints, theToDrawCurve);
|
||||
}
|
||||
|
||||
virtual Standard_Boolean Match (const Quantity_Length theX,
|
||||
const Quantity_Length theY,
|
||||
const Quantity_Length theZ,
|
||||
const Quantity_Length theDistance,
|
||||
const Adaptor3d_Curve& theCurve,
|
||||
const Handle(Prs3d_Drawer)& theDrawer) const
|
||||
{
|
||||
return StdPrs_Curve::Match (theX, theY, theZ, theDistance, theCurve, theDrawer);
|
||||
}
|
||||
};
|
||||
//! Compute free and boundary edges on a triangulation of a face.
|
||||
//! @param thePresentation [in] the presentation.
|
||||
//! @param theFaces [in] the list of triangulated faces.
|
||||
//! @param theAspect [in] the edge drawing aspect.
|
||||
//! @param theDrawer [in] the drawer settings.
|
||||
static void addEdgesOnTriangulation (const Handle(Prs3d_Presentation)& thePresentation,
|
||||
const TopTools_ListOfShape& theFaces,
|
||||
const Handle (Prs3d_LineAspect)& theAspect);
|
||||
|
||||
//! Compute vertex presentation for a shape.
|
||||
//! @param thePresentation [in] the presentation.
|
||||
//! @param theVertices [in] the list of points.
|
||||
//! @param theAspect [in] the point drawing aspect.
|
||||
static void addVertices (const Handle (Prs3d_Presentation)& thePresentation,
|
||||
const TColgp_SequenceOfPnt& theVertices,
|
||||
const Handle (Prs3d_PointAspect)& theAspect);
|
||||
};
|
||||
|
||||
#endif // _StdPrs_WFShape_H__
|
||||
|
@@ -145,28 +145,6 @@ void StdPrs_WFSurface::Add (const Handle(Prs3d_Presentation)& aPresentation,
|
||||
|
||||
Standard_Boolean UClosed = aSurface->IsUClosed();
|
||||
Standard_Boolean VClosed = aSurface->IsVClosed();
|
||||
|
||||
Standard_Real TheDeflection;
|
||||
Aspect_TypeOfDeflection TOD = aDrawer->TypeOfDeflection();
|
||||
if (TOD == Aspect_TOD_RELATIVE) {
|
||||
// On calcule la fleche en fonction des min max globaux de la piece:
|
||||
Bnd_Box Total;
|
||||
BndLib_AddSurface::Add(aSurface->Surface(),U1, U2, V1, V2, 0.,Total);
|
||||
Standard_Real m = aDrawer->MaximalChordialDeviation()/
|
||||
aDrawer->DeviationCoefficient();
|
||||
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
|
||||
Total.Get( aXmin, aYmin, aZmin, aXmax, aYmax, aZmax );
|
||||
if ( ! (Total.IsOpenXmin() || Total.IsOpenXmax() ))
|
||||
m = Min ( m , Abs (aXmax-aXmin));
|
||||
if ( ! (Total.IsOpenYmin() || Total.IsOpenYmax() ))
|
||||
m = Min ( m , Abs (aYmax-aYmin));
|
||||
if ( ! (Total.IsOpenZmin() || Total.IsOpenZmax() ))
|
||||
m = Min ( m , Abs (aZmax-aZmin));
|
||||
|
||||
TheDeflection = m * aDrawer->DeviationCoefficient();
|
||||
}
|
||||
else
|
||||
TheDeflection = aDrawer->MaximalChordialDeviation();
|
||||
|
||||
Adaptor3d_IsoCurve anIso;
|
||||
anIso.Load(aSurface);
|
||||
@@ -174,66 +152,67 @@ void StdPrs_WFSurface::Add (const Handle(Prs3d_Presentation)& aPresentation,
|
||||
// Trace des frontieres.
|
||||
// *********************
|
||||
//
|
||||
if ( !(UClosed && VClosed) ) {
|
||||
|
||||
(Prs3d_Root::CurrentGroup(aPresentation))->SetPrimitivesAspect
|
||||
(aDrawer->FreeBoundaryAspect()->Aspect());
|
||||
if ( !UClosed )
|
||||
{
|
||||
anIso.Load(GeomAbs_IsoU,U1,V1,V2);
|
||||
Handle(TColgp_HSequenceOfPnt) aPntsU1 = new TColgp_HSequenceOfPnt;
|
||||
StdPrs_Curve::Add(aPresentation,anIso,TheDeflection, aDrawer, aPntsU1->ChangeSequence(), Standard_False);
|
||||
freeCurves.Append(aPntsU1);
|
||||
anIso.Load(GeomAbs_IsoU,U2,V1,V2);
|
||||
Handle(TColgp_HSequenceOfPnt) aPntsU2 = new TColgp_HSequenceOfPnt;
|
||||
StdPrs_Curve::Add(aPresentation,anIso,TheDeflection, aDrawer, aPntsU2->ChangeSequence(), Standard_False);
|
||||
freeCurves.Append(aPntsU2);
|
||||
}
|
||||
if ( !VClosed )
|
||||
{
|
||||
anIso.Load(GeomAbs_IsoV,V1,U1,U2);
|
||||
Handle(TColgp_HSequenceOfPnt) aPntsV1 = new TColgp_HSequenceOfPnt;
|
||||
StdPrs_Curve::Add(aPresentation,anIso,TheDeflection, aDrawer, aPntsV1->ChangeSequence(), Standard_False);
|
||||
freeCurves.Append(aPntsV1);
|
||||
anIso.Load(GeomAbs_IsoV,V2,U1,U2);
|
||||
Handle(TColgp_HSequenceOfPnt) aPntsV2 = new TColgp_HSequenceOfPnt;
|
||||
StdPrs_Curve::Add(aPresentation,anIso,TheDeflection, aDrawer, aPntsV2->ChangeSequence(), Standard_False);
|
||||
freeCurves.Append(aPntsV2);
|
||||
}
|
||||
if (!(UClosed && VClosed))
|
||||
{
|
||||
Prs3d_Root::CurrentGroup (aPresentation)->SetPrimitivesAspect (aDrawer->FreeBoundaryAspect()->Aspect());
|
||||
if (!UClosed)
|
||||
{
|
||||
anIso.Load (GeomAbs_IsoU, U1, V1, V2);
|
||||
Handle(TColgp_HSequenceOfPnt) aPntsU1 = new TColgp_HSequenceOfPnt;
|
||||
StdPrs_Curve::Add (aPresentation, anIso, aDrawer, aPntsU1->ChangeSequence(), Standard_False);
|
||||
freeCurves.Append (aPntsU1);
|
||||
|
||||
anIso.Load (GeomAbs_IsoU,U2,V1,V2);
|
||||
Handle(TColgp_HSequenceOfPnt) aPntsU2 = new TColgp_HSequenceOfPnt;
|
||||
StdPrs_Curve::Add (aPresentation, anIso, aDrawer, aPntsU2->ChangeSequence(), Standard_False);
|
||||
freeCurves.Append(aPntsU2);
|
||||
}
|
||||
if (!VClosed)
|
||||
{
|
||||
anIso.Load (GeomAbs_IsoV, V1, U1, U2);
|
||||
Handle(TColgp_HSequenceOfPnt) aPntsV1 = new TColgp_HSequenceOfPnt;
|
||||
StdPrs_Curve::Add (aPresentation, anIso, aDrawer, aPntsV1->ChangeSequence(), Standard_False);
|
||||
freeCurves.Append (aPntsV1);
|
||||
|
||||
anIso.Load (GeomAbs_IsoV, V2, U1, U2);
|
||||
Handle(TColgp_HSequenceOfPnt) aPntsV2 = new TColgp_HSequenceOfPnt;
|
||||
StdPrs_Curve::Add (aPresentation, anIso, aDrawer, aPntsV2->ChangeSequence(), Standard_False);
|
||||
freeCurves.Append(aPntsV2);
|
||||
}
|
||||
}
|
||||
//
|
||||
// Trace des isoparametriques.
|
||||
// ***************************
|
||||
//
|
||||
Standard_Integer fin = aDrawer->UIsoAspect()->Number();
|
||||
if ( fin != 0) {
|
||||
|
||||
(Prs3d_Root::CurrentGroup(aPresentation))->SetPrimitivesAspect
|
||||
(aDrawer->UIsoAspect()->Aspect());
|
||||
|
||||
Standard_Real du= UClosed ? (U2-U1)/fin : (U2-U1)/(1+fin);
|
||||
for (Standard_Integer i=1; i<=fin;i++){
|
||||
anIso.Load(GeomAbs_IsoU,U1+du*i,V1,V2);
|
||||
if (fin != 0)
|
||||
{
|
||||
Prs3d_Root::CurrentGroup (aPresentation)->SetPrimitivesAspect (aDrawer->UIsoAspect()->Aspect());
|
||||
|
||||
Standard_Real du= UClosed ? (U2-U1) / fin : (U2-U1) / (1 + fin);
|
||||
for (Standard_Integer i = 1; i <= fin; i++)
|
||||
{
|
||||
anIso.Load (GeomAbs_IsoU, U1 + du * i, V1, V2);
|
||||
Handle(TColgp_HSequenceOfPnt) Pnts = new TColgp_HSequenceOfPnt;
|
||||
StdPrs_Curve::Add(aPresentation,anIso,TheDeflection, aDrawer, Pnts->ChangeSequence(), Standard_False);
|
||||
UIsoCurves.Append(Pnts);
|
||||
StdPrs_Curve::Add (aPresentation, anIso, aDrawer, Pnts->ChangeSequence(), Standard_False);
|
||||
UIsoCurves.Append (Pnts);
|
||||
}
|
||||
}
|
||||
fin = aDrawer->VIsoAspect()->Number();
|
||||
if ( fin != 0) {
|
||||
if (fin != 0)
|
||||
{
|
||||
Prs3d_Root::CurrentGroup (aPresentation)->SetPrimitivesAspect (aDrawer->VIsoAspect()->Aspect());
|
||||
|
||||
(Prs3d_Root::CurrentGroup(aPresentation))->SetPrimitivesAspect
|
||||
(aDrawer->VIsoAspect()->Aspect());
|
||||
|
||||
Standard_Real dv= VClosed ?(V2-V1)/fin : (V2-V1)/(1+fin);
|
||||
for (Standard_Integer i=1; i<=fin;i++){
|
||||
anIso.Load(GeomAbs_IsoV,V1+dv*i,U1,U2);
|
||||
Standard_Real dv = VClosed ? (V2 - V1) / fin : (V2 - V1) / (1 + fin);
|
||||
for (Standard_Integer i = 1; i <= fin; i++)
|
||||
{
|
||||
anIso.Load (GeomAbs_IsoV, V1 + dv * i, U1, U2);
|
||||
Handle(TColgp_HSequenceOfPnt) Pnts = new TColgp_HSequenceOfPnt;
|
||||
StdPrs_Curve::Add(aPresentation,anIso,TheDeflection, aDrawer, Pnts->ChangeSequence(), Standard_False);
|
||||
VIsoCurves.Append(Pnts);
|
||||
StdPrs_Curve::Add (aPresentation, anIso, aDrawer, Pnts->ChangeSequence(), Standard_False);
|
||||
VIsoCurves.Append (Pnts);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Standard_Integer nbVertices = 0, nbBounds = 0;
|
||||
//Draw surface via primitive array
|
||||
if(UIsoCurves.Size() > 0) {
|
||||
|
Reference in New Issue
Block a user