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.
n SelectMgr
n StdPrs
n StdSelect
-n TColQuantity
n V3d
n WNT
n Xw
Enumeration BRepOffset_Type is renamed to ChFiDS_TypeOfConcavity.
+@subsection upgrade_750_tkv3d TKV3d/TKService toolkits changes
+
+The following changes could be highlighted while porting:
+* *Prs3d::GetDeflection()* has been moved to *StdPrs_ToolTriangulatedShape::GetDeflection()*.
+* *Prs3d_ShapeTool* has been moved to *StdPrs_ShapeTool*.
+* *StdSelect_ViewerSelector3d* has been moved to *SelectMgr_ViewerSelector3d*.
+* *Font_BRepFont* has been moved to *StdPrs_BRepFont*.
+* Visualization classes now use *TopLoc_Datum3D* (from *TKMath*) instead of *Geom_Transformation* (from *TKG3d*) as smart pointer to *gp_Trsf*.
+ This is rather an internal change, but some applications might need to be updated.
+
@subsection upgrade_750_hlrangle Prs3d_Drawer deviation angle
Properties Prs3d_Drawer::HLRAngle() and Prs3d_Drawer::HLRDeviationCoefficient() have been removed from classes *Prs3d_Drawer*, *AIS_Shape* and *AIS_InteractiveContext*.
#include <Message.hxx>
#include <Message_Messenger.hxx>
#include <OpenGl_GraphicDriver.hxx>
-#include <Prs3d.hxx>
+#include <StdPrs_ToolTriangulatedShape.hxx>
#include <Prs3d_Drawer.hxx>
#include <STEPControl_Reader.hxx>
#include <STEPCAFControl_Reader.hxx>
}
Handle(Prs3d_Drawer) aDrawer = myContext->DefaultDrawer();
- Standard_Real aDeflection = Prs3d::GetDeflection (aCompound, aDrawer);
+ Standard_Real aDeflection = StdPrs_ToolTriangulatedShape::GetDeflection (aCompound, aDrawer);
if (!BRepTools::Triangulation (aCompound, aDeflection))
{
BRepMesh_IncrementalMesh anAlgo;
#include <GProp_PGProps.hxx>
#include <Quantity_Color.hxx>
#include <BRepMesh_IncrementalMesh.hxx>
-#include <Prs3d.hxx>
+#include <StdPrs_ToolTriangulatedShape.hxx>
#include <AIS_GraphicTool.hxx>
mygroup->SetPrimitivesAspect(myAspect);
myAspect->SetEdgeOn();
- myDeflection = Prs3d::GetDeflection(myShape,myDrawer);
+ myDeflection = StdPrs_ToolTriangulatedShape::GetDeflection(myShape,myDrawer);
BRepMesh_IncrementalMesh(myShape,myDeflection);
myX1OnOff = Standard_False;
}
void User_Cylinder::computeHLR (const Handle(Graphic3d_Camera)& aProjector,
- const Handle(Geom_Transformation)& ,
+ const Handle(TopLoc_Datum3D)& ,
const Handle(Prs3d_Presentation)& aPresentation)
{
Handle (Prs3d_Drawer) aDefDrawer = GetContext()->DefaultDrawer();
const Standard_Integer aMode = 0) ;
void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
const Standard_Integer aMode) ;
- void computeHLR (const Handle(Graphic3d_Camera)& aProjector, const Handle(Geom_Transformation)& theTrsf, const Handle(Prs3d_Presentation)& aPresentation);
+ void computeHLR (const Handle(Graphic3d_Camera)& aProjector, const Handle(TopLoc_Datum3D)& theTrsf, const Handle(Prs3d_Presentation)& aPresentation);
Standard_Boolean TriangleIsValid(const gp_Pnt& P1,const gp_Pnt& P2,const gp_Pnt& P3) const;
Quantity_Color Color(gp_Pnt& thePoint,Standard_Real AltMin,Standard_Real AltMax, const Standard_Integer ColorizationMode) ;
#include <Geom_Axis1Placement.hxx>
#include <Geom_Axis2Placement.hxx>
#include <Geom_Line.hxx>
-#include <Geom_Transformation.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <gp_Ax1.hxx>
#include <gp_Ax2.hxx>
#include <Aspect_TypeOfLine.hxx>
#include <GC_MakeArcOfCircle.hxx>
#include <Geom_Circle.hxx>
-#include <Geom_Transformation.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_Structure.hxx>
{
Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this);
Handle(Select3D_SensitiveCircle) seg = new Select3D_SensitiveCircle (eown,
- myComponent,
+ myComponent->Circ(),
myIsFilledCircleSens);
aSelection->Add(seg);
}
Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this);
Handle(Select3D_SensitiveCircle) seg = new Select3D_SensitiveCircle (eown,
- myComponent,
+ myComponent->Circ(),
myUStart, myUEnd,
myIsFilledCircleSens);
aSelection->Add(seg);
// After this call if type of deflection is relative
// computed deflection coefficient is stored as absolute.
- Prs3d::GetDeflection (myshape, myDrawer);
+ StdPrs_ToolTriangulatedShape::GetDeflection (myshape, myDrawer);
break;
}
case AIS_Shaded:
}
const TopAbs_ShapeEnum aTypOfSel = AIS_Shape::SelectionType (theMode);
- const Standard_Real aDeflection = Prs3d::GetDeflection (myshape, myDrawer);
+ const Standard_Real aDeflection = StdPrs_ToolTriangulatedShape::GetDeflection (myshape, myDrawer);
const Standard_Real aDeviationAngle = myDrawer->DeviationAngle();
const Standard_Integer aPriority = StdSelect_BRepSelectionTool::GetStandardPriority (myshape, aTypOfSel);
if (myDrawer->IsAutoTriangulation()
//purpose :
//=======================================================================
void AIS_ConnectedInteractive::connect (const Handle(AIS_InteractiveObject)& theAnotherObj,
- const Handle(Geom_Transformation)& theLocation)
+ const Handle(TopLoc_Datum3D)& theLocation)
{
if (myReference == theAnotherObj)
{
//purpose :
//=======================================================================
void AIS_ConnectedInteractive::computeHLR (const Handle(Graphic3d_Camera)& theProjector,
- const Handle(Geom_Transformation)& theTransformation,
+ const Handle(TopLoc_Datum3D)& theTransformation,
const Handle(Prs3d_Presentation)& thePresentation)
{
const bool hasTrsf = !theTransformation.IsNull()
//! Establishes the connection between the Connected
//! Interactive Object, anotherIobj, and its reference.
- void Connect (const Handle(AIS_InteractiveObject)& theAnotherObj) { connect (theAnotherObj, Handle(Geom_Transformation)()); }
+ void Connect (const Handle(AIS_InteractiveObject)& theAnotherObj) { connect (theAnotherObj, Handle(TopLoc_Datum3D)()); }
//! Establishes the connection between the Connected
//! Interactive Object, anotherIobj, and its reference.
//! Locates instance in aLocation.
void Connect (const Handle(AIS_InteractiveObject)& theAnotherObj,
- const gp_Trsf& theLocation) { connect (theAnotherObj, new Geom_Transformation (theLocation)); }
+ const gp_Trsf& theLocation) { connect (theAnotherObj, new TopLoc_Datum3D (theLocation)); }
//! Establishes the connection between the Connected
//! Interactive Object, anotherIobj, and its reference.
//! Locates instance in aLocation.
void Connect (const Handle(AIS_InteractiveObject)& theAnotherObj,
- const Handle(Geom_Transformation)& theLocation) { connect (theAnotherObj, theLocation); }
+ const Handle(TopLoc_Datum3D)& theLocation) { connect (theAnotherObj, theLocation); }
//! Returns true if there is a connection established
//! between the presentation and its source reference.
//! Computes the presentation according to a point of view.
Standard_EXPORT virtual void computeHLR (const Handle(Graphic3d_Camera)& theProjector,
- const Handle(Geom_Transformation)& theTrsf,
+ const Handle(TopLoc_Datum3D)& theTrsf,
const Handle(Prs3d_Presentation)& thePrs) Standard_OVERRIDE;
//! Generates sensitive entities by copying
Standard_EXPORT void updateShape (const Standard_Boolean WithLocation = Standard_True);
Standard_EXPORT void connect (const Handle(AIS_InteractiveObject)& theAnotherObj,
- const Handle(Geom_Transformation)& theLocation);
+ const Handle(TopLoc_Datum3D)& theLocation);
protected:
#include <GC_MakeSegment.hxx>
#include <Geom_Line.hxx>
#include <Geom_Point.hxx>
-#include <Geom_Transformation.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_Structure.hxx>
#include <AIS_ManipulatorOwner.hxx>
#include <Extrema_ExtElC.hxx>
#include <gce_MakeDir.hxx>
-#include <Geom_Circle.hxx>
-#include <Geom_Transformation.hxx>
#include <IntAna_IntConicQuad.hxx>
#include <Prs3d_Arrow.hxx>
#include <Prs3d_Root.hxx>
public:
//! Main constructor.
ManipSensCircle (const Handle(SelectMgr_EntityOwner)& theOwnerId,
- const Handle(Geom_Circle)& theCircle,
+ const gp_Circ& theCircle,
const Standard_Integer theNbPnts)
: Select3D_SensitiveCircle (theOwnerId, theCircle, Standard_False, theNbPnts),
- ManipSensRotation (theCircle->Position().Direction()) {}
+ ManipSensRotation (theCircle.Position().Direction()) {}
//! Checks whether the circle overlaps current selecting volume
virtual Standard_Boolean Matches (SelectBasics_SelectingVolumeManager& theMgr,
{
const Handle(AIS_InteractiveObject)& anObj = anObjIter.ChangeValue();
const gp_Trsf& anOldTrsf = aTrsfIter.Value();
- const Handle(Geom_Transformation)& aParentTrsf = anObj->CombinedParentTransformation();
+ const Handle(TopLoc_Datum3D)& aParentTrsf = anObj->CombinedParentTransformation();
if (!aParentTrsf.IsNull()
&& aParentTrsf->Form() != gp_Identity)
{
aTrsf.SetTransformation (gp_Ax2 (gp::Origin(), aVDir, aXDir), gp::XOY());
}
- Handle(Geom_Transformation) aGeomTrsf = new Geom_Transformation (aTrsf);
+ Handle(TopLoc_Datum3D) aGeomTrsf = new TopLoc_Datum3D (aTrsf);
// we explicitly call here setLocalTransformation() of the base class
// since AIS_Manipulator::setLocalTransformation() implementation throws exception
// as protection from external calls
//function : setLocalTransformation
//purpose :
//=======================================================================
-void AIS_Manipulator::setLocalTransformation (const Handle(Geom_Transformation)& /*theTrsf*/)
+void AIS_Manipulator::setLocalTransformation (const Handle(TopLoc_Datum3D)& /*theTrsf*/)
{
Standard_ASSERT_INVOKE ("AIS_Manipulator::setLocalTransformation: "
"Custom transformation is not supported by this class");
anOwner = new AIS_ManipulatorOwner (this, anIt, AIS_MM_Rotation, 9);
}
// define sensitivity by circle
- Handle(Geom_Circle) aGeomCircle = new Geom_Circle (gp_Ax2 (gp::Origin(), anAxis.ReferenceAxis().Direction()), anAxis.RotatorDiskRadius());
+ const gp_Circ aGeomCircle (gp_Ax2 (gp::Origin(), anAxis.ReferenceAxis().Direction()), anAxis.RotatorDiskRadius());
Handle(Select3D_SensitiveCircle) aCircle = new ManipSensCircle (anOwner, aGeomCircle, anAxis.FacettesNumber());
aCircle->SetSensitivityFactor (15);
theSelection->Add (aCircle);
//! without need for recomputing presentation.
//! @warning Invokes debug assertion in debug to catch incompatible usage of the
//! method, silently does nothing in release mode.
- Standard_EXPORT virtual void setLocalTransformation (const Handle(Geom_Transformation)& theTrsf) Standard_OVERRIDE;
+ Standard_EXPORT virtual void setLocalTransformation (const Handle(TopLoc_Datum3D)& theTrsf) Standard_OVERRIDE;
using AIS_InteractiveObject::SetLocalTransformation; // hide visibility
protected: //! @name Auxiliary classes to fill presentation with proper primitives
}
}
- void Transform (const Handle(Geom_Transformation)& theTransformation)
+ void Transform (const Handle(TopLoc_Datum3D)& theTransformation)
{
if (!myHighlightTranslator.IsNull())
{
//purpose :
//=======================================================================
Handle(AIS_InteractiveObject) AIS_MultipleConnectedInteractive::connect (const Handle(AIS_InteractiveObject)& theAnotherObj,
- const Handle(Geom_Transformation)& theTrsf,
+ const Handle(TopLoc_Datum3D)& theTrsf,
const Handle(Graphic3d_TransformPers)& theTrsfPers)
{
if (myAssemblyOwner.IsNull())
//! Locates instance in theLocation and applies specified transformation persistence mode.
//! @return created instance object (AIS_ConnectedInteractive or AIS_MultipleConnectedInteractive)
Handle(AIS_InteractiveObject) Connect (const Handle(AIS_InteractiveObject)& theAnotherObj,
- const Handle(Geom_Transformation)& theLocation,
+ const Handle(TopLoc_Datum3D)& theLocation,
const Handle(Graphic3d_TransformPers)& theTrsfPers)
{
return connect (theAnotherObj, theLocation, theTrsfPers);
Handle(AIS_InteractiveObject) Connect (const Handle(AIS_InteractiveObject)& theAnotherObj,
const gp_Trsf& theLocation)
{
- return connect (theAnotherObj, new Geom_Transformation (theLocation), theAnotherObj->TransformPersistence());
+ return connect (theAnotherObj, new TopLoc_Datum3D (theLocation), theAnotherObj->TransformPersistence());
}
//! Establishes the connection between the Connected Interactive Object, theInteractive, and its reference.
const gp_Trsf& theLocation,
const Handle(Graphic3d_TransformPers)& theTrsfPers)
{
- return connect (theAnotherObj, new Geom_Transformation (theLocation), theTrsfPers);
+ return connect (theAnotherObj, new TopLoc_Datum3D (theLocation), theTrsfPers);
}
Standard_DEPRECATED("This method is deprecated - Connect() taking Graphic3d_TransformPers should be called instead")
const Graphic3d_TransModeFlags& theTrsfPersFlag,
const gp_Pnt& theTrsfPersPoint)
{
- return connect (theInteractive, new Geom_Transformation (theLocation), Graphic3d_TransformPers::FromDeprecatedParams (theTrsfPersFlag, theTrsfPersPoint));
+ return connect (theInteractive, new TopLoc_Datum3D (theLocation), Graphic3d_TransformPers::FromDeprecatedParams (theTrsfPersFlag, theTrsfPersPoint));
}
protected:
//! Locates instance in theLocation and applies specified transformation persistence mode.
//! @return created instance object (AIS_ConnectedInteractive or AIS_MultipleConnectedInteractive)
Standard_EXPORT virtual Handle(AIS_InteractiveObject) connect (const Handle(AIS_InteractiveObject)& theInteractive,
- const Handle(Geom_Transformation)& theLocation,
+ const Handle(TopLoc_Datum3D)& theLocation,
const Handle(Graphic3d_TransformPers)& theTrsfPers);
private:
#include <ElSLib.hxx>
#include <Geom_Axis2Placement.hxx>
#include <Geom_Plane.hxx>
-#include <Geom_Transformation.hxx>
#include <GeomAdaptor_Surface.hxx>
#include <gp_Pnt.hxx>
#include <Graphic3d_ArrayOfQuadrangles.hxx>
#include <Geom_CartesianPoint.hxx>
#include <Geom_Line.hxx>
#include <Geom_Plane.hxx>
-#include <Geom_Transformation.hxx>
#include <gp_Ax2.hxx>
#include <gp_Pln.hxx>
#include <gp_Pnt.hxx>
#include <Aspect_TypeOfLine.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>
#include <Geom_Point.hxx>
-#include <Geom_Transformation.hxx>
#include <Graphic3d_ArrayOfPoints.hxx>
#include <Graphic3d_AspectMarker3d.hxx>
#include <Graphic3d_Group.hxx>
#include <Select3D_SensitivePrimitiveArray.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <SelectMgr_Selection.hxx>
-#include <StdPrs_BndBox.hxx>
+#include <Prs3d_BndBox.hxx>
IMPLEMENT_STANDARD_RTTIEXT(AIS_PointCloudOwner, SelectMgr_EntityOwner)
IMPLEMENT_STANDARD_RTTIEXT(AIS_PointCloud, AIS_InteractiveObject)
return;
}
- StdPrs_BndBox::Add (thePrs, aBndBox, myDrawer);
+ Prs3d_BndBox::Add (thePrs, aBndBox, myDrawer);
break;
}
}
#include <BRepBndLib.hxx>
#include <BRepTools.hxx>
#include <BRepTools_ShapeSet.hxx>
-#include <Geom_Transformation.hxx>
#include <gp_Pnt.hxx>
#include <Graphic3d_ArrayOfPolylines.hxx>
#include <Graphic3d_AspectFillArea3d.hxx>
#include <Prs3d_Presentation.hxx>
#include <Prs3d_Root.hxx>
#include <Prs3d_ShadingAspect.hxx>
-#include <StdPrs_BndBox.hxx>
+#include <Prs3d_BndBox.hxx>
#include <StdPrs_ToolTriangulatedShape.hxx>
#include <Quantity_Color.hxx>
#include <Select3D_SensitiveBox.hxx>
#include <StdSelect.hxx>
#include <StdSelect_BRepOwner.hxx>
#include <StdSelect_BRepSelectionTool.hxx>
-#include <StdSelect_DisplayMode.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
#include <TopExp.hxx>
}
else
{
- StdPrs_BndBox::Add (aPrs, BoundingBox(), myDrawer);
+ Prs3d_BndBox::Add (aPrs, BoundingBox(), myDrawer);
}
}
}
// POP protection against crash in low layers
- Standard_Real aDeflection = Prs3d::GetDeflection(shape, myDrawer);
+ Standard_Real aDeflection = StdPrs_ToolTriangulatedShape::GetDeflection(shape, myDrawer);
try
{
OCC_CATCH_SIGNALS
//! Compute projected presentation.
virtual void computeHLR (const Handle(Graphic3d_Camera)& theProjector,
- const Handle(Geom_Transformation)& theTrsf,
+ const Handle(TopLoc_Datum3D)& theTrsf,
const Handle(Prs3d_Presentation)& thePrs) Standard_OVERRIDE
{
if (!theTrsf.IsNull()
#include <Prs3d_ShadingAspect.hxx>
#include <PrsMgr_PresentationManager3d.hxx>
#include <Standard_ErrorHandler.hxx>
-#include <StdPrs_BndBox.hxx>
+#include <Prs3d_BndBox.hxx>
#include <StdPrs_ShadedShape.hxx>
#include <StdPrs_ToolTriangulatedShape.hxx>
#include <StdPrs_WFShape.hxx>
}
else
{
- StdPrs_BndBox::Add (thePrs, BoundingBox(), myDrawer);
+ Prs3d_BndBox::Add (thePrs, BoundingBox(), myDrawer);
}
break;
}
#include <AIS_InteractiveContext.hxx>
#include <AIS_TrihedronOwner.hxx>
#include <Geom_Axis2Placement.hxx>
-#include <Geom_Transformation.hxx>
#include <gp_Pnt.hxx>
#include <Graphic3d_ArrayOfPoints.hxx>
#include <Graphic3d_ArrayOfSegments.hxx>
#include <Quantity_Color.hxx>
class Geom_Axis2Placement;
-class AIS_Axis;
-class AIS_Point;
-class AIS_Plane;
-class Geom_Transformation;
-class gp_Trsf;
//! Create a selectable trihedron
//! The trihedron includes 1 origin, 3 axes and 3 labels.
-Font_BRepFont.cxx
Font_BRepFont.hxx
-Font_BRepTextBuilder.cxx
Font_BRepTextBuilder.hxx
Font_FontAspect.hxx
Font_FontMgr.cxx
+++ /dev/null
-// Created on: 2013-09-16
-// 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 <Font_BRepFont.hxx>
-
-#include <BRep_Tool.hxx>
-#include <BRepTopAdaptor_FClass2d.hxx>
-#include <BRepBuilderAPI_MakeFace.hxx>
-#include <BRepBuilderAPI_MakeWire.hxx>
-#include <BRepLib_MakeEdge.hxx>
-#include <Font_FTLibrary.hxx>
-#include <Font_FontMgr.hxx>
-#include <Font_TextFormatter.hxx>
-#include <GCE2d_MakeSegment.hxx>
-#include <GC_MakeSegment.hxx>
-#include <Geom_BezierCurve.hxx>
-#include <Geom_BSplineCurve.hxx>
-#include <Geom2d_TrimmedCurve.hxx>
-#include <Geom_Plane.hxx>
-#include <Geom2d_BezierCurve.hxx>
-#include <Geom2d_BSplineCurve.hxx>
-#include <Geom2d_TrimmedCurve.hxx>
-#include <Geom2d_Line.hxx>
-#include <GeomAPI.hxx>
-#include <GeomAdaptor_HSurface.hxx>
-#include <GeomLib.hxx>
-#include <gp_Pln.hxx>
-#include <TColGeom2d_HSequenceOfBoundedCurve.hxx>
-#include <TCollection_AsciiString.hxx>
-#include <TCollection_HAsciiString.hxx>
-#include <TopExp.hxx>
-#include <TopExp_Explorer.hxx>
-#include <TopoDS.hxx>
-#include <TopoDS_Compound.hxx>
-#include <TopoDS_Vertex.hxx>
-#include <TopTools_DataMapOfShapeInteger.hxx>
-#include <TopTools_DataMapOfShapeSequenceOfShape.hxx>
-
-#include <ft2build.h>
-#include FT_FREETYPE_H
-#include FT_OUTLINE_H
-
-IMPLEMENT_STANDARD_RTTIEXT(Font_BRepFont,Font_FTFont)
-
-namespace
-{
- // pre-defined font rendering options
- static const unsigned int THE_FONT_SIZE = 72;
- static const unsigned int THE_RESOLUTION_DPI = 4800;
- static const Font_FTFontParams THE_FONT_PARAMS (THE_FONT_SIZE, THE_RESOLUTION_DPI);
-
- // compute scaling factor for specified font size
- inline Standard_Real getScale (const Standard_Real theSize)
- {
- return theSize / Standard_Real(THE_FONT_SIZE) * 72.0 / Standard_Real(THE_RESOLUTION_DPI);
- }
-
- //! Auxiliary method to convert FT_Vector to gp_XY
- static gp_XY readFTVec (const FT_Vector& theVec,
- const Standard_Real theScaleUnits,
- const Standard_Real theWidthScaling = 1.0)
- {
- return gp_XY (theScaleUnits * Standard_Real(theVec.x) * theWidthScaling / 64.0, theScaleUnits * Standard_Real(theVec.y) / 64.0);
- }
-
- //! Auxiliary method for classification wire theW2 with respect to wire theW1
- static TopAbs_State classifyWW (const TopoDS_Wire& theW1,
- const TopoDS_Wire& theW2,
- const TopoDS_Face& theF)
- {
- TopAbs_State aRes = TopAbs_UNKNOWN;
-
- TopoDS_Face aF = TopoDS::Face (theF.EmptyCopied());
- aF.Orientation (TopAbs_FORWARD);
- BRep_Builder aB;
- aB.Add (aF, theW1);
- BRepTopAdaptor_FClass2d aClass2d (aF, ::Precision::PConfusion());
- for (TopoDS_Iterator anEdgeIter (theW2); anEdgeIter.More(); anEdgeIter.Next())
- {
- const TopoDS_Edge& anEdge = TopoDS::Edge (anEdgeIter.Value());
- Standard_Real aPFirst = 0.0, aPLast = 0.0;
- Handle(Geom2d_Curve) aCurve2d = BRep_Tool::CurveOnSurface (anEdge, theF, aPFirst, aPLast);
- if (aCurve2d.IsNull())
- {
- continue;
- }
-
- gp_Pnt2d aPnt2d = aCurve2d->Value ((aPFirst + aPLast) / 2.0);
- TopAbs_State aState = aClass2d.Perform (aPnt2d, Standard_False);
- if (aState == TopAbs_OUT
- || aState == TopAbs_IN)
- {
- if (aRes == TopAbs_UNKNOWN)
- {
- aRes = aState;
- }
- else if (aRes != aState)
- {
- return TopAbs_UNKNOWN;
- }
- }
- }
- return aRes;
- }
-
-}
-
-// =======================================================================
-// function : Constructor
-// purpose :
-// =======================================================================
-Font_BRepFont::Font_BRepFont ()
-: myPrecision (Precision::Confusion()),
- myScaleUnits (1.0),
- myIsCompositeCurve (Standard_False),
- my3Poles (1, 3),
- my4Poles (1, 4)
-{
- init();
-}
-
-// =======================================================================
-// function : init
-// purpose :
-// =======================================================================
-void Font_BRepFont::init()
-{
- mySurface = new Geom_Plane (gp_Pln (gp::XOY()));
- myCurve2dAdaptor = new Geom2dAdaptor_HCurve();
- Handle(Adaptor3d_HSurface) aSurfAdaptor = new GeomAdaptor_HSurface (mySurface);
- myCurvOnSurf.Load (aSurfAdaptor);
-}
-
-// =======================================================================
-// function : Constructor
-// purpose :
-// =======================================================================
-Font_BRepFont::Font_BRepFont (const NCollection_String& theFontPath,
- const Standard_Real theSize,
- const Standard_Integer theFaceId)
-: myPrecision (Precision::Confusion()),
- myScaleUnits (1.0),
- myIsCompositeCurve (Standard_False),
- my3Poles (1, 3),
- my4Poles (1, 4)
-{
- init();
- if (theSize <= myPrecision * 100.0)
- {
- return;
- }
-
- myScaleUnits = getScale (theSize);
- Font_FTFont::Init (theFontPath.ToCString(), THE_FONT_PARAMS, theFaceId);
-}
-
-// =======================================================================
-// function : Constructor
-// purpose :
-// =======================================================================
-Font_BRepFont::Font_BRepFont (const NCollection_String& theFontName,
- const Font_FontAspect theFontAspect,
- const Standard_Real theSize,
- const Font_StrictLevel theStrictLevel)
-: myPrecision (Precision::Confusion()),
- myScaleUnits (1.0),
- myIsCompositeCurve (Standard_False),
- my3Poles (1, 3),
- my4Poles (1, 4)
-{
- init();
- if (theSize <= myPrecision * 100.0)
- {
- return;
- }
-
- myScaleUnits = getScale (theSize);
- Font_FTFont::FindAndInit (theFontName.ToCString(), theFontAspect, THE_FONT_PARAMS, theStrictLevel);
-}
-
-// =======================================================================
-// function : Release
-// purpose :
-// =======================================================================
-void Font_BRepFont::Release()
-{
- myCache.Clear();
- Font_FTFont::Release();
-}
-
-// =======================================================================
-// function : SetCompositeCurveMode
-// purpose :
-// =======================================================================
-void Font_BRepFont::SetCompositeCurveMode (const Standard_Boolean theToConcatenate)
-{
- if (myIsCompositeCurve != theToConcatenate)
- {
- myIsCompositeCurve = theToConcatenate;
- myCache.Clear();
- }
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-bool Font_BRepFont::Init (const NCollection_String& theFontPath,
- const Standard_Real theSize,
- const Standard_Integer theFaceId)
-{
- if (theSize <= myPrecision * 100.0)
- {
- return false;
- }
-
- myScaleUnits = getScale (theSize);
- return Font_FTFont::Init (theFontPath.ToCString(), THE_FONT_PARAMS, theFaceId);
-}
-
-// =======================================================================
-// function : FindAndInit
-// purpose :
-// =======================================================================
-bool Font_BRepFont::FindAndInit (const TCollection_AsciiString& theFontName,
- const Font_FontAspect theFontAspect,
- const Standard_Real theSize,
- const Font_StrictLevel theStrictLevel)
-{
- if (theSize <= myPrecision * 100.0)
- {
- return false;
- }
-
- myScaleUnits = getScale (theSize);
- return Font_FTFont::FindAndInit (theFontName.ToCString(), theFontAspect, THE_FONT_PARAMS, theStrictLevel);
-}
-
-// =======================================================================
-// function : RenderGlyph
-// purpose :
-// =======================================================================
-TopoDS_Shape Font_BRepFont::RenderGlyph (const Standard_Utf32Char& theChar)
-{
- TopoDS_Shape aShape;
- Standard_Mutex::Sentry aSentry (myMutex);
- renderGlyph (theChar, aShape);
- return aShape;
-}
-
-// =======================================================================
-// function : to3d
-// purpose :
-// =======================================================================
-bool Font_BRepFont::to3d (const Handle(Geom2d_Curve)& theCurve2d,
- const GeomAbs_Shape theContinuity,
- Handle(Geom_Curve)& theCurve3d)
-{
- Standard_Real aMaxDeviation = 0.0;
- Standard_Real anAverDeviation = 0.0;
- myCurve2dAdaptor->ChangeCurve2d().Load (theCurve2d);
- const Handle(Adaptor2d_HCurve2d)& aCurve = myCurve2dAdaptor; // to avoid ambiguity
- myCurvOnSurf.Load (aCurve);
- GeomLib::BuildCurve3d (myPrecision, myCurvOnSurf,
- myCurve2dAdaptor->FirstParameter(), myCurve2dAdaptor->LastParameter(),
- theCurve3d, aMaxDeviation, anAverDeviation, theContinuity);
- return !theCurve3d.IsNull();
-}
-
-
-// =======================================================================
-// function : buildFaces
-// purpose :
-// =======================================================================
-Standard_Boolean Font_BRepFont::buildFaces (const NCollection_Sequence<TopoDS_Wire>& theWires,
- TopoDS_Shape& theRes)
-{
- // classify wires
- NCollection_DataMap<TopoDS_Shape, NCollection_Sequence<TopoDS_Wire>, TopTools_ShapeMapHasher> aMapOutInts;
- TopTools_DataMapOfShapeInteger aMapNbOuts;
- TopoDS_Face aF;
- myBuilder.MakeFace (aF, mySurface, myPrecision);
- Standard_Integer aWireIter1Index = 1;
- for (NCollection_Sequence<TopoDS_Wire>::Iterator aWireIter1 (theWires); aWireIter1.More(); ++aWireIter1Index, aWireIter1.Next())
- {
- const TopoDS_Wire& aW1 = aWireIter1.Value();
- if (!aMapNbOuts.IsBound (aW1))
- {
- const Standard_Integer aNbOuts = 0;
- aMapNbOuts.Bind (aW1, aNbOuts);
- }
-
- NCollection_Sequence<TopoDS_Wire>* anIntWs = aMapOutInts.Bound (aW1, NCollection_Sequence<TopoDS_Wire>());
- Standard_Integer aWireIter2Index = 1;
- for (NCollection_Sequence<TopoDS_Wire>::Iterator aWireIter2 (theWires); aWireIter2.More(); ++aWireIter2Index, aWireIter2.Next())
- {
- if (aWireIter1Index == aWireIter2Index)
- {
- continue;
- }
-
- const TopoDS_Wire& aW2 = aWireIter2.Value();
- const TopAbs_State aClass = classifyWW (aW1, aW2, aF);
- if (aClass == TopAbs_IN)
- {
- anIntWs->Append (aW2);
- if (Standard_Integer* aNbOutsPtr = aMapNbOuts.ChangeSeek (aW2))
- {
- ++(*aNbOutsPtr);
- }
- else
- {
- const Standard_Integer aNbOuts = 1;
- aMapNbOuts.Bind (aW2, aNbOuts);
- }
- }
- }
- }
-
- // check out wires and remove "not out" wires from maps
- for (TopTools_DataMapIteratorOfDataMapOfShapeInteger anOutIter (aMapNbOuts); anOutIter.More(); anOutIter.Next())
- {
- const Standard_Integer aTmp = anOutIter.Value() % 2;
- if (aTmp > 0)
- {
- // not out wire
- aMapOutInts.UnBind (anOutIter.Key());
- }
- }
-
- // create faces for out wires
- TopTools_MapOfShape anUsedShapes;
- TopoDS_Compound aFaceComp;
- myBuilder.MakeCompound (aFaceComp);
- for (; !aMapOutInts.IsEmpty(); )
- {
- // find out wire with max number of outs
- TopoDS_Shape aW;
- Standard_Integer aMaxNbOuts = -1;
- for (NCollection_DataMap<TopoDS_Shape, NCollection_Sequence<TopoDS_Wire>, TopTools_ShapeMapHasher>::Iterator itMOI (aMapOutInts);
- itMOI.More(); itMOI.Next())
- {
- const TopoDS_Shape& aKey = itMOI.Key();
- const Standard_Integer aNbOuts = aMapNbOuts.Find (aKey);
- if (aNbOuts > aMaxNbOuts)
- {
- aMaxNbOuts = aNbOuts;
- aW = aKey;
- }
- }
-
- // create face for selected wire
- TopoDS_Face aNewF;
- myBuilder.MakeFace (aNewF, mySurface, myPrecision);
- myBuilder.Add (aNewF, aW);
- anUsedShapes.Add (aW);
- const NCollection_Sequence<TopoDS_Wire>& anIns = aMapOutInts.Find (aW);
- for (NCollection_Sequence<TopoDS_Wire>::Iterator aWireIter (anIns); aWireIter.More(); aWireIter.Next())
- {
- TopoDS_Wire aWin = aWireIter.Value();
- if (anUsedShapes.Contains (aWin))
- {
- continue;
- }
-
- aWin.Reverse();
- myBuilder.Add (aNewF, aWin);
- anUsedShapes.Add (aWin);
- }
-
- myBuilder.Add (aFaceComp, aNewF);
- aMapOutInts.UnBind (aW);
- }
-
- if (aFaceComp.NbChildren() == 0)
- {
- return Standard_False;
- }
-
- if (aFaceComp.NbChildren() == 1)
- {
- theRes = TopoDS_Iterator (aFaceComp).Value();
- }
- else
- {
- theRes = aFaceComp;
- }
- return Standard_True;
-}
-
-
-// =======================================================================
-// function : renderGlyph
-// purpose :
-// =======================================================================
-Standard_Boolean Font_BRepFont::renderGlyph (const Standard_Utf32Char theChar,
- TopoDS_Shape& theShape)
-{
- theShape.Nullify();
- if (!loadGlyph (theChar)
- || myActiveFTFace->glyph->format != FT_GLYPH_FORMAT_OUTLINE)
- {
- return Standard_False;
- }
- else if (myCache.Find (theChar, theShape))
- {
- return !theShape.IsNull();
- }
-
- const FT_Outline& anOutline = myActiveFTFace->glyph->outline;
- if (!anOutline.n_contours)
- return Standard_False;
-
- TopLoc_Location aLoc;
- NCollection_Sequence<TopoDS_Wire> aWires;
- TopoDS_Compound aFaceCompDraft;
-
- // Get orientation is useless since it doesn't retrieve any in-font information and just computes orientation.
- // Because it fails in some cases - leave this to ShapeFix.
- //const FT_Orientation anOrient = FT_Outline_Get_Orientation (&anOutline);
- for (short aContour = 0, aStartIndex = 0; aContour < anOutline.n_contours; ++aContour)
- {
- const FT_Vector* aPntList = &anOutline.points[aStartIndex];
- const char* aTags = &anOutline.tags[aStartIndex];
- const short anEndIndex = anOutline.contours[aContour];
- const short aPntsNb = (anEndIndex - aStartIndex) + 1;
- aStartIndex = anEndIndex + 1;
- if (aPntsNb < 3 && !myFontParams.IsSingleStrokeFont)
- {
- // closed contour can not be constructed from < 3 points
- continue;
- }
-
- BRepBuilderAPI_MakeWire aWireMaker;
-
- gp_XY aPntPrev;
- gp_XY aPntCurr = readFTVec (aPntList[aPntsNb - 1], myScaleUnits, myWidthScaling);
- gp_XY aPntNext = readFTVec (aPntList[0], myScaleUnits, myWidthScaling);
-
- bool isLineSeg = !myFontParams.IsSingleStrokeFont
- && FT_CURVE_TAG(aTags[aPntsNb - 1]) == FT_Curve_Tag_On;
- gp_XY aPntLine1 = aPntCurr;
-
- // see http://freetype.sourceforge.net/freetype2/docs/glyphs/glyphs-6.html
- // for a full description of FreeType tags.
- for (short aPntId = 0; aPntId < aPntsNb; ++aPntId)
- {
- aPntPrev = aPntCurr;
- aPntCurr = aPntNext;
- aPntNext = readFTVec (aPntList[(aPntId + 1) % aPntsNb], myScaleUnits, myWidthScaling);
-
- // process tags
- if (FT_CURVE_TAG(aTags[aPntId]) == FT_Curve_Tag_On)
- {
- if (!isLineSeg)
- {
- aPntLine1 = aPntCurr;
- isLineSeg = true;
- continue;
- }
-
- const gp_XY aDirVec = aPntCurr - aPntLine1;
- const Standard_Real aLen = aDirVec.Modulus();
- if (aLen <= myPrecision)
- {
- aPntLine1 = aPntCurr;
- isLineSeg = true;
- continue;
- }
-
- if (myIsCompositeCurve)
- {
- Handle(Geom2d_TrimmedCurve) aLine = GCE2d_MakeSegment (gp_Pnt2d (aPntLine1), gp_Pnt2d (aPntCurr));
- myConcatMaker.Add (aLine, myPrecision);
- }
- else
- {
- Handle(Geom_Curve) aCurve3d;
- Handle(Geom2d_Line) aCurve2d = new Geom2d_Line (gp_Pnt2d (aPntLine1), gp_Dir2d (aDirVec));
- if (to3d (aCurve2d, GeomAbs_C1, aCurve3d))
- {
- TopoDS_Edge anEdge = BRepLib_MakeEdge (aCurve3d, 0.0, aLen);
- myBuilder.UpdateEdge (anEdge, aCurve2d, mySurface, aLoc, myPrecision);
- aWireMaker.Add (anEdge);
- }
- }
- aPntLine1 = aPntCurr;
- }
- else if (FT_CURVE_TAG(aTags[aPntId]) == FT_Curve_Tag_Conic)
- {
- isLineSeg = false;
- gp_XY aPntPrev2 = aPntPrev;
- gp_XY aPntNext2 = aPntNext;
-
- // previous point is either the real previous point (an "on" point),
- // or the midpoint between the current one and the previous "conic off" point
- if (FT_CURVE_TAG(aTags[(aPntId - 1 + aPntsNb) % aPntsNb]) == FT_Curve_Tag_Conic)
- {
- aPntPrev2 = (aPntCurr + aPntPrev) * 0.5;
- }
-
- // next point is either the real next point or the midpoint
- if (FT_CURVE_TAG(aTags[(aPntId + 1) % aPntsNb]) == FT_Curve_Tag_Conic)
- {
- aPntNext2 = (aPntCurr + aPntNext) * 0.5;
- }
-
- my3Poles.SetValue (1, aPntPrev2);
- my3Poles.SetValue (2, aPntCurr);
- my3Poles.SetValue (3, aPntNext2);
- Handle(Geom2d_BezierCurve) aBezierArc = new Geom2d_BezierCurve (my3Poles);
- if (myIsCompositeCurve)
- {
- myConcatMaker.Add (aBezierArc, myPrecision);
- }
- else
- {
- Handle(Geom_Curve) aCurve3d;
- if (to3d (aBezierArc, GeomAbs_C1, aCurve3d))
- {
- TopoDS_Edge anEdge = BRepLib_MakeEdge (aCurve3d);
- myBuilder.UpdateEdge (anEdge, aBezierArc, mySurface, aLoc, myPrecision);
- aWireMaker.Add (anEdge);
- }
- }
- }
- else if (FT_CURVE_TAG(aTags[aPntId]) == FT_Curve_Tag_Cubic
- && FT_CURVE_TAG(aTags[(aPntId + 1) % aPntsNb]) == FT_Curve_Tag_Cubic)
- {
- isLineSeg = false;
- my4Poles.SetValue (1, aPntPrev);
- my4Poles.SetValue (2, aPntCurr);
- my4Poles.SetValue (3, aPntNext);
- my4Poles.SetValue (4, gp_Pnt2d(readFTVec (aPntList[(aPntId + 2) % aPntsNb], myScaleUnits, myWidthScaling)));
- Handle(Geom2d_BezierCurve) aBezier = new Geom2d_BezierCurve (my4Poles);
- if (myIsCompositeCurve)
- {
- myConcatMaker.Add (aBezier, myPrecision);
- }
- else
- {
- Handle(Geom_Curve) aCurve3d;
- if (to3d (aBezier, GeomAbs_C1, aCurve3d))
- {
- TopoDS_Edge anEdge = BRepLib_MakeEdge (aCurve3d);
- myBuilder.UpdateEdge (anEdge, aBezier, mySurface, aLoc, myPrecision);
- aWireMaker.Add (anEdge);
- }
- }
- }
- }
-
- if (myIsCompositeCurve)
- {
- Handle(Geom2d_BSplineCurve) aDraft2d = myConcatMaker.BSplineCurve();
- if (aDraft2d.IsNull())
- {
- continue;
- }
-
- const gp_Pnt2d aFirstPnt = aDraft2d->StartPoint();
- const gp_Pnt2d aLastPnt = aDraft2d->EndPoint();
- if (!myFontParams.IsSingleStrokeFont
- && !aFirstPnt.IsEqual (aLastPnt, myPrecision))
- {
- Handle(Geom2d_TrimmedCurve) aLine = GCE2d_MakeSegment (aLastPnt, aFirstPnt);
- myConcatMaker.Add (aLine, myPrecision);
- }
-
- Handle(Geom2d_BSplineCurve) aCurve2d = myConcatMaker.BSplineCurve();
- Handle(Geom_Curve) aCurve3d;
- if (to3d (aCurve2d, GeomAbs_C0, aCurve3d))
- {
- TopoDS_Edge anEdge = BRepLib_MakeEdge (aCurve3d);
- myBuilder.UpdateEdge (anEdge, aCurve2d, mySurface, aLoc, myPrecision);
- aWireMaker.Add (anEdge);
- }
- myConcatMaker.Clear();
- }
- else
- {
- if (!aWireMaker.IsDone())
- {
- continue;
- }
-
- TopoDS_Vertex aFirstV, aLastV;
- TopExp::Vertices (aWireMaker.Wire(), aFirstV, aLastV);
- gp_Pnt aFirstPoint = BRep_Tool::Pnt (aFirstV);
- gp_Pnt aLastPoint = BRep_Tool::Pnt (aLastV);
- if (!myFontParams.IsSingleStrokeFont
- && !aFirstPoint.IsEqual (aLastPoint, myPrecision))
- {
- aWireMaker.Add (BRepLib_MakeEdge (aFirstV, aLastV));
- }
- }
-
- if (!aWireMaker.IsDone())
- {
- continue;
- }
-
- TopoDS_Wire aWireDraft = aWireMaker.Wire();
- if (!myFontParams.IsSingleStrokeFont)
- {
- // collect all wires and set CCW orientation
- TopoDS_Face aFace;
- myBuilder.MakeFace (aFace, mySurface, myPrecision);
- myBuilder.Add (aFace, aWireDraft);
- BRepTopAdaptor_FClass2d aClass2d (aFace, ::Precision::PConfusion());
- TopAbs_State aState = aClass2d.PerformInfinitePoint();
- if (aState != TopAbs_OUT)
- {
- // need to reverse
- aWireDraft.Reverse();
- }
- aWires.Append (aWireDraft);
- }
- else
- {
- if (aFaceCompDraft.IsNull())
- {
- myBuilder.MakeCompound (aFaceCompDraft);
- }
- myBuilder.Add (aFaceCompDraft, aWireDraft);
- }
- }
-
- if (!aWires.IsEmpty())
- {
- buildFaces (aWires, theShape);
- }
- else if (!aFaceCompDraft.IsNull())
- {
- theShape = aFaceCompDraft;
- }
-
- myCache.Bind (theChar, theShape);
- return !theShape.IsNull();
-}
#ifndef _Font_BRepFont_H__
#define _Font_BRepFont_H__
-#include <Adaptor3d_CurveOnSurface.hxx>
-#include <BRep_Builder.hxx>
-#include <Font_FTFont.hxx>
-#include <Font_TextFormatter.hxx>
-#include <Geom2dAdaptor_HCurve.hxx>
-#include <Geom2dConvert_CompCurveToBSplineCurve.hxx>
-#include <gp_Ax3.hxx>
-#include <gp_XY.hxx>
-#include <gp_XYZ.hxx>
-#include <NCollection_DataMap.hxx>
-#include <NCollection_String.hxx>
-#include <Standard_Mutex.hxx>
-#include <TColgp_Array1OfPnt2d.hxx>
-#include <TopoDS_Shape.hxx>
-#include <TopoDS_Face.hxx>
-#include <TopTools_SequenceOfShape.hxx>
+#include <StdPrs_BRepFont.hxx>
-DEFINE_STANDARD_HANDLE(Font_BRepFont, Font_FTFont)
-
-//! This tool provides basic services for rendering of vectorized text glyphs as BRep shapes.
-//! Single instance initialize single font for sequential glyphs rendering with implicit caching of already rendered glyphs.
-//! Thus position of each glyph in the text is specified by shape location.
-//!
-//! Please notice that this implementation uses mutex for thread-safety access,
-//! thus may lead to performance penalties in case of concurrent access.
-//! Although caching should eliminate this issue after rendering of sufficient number of glyphs.
-class Font_BRepFont : protected Font_FTFont
-{
- DEFINE_STANDARD_RTTIEXT(Font_BRepFont, Font_FTFont)
-public:
-
- //! Empty constructor
- Standard_EXPORT Font_BRepFont();
-
- //! Constructor with initialization.
- //! @param theFontPath FULL path to the font
- //! @param theSize the face size in model units
- //! @param theFaceId face id within the file (0 by default)
- Standard_EXPORT Font_BRepFont (const NCollection_String& theFontPath,
- const Standard_Real theSize,
- const Standard_Integer theFaceId = 0);
-
- //! Constructor with initialization.
- //! @param theFontName the font name
- //! @param theFontAspect the font style
- //! @param theSize the face size in model units
- //! @param theStrictLevel search strict level for using aliases and fallback
- Standard_EXPORT Font_BRepFont (const NCollection_String& theFontName,
- const Font_FontAspect theFontAspect,
- const Standard_Real theSize,
- const Font_StrictLevel theStrictLevel = Font_StrictLevel_Any);
-
- //! Release currently loaded font.
- Standard_EXPORT virtual void Release() Standard_OVERRIDE;
-
- //! Initialize the font.
- //! @param theFontPath FULL path to the font
- //! @param theSize the face size in model units
- //! @param theFaceId face id within the file (0 by default)
- //! @return true on success
- Standard_EXPORT bool Init (const NCollection_String& theFontPath,
- const Standard_Real theSize,
- const Standard_Integer theFaceId);
-
- //! Find (using Font_FontMgr) and initialize the font from the given name.
- //! Please take into account that size is specified NOT in typography points (pt.).
- //! If you need to specify size in points, value should be converted.
- //! Formula for pt. -> m conversion:
- //! aSizeMeters = 0.0254 * theSizePt / 72.0
- //! @param theFontName the font name
- //! @param theFontAspect the font style
- //! @param theSize the face size in model units
- //! @param theStrictLevel search strict level for using aliases and fallback
- //! @return true on success
- Standard_EXPORT bool FindAndInit (const TCollection_AsciiString& theFontName,
- const Font_FontAspect theFontAspect,
- const Standard_Real theSize,
- const Font_StrictLevel theStrictLevel = Font_StrictLevel_Any);
-
- //! Render single glyph as TopoDS_Shape.
- //! @param theChar glyph identifier
- //! @return rendered glyph within cache, might be NULL shape
- Standard_EXPORT TopoDS_Shape RenderGlyph (const Standard_Utf32Char& theChar);
-
- //! Setup glyph geometry construction mode.
- //! By default algorithm creates independent TopoDS_Edge
- //! for each original curve in the glyph (line segment or Bezie curve).
- //! Algorithm might optionally create composite BSpline curve for each contour
- //! which reduces memory footprint but limits curve class to C0.
- //! Notice that altering this flag clears currently accumulated cache!
- Standard_EXPORT void SetCompositeCurveMode (const Standard_Boolean theToConcatenate);
-
- //! Setup glyph scaling along X-axis.
- //! By default glyphs are not scaled (scaling factor = 1.0)
- void SetWidthScaling (const float theScaleFactor)
- {
- myWidthScaling = theScaleFactor;
- }
-
-public:
-
- //! @return vertical distance from the horizontal baseline to the highest character coordinate.
- Standard_Real Ascender() const
- {
- return myScaleUnits * Standard_Real(Font_FTFont::Ascender());
- }
-
- //! @return vertical distance from the horizontal baseline to the lowest character coordinate.
- Standard_Real Descender() const
- {
- return myScaleUnits * Standard_Real(Font_FTFont::Descender());
- }
-
- //! @return default line spacing (the baseline-to-baseline distance).
- Standard_Real LineSpacing() const
- {
- return myScaleUnits * Standard_Real(Font_FTFont::LineSpacing());
- }
-
- //! Configured point size
- Standard_Real PointSize() const
- {
- return myScaleUnits * Standard_Real(Font_FTFont::PointSize());
- }
-
- //! Compute advance to the next character with kerning applied when applicable.
- //! Assuming text rendered horizontally.
- Standard_Real AdvanceX (const Standard_Utf32Char theUCharNext)
- {
- return myScaleUnits * Standard_Real(Font_FTFont::AdvanceX (theUCharNext));
- }
-
- //! Compute advance to the next character with kerning applied when applicable.
- //! Assuming text rendered horizontally.
- Standard_Real AdvanceX (const Standard_Utf32Char theUChar,
- const Standard_Utf32Char theUCharNext)
- {
- return myScaleUnits * Standard_Real(Font_FTFont::AdvanceX (theUChar, theUCharNext));
- }
-
- //! Compute advance to the next character with kerning applied when applicable.
- //! Assuming text rendered vertically.
- Standard_Real AdvanceY (const Standard_Utf32Char theUCharNext)
- {
- return myScaleUnits * Standard_Real(Font_FTFont::AdvanceY (theUCharNext));
- }
-
- //! Compute advance to the next character with kerning applied when applicable.
- //! Assuming text rendered vertically.
- Standard_Real AdvanceY (const Standard_Utf32Char theUChar,
- const Standard_Utf32Char theUCharNext)
- {
- return myScaleUnits * Standard_Real(Font_FTFont::AdvanceY (theUChar, theUCharNext));
- }
-
- //! Returns scaling factor for current font size.
- Standard_Real Scale() const
- {
- return myScaleUnits;
- }
-
- //! Returns mutex.
- Standard_Mutex& Mutex()
- {
- return myMutex;
- }
-
-public:
-
- //! Find (using Font_FontMgr) and initialize the font from the given name.
- //! Alias for FindAndInit() for backward compatibility.
- bool Init (const NCollection_String& theFontName,
- const Font_FontAspect theFontAspect,
- const Standard_Real theSize)
- {
- return FindAndInit (theFontName.ToCString(), theFontAspect, theSize, Font_StrictLevel_Any);
- }
-
-protected:
-
- //! Render single glyph as TopoDS_Shape. This method does not lock the mutex.
- //! @param theChar glyph identifier
- //! @param theShape rendered glyph within cache, might be NULL shape
- //! @return true if glyph's geometry is available
- Standard_EXPORT Standard_Boolean renderGlyph (const Standard_Utf32Char theChar,
- TopoDS_Shape& theShape);
-
-private:
-
- //! Initialize class fields
- void init();
-
- //! Auxiliary method to create 3D curve
- bool to3d (const Handle(Geom2d_Curve)& theCurve2d,
- const GeomAbs_Shape theContinuity,
- Handle(Geom_Curve)& theCurve3d);
-
- //! Auxiliary method for creation faces from sequence of wires.
- //! Splits to few faces (if it is needed) and updates orientation of wires.
- Standard_Boolean buildFaces (const NCollection_Sequence<TopoDS_Wire>& theWires,
- TopoDS_Shape& theRes);
-
- //! Hide visibility.
- using Font_FTFont::FindAndCreate;
-
-protected: //! @name Protected fields
-
- NCollection_DataMap<Standard_Utf32Char, TopoDS_Shape>
- myCache; //!< glyphs cache
- Standard_Mutex myMutex; //!< lock for thread-safety
- Handle(Geom_Surface) mySurface; //!< surface to place glyphs on to
- Standard_Real myPrecision; //!< algorithm precision
- Standard_Real myScaleUnits; //!< scale font rendering units into model units
- Standard_Boolean myIsCompositeCurve; //!< flag to merge C1 curves of each contour into single C0 curve, OFF by default
-
-protected: //! @name Shared temporary variables for glyph construction
-
- Adaptor3d_CurveOnSurface myCurvOnSurf;
- Handle(Geom2dAdaptor_HCurve) myCurve2dAdaptor;
- Geom2dConvert_CompCurveToBSplineCurve myConcatMaker;
- TColgp_Array1OfPnt2d my3Poles;
- TColgp_Array1OfPnt2d my4Poles;
- BRep_Builder myBuilder;
-
-};
+//! Alias for porting from old name.
+typedef StdPrs_BRepFont Font_BRepFont;
#endif // _Font_BRepFont_H__
+++ /dev/null
-// Created on: 2015-08-10
-// Created by: Ilya SEVRIKOV
-// 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 <Font_BRepTextBuilder.hxx>
-
-// =======================================================================
-// Function : Perfrom
-// Purpose :
-// =======================================================================
-TopoDS_Shape Font_BRepTextBuilder::Perform (Font_BRepFont& theFont,
- const Font_TextFormatter& theFormatter,
- const gp_Ax3& thePenLoc)
-{
- gp_Trsf aTrsf;
- gp_XYZ aPen;
- TopoDS_Shape aGlyphShape;
- TopoDS_Compound aResult;
- Standard_Mutex::Sentry aSentry (theFont.Mutex());
-
- myBuilder.MakeCompound (aResult);
-
- Standard_Integer aSymbolCounter = 0;
- Standard_Real aScaleUnits = theFont.Scale();
- for (NCollection_Utf8Iter anIter = theFormatter.String().Iterator(); *anIter != 0; ++anIter)
- {
- const Standard_Utf32Char aCharCurr = *anIter;
- if (aCharCurr == '\x0D' // CR (carriage return)
- || aCharCurr == '\a' // BEL (alarm)
- || aCharCurr == '\f' // FF (form feed) NP (new page)
- || aCharCurr == '\b' // BS (backspace)
- || aCharCurr == '\v' // VT (vertical tab)
- || aCharCurr == ' '
- || aCharCurr == '\t'
- || aCharCurr == '\n')
- {
- continue; // skip unsupported carriage control codes
- }
-
- const NCollection_Vec2<Standard_ShortReal>& aCorner = theFormatter.TopLeft (aSymbolCounter);
- aPen.SetCoord (aCorner.x() * aScaleUnits, aCorner.y() * aScaleUnits, 0.0);
- aGlyphShape = theFont.RenderGlyph (aCharCurr);
- if (!aGlyphShape.IsNull())
- {
- aTrsf.SetTranslation (gp_Vec (aPen));
- aGlyphShape.Move (aTrsf);
- myBuilder.Add (aResult, aGlyphShape);
- }
-
- ++aSymbolCounter;
- }
-
- aTrsf.SetTransformation (thePenLoc, gp_Ax3 (gp::XOY()));
- aResult.Move (aTrsf);
-
- return aResult;
-}
-
-// =======================================================================
-// Function : Perform
-// Purpose :
-// =======================================================================
-TopoDS_Shape Font_BRepTextBuilder::Perform (Font_BRepFont& theFont,
- const NCollection_String& theString,
- const gp_Ax3& thePenLoc,
- const Graphic3d_HorizontalTextAlignment theHAlign,
- const Graphic3d_VerticalTextAlignment theVAlign)
-{
- Font_TextFormatter aFormatter;
-
- aFormatter.Reset();
- aFormatter.SetupAlignment (theHAlign, theVAlign);
-
- aFormatter.Append (theString, *(reinterpret_cast<Font_FTFont*> (&theFont)));
- aFormatter.Format();
-
- return Perform (theFont, aFormatter, thePenLoc);
-}
-// Created on: 2015-08-10
-// Created by: Ilya SEVRIKOV
-// Copyright (c) 2013-2014 OPEN CASCADE SAS
+// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
#ifndef Font_BRepTextBuilder_Header
#define Font_BRepTextBuilder_Header
-#include <Font_BRepFont.hxx>
-#include <Font_TextFormatter.hxx>
-#include <gp_Ax3.hxx>
+#include <StdPrs_BRepTextBuilder.hxx>
-//! Represents class for applying text formatting.
-class Font_BRepTextBuilder
-{
-public:
- //! Render text as BRep shape.
- //! @param theString text in UTF-8 encoding
- //! @param thePenLoc start position and orientation on the baseline
- //! @param theFormatter formatter which defines alignment for the text
- //! @return result shape with pen transformation applied as shape location
- Standard_EXPORT TopoDS_Shape Perform (Font_BRepFont& theFont,
- const Font_TextFormatter& theFormatter,
- const gp_Ax3& thePenLoc = gp_Ax3());
- //! Render text as BRep shape.
- //! @param theString text in UTF-8 encoding
- //! @param thePenLoc start position and orientation on the baseline
- //! @param theHAlign horizontal alignment of the text
- //! @param theVAlign vertical alignment of the text
- //! @return result shape with pen transformation applied as shape location
- Standard_EXPORT TopoDS_Shape Perform (Font_BRepFont& theFont,
- const NCollection_String& theString,
- const gp_Ax3& thePenLoc = gp_Ax3(),
- const Graphic3d_HorizontalTextAlignment theHAlign = Graphic3d_HTA_LEFT,
- const Graphic3d_VerticalTextAlignment theVAlign = Graphic3d_VTA_BOTTOM);
-
-protected:
- BRep_Builder myBuilder;
-};
+//! Alias for porting from old name.
+typedef StdPrs_BRepTextBuilder Font_BRepTextBuilder;
#endif // Font_BRepTextBuilder_Header
#include <Graphic3d_TransformPers.hxx>
#include <Graphic3d_Vec3.hxx>
#include <Graphic3d_ZLayerId.hxx>
-#include <Geom_Transformation.hxx>
+#include <TopLoc_Datum3D.hxx>
#include <NCollection_IndexedMap.hxx>
class Graphic3d_GraphicDriver;
}
//! Return transformation.
- const Handle(Geom_Transformation)& Transformation() const { return myTrsf; }
+ const Handle(TopLoc_Datum3D)& Transformation() const { return myTrsf; }
//! Assign transformation.
- virtual void SetTransformation (const Handle(Geom_Transformation)& theTrsf) { myTrsf = theTrsf; }
+ virtual void SetTransformation (const Handle(TopLoc_Datum3D)& theTrsf) { myTrsf = theTrsf; }
//! Return transformation persistence.
const Handle(Graphic3d_TransformPers)& TransformPersistence() const { return myTrsfPers; }
Handle(Graphic3d_GraphicDriver) myGraphicDriver;
Graphic3d_SequenceOfGroup myGroups;
Graphic3d_BndBox3d myBndBox;
- Handle(Geom_Transformation) myTrsf;
+ Handle(TopLoc_Datum3D) myTrsf;
Handle(Graphic3d_TransformPers) myTrsfPers;
Handle(Graphic3d_SequenceOfHClipPlane) myClipPlanes;
Handle(Graphic3d_PresentationAttributes) myHighlightStyle; //! Current highlight style; is set only if highlight flag is true
// compute + validation
Handle(Graphic3d_Structure) aCompStructOld = myStructsComputed.ChangeValue (anIndex);
Handle(Graphic3d_Structure) aCompStruct = aCompStructOld;
- aCompStruct->SetTransformation (Handle(Geom_Transformation)());
+ aCompStruct->SetTransformation (Handle(TopLoc_Datum3D)());
theStruct->computeHLR (myCamera, aCompStruct);
aCompStruct->SetHLRValidation (Standard_True);
aCompStruct->CalculateBoundBox();
if (anIndex != 0)
{
aStruct = myStructsComputed.Value (anIndex);
- aStruct->SetTransformation (Handle(Geom_Transformation)());
+ aStruct->SetTransformation (Handle(TopLoc_Datum3D)());
}
theStructure->computeHLR (myCamera, aStruct);
// purpose :
// =======================================================================
void Graphic3d_CView::SetTransform (const Handle(Graphic3d_Structure)& theStructure,
- const Handle(Geom_Transformation)& theTrsf)
+ const Handle(TopLoc_Datum3D)& theTrsf)
{
const Standard_Integer anIndex = IsComputed (theStructure);
if (anIndex != 0)
//! Transforms the structure in the view.
Standard_EXPORT void SetTransform (const Handle(Graphic3d_Structure)& theStructure,
- const Handle(Geom_Transformation)& theTrsf);
+ const Handle(TopLoc_Datum3D)& theTrsf);
//! Suppress the highlighting on the structure <AStructure>
//! in the view <me>.
//function : SetTransform
//purpose :
//=============================================================================
-void Graphic3d_Structure::SetTransformation (const Handle(Geom_Transformation)& theTrsf)
+void Graphic3d_Structure::SetTransformation (const Handle(TopLoc_Datum3D)& theTrsf)
{
if (IsDeleted()) return;
if (!theTrsf.IsNull()
&& theTrsf->Trsf().Form() == gp_Identity)
{
- myCStructure->SetTransformation (Handle(Geom_Transformation)());
+ myCStructure->SetTransformation (Handle(TopLoc_Datum3D)());
}
else
{
}
//! Return local transformation.
- const Handle(Geom_Transformation)& Transformation() const { return myCStructure->Transformation(); }
+ const Handle(TopLoc_Datum3D)& Transformation() const { return myCStructure->Transformation(); }
//! Modifies the current local transformation
- Standard_EXPORT void SetTransformation (const Handle(Geom_Transformation)& theTrsf);
+ Standard_EXPORT void SetTransformation (const Handle(TopLoc_Datum3D)& theTrsf);
Standard_DEPRECATED("This method is deprecated - SetTransformation() should be called instead")
- void Transform (const Handle(Geom_Transformation)& theTrsf) { SetTransformation (theTrsf); }
+ void Transform (const Handle(TopLoc_Datum3D)& theTrsf) { SetTransformation (theTrsf); }
//! Modifies the current transform persistence (pan, zoom or rotate)
Standard_EXPORT void SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers);
void GraphicDisconnect (const Handle(Graphic3d_Structure)& theDaughter) { myCStructure->Disconnect (*theDaughter->myCStructure); }
//! Internal method which sets new transformation without calling graphic manager callbacks.
- void GraphicTransform (const Handle(Geom_Transformation)& theTrsf) { myCStructure->SetTransformation (theTrsf); }
+ void GraphicTransform (const Handle(TopLoc_Datum3D)& theTrsf) { myCStructure->SetTransformation (theTrsf); }
//! Returns the identification number of this structure.
Standard_Integer Identification() const { return myCStructure->Id; }
// purpose :
// ========================================================================
void Graphic3d_StructureManager::SetTransform (const Handle(Graphic3d_Structure)& theStructure,
- const Handle(Geom_Transformation)& theTrsf)
+ const Handle(TopLoc_Datum3D)& theTrsf)
{
for (Graphic3d_IndexedMapOfView::Iterator aViewIt (myDefinedViews); aViewIt.More(); aViewIt.Next())
{
Standard_EXPORT virtual void Highlight (const Handle(Graphic3d_Structure)& theStructure);
//! Transforms the structure.
- Standard_EXPORT virtual void SetTransform (const Handle(Graphic3d_Structure)& theStructure, const Handle(Geom_Transformation)& theTrsf);
+ Standard_EXPORT virtual void SetTransform (const Handle(Graphic3d_Structure)& theStructure, const Handle(TopLoc_Datum3D)& theTrsf);
//! Changes the display priority of the structure <AStructure>.
Standard_EXPORT virtual void ChangeDisplayPriority (const Handle(Graphic3d_Structure)& theStructure, const Standard_Integer theOldPriority, const Standard_Integer theNewPriority);
#define _Graphic3d_ZLayerSettings_HeaderFile
#include <gp_XYZ.hxx>
-#include <Geom_Transformation.hxx>
+#include <TopLoc_Datum3D.hxx>
#include <Graphic3d_LightSet.hxx>
#include <Graphic3d_PolygonOffset.hxx>
#include <Precision.hxx>
const gp_XYZ& Origin() const { return myOrigin; }
//! Return the transformation to the origin.
- const Handle(Geom_Transformation)& OriginTransformation() const { return myOriginTrsf; }
+ const Handle(TopLoc_Datum3D)& OriginTransformation() const { return myOriginTrsf; }
//! Set the origin of all objects within the layer.
void SetOrigin (const gp_XYZ& theOrigin)
myOriginTrsf.Nullify();
if (!theOrigin.IsEqual (gp_XYZ(0.0, 0.0, 0.0), gp::Resolution()))
{
- myOriginTrsf = new Geom_Transformation();
- myOriginTrsf->SetTranslation (theOrigin);
+ gp_Trsf aTrsf;
+ aTrsf.SetTranslation (theOrigin);
+ myOriginTrsf = new TopLoc_Datum3D (aTrsf);
}
}
TCollection_AsciiString myName; //!< user-provided name
Handle(Graphic3d_LightSet) myLights; //!< lights list
- Handle(Geom_Transformation) myOriginTrsf; //!< transformation to the origin
+ Handle(TopLoc_Datum3D) myOriginTrsf; //!< transformation to the origin
gp_XYZ myOrigin; //!< the origin of all objects within the layer
Standard_Real myCullingDistance; //!< distance to discard objects
Standard_Real myCullingSize; //!< size to discard objects
#include <Prs3d_IsoAspect.hxx>
#include <Standard_ErrorHandler.hxx>
#include <StdPrs_Isolines.hxx>
+#include <StdPrs_ToolTriangulatedShape.hxx>
#include <TColgp_SequenceOfPnt2d.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TopExp.hxx>
Handle(Prs3d_Drawer) aDefDrawer = new Prs3d_Drawer();
aDefDrawer->SetTypeOfDeflection (Aspect_TOD_RELATIVE);
aDefDrawer->SetDeviationCoefficient (GetDeviationCoeff());
- myDeflection = Prs3d::GetDeflection (GetShapeObj()->GetShape(), aDefDrawer);
+ myDeflection = StdPrs_ToolTriangulatedShape::GetDeflection (GetShapeObj()->GetShape(), aDefDrawer);
}
return myDeflection;
// Purpose :
//================================================================
MeshVS_MeshEntityOwner::MeshVS_MeshEntityOwner
- ( const SelectMgr_SOPtr& SelObj,
+ ( const SelectMgr_SelectableObject* SelObj,
const Standard_Integer ID,
const Standard_Address MeshEntity,
const MeshVS_EntityType& Type,
#ifndef _MeshVS_MeshEntityOwner_HeaderFile
#define _MeshVS_MeshEntityOwner_HeaderFile
-#include <Standard.hxx>
-#include <Standard_Type.hxx>
-
-#include <Standard_Address.hxx>
#include <MeshVS_EntityType.hxx>
-#include <Standard_Integer.hxx>
-#include <Standard_Boolean.hxx>
#include <SelectMgr_EntityOwner.hxx>
-#include <SelectMgr_SOPtr.hxx>
#include <PrsMgr_PresentationManager3d.hxx>
#include <Quantity_NameOfColor.hxx>
class PrsMgr_PresentationManager;
public:
- Standard_EXPORT MeshVS_MeshEntityOwner(const SelectMgr_SOPtr& SelObj, const Standard_Integer ID, const Standard_Address MeshEntity, const MeshVS_EntityType& Type, const Standard_Integer Priority = 0, const Standard_Boolean IsGroup = Standard_False);
+ Standard_EXPORT MeshVS_MeshEntityOwner(const SelectMgr_SelectableObject* SelObj, const Standard_Integer ID, const Standard_Address MeshEntity, const MeshVS_EntityType& Type, const Standard_Integer Priority = 0, const Standard_Boolean IsGroup = Standard_False);
//! Returns an address of element or node data structure
Standard_EXPORT Standard_Address Owner() const;
// Function : Constructor MeshVS_MeshOwner
// Purpose :
//================================================================
-MeshVS_MeshOwner::MeshVS_MeshOwner (const SelectMgr_SOPtr& theSelObj,
+MeshVS_MeshOwner::MeshVS_MeshOwner (const SelectMgr_SelectableObject* theSelObj,
const Handle(MeshVS_DataSource)& theDS,
const Standard_Integer thePriority)
: SelectMgr_EntityOwner ( theSelObj, thePriority )
#ifndef _MeshVS_MeshOwner_HeaderFile
#define _MeshVS_MeshOwner_HeaderFile
-#include <Standard.hxx>
-#include <Standard_Type.hxx>
-
-#include <Standard_Integer.hxx>
#include <SelectMgr_EntityOwner.hxx>
-#include <SelectMgr_SOPtr.hxx>
#include <PrsMgr_PresentationManager3d.hxx>
#include <Quantity_NameOfColor.hxx>
-#include <Standard_Boolean.hxx>
+
class MeshVS_DataSource;
class TColStd_HPackedMapOfInteger;
class PrsMgr_PresentationManager;
public:
- Standard_EXPORT MeshVS_MeshOwner(const SelectMgr_SOPtr& theSelObj, const Handle(MeshVS_DataSource)& theDS, const Standard_Integer thePriority = 0);
+ Standard_EXPORT MeshVS_MeshOwner(const SelectMgr_SelectableObject* theSelObj, const Handle(MeshVS_DataSource)& theDS, const Standard_Integer thePriority = 0);
Standard_EXPORT const Handle(MeshVS_DataSource)& GetDataSource() const;
// function : SetTransformation
// purpose :
// =======================================================================
-void OpenGl_Structure::SetTransformation (const Handle(Geom_Transformation)& theTrsf)
+void OpenGl_Structure::SetTransformation (const Handle(TopLoc_Datum3D)& theTrsf)
{
myTrsf = theTrsf;
myIsMirrored = Standard_False;
if (!myTrsf.IsNull())
{
// Determinant of transform matrix less then 0 means that mirror transform applied.
- const Standard_Real aDet = myTrsf->Value(1, 1) * (myTrsf->Value (2, 2) * myTrsf->Value (3, 3) - myTrsf->Value (3, 2) * myTrsf->Value (2, 3))
- - myTrsf->Value(1, 2) * (myTrsf->Value (2, 1) * myTrsf->Value (3, 3) - myTrsf->Value (3, 1) * myTrsf->Value (2, 3))
- + myTrsf->Value(1, 3) * (myTrsf->Value (2, 1) * myTrsf->Value (3, 2) - myTrsf->Value (3, 1) * myTrsf->Value (2, 2));
+ const gp_Trsf& aTrsf = myTrsf->Transformation();
+ const Standard_Real aDet = aTrsf.Value(1, 1) * (aTrsf.Value (2, 2) * aTrsf.Value (3, 3) - aTrsf.Value (3, 2) * aTrsf.Value (2, 3))
+ - aTrsf.Value(1, 2) * (aTrsf.Value (2, 1) * aTrsf.Value (3, 3) - aTrsf.Value (3, 1) * aTrsf.Value (2, 3))
+ + aTrsf.Value(1, 3) * (aTrsf.Value (2, 1) * aTrsf.Value (3, 2) - aTrsf.Value (3, 1) * aTrsf.Value (2, 2));
myIsMirrored = aDet < 0.0;
}
if (aCtx->core11 != NULL
&& !myTrsf.IsNull())
{
- const Standard_Real aScale = myTrsf->ScaleFactor();
+ const Standard_Real aScale = myTrsf->Trsf().ScaleFactor();
if (Abs (aScale - 1.0) > Precision::Confusion())
{
aCtx->SetGlNormalizeEnabled (Standard_True);
Standard_EXPORT virtual void Disconnect (Graphic3d_CStructure& theStructure) Standard_OVERRIDE;
//! Synchronize structure transformation
- Standard_EXPORT virtual void SetTransformation (const Handle(Geom_Transformation)& theTrsf) Standard_OVERRIDE;
+ Standard_EXPORT virtual void SetTransformation (const Handle(TopLoc_Datum3D)& theTrsf) Standard_OVERRIDE;
//! Set transformation persistence.
Standard_EXPORT virtual void SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers) Standard_OVERRIDE;
//! Adds OpenGL groups to ray-traced scene geometry.
Standard_Boolean addRaytraceGroups (const OpenGl_Structure* theStructure,
const OpenGl_RaytraceMaterial& theStructMat,
- const Handle(Geom_Transformation)& theTrsf,
+ const Handle(TopLoc_Datum3D)& theTrsf,
const Handle(OpenGl_Context)& theGlContext);
//! Creates ray-tracing material properties.
// =======================================================================
Standard_Boolean OpenGl_View::addRaytraceGroups (const OpenGl_Structure* theStructure,
const OpenGl_RaytraceMaterial& theStructMat,
- const Handle(Geom_Transformation)& theTrsf,
+ const Handle(TopLoc_Datum3D)& theTrsf,
const Handle(OpenGl_Context)& theGlContext)
{
OpenGl_Mat4 aMat4;
Prs3d_ArrowAspect.hxx
Prs3d_BasicAspect.cxx
Prs3d_BasicAspect.hxx
+Prs3d_BndBox.cxx
+Prs3d_BndBox.hxx
Prs3d_DatumAspect.cxx
Prs3d_DatumAspect.hxx
Prs3d_DatumAttribute.hxx
Prs3d_Root.hxx
Prs3d_ShadingAspect.cxx
Prs3d_ShadingAspect.hxx
-Prs3d_ShapeTool.cxx
Prs3d_ShapeTool.hxx
Prs3d_Text.cxx
Prs3d_Text.hxx
#include <Prs3d.hxx>
-#include <Bnd_Box.hxx>
-#include <BRepBndLib.hxx>
#include <gp_Pnt.hxx>
+#include <Graphic3d_ArrayOfSegments.hxx>
#include <Graphic3d_Group.hxx>
-#include <Prs3d_Drawer.hxx>
+#include <Poly_Connect.hxx>
+#include <Poly_Triangulation.hxx>
#include <Prs3d_LineAspect.hxx>
-#include <Prs3d_Root.hxx>
-#include <TopoDS_Shape.hxx>
-#include <Graphic3d_ArrayOfSegments.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
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:
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);
}
#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
//! 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
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
--- /dev/null
+// 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));
+ }
+}
--- /dev/null
+// 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__
+++ /dev/null
-// 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);
-}
#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
#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.
#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.
#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
#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.
#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.
//Creation of 2 sensitive circles
// the greater
gp_Ax2 ax(myCenter, myDir);
- Handle(Geom_Circle) Circ = new Geom_Circle(ax, myRad) ;
- Handle(Select3D_SensitiveCircle)
- sensit = new Select3D_SensitiveCircle (own,
- Circ);
+ gp_Circ aCirc (ax, myRad);
+ Handle(Select3D_SensitiveCircle) sensit = new Select3D_SensitiveCircle (own, aCirc);
aSelection->Add(sensit);
// the smaller
- Circ->SetRadius(myRad/2);
- sensit = new Select3D_SensitiveCircle (own,
- Circ);
+ aCirc.SetRadius(myRad/2);
+ sensit = new Select3D_SensitiveCircle (own, aCirc);
aSelection->Add(sensit);
//Creation of 2 segments sensitive for the cross
#include <GC_MakeCircle.hxx>
#include <Geom_Line.hxx>
#include <GeomAdaptor_Curve.hxx>
-#include <Geom_Circle.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <gce_MakeDir.hxx>
#include <gce_MakeLin.hxx>
{
gp_Circ aTextGeom (aTextAxes, mySelToleranceForText2d != 0.0
? mySelToleranceForText2d : 1.0);
-
- Handle(Geom_Circle) aSensGeom = new Geom_Circle (aTextGeom);
-
- aTextSensitive = new Select3D_SensitiveCircle (aSensitiveOwner, aSensGeom, Standard_True);
+ aTextSensitive = new Select3D_SensitiveCircle (aSensitiveOwner, aTextGeom, Standard_True);
}
theSelection->Add (aTextSensitive);
Standard_Real FirstPar = ElCLib::Parameter(aCircle->Circ(), myAttachPoint1),
LastPar = ElCLib::Parameter(aCircle->Circ(), myPoint1);
if (LastPar < FirstPar ) LastPar+=M_PI*2;
- //add sensetive arc
- Handle(Select3D_SensitiveCircle) circ =
- new Select3D_SensitiveCircle( own, aCircle, FirstPar, LastPar);
+ Handle(Select3D_SensitiveCircle) circ = new Select3D_SensitiveCircle (own, aCircle->Circ(), FirstPar, LastPar);
aSelection->Add( circ );
}
}
Standard_Real FirstPar = ElCLib::Parameter(aCircle->Circ(), myAttachPoint2),
LastPar = ElCLib::Parameter(aCircle->Circ(), myPoint2);
if (LastPar < FirstPar ) LastPar+=M_PI*2;
- //add sensetive arc
- Handle(Select3D_SensitiveCircle) circ =
- new Select3D_SensitiveCircle( own,aCircle, FirstPar, LastPar);
+ Handle(Select3D_SensitiveCircle) circ = new Select3D_SensitiveCircle (own, aCircle->Circ(), FirstPar, LastPar);
aSelection->Add( circ );
}
}
Standard_Real FirstPar = ElCLib::Parameter(aCircle->Circ(), myAttachPoint3),
LastPar = ElCLib::Parameter(aCircle->Circ(), myPoint3);
if (LastPar < FirstPar ) LastPar+=M_PI*2;
- Handle(Select3D_SensitiveCircle) circ =
- new Select3D_SensitiveCircle( own, aCircle, FirstPar, LastPar);
+ Handle(Select3D_SensitiveCircle) circ = new Select3D_SensitiveCircle (own, aCircle->Circ(), FirstPar, LastPar);
aSelection->Add( circ );
}
else {
Standard_Real FirstPar = ElCLib::Parameter(aCircle->Circ(), myAttachPoint4),
LastPar = ElCLib::Parameter(aCircle->Circ(), myPoint4);
if (LastPar < FirstPar ) LastPar+=M_PI*2;
- //add sensetive arc
- Handle(Select3D_SensitiveCircle) circ =
- new Select3D_SensitiveCircle( own,aCircle, FirstPar, LastPar);
+ Handle(Select3D_SensitiveCircle) circ = new Select3D_SensitiveCircle (own, aCircle->Circ(), FirstPar, LastPar);
aSelection->Add( circ );
}
}
for (PrsMgr_ListOfPresentableObjectsIter anIter (myChildren); anIter.More(); anIter.Next())
{
- anIter.Value()->SetCombinedParentTransform (Handle(Geom_Transformation)());
+ anIter.Value()->SetCombinedParentTransform (Handle(TopLoc_Datum3D)());
anIter.Value()->myParent = NULL;
}
}
//purpose :
//=======================================================================
void PrsMgr_PresentableObject::computeHLR (const Handle(Graphic3d_Camera)& ,
- const Handle(Geom_Transformation)& ,
+ const Handle(TopLoc_Datum3D)& ,
const Handle(Prs3d_Presentation)& )
{
throw Standard_NotImplemented("cannot compute under a specific projector");
//function : setLocalTransformation
//purpose :
//=======================================================================
-void PrsMgr_PresentableObject::setLocalTransformation (const Handle(Geom_Transformation)& theTransformation)
+void PrsMgr_PresentableObject::setLocalTransformation (const Handle(TopLoc_Datum3D)& theTransformation)
{
myLocalTransformation = theTransformation;
UpdateTransformation();
//=======================================================================
void PrsMgr_PresentableObject::ResetTransformation()
{
- setLocalTransformation (Handle(Geom_Transformation)());
+ setLocalTransformation (Handle(TopLoc_Datum3D)());
}
//=======================================================================
//function : SetCombinedParentTransform
//purpose :
//=======================================================================
-void PrsMgr_PresentableObject::SetCombinedParentTransform (const Handle(Geom_Transformation)& theTrsf)
+void PrsMgr_PresentableObject::SetCombinedParentTransform (const Handle(TopLoc_Datum3D)& theTrsf)
{
myCombinedParentTransform = theTrsf;
UpdateTransformation();
if (!myLocalTransformation.IsNull() && myLocalTransformation->Form() != gp_Identity)
{
const gp_Trsf aTrsf = myCombinedParentTransform->Trsf() * myLocalTransformation->Trsf();
- myTransformation = new Geom_Transformation (aTrsf);
+ myTransformation = new TopLoc_Datum3D (aTrsf);
myInvTransformation = aTrsf.Inverted();
}
else
if (anIter.Value() == theObject)
{
theObject->myParent = NULL;
- theObject->SetCombinedParentTransform (Handle(Geom_Transformation)());
+ theObject->SetCombinedParentTransform (Handle(TopLoc_Datum3D)());
myChildren.Remove (anIter);
break;
}
//! Return the local transformation.
//! Note that the local transformation of the object having Transformation Persistence
//! is applied within Local Coordinate system defined by this Persistence.
- const Handle(Geom_Transformation)& LocalTransformationGeom() const { return myLocalTransformation; }
+ const Handle(TopLoc_Datum3D)& LocalTransformationGeom() const { return myLocalTransformation; }
//! Sets local transformation to theTransformation.
//! Note that the local transformation of the object having Transformation Persistence
//! is applied within Local Coordinate system defined by this Persistence.
- void SetLocalTransformation (const gp_Trsf& theTrsf) { setLocalTransformation (new Geom_Transformation (theTrsf)); }
+ void SetLocalTransformation (const gp_Trsf& theTrsf) { setLocalTransformation (new TopLoc_Datum3D (theTrsf)); }
//! Sets local transformation to theTransformation.
//! Note that the local transformation of the object having Transformation Persistence
//! is applied within Local Coordinate system defined by this Persistence.
- void SetLocalTransformation (const Handle(Geom_Transformation)& theTrsf) { setLocalTransformation (theTrsf); }
+ void SetLocalTransformation (const Handle(TopLoc_Datum3D)& theTrsf) { setLocalTransformation (theTrsf); }
//! Returns true if object has a transformation that is different from the identity.
Standard_Boolean HasTransformation() const { return !myTransformation.IsNull() && myTransformation->Form() != gp_Identity; }
//! Return the transformation taking into account transformation of parent object(s).
//! Note that the local transformation of the object having Transformation Persistence
//! is applied within Local Coordinate system defined by this Persistence.
- const Handle(Geom_Transformation)& TransformationGeom() const { return myTransformation; }
+ const Handle(TopLoc_Datum3D)& TransformationGeom() const { return myTransformation; }
//! Return the local transformation.
//! Note that the local transformation of the object having Transformation Persistence
const gp_GTrsf& InversedTransformation() const { return myInvTransformation; }
//! Return combined parent transformation.
- const Handle(Geom_Transformation)& CombinedParentTransformation() const { return myCombinedParentTransform; }
+ const Handle(TopLoc_Datum3D)& CombinedParentTransformation() const { return myCombinedParentTransform; }
//! resets local transformation to identity.
Standard_EXPORT virtual void ResetTransformation();
//! @param theTrsf [in] additional transformation, or NULL if undefined
//! @param thePrs [in] presentation to fill
Standard_EXPORT virtual void computeHLR (const Handle(Graphic3d_Camera)& theProjector,
- const Handle(Geom_Transformation)& theTrsf,
+ const Handle(TopLoc_Datum3D)& theTrsf,
const Handle(Prs3d_Presentation)& thePrs);
//! Recomputes invalidated presentations of the object.
//! Sets myCombinedParentTransform to theTransformation. Thus object receives transformation
//! from parent node and able to derive its own.
- Standard_EXPORT virtual void SetCombinedParentTransform (const Handle(Geom_Transformation)& theTrsf);
+ Standard_EXPORT virtual void SetCombinedParentTransform (const Handle(TopLoc_Datum3D)& theTrsf);
//! Sets local transformation to theTransformation.
- Standard_EXPORT virtual void setLocalTransformation (const Handle(Geom_Transformation)& theTransformation);
+ Standard_EXPORT virtual void setLocalTransformation (const Handle(TopLoc_Datum3D)& theTransformation);
//! Return the identity transformation.
Standard_EXPORT static const gp_Trsf& getIdentityTrsf();
Handle(Prs3d_Drawer) myHilightDrawer; //!< (optional) custom presentation attributes for highlighting selected object
Handle(Prs3d_Drawer) myDynHilightDrawer; //!< (optional) custom presentation attributes for highlighting detected object
Handle(Graphic3d_TransformPers) myTransformPersistence; //!< transformation persistence
- Handle(Geom_Transformation) myLocalTransformation; //!< local transformation relative to parent object
- Handle(Geom_Transformation) myTransformation; //!< absolute transformation of this object (combined parents + local transformations)
- Handle(Geom_Transformation) myCombinedParentTransform; //!< transformation of parent object (combined for all parents)
+ Handle(TopLoc_Datum3D) myLocalTransformation; //!< local transformation relative to parent object
+ Handle(TopLoc_Datum3D) myTransformation; //!< absolute transformation of this object (combined parents + local transformations)
+ Handle(TopLoc_Datum3D) myCombinedParentTransform; //!< transformation of parent object (combined for all parents)
PrsMgr_ListOfPresentableObjects myChildren; //!< list of children
gp_GTrsf myInvTransformation; //!< inversion of absolute transformation (combined parents + local transformations)
PrsMgr_TypeOfPresentation3d myTypeOfPresentation3d; //!< presentation type
#include <PrsMgr_Presentation.hxx>
-#include <Geom_Transformation.hxx>
#include <Graphic3d_DataStructureManager.hxx>
#include <Precision.hxx>
#include <Prs3d_Drawer.hxx>
class PrsMgr_PresentableObject;
class Quantity_Color;
class Graphic3d_Camera;
-class Geom_Transformation;
class Prs3d_Drawer;
class Graphic3d_Structure;
class Graphic3d_DataStructureManager;
#include <PrsMgr_PresentationManager.hxx>
-#include <Geom_Transformation.hxx>
+#include <TopLoc_Datum3D.hxx>
#include <Graphic3d_GraphicDriver.hxx>
#include <Prs3d_Drawer.hxx>
#include <Prs3d_Presentation.hxx>
// purpose :
// =======================================================================
void PrsMgr_PresentationManager::Transform (const Handle(PrsMgr_PresentableObject)& thePrsObj,
- const Handle(Geom_Transformation)& theTransformation,
- const Standard_Integer theMode)
+ const Handle(TopLoc_Datum3D)& theTransformation,
+ const Standard_Integer theMode)
{
Presentation (thePrsObj, theMode)->SetTransformation (theTransformation);
}
namespace
{
- // =======================================================================
- // function : updatePrsTransformation
- // purpose : Internal function that scans thePrsList for shadow presentations
- // and applies transformation theTrsf to them in case if parent ID
- // of shadow presentation is equal to theRefId
- // =======================================================================
- void updatePrsTransformation (const PrsMgr_ListOfPresentations& thePrsList,
- const Standard_Integer theRefId,
- const Handle(Geom_Transformation)& theTrsf)
+ //! Internal function that scans thePrsList for shadow presentations
+ //! and applies transformation theTrsf to them in case if parent ID
+ //! of shadow presentation is equal to theRefId
+ static void updatePrsTransformation (const PrsMgr_ListOfPresentations& thePrsList,
+ const Standard_Integer theRefId,
+ const Handle(TopLoc_Datum3D)& theTrsf)
{
for (PrsMgr_ListOfPresentations::Iterator anIter (thePrsList); anIter.More(); anIter.Next())
{
return;
}
- Handle(Geom_Transformation) aTrsf = theObj->LocalTransformationGeom();
+ Handle(TopLoc_Datum3D) aTrsf = theObj->LocalTransformationGeom();
const Standard_Integer aParentId = aPrs->CStructure()->Id;
updatePrsTransformation (myImmediateList, aParentId, aTrsf);
class Graphic3d_Structure;
typedef Graphic3d_Structure Prs3d_Presentation;
-class Geom_Transformation;
+class TopLoc_Datum3D;
class Prs3d_Drawer;
class PrsMgr_Presentation;
class PrsMgr_PresentableObject;
//! Sets the transformation theTransformation for the presentable object thePrsObject.
//! thePrsObject has the display mode theMode; this has the default value of 0, that is, the wireframe display mode.
- Standard_EXPORT void Transform (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Handle(Geom_Transformation)& theTransformation, const Standard_Integer theMode = 0);
+ Standard_EXPORT void Transform (const Handle(PrsMgr_PresentableObject)& thePrsObject,
+ const Handle(TopLoc_Datum3D)& theTransformation,
+ const Standard_Integer theMode = 0);
//! Returns the structure manager.
const Handle(Graphic3d_StructureManager)& StructureManager() const { return myStructureManager; }
#include <TopoDS_Compound.hxx>
#include <TopoDS_CompSolid.hxx>
-#include <StdSelect_ShapeTypeFilter.hxx>
#include <HLRAlgo_Projector.hxx>
#include <Standard_ErrorHandler.hxx>
#include <Font_NameOfFont.hxx>
#include <Select3D_SensitiveCircle.hxx>
-#include <Geom_Circle.hxx>
+#include <ElCLib.hxx>
#include <Precision.hxx>
#include <Select3D_SensitiveTriangle.hxx>
namespace
{
- static Standard_Integer GetCircleNbPoints (const Handle(Geom_Circle)& theCircle,
+ static Standard_Integer GetCircleNbPoints (const gp_Circ& theCircle,
const Standard_Integer theNbPnts)
{
// Check if number of points is invalid.
if (theNbPnts <= 0)
return 0;
- if (theCircle->Radius() > Precision::Confusion())
+ if (theCircle.Radius() > Precision::Confusion())
return 2 * theNbPnts + 1;
// The radius is too small and circle degenerates into point
return 1;
}
- static Standard_Integer GetArcNbPoints (const Handle(Geom_Circle)& theCircle,
- const Standard_Integer theNbPnts)
+ //! Definition of circle polyline
+ static void initCircle (Select3D_PointData& thePolygon,
+ const gp_Circ& theCircle,
+ const Standard_Real theU1,
+ const Standard_Real theU2,
+ const Standard_Integer theNbPnts)
{
- // There is no need to check number of points here.
- // In case of invalid number of points this method returns
- // -1 or smaller value.
- if (theCircle->Radius() > Precision::Confusion())
- return 2 * theNbPnts - 1;
+ const Standard_Real aStep = (theU2 - theU1) / theNbPnts;
+ const Standard_Real aRadius = theCircle.Radius();
+ Standard_Integer aPntIdx = 0;
+ Standard_Real aCurU = theU1;
+ gp_Pnt aP1;
+ gp_Vec aV1;
+ for (Standard_Integer anIndex = 1; anIndex <= theNbPnts; ++anIndex, aCurU += aStep)
+ {
+ ElCLib::CircleD1 (aCurU, theCircle.Position(), theCircle.Radius(), aP1, aV1);
+ thePolygon.SetPnt (aPntIdx++, aP1);
- // The radius is too small and circle degenerates into point
- return 1;
+ aV1.Normalize();
+ const gp_Pnt aP2 = aP1.XYZ() + aV1.XYZ() * Tan (aStep * 0.5) * aRadius;
+ thePolygon.SetPnt (aPntIdx++, aP2);
+ }
+ aP1 = ElCLib::CircleValue (theU2, theCircle.Position(), theCircle.Radius());
+ thePolygon.SetPnt (theNbPnts * 2, aP1);
}
}
//purpose : Definition of a sensitive circle
//=======================================================================
Select3D_SensitiveCircle::Select3D_SensitiveCircle(const Handle(SelectMgr_EntityOwner)& theOwnerId,
- const Handle(Geom_Circle)& theCircle,
+ const gp_Circ& theCircle,
const Standard_Boolean theIsFilled,
const Standard_Integer theNbPnts)
: Select3D_SensitivePoly (theOwnerId, !theIsFilled, GetCircleNbPoints (theCircle, theNbPnts)),
myCircle (theCircle),
- myStart (0),
- myEnd (0)
+ myStart (0.0),
+ myEnd (2.0 * M_PI)
{
mySensType = theIsFilled ? Select3D_TOS_INTERIOR : Select3D_TOS_BOUNDARY;
+ myCenter3D = theCircle.Position().Location();
if (myPolyg.Size() != 1)
{
- gp_Pnt aP1, aP2;
- gp_Vec aV1;
- Standard_Real anUStart = theCircle->FirstParameter();
- Standard_Real anUEnd = theCircle->LastParameter();
- Standard_Real aStep = (anUEnd - anUStart) / theNbPnts;
- Standard_Real aRadius = theCircle->Radius();
- Standard_Integer aPntIdx = 1;
- Standard_Real aCurU = anUStart;
- for (Standard_Integer anIndex = 1; anIndex <= theNbPnts; anIndex++)
- {
- theCircle->D1 (aCurU, aP1, aV1);
-
- aV1.Normalize();
- myPolyg.SetPnt (aPntIdx - 1, aP1);
- aPntIdx++;
- aP2 = gp_Pnt (aP1.X() + aV1.X() * tan (aStep / 2.0) * aRadius,
- aP1.Y() + aV1.Y() * tan (aStep / 2.0) * aRadius,
- aP1.Z() + aV1.Z() * tan (aStep / 2.0) * aRadius);
- myPolyg.SetPnt (aPntIdx - 1, aP2);
- aPntIdx++;
- aCurU += aStep;
- }
-
- // Copy the first point to the last point of myPolyg
- myPolyg.SetPnt (theNbPnts * 2, myPolyg.Pnt (0));
- // Get myCenter3D
- myCenter3D = theCircle->Location();
+ initCircle (myPolyg, theCircle, myStart, myEnd, theNbPnts);
}
// Radius = 0.0
else
{
- myPolyg.SetPnt (0, theCircle->Location());
- // Get myCenter3D
- myCenter3D = myPolyg.Pnt (0);
+ myPolyg.SetPnt (0, theCircle.Position().Location());
}
if (mySensType == Select3D_TOS_BOUNDARY)
//purpose : Definition of a sensitive arc
//=======================================================================
Select3D_SensitiveCircle::Select3D_SensitiveCircle (const Handle(SelectMgr_EntityOwner)& theOwnerId,
- const Handle(Geom_Circle)& theCircle,
+ const gp_Circ& theCircle,
const Standard_Real theU1,
const Standard_Real theU2,
const Standard_Boolean theIsFilled,
const Standard_Integer theNbPnts)
-: Select3D_SensitivePoly (theOwnerId, !theIsFilled, GetArcNbPoints (theCircle, theNbPnts)),
+: Select3D_SensitivePoly (theOwnerId, !theIsFilled, GetCircleNbPoints (theCircle, theNbPnts)),
myCircle (theCircle),
myStart (Min (theU1, theU2)),
myEnd (Max (theU1, theU2))
{
mySensType = theIsFilled ? Select3D_TOS_INTERIOR : Select3D_TOS_BOUNDARY;
-
+ myCenter3D = theCircle.Position().Location();
if (myPolyg.Size() != 1)
{
- gp_Pnt aP1, aP2;
- gp_Vec aV1;
-
- Standard_Real aStep = (myEnd - myStart) / (theNbPnts - 1);
- Standard_Real aRadius = theCircle->Radius();
- Standard_Integer aPntIdx = 1;
- Standard_Real aCurU = myStart;
-
- for (Standard_Integer anIndex = 1; anIndex <= theNbPnts - 1; anIndex++)
- {
- theCircle->D1 (aCurU, aP1, aV1);
- aV1.Normalize();
- myPolyg.SetPnt (aPntIdx - 1, aP1);
- aPntIdx++;
- aP2 = gp_Pnt (aP1.X() + aV1.X() * tan (aStep /2.0) * aRadius,
- aP1.Y() + aV1.Y() * tan (aStep /2.0) * aRadius,
- aP1.Z() + aV1.Z() * tan (aStep /2.0) * aRadius);
- myPolyg.SetPnt (aPntIdx - 1, aP2);
- aPntIdx++;
- aCurU += aStep;
- }
- theCircle->D0 (myEnd, aP1);
- myPolyg.SetPnt (theNbPnts * 2 - 2, aP1);
- // Get myCenter3D
- myCenter3D = theCircle->Location();
+ initCircle (myPolyg, theCircle, myStart, myEnd, theNbPnts);
}
else
{
- myPolyg.SetPnt (0, theCircle->Location());
- // Get myCenter3D
- myCenter3D = myPolyg.Pnt (0);
+ myPolyg.SetPnt (0, theCircle.Position().Location());
}
if (mySensType == Select3D_TOS_BOUNDARY)
return Standard_True;
}
-void Select3D_SensitiveCircle::ArrayBounds (Standard_Integer & theLow,
- Standard_Integer & theUp) const
-{
- theLow = 0;
- theUp = myPolyg.Size() - 1;
-}
-
-//=======================================================================
-//function : GetPoint3d
-//purpose :
-//=======================================================================
-gp_Pnt Select3D_SensitiveCircle::GetPoint3d (const Standard_Integer thePntIdx) const
-{
- if (thePntIdx >= 0 && thePntIdx < myPolyg.Size())
- return myPolyg.Pnt (thePntIdx);
-
- return gp_Pnt();
-}
-
//=======================================================================
//function : GetConnected
//purpose :
// Create a copy of this
Handle(Select3D_SensitiveEntity) aNewEntity;
// this was constructed using Handle(Geom_Circle)
- if(!myCircle.IsNull())
+ if (!Precision::IsInfinite (myCircle.Radius()))
{
if ((myEnd - myStart) > Precision::Confusion())
{
#ifndef _Select3D_SensitiveCircle_HeaderFile
#define _Select3D_SensitiveCircle_HeaderFile
+#include <gp_Circ.hxx>
#include <Select3D_SensitivePoly.hxx>
-#include <TColgp_HArray1OfPnt.hxx>
-#include <SelectMgr_SelectingVolumeManager.hxx>
#include <Select3D_TypeOfSensitivity.hxx>
-
-class Geom_Circle;
-class Standard_ConstructionError;
-class Standard_OutOfRange;
+#include <SelectMgr_SelectingVolumeManager.hxx>
+#include <TColgp_HArray1OfPnt.hxx>
//! A framework to define sensitive 3D arcs and circles.
//! In some cases this class can raise Standard_ConstructionError and
//! owner theOwnerId, the circle theCircle, the boolean
//! theIsFilled and the number of points theNbPnts.
Standard_EXPORT Select3D_SensitiveCircle (const Handle(SelectMgr_EntityOwner)& theOwnerId,
- const Handle(Geom_Circle)& theCircle,
+ const gp_Circ& theCircle,
const Standard_Boolean theIsFilled = Standard_False,
const Standard_Integer theNbPnts = 12);
//! and theU2, the boolean theIsFilled and the number of points theNbPnts.
//! theU1 and theU2 define the first and last points of the arc on theCircle.
Standard_EXPORT Select3D_SensitiveCircle (const Handle(SelectMgr_EntityOwner)& theOwnerId,
- const Handle(Geom_Circle)& theCircle,
+ const gp_Circ& theCircle,
const Standard_Real theU1,
const Standard_Real theU2,
const Standard_Boolean theIsFilled = Standard_False,
Standard_EXPORT virtual Standard_Boolean Matches (SelectBasics_SelectingVolumeManager& theMgr,
SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
-
- Standard_EXPORT void ArrayBounds (Standard_Integer & theLow, Standard_Integer & theUp) const;
-
- Standard_EXPORT gp_Pnt GetPoint3d (const Standard_Integer thePntIdx) const;
-
Standard_EXPORT virtual Handle(Select3D_SensitiveEntity) GetConnected() Standard_OVERRIDE;
//! Returns center of the circle. If location
Select3D_TypeOfSensitivity mySensType; //!< True if type of selection is interior, false otherwise
gp_Pnt myCenter3D; //!< Center of a circle
- Handle(Geom_Circle) myCircle; //!< Points of the circle
+ gp_Circ myCircle; //!< Points of the circle
Standard_Real myStart; //!< Sensitive arc parameter
Standard_Real myEnd; //!< Sensitive arc parameter
};
// commercial license or contractual agreement.
#include <Select3D_SensitiveCurve.hxx>
+
#include <Precision.hxx>
#include <TColgp_Array1OfPnt.hxx>
-
IMPLEMENT_STANDARD_RTTIEXT(Select3D_SensitiveCurve,Select3D_SensitivePoly)
-//==================================================
-// Function: Creation
-// Purpose :
-//==================================================
-Select3D_SensitiveCurve::Select3D_SensitiveCurve (const Handle(SelectMgr_EntityOwner)& theOwnerId,
- const Handle(Geom_Curve)& theCurve,
- const Standard_Integer theNbPnts)
-: Select3D_SensitivePoly (theOwnerId, Standard_True, theNbPnts),
- myCurve (theCurve)
-{
- loadPoints (theCurve, theNbPnts);
- SetSensitivityFactor (3);
-}
-
//==================================================
// Function: Creation
// Purpose :
SetSensitivityFactor (3);
}
-//==================================================
-// Function: loadPoints
-// Purpose :
-//==================================================
-void Select3D_SensitiveCurve::loadPoints (const Handle(Geom_Curve)& theCurve, const Standard_Integer theNbPnts)
-{
- Standard_Real aStep = (theCurve->LastParameter() - theCurve->FirstParameter()) / (theNbPnts - 1);
- Standard_Real aParam = theCurve->FirstParameter();
- for (Standard_Integer aPntIdx = 0; aPntIdx < myPolyg.Size(); ++aPntIdx)
- {
- myPolyg.SetPnt (aPntIdx, theCurve->Value (aParam));
- aParam += aStep;
- }
-}
-
//=======================================================================
//function : GetConnected
//purpose :
//=======================================================================
Handle(Select3D_SensitiveEntity) Select3D_SensitiveCurve::GetConnected()
{
- // Create a copy of this
- Handle(Select3D_SensitiveEntity) aNewEntity;
- // this was constructed using Handle(Geom_Curve)
- if (!myCurve.IsNull())
- {
- aNewEntity = new Select3D_SensitiveCurve (myOwnerId, myCurve);
- }
- // this was constructed using TColgp_HArray1OfPnt
- else
+ Handle(TColgp_HArray1OfPnt) aPoints = new TColgp_HArray1OfPnt (1, myPolyg.Size());
+ for (Standard_Integer anIndex = 1; anIndex <= myPolyg.Size(); ++anIndex)
{
- Standard_Integer aSize = myPolyg.Size();
- Handle(TColgp_HArray1OfPnt) aPoints = new TColgp_HArray1OfPnt (1, aSize);
- // Fill the array with points from mypolyg3d
- for (Standard_Integer anIndex = 1; anIndex <= aSize; ++anIndex)
- {
- aPoints->SetValue (anIndex, myPolyg.Pnt (anIndex-1));
- }
- aNewEntity = new Select3D_SensitiveCurve (myOwnerId, aPoints);
+ aPoints->SetValue (anIndex, myPolyg.Pnt (anIndex-1));
}
-
+ Handle(Select3D_SensitiveEntity) aNewEntity = new Select3D_SensitiveCurve (myOwnerId, aPoints);
return aNewEntity;
-}
\ No newline at end of file
+}
//! Constructs a sensitive curve object defined by the
//! owner theOwnerId, the curve theCurve, and the
//! maximum number of points on the curve: theNbPnts.
- Standard_EXPORT Select3D_SensitiveCurve (const Handle(SelectMgr_EntityOwner)& theOwnerId,
- const Handle(Geom_Curve)& theCurve,
- const Standard_Integer theNbPnts = 17);
+ Select3D_SensitiveCurve (const Handle(SelectMgr_EntityOwner)& theOwnerId,
+ const Handle(Geom_Curve)& theCurve,
+ const Standard_Integer theNbPnts = 17)
+ : Select3D_SensitivePoly (theOwnerId, Standard_True, theNbPnts)
+ {
+ loadPoints (theCurve, theNbPnts);
+ mySFactor = 3;
+ }
//! Constructs a sensitive curve object defined by the
//! owner theOwnerId and the set of points ThePoints.
private:
- void loadPoints (const Handle(Geom_Curve)& aCurve,
- const Standard_Integer NbPoints);
-
-private:
+ void loadPoints (const Handle(Geom_Curve)& theCurve,
+ const Standard_Integer theNbPnts)
+ {
+ const Standard_Real aStep = (theCurve->LastParameter() - theCurve->FirstParameter()) / (theNbPnts - 1);
+ Standard_Real aParam = theCurve->FirstParameter();
+ for (Standard_Integer aPntIdx = 0; aPntIdx < myPolyg.Size(); ++aPntIdx)
+ {
+ myPolyg.SetPnt (aPntIdx, theCurve->Value (aParam));
+ aParam += aStep;
+ }
+ }
- Handle(Geom_Curve) myCurve; //!< Curve points
};
DEFINE_STANDARD_HANDLE(Select3D_SensitiveCurve, Select3D_SensitivePoly)
}
}
+ //! Return array bounds.
+ void ArrayBounds (Standard_Integer& theLow,
+ Standard_Integer& theUp) const
+ {
+ theLow = 0;
+ theUp = myPolyg.Size() - 1;
+ }
+
+ //! Return point.
+ gp_Pnt GetPoint3d (const Standard_Integer thePntIdx) const
+ {
+ return (thePntIdx >= 0 && thePntIdx < myPolyg.Size())
+ ? myPolyg.Pnt (thePntIdx)
+ : gp_Pnt();
+ }
+
//! Returns bounding box of a polygon. If location
//! transformation is set, it will be applied
Standard_EXPORT virtual Select3D_BndBox3d BoundingBox() Standard_OVERRIDE;
+SelectMgr.cxx
+SelectMgr.hxx
SelectMgr_AndFilter.cxx
SelectMgr_AndFilter.hxx
SelectMgr_BaseFrustum.cxx
SelectMgr_SelectingVolumeManager.hxx
SelectMgr_Selection.cxx
SelectMgr_Selection.hxx
+SelectMgr_SelectionImageFiller.cxx
+SelectMgr_SelectionImageFiller.hxx
SelectMgr_SelectionManager.cxx
SelectMgr_SelectionManager.hxx
SelectMgr_SensitiveEntity.cxx
SelectMgr_SequenceOfFilter.hxx
SelectMgr_SequenceOfOwner.hxx
SelectMgr_SequenceOfSelection.hxx
-SelectMgr_SOPtr.hxx
SelectMgr_SortCriterion.hxx
SelectMgr_StateOfSelection.hxx
SelectMgr_ToleranceMap.hxx
SelectMgr_ViewClipRange.hxx
SelectMgr_ViewerSelector.cxx
SelectMgr_ViewerSelector.hxx
+SelectMgr_ViewerSelector3d.cxx
+SelectMgr_ViewerSelector3d.hxx
--- /dev/null
+// Copyright (c) 2020 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 <SelectMgr.hxx>
+
+#include <Graphic3d_ArrayOfPoints.hxx>
+#include <Graphic3d_AspectMarker3d.hxx>
+#include <Graphic3d_Group.hxx>
+#include <Graphic3d_Structure.hxx>
+#include <Poly_Array1OfTriangle.hxx>
+#include <Poly_Triangulation.hxx>
+#include <Prs3d.hxx>
+#include <Prs3d_LineAspect.hxx>
+#include <Prs3d_NListOfSequenceOfPnt.hxx>
+#include <TColgp_HArray1OfPnt.hxx>
+#include <TColgp_SequenceOfPnt.hxx>
+#include <Select3D_SensitiveBox.hxx>
+#include <Select3D_SensitiveEntity.hxx>
+#include <Select3D_SensitiveFace.hxx>
+#include <Select3D_SensitivePoint.hxx>
+#include <Select3D_SensitiveSegment.hxx>
+#include <Select3D_SensitiveTriangle.hxx>
+#include <Select3D_SensitiveTriangulation.hxx>
+#include <Select3D_SensitiveWire.hxx>
+#include <SelectMgr_Selection.hxx>
+
+namespace
+{
+ //! Compute polyline of shrunk triangle.
+ static Handle(TColgp_HSequenceOfPnt) shrunkTriangle (const gp_Pnt* thePnts,
+ const gp_XYZ& theCenter)
+ {
+ const gp_XYZ aV1 = theCenter + (thePnts[0].XYZ() - theCenter) * 0.9;
+ const gp_XYZ aV2 = theCenter + (thePnts[1].XYZ() - theCenter) * 0.9;
+ const gp_XYZ aV3 = theCenter + (thePnts[2].XYZ() - theCenter) * 0.9;
+ Handle(TColgp_HSequenceOfPnt) aPoints = new TColgp_HSequenceOfPnt();
+ aPoints->Append (aV1);
+ aPoints->Append (aV2);
+ aPoints->Append (aV3);
+ aPoints->Append (aV1);
+ return aPoints;
+ }
+
+ //! Fill in triangulation polylines.
+ static void addTriangulation (Prs3d_NListOfSequenceOfPnt& theSeqLines,
+ Prs3d_NListOfSequenceOfPnt& theSeqFree,
+ const Handle(Select3D_SensitiveTriangulation)& theTri,
+ const gp_Trsf& theLoc)
+ {
+ gp_Trsf aTrsf = theLoc;
+ if (theTri->HasInitLocation())
+ {
+ aTrsf = theLoc * theTri->GetInitLocation();
+ }
+ const Handle(Poly_Triangulation)& aPolyTri = theTri->Triangulation();
+ for (Standard_Integer aTriIter = 1; aTriIter <= aPolyTri->NbTriangles(); ++aTriIter)
+ {
+ const Poly_Triangle& aTri = aPolyTri->Triangle (aTriIter);
+ const gp_Pnt aPnts[3] =
+ {
+ aPolyTri->Node (aTri (1)).Transformed (aTrsf),
+ aPolyTri->Node (aTri (2)).Transformed (aTrsf),
+ aPolyTri->Node (aTri (3)).Transformed (aTrsf)
+ };
+ const gp_XYZ aCenter = (aPnts[0].XYZ() + aPnts[1].XYZ() + aPnts[2].XYZ()) / 3.0;
+ theSeqLines.Append (shrunkTriangle (aPnts, aCenter));
+ }
+
+ Handle(TColgp_HSequenceOfPnt) aPoints = new TColgp_HSequenceOfPnt();
+ Prs3d::AddFreeEdges (*aPoints, aPolyTri, aTrsf);
+ if (!aPoints->IsEmpty())
+ {
+ theSeqFree.Append (aPoints);
+ }
+ }
+
+ //! Fill in bounding box polylines.
+ static void addBoundingBox (Prs3d_NListOfSequenceOfPnt& theSeqLines,
+ const Handle(Select3D_SensitiveBox)& theSensBox,
+ const gp_Trsf& theLoc)
+ {
+ Graphic3d_Vec3d aMin, aMax;
+ theSensBox->Box().Get (aMin.x(), aMin.y(), aMin.z(), aMax.x(), aMax.y(), aMax.z());
+ gp_Pnt aPnts[8] =
+ {
+ gp_Pnt(aMin.x(), aMin.y(), aMin.z()),
+ gp_Pnt(aMax.x(), aMin.y(), aMin.z()),
+ gp_Pnt(aMax.x(), aMax.y(), aMin.z()),
+ gp_Pnt(aMin.x(), aMax.y(), aMin.z()),
+ gp_Pnt(aMin.x(), aMin.y(), aMax.z()),
+ gp_Pnt(aMax.x(), aMin.y(), aMax.z()),
+ gp_Pnt(aMax.x(), aMax.y(), aMax.z()),
+ gp_Pnt(aMin.x(), aMax.y(), aMax.z())
+ };
+ for (Standard_Integer aPntIter = 0; aPntIter <= 7; ++aPntIter)
+ {
+ aPnts[aPntIter].Transform (theLoc);
+ }
+
+ {
+ Handle(TColgp_HSequenceOfPnt) aPoints = new TColgp_HSequenceOfPnt();
+ for (Standard_Integer i = 0; i < 4; ++i)
+ {
+ aPoints->Append (aPnts[i]);
+ }
+ aPoints->Append (aPnts[0]);
+ theSeqLines.Append (aPoints);
+ }
+ {
+ Handle(TColgp_HSequenceOfPnt) aPoints = new TColgp_HSequenceOfPnt();
+ for (Standard_Integer i = 4; i < 8; i++)
+ {
+ aPoints->Append (aPnts[i]);
+ }
+ aPoints->Append (aPnts[4]);
+ theSeqLines.Append (aPoints);
+ }
+ for (Standard_Integer i = 0; i < 4; i++)
+ {
+ Handle(TColgp_HSequenceOfPnt) aPoints = new TColgp_HSequenceOfPnt();
+ aPoints->Append (aPnts[i]);
+ aPoints->Append (aPnts[i+4]);
+ theSeqLines.Append (aPoints);
+ }
+ }
+}
+
+//=======================================================================
+//function : ComputeSensitivePrs
+//purpose :
+//=======================================================================
+void SelectMgr::ComputeSensitivePrs (const Handle(Graphic3d_Structure)& thePrs,
+ const Handle(SelectMgr_Selection)& theSel,
+ const gp_Trsf& theLoc,
+ const Handle(Graphic3d_TransformPers)& theTrsfPers)
+{
+ thePrs->SetTransformPersistence (theTrsfPers);
+
+ Prs3d_NListOfSequenceOfPnt aSeqLines, aSeqFree;
+ TColgp_SequenceOfPnt aSeqPoints;
+ for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (theSel->Entities()); aSelEntIter.More(); aSelEntIter.Next())
+ {
+ const Handle(Select3D_SensitiveEntity)& anEnt = aSelEntIter.Value()->BaseSensitive();
+ if (Handle(Select3D_SensitiveBox) aSensBox = Handle(Select3D_SensitiveBox)::DownCast (anEnt))
+ {
+ addBoundingBox (aSeqLines, aSensBox, theLoc);
+ }
+ else if (Handle(Select3D_SensitiveFace) aFace = Handle(Select3D_SensitiveFace)::DownCast(anEnt))
+ {
+ Handle(TColgp_HArray1OfPnt) aSensPnts;
+ aFace->GetPoints (aSensPnts);
+ Handle(TColgp_HSequenceOfPnt) aPoints = new TColgp_HSequenceOfPnt();
+ for (TColgp_HArray1OfPnt::Iterator aPntIter (*aSensPnts); aPntIter.More(); aPntIter.Next())
+ {
+ aPoints->Append (aPntIter.Value().Transformed (theLoc));
+ }
+ aSeqLines.Append (aPoints);
+ }
+ else if (Handle(Select3D_SensitivePoly) aSensPoly = Handle(Select3D_SensitivePoly)::DownCast (anEnt))
+ {
+ Standard_Integer aFrom = 0, aTo = 0;
+ aSensPoly->ArrayBounds (aFrom, aTo);
+ Handle(TColgp_HSequenceOfPnt) aPoints = new TColgp_HSequenceOfPnt();
+ for (Standard_Integer aPntIter = aFrom; aPntIter <= aTo; ++aPntIter)
+ {
+ aPoints->Append (aSensPoly->GetPoint3d (aPntIter).Transformed (theLoc));
+ }
+ aSeqLines.Append (aPoints);
+ }
+ else if (Handle(Select3D_SensitiveWire) aWire = Handle(Select3D_SensitiveWire)::DownCast(anEnt))
+ {
+ const NCollection_Vector<Handle(Select3D_SensitiveEntity)>& anEntities = aWire->GetEdges();
+ for (NCollection_Vector<Handle(Select3D_SensitiveEntity)>::Iterator aSubIter (anEntities); aSubIter.More(); aSubIter.Next())
+ {
+ const Handle(Select3D_SensitiveEntity)& aSubEnt = aSubIter.Value();
+ if (Handle(Select3D_SensitiveSegment) aSensSeg = Handle(Select3D_SensitiveSegment)::DownCast (aSubEnt))
+ {
+ Handle(TColgp_HSequenceOfPnt) aPoints = new TColgp_HSequenceOfPnt();
+ aPoints->Append (aSensSeg->StartPoint().Transformed (theLoc));
+ aPoints->Append (aSensSeg->EndPoint() .Transformed (theLoc));
+ aSeqLines.Append (aPoints);
+ }
+ else if (Handle(Select3D_SensitivePoly) aSubSensPoly = Handle(Select3D_SensitivePoly)::DownCast (aSubEnt))
+ {
+ Standard_Integer aFrom = 0, aTo = 0;
+ aSubSensPoly->ArrayBounds (aFrom, aTo);
+ Handle(TColgp_HSequenceOfPnt) aPoints = new TColgp_HSequenceOfPnt();
+ for (Standard_Integer aPntIter = aFrom; aPntIter <= aTo; ++aPntIter)
+ {
+ aPoints->Append (aSubSensPoly->GetPoint3d (aPntIter).Transformed (theLoc));
+ }
+ aSeqLines.Append (aPoints);
+ }
+ }
+ }
+ else if (Handle(Select3D_SensitiveSegment) aSensSeg = Handle(Select3D_SensitiveSegment)::DownCast(anEnt))
+ {
+ Handle(TColgp_HSequenceOfPnt) aPoints = new TColgp_HSequenceOfPnt();
+ aPoints->Append (aSensSeg->StartPoint().Transformed (theLoc));
+ aPoints->Append (aSensSeg->EndPoint() .Transformed (theLoc));
+ aSeqLines.Append (aPoints);
+ }
+ else if (Handle(Select3D_SensitivePoint) aSensPnt = Handle(Select3D_SensitivePoint)::DownCast(anEnt))
+ {
+ aSeqPoints.Append (aSensPnt->Point().Transformed (theLoc));
+ }
+ else if (Handle(Select3D_SensitiveTriangulation) aSensTri = Handle(Select3D_SensitiveTriangulation)::DownCast (anEnt))
+ {
+ addTriangulation (aSeqLines, aSeqFree, aSensTri, theLoc);
+ }
+ else if (Handle(Select3D_SensitiveTriangle) aSensTri1 = Handle(Select3D_SensitiveTriangle)::DownCast(anEnt))
+ {
+ gp_Pnt aPnts[3];
+ aSensTri1->Points3D (aPnts[0], aPnts[1], aPnts[2]);
+ aPnts[0].Transform (theLoc);
+ aPnts[1].Transform (theLoc);
+ aPnts[2].Transform (theLoc);
+ aSeqLines.Append (shrunkTriangle (aPnts, aSensTri1->Center3D().XYZ()));
+ }
+ }
+
+ if (!aSeqPoints.IsEmpty())
+ {
+ Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (aSeqPoints.Size());
+ for (TColgp_SequenceOfPnt::Iterator aPntIter (aSeqPoints); aPntIter.More(); aPntIter.Next())
+ {
+ anArrayOfPoints->AddVertex (aPntIter.Value());
+ }
+
+ Handle(Graphic3d_Group) aSensPntGroup = thePrs->NewGroup();
+ aSensPntGroup->SetPrimitivesAspect (new Graphic3d_AspectMarker3d (Aspect_TOM_O_PLUS, Quantity_NOC_INDIANRED3, 2.0));
+ aSensPntGroup->AddPrimitiveArray (anArrayOfPoints);
+ }
+ if (!aSeqLines.IsEmpty())
+ {
+ Prs3d::AddPrimitivesGroup (thePrs, new Prs3d_LineAspect (Quantity_NOC_AQUAMARINE1, Aspect_TOL_DASH, 1.0), aSeqLines);
+ }
+ if (!aSeqFree.IsEmpty())
+ {
+ Prs3d::AddPrimitivesGroup (thePrs, new Prs3d_LineAspect (Quantity_NOC_GREEN, Aspect_TOL_SOLID, 2.0), aSeqFree);
+ }
+}
--- /dev/null
+// Copyright (c) 2020 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 _SelectMgr_HeaderFile
+#define _SelectMgr_HeaderFile
+
+#include <Standard_Type.hxx>
+
+class Graphic3d_Structure;
+class Graphic3d_TransformPers;
+class SelectMgr_Selection;
+class gp_Trsf;
+
+//! Auxiliary tools for SelectMgr package.
+class SelectMgr
+{
+public:
+
+ //! Compute debug presentation for sensitive objects.
+ Standard_EXPORT static void ComputeSensitivePrs (const Handle(Graphic3d_Structure)& theStructure,
+ const Handle(SelectMgr_Selection)& theSel,
+ const gp_Trsf& theLoc,
+ const Handle(Graphic3d_TransformPers)& theTrsfPers);
+
+};
+
+#endif
+++ /dev/null
-// Created on: 1995-02-06
-// Created by: Mister rmi
-// 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.
-
-#ifndef _SelectMgr_SOPtr_HeaderFile
-#define _SelectMgr_SOPtr_HeaderFile
-
-class SelectMgr_SelectableObject;
-typedef SelectMgr_SelectableObject* SelectMgr_SOPtr;
-
-#endif // _SelectMgr_SOPtr_HeaderFile
--- /dev/null
+// Copyright (c) 2020 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 <SelectMgr_SelectionImageFiller.hxx>
+
+#include <SelectMgr_ViewerSelector.hxx>
+
+namespace
+{
+ //! Help class for filling pixel with random color.
+ class GeneratedEntityColorFiller : public SelectMgr_SelectionImageFiller
+ {
+ public:
+ GeneratedEntityColorFiller (Image_PixMap& thePixMap,
+ SelectMgr_ViewerSelector* theSelector)
+ : SelectMgr_SelectionImageFiller (thePixMap, theSelector)
+ {
+ // generate per-entity colors in the order as they have been activated
+ for (SelectMgr_SelectableObjectSet::Iterator anObjIter (theSelector->SelectableObjects()); anObjIter.More(); anObjIter.Next())
+ {
+ const Handle(SelectMgr_SelectableObject)& anObj = anObjIter.Value();
+ for (SelectMgr_SequenceOfSelection::Iterator aSelIter (anObj->Selections()); aSelIter.More(); aSelIter.Next())
+ {
+ const Handle(SelectMgr_Selection)& aSel = aSelIter.Value();
+ for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aSel->Entities()); aSelEntIter.More(); aSelEntIter.Next())
+ {
+ const Handle(SelectMgr_SensitiveEntity)& aSens = aSelEntIter.Value();
+ if (!myMapEntityColors.IsBound (aSens->BaseSensitive()))
+ {
+ Quantity_Color aColor;
+ randomPastelColor (aColor);
+ myMapEntityColors.Bind (aSens->BaseSensitive(), aColor);
+ }
+ }
+ }
+ }
+ }
+
+ virtual void Fill (const Standard_Integer theCol,
+ const Standard_Integer theRow,
+ const Standard_Integer thePicked) Standard_OVERRIDE
+ {
+ if (thePicked < 1
+ || thePicked > myMainSel->NbPicked())
+ {
+ myImage->SetPixelColor (theCol, theRow, Quantity_Color(Quantity_NOC_BLACK));
+ return;
+ }
+
+ const Handle(Select3D_SensitiveEntity)& aPickedEntity = myMainSel->PickedEntity (thePicked);
+ Quantity_Color aColor (Quantity_NOC_BLACK);
+ myMapEntityColors.Find (aPickedEntity, aColor);
+ myImage->SetPixelColor (theCol, theRow, aColor);
+ }
+
+ protected:
+ NCollection_DataMap<Handle(Select3D_SensitiveEntity), Quantity_Color> myMapEntityColors;
+ };
+
+ //! Help class for filling pixel with normalized depth of ray.
+ class NormalizedDepthFiller : public SelectMgr_SelectionImageFiller
+ {
+ public:
+ NormalizedDepthFiller (Image_PixMap& thePixMap,
+ SelectMgr_ViewerSelector* theSelector,
+ const Standard_Boolean theToInverse)
+ : SelectMgr_SelectionImageFiller (thePixMap, theSelector),
+ myDepthMin ( RealLast()),
+ myDepthMax (-RealLast()),
+ myToInverse(theToInverse)
+ {
+ myUnnormImage.InitZero (Image_Format_GrayF, thePixMap.SizeX(), thePixMap.SizeY());
+ }
+
+ //! Accumulate the data.
+ virtual void Fill (const Standard_Integer theCol,
+ const Standard_Integer theRow,
+ const Standard_Integer thePicked) Standard_OVERRIDE
+ {
+ if (myUnnormImage.IsEmpty())
+ {
+ return;
+ }
+
+ if (thePicked < 1
+ || thePicked > myMainSel->NbPicked())
+ {
+ myUnnormImage.ChangeValue<float> (theRow, theCol) = ShortRealLast();
+ return;
+ }
+
+ const SelectMgr_SortCriterion& aSortCriterion = myMainSel->PickedData (thePicked);
+ myUnnormImage.ChangeValue<float> (theRow, theCol) = float(aSortCriterion.Depth);
+ myDepthMin = Min (myDepthMin, aSortCriterion.Depth);
+ myDepthMax = Max (myDepthMax, aSortCriterion.Depth);
+ }
+
+ //! Normalize the depth values.
+ virtual void Flush() Standard_OVERRIDE
+ {
+ float aFrom = 0.0f;
+ float aDelta = 1.0f;
+ if (myDepthMin <= myDepthMax)
+ {
+ aFrom = float(myDepthMin);
+ aDelta = float(myDepthMax) - float(myDepthMin);
+ if (aDelta <= ShortRealEpsilon())
+ {
+ aDelta = 1.0f;
+ }
+ }
+ for (Standard_Size aRowIter = 0; aRowIter < myUnnormImage.SizeY(); ++aRowIter)
+ {
+ for (Standard_Size aColIter = 0; aColIter < myUnnormImage.SizeX(); ++aColIter)
+ {
+ float aDepth = myUnnormImage.Value<float> (aRowIter, aColIter);
+ if (aDepth <= -ShortRealLast()
+ || aDepth >= ShortRealLast())
+ {
+ myImage->SetPixelColor (Standard_Integer(aColIter), Standard_Integer(aRowIter),
+ Quantity_ColorRGBA (0.0f, 0.0f, 0.0f, 1.0f));
+ continue;
+ }
+
+ float aNormDepth = (aDepth - aFrom) / aDelta;
+ if (myToInverse)
+ {
+ aNormDepth = 1.0f - aNormDepth;
+ }
+ myImage->SetPixelColor (Standard_Integer(aColIter), Standard_Integer(aRowIter),
+ Quantity_ColorRGBA (aNormDepth, aNormDepth, aNormDepth, 1.0f));
+ }
+ }
+ }
+
+ private:
+ Image_PixMap myUnnormImage;
+ Standard_Real myDepthMin;
+ Standard_Real myDepthMax;
+ Standard_Boolean myToInverse;
+ };
+
+ //! Help class for filling pixel with unnormalized depth of ray.
+ class UnnormalizedDepthFiller : public SelectMgr_SelectionImageFiller
+ {
+ public:
+ UnnormalizedDepthFiller (Image_PixMap& thePixMap,
+ SelectMgr_ViewerSelector* theSelector)
+ : SelectMgr_SelectionImageFiller (thePixMap, theSelector) {}
+
+ virtual void Fill (const Standard_Integer theCol,
+ const Standard_Integer theRow,
+ const Standard_Integer thePicked) Standard_OVERRIDE
+ {
+ if (thePicked < 1
+ || thePicked > myMainSel->NbPicked())
+ {
+ myImage->SetPixelColor (theCol, theRow, Quantity_ColorRGBA (0.0f, 0.0f, 0.0f, 1.0f));
+ return;
+ }
+
+ const SelectMgr_SortCriterion& aSortCriterion = myMainSel->PickedData (thePicked);
+ const float aDepth = float(aSortCriterion.Depth);
+ myImage->SetPixelColor (theCol, theRow, Quantity_ColorRGBA (Graphic3d_Vec4 (aDepth, aDepth, aDepth, 1.0f)));
+ }
+ };
+
+ //! Help class for filling pixel with color of detected object.
+ class GeneratedOwnerColorFiller : public SelectMgr_SelectionImageFiller
+ {
+ public:
+ GeneratedOwnerColorFiller (Image_PixMap& thePixMap,
+ SelectMgr_ViewerSelector* theSelector)
+ : SelectMgr_SelectionImageFiller (thePixMap, theSelector)
+ {
+ // generate per-owner colors in the order as they have been activated
+ for (SelectMgr_SelectableObjectSet::Iterator anObjIter (theSelector->SelectableObjects()); anObjIter.More(); anObjIter.Next())
+ {
+ const Handle(SelectMgr_SelectableObject)& anObj = anObjIter.Value();
+ for (SelectMgr_SequenceOfSelection::Iterator aSelIter (anObj->Selections()); aSelIter.More(); aSelIter.Next())
+ {
+ const Handle(SelectMgr_Selection)& aSel = aSelIter.Value();
+ for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aSel->Entities()); aSelEntIter.More(); aSelEntIter.Next())
+ {
+ const Handle(SelectMgr_SensitiveEntity)& aSens = aSelEntIter.Value();
+ const Handle(SelectBasics_EntityOwner)& anOwner = aSens->BaseSensitive()->OwnerId();
+ if (!myMapOwnerColors.IsBound (anOwner))
+ {
+ Quantity_Color aColor;
+ randomPastelColor (aColor);
+ myMapOwnerColors.Bind (anOwner, aColor);
+ }
+ }
+ }
+ }
+ }
+
+ virtual void Fill (const Standard_Integer theCol,
+ const Standard_Integer theRow,
+ const Standard_Integer thePicked) Standard_OVERRIDE
+ {
+ if (thePicked < 1
+ || thePicked > myMainSel->NbPicked())
+ {
+ myImage->SetPixelColor (theCol, theRow, Quantity_Color(Quantity_NOC_BLACK));
+ return;
+ }
+
+ const Handle(SelectMgr_EntityOwner)& aPickedOwner = myMainSel->Picked (thePicked);
+ Quantity_Color aColor (Quantity_NOC_BLACK);
+ myMapOwnerColors.Find (aPickedOwner, aColor);
+ myImage->SetPixelColor (theCol, theRow, aColor);
+ }
+
+ protected:
+ NCollection_DataMap<Handle(SelectBasics_EntityOwner), Quantity_Color> myMapOwnerColors;
+ };
+
+ //! Help class for filling pixel with random color for each selection mode.
+ class GeneratedSelModeColorFiller : public SelectMgr_SelectionImageFiller
+ {
+ public:
+ GeneratedSelModeColorFiller (Image_PixMap& thePixMap,
+ SelectMgr_ViewerSelector* theSelector)
+ : SelectMgr_SelectionImageFiller (thePixMap, theSelector)
+ {
+ // generate standard modes in proper order, consider custom objects would use similar scheme
+ myMapSelectionModeColors.Bind ( 0, Quantity_NOC_WHITE); // default (entire object selection)
+ myMapSelectionModeColors.Bind ( 1, Quantity_NOC_YELLOW); // TopAbs_VERTEX
+ myMapSelectionModeColors.Bind ( 2, Quantity_NOC_GREEN); // TopAbs_EDGE
+ myMapSelectionModeColors.Bind ( 3, Quantity_NOC_RED); // TopAbs_WIRE
+ myMapSelectionModeColors.Bind ( 4, Quantity_NOC_BLUE1); // TopAbs_FACE
+ myMapSelectionModeColors.Bind ( 5, Quantity_NOC_CYAN1); // TopAbs_SHELL
+ myMapSelectionModeColors.Bind ( 6, Quantity_NOC_PURPLE); // TopAbs_SOLID
+ myMapSelectionModeColors.Bind ( 7, Quantity_NOC_MAGENTA1); // TopAbs_COMPSOLID
+ myMapSelectionModeColors.Bind ( 8, Quantity_NOC_BROWN); // TopAbs_COMPOUND
+ myMapSelectionModeColors.Bind (0x0010, Quantity_NOC_PINK); // MeshVS_SMF_Volume
+ myMapSelectionModeColors.Bind (0x001E, Quantity_NOC_LIMEGREEN); // MeshVS_SMF_Element
+ myMapSelectionModeColors.Bind (0x001F, Quantity_NOC_DARKOLIVEGREEN); // MeshVS_SMF_All
+ myMapSelectionModeColors.Bind (0x0100, Quantity_NOC_GOLD); // MeshVS_SMF_Group
+ }
+
+ virtual void Fill (const Standard_Integer theCol,
+ const Standard_Integer theRow,
+ const Standard_Integer thePicked) Standard_OVERRIDE
+ {
+ if (thePicked < 1
+ || thePicked > myMainSel->NbPicked())
+ {
+ myImage->SetPixelColor (theCol, theRow, Quantity_Color (Quantity_NOC_BLACK));
+ return;
+ }
+
+ Standard_Integer aSelectionMode = -1;
+ const Handle(SelectMgr_SelectableObject)& aSelectable = myMainSel->Picked (thePicked)->Selectable();
+ const Handle(Select3D_SensitiveEntity)& anEntity = myMainSel->PickedEntity (thePicked);
+ for (SelectMgr_SequenceOfSelection::Iterator aSelIter (aSelectable->Selections()); aSelIter.More(); aSelIter.Next())
+ {
+ const Handle(SelectMgr_Selection)& aSelection = aSelIter.Value();
+ for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aSelection->Entities()); aSelEntIter.More(); aSelEntIter.Next())
+ {
+ if (aSelEntIter.Value()->BaseSensitive() == anEntity)
+ {
+ aSelectionMode = aSelection->Mode();
+ break;
+ }
+ }
+ }
+ if (aSelectionMode == -1)
+ {
+ myImage->SetPixelColor (theCol, theRow, Quantity_Color (Quantity_NOC_BLACK));
+ return;
+ }
+
+ if (!myMapSelectionModeColors.IsBound (aSelectionMode))
+ {
+ Quantity_Color aColor;
+ randomPastelColor (aColor);
+ myMapSelectionModeColors.Bind (aSelectionMode, aColor);
+ }
+
+ const Quantity_Color& aColor = myMapSelectionModeColors.Find (aSelectionMode);
+ myImage->SetPixelColor (theCol, theRow, aColor);
+ }
+
+ protected:
+ NCollection_DataMap<Standard_Integer, Quantity_Color> myMapSelectionModeColors;
+ };
+
+ //! Help class for filling pixel with color of detected shape.
+ class DetectedObjectColorFiller : public SelectMgr_SelectionImageFiller
+ {
+ public:
+ DetectedObjectColorFiller (Image_PixMap& thePixMap,
+ SelectMgr_ViewerSelector* theSelector)
+ : SelectMgr_SelectionImageFiller (thePixMap, theSelector) {}
+
+ virtual void Fill (const Standard_Integer theCol,
+ const Standard_Integer theRow,
+ const Standard_Integer thePicked) Standard_OVERRIDE
+ {
+ Quantity_Color aColor (Quantity_NOC_BLACK);
+ if (thePicked > 0
+ && thePicked <= myMainSel->NbPicked())
+ {
+ const Handle(SelectMgr_SelectableObject)& aSelectable = myMainSel->Picked (thePicked)->Selectable();
+ aColor = aSelectable->Attributes()->Color();
+ }
+ myImage->SetPixelColor (theCol, theRow, aColor);
+ }
+ };
+}
+
+// =======================================================================
+// function : CreateFiller
+// purpose :
+// =======================================================================
+Handle(SelectMgr_SelectionImageFiller) SelectMgr_SelectionImageFiller::CreateFiller (Image_PixMap& thePixMap,
+ SelectMgr_ViewerSelector* theSelector,
+ StdSelect_TypeOfSelectionImage theType)
+{
+ switch (theType)
+ {
+ case StdSelect_TypeOfSelectionImage_NormalizedDepth:
+ case StdSelect_TypeOfSelectionImage_NormalizedDepthInverted:
+ {
+ return new NormalizedDepthFiller (thePixMap, theSelector, theType == StdSelect_TypeOfSelectionImage_NormalizedDepthInverted);
+ }
+ case StdSelect_TypeOfSelectionImage_UnnormalizedDepth:
+ {
+ return new UnnormalizedDepthFiller (thePixMap, theSelector);
+ }
+ case StdSelect_TypeOfSelectionImage_ColoredDetectedObject:
+ {
+ return new DetectedObjectColorFiller (thePixMap, theSelector);
+ }
+ case StdSelect_TypeOfSelectionImage_ColoredEntity:
+ {
+ return new GeneratedEntityColorFiller (thePixMap, theSelector);
+ }
+ case StdSelect_TypeOfSelectionImage_ColoredOwner:
+ {
+ return new GeneratedOwnerColorFiller (thePixMap, theSelector);
+ }
+ case StdSelect_TypeOfSelectionImage_ColoredSelectionMode:
+ {
+ return new GeneratedSelModeColorFiller (thePixMap, theSelector);
+ }
+ }
+ return Handle(SelectMgr_SelectionImageFiller)();
+}
--- /dev/null
+// Copyright (c) 2020 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 _SelectMgr_SelectionImageFiller_HeaderFile
+#define _SelectMgr_SelectionImageFiller_HeaderFile
+
+#include <Image_PixMap.hxx>
+#include <math_BullardGenerator.hxx>
+#include <NCollection_Map.hxx>
+#include <StdSelect_TypeOfSelectionImage.hxx>
+#include <Quantity_ColorHasher.hxx>
+
+class SelectMgr_ViewerSelector;
+
+//! Abstract class for filling pixel with color.
+//! This is internal tool for SelectMgr_ViewerSelector3d::ToPixMap().
+class SelectMgr_SelectionImageFiller : public Standard_Transient
+{
+public:
+ //! Create filler of specified type.
+ static Handle(SelectMgr_SelectionImageFiller) CreateFiller (Image_PixMap& thePixMap,
+ SelectMgr_ViewerSelector* theSelector,
+ StdSelect_TypeOfSelectionImage theType);
+
+public:
+
+ //! Main constructor.
+ SelectMgr_SelectionImageFiller (Image_PixMap& thePixMap,
+ SelectMgr_ViewerSelector* theSelector)
+ : myImage (&thePixMap),
+ myMainSel(theSelector) {}
+
+ //! Fill pixel at specified position.
+ virtual void Fill (const Standard_Integer theCol,
+ const Standard_Integer theRow,
+ const Standard_Integer thePicked) = 0;
+
+ //! Flush results into final image.
+ virtual void Flush() {}
+
+protected:
+
+ //! Find the new unique random color.
+ void randomPastelColor (Quantity_Color& theColor)
+ {
+ for (;;)
+ {
+ nextRandomPastelColor (theColor);
+ if (myUniqueColors.Add (theColor))
+ {
+ return;
+ }
+ }
+ }
+
+ //! Fills the given color as random.
+ void nextRandomPastelColor (Quantity_Color& theColor)
+ {
+ theColor = Quantity_Color (Standard_Real(myBullardGenerator.NextInt() % 256) / 255.0,
+ Standard_Real(myBullardGenerator.NextInt() % 256) / 255.0,
+ Standard_Real(myBullardGenerator.NextInt() % 256) / 255.0,
+ Quantity_TOC_sRGB);
+ }
+
+protected:
+ Image_PixMap* myImage;
+ SelectMgr_ViewerSelector* myMainSel;
+ math_BullardGenerator myBullardGenerator;
+ NCollection_Map<Quantity_Color, Quantity_ColorHasher> myUniqueColors;
+};
+
+#endif
myEntitySetBuilder = new BVH_BinnedBuilder<Standard_Real, 3, 4> (BVH_Constants_LeafNodeSizeSingle, BVH_Constants_MaxTreeDepth, Standard_True);
}
+//=======================================================================
+// Function: SetPixelTolerance
+// Purpose :
+//=======================================================================
+void SelectMgr_ViewerSelector::SetPixelTolerance (const Standard_Integer theTolerance)
+{
+ if (myTolerances.Tolerance() == theTolerance)
+ {
+ return;
+ }
+
+ myToUpdateTolerance = Standard_True;
+ if (theTolerance < 0)
+ {
+ myTolerances.ResetDefaults();
+ }
+ else
+ {
+ myTolerances.SetCustomTolerance (theTolerance);
+ }
+}
+
//==================================================
// Function: Activate
// Purpose :
//! returns the Sensitivity of picking
Standard_Real Sensitivity() const { return myTolerances.Tolerance(); }
+ //! Returns the pixel tolerance.
+ Standard_Integer PixelTolerance() const { return myTolerances.Tolerance(); }
+
+ //! Sets the pixel tolerance <theTolerance>.
+ Standard_EXPORT void SetPixelTolerance (const Standard_Integer theTolerance);
+
//! Sorts the detected entites by priority and distance.
//! to be redefined if other criterion are used...
Standard_EXPORT void SortResult();
//! Returns instance of selecting volume manager of the viewer selector
SelectMgr_SelectingVolumeManager& GetManager() { return mySelectingVolumeMgr; }
+ //! Return map of selectable objects.
+ const SelectMgr_SelectableObjectSet& SelectableObjects() const { return mySelectableObjects; }
+
//! Marks all added sensitive entities of all objects as non-selectable
Standard_EXPORT void ResetSelectionActivationStatus();
--- /dev/null
+// Created on: 1995-03-15
+// Created by: Robert COUBLANC
+// 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 <SelectMgr_ViewerSelector3d.hxx>
+
+#include <Graphic3d_SequenceOfHClipPlane.hxx>
+#include <Graphic3d_Structure.hxx>
+#include <math_BullardGenerator.hxx>
+#include <Quantity_ColorHasher.hxx>
+#include <TColgp_Array1OfPnt2d.hxx>
+#include <SelectMgr.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+#include <SelectMgr_SelectableObject.hxx>
+#include <SelectMgr_Selection.hxx>
+#include <SelectMgr_SelectionImageFiller.hxx>
+#include <V3d_View.hxx>
+#include <V3d_Viewer.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_ViewerSelector3d, SelectMgr_ViewerSelector)
+
+//=======================================================================
+// Function : Constructor
+// Purpose :
+//=======================================================================
+SelectMgr_ViewerSelector3d::SelectMgr_ViewerSelector3d()
+{
+ //
+}
+
+//=======================================================================
+// Function: Pick
+// Purpose :
+//=======================================================================
+void SelectMgr_ViewerSelector3d::Pick (const Standard_Integer theXPix,
+ const Standard_Integer theYPix,
+ const Handle(V3d_View)& theView)
+{
+ updateZLayers (theView);
+ if(myToUpdateTolerance)
+ {
+ mySelectingVolumeMgr.SetPixelTolerance (myTolerances.Tolerance());
+ myToUpdateTolerance = Standard_False;
+ }
+
+ mySelectingVolumeMgr.SetCamera (theView->Camera());
+ mySelectingVolumeMgr.SetActiveSelectionType (SelectMgr_SelectingVolumeManager::Point);
+ Standard_Integer aWidth = 0, aHeight = 0;
+ theView->Window()->Size (aWidth, aHeight);
+ mySelectingVolumeMgr.SetWindowSize (aWidth, aHeight);
+ gp_Pnt2d aMousePos (static_cast<Standard_Real> (theXPix),
+ static_cast<Standard_Real> (theYPix));
+ mySelectingVolumeMgr.BuildSelectingVolume (aMousePos);
+ mySelectingVolumeMgr.SetViewClipping (theView->ClipPlanes(), Handle(Graphic3d_SequenceOfHClipPlane)());
+
+ TraverseSensitives();
+}
+
+//=======================================================================
+// Function: Pick
+// Purpose :
+//=======================================================================
+void SelectMgr_ViewerSelector3d::Pick (const Standard_Integer theXPMin,
+ const Standard_Integer theYPMin,
+ const Standard_Integer theXPMax,
+ const Standard_Integer theYPMax,
+ const Handle(V3d_View)& theView)
+{
+ updateZLayers (theView);
+ mySelectingVolumeMgr.SetCamera (theView->Camera());
+ mySelectingVolumeMgr.SetActiveSelectionType (SelectMgr_SelectingVolumeManager::Box);
+ Standard_Integer aWidth = 0, aHeight = 0;
+ theView->Window()->Size (aWidth, aHeight);
+ mySelectingVolumeMgr.SetWindowSize (aWidth, aHeight);
+ gp_Pnt2d aMinMousePos (static_cast<Standard_Real> (theXPMin),
+ static_cast<Standard_Real> (theYPMin));
+ gp_Pnt2d aMaxMousePos (static_cast<Standard_Real> (theXPMax),
+ static_cast<Standard_Real> (theYPMax));
+ mySelectingVolumeMgr.BuildSelectingVolume (aMinMousePos,
+ aMaxMousePos);
+
+ mySelectingVolumeMgr.SetViewClipping (theView->ClipPlanes(), Handle(Graphic3d_SequenceOfHClipPlane)());
+
+ TraverseSensitives();
+}
+
+//=======================================================================
+// Function: Pick
+// Purpose : Selection using a polyline
+//=======================================================================
+void SelectMgr_ViewerSelector3d::Pick (const TColgp_Array1OfPnt2d& thePolyline,
+ const Handle(V3d_View)& theView)
+{
+ updateZLayers (theView);
+ mySelectingVolumeMgr.SetCamera (theView->Camera());
+ mySelectingVolumeMgr.SetActiveSelectionType (SelectMgr_SelectingVolumeManager::Polyline);
+ Standard_Integer aWidth = 0, aHeight = 0;
+ theView->Window()->Size (aWidth, aHeight);
+ mySelectingVolumeMgr.SetWindowSize (aWidth, aHeight);
+ mySelectingVolumeMgr.BuildSelectingVolume (thePolyline);
+
+ mySelectingVolumeMgr.SetViewClipping (theView->ClipPlanes(), Handle(Graphic3d_SequenceOfHClipPlane)());
+
+ TraverseSensitives();
+}
+
+//=======================================================================
+// Function: DisplaySensitive.
+// Purpose : Display active primitives.
+//=======================================================================
+void SelectMgr_ViewerSelector3d::DisplaySensitive (const Handle(V3d_View)& theView)
+{
+ for (SelectMgr_SelectableObjectSet::Iterator aSelectableIt (mySelectableObjects); aSelectableIt.More(); aSelectableIt.Next())
+ {
+ Handle(Graphic3d_Structure) aStruct = new Graphic3d_Structure (theView->Viewer()->StructureManager());
+ const Handle (SelectMgr_SelectableObject)& anObj = aSelectableIt.Value();
+ for (SelectMgr_SequenceOfSelection::Iterator aSelIter (anObj->Selections()); aSelIter.More(); aSelIter.Next())
+ {
+ if (aSelIter.Value()->GetSelectionState() == SelectMgr_SOS_Activated)
+ {
+ SelectMgr::ComputeSensitivePrs (aStruct, aSelIter.Value(), anObj->Transformation(), Handle(Graphic3d_TransformPers)());
+ }
+ }
+
+ myStructs.Append (aStruct);
+ }
+
+ for (Graphic3d_SequenceOfStructure::Iterator aStructIter (myStructs); aStructIter.More(); aStructIter.Next())
+ {
+ Handle(Graphic3d_Structure)& aStruct = aStructIter.ChangeValue();
+ aStruct->SetDisplayPriority (10);
+ aStruct->Display();
+ }
+
+ theView->Update();
+}
+
+//=======================================================================
+// Function: ClearSensitive
+// Purpose :
+//=======================================================================
+void SelectMgr_ViewerSelector3d::ClearSensitive (const Handle(V3d_View)& theView)
+{
+ for (Graphic3d_SequenceOfStructure::Iterator aStructIter (myStructs); aStructIter.More(); aStructIter.Next())
+ {
+ aStructIter.ChangeValue()->Remove();
+ }
+ myStructs.Clear();
+
+ if (!theView.IsNull())
+ {
+ theView->Update();
+ }
+}
+
+//=======================================================================
+//function : DisplaySenstive
+//purpose :
+//=======================================================================
+void SelectMgr_ViewerSelector3d::DisplaySensitive (const Handle(SelectMgr_Selection)& theSel,
+ const gp_Trsf& theTrsf,
+ const Handle(V3d_View)& theView,
+ const Standard_Boolean theToClearOthers)
+{
+ if (theToClearOthers)
+ {
+ ClearSensitive (theView);
+ }
+
+ Handle(Graphic3d_Structure) aStruct = new Graphic3d_Structure (theView->Viewer()->StructureManager());
+
+ SelectMgr::ComputeSensitivePrs (aStruct, theSel, theTrsf, Handle(Graphic3d_TransformPers)());
+
+ myStructs.Append (aStruct);
+ myStructs.Last()->SetDisplayPriority (10);
+ myStructs.Last()->Display();
+
+ theView->Update();
+}
+
+//=======================================================================
+// Function: updateZLayers
+// Purpose :
+//=======================================================================
+void SelectMgr_ViewerSelector3d::updateZLayers (const Handle(V3d_View)& theView)
+{
+ myZLayerOrderMap.Clear();
+ TColStd_SequenceOfInteger aZLayers;
+ theView->Viewer()->GetAllZLayers (aZLayers);
+ Standard_Integer aPos = 0;
+ Standard_Boolean isPrevDepthWrite = true;
+ for (TColStd_SequenceOfInteger::Iterator aLayerIter (aZLayers); aLayerIter.More(); aLayerIter.Next())
+ {
+ Graphic3d_ZLayerSettings aSettings = theView->Viewer()->ZLayerSettings (aLayerIter.Value());
+ if (aSettings.ToClearDepth()
+ || isPrevDepthWrite != aSettings.ToEnableDepthWrite())
+ {
+ ++aPos;
+ }
+ isPrevDepthWrite = aSettings.ToEnableDepthWrite();
+ myZLayerOrderMap.Bind (aLayerIter.Value(), aPos);
+ }
+}
+
+//=======================================================================
+//function : ToPixMap
+//purpose :
+//=======================================================================
+Standard_Boolean SelectMgr_ViewerSelector3d::ToPixMap (Image_PixMap& theImage,
+ const Handle(V3d_View)& theView,
+ const StdSelect_TypeOfSelectionImage theType,
+ const Standard_Integer thePickedIndex)
+{
+ if (theImage.IsEmpty())
+ {
+ throw Standard_ProgramError("SelectMgr_ViewerSelector3d::ToPixMap() has been called with empty image");
+ }
+
+ Handle(SelectMgr_SelectionImageFiller) aFiller = SelectMgr_SelectionImageFiller::CreateFiller (theImage, this, theType);
+ if (aFiller.IsNull())
+ {
+ return Standard_False;
+ }
+
+ const Standard_Integer aSizeX = static_cast<Standard_Integer> (theImage.SizeX());
+ const Standard_Integer aSizeY = static_cast<Standard_Integer> (theImage.SizeY());
+ for (Standard_Integer aRowIter = 0; aRowIter < aSizeY; ++aRowIter)
+ {
+ for (Standard_Integer aColIter = 0; aColIter < aSizeX; ++aColIter)
+ {
+ Pick (aColIter, aRowIter, theView);
+ aFiller->Fill (aColIter, aRowIter, thePickedIndex);
+ }
+ }
+ aFiller->Flush();
+ return Standard_True;
+}
+
+//=======================================================================
+//function : DumpJson
+//purpose :
+//=======================================================================
+void SelectMgr_ViewerSelector3d::DumpJson (Standard_OStream& theOStream, Standard_Integer) const
+{
+ OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
+
+ OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myStructs.Length())
+ for (Graphic3d_SequenceOfStructure::Iterator aStructsIt (myStructs); aStructsIt.More(); aStructsIt.Next())
+ {
+ const Handle(Graphic3d_Structure)& aStructure = aStructsIt.Value();
+ OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, aStructure)
+ }
+}
--- /dev/null
+// Created on: 1995-03-15
+// Created by: Robert COUBLANC
+// 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.
+
+#ifndef _SelectMgr_ViewerSelector3d_HeaderFile
+#define _SelectMgr_ViewerSelector3d_HeaderFile
+
+#include <Graphic3d_SequenceOfStructure.hxx>
+#include <SelectMgr_ViewerSelector.hxx>
+#include <SelectMgr_Selection.hxx>
+#include <StdSelect_TypeOfSelectionImage.hxx>
+
+class Graphic3d_Structure;
+class Graphic3d_TransformPers;
+class V3d_View;
+
+//! Selector Usable by Viewers from V3d
+class SelectMgr_ViewerSelector3d : public SelectMgr_ViewerSelector
+{
+ DEFINE_STANDARD_RTTIEXT(SelectMgr_ViewerSelector3d, SelectMgr_ViewerSelector)
+public:
+
+ //! Constructs an empty 3D selector object.
+ Standard_EXPORT SelectMgr_ViewerSelector3d();
+
+ //! Picks the sensitive entity at the pixel coordinates of
+ //! the mouse <theXPix> and <theYPix>. The selector looks for touched areas and owners.
+ Standard_EXPORT void Pick (const Standard_Integer theXPix,
+ const Standard_Integer theYPix,
+ const Handle(V3d_View)& theView);
+
+ //! Picks the sensitive entity according to the minimum
+ //! and maximum pixel values <theXPMin>, <theYPMin>, <theXPMax>
+ //! and <theYPMax> defining a 2D area for selection in the 3D view aView.
+ Standard_EXPORT void Pick (const Standard_Integer theXPMin,
+ const Standard_Integer theYPMin,
+ const Standard_Integer theXPMax,
+ const Standard_Integer theYPMax,
+ const Handle(V3d_View)& theView);
+
+ //! pick action - input pixel values for polyline selection for selection.
+ Standard_EXPORT void Pick (const TColgp_Array1OfPnt2d& thePolyline,
+ const Handle(V3d_View)& theView);
+
+ //! Dump of detection results into image.
+ //! This method performs axis picking for each pixel in the image
+ //! and generates a color depending on picking results and selection image type.
+ //! @param theImage result image, should be initialized
+ //! @param theView 3D view defining camera position
+ //! @param theType type of image to define
+ //! @param thePickedIndex index of picked entity (1 means topmost)
+ Standard_EXPORT Standard_Boolean ToPixMap (Image_PixMap& theImage,
+ const Handle(V3d_View)& theView,
+ const StdSelect_TypeOfSelectionImage theType,
+ const Standard_Integer thePickedIndex = 1);
+
+public:
+
+ //! Displays sensitives in view <theView>.
+ Standard_EXPORT void DisplaySensitive (const Handle(V3d_View)& theView);
+
+ Standard_EXPORT void ClearSensitive (const Handle(V3d_View)& theView);
+
+ Standard_EXPORT void DisplaySensitive (const Handle(SelectMgr_Selection)& theSel,
+ const gp_Trsf& theTrsf,
+ const Handle(V3d_View)& theView,
+ const Standard_Boolean theToClearOthers = Standard_True);
+
+ //! Dumps the content of me into the stream
+ Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
+
+protected:
+
+ //! Update z-layers order map.
+ Standard_EXPORT void updateZLayers (const Handle(V3d_View)& theView);
+
+protected:
+
+ Graphic3d_SequenceOfStructure myStructs; //!< list of debug presentations
+};
+
+DEFINE_STANDARD_HANDLE(SelectMgr_ViewerSelector3d, SelectMgr_ViewerSelector)
+
+#endif
-StdPrs_BndBox.cxx
+StdPrs_BRepFont.cxx
+StdPrs_BRepFont.hxx
+StdPrs_BRepTextBuilder.cxx
+StdPrs_BRepTextBuilder.hxx
StdPrs_BndBox.hxx
StdPrs_Curve.cxx
StdPrs_Curve.hxx
StdPrs_ShadedShape.hxx
StdPrs_ShadedSurface.cxx
StdPrs_ShadedSurface.hxx
+StdPrs_ShapeTool.cxx
+StdPrs_ShapeTool.hxx
StdPrs_ToolPoint.cxx
StdPrs_ToolPoint.hxx
StdPrs_ToolRFace.cxx
--- /dev/null
+// Created on: 2013-09-16
+// 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_BRepFont.hxx>
+
+#include <BRep_Tool.hxx>
+#include <BRepTopAdaptor_FClass2d.hxx>
+#include <BRepBuilderAPI_MakeFace.hxx>
+#include <BRepBuilderAPI_MakeWire.hxx>
+#include <BRepLib_MakeEdge.hxx>
+#include <Font_FTLibrary.hxx>
+#include <Font_FontMgr.hxx>
+#include <Font_TextFormatter.hxx>
+#include <GCE2d_MakeSegment.hxx>
+#include <GC_MakeSegment.hxx>
+#include <Geom_BezierCurve.hxx>
+#include <Geom_BSplineCurve.hxx>
+#include <Geom2d_TrimmedCurve.hxx>
+#include <Geom_Plane.hxx>
+#include <Geom2d_BezierCurve.hxx>
+#include <Geom2d_BSplineCurve.hxx>
+#include <Geom2d_TrimmedCurve.hxx>
+#include <Geom2d_Line.hxx>
+#include <GeomAPI.hxx>
+#include <GeomAdaptor_HSurface.hxx>
+#include <GeomLib.hxx>
+#include <gp_Pln.hxx>
+#include <TColGeom2d_HSequenceOfBoundedCurve.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_HAsciiString.hxx>
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Compound.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopTools_DataMapOfShapeInteger.hxx>
+#include <TopTools_DataMapOfShapeSequenceOfShape.hxx>
+
+#include <ft2build.h>
+#include FT_FREETYPE_H
+#include FT_OUTLINE_H
+
+IMPLEMENT_STANDARD_RTTIEXT(StdPrs_BRepFont, Font_FTFont)
+
+namespace
+{
+ // pre-defined font rendering options
+ static const unsigned int THE_FONT_SIZE = 72;
+ static const unsigned int THE_RESOLUTION_DPI = 4800;
+ static const Font_FTFontParams THE_FONT_PARAMS (THE_FONT_SIZE, THE_RESOLUTION_DPI);
+
+ // compute scaling factor for specified font size
+ inline Standard_Real getScale (const Standard_Real theSize)
+ {
+ return theSize / Standard_Real(THE_FONT_SIZE) * 72.0 / Standard_Real(THE_RESOLUTION_DPI);
+ }
+
+ //! Auxiliary method to convert FT_Vector to gp_XY
+ static gp_XY readFTVec (const FT_Vector& theVec,
+ const Standard_Real theScaleUnits,
+ const Standard_Real theWidthScaling = 1.0)
+ {
+ return gp_XY (theScaleUnits * Standard_Real(theVec.x) * theWidthScaling / 64.0, theScaleUnits * Standard_Real(theVec.y) / 64.0);
+ }
+
+ //! Auxiliary method for classification wire theW2 with respect to wire theW1
+ static TopAbs_State classifyWW (const TopoDS_Wire& theW1,
+ const TopoDS_Wire& theW2,
+ const TopoDS_Face& theF)
+ {
+ TopAbs_State aRes = TopAbs_UNKNOWN;
+
+ TopoDS_Face aF = TopoDS::Face (theF.EmptyCopied());
+ aF.Orientation (TopAbs_FORWARD);
+ BRep_Builder aB;
+ aB.Add (aF, theW1);
+ BRepTopAdaptor_FClass2d aClass2d (aF, ::Precision::PConfusion());
+ for (TopoDS_Iterator anEdgeIter (theW2); anEdgeIter.More(); anEdgeIter.Next())
+ {
+ const TopoDS_Edge& anEdge = TopoDS::Edge (anEdgeIter.Value());
+ Standard_Real aPFirst = 0.0, aPLast = 0.0;
+ Handle(Geom2d_Curve) aCurve2d = BRep_Tool::CurveOnSurface (anEdge, theF, aPFirst, aPLast);
+ if (aCurve2d.IsNull())
+ {
+ continue;
+ }
+
+ gp_Pnt2d aPnt2d = aCurve2d->Value ((aPFirst + aPLast) / 2.0);
+ TopAbs_State aState = aClass2d.Perform (aPnt2d, Standard_False);
+ if (aState == TopAbs_OUT
+ || aState == TopAbs_IN)
+ {
+ if (aRes == TopAbs_UNKNOWN)
+ {
+ aRes = aState;
+ }
+ else if (aRes != aState)
+ {
+ return TopAbs_UNKNOWN;
+ }
+ }
+ }
+ return aRes;
+ }
+
+}
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+StdPrs_BRepFont::StdPrs_BRepFont ()
+: myPrecision (Precision::Confusion()),
+ myScaleUnits (1.0),
+ myIsCompositeCurve (Standard_False),
+ my3Poles (1, 3),
+ my4Poles (1, 4)
+{
+ init();
+}
+
+// =======================================================================
+// function : init
+// purpose :
+// =======================================================================
+void StdPrs_BRepFont::init()
+{
+ mySurface = new Geom_Plane (gp_Pln (gp::XOY()));
+ myCurve2dAdaptor = new Geom2dAdaptor_HCurve();
+ Handle(Adaptor3d_HSurface) aSurfAdaptor = new GeomAdaptor_HSurface (mySurface);
+ myCurvOnSurf.Load (aSurfAdaptor);
+}
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+StdPrs_BRepFont::StdPrs_BRepFont (const NCollection_String& theFontPath,
+ const Standard_Real theSize,
+ const Standard_Integer theFaceId)
+: myPrecision (Precision::Confusion()),
+ myScaleUnits (1.0),
+ myIsCompositeCurve (Standard_False),
+ my3Poles (1, 3),
+ my4Poles (1, 4)
+{
+ init();
+ if (theSize <= myPrecision * 100.0)
+ {
+ return;
+ }
+
+ myScaleUnits = getScale (theSize);
+ Font_FTFont::Init (theFontPath.ToCString(), THE_FONT_PARAMS, theFaceId);
+}
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+StdPrs_BRepFont::StdPrs_BRepFont (const NCollection_String& theFontName,
+ const Font_FontAspect theFontAspect,
+ const Standard_Real theSize,
+ const Font_StrictLevel theStrictLevel)
+: myPrecision (Precision::Confusion()),
+ myScaleUnits (1.0),
+ myIsCompositeCurve (Standard_False),
+ my3Poles (1, 3),
+ my4Poles (1, 4)
+{
+ init();
+ if (theSize <= myPrecision * 100.0)
+ {
+ return;
+ }
+
+ myScaleUnits = getScale (theSize);
+ Font_FTFont::FindAndInit (theFontName.ToCString(), theFontAspect, THE_FONT_PARAMS, theStrictLevel);
+}
+
+// =======================================================================
+// function : Release
+// purpose :
+// =======================================================================
+void StdPrs_BRepFont::Release()
+{
+ myCache.Clear();
+ Font_FTFont::Release();
+}
+
+// =======================================================================
+// function : SetCompositeCurveMode
+// purpose :
+// =======================================================================
+void StdPrs_BRepFont::SetCompositeCurveMode (const Standard_Boolean theToConcatenate)
+{
+ if (myIsCompositeCurve != theToConcatenate)
+ {
+ myIsCompositeCurve = theToConcatenate;
+ myCache.Clear();
+ }
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+bool StdPrs_BRepFont::Init (const NCollection_String& theFontPath,
+ const Standard_Real theSize,
+ const Standard_Integer theFaceId)
+{
+ if (theSize <= myPrecision * 100.0)
+ {
+ return false;
+ }
+
+ myScaleUnits = getScale (theSize);
+ return Font_FTFont::Init (theFontPath.ToCString(), THE_FONT_PARAMS, theFaceId);
+}
+
+// =======================================================================
+// function : FindAndInit
+// purpose :
+// =======================================================================
+bool StdPrs_BRepFont::FindAndInit (const TCollection_AsciiString& theFontName,
+ const Font_FontAspect theFontAspect,
+ const Standard_Real theSize,
+ const Font_StrictLevel theStrictLevel)
+{
+ if (theSize <= myPrecision * 100.0)
+ {
+ return false;
+ }
+
+ myScaleUnits = getScale (theSize);
+ return Font_FTFont::FindAndInit (theFontName.ToCString(), theFontAspect, THE_FONT_PARAMS, theStrictLevel);
+}
+
+// =======================================================================
+// function : RenderGlyph
+// purpose :
+// =======================================================================
+TopoDS_Shape StdPrs_BRepFont::RenderGlyph (const Standard_Utf32Char& theChar)
+{
+ TopoDS_Shape aShape;
+ Standard_Mutex::Sentry aSentry (myMutex);
+ renderGlyph (theChar, aShape);
+ return aShape;
+}
+
+// =======================================================================
+// function : to3d
+// purpose :
+// =======================================================================
+bool StdPrs_BRepFont::to3d (const Handle(Geom2d_Curve)& theCurve2d,
+ const GeomAbs_Shape theContinuity,
+ Handle(Geom_Curve)& theCurve3d)
+{
+ Standard_Real aMaxDeviation = 0.0;
+ Standard_Real anAverDeviation = 0.0;
+ myCurve2dAdaptor->ChangeCurve2d().Load (theCurve2d);
+ const Handle(Adaptor2d_HCurve2d)& aCurve = myCurve2dAdaptor; // to avoid ambiguity
+ myCurvOnSurf.Load (aCurve);
+ GeomLib::BuildCurve3d (myPrecision, myCurvOnSurf,
+ myCurve2dAdaptor->FirstParameter(), myCurve2dAdaptor->LastParameter(),
+ theCurve3d, aMaxDeviation, anAverDeviation, theContinuity);
+ return !theCurve3d.IsNull();
+}
+
+
+// =======================================================================
+// function : buildFaces
+// purpose :
+// =======================================================================
+Standard_Boolean StdPrs_BRepFont::buildFaces (const NCollection_Sequence<TopoDS_Wire>& theWires,
+ TopoDS_Shape& theRes)
+{
+ // classify wires
+ NCollection_DataMap<TopoDS_Shape, NCollection_Sequence<TopoDS_Wire>, TopTools_ShapeMapHasher> aMapOutInts;
+ TopTools_DataMapOfShapeInteger aMapNbOuts;
+ TopoDS_Face aF;
+ myBuilder.MakeFace (aF, mySurface, myPrecision);
+ Standard_Integer aWireIter1Index = 1;
+ for (NCollection_Sequence<TopoDS_Wire>::Iterator aWireIter1 (theWires); aWireIter1.More(); ++aWireIter1Index, aWireIter1.Next())
+ {
+ const TopoDS_Wire& aW1 = aWireIter1.Value();
+ if (!aMapNbOuts.IsBound (aW1))
+ {
+ const Standard_Integer aNbOuts = 0;
+ aMapNbOuts.Bind (aW1, aNbOuts);
+ }
+
+ NCollection_Sequence<TopoDS_Wire>* anIntWs = aMapOutInts.Bound (aW1, NCollection_Sequence<TopoDS_Wire>());
+ Standard_Integer aWireIter2Index = 1;
+ for (NCollection_Sequence<TopoDS_Wire>::Iterator aWireIter2 (theWires); aWireIter2.More(); ++aWireIter2Index, aWireIter2.Next())
+ {
+ if (aWireIter1Index == aWireIter2Index)
+ {
+ continue;
+ }
+
+ const TopoDS_Wire& aW2 = aWireIter2.Value();
+ const TopAbs_State aClass = classifyWW (aW1, aW2, aF);
+ if (aClass == TopAbs_IN)
+ {
+ anIntWs->Append (aW2);
+ if (Standard_Integer* aNbOutsPtr = aMapNbOuts.ChangeSeek (aW2))
+ {
+ ++(*aNbOutsPtr);
+ }
+ else
+ {
+ const Standard_Integer aNbOuts = 1;
+ aMapNbOuts.Bind (aW2, aNbOuts);
+ }
+ }
+ }
+ }
+
+ // check out wires and remove "not out" wires from maps
+ for (TopTools_DataMapIteratorOfDataMapOfShapeInteger anOutIter (aMapNbOuts); anOutIter.More(); anOutIter.Next())
+ {
+ const Standard_Integer aTmp = anOutIter.Value() % 2;
+ if (aTmp > 0)
+ {
+ // not out wire
+ aMapOutInts.UnBind (anOutIter.Key());
+ }
+ }
+
+ // create faces for out wires
+ TopTools_MapOfShape anUsedShapes;
+ TopoDS_Compound aFaceComp;
+ myBuilder.MakeCompound (aFaceComp);
+ for (; !aMapOutInts.IsEmpty(); )
+ {
+ // find out wire with max number of outs
+ TopoDS_Shape aW;
+ Standard_Integer aMaxNbOuts = -1;
+ for (NCollection_DataMap<TopoDS_Shape, NCollection_Sequence<TopoDS_Wire>, TopTools_ShapeMapHasher>::Iterator itMOI (aMapOutInts);
+ itMOI.More(); itMOI.Next())
+ {
+ const TopoDS_Shape& aKey = itMOI.Key();
+ const Standard_Integer aNbOuts = aMapNbOuts.Find (aKey);
+ if (aNbOuts > aMaxNbOuts)
+ {
+ aMaxNbOuts = aNbOuts;
+ aW = aKey;
+ }
+ }
+
+ // create face for selected wire
+ TopoDS_Face aNewF;
+ myBuilder.MakeFace (aNewF, mySurface, myPrecision);
+ myBuilder.Add (aNewF, aW);
+ anUsedShapes.Add (aW);
+ const NCollection_Sequence<TopoDS_Wire>& anIns = aMapOutInts.Find (aW);
+ for (NCollection_Sequence<TopoDS_Wire>::Iterator aWireIter (anIns); aWireIter.More(); aWireIter.Next())
+ {
+ TopoDS_Wire aWin = aWireIter.Value();
+ if (anUsedShapes.Contains (aWin))
+ {
+ continue;
+ }
+
+ aWin.Reverse();
+ myBuilder.Add (aNewF, aWin);
+ anUsedShapes.Add (aWin);
+ }
+
+ myBuilder.Add (aFaceComp, aNewF);
+ aMapOutInts.UnBind (aW);
+ }
+
+ if (aFaceComp.NbChildren() == 0)
+ {
+ return Standard_False;
+ }
+
+ if (aFaceComp.NbChildren() == 1)
+ {
+ theRes = TopoDS_Iterator (aFaceComp).Value();
+ }
+ else
+ {
+ theRes = aFaceComp;
+ }
+ return Standard_True;
+}
+
+// =======================================================================
+// function : renderGlyph
+// purpose :
+// =======================================================================
+Standard_Boolean StdPrs_BRepFont::renderGlyph (const Standard_Utf32Char theChar,
+ TopoDS_Shape& theShape)
+{
+ theShape.Nullify();
+ if (!loadGlyph (theChar)
+ || myActiveFTFace->glyph->format != FT_GLYPH_FORMAT_OUTLINE)
+ {
+ return Standard_False;
+ }
+ else if (myCache.Find (theChar, theShape))
+ {
+ return !theShape.IsNull();
+ }
+
+ const FT_Outline& anOutline = myActiveFTFace->glyph->outline;
+ if (!anOutline.n_contours)
+ return Standard_False;
+
+ TopLoc_Location aLoc;
+ NCollection_Sequence<TopoDS_Wire> aWires;
+ TopoDS_Compound aFaceCompDraft;
+
+ // Get orientation is useless since it doesn't retrieve any in-font information and just computes orientation.
+ // Because it fails in some cases - leave this to ShapeFix.
+ //const FT_Orientation anOrient = FT_Outline_Get_Orientation (&anOutline);
+ for (short aContour = 0, aStartIndex = 0; aContour < anOutline.n_contours; ++aContour)
+ {
+ const FT_Vector* aPntList = &anOutline.points[aStartIndex];
+ const char* aTags = &anOutline.tags[aStartIndex];
+ const short anEndIndex = anOutline.contours[aContour];
+ const short aPntsNb = (anEndIndex - aStartIndex) + 1;
+ aStartIndex = anEndIndex + 1;
+ if (aPntsNb < 3 && !myFontParams.IsSingleStrokeFont)
+ {
+ // closed contour can not be constructed from < 3 points
+ continue;
+ }
+
+ BRepBuilderAPI_MakeWire aWireMaker;
+
+ gp_XY aPntPrev;
+ gp_XY aPntCurr = readFTVec (aPntList[aPntsNb - 1], myScaleUnits, myWidthScaling);
+ gp_XY aPntNext = readFTVec (aPntList[0], myScaleUnits, myWidthScaling);
+
+ bool isLineSeg = !myFontParams.IsSingleStrokeFont
+ && FT_CURVE_TAG(aTags[aPntsNb - 1]) == FT_Curve_Tag_On;
+ gp_XY aPntLine1 = aPntCurr;
+
+ // see http://freetype.sourceforge.net/freetype2/docs/glyphs/glyphs-6.html
+ // for a full description of FreeType tags.
+ for (short aPntId = 0; aPntId < aPntsNb; ++aPntId)
+ {
+ aPntPrev = aPntCurr;
+ aPntCurr = aPntNext;
+ aPntNext = readFTVec (aPntList[(aPntId + 1) % aPntsNb], myScaleUnits, myWidthScaling);
+
+ // process tags
+ if (FT_CURVE_TAG(aTags[aPntId]) == FT_Curve_Tag_On)
+ {
+ if (!isLineSeg)
+ {
+ aPntLine1 = aPntCurr;
+ isLineSeg = true;
+ continue;
+ }
+
+ const gp_XY aDirVec = aPntCurr - aPntLine1;
+ const Standard_Real aLen = aDirVec.Modulus();
+ if (aLen <= myPrecision)
+ {
+ aPntLine1 = aPntCurr;
+ isLineSeg = true;
+ continue;
+ }
+
+ if (myIsCompositeCurve)
+ {
+ Handle(Geom2d_TrimmedCurve) aLine = GCE2d_MakeSegment (gp_Pnt2d (aPntLine1), gp_Pnt2d (aPntCurr));
+ myConcatMaker.Add (aLine, myPrecision);
+ }
+ else
+ {
+ Handle(Geom_Curve) aCurve3d;
+ Handle(Geom2d_Line) aCurve2d = new Geom2d_Line (gp_Pnt2d (aPntLine1), gp_Dir2d (aDirVec));
+ if (to3d (aCurve2d, GeomAbs_C1, aCurve3d))
+ {
+ TopoDS_Edge anEdge = BRepLib_MakeEdge (aCurve3d, 0.0, aLen);
+ myBuilder.UpdateEdge (anEdge, aCurve2d, mySurface, aLoc, myPrecision);
+ aWireMaker.Add (anEdge);
+ }
+ }
+ aPntLine1 = aPntCurr;
+ }
+ else if (FT_CURVE_TAG(aTags[aPntId]) == FT_Curve_Tag_Conic)
+ {
+ isLineSeg = false;
+ gp_XY aPntPrev2 = aPntPrev;
+ gp_XY aPntNext2 = aPntNext;
+
+ // previous point is either the real previous point (an "on" point),
+ // or the midpoint between the current one and the previous "conic off" point
+ if (FT_CURVE_TAG(aTags[(aPntId - 1 + aPntsNb) % aPntsNb]) == FT_Curve_Tag_Conic)
+ {
+ aPntPrev2 = (aPntCurr + aPntPrev) * 0.5;
+ }
+
+ // next point is either the real next point or the midpoint
+ if (FT_CURVE_TAG(aTags[(aPntId + 1) % aPntsNb]) == FT_Curve_Tag_Conic)
+ {
+ aPntNext2 = (aPntCurr + aPntNext) * 0.5;
+ }
+
+ my3Poles.SetValue (1, aPntPrev2);
+ my3Poles.SetValue (2, aPntCurr);
+ my3Poles.SetValue (3, aPntNext2);
+ Handle(Geom2d_BezierCurve) aBezierArc = new Geom2d_BezierCurve (my3Poles);
+ if (myIsCompositeCurve)
+ {
+ myConcatMaker.Add (aBezierArc, myPrecision);
+ }
+ else
+ {
+ Handle(Geom_Curve) aCurve3d;
+ if (to3d (aBezierArc, GeomAbs_C1, aCurve3d))
+ {
+ TopoDS_Edge anEdge = BRepLib_MakeEdge (aCurve3d);
+ myBuilder.UpdateEdge (anEdge, aBezierArc, mySurface, aLoc, myPrecision);
+ aWireMaker.Add (anEdge);
+ }
+ }
+ }
+ else if (FT_CURVE_TAG(aTags[aPntId]) == FT_Curve_Tag_Cubic
+ && FT_CURVE_TAG(aTags[(aPntId + 1) % aPntsNb]) == FT_Curve_Tag_Cubic)
+ {
+ isLineSeg = false;
+ my4Poles.SetValue (1, aPntPrev);
+ my4Poles.SetValue (2, aPntCurr);
+ my4Poles.SetValue (3, aPntNext);
+ my4Poles.SetValue (4, gp_Pnt2d(readFTVec (aPntList[(aPntId + 2) % aPntsNb], myScaleUnits, myWidthScaling)));
+ Handle(Geom2d_BezierCurve) aBezier = new Geom2d_BezierCurve (my4Poles);
+ if (myIsCompositeCurve)
+ {
+ myConcatMaker.Add (aBezier, myPrecision);
+ }
+ else
+ {
+ Handle(Geom_Curve) aCurve3d;
+ if (to3d (aBezier, GeomAbs_C1, aCurve3d))
+ {
+ TopoDS_Edge anEdge = BRepLib_MakeEdge (aCurve3d);
+ myBuilder.UpdateEdge (anEdge, aBezier, mySurface, aLoc, myPrecision);
+ aWireMaker.Add (anEdge);
+ }
+ }
+ }
+ }
+
+ if (myIsCompositeCurve)
+ {
+ Handle(Geom2d_BSplineCurve) aDraft2d = myConcatMaker.BSplineCurve();
+ if (aDraft2d.IsNull())
+ {
+ continue;
+ }
+
+ const gp_Pnt2d aFirstPnt = aDraft2d->StartPoint();
+ const gp_Pnt2d aLastPnt = aDraft2d->EndPoint();
+ if (!myFontParams.IsSingleStrokeFont
+ && !aFirstPnt.IsEqual (aLastPnt, myPrecision))
+ {
+ Handle(Geom2d_TrimmedCurve) aLine = GCE2d_MakeSegment (aLastPnt, aFirstPnt);
+ myConcatMaker.Add (aLine, myPrecision);
+ }
+
+ Handle(Geom2d_BSplineCurve) aCurve2d = myConcatMaker.BSplineCurve();
+ Handle(Geom_Curve) aCurve3d;
+ if (to3d (aCurve2d, GeomAbs_C0, aCurve3d))
+ {
+ TopoDS_Edge anEdge = BRepLib_MakeEdge (aCurve3d);
+ myBuilder.UpdateEdge (anEdge, aCurve2d, mySurface, aLoc, myPrecision);
+ aWireMaker.Add (anEdge);
+ }
+ myConcatMaker.Clear();
+ }
+ else
+ {
+ if (!aWireMaker.IsDone())
+ {
+ continue;
+ }
+
+ TopoDS_Vertex aFirstV, aLastV;
+ TopExp::Vertices (aWireMaker.Wire(), aFirstV, aLastV);
+ gp_Pnt aFirstPoint = BRep_Tool::Pnt (aFirstV);
+ gp_Pnt aLastPoint = BRep_Tool::Pnt (aLastV);
+ if (!myFontParams.IsSingleStrokeFont
+ && !aFirstPoint.IsEqual (aLastPoint, myPrecision))
+ {
+ aWireMaker.Add (BRepLib_MakeEdge (aFirstV, aLastV));
+ }
+ }
+
+ if (!aWireMaker.IsDone())
+ {
+ continue;
+ }
+
+ TopoDS_Wire aWireDraft = aWireMaker.Wire();
+ if (!myFontParams.IsSingleStrokeFont)
+ {
+ // collect all wires and set CCW orientation
+ TopoDS_Face aFace;
+ myBuilder.MakeFace (aFace, mySurface, myPrecision);
+ myBuilder.Add (aFace, aWireDraft);
+ BRepTopAdaptor_FClass2d aClass2d (aFace, ::Precision::PConfusion());
+ TopAbs_State aState = aClass2d.PerformInfinitePoint();
+ if (aState != TopAbs_OUT)
+ {
+ // need to reverse
+ aWireDraft.Reverse();
+ }
+ aWires.Append (aWireDraft);
+ }
+ else
+ {
+ if (aFaceCompDraft.IsNull())
+ {
+ myBuilder.MakeCompound (aFaceCompDraft);
+ }
+ myBuilder.Add (aFaceCompDraft, aWireDraft);
+ }
+ }
+
+ if (!aWires.IsEmpty())
+ {
+ buildFaces (aWires, theShape);
+ }
+ else if (!aFaceCompDraft.IsNull())
+ {
+ theShape = aFaceCompDraft;
+ }
+
+ myCache.Bind (theChar, theShape);
+ return !theShape.IsNull();
+}
--- /dev/null
+// Created on: 2013-09-16
+// 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_BRepFont_H__
+#define _StdPrs_BRepFont_H__
+
+#include <Adaptor3d_CurveOnSurface.hxx>
+#include <BRep_Builder.hxx>
+#include <Font_FTFont.hxx>
+#include <Font_TextFormatter.hxx>
+#include <Geom2dAdaptor_HCurve.hxx>
+#include <Geom2dConvert_CompCurveToBSplineCurve.hxx>
+#include <gp_Ax3.hxx>
+#include <gp_XY.hxx>
+#include <gp_XYZ.hxx>
+#include <NCollection_DataMap.hxx>
+#include <NCollection_String.hxx>
+#include <Standard_Mutex.hxx>
+#include <TColgp_Array1OfPnt2d.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopTools_SequenceOfShape.hxx>
+
+DEFINE_STANDARD_HANDLE(StdPrs_BRepFont, Font_FTFont)
+
+//! This tool provides basic services for rendering of vectorized text glyphs as BRep shapes.
+//! Single instance initialize single font for sequential glyphs rendering with implicit caching of already rendered glyphs.
+//! Thus position of each glyph in the text is specified by shape location.
+//!
+//! Please notice that this implementation uses mutex for thread-safety access,
+//! thus may lead to performance penalties in case of concurrent access.
+//! Although caching should eliminate this issue after rendering of sufficient number of glyphs.
+class StdPrs_BRepFont : protected Font_FTFont
+{
+ DEFINE_STANDARD_RTTIEXT(StdPrs_BRepFont, Font_FTFont)
+public:
+
+ //! Empty constructor
+ Standard_EXPORT StdPrs_BRepFont();
+
+ //! Constructor with initialization.
+ //! @param theFontPath FULL path to the font
+ //! @param theSize the face size in model units
+ //! @param theFaceId face id within the file (0 by default)
+ Standard_EXPORT StdPrs_BRepFont (const NCollection_String& theFontPath,
+ const Standard_Real theSize,
+ const Standard_Integer theFaceId = 0);
+
+ //! Constructor with initialization.
+ //! @param theFontName the font name
+ //! @param theFontAspect the font style
+ //! @param theSize the face size in model units
+ //! @param theStrictLevel search strict level for using aliases and fallback
+ Standard_EXPORT StdPrs_BRepFont (const NCollection_String& theFontName,
+ const Font_FontAspect theFontAspect,
+ const Standard_Real theSize,
+ const Font_StrictLevel theStrictLevel = Font_StrictLevel_Any);
+
+ //! Release currently loaded font.
+ Standard_EXPORT virtual void Release() Standard_OVERRIDE;
+
+ //! Initialize the font.
+ //! @param theFontPath FULL path to the font
+ //! @param theSize the face size in model units
+ //! @param theFaceId face id within the file (0 by default)
+ //! @return true on success
+ Standard_EXPORT bool Init (const NCollection_String& theFontPath,
+ const Standard_Real theSize,
+ const Standard_Integer theFaceId);
+
+ //! Find (using Font_FontMgr) and initialize the font from the given name.
+ //! Please take into account that size is specified NOT in typography points (pt.).
+ //! If you need to specify size in points, value should be converted.
+ //! Formula for pt. -> m conversion:
+ //! aSizeMeters = 0.0254 * theSizePt / 72.0
+ //! @param theFontName the font name
+ //! @param theFontAspect the font style
+ //! @param theSize the face size in model units
+ //! @param theStrictLevel search strict level for using aliases and fallback
+ //! @return true on success
+ Standard_EXPORT bool FindAndInit (const TCollection_AsciiString& theFontName,
+ const Font_FontAspect theFontAspect,
+ const Standard_Real theSize,
+ const Font_StrictLevel theStrictLevel = Font_StrictLevel_Any);
+
+ //! Render single glyph as TopoDS_Shape.
+ //! @param theChar glyph identifier
+ //! @return rendered glyph within cache, might be NULL shape
+ Standard_EXPORT TopoDS_Shape RenderGlyph (const Standard_Utf32Char& theChar);
+
+ //! Setup glyph geometry construction mode.
+ //! By default algorithm creates independent TopoDS_Edge
+ //! for each original curve in the glyph (line segment or Bezie curve).
+ //! Algorithm might optionally create composite BSpline curve for each contour
+ //! which reduces memory footprint but limits curve class to C0.
+ //! Notice that altering this flag clears currently accumulated cache!
+ Standard_EXPORT void SetCompositeCurveMode (const Standard_Boolean theToConcatenate);
+
+ //! Setup glyph scaling along X-axis.
+ //! By default glyphs are not scaled (scaling factor = 1.0)
+ void SetWidthScaling (const float theScaleFactor)
+ {
+ myWidthScaling = theScaleFactor;
+ }
+
+public:
+
+ //! @return vertical distance from the horizontal baseline to the highest character coordinate.
+ Standard_Real Ascender() const
+ {
+ return myScaleUnits * Standard_Real(Font_FTFont::Ascender());
+ }
+
+ //! @return vertical distance from the horizontal baseline to the lowest character coordinate.
+ Standard_Real Descender() const
+ {
+ return myScaleUnits * Standard_Real(Font_FTFont::Descender());
+ }
+
+ //! @return default line spacing (the baseline-to-baseline distance).
+ Standard_Real LineSpacing() const
+ {
+ return myScaleUnits * Standard_Real(Font_FTFont::LineSpacing());
+ }
+
+ //! Configured point size
+ Standard_Real PointSize() const
+ {
+ return myScaleUnits * Standard_Real(Font_FTFont::PointSize());
+ }
+
+ //! Compute advance to the next character with kerning applied when applicable.
+ //! Assuming text rendered horizontally.
+ Standard_Real AdvanceX (const Standard_Utf32Char theUCharNext)
+ {
+ return myScaleUnits * Standard_Real(Font_FTFont::AdvanceX (theUCharNext));
+ }
+
+ //! Compute advance to the next character with kerning applied when applicable.
+ //! Assuming text rendered horizontally.
+ Standard_Real AdvanceX (const Standard_Utf32Char theUChar,
+ const Standard_Utf32Char theUCharNext)
+ {
+ return myScaleUnits * Standard_Real(Font_FTFont::AdvanceX (theUChar, theUCharNext));
+ }
+
+ //! Compute advance to the next character with kerning applied when applicable.
+ //! Assuming text rendered vertically.
+ Standard_Real AdvanceY (const Standard_Utf32Char theUCharNext)
+ {
+ return myScaleUnits * Standard_Real(Font_FTFont::AdvanceY (theUCharNext));
+ }
+
+ //! Compute advance to the next character with kerning applied when applicable.
+ //! Assuming text rendered vertically.
+ Standard_Real AdvanceY (const Standard_Utf32Char theUChar,
+ const Standard_Utf32Char theUCharNext)
+ {
+ return myScaleUnits * Standard_Real(Font_FTFont::AdvanceY (theUChar, theUCharNext));
+ }
+
+ //! Returns scaling factor for current font size.
+ Standard_Real Scale() const
+ {
+ return myScaleUnits;
+ }
+
+ //! Returns mutex.
+ Standard_Mutex& Mutex()
+ {
+ return myMutex;
+ }
+
+public:
+
+ //! Find (using Font_FontMgr) and initialize the font from the given name.
+ //! Alias for FindAndInit() for backward compatibility.
+ bool Init (const NCollection_String& theFontName,
+ const Font_FontAspect theFontAspect,
+ const Standard_Real theSize)
+ {
+ return FindAndInit (theFontName.ToCString(), theFontAspect, theSize, Font_StrictLevel_Any);
+ }
+
+protected:
+
+ //! Render single glyph as TopoDS_Shape. This method does not lock the mutex.
+ //! @param theChar glyph identifier
+ //! @param theShape rendered glyph within cache, might be NULL shape
+ //! @return true if glyph's geometry is available
+ Standard_EXPORT Standard_Boolean renderGlyph (const Standard_Utf32Char theChar,
+ TopoDS_Shape& theShape);
+
+private:
+
+ //! Initialize class fields
+ void init();
+
+ //! Auxiliary method to create 3D curve
+ bool to3d (const Handle(Geom2d_Curve)& theCurve2d,
+ const GeomAbs_Shape theContinuity,
+ Handle(Geom_Curve)& theCurve3d);
+
+ //! Auxiliary method for creation faces from sequence of wires.
+ //! Splits to few faces (if it is needed) and updates orientation of wires.
+ Standard_Boolean buildFaces (const NCollection_Sequence<TopoDS_Wire>& theWires,
+ TopoDS_Shape& theRes);
+
+ //! Hide visibility.
+ using Font_FTFont::FindAndCreate;
+
+protected: //! @name Protected fields
+
+ NCollection_DataMap<Standard_Utf32Char, TopoDS_Shape>
+ myCache; //!< glyphs cache
+ Standard_Mutex myMutex; //!< lock for thread-safety
+ Handle(Geom_Surface) mySurface; //!< surface to place glyphs on to
+ Standard_Real myPrecision; //!< algorithm precision
+ Standard_Real myScaleUnits; //!< scale font rendering units into model units
+ Standard_Boolean myIsCompositeCurve; //!< flag to merge C1 curves of each contour into single C0 curve, OFF by default
+
+protected: //! @name Shared temporary variables for glyph construction
+
+ Adaptor3d_CurveOnSurface myCurvOnSurf;
+ Handle(Geom2dAdaptor_HCurve) myCurve2dAdaptor;
+ Geom2dConvert_CompCurveToBSplineCurve myConcatMaker;
+ TColgp_Array1OfPnt2d my3Poles;
+ TColgp_Array1OfPnt2d my4Poles;
+ BRep_Builder myBuilder;
+
+};
+
+#endif // _StdPrs_BRepFont_H__
--- /dev/null
+// Created on: 2015-08-10
+// Created by: Ilya SEVRIKOV
+// 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_BRepTextBuilder.hxx>
+
+// =======================================================================
+// Function : Perfrom
+// Purpose :
+// =======================================================================
+TopoDS_Shape StdPrs_BRepTextBuilder::Perform (StdPrs_BRepFont& theFont,
+ const Font_TextFormatter& theFormatter,
+ const gp_Ax3& thePenLoc)
+{
+ gp_Trsf aTrsf;
+ gp_XYZ aPen;
+ TopoDS_Shape aGlyphShape;
+ TopoDS_Compound aResult;
+ Standard_Mutex::Sentry aSentry (theFont.Mutex());
+
+ myBuilder.MakeCompound (aResult);
+
+ Standard_Integer aSymbolCounter = 0;
+ Standard_Real aScaleUnits = theFont.Scale();
+ for (NCollection_Utf8Iter anIter = theFormatter.String().Iterator(); *anIter != 0; ++anIter)
+ {
+ const Standard_Utf32Char aCharCurr = *anIter;
+ if (aCharCurr == '\x0D' // CR (carriage return)
+ || aCharCurr == '\a' // BEL (alarm)
+ || aCharCurr == '\f' // FF (form feed) NP (new page)
+ || aCharCurr == '\b' // BS (backspace)
+ || aCharCurr == '\v' // VT (vertical tab)
+ || aCharCurr == ' '
+ || aCharCurr == '\t'
+ || aCharCurr == '\n')
+ {
+ continue; // skip unsupported carriage control codes
+ }
+
+ const NCollection_Vec2<Standard_ShortReal>& aCorner = theFormatter.TopLeft (aSymbolCounter);
+ aPen.SetCoord (aCorner.x() * aScaleUnits, aCorner.y() * aScaleUnits, 0.0);
+ aGlyphShape = theFont.RenderGlyph (aCharCurr);
+ if (!aGlyphShape.IsNull())
+ {
+ aTrsf.SetTranslation (gp_Vec (aPen));
+ aGlyphShape.Move (aTrsf);
+ myBuilder.Add (aResult, aGlyphShape);
+ }
+
+ ++aSymbolCounter;
+ }
+
+ aTrsf.SetTransformation (thePenLoc, gp_Ax3 (gp::XOY()));
+ aResult.Move (aTrsf);
+
+ return aResult;
+}
+
+// =======================================================================
+// Function : Perform
+// Purpose :
+// =======================================================================
+TopoDS_Shape StdPrs_BRepTextBuilder::Perform (StdPrs_BRepFont& theFont,
+ const NCollection_String& theString,
+ const gp_Ax3& thePenLoc,
+ const Graphic3d_HorizontalTextAlignment theHAlign,
+ const Graphic3d_VerticalTextAlignment theVAlign)
+{
+ Font_TextFormatter aFormatter;
+
+ aFormatter.Reset();
+ aFormatter.SetupAlignment (theHAlign, theVAlign);
+
+ aFormatter.Append (theString, *(reinterpret_cast<Font_FTFont*> (&theFont)));
+ aFormatter.Format();
+
+ return Perform (theFont, aFormatter, thePenLoc);
+}
--- /dev/null
+// Created on: 2015-08-10
+// Created by: Ilya SEVRIKOV
+// 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_BRepTextBuilder_Header
+#define StdPrs_BRepTextBuilder_Header
+
+#include <Font_BRepFont.hxx>
+#include <Font_TextFormatter.hxx>
+#include <gp_Ax3.hxx>
+
+//! Represents class for applying text formatting.
+class StdPrs_BRepTextBuilder
+{
+public:
+ //! Render text as BRep shape.
+ //! @param theString text in UTF-8 encoding
+ //! @param thePenLoc start position and orientation on the baseline
+ //! @param theFormatter formatter which defines alignment for the text
+ //! @return result shape with pen transformation applied as shape location
+ Standard_EXPORT TopoDS_Shape Perform (StdPrs_BRepFont& theFont,
+ const Font_TextFormatter& theFormatter,
+ const gp_Ax3& thePenLoc = gp_Ax3());
+ //! Render text as BRep shape.
+ //! @param theString text in UTF-8 encoding
+ //! @param thePenLoc start position and orientation on the baseline
+ //! @param theHAlign horizontal alignment of the text
+ //! @param theVAlign vertical alignment of the text
+ //! @return result shape with pen transformation applied as shape location
+ Standard_EXPORT TopoDS_Shape Perform (StdPrs_BRepFont& theFont,
+ const NCollection_String& theString,
+ const gp_Ax3& thePenLoc = gp_Ax3(),
+ const Graphic3d_HorizontalTextAlignment theHAlign = Graphic3d_HTA_LEFT,
+ const Graphic3d_VerticalTextAlignment theVAlign = Graphic3d_VTA_BOTTOM);
+
+protected:
+ BRep_Builder myBuilder;
+};
+
+#endif // StdPrs_BRepTextBuilder_Header
+++ /dev/null
-// 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 <Prs3d_LineAspect.hxx>
-
-//=======================================================================
-//function : Add
-//purpose :
-//=======================================================================
-void StdPrs_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 StdPrs_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));
- }
-}
-// Created on: 2014-10-14
-// Created by: Anton POLETAEV
-// Copyright (c) 2013-2014 OPEN CASCADE SAS
+// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
#ifndef _StdPrs_BndBox_H__
#define _StdPrs_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>
+#include <Prs3d_BndBox.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);
-
- //! 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);
- }
-
-};
+typedef Prs3d_BndBox StdPrs_BndBox;
#endif // _StdPrs_BndBox_H__
--- /dev/null
+// 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 <StdPrs_ShapeTool.hxx>
+
+#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 <TopExp.hxx>
+#include <TopLoc_Location.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_MapOfShape.hxx>
+
+//=======================================================================
+//function : StdPrs_ShapeTool
+//purpose :
+//=======================================================================
+StdPrs_ShapeTool::StdPrs_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 : FaceBound
+//purpose :
+//=======================================================================
+Bnd_Box StdPrs_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 StdPrs_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 : CurveBound
+//purpose :
+//=======================================================================
+Bnd_Box StdPrs_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 StdPrs_ShapeTool::Neighbours() const
+{
+ const TopTools_ListOfShape& L = myEdgeMap.FindFromIndex(myEdge);
+ return L.Extent();
+}
+
+//=======================================================================
+//function : FacesOfEdge
+//purpose :
+//=======================================================================
+Handle(TopTools_HSequenceOfShape) StdPrs_ShapeTool::FacesOfEdge() const
+{
+ Handle(TopTools_HSequenceOfShape) H = new TopTools_HSequenceOfShape();
+ const TopTools_ListOfShape& L = myEdgeMap.FindFromIndex(myEdge);
+ for (TopTools_ListIteratorOfListOfShape LI (L); LI.More(); LI.Next())
+ {
+ H->Append(LI.Value());
+ }
+ return H;
+}
+
+//=======================================================================
+//function : HasSurface
+//purpose :
+//=======================================================================
+Standard_Boolean StdPrs_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) StdPrs_ShapeTool::CurrentTriangulation(TopLoc_Location& l) const
+{
+ return BRep_Tool::Triangulation(GetFace(), l);
+}
+
+//=======================================================================
+//function : HasCurve
+//purpose :
+//=======================================================================
+Standard_Boolean StdPrs_ShapeTool::HasCurve() const
+{
+ return BRep_Tool::IsGeometric(GetCurve());
+}
+
+//=======================================================================
+//function : PolygonOnTriangulation
+//purpose :
+//=======================================================================
+void StdPrs_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) StdPrs_ShapeTool::Polygon3D(TopLoc_Location& l) const
+{
+ return BRep_Tool::Polygon3D(GetCurve(), l);
+}
--- /dev/null
+// Created on: 1993-01-27
+// Created by: Jean-Louis Frenkel
+// Copyright (c) 1993-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.
+
+#ifndef _StdPrs_ShapeTool_HeaderFile
+#define _StdPrs_ShapeTool_HeaderFile
+
+#include <Standard_DefineAlloc.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopTools_HSequenceOfShape.hxx>
+
+class Bnd_Box;
+class Poly_Triangulation;
+class Poly_PolygonOnTriangulation;
+class Poly_Polygon3D;
+
+//! Describes the behaviour requested for a wireframe shape presentation.
+class StdPrs_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 StdPrs_ShapeTool (const TopoDS_Shape& theShape, const Standard_Boolean theAllVertices = Standard_False);
+
+ void InitFace() { myFaceExplorer.Init(myShape,TopAbs_FACE); }
+
+ Standard_Boolean MoreFace() const { return myFaceExplorer.More(); }
+
+ void NextFace() { myFaceExplorer.Next(); }
+
+ const TopoDS_Face& GetFace() const { return TopoDS::Face(myFaceExplorer.Current()); }
+
+ Standard_EXPORT Bnd_Box FaceBound() const;
+
+ Standard_Boolean IsPlanarFace() const
+ {
+ const TopoDS_Face& aFace = TopoDS::Face (myFaceExplorer.Current());
+ return IsPlanarFace (aFace);
+ }
+
+ void InitCurve() { myEdge = 1; }
+
+ Standard_Boolean MoreCurve() const { return myEdge <= myEdgeMap.Extent(); }
+
+ void NextCurve() { ++myEdge; }
+
+ const TopoDS_Edge& GetCurve() const { return TopoDS::Edge(myEdgeMap.FindKey(myEdge)); }
+
+ Standard_EXPORT Bnd_Box CurveBound() const;
+
+ Standard_EXPORT Standard_Integer Neighbours() const;
+
+ Standard_EXPORT Handle(TopTools_HSequenceOfShape) FacesOfEdge() const;
+
+ void InitVertex() { myVertex = 1; }
+
+ Standard_Boolean MoreVertex() const { return myVertex <= myVertexMap.Extent(); }
+
+ void NextVertex() { ++myVertex; }
+
+ const TopoDS_Vertex& GetVertex() const { return TopoDS::Vertex (myVertexMap.FindKey(myVertex)); }
+
+ 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;
+
+};
+
+#endif // _StdPrs_ShapeTool_HeaderFile
#include <StdPrs_ToolTriangulatedShape.hxx>
+#include <BRepBndLib.hxx>
#include <BRepMesh_DiscretFactory.hxx>
#include <BRepMesh_DiscretRoot.hxx>
#include <BRepTools.hxx>
}
}
+//=======================================================================
+//function : GetDeflection
+//purpose :
+//=======================================================================
+Standard_Real StdPrs_ToolTriangulatedShape::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();
+ }
+
+ // store computed relative deflection of shape as absolute deviation coefficient in case relative type to use it later on for sub-shapes
+ const Standard_Real aDeflection = Prs3d::GetDeflection (aBndBox, theDrawer->DeviationCoefficient(), theDrawer->MaximalChordialDeviation());
+ theDrawer->SetMaximalChordialDeviation (aDeflection);
+ return aDeflection;
+}
+
//=======================================================================
//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), true);
+ return BRepTools::Triangulation (theShape, GetDeflection (theShape, theDrawer), true);
}
// =======================================================================
return wasRecomputed;
}
- Standard_Real aDeflection = Prs3d::GetDeflection (theShape, theDrawer);
+ const Standard_Real aDeflection = GetDeflection (theShape, theDrawer);
// retrieve meshing tool from Factory
Handle(BRepMesh_DiscretRoot) aMeshAlgo = BRepMesh_DiscretFactory::Get().Discret (theShape,
Poly_Connect& thePolyConnect,
TColgp_Array1OfDir& theNormals);
+ //! 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);
+
//! Checks whether the shape is properly triangulated for a given display settings.
//! @param theShape [in] the shape.
//! @param theDrawer [in] the display settings.
#include <BRepAdaptor_HSurface.hxx>
#include <OSD_Parallel.hxx>
#include <StdPrs_DeflectionCurve.hxx>
-#include <StdPrs_ToolTriangulatedShape.hxx>
#include <StdPrs_Isolines.hxx>
+#include <StdPrs_ShapeTool.hxx>
+#include <StdPrs_ToolTriangulatedShape.hxx>
#include <Standard_ErrorHandler.hxx>
-#include <Prs3d_ShapeTool.hxx>
#include <Prs3d_IsoAspect.hxx>
#include <Prs3d.hxx>
-#include <Poly_Connect.hxx>
#include <Poly_PolygonOnTriangulation.hxx>
#include <Poly_Polygon3D.hxx>
#include <Poly_Triangulation.hxx>
Prs3d_NListOfSequenceOfPnt aCommonPolylines;
const Handle(Prs3d_LineAspect)& aWireAspect = theDrawer->WireAspect();
- const Standard_Real aShapeDeflection = Prs3d::GetDeflection (theShape, theDrawer);
+ const Standard_Real aShapeDeflection = StdPrs_ToolTriangulatedShape::GetDeflection (theShape, theDrawer);
// Draw isolines
{
for (TopExp_Explorer aFaceExplorer (theShape, TopAbs_FACE); aFaceExplorer.More(); aFaceExplorer.Next())
{
const TopoDS_Face& aFace = TopoDS::Face (aFaceExplorer.Current());
- if (theDrawer->IsoOnPlane() || !Prs3d_ShapeTool::IsPlanarFace (aFace))
+ if (theDrawer->IsoOnPlane() || !StdPrs_ShapeTool::IsPlanarFace (aFace))
{
aFaces[aNbFaces++] = aFace;
}
for (TopExp_Explorer aFaceExplorer (theShape, TopAbs_FACE); aFaceExplorer.More(); aFaceExplorer.Next())
{
const TopoDS_Face& aFace = TopoDS::Face (aFaceExplorer.Current());
- if (theDrawer->IsoOnPlane() || !Prs3d_ShapeTool::IsPlanarFace (aFace))
+ if (theDrawer->IsoOnPlane() || !StdPrs_ShapeTool::IsPlanarFace (aFace))
{
StdPrs_Isolines::Add (aFace, theDrawer, aShapeDeflection, *aUPolylinesPtr, *aVPolylinesPtr);
}
Handle(Graphic3d_ArrayOfPrimitives) StdPrs_WFShape::AddAllEdges (const TopoDS_Shape& theShape,
const Handle(Prs3d_Drawer)& theDrawer)
{
- const Standard_Real aShapeDeflection = Prs3d::GetDeflection (theShape, theDrawer);
+ const Standard_Real aShapeDeflection = StdPrs_ToolTriangulatedShape::GetDeflection (theShape, theDrawer);
Prs3d_NListOfSequenceOfPnt aPolylines;
addEdges (theShape, theDrawer, aShapeDeflection,
&aPolylines, &aPolylines, &aPolylines);
continue;
}
}
- const 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;
- }
- }
- }
-
- if (aNbFree == 0)
- {
- continue;
- }
-
- // Allocate the arrays.
- TColStd_Array1OfInteger aFree (1, 2 * aNbFree);
-
- Standard_Integer aFreeIndex = 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;
- }
- }
- }
-
- // free edges
- Standard_Integer aFreeHalfNb = aFree.Length() / 2;
- for (Standard_Integer anI = 1; anI <= aFreeHalfNb; ++anI)
+ if (const Handle(Poly_Triangulation)& aPolyTri = BRep_Tool::Triangulation (aFace, aLocation))
{
- gp_Pnt aPoint1 = aNodes (aFree (2 * anI - 1)).Transformed (aLocation);
- gp_Pnt aPoint2 = aNodes (aFree (2 * anI )).Transformed (aLocation);
- theSegments.Append (aPoint1);
- theSegments.Append (aPoint2);
+ Prs3d::AddFreeEdges (theSegments, aPolyTri, aLocation);
}
}
}
StdSelect.hxx
StdSelect_BRepOwner.cxx
StdSelect_BRepOwner.hxx
-StdSelect_BRepOwner.lxx
StdSelect_BRepSelectionTool.cxx
StdSelect_BRepSelectionTool.hxx
-StdSelect_DisplayMode.hxx
StdSelect_EdgeFilter.cxx
StdSelect_EdgeFilter.hxx
StdSelect_FaceFilter.cxx
StdSelect_FaceFilter.hxx
-StdSelect_IndexedDataMapOfOwnerPrs.hxx
-StdSelect_Prs.cxx
-StdSelect_Prs.hxx
-StdSelect_Prs.lxx
-StdSelect_SensitivityMode.hxx
StdSelect_Shape.cxx
StdSelect_Shape.hxx
StdSelect_ShapeTypeFilter.cxx
StdSelect_ShapeTypeFilter.hxx
-StdSelect_ShapeTypeFilter.lxx
StdSelect_TypeOfEdge.hxx
StdSelect_TypeOfFace.hxx
-StdSelect_TypeOfResult.hxx
StdSelect_TypeOfSelectionImage.hxx
-StdSelect_ViewerSelector3d.cxx
StdSelect_ViewerSelector3d.hxx
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
+#include <StdSelect.hxx>
-#include <Aspect_TypeOfLine.hxx>
-#include <gp_Ax3.hxx>
-#include <gp_Dir.hxx>
-#include <gp_Pnt.hxx>
-#include <Graphic3d_AspectLine3d.hxx>
-#include <Graphic3d_Group.hxx>
-#include <Graphic3d_Structure.hxx>
-#include <Graphic3d_StructureManager.hxx>
-#include <Quantity_NameOfColor.hxx>
-#include <Select3D_SensitiveCurve.hxx>
-#include <Select3D_SensitiveFace.hxx>
-#include <Select3D_SensitiveSegment.hxx>
#include <SelectMgr_Selection.hxx>
-#include <StdSelect.hxx>
#include <StdSelect_BRepOwner.hxx>
-#include <TColgp_HArray1OfPnt.hxx>
//=======================================================================
//function : SetDrawerForBRepOwner
#ifndef _StdSelect_HeaderFile
#define _StdSelect_HeaderFile
-#include <Standard.hxx>
-#include <Standard_DefineAlloc.hxx>
-#include <Standard_Handle.hxx>
-
#include <SelectMgr_Selection.hxx>
#include <Prs3d_Drawer.hxx>
-class StdSelect_BRepSelectionTool;
-class StdSelect_BRepOwner;
-class StdSelect_EdgeFilter;
-class StdSelect_FaceFilter;
-class StdSelect_ShapeTypeFilter;
-class StdSelect_Prs;
-class StdSelect_Shape;
-
//! The StdSelect package provides the following services
//! - the definition of selection modes for topological shapes
DEFINE_STANDARD_ALLOC
-
//! puts The same drawer in every BRepOwner Of SensitivePrimitive
//! Used Only for hilight Of BRepOwner...
Standard_EXPORT static void SetDrawerForBRepOwner (const Handle(SelectMgr_Selection)& aSelection, const Handle(Prs3d_Drawer)& aDrawer);
-
-
-
-protected:
-
-
-
-
-
-private:
-
-
-
-
-friend class StdSelect_BRepSelectionTool;
-friend class StdSelect_BRepOwner;
-friend class StdSelect_EdgeFilter;
-friend class StdSelect_FaceFilter;
-friend class StdSelect_ShapeTypeFilter;
-friend class StdSelect_Prs;
-friend class StdSelect_Shape;
-
};
-
-
-
-
-
-
#endif // _StdSelect_HeaderFile
+++ /dev/null
-// Copyright (c) 1997-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 <StdSelect_Shape.hxx>
-
-inline Standard_Boolean StdSelect_BRepOwner::HasHilightMode() const
-{return myCurMode == -1;}
-
-inline void StdSelect_BRepOwner::SetHilightMode(const Standard_Integer HiMod)
-{myCurMode=HiMod;}
-inline void StdSelect_BRepOwner::ResetHilightMode()
-{myCurMode =-1;}
-inline Standard_Integer StdSelect_BRepOwner::HilightMode() const
-{return myCurMode;}
-
-inline const TopoDS_Shape& StdSelect_BRepOwner::Shape() const
-{return myShape;}
-
-inline Standard_Boolean StdSelect_BRepOwner::HasShape() const
-{return !myShape.IsNull();}
-
-inline Standard_Boolean StdSelect_BRepOwner::ComesFromDecomposition() const
-{return myFromDecomposition;}
-
-
#include <BRepTools.hxx>
#include <BRepTools_WireExplorer.hxx>
#include <GCPnts_TangentialDeflection.hxx>
-#include <Geom_Circle.hxx>
#include <GeomAbs_SurfaceType.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <gp_Circ.hxx>
}
case GeomAbs_Circle:
{
- Handle (Geom_Circle) aCircle = new Geom_Circle (cu3d.Circle());
- if (aCircle->Radius() <= Precision::Confusion())
+ const gp_Circ aCircle = cu3d.Circle();
+ if (aCircle.Radius() <= Precision::Confusion())
{
- theSelection->Add (new Select3D_SensitivePoint (theOwner, aCircle->Location()));
+ theSelection->Add (new Select3D_SensitivePoint (theOwner, aCircle.Location()));
}
else
{
}
else
{
- theSensitiveList.Append (new Select3D_SensitiveCircle (theOwner, new Geom_Circle (cu3d.Circle()), theInteriorFlag, 16));
+ theSensitiveList.Append (new Select3D_SensitiveCircle (theOwner, cu3d.Circle(), theInteriorFlag, 16));
}
}
}
+++ /dev/null
-// Created on: 1995-03-08
-// Created by: Mister rmi
-// 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.
-
-#ifndef _StdSelect_DisplayMode_HeaderFile
-#define _StdSelect_DisplayMode_HeaderFile
-
-
-enum StdSelect_DisplayMode
-{
-StdSelect_DM_Wireframe,
-StdSelect_DM_Shading,
-StdSelect_DM_HLR
-};
-
-#endif // _StdSelect_DisplayMode_HeaderFile
+++ /dev/null
-// Created on: 1995-03-08
-// Created by: Mister rmi
-// 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.
-
-#ifndef StdSelect_IndexedDataMapOfOwnerPrs_HeaderFile
-#define StdSelect_IndexedDataMapOfOwnerPrs_HeaderFile
-
-#include <SelectMgr_EntityOwner.hxx>
-#include <StdSelect_Prs.hxx>
-#include <TColStd_MapTransientHasher.hxx>
-#include <NCollection_IndexedDataMap.hxx>
-
-typedef NCollection_IndexedDataMap<Handle(SelectMgr_EntityOwner), Handle(StdSelect_Prs), TColStd_MapTransientHasher> StdSelect_IndexedDataMapOfOwnerPrs;
-
-#endif
+++ /dev/null
-// Created on: 1995-03-17
-// Created by: Robert COUBLANC
-// 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 <Graphic3d_StructureManager.hxx>
-#include <Standard_Type.hxx>
-#include <StdSelect_Prs.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(StdSelect_Prs,Prs3d_Presentation)
-
-StdSelect_Prs::
-StdSelect_Prs(const Handle(Graphic3d_StructureManager)& aStructureManager):
-Prs3d_Presentation(aStructureManager),
-myManager(aStructureManager){}
-
+++ /dev/null
-// Created on: 1995-03-17
-// Created by: Robert COUBLANC
-// 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.
-
-#ifndef _StdSelect_Prs_HeaderFile
-#define _StdSelect_Prs_HeaderFile
-
-#include <Standard.hxx>
-#include <Standard_Type.hxx>
-
-#include <Prs3d_Presentation.hxx>
-class Graphic3d_StructureManager;
-
-
-class StdSelect_Prs;
-DEFINE_STANDARD_HANDLE(StdSelect_Prs, Prs3d_Presentation)
-
-//! allows entities owners to be hilighted
-//! independantly from PresentableObjects
-class StdSelect_Prs : public Prs3d_Presentation
-{
-
-public:
-
-
- Standard_EXPORT StdSelect_Prs(const Handle(Graphic3d_StructureManager)& aStructureManager);
-
- const Handle(Graphic3d_StructureManager)& Manager() const;
-
-
-
-
- DEFINE_STANDARD_RTTIEXT(StdSelect_Prs,Prs3d_Presentation)
-
-protected:
-
-
-
-
-private:
-
-
- Handle(Graphic3d_StructureManager) myManager;
-
-
-};
-
-
-#include <StdSelect_Prs.lxx>
-
-
-
-
-
-#endif // _StdSelect_Prs_HeaderFile
+++ /dev/null
-// Copyright (c) 1997-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.
-
-inline const Handle(Graphic3d_StructureManager)& StdSelect_Prs::
-Manager() const {return myManager;}
+++ /dev/null
-// Created on: 1995-03-08
-// Created by: Mister rmi
-// 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.
-
-#ifndef _StdSelect_SensitivityMode_HeaderFile
-#define _StdSelect_SensitivityMode_HeaderFile
-
-//! Selection sensitivity mode. SM_WINDOW mode uses the
-//! specified pixel tolerance to compute the sensitivity value,
-//! SM_VIEW mode allows to define the sensitivity manually.
-enum StdSelect_SensitivityMode
-{
-StdSelect_SM_WINDOW,
-StdSelect_SM_VIEW
-};
-
-#endif // _StdSelect_SensitivityMode_HeaderFile
#include <StdSelect_Shape.hxx>
-#include <Geom_Transformation.hxx>
#include <Prs3d_Drawer.hxx>
#include <Prs3d_Presentation.hxx>
#include <Standard_Type.hxx>
#ifndef _StdSelect_ShapeTypeFilter_HeaderFile
#define _StdSelect_ShapeTypeFilter_HeaderFile
-#include <Standard.hxx>
-#include <Standard_Type.hxx>
-
#include <TopAbs_ShapeEnum.hxx>
#include <SelectMgr_Filter.hxx>
-#include <Standard_Boolean.hxx>
-class SelectMgr_EntityOwner;
+class SelectMgr_EntityOwner;
-class StdSelect_ShapeTypeFilter;
DEFINE_STANDARD_HANDLE(StdSelect_ShapeTypeFilter, SelectMgr_Filter)
-//! A filter framework which allows you to define a filter
-//! for a specific shape type. The types available include:
-//! - compound
-//! - compsolid
-//! - solid
-//! - shell
-//! - face
-//! - wire
-//! - edge
-//! - vertex.
+//! A filter framework which allows you to define a filter for a specific shape type.
class StdSelect_ShapeTypeFilter : public SelectMgr_Filter
{
-
+ DEFINE_STANDARD_RTTIEXT(StdSelect_ShapeTypeFilter, SelectMgr_Filter)
public:
-
//! Constructs a filter object defined by the shape type aType.
Standard_EXPORT StdSelect_ShapeTypeFilter(const TopAbs_ShapeEnum aType);
-
- Standard_EXPORT virtual Standard_Boolean IsOk (const Handle(SelectMgr_EntityOwner)& anobj) const Standard_OVERRIDE;
-
- //! Returns the type of shape selected by the filter.
- TopAbs_ShapeEnum Type() const;
-
- Standard_EXPORT virtual Standard_Boolean ActsOn (const TopAbs_ShapeEnum aStandardMode) const Standard_OVERRIDE;
-
-
-
-
- DEFINE_STANDARD_RTTIEXT(StdSelect_ShapeTypeFilter,SelectMgr_Filter)
-
-protected:
+ //! Returns the type of shape selected by the filter.
+ TopAbs_ShapeEnum Type() const {return myType;}
+ Standard_EXPORT virtual Standard_Boolean IsOk (const Handle(SelectMgr_EntityOwner)& anobj) const Standard_OVERRIDE;
+ Standard_EXPORT virtual Standard_Boolean ActsOn (const TopAbs_ShapeEnum aStandardMode) const Standard_OVERRIDE;
private:
-
TopAbs_ShapeEnum myType;
-
};
-
-#include <StdSelect_ShapeTypeFilter.lxx>
-
-
-
-
-
#endif // _StdSelect_ShapeTypeFilter_HeaderFile
+++ /dev/null
-// Created on: 1997-03-06
-// Created by: Robert COUBLANC
-// Copyright (c) 1997-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.
-
-inline TopAbs_ShapeEnum StdSelect_ShapeTypeFilter::Type() const
-{return myType;}
+++ /dev/null
-// Created on: 1995-03-08
-// Created by: Mister rmi
-// 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.
-
-#ifndef _StdSelect_TypeOfResult_HeaderFile
-#define _StdSelect_TypeOfResult_HeaderFile
-
-//! Provides values for type of result.
-//! These are used to specify whether the result is to
-//! be simple or whether it may be multiple.
-enum StdSelect_TypeOfResult
-{
-StdSelect_TOR_SIMPLE,
-StdSelect_TOR_MULTIPLE
-};
-
-#endif // _StdSelect_TypeOfResult_HeaderFile
+++ /dev/null
-// Created on: 1995-03-15
-// Created by: Robert COUBLANC
-// 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 <StdSelect_ViewerSelector3d.hxx>
-#include <StdSelect.hxx>
-#include <Select3D_SensitiveEntity.hxx>
-#include <Graphic3d_AspectLine3d.hxx>
-#include <gp_Pnt.hxx>
-#include <gp_Lin.hxx>
-#include <gp_Pnt2d.hxx>
-#include <gp_Dir.hxx>
-#include <gp_Ax3.hxx>
-#include <gp_GTrsf.hxx>
-#include <gp_Pln.hxx>
-#include <Select3D_SensitiveEntity.hxx>
-#include <Graphic3d_ArrayOfPolylines.hxx>
-#include <Graphic3d_Group.hxx>
-#include <Graphic3d_SequenceOfHClipPlane.hxx>
-#include <Graphic3d_Structure.hxx>
-#include <SelectMgr_SelectableObject.hxx>
-#include <TColgp_HArray1OfPnt.hxx>
-#include <TColgp_Array1OfPnt.hxx>
-#include <TColgp_Array1OfPnt2d.hxx>
-#include <TColgp_HArray1OfPnt2d.hxx>
-#include <Select3D_SensitiveCurve.hxx>
-#include <Select3D_SensitiveSegment.hxx>
-#include <Select3D_SensitiveFace.hxx>
-#include <Select3D_SensitiveCircle.hxx>
-#include <Select3D_SensitivePoint.hxx>
-#include <Select3D_SensitiveTriangulation.hxx>
-#include <Select3D_SensitiveTriangle.hxx>
-#include <Select3D_SensitiveWire.hxx>
-#include <Select3D_SensitiveBox.hxx>
-#include <SelectMgr_Selection.hxx>
-#include <SelectMgr_EntityOwner.hxx>
-
-#include <Aspect_Grid.hxx>
-#include &l