mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +03:00
749 lines
25 KiB
C++
749 lines
25 KiB
C++
// Copyright (c) 2013 OPEN CASCADE SAS
|
|
//
|
|
// The content of this file is subject to the Open CASCADE Technology Public
|
|
// License Version 6.5 (the "License"). You may not use the content of this file
|
|
// except in compliance with the License. Please obtain a copy of the License
|
|
// at http://www.opencascade.org and read it completely before using this file.
|
|
//
|
|
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
|
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
|
//
|
|
// The Original Code and all software distributed under the License is
|
|
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
|
// Initial Developer hereby disclaims all such warranties, including without
|
|
// limitation, any warranties of merchantability, fitness for a particular
|
|
// purpose or non-infringement. Please see the License for the specific terms
|
|
// and conditions governing the rights and limitations under the License.
|
|
|
|
#ifndef _Prs3d_WFShape_H__
|
|
#define _Prs3d_WFShape_H__
|
|
|
|
#include <Bnd_Box.hxx>
|
|
#include <BRepAdaptor_HSurface.hxx>
|
|
#include <BRepAdaptor_Curve.hxx>
|
|
#include <BRepBndLib.hxx>
|
|
#include <BRep_Builder.hxx>
|
|
#include <BRep_Tool.hxx>
|
|
#include <Graphic3d_Group.hxx>
|
|
#include <Graphic3d_AspectLine3d.hxx>
|
|
#include <Graphic3d_ArrayOfPolylines.hxx>
|
|
#include <Graphic3d_Array1OfVertex.hxx>
|
|
#include <GCPnts_TangentialDeflection.hxx>
|
|
#include <GCPnts_UniformDeflection.hxx>
|
|
#include <gp_Circ.hxx>
|
|
#include <gp_Pnt.hxx>
|
|
#include <Poly_Connect.hxx>
|
|
#include <Poly_Triangulation.hxx>
|
|
#include <Poly_Array1OfTriangle.hxx>
|
|
#include <Poly_Polygon3D.hxx>
|
|
#include <Poly_PolygonOnTriangulation.hxx>
|
|
#include <Precision.hxx>
|
|
#include <Prs3d_Root.hxx>
|
|
#include <Prs3d_Drawer.hxx>
|
|
#include <Prs3d_IsoAspect.hxx>
|
|
#include <Prs3d_PointAspect.hxx>
|
|
#include <Prs3d_NListOfSequenceOfPnt.hxx>
|
|
#include <Prs3d_NListIteratorOfListOfSequenceOfPnt.hxx>
|
|
#include <Prs3d_ShapeTool.hxx>
|
|
#include <Standard_ErrorHandler.hxx>
|
|
#include <TColgp_Array1OfPnt.hxx>
|
|
#include <TColgp_SequenceOfPnt.hxx>
|
|
#include <TColStd_Array1OfReal.hxx>
|
|
#include <TColStd_HArray1OfInteger.hxx>
|
|
#include <TopoDS_Edge.hxx>
|
|
#include <TopoDS_Vertex.hxx>
|
|
#include <TopoDS.hxx>
|
|
#include <TopTools_HSequenceOfShape.hxx>
|
|
#include <TopTools_ListOfShape.hxx>
|
|
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
|
|
|
template <class FacePresentation, class CurvePresentation, class PointPresentation>
|
|
class Prs3d_WFShape : Prs3d_Root
|
|
{
|
|
public:
|
|
|
|
DEFINE_STANDARD_ALLOC
|
|
|
|
private:
|
|
|
|
//=========================================================================
|
|
// function: IsSame
|
|
// purpose
|
|
//=========================================================================
|
|
|
|
Standard_EXPORT static Standard_Boolean IsSame (const Handle(Graphic3d_AspectLine3d)& theUAspect,
|
|
const Handle(Graphic3d_AspectLine3d)& theVAspect)
|
|
{
|
|
Standard_Boolean isSame = Standard_True;
|
|
Quantity_Color aCU, aCV;
|
|
Aspect_TypeOfLine aTlU, aTlV;
|
|
Standard_Real aWU, aWV;
|
|
|
|
theUAspect->Values(aCU, aTlU, aWU);
|
|
theVAspect->Values(aCV, aTlV, aWV);
|
|
|
|
if (aCU != aCV || aTlU != aTlV || aWU != aWV)
|
|
{
|
|
isSame = Standard_False;
|
|
}
|
|
|
|
return isSame;
|
|
}
|
|
|
|
//=========================================================================
|
|
// function: AddPolygon
|
|
// purpose
|
|
//=========================================================================
|
|
|
|
Standard_EXPORT static Standard_Boolean AddPolygon (const TopoDS_Edge& theEdge,
|
|
Handle(Graphic3d_Group)& theGroup,
|
|
const Standard_Real theDeflection,
|
|
const Handle (Prs3d_Drawer)& ,
|
|
TColgp_SequenceOfPnt& thePoints)
|
|
{
|
|
TopLoc_Location aLocation;
|
|
Standard_Real aFirst, aLast;
|
|
Handle(Geom_Curve) aCurve3d = BRep_Tool::Curve(theEdge, aFirst, aLast);
|
|
Handle(Poly_Polygon3D) aPolygon = BRep_Tool::Polygon3D(theEdge, aLocation);
|
|
|
|
if (!aPolygon.IsNull())
|
|
{
|
|
if ((aPolygon->Deflection() <= theDeflection) || aCurve3d.IsNull())
|
|
{
|
|
const TColgp_Array1OfPnt& aPoints = aPolygon->Nodes();
|
|
Standard_Integer anIndex = aPoints.Lower();
|
|
if (aLocation.IsIdentity())
|
|
{
|
|
for (; anIndex <= aPoints.Upper(); anIndex++)
|
|
thePoints.Append(aPoints.Value(anIndex));
|
|
}
|
|
else
|
|
{
|
|
for (; anIndex <= aPoints.Upper(); anIndex++)
|
|
thePoints.Append(aPoints.Value(anIndex).Transformed(aLocation));
|
|
}
|
|
return Standard_True;
|
|
}
|
|
}
|
|
|
|
Handle(Poly_Triangulation) aTriangulation;
|
|
Handle(Poly_PolygonOnTriangulation) aHIndices;
|
|
BRep_Tool::PolygonOnTriangulation(theEdge, aHIndices, aTriangulation, aLocation);
|
|
if (!aHIndices.IsNull())
|
|
{
|
|
if ((aHIndices->Deflection() <= theDeflection) || aCurve3d.IsNull())
|
|
{
|
|
const TColStd_Array1OfInteger& anIndices = aHIndices->Nodes();
|
|
const TColgp_Array1OfPnt& aNodes = aTriangulation->Nodes();
|
|
|
|
Standard_Integer anIndex = anIndices.Lower();
|
|
if (aLocation.IsIdentity())
|
|
{
|
|
for (; anIndex <= anIndices.Upper(); anIndex++)
|
|
thePoints.Append(aNodes(anIndices(anIndex)));
|
|
}
|
|
else
|
|
{
|
|
for (; anIndex <= anIndices.Upper(); anIndex++)
|
|
thePoints.Append(aNodes(anIndices(anIndex)).Transformed(aLocation));
|
|
}
|
|
return Standard_True;
|
|
}
|
|
}
|
|
return Standard_False;
|
|
}
|
|
|
|
public:
|
|
|
|
//=========================================================================
|
|
// function: Add
|
|
// purpose
|
|
//=========================================================================
|
|
|
|
Standard_EXPORT static void Add (const Handle (Prs3d_Presentation)& thePresentation,
|
|
const TopoDS_Shape& theShape,
|
|
const Handle (Prs3d_Drawer)& theDrawer)
|
|
{
|
|
if (theShape.IsNull()) return;
|
|
|
|
Prs3d_ShapeTool aTool(theShape);
|
|
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);
|
|
}
|
|
}
|
|
|
|
Standard_Real aDeflection;
|
|
if (theDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE)
|
|
{
|
|
// The arrow calculation is based on the global min max
|
|
Bnd_Box aBndBox;
|
|
BRepBndLib::Add(theShape, aBndBox);
|
|
if (! aBndBox.IsVoid())
|
|
{
|
|
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
|
|
aBndBox.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
|
|
aDeflection = Max (aXmax-aXmin, Max (aYmax-aYmin, aZmax-aZmin)) *
|
|
theDrawer->DeviationCoefficient();
|
|
}
|
|
else
|
|
aDeflection = theDrawer->MaximalChordialDeviation();
|
|
}
|
|
else
|
|
aDeflection = theDrawer->MaximalChordialDeviation();
|
|
|
|
Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePresentation);
|
|
|
|
Prs3d_NListOfSequenceOfPnt anUIsoCurves;
|
|
Prs3d_NListOfSequenceOfPnt aVIsoCurves;
|
|
Prs3d_NListOfSequenceOfPnt aWireCurves;
|
|
Prs3d_NListOfSequenceOfPnt aFreeCurves;
|
|
Prs3d_NListOfSequenceOfPnt anUnFreeCurves;
|
|
TColgp_SequenceOfPnt aShapePoints;
|
|
|
|
if (IsSame(theDrawer->UIsoAspect()->Aspect(), theDrawer->VIsoAspect()->Aspect()))
|
|
{
|
|
const Standard_Integer anIsoU = theDrawer->UIsoAspect()->Number();
|
|
const Standard_Integer anIsoV = theDrawer->VIsoAspect()->Number();
|
|
if (anIsoU || anIsoV)
|
|
{
|
|
BRepAdaptor_Surface aSurface;
|
|
for (aTool.InitFace();aTool.MoreFace();aTool.NextFace())
|
|
{
|
|
if (aTool.HasSurface())
|
|
{
|
|
if (!aTool.IsPlanarFace() || theDrawer->IsoOnPlane())
|
|
{
|
|
aSurface.Initialize(aTool.GetFace());
|
|
Handle(BRepAdaptor_HSurface) aHSurface = new BRepAdaptor_HSurface(aSurface);
|
|
try {
|
|
OCC_CATCH_SIGNALS
|
|
Prs3d_NListOfSequenceOfPnt aCurUIsoCurves;
|
|
FacePresentation::Add(thePresentation, aHSurface,
|
|
anIsoU, anIsoV,
|
|
aDeflection,
|
|
anIsoU, anIsoV,
|
|
theDrawer,
|
|
aCurUIsoCurves);
|
|
Prs3d_NListIteratorOfListOfSequenceOfPnt anIt;
|
|
for( anIt.Init(aCurUIsoCurves); anIt.More(); anIt.Next())
|
|
anUIsoCurves.Append(anIt.Value());
|
|
}
|
|
catch (Standard_Failure)
|
|
{
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
const Standard_Integer anIsoU = theDrawer->UIsoAspect()->Number();
|
|
const Standard_Integer anIsoV = theDrawer->VIsoAspect()->Number();
|
|
if (anIsoU)
|
|
{
|
|
BRepAdaptor_Surface aSurface;
|
|
for (aTool.InitFace();aTool.MoreFace();aTool.NextFace())
|
|
{
|
|
if (aTool.HasSurface())
|
|
{
|
|
if (!aTool.IsPlanarFace() || theDrawer->IsoOnPlane())
|
|
{
|
|
aSurface.Initialize(aTool.GetFace());
|
|
Handle(BRepAdaptor_HSurface) aHSurface = new BRepAdaptor_HSurface(aSurface);
|
|
try
|
|
{
|
|
OCC_CATCH_SIGNALS
|
|
Prs3d_NListOfSequenceOfPnt aCurUIsoCurves;
|
|
FacePresentation::Add(thePresentation, aHSurface,
|
|
anIsoU, Standard_False,
|
|
aDeflection,
|
|
anIsoU, 0,
|
|
theDrawer,
|
|
aCurUIsoCurves);
|
|
}
|
|
catch (Standard_Failure)
|
|
{
|
|
#ifdef DEB
|
|
const TopoDS_Face& aFace = aSurface.Face();
|
|
cout <<"Problem with the face "<< (void*) &(*(aFace).TShape()) << endl;
|
|
#endif
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (anIsoV)
|
|
{
|
|
BRepAdaptor_Surface aSurface;
|
|
for (aTool.InitFace();aTool.MoreFace();aTool.NextFace())
|
|
{
|
|
if (aTool.HasSurface())
|
|
{
|
|
if (!aTool.IsPlanarFace() || theDrawer->IsoOnPlane())
|
|
{
|
|
aSurface.Initialize(aTool.GetFace());
|
|
Handle(BRepAdaptor_HSurface) aHSurface = new BRepAdaptor_HSurface(aSurface);
|
|
try
|
|
{
|
|
OCC_CATCH_SIGNALS
|
|
Prs3d_NListOfSequenceOfPnt aCurUIsoCurves;
|
|
FacePresentation::Add(thePresentation, aHSurface,
|
|
Standard_False, anIsoV,
|
|
aDeflection,
|
|
0, anIsoV,
|
|
theDrawer,
|
|
aCurUIsoCurves);
|
|
}
|
|
catch (Standard_Failure)
|
|
{
|
|
#ifdef DEB
|
|
const TopoDS_Face& aFace = aSurface.Face();
|
|
cout <<"Problem with the face "<< (void*) &(*(aFace).TShape()) << endl;
|
|
#endif
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
Standard_Integer aNbVertices = 0, aNbBounds = 0;
|
|
|
|
if(anUIsoCurves.Size() > 0) {
|
|
aNbBounds = anUIsoCurves.Size();
|
|
Prs3d_NListIteratorOfListOfSequenceOfPnt anIt;
|
|
for( anIt.Init(anUIsoCurves); anIt.More(); anIt.Next())
|
|
aNbVertices += anIt.Value().Length();
|
|
Handle(Graphic3d_ArrayOfPolylines) anUIsoArray =
|
|
new Graphic3d_ArrayOfPolylines(aNbVertices,aNbBounds);
|
|
for( anIt.Init(anUIsoCurves); anIt.More(); anIt.Next()) {
|
|
TColgp_SequenceOfPnt aPoints;
|
|
aPoints.Assign(anIt.Value());
|
|
anUIsoArray->AddBound(aPoints.Length());
|
|
for(Standard_Integer anI = 1; anI <= aPoints.Length(); ++anI)
|
|
anUIsoArray->AddVertex(aPoints.Value(anI));
|
|
}
|
|
Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePresentation);
|
|
aGroup->SetPrimitivesAspect(theDrawer->UIsoAspect()->Aspect());
|
|
aGroup->AddPrimitiveArray(anUIsoArray);
|
|
}
|
|
|
|
if(aVIsoCurves.Size() > 0) {
|
|
aNbBounds = aVIsoCurves.Size();
|
|
Prs3d_NListIteratorOfListOfSequenceOfPnt anIt;
|
|
for( anIt.Init(aVIsoCurves); anIt.More(); anIt.Next())
|
|
aNbVertices += anIt.Value().Length();
|
|
Handle(Graphic3d_ArrayOfPolylines) VIsoArray =
|
|
new Graphic3d_ArrayOfPolylines(aNbVertices,aNbBounds);
|
|
for( anIt.Init(aVIsoCurves); anIt.More(); anIt.Next()) {
|
|
TColgp_SequenceOfPnt aPoints;
|
|
aPoints.Assign(anIt.Value());
|
|
VIsoArray->AddBound(aPoints.Length());
|
|
for(int anI=1; anI<=aPoints.Length(); anI++)
|
|
VIsoArray->AddVertex(aPoints.Value(anI));
|
|
}
|
|
Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePresentation);
|
|
aGroup->SetPrimitivesAspect(theDrawer->VIsoAspect()->Aspect());
|
|
aGroup->AddPrimitiveArray(VIsoArray);
|
|
}
|
|
|
|
TopLoc_Location aLocation;
|
|
Standard_Integer anI, aJ, aN[3];
|
|
|
|
Standard_Boolean isDispTriangles = Standard_False;
|
|
const char* anEnvVar = getenv("DEBUG_TRIANGLES");
|
|
if (anEnvVar != 0L) {
|
|
isDispTriangles = (atol(anEnvVar) != 0);
|
|
}
|
|
|
|
TColgp_SequenceOfPnt aSurfPoints;
|
|
for (aTool.InitFace();aTool.MoreFace();aTool.NextFace())
|
|
{
|
|
if (!aTool.HasSurface() || isDispTriangles)
|
|
{
|
|
Handle(Poly_Triangulation) T = aTool.CurrentTriangulation(aLocation);
|
|
if (!T.IsNull())
|
|
{
|
|
const TColgp_Array1OfPnt& aNodes = T->Nodes();
|
|
// Build the connect tool
|
|
Poly_Connect aPolyConnect(T);
|
|
|
|
Standard_Integer aNbFree, aNbInternal, aNbTriangles = T->NbTriangles();
|
|
Standard_Integer aT[3];
|
|
|
|
// Count the free edges
|
|
aNbFree = 0;
|
|
for (anI = 1; anI <= aNbTriangles; anI++) {
|
|
aPolyConnect.Triangles(anI,aT[0],aT[1],aT[2]);
|
|
for (aJ = 0; aJ < 3; aJ++)
|
|
if (aT[aJ] == 0) aNbFree++;
|
|
}
|
|
|
|
// Allocate the arrays
|
|
TColStd_Array1OfInteger aFree(1,2*aNbFree);
|
|
aNbInternal = (3*aNbTriangles - aNbFree) / 2;
|
|
TColStd_Array1OfInteger anInternal(0,2*aNbInternal);
|
|
|
|
Standard_Integer aFreeIndex = 1, anIntIndex = 1;
|
|
const Poly_Array1OfTriangle& aTriangles = T->Triangles();
|
|
for (anI = 1; anI <= aNbTriangles; anI++) {
|
|
aPolyConnect.Triangles(anI,aT[0],aT[1],aT[2]);
|
|
aTriangles(anI).Get(aN[0],aN[1],aN[2]);
|
|
for (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;
|
|
}
|
|
}
|
|
}
|
|
|
|
if(!aTool.HasSurface())
|
|
{
|
|
// free edges
|
|
Standard_Integer aFreeHalfNb = aFree.Length() / 2;
|
|
for (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(isDispTriangles)
|
|
{
|
|
for (anI = 1; anI <= aNbInternal; anI++) {
|
|
gp_Pnt aPoint1 = aNodes(anInternal(2*anI-1)).Transformed(aLocation);
|
|
gp_Pnt aPoint2 = aNodes(anInternal(2*anI)).Transformed(aLocation);
|
|
aSurfPoints.Append(aPoint1);
|
|
aSurfPoints.Append(aPoint2);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if(aSurfPoints.Length()>0){
|
|
aNbVertices = aSurfPoints.Length();
|
|
aNbBounds = (Standard_Integer)aNbVertices / 2;
|
|
Handle(Graphic3d_ArrayOfPolylines) aSurfArray =
|
|
new Graphic3d_ArrayOfPolylines(aNbVertices,aNbBounds);
|
|
for(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);
|
|
if(isDispTriangles && aTool.HasSurface())
|
|
aGroup->SetPrimitivesAspect(theDrawer->UIsoAspect()->Aspect());
|
|
else
|
|
aGroup->SetPrimitivesAspect(theDrawer->FreeBoundaryAspect()->Aspect());
|
|
aGroup->AddPrimitiveArray(aSurfArray);
|
|
}
|
|
TopTools_ListIteratorOfListOfShape anIt;
|
|
|
|
if (theDrawer->WireDraw())
|
|
{
|
|
// Wire (without any neighbour)
|
|
aGroup->SetPrimitivesAspect(theDrawer->WireAspect()->Aspect());
|
|
for (anIt.Initialize(aLWire); anIt.More(); anIt.Next()) {
|
|
const TopoDS_Edge& anEdge = TopoDS::Edge(anIt.Value());
|
|
try
|
|
{
|
|
OCC_CATCH_SIGNALS
|
|
TColgp_SequenceOfPnt aPoints;
|
|
if (!AddPolygon(anEdge, aGroup, aDeflection, theDrawer, aPoints))
|
|
{
|
|
if (BRep_Tool::IsGeometric(anEdge))
|
|
{
|
|
BRepAdaptor_Curve aCurve(anEdge);
|
|
CurvePresentation::Add(thePresentation, aCurve, aDeflection, theDrawer,
|
|
aPoints, Standard_False);
|
|
aWireCurves.Append(aPoints);
|
|
}
|
|
}
|
|
else
|
|
aWireCurves.Append(aPoints);
|
|
}
|
|
catch(Standard_Failure)
|
|
{
|
|
#ifdef DEB
|
|
cout <<"probleme sur aLocation'edge "<< (void*) &(*(anEdge).TShape()) << endl;
|
|
#endif
|
|
}
|
|
}
|
|
}
|
|
|
|
if (theDrawer->FreeBoundaryDraw())
|
|
{
|
|
// aFree boundaries;
|
|
for (anIt.Initialize(aLFree); anIt.More(); anIt.Next())
|
|
{
|
|
const TopoDS_Edge& anEdge = TopoDS::Edge(anIt.Value());
|
|
if (!BRep_Tool::Degenerated(anEdge))
|
|
{
|
|
try {
|
|
OCC_CATCH_SIGNALS
|
|
TColgp_SequenceOfPnt aPoints;
|
|
if (!AddPolygon(anEdge, aGroup, aDeflection, theDrawer, aPoints)) {
|
|
if (BRep_Tool::IsGeometric(anEdge)) {
|
|
BRepAdaptor_Curve aCurve(anEdge);
|
|
CurvePresentation::Add(thePresentation, aCurve, aDeflection, theDrawer,
|
|
aPoints, Standard_False);
|
|
aFreeCurves.Append(aPoints);
|
|
}
|
|
}
|
|
else
|
|
aFreeCurves.Append(aPoints);
|
|
}
|
|
catch(Standard_Failure)
|
|
{
|
|
#ifdef DEB
|
|
cout <<"probleme sur aLocation'edge "<< (void*) &(*(anEdge).TShape()) << endl;
|
|
#endif
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (theDrawer->UnFreeBoundaryDraw())
|
|
{
|
|
// Unfree boundaries;
|
|
|
|
for (anIt.Initialize(aLUnFree); anIt.More(); anIt.Next())
|
|
{
|
|
const TopoDS_Edge& anEdge = TopoDS::Edge(anIt.Value());
|
|
try
|
|
{
|
|
OCC_CATCH_SIGNALS
|
|
TColgp_SequenceOfPnt aPoints;
|
|
if (!AddPolygon(anEdge, aGroup, aDeflection, theDrawer, aPoints)) {
|
|
if (BRep_Tool::IsGeometric(anEdge)) {
|
|
BRepAdaptor_Curve aCurve(anEdge);
|
|
CurvePresentation::Add(thePresentation, aCurve, aDeflection, theDrawer, aPoints, Standard_False);
|
|
anUnFreeCurves.Append(aPoints);
|
|
}
|
|
}
|
|
else
|
|
anUnFreeCurves.Append(aPoints);
|
|
}
|
|
catch(Standard_Failure)
|
|
{
|
|
#ifdef DEB
|
|
cout <<"probleme sur aLocation'edge "<< (void*) &(*(anEdge).TShape()) << endl;
|
|
#endif
|
|
}
|
|
}
|
|
}
|
|
|
|
if(aWireCurves.Size() > 0)
|
|
{
|
|
aNbBounds = aWireCurves.Size();
|
|
Prs3d_NListIteratorOfListOfSequenceOfPnt anIt;
|
|
for( anIt.Init(aWireCurves); anIt.More(); anIt.Next())
|
|
aNbVertices += anIt.Value().Length();
|
|
Handle(Graphic3d_ArrayOfPolylines) WireArray =
|
|
new Graphic3d_ArrayOfPolylines(aNbVertices,aNbBounds);
|
|
for( anIt.Init(aWireCurves); anIt.More(); anIt.Next()) {
|
|
TColgp_SequenceOfPnt aPoints;
|
|
aPoints.Assign(anIt.Value());
|
|
WireArray->AddBound(aPoints.Length());
|
|
for(anI=1; anI<=aPoints.Length(); ++anI)
|
|
WireArray->AddVertex(aPoints.Value(anI));
|
|
}
|
|
Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePresentation);
|
|
aGroup->SetPrimitivesAspect(theDrawer->WireAspect()->Aspect());
|
|
aGroup->AddPrimitiveArray(WireArray);
|
|
}
|
|
if(aFreeCurves.Size() > 0) {
|
|
aNbBounds = aFreeCurves.Size();
|
|
Prs3d_NListIteratorOfListOfSequenceOfPnt anIt;
|
|
for( anIt.Init(aFreeCurves); anIt.More(); anIt.Next())
|
|
aNbVertices += anIt.Value().Length();
|
|
Handle(Graphic3d_ArrayOfPolylines) aFreeArray =
|
|
new Graphic3d_ArrayOfPolylines(aNbVertices,aNbBounds);
|
|
for( anIt.Init(aFreeCurves); anIt.More(); anIt.Next()) {
|
|
TColgp_SequenceOfPnt aPoints;
|
|
aPoints.Assign(anIt.Value());
|
|
aFreeArray->AddBound(aPoints.Length());
|
|
for(anI=1; anI<=aPoints.Length(); anI++)
|
|
aFreeArray->AddVertex(aPoints.Value(anI));
|
|
}
|
|
Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePresentation);
|
|
aGroup->SetPrimitivesAspect(theDrawer->FreeBoundaryAspect()->Aspect());
|
|
aGroup->AddPrimitiveArray(aFreeArray);
|
|
}
|
|
if(anUnFreeCurves.Size() > 0) {
|
|
aNbBounds = anUnFreeCurves.Size();
|
|
Prs3d_NListIteratorOfListOfSequenceOfPnt anIt;
|
|
for( anIt.Init(anUnFreeCurves); anIt.More(); anIt.Next())
|
|
aNbVertices += anIt.Value().Length();
|
|
Handle(Graphic3d_ArrayOfPolylines) anUnFreeArray =
|
|
new Graphic3d_ArrayOfPolylines(aNbVertices,aNbBounds);
|
|
for( anIt.Init(anUnFreeCurves); anIt.More(); anIt.Next()) {
|
|
TColgp_SequenceOfPnt aPoints;
|
|
aPoints.Assign(anIt.Value());
|
|
anUnFreeArray->AddBound(aPoints.Length());
|
|
for(anI=1; anI<=aPoints.Length(); anI++)
|
|
anUnFreeArray->AddVertex(aPoints.Value(anI));
|
|
}
|
|
Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePresentation);
|
|
aGroup->SetPrimitivesAspect(theDrawer->UnFreeBoundaryAspect()->Aspect());
|
|
aGroup->AddPrimitiveArray(anUnFreeArray);
|
|
}
|
|
|
|
// Points
|
|
for(aTool.InitVertex();aTool.MoreVertex();aTool.NextVertex())
|
|
aShapePoints.Append(BRep_Tool::Pnt(aTool.GetVertex()));
|
|
|
|
aNbVertices = aShapePoints.Length();
|
|
if(aNbVertices > 0) {
|
|
Graphic3d_Array1OfVertex aPointArray(1, aNbVertices);
|
|
for(anI=1; anI<=aNbVertices; anI++)
|
|
aPointArray.SetValue(anI, Graphic3d_Vertex(aShapePoints.Value(anI).X(), aShapePoints.Value(anI).Y(), aShapePoints.Value(anI).Z()));
|
|
|
|
Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePresentation);
|
|
aGroup->SetPrimitivesAspect(theDrawer->PointAspect()->Aspect());
|
|
aGroup->MarkerSet(aPointArray);
|
|
}
|
|
}
|
|
|
|
//=========================================================================
|
|
// function: PickCurve
|
|
// purpose
|
|
//=========================================================================
|
|
|
|
Standard_EXPORT static 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)
|
|
{
|
|
Handle(TopTools_HSequenceOfShape) aSeq = new TopTools_HSequenceOfShape;
|
|
Prs3d_ShapeTool aTool(theShape);
|
|
Standard_Boolean isContain;
|
|
|
|
for (aTool.InitCurve(); aTool.MoreCurve(); aTool.NextCurve())
|
|
{
|
|
Bnd_Box aBndBox = aTool.CurveBound();
|
|
aBndBox.Enlarge(theDistance);
|
|
if (! aBndBox.IsOut(gp_Pnt(theX, theY, theZ)))
|
|
{
|
|
if (CurvePresentation::Match(theX, theY, theZ, theDistance,
|
|
BRepAdaptor_Curve(aTool.GetCurve()), theDrawer))
|
|
{
|
|
isContain = Standard_False;
|
|
for (Standard_Integer anI = 1; anI <= aSeq->Length(); ++anI)
|
|
{
|
|
if (aSeq->Value(anI) == (aTool.GetCurve()))
|
|
{
|
|
isContain = Standard_True;
|
|
break;
|
|
}
|
|
}
|
|
if (!isContain) aSeq->Append(aTool.GetCurve());
|
|
}
|
|
}
|
|
}
|
|
return aSeq;
|
|
}
|
|
|
|
|
|
//=========================================================================
|
|
// function: PickPatch
|
|
// purpose
|
|
//=========================================================================
|
|
|
|
Standard_EXPORT static 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)
|
|
{
|
|
|
|
Handle(TopTools_HSequenceOfShape) aSeq = new TopTools_HSequenceOfShape;
|
|
Prs3d_ShapeTool aTool(theShape);
|
|
|
|
Standard_Boolean aRba1 = theDrawer->UIsoAspect()->Number() != 0;
|
|
Standard_Boolean aRba2 = theDrawer->VIsoAspect()->Number() != 0;
|
|
Standard_Boolean isContain;
|
|
|
|
if (aRba1 || aRba2)
|
|
{
|
|
BRepAdaptor_Surface aSurface;
|
|
for (aTool.InitFace(); aTool.MoreFace(); aTool.NextFace())
|
|
{
|
|
Bnd_Box aBndBox = aTool.FaceBound();
|
|
aBndBox.Enlarge(theDistance);
|
|
if (!aBndBox.IsOut(gp_Pnt(theX, theY, theZ)))
|
|
{
|
|
aSurface.Initialize(aTool.GetFace());
|
|
Handle(BRepAdaptor_HSurface) aHSurface = new BRepAdaptor_HSurface(aSurface);
|
|
if (FacePresentation::Match(theX, theY, theZ, theDistance, aHSurface, theDrawer))
|
|
{
|
|
isContain = Standard_False;
|
|
for (Standard_Integer anI = 1; anI <= aSeq->Length(); ++anI)
|
|
{
|
|
if (aSeq->Value(anI) == (aTool.GetFace()))
|
|
{
|
|
isContain = Standard_True;
|
|
break;
|
|
}
|
|
}
|
|
if (!isContain)
|
|
aSeq->Append(aTool.GetFace());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
for (aTool.InitCurve(); aTool.MoreCurve(); aTool.NextCurve())
|
|
{
|
|
Bnd_Box aBndBox = aTool.CurveBound();
|
|
aBndBox.Enlarge(theDistance);
|
|
if (!aBndBox.IsOut(gp_Pnt(theX, theY, theZ)))
|
|
{
|
|
if(CurvePresentation::Match(theX, theY, theZ, theDistance,
|
|
BRepAdaptor_Curve(aTool.GetCurve()), theDrawer))
|
|
{
|
|
Handle(TopTools_HSequenceOfShape) aSurface = aTool.FacesOfEdge();
|
|
for (Standard_Integer anI = 1; anI <= aSurface->Length(); ++anI)
|
|
{
|
|
isContain = Standard_False;
|
|
for (Standard_Integer aJ = 1; aJ <= aSeq->Length(); ++aJ)
|
|
{
|
|
if (aSeq->Value(aJ) == (aSurface->Value(anI)))
|
|
{
|
|
isContain = Standard_True;
|
|
break;
|
|
}
|
|
}
|
|
if (!isContain)
|
|
aSeq->Append(aSurface->Value(anI));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return aSeq;
|
|
}
|
|
|
|
};
|
|
|
|
#endif
|