mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-09-03 14:10:33 +03:00
0031458: Visualization - refine classes across Prs3d and StdPrs packages
Prs3d::GetDeflection() has been moved to StdPrs_ToolTriangulatedShape::GetDeflection(). Prs3d_ShapeTool has been moved to StdPrs_ShapeTool. Code collecting free edges on Poly_Triangulation has been moved out from StdPrs_WFShape to Prs3d::AddFreeEdges(). StdPrs_BndBox has been moved to Prs3d_BndBox. Geom_Transformation has been replaced by TopLoc_Datum3D within visualization classes. Select3D_SensitiveCircle constructor now takes gp_Circ instead of Geom_Circle. StdSelect_ViewerSelector3d has been moved to SelectMgr_ViewerSelector3d. Methods ::GetPoint3d() and ::ArrayBounds() has been moved from subclass Select3D_SensitiveCircle to the base class Select3D_SensitiveCurve. StdSelect_ViewerSelector3d::computeSensitivePrs() has been moved to SelectMgr::ComputeSensitivePrs(). Removed unused declarations StdSelect_Prs, StdSelect_DisplayMode, StdSelect_SensitivityMode, StdSelect_TypeOfResult, SelectMgr_SOPtr, TColQuantity. Package Graphic3d has been moved from TKV3d to TKService.
This commit is contained in:
@@ -6,6 +6,8 @@ Prs3d_ArrowAspect.cxx
|
||||
Prs3d_ArrowAspect.hxx
|
||||
Prs3d_BasicAspect.cxx
|
||||
Prs3d_BasicAspect.hxx
|
||||
Prs3d_BndBox.cxx
|
||||
Prs3d_BndBox.hxx
|
||||
Prs3d_DatumAspect.cxx
|
||||
Prs3d_DatumAspect.hxx
|
||||
Prs3d_DatumAttribute.hxx
|
||||
@@ -38,7 +40,6 @@ Prs3d_PresentationShadow.hxx
|
||||
Prs3d_Root.hxx
|
||||
Prs3d_ShadingAspect.cxx
|
||||
Prs3d_ShadingAspect.hxx
|
||||
Prs3d_ShapeTool.cxx
|
||||
Prs3d_ShapeTool.hxx
|
||||
Prs3d_Text.cxx
|
||||
Prs3d_Text.hxx
|
||||
|
@@ -16,15 +16,83 @@
|
||||
|
||||
#include <Prs3d.hxx>
|
||||
|
||||
#include <Bnd_Box.hxx>
|
||||
#include <BRepBndLib.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <Graphic3d_Group.hxx>
|
||||
#include <Prs3d_Drawer.hxx>
|
||||
#include <Prs3d_LineAspect.hxx>
|
||||
#include <Prs3d_Root.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <Graphic3d_ArrayOfSegments.hxx>
|
||||
#include <Graphic3d_Group.hxx>
|
||||
#include <Poly_Connect.hxx>
|
||||
#include <Poly_Triangulation.hxx>
|
||||
#include <Prs3d_LineAspect.hxx>
|
||||
|
||||
// =========================================================================
|
||||
// function : AddFreeEdges
|
||||
// purpose :
|
||||
// =========================================================================
|
||||
void Prs3d::AddFreeEdges (TColgp_SequenceOfPnt& theSegments,
|
||||
const Handle(Poly_Triangulation)& thePolyTri,
|
||||
const gp_Trsf& theLocation)
|
||||
{
|
||||
if (thePolyTri.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const TColgp_Array1OfPnt& aNodes = thePolyTri->Nodes();
|
||||
|
||||
// Build the connect tool.
|
||||
Poly_Connect aPolyConnect (thePolyTri);
|
||||
|
||||
Standard_Integer aNbTriangles = thePolyTri->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;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (aNbFree == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TColStd_Array1OfInteger aFree (1, 2 * aNbFree);
|
||||
|
||||
Standard_Integer aFreeIndex = 1;
|
||||
const Poly_Array1OfTriangle& aTriangles = thePolyTri->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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// free edges
|
||||
Standard_Integer aFreeHalfNb = aFree.Length() / 2;
|
||||
for (Standard_Integer anI = 1; anI <= aFreeHalfNb; ++anI)
|
||||
{
|
||||
const gp_Pnt aPoint1 = aNodes (aFree (2 * anI - 1)).Transformed (theLocation);
|
||||
const gp_Pnt aPoint2 = aNodes (aFree (2 * anI )).Transformed (theLocation);
|
||||
theSegments.Append (aPoint1);
|
||||
theSegments.Append (aPoint2);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : MatchSegment
|
||||
@@ -55,44 +123,6 @@ Standard_Boolean Prs3d::MatchSegment
|
||||
return (dist < aDistance);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetDeflection
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Real Prs3d::GetDeflection (const TopoDS_Shape& theShape,
|
||||
const Handle(Prs3d_Drawer)& theDrawer)
|
||||
{
|
||||
if (theDrawer->TypeOfDeflection() != Aspect_TOD_RELATIVE)
|
||||
{
|
||||
return theDrawer->MaximalChordialDeviation();
|
||||
}
|
||||
|
||||
Bnd_Box aBndBox;
|
||||
BRepBndLib::Add (theShape, aBndBox, Standard_False);
|
||||
if (aBndBox.IsVoid())
|
||||
{
|
||||
return theDrawer->MaximalChordialDeviation();
|
||||
}
|
||||
else if (aBndBox.IsOpen())
|
||||
{
|
||||
if (!aBndBox.HasFinitePart())
|
||||
{
|
||||
return theDrawer->MaximalChordialDeviation();
|
||||
}
|
||||
aBndBox = aBndBox.FinitePart();
|
||||
}
|
||||
|
||||
Graphic3d_Vec3d aVecMin, aVecMax;
|
||||
aBndBox.Get (aVecMin.x(), aVecMin.y(), aVecMin.z(), aVecMax.x(), aVecMax.y(), aVecMax.z());
|
||||
const Graphic3d_Vec3d aDiag = aVecMax - aVecMin;
|
||||
const Standard_Real aDeflection = aDiag.maxComp() * theDrawer->DeviationCoefficient() * 4.0;
|
||||
|
||||
// we store computed relative deflection of shape as absolute deviation coefficient
|
||||
// in case relative type to use it later on for sub-shapes.
|
||||
theDrawer->SetMaximalChordialDeviation (aDeflection);
|
||||
return aDeflection;
|
||||
}
|
||||
|
||||
//==================================================================
|
||||
// function: PrimitivesFromPolylines
|
||||
// purpose:
|
||||
@@ -140,7 +170,7 @@ void Prs3d::AddPrimitivesGroup (const Handle(Prs3d_Presentation)& thePrs,
|
||||
thePolylines.Clear();
|
||||
if (!aPrims.IsNull())
|
||||
{
|
||||
Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup (thePrs);
|
||||
Handle(Graphic3d_Group) aGroup = thePrs->NewGroup();
|
||||
aGroup->SetPrimitivesAspect (theAspect->Aspect());
|
||||
aGroup->AddPrimitiveArray (aPrims);
|
||||
}
|
||||
|
@@ -17,15 +17,14 @@
|
||||
#ifndef _Prs3d_HeaderFile
|
||||
#define _Prs3d_HeaderFile
|
||||
|
||||
#include <Bnd_Box.hxx>
|
||||
#include <Graphic3d_ArrayOfPrimitives.hxx>
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
#include <Prs3d_Drawer.hxx>
|
||||
#include <Prs3d_NListOfSequenceOfPnt.hxx>
|
||||
#include <Prs3d_Presentation.hxx>
|
||||
|
||||
class TopoDS_Shape;
|
||||
class Poly_Triangulation;
|
||||
|
||||
//! The Prs3d package provides the following services
|
||||
//! - a presentation object (the context for all
|
||||
@@ -49,20 +48,48 @@ public:
|
||||
//! draws an arrow at a given location, with respect
|
||||
//! to a given direction.
|
||||
Standard_EXPORT static Standard_Boolean MatchSegment (const Standard_Real X, const Standard_Real Y, const Standard_Real Z, const Standard_Real aDistance, const gp_Pnt& p1, const gp_Pnt& p2, Standard_Real& dist);
|
||||
|
||||
//! Computes the absolute deflection value depending on
|
||||
//! the type of deflection in theDrawer:
|
||||
//! <ul>
|
||||
//! <li><b>Aspect_TOD_RELATIVE</b>: the absolute deflection is computed using the relative
|
||||
//! deviation coefficient from theDrawer and the shape's bounding box;</li>
|
||||
//! <li><b>Aspect_TOD_ABSOLUTE</b>: the maximal chordial deviation from theDrawer is returned.</li>
|
||||
//! </ul>
|
||||
//! In case of the type of deflection in theDrawer computed relative deflection for shape
|
||||
//! is stored as absolute deflection. It is necessary to use it later on for sub-shapes.
|
||||
//! This function should always be used to compute the deflection value for building
|
||||
//! discrete representations of the shape (triangualtion, wireframe) to avoid incosistencies
|
||||
//! between different representations of the shape and undesirable visual artifacts.
|
||||
Standard_EXPORT static Standard_Real GetDeflection (const TopoDS_Shape& theShape, const Handle(Prs3d_Drawer)& theDrawer);
|
||||
|
||||
//! Computes the absolute deflection value based on relative deflection Prs3d_Drawer::DeviationCoefficient().
|
||||
//! @param theBndMin [in] bounding box min corner
|
||||
//! @param theBndMax [in] bounding box max corner
|
||||
//! @param theDeviationCoefficient [in] relative deflection coefficient from Prs3d_Drawer::DeviationCoefficient()
|
||||
//! @return absolute deflection coefficient based on bounding box dimensions
|
||||
static Standard_Real GetDeflection (const Graphic3d_Vec3d& theBndMin,
|
||||
const Graphic3d_Vec3d& theBndMax,
|
||||
const Standard_Real theDeviationCoefficient)
|
||||
{
|
||||
const Graphic3d_Vec3d aDiag = theBndMax - theBndMin;
|
||||
return aDiag.maxComp() * theDeviationCoefficient * 4.0;
|
||||
}
|
||||
|
||||
//! Computes the absolute deflection value based on relative deflection Prs3d_Drawer::DeviationCoefficient().
|
||||
//! @param theBndBox [in] bounding box
|
||||
//! @param theDeviationCoefficient [in] relative deflection coefficient from Prs3d_Drawer::DeviationCoefficient()
|
||||
//! @param theMaximalChordialDeviation [in] absolute deflection coefficient from Prs3d_Drawer::MaximalChordialDeviation()
|
||||
//! @return absolute deflection coefficient based on bounding box dimensions or theMaximalChordialDeviation if bounding box is Void or Infinite
|
||||
static Standard_Real GetDeflection (const Bnd_Box& theBndBox,
|
||||
const Standard_Real theDeviationCoefficient,
|
||||
const Standard_Real theMaximalChordialDeviation)
|
||||
{
|
||||
if (theBndBox.IsVoid())
|
||||
{
|
||||
return theMaximalChordialDeviation;
|
||||
}
|
||||
|
||||
Bnd_Box aBndBox = theBndBox;
|
||||
if (theBndBox.IsOpen())
|
||||
{
|
||||
if (!theBndBox.HasFinitePart())
|
||||
{
|
||||
return theMaximalChordialDeviation;
|
||||
}
|
||||
aBndBox = theBndBox.FinitePart();
|
||||
}
|
||||
|
||||
Graphic3d_Vec3d aVecMin, aVecMax;
|
||||
aBndBox.Get (aVecMin.x(), aVecMin.y(), aVecMin.z(), aVecMax.x(), aVecMax.y(), aVecMax.z());
|
||||
return GetDeflection (aVecMin, aVecMax, theDeviationCoefficient);
|
||||
}
|
||||
|
||||
//! Assembles array of primitives for sequence of polylines.
|
||||
//! @param thePoints [in] the polylines sequence
|
||||
@@ -74,6 +101,14 @@ public:
|
||||
const Handle(Prs3d_LineAspect)& theAspect,
|
||||
Prs3d_NListOfSequenceOfPnt& thePolylines);
|
||||
|
||||
//! Add triangulation free edges into sequence of line segments.
|
||||
//! @param theSegments [out] sequence of line segments to fill
|
||||
//! @param thePolyTri [in] triangulation to process
|
||||
//! @param theLocation [in] transformation to apply
|
||||
Standard_EXPORT static void AddFreeEdges (TColgp_SequenceOfPnt& theSegments,
|
||||
const Handle(Poly_Triangulation)& thePolyTri,
|
||||
const gp_Trsf& theLocation);
|
||||
|
||||
};
|
||||
|
||||
#endif // _Prs3d_HeaderFile
|
||||
|
54
src/Prs3d/Prs3d_BndBox.cxx
Normal file
54
src/Prs3d/Prs3d_BndBox.cxx
Normal file
@@ -0,0 +1,54 @@
|
||||
// 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 <Prs3d_BndBox.hxx>
|
||||
|
||||
#include <Prs3d_LineAspect.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void Prs3d_BndBox::Add (const Handle(Prs3d_Presentation)& thePresentation,
|
||||
const Bnd_Box& theBndBox,
|
||||
const Handle(Prs3d_Drawer)& theDrawer)
|
||||
{
|
||||
if (!theBndBox.IsVoid())
|
||||
{
|
||||
Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (thePresentation);
|
||||
aGroup->SetGroupPrimitivesAspect (new Graphic3d_AspectLine3d (theDrawer->LineAspect()->Aspect()->Color(),
|
||||
Aspect_TOL_DOTDASH,
|
||||
theDrawer->LineAspect()->Aspect()->Width()));
|
||||
aGroup->AddPrimitiveArray (FillSegments (theBndBox));
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void Prs3d_BndBox::Add (const Handle(Prs3d_Presentation)& thePresentation,
|
||||
const Bnd_OBB& theBndBox,
|
||||
const Handle(Prs3d_Drawer)& theDrawer)
|
||||
{
|
||||
if (!theBndBox.IsVoid())
|
||||
{
|
||||
Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (thePresentation);
|
||||
aGroup->SetGroupPrimitivesAspect (new Graphic3d_AspectLine3d (theDrawer->LineAspect()->Aspect()->Color(),
|
||||
Aspect_TOL_DOTDASH,
|
||||
theDrawer->LineAspect()->Aspect()->Width()));
|
||||
aGroup->AddPrimitiveArray (FillSegments (theBndBox));
|
||||
}
|
||||
}
|
148
src/Prs3d/Prs3d_BndBox.hxx
Normal file
148
src/Prs3d/Prs3d_BndBox.hxx
Normal file
@@ -0,0 +1,148 @@
|
||||
// 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 _Prs3d_BndBox_H__
|
||||
#define _Prs3d_BndBox_H__
|
||||
|
||||
#include <Bnd_OBB.hxx>
|
||||
#include <Graphic3d_ArrayOfSegments.hxx>
|
||||
#include <Graphic3d_ArrayOfTriangles.hxx>
|
||||
#include <Prs3d_Drawer.hxx>
|
||||
#include <Prs3d_Presentation.hxx>
|
||||
#include <Prs3d_Root.hxx>
|
||||
|
||||
//! Tool for computing bounding box presentation.
|
||||
class Prs3d_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);
|
||||
|
||||
//! 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_OBB& theBndBox,
|
||||
const Handle(Prs3d_Drawer)& theDrawer);
|
||||
|
||||
public:
|
||||
|
||||
//! Create primitive array with line segments for displaying a box.
|
||||
//! @param theBox [in] the box to add
|
||||
static Handle(Graphic3d_ArrayOfSegments) FillSegments (const Bnd_OBB& theBox)
|
||||
{
|
||||
if (theBox.IsVoid())
|
||||
{
|
||||
return Handle(Graphic3d_ArrayOfSegments)();
|
||||
}
|
||||
|
||||
Handle(Graphic3d_ArrayOfSegments) aSegs = new Graphic3d_ArrayOfSegments (8, 12 * 2);
|
||||
FillSegments (aSegs, theBox);
|
||||
return aSegs;
|
||||
}
|
||||
|
||||
//! Create primitive array with line segments for displaying a box.
|
||||
//! @param theBox [in] the box to add
|
||||
static Handle(Graphic3d_ArrayOfSegments) FillSegments (const Bnd_Box& theBox)
|
||||
{
|
||||
if (theBox.IsVoid())
|
||||
{
|
||||
return Handle(Graphic3d_ArrayOfSegments)();
|
||||
}
|
||||
|
||||
Handle(Graphic3d_ArrayOfSegments) aSegs = new Graphic3d_ArrayOfSegments (8, 12 * 2);
|
||||
FillSegments (aSegs, theBox);
|
||||
return aSegs;
|
||||
}
|
||||
|
||||
//! Create primitive array with line segments for displaying a box.
|
||||
//! @param theSegments [in] [out] primitive array to be filled;
|
||||
//! should be at least 8 nodes and 24 edges in size
|
||||
//! @param theBox [in] the box to add
|
||||
static void FillSegments (const Handle(Graphic3d_ArrayOfSegments)& theSegments, const Bnd_OBB& theBox)
|
||||
{
|
||||
if (!theBox.IsVoid())
|
||||
{
|
||||
gp_Pnt aXYZ[8];
|
||||
theBox.GetVertex (aXYZ);
|
||||
fillSegments (theSegments, aXYZ);
|
||||
}
|
||||
}
|
||||
|
||||
//! Create primitive array with line segments for displaying a box.
|
||||
//! @param theSegments [in] [out] primitive array to be filled;
|
||||
//! should be at least 8 nodes and 24 edges in size
|
||||
//! @param theBox [in] the box to add
|
||||
static void FillSegments (const Handle(Graphic3d_ArrayOfSegments)& theSegments, const Bnd_Box& theBox)
|
||||
{
|
||||
if (!theBox.IsVoid())
|
||||
{
|
||||
const gp_Pnt aMin = theBox.CornerMin();
|
||||
const gp_Pnt aMax = theBox.CornerMax();
|
||||
const gp_Pnt aXYZ[8] =
|
||||
{
|
||||
gp_Pnt (aMin.X(), aMin.Y(), aMin.Z()),
|
||||
gp_Pnt (aMax.X(), aMin.Y(), aMin.Z()),
|
||||
gp_Pnt (aMin.X(), aMax.Y(), aMin.Z()),
|
||||
gp_Pnt (aMax.X(), aMax.Y(), aMin.Z()),
|
||||
gp_Pnt (aMin.X(), aMin.Y(), aMax.Z()),
|
||||
gp_Pnt (aMax.X(), aMin.Y(), aMax.Z()),
|
||||
gp_Pnt (aMin.X(), aMax.Y(), aMax.Z()),
|
||||
gp_Pnt (aMax.X(), aMax.Y(), aMax.Z()),
|
||||
};
|
||||
fillSegments (theSegments, aXYZ);
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
//! Create primitive array with line segments for displaying a box.
|
||||
//! @param theSegments [in] [out] primitive array to be filled;
|
||||
//! should be at least 8 nodes and 24 edges in size
|
||||
//! @param theBox [in] the box to add
|
||||
static void fillSegments (const Handle(Graphic3d_ArrayOfSegments)& theSegments, const gp_Pnt* theBox)
|
||||
{
|
||||
const Standard_Integer aFrom = theSegments->VertexNumber();
|
||||
for (int aVertIter = 0; aVertIter < 8; ++aVertIter)
|
||||
{
|
||||
theSegments->AddVertex (theBox[aVertIter]);
|
||||
}
|
||||
|
||||
theSegments->AddEdges (aFrom + 1, aFrom + 2);
|
||||
theSegments->AddEdges (aFrom + 3, aFrom + 4);
|
||||
theSegments->AddEdges (aFrom + 5, aFrom + 6);
|
||||
theSegments->AddEdges (aFrom + 7, aFrom + 8);
|
||||
//
|
||||
theSegments->AddEdges (aFrom + 1, aFrom + 3);
|
||||
theSegments->AddEdges (aFrom + 2, aFrom + 4);
|
||||
theSegments->AddEdges (aFrom + 5, aFrom + 7);
|
||||
theSegments->AddEdges (aFrom + 6, aFrom + 8);
|
||||
//
|
||||
theSegments->AddEdges (aFrom + 1, aFrom + 5);
|
||||
theSegments->AddEdges (aFrom + 2, aFrom + 6);
|
||||
theSegments->AddEdges (aFrom + 3, aFrom + 7);
|
||||
theSegments->AddEdges (aFrom + 4, aFrom + 8);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // _Prs3d_BndBox_H__
|
@@ -1,349 +0,0 @@
|
||||
// Created on: 1995-08-07
|
||||
// Created by: Modelistation
|
||||
// Copyright (c) 1995-1999 Matra Datavision
|
||||
// Copyright (c) 1999-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 <Bnd_Box.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <BRepAdaptor_Curve.hxx>
|
||||
#include <BRepAdaptor_Surface.hxx>
|
||||
#include <BRepBndLib.hxx>
|
||||
#include <BRepTools.hxx>
|
||||
#include <Geom_Plane.hxx>
|
||||
#include <Geom_RectangularTrimmedSurface.hxx>
|
||||
#include <Geom_Surface.hxx>
|
||||
#include <Poly_Polygon3D.hxx>
|
||||
#include <Poly_PolygonOnTriangulation.hxx>
|
||||
#include <Poly_Triangulation.hxx>
|
||||
#include <Prs3d_ShapeTool.hxx>
|
||||
#include <TopExp.hxx>
|
||||
#include <TopLoc_Location.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Face.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
||||
#include <TopTools_ListOfShape.hxx>
|
||||
#include <TopTools_MapOfShape.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : Prs3d_ShapeTool
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Prs3d_ShapeTool::Prs3d_ShapeTool (const TopoDS_Shape& theShape,
|
||||
const Standard_Boolean theAllVertices)
|
||||
: myShape (theShape)
|
||||
{
|
||||
myEdgeMap.Clear();
|
||||
myVertexMap.Clear();
|
||||
TopExp::MapShapesAndAncestors (theShape,TopAbs_EDGE,TopAbs_FACE, myEdgeMap);
|
||||
|
||||
TopExp_Explorer anExpl;
|
||||
if (theAllVertices)
|
||||
{
|
||||
for (anExpl.Init (theShape, TopAbs_VERTEX); anExpl.More(); anExpl.Next())
|
||||
{
|
||||
myVertexMap.Add (anExpl.Current());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Extracting isolated vertices
|
||||
for (anExpl.Init (theShape, TopAbs_VERTEX, TopAbs_EDGE); anExpl.More(); anExpl.Next())
|
||||
{
|
||||
myVertexMap.Add (anExpl.Current());
|
||||
}
|
||||
|
||||
// Extracting internal vertices
|
||||
for (anExpl.Init (theShape, TopAbs_EDGE); anExpl.More(); anExpl.Next())
|
||||
{
|
||||
TopoDS_Iterator aIt (anExpl.Current(), Standard_False, Standard_True);
|
||||
for (; aIt.More(); aIt.Next())
|
||||
{
|
||||
const TopoDS_Shape& aV = aIt.Value();
|
||||
if (aV.Orientation() == TopAbs_INTERNAL)
|
||||
{
|
||||
myVertexMap.Add (aV);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : InitFace
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Prs3d_ShapeTool::InitFace()
|
||||
{
|
||||
myFaceExplorer.Init(myShape,TopAbs_FACE);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : MoreFace
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean Prs3d_ShapeTool::MoreFace() const
|
||||
{
|
||||
return myFaceExplorer.More();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NextFace
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Prs3d_ShapeTool::NextFace()
|
||||
{
|
||||
myFaceExplorer.Next();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetFace
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const TopoDS_Face& Prs3d_ShapeTool::GetFace () const
|
||||
{
|
||||
return TopoDS::Face(myFaceExplorer.Current());
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : FaceBound
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Bnd_Box Prs3d_ShapeTool::FaceBound() const
|
||||
{
|
||||
const TopoDS_Face& F = TopoDS::Face(myFaceExplorer.Current());
|
||||
Bnd_Box B;
|
||||
BRepBndLib::Add(F, B);
|
||||
return B;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsPlanarFace
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean Prs3d_ShapeTool::IsPlanarFace (const TopoDS_Face& theFace)
|
||||
{
|
||||
TopLoc_Location l;
|
||||
const Handle(Geom_Surface)& S = BRep_Tool::Surface(theFace, l);
|
||||
if (S.IsNull())
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
Handle(Standard_Type) TheType = S->DynamicType();
|
||||
|
||||
if (TheType == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
|
||||
Handle(Geom_RectangularTrimmedSurface)
|
||||
RTS = Handle(Geom_RectangularTrimmedSurface)::DownCast (S);
|
||||
TheType = RTS->BasisSurface()->DynamicType();
|
||||
}
|
||||
return (TheType == STANDARD_TYPE(Geom_Plane));
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : InitCurve
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Prs3d_ShapeTool::InitCurve()
|
||||
{
|
||||
myEdge = 1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : MoreCurve
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean Prs3d_ShapeTool::MoreCurve() const
|
||||
{
|
||||
return myEdge <= myEdgeMap.Extent();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NextCurve
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Prs3d_ShapeTool::NextCurve()
|
||||
{
|
||||
myEdge++;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetCurve
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const TopoDS_Edge& Prs3d_ShapeTool::GetCurve () const
|
||||
{
|
||||
return TopoDS::Edge(myEdgeMap.FindKey(myEdge));
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : CurveBound
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Bnd_Box Prs3d_ShapeTool::CurveBound () const
|
||||
{
|
||||
const TopoDS_Edge& E = TopoDS::Edge(myEdgeMap.FindKey(myEdge));
|
||||
Bnd_Box B;
|
||||
BRepBndLib::Add(E, B);
|
||||
return B;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Neighbours
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer Prs3d_ShapeTool::Neighbours () const
|
||||
{
|
||||
const TopTools_ListOfShape& L = myEdgeMap.FindFromIndex(myEdge);
|
||||
return L.Extent();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : FacesOfEdge
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(TopTools_HSequenceOfShape) Prs3d_ShapeTool::FacesOfEdge () const
|
||||
{
|
||||
Handle(TopTools_HSequenceOfShape) H = new TopTools_HSequenceOfShape;
|
||||
|
||||
const TopTools_ListOfShape& L = myEdgeMap.FindFromIndex(myEdge);
|
||||
TopTools_ListIteratorOfListOfShape LI;
|
||||
|
||||
for (LI.Initialize(L); LI.More(); LI.Next()) H->Append(LI.Value());
|
||||
return H;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : InitVertex
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Prs3d_ShapeTool::InitVertex()
|
||||
{
|
||||
myVertex = 1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : MoreVertex
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean Prs3d_ShapeTool::MoreVertex() const
|
||||
{
|
||||
return myVertex <= myVertexMap.Extent();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NextVertex
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Prs3d_ShapeTool::NextVertex()
|
||||
{
|
||||
myVertex++;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetVertex
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const TopoDS_Vertex& Prs3d_ShapeTool::GetVertex () const
|
||||
{
|
||||
return TopoDS::Vertex(myVertexMap.FindKey(myVertex));
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : HasSurface
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean Prs3d_ShapeTool::HasSurface() const
|
||||
{
|
||||
TopLoc_Location l;
|
||||
const Handle(Geom_Surface)& S = BRep_Tool::Surface(GetFace(), l);
|
||||
return (!S.IsNull());
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : CurrentTriangulation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Poly_Triangulation) Prs3d_ShapeTool::CurrentTriangulation(TopLoc_Location& l) const
|
||||
{
|
||||
return BRep_Tool::Triangulation(GetFace(), l);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : HasCurve
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean Prs3d_ShapeTool::HasCurve() const
|
||||
{
|
||||
return (BRep_Tool::IsGeometric(GetCurve()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : PolygonOnTriangulation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Prs3d_ShapeTool::PolygonOnTriangulation
|
||||
(Handle(Poly_PolygonOnTriangulation)& Indices,
|
||||
Handle(Poly_Triangulation)& T,
|
||||
TopLoc_Location& l) const
|
||||
{
|
||||
BRep_Tool::PolygonOnTriangulation(GetCurve(), Indices, T, l);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Polygon3D
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Poly_Polygon3D) Prs3d_ShapeTool::Polygon3D(TopLoc_Location& l) const
|
||||
{
|
||||
return BRep_Tool::Polygon3D(GetCurve(), l);
|
||||
}
|
@@ -17,95 +17,9 @@
|
||||
#ifndef _Prs3d_ShapeTool_HeaderFile
|
||||
#define _Prs3d_ShapeTool_HeaderFile
|
||||
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Face.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
|
||||
#include <TopTools_IndexedMapOfShape.hxx>
|
||||
#include <TopTools_HSequenceOfShape.hxx>
|
||||
#include <StdPrs_ShapeTool.hxx>
|
||||
|
||||
class Bnd_Box;
|
||||
class TopoDS_Edge;
|
||||
class TopoDS_Vertex;
|
||||
class Poly_Triangulation;
|
||||
class Poly_PolygonOnTriangulation;
|
||||
class Poly_Polygon3D;
|
||||
|
||||
//! describes the behaviour requested for a wireframe
|
||||
//! shape presentation.
|
||||
class Prs3d_ShapeTool
|
||||
{
|
||||
public:
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
//! Constructs the tool and initializes it using theShape and theAllVertices
|
||||
//! (optional) arguments. By default, only isolated and internal vertices are considered,
|
||||
//! however if theAllVertices argument is equal to True, all shape's vertices are taken into account.
|
||||
Standard_EXPORT Prs3d_ShapeTool(const TopoDS_Shape& theShape, const Standard_Boolean theAllVertices = Standard_False);
|
||||
|
||||
Standard_EXPORT void InitFace();
|
||||
|
||||
Standard_EXPORT Standard_Boolean MoreFace() const;
|
||||
|
||||
Standard_EXPORT void NextFace();
|
||||
|
||||
Standard_EXPORT const TopoDS_Face& GetFace() const;
|
||||
|
||||
Standard_EXPORT Bnd_Box FaceBound() const;
|
||||
|
||||
Standard_Boolean IsPlanarFace() const
|
||||
{
|
||||
const TopoDS_Face& aFace = TopoDS::Face (myFaceExplorer.Current());
|
||||
return IsPlanarFace (aFace);
|
||||
}
|
||||
|
||||
Standard_EXPORT void InitCurve();
|
||||
|
||||
Standard_EXPORT Standard_Boolean MoreCurve() const;
|
||||
|
||||
Standard_EXPORT void NextCurve();
|
||||
|
||||
Standard_EXPORT const TopoDS_Edge& GetCurve() const;
|
||||
|
||||
Standard_EXPORT Bnd_Box CurveBound() const;
|
||||
|
||||
Standard_EXPORT Standard_Integer Neighbours() const;
|
||||
|
||||
Standard_EXPORT Handle(TopTools_HSequenceOfShape) FacesOfEdge() const;
|
||||
|
||||
Standard_EXPORT void InitVertex();
|
||||
|
||||
Standard_EXPORT Standard_Boolean MoreVertex() const;
|
||||
|
||||
Standard_EXPORT void NextVertex();
|
||||
|
||||
Standard_EXPORT const TopoDS_Vertex& GetVertex() const;
|
||||
|
||||
Standard_EXPORT Standard_Boolean HasSurface() const;
|
||||
|
||||
Standard_EXPORT Handle(Poly_Triangulation) CurrentTriangulation (TopLoc_Location& l) const;
|
||||
|
||||
Standard_EXPORT Standard_Boolean HasCurve() const;
|
||||
|
||||
Standard_EXPORT void PolygonOnTriangulation (Handle(Poly_PolygonOnTriangulation)& Indices, Handle(Poly_Triangulation)& T, TopLoc_Location& l) const;
|
||||
|
||||
Standard_EXPORT Handle(Poly_Polygon3D) Polygon3D (TopLoc_Location& l) const;
|
||||
|
||||
public:
|
||||
|
||||
Standard_EXPORT static Standard_Boolean IsPlanarFace (const TopoDS_Face& theFace);
|
||||
|
||||
private:
|
||||
|
||||
TopoDS_Shape myShape;
|
||||
TopExp_Explorer myFaceExplorer;
|
||||
TopTools_IndexedDataMapOfShapeListOfShape myEdgeMap;
|
||||
TopTools_IndexedMapOfShape myVertexMap;
|
||||
Standard_Integer myEdge;
|
||||
Standard_Integer myVertex;
|
||||
|
||||
};
|
||||
Standard_DEPRECATED("Alias to moved class StdPrs_ShapeTool")
|
||||
typedef StdPrs_ShapeTool Prs3d_ShapeTool;
|
||||
|
||||
#endif // _Prs3d_ShapeTool_HeaderFile
|
||||
|
@@ -16,7 +16,6 @@
|
||||
#ifndef _Prs3d_ToolCylinder_HeaderFile
|
||||
#define _Prs3d_ToolCylinder_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Prs3d_ToolQuadric.hxx>
|
||||
|
||||
//! Standard presentation algorithm that outputs graphical primitives for cylindrical surface.
|
||||
|
@@ -16,7 +16,6 @@
|
||||
#ifndef _Prs3d_ToolDisk_HeaderFile
|
||||
#define _Prs3d_ToolDisk_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Prs3d_ToolQuadric.hxx>
|
||||
|
||||
//! Standard presentation algorithm that outputs graphical primitives for disk surface.
|
||||
|
@@ -16,14 +16,8 @@
|
||||
#ifndef _Prs3d_ToolQuadric_HeaderFile
|
||||
#define _Prs3d_ToolQuadric_HeaderFile
|
||||
|
||||
#include <gp_Ax1.hxx>
|
||||
#include <Graphic3d_ArrayOfPrimitives.hxx>
|
||||
#include <Graphic3d_ArrayOfTriangles.hxx>
|
||||
#include <Poly_Triangulation.hxx>
|
||||
#include <Prs3d_Root.hxx>
|
||||
#include <Prs3d_Drawer.hxx>
|
||||
#include <SelectMgr_Selection.hxx>
|
||||
#include <Standard.hxx>
|
||||
|
||||
//! Base class to build 3D surfaces presentation of quadric surfaces.
|
||||
class Prs3d_ToolQuadric
|
||||
|
@@ -16,7 +16,6 @@
|
||||
#ifndef _Prs3d_ToolSector_HeaderFile
|
||||
#define _Prs3d_ToolSector_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Prs3d_ToolQuadric.hxx>
|
||||
|
||||
//! Standard presentation algorithm that outputs graphical primitives for disk surface.
|
||||
|
@@ -16,14 +16,6 @@
|
||||
#ifndef _Prs3d_ToolSphere_HeaderFile
|
||||
#define _Prs3d_ToolSphere_HeaderFile
|
||||
|
||||
#include <Graphic3d_ArrayOfPrimitives.hxx>
|
||||
#include <Graphic3d_ArrayOfTriangles.hxx>
|
||||
#include <Poly_Triangulation.hxx>
|
||||
#include <Prs3d_Root.hxx>
|
||||
#include <Prs3d_Drawer.hxx>
|
||||
#include <SelectMgr_Selection.hxx>
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
#include <Prs3d_ToolQuadric.hxx>
|
||||
|
||||
//! Standard presentation algorithm that outputs graphical primitives for spherical surface.
|
||||
|
Reference in New Issue
Block a user