From 7f24b768c30df045ec4a7c712724195643081dfb Mon Sep 17 00:00:00 2001 From: kgv Date: Sat, 14 Mar 2020 13:32:48 +0300 Subject: [PATCH] 0031458: Visualization - refine classes across Prs3d and StdPrs packages Prs3d::GetDeflection() has been moved to StdPrs_ToolTriangulatedShape::GetDeflection(). Prs3d_ShapeTool has been moved to StdPrs_ShapeTool. Code collecting free edges on Poly_Triangulation has been moved out from StdPrs_WFShape to Prs3d::AddFreeEdges(). StdPrs_BndBox has been moved to Prs3d_BndBox. Geom_Transformation has been replaced by TopLoc_Datum3D within visualization classes. Select3D_SensitiveCircle constructor now takes gp_Circ instead of Geom_Circle. StdSelect_ViewerSelector3d has been moved to SelectMgr_ViewerSelector3d. Methods ::GetPoint3d() and ::ArrayBounds() has been moved from subclass Select3D_SensitiveCircle to the base class Select3D_SensitiveCurve. StdSelect_ViewerSelector3d::computeSensitivePrs() has been moved to SelectMgr::ComputeSensitivePrs(). Removed unused declarations StdSelect_Prs, StdSelect_DisplayMode, StdSelect_SensitivityMode, StdSelect_TypeOfResult, SelectMgr_SOPtr, TColQuantity. Package Graphic3d has been moved from TKV3d to TKService. --- adm/UDLIST | 1 - dox/dev_guides/upgrade/upgrade.md | 10 + .../ios/UIKitSample/UIKitSample/OcctViewer.mm | 4 +- samples/mfc/standard/Common/User_Cylinder.cxx | 6 +- samples/mfc/standard/Common/User_Cylinder.hxx | 2 +- src/AIS/AIS_Axis.cxx | 1 - src/AIS/AIS_Circle.cxx | 5 +- src/AIS/AIS_ColoredShape.cxx | 4 +- src/AIS/AIS_ConnectedInteractive.cxx | 4 +- src/AIS/AIS_ConnectedInteractive.hxx | 10 +- src/AIS/AIS_Line.cxx | 1 - src/AIS/AIS_Manipulator.cxx | 14 +- src/AIS/AIS_Manipulator.hxx | 4 +- src/AIS/AIS_MultipleConnectedInteractive.cxx | 2 +- src/AIS/AIS_MultipleConnectedInteractive.hxx | 10 +- src/AIS/AIS_Plane.cxx | 1 - src/AIS/AIS_PlaneTrihedron.cxx | 1 - src/AIS/AIS_Point.cxx | 1 - src/AIS/AIS_PointCloud.cxx | 4 +- src/AIS/AIS_Shape.cxx | 8 +- src/AIS/AIS_Shape.hxx | 2 +- src/AIS/AIS_TexturedShape.cxx | 4 +- src/AIS/AIS_Trihedron.cxx | 1 - src/AIS/AIS_Trihedron.hxx | 5 - src/Font/FILES | 2 - src/Font/Font_BRepFont.hxx | 227 +--- src/Font/Font_BRepTextBuilder.hxx | 37 +- src/Graphic3d/Graphic3d_CStructure.hxx | 8 +- src/Graphic3d/Graphic3d_CView.cxx | 6 +- src/Graphic3d/Graphic3d_CView.hxx | 2 +- src/Graphic3d/Graphic3d_Structure.cxx | 4 +- src/Graphic3d/Graphic3d_Structure.hxx | 8 +- src/Graphic3d/Graphic3d_StructureManager.cxx | 2 +- src/Graphic3d/Graphic3d_StructureManager.hxx | 2 +- src/Graphic3d/Graphic3d_ZLayerSettings.hxx | 11 +- src/IVtkOCC/IVtkOCC_ShapeMesher.cxx | 3 +- src/MeshVS/MeshVS_MeshEntityOwner.cxx | 2 +- src/MeshVS/MeshVS_MeshEntityOwner.hxx | 9 +- src/MeshVS/MeshVS_MeshOwner.cxx | 2 +- src/MeshVS/MeshVS_MeshOwner.hxx | 9 +- src/OpenGl/OpenGl_Structure.cxx | 11 +- src/OpenGl/OpenGl_Structure.hxx | 2 +- src/OpenGl/OpenGl_View.hxx | 2 +- src/OpenGl/OpenGl_View_Raytrace.cxx | 2 +- src/Prs3d/FILES | 3 +- src/Prs3d/Prs3d.cxx | 120 +- src/Prs3d/Prs3d.hxx | 69 +- .../Prs3d_BndBox.cxx} | 14 +- src/Prs3d/Prs3d_BndBox.hxx | 148 +++ src/Prs3d/Prs3d_ShapeTool.hxx | 92 +- src/Prs3d/Prs3d_ToolCylinder.hxx | 1 - src/Prs3d/Prs3d_ToolDisk.hxx | 1 - src/Prs3d/Prs3d_ToolQuadric.hxx | 6 - src/Prs3d/Prs3d_ToolSector.hxx | 1 - src/Prs3d/Prs3d_ToolSphere.hxx | 8 - src/PrsDim/PrsDim_ConcentricRelation.cxx | 11 +- src/PrsDim/PrsDim_Dimension.cxx | 6 +- src/PrsDim/PrsDim_EqualDistanceRelation.cxx | 15 +- src/PrsMgr/PrsMgr_PresentableObject.cxx | 14 +- src/PrsMgr/PrsMgr_PresentableObject.hxx | 22 +- src/PrsMgr/PrsMgr_Presentation.cxx | 1 - src/PrsMgr/PrsMgr_Presentation.hxx | 1 - src/PrsMgr/PrsMgr_PresentationManager.cxx | 23 +- src/PrsMgr/PrsMgr_PresentationManager.hxx | 6 +- src/QABugs/QABugs_17.cxx | 1 - src/Select3D/Select3D_SensitiveCircle.cxx | 133 +- src/Select3D/Select3D_SensitiveCircle.hxx | 20 +- src/Select3D/Select3D_SensitiveCurve.cxx | 55 +- src/Select3D/Select3D_SensitiveCurve.hxx | 27 +- src/Select3D/Select3D_SensitivePoly.hxx | 16 + src/SelectMgr/FILES | 7 +- src/SelectMgr/SelectMgr.cxx | 252 ++++ src/SelectMgr/SelectMgr.hxx | 37 + src/SelectMgr/SelectMgr_SOPtr.hxx | 23 - .../SelectMgr_SelectionImageFiller.cxx | 361 ++++++ .../SelectMgr_SelectionImageFiller.hxx | 82 ++ src/SelectMgr/SelectMgr_ViewerSelector.cxx | 22 + src/SelectMgr/SelectMgr_ViewerSelector.hxx | 9 + src/SelectMgr/SelectMgr_ViewerSelector3d.cxx | 265 ++++ src/SelectMgr/SelectMgr_ViewerSelector3d.hxx | 96 ++ src/StdPrs/FILES | 7 +- .../StdPrs_BRepFont.cxx} | 57 +- src/StdPrs/StdPrs_BRepFont.hxx | 244 ++++ .../StdPrs_BRepTextBuilder.cxx} | 18 +- src/StdPrs/StdPrs_BRepTextBuilder.hxx | 51 + src/StdPrs/StdPrs_BndBox.hxx | 133 +- .../StdPrs_ShapeTool.cxx} | 217 +--- src/StdPrs/StdPrs_ShapeTool.hxx | 110 ++ src/StdPrs/StdPrs_ToolTriangulatedShape.cxx | 38 +- src/StdPrs/StdPrs_ToolTriangulatedShape.hxx | 14 + src/StdPrs/StdPrs_WFShape.cxx | 77 +- src/StdSelect/FILES | 10 - src/StdSelect/StdSelect.cxx | 15 +- src/StdSelect/StdSelect.hxx | 41 - src/StdSelect/StdSelect_BRepOwner.lxx | 36 - src/StdSelect/StdSelect_BRepSelectionTool.cxx | 9 +- src/StdSelect/StdSelect_DisplayMode.hxx | 28 - .../StdSelect_IndexedDataMapOfOwnerPrs.hxx | 27 - src/StdSelect/StdSelect_Prs.cxx | 28 - src/StdSelect/StdSelect_Prs.hxx | 67 - src/StdSelect/StdSelect_Prs.lxx | 16 - src/StdSelect/StdSelect_SensitivityMode.hxx | 29 - src/StdSelect/StdSelect_Shape.cxx | 1 - src/StdSelect/StdSelect_ShapeTypeFilter.hxx | 48 +- src/StdSelect/StdSelect_ShapeTypeFilter.lxx | 18 - src/StdSelect/StdSelect_TypeOfResult.hxx | 29 - src/StdSelect/StdSelect_ViewerSelector3d.cxx | 1104 ----------------- src/StdSelect/StdSelect_ViewerSelector3d.hxx | 105 +- src/TColQuantity/FILES | 4 - .../TColQuantity_Array1OfLength.hxx | 26 - .../TColQuantity_Array2OfLength.hxx | 26 - .../TColQuantity_HArray1OfLength.hxx | 27 - .../TColQuantity_HArray2OfLength.hxx | 27 - src/TKOpenGl/EXTERNLIB | 1 - src/TKService/EXTERNLIB | 6 - src/TKService/PACKAGES | 2 +- src/TKV3d/PACKAGES | 1 - src/TPrsStd/TPrsStd_NamedShapeDriver.cxx | 1 - src/TopLoc/FILES | 1 - src/TopLoc/TopLoc_Datum3D.hxx | 33 +- src/TopLoc/TopLoc_Datum3D.lxx | 25 - src/V3d/V3d_CircularGrid.cxx | 2 +- src/V3d/V3d_Plane.cxx | 2 +- src/V3d/V3d_RectangularGrid.cxx | 2 +- src/ViewerTest/ViewerTest_ObjectCommands.cxx | 6 +- .../VrmlConverter_WFDeflectionShape.cxx | 4 +- src/VrmlConverter/VrmlConverter_WFShape.cxx | 4 +- 127 files changed, 2212 insertions(+), 2989 deletions(-) rename src/{StdPrs/StdPrs_BndBox.cxx => Prs3d/Prs3d_BndBox.cxx} (81%) create mode 100644 src/Prs3d/Prs3d_BndBox.hxx create mode 100644 src/SelectMgr/SelectMgr.cxx create mode 100644 src/SelectMgr/SelectMgr.hxx delete mode 100644 src/SelectMgr/SelectMgr_SOPtr.hxx create mode 100644 src/SelectMgr/SelectMgr_SelectionImageFiller.cxx create mode 100644 src/SelectMgr/SelectMgr_SelectionImageFiller.hxx create mode 100644 src/SelectMgr/SelectMgr_ViewerSelector3d.cxx create mode 100644 src/SelectMgr/SelectMgr_ViewerSelector3d.hxx rename src/{Font/Font_BRepFont.cxx => StdPrs/StdPrs_BRepFont.cxx} (91%) mode change 100755 => 100644 create mode 100644 src/StdPrs/StdPrs_BRepFont.hxx rename src/{Font/Font_BRepTextBuilder.cxx => StdPrs/StdPrs_BRepTextBuilder.cxx} (77%) create mode 100644 src/StdPrs/StdPrs_BRepTextBuilder.hxx rename src/{Prs3d/Prs3d_ShapeTool.cxx => StdPrs/StdPrs_ShapeTool.cxx} (53%) create mode 100644 src/StdPrs/StdPrs_ShapeTool.hxx delete mode 100644 src/StdSelect/StdSelect_BRepOwner.lxx delete mode 100644 src/StdSelect/StdSelect_DisplayMode.hxx delete mode 100644 src/StdSelect/StdSelect_IndexedDataMapOfOwnerPrs.hxx delete mode 100644 src/StdSelect/StdSelect_Prs.cxx delete mode 100644 src/StdSelect/StdSelect_Prs.hxx delete mode 100644 src/StdSelect/StdSelect_Prs.lxx delete mode 100644 src/StdSelect/StdSelect_SensitivityMode.hxx delete mode 100644 src/StdSelect/StdSelect_ShapeTypeFilter.lxx delete mode 100644 src/StdSelect/StdSelect_TypeOfResult.hxx delete mode 100644 src/StdSelect/StdSelect_ViewerSelector3d.cxx delete mode 100644 src/TColQuantity/FILES delete mode 100644 src/TColQuantity/TColQuantity_Array1OfLength.hxx delete mode 100644 src/TColQuantity/TColQuantity_Array2OfLength.hxx delete mode 100644 src/TColQuantity/TColQuantity_HArray1OfLength.hxx delete mode 100644 src/TColQuantity/TColQuantity_HArray2OfLength.hxx delete mode 100644 src/TopLoc/TopLoc_Datum3D.lxx diff --git a/adm/UDLIST b/adm/UDLIST index b81cd39c31..bb83ccd9fb 100644 --- a/adm/UDLIST +++ b/adm/UDLIST @@ -216,7 +216,6 @@ n SelectBasics n SelectMgr n StdPrs n StdSelect -n TColQuantity n V3d n WNT n Xw diff --git a/dox/dev_guides/upgrade/upgrade.md b/dox/dev_guides/upgrade/upgrade.md index 9f70d21deb..fb2e134943 100644 --- a/dox/dev_guides/upgrade/upgrade.md +++ b/dox/dev_guides/upgrade/upgrade.md @@ -1889,6 +1889,16 @@ Unexpected const-ness of Aspect_Window::DoResize() method has been removed, so t 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*. diff --git a/samples/ios/UIKitSample/UIKitSample/OcctViewer.mm b/samples/ios/UIKitSample/UIKitSample/OcctViewer.mm index 0ede0c71ac..c2c4fe80bb 100644 --- a/samples/ios/UIKitSample/UIKitSample/OcctViewer.mm +++ b/samples/ios/UIKitSample/UIKitSample/OcctViewer.mm @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include #include @@ -257,7 +257,7 @@ bool OcctViewer::ImportSTEP(std::string theFilename) } 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; diff --git a/samples/mfc/standard/Common/User_Cylinder.cxx b/samples/mfc/standard/Common/User_Cylinder.cxx index 9de18f60bf..b2c482024b 100755 --- a/samples/mfc/standard/Common/User_Cylinder.cxx +++ b/samples/mfc/standard/Common/User_Cylinder.cxx @@ -20,7 +20,7 @@ IMPLEMENT_STANDARD_RTTIEXT(User_Cylinder,AIS_InteractiveObject) #include #include #include -#include +#include #include @@ -88,7 +88,7 @@ case 6: //color mygroup->SetPrimitivesAspect(myAspect); myAspect->SetEdgeOn(); - myDeflection = Prs3d::GetDeflection(myShape,myDrawer); + myDeflection = StdPrs_ToolTriangulatedShape::GetDeflection(myShape,myDrawer); BRepMesh_IncrementalMesh(myShape,myDeflection); myX1OnOff = Standard_False; @@ -292,7 +292,7 @@ case 6: //color } 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(); diff --git a/samples/mfc/standard/Common/User_Cylinder.hxx b/samples/mfc/standard/Common/User_Cylinder.hxx index 16eb7a6f39..1602d850d3 100755 --- a/samples/mfc/standard/Common/User_Cylinder.hxx +++ b/samples/mfc/standard/Common/User_Cylinder.hxx @@ -30,7 +30,7 @@ private: 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) ; diff --git a/src/AIS/AIS_Axis.cxx b/src/AIS/AIS_Axis.cxx index 507a4325fa..5c1d8c3767 100644 --- a/src/AIS/AIS_Axis.cxx +++ b/src/AIS/AIS_Axis.cxx @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include diff --git a/src/AIS/AIS_Circle.cxx b/src/AIS/AIS_Circle.cxx index 19f9ea1269..78239a13b7 100644 --- a/src/AIS/AIS_Circle.cxx +++ b/src/AIS/AIS_Circle.cxx @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -248,7 +247,7 @@ void AIS_Circle::ComputeCircleSelection(const Handle(SelectMgr_Selection)& aSele { Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this); Handle(Select3D_SensitiveCircle) seg = new Select3D_SensitiveCircle (eown, - myComponent, + myComponent->Circ(), myIsFilledCircleSens); aSelection->Add(seg); } @@ -263,7 +262,7 @@ void AIS_Circle::ComputeArcSelection(const Handle(SelectMgr_Selection)& aSelecti 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); diff --git a/src/AIS/AIS_ColoredShape.cxx b/src/AIS/AIS_ColoredShape.cxx index 3354a5c360..22b58730a0 100644 --- a/src/AIS/AIS_ColoredShape.cxx +++ b/src/AIS/AIS_ColoredShape.cxx @@ -372,7 +372,7 @@ void AIS_ColoredShape::Compute (const Handle(PrsMgr_PresentationManager3d)& theP // 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: @@ -490,7 +490,7 @@ void AIS_ColoredShape::ComputeSelection (const Handle(SelectMgr_Selection)& theS } 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() diff --git a/src/AIS/AIS_ConnectedInteractive.cxx b/src/AIS/AIS_ConnectedInteractive.cxx index ac45194a5b..cf839411f3 100644 --- a/src/AIS/AIS_ConnectedInteractive.cxx +++ b/src/AIS/AIS_ConnectedInteractive.cxx @@ -55,7 +55,7 @@ AIS_InteractiveObject(aTypeOfPresentation3d) //purpose : //======================================================================= void AIS_ConnectedInteractive::connect (const Handle(AIS_InteractiveObject)& theAnotherObj, - const Handle(Geom_Transformation)& theLocation) + const Handle(TopLoc_Datum3D)& theLocation) { if (myReference == theAnotherObj) { @@ -141,7 +141,7 @@ void AIS_ConnectedInteractive::Compute (const Handle(PrsMgr_PresentationManager3 //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() diff --git a/src/AIS/AIS_ConnectedInteractive.hxx b/src/AIS/AIS_ConnectedInteractive.hxx index ec53af2e5c..cebfaac2c5 100644 --- a/src/AIS/AIS_ConnectedInteractive.hxx +++ b/src/AIS/AIS_ConnectedInteractive.hxx @@ -52,19 +52,19 @@ public: //! 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. @@ -107,7 +107,7 @@ protected: //! 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 @@ -123,7 +123,7 @@ protected: 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: diff --git a/src/AIS/AIS_Line.cxx b/src/AIS/AIS_Line.cxx index d96dfd9ff8..499ccecbf0 100644 --- a/src/AIS/AIS_Line.cxx +++ b/src/AIS/AIS_Line.cxx @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include diff --git a/src/AIS/AIS_Manipulator.cxx b/src/AIS/AIS_Manipulator.cxx index a7503e71b2..bb0ced8bdf 100644 --- a/src/AIS/AIS_Manipulator.cxx +++ b/src/AIS/AIS_Manipulator.cxx @@ -19,8 +19,6 @@ #include #include #include -#include -#include #include #include #include @@ -86,10 +84,10 @@ namespace 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, @@ -703,7 +701,7 @@ void AIS_Manipulator::Transform (const gp_Trsf& theTrsf) { 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) { @@ -782,7 +780,7 @@ void AIS_Manipulator::updateTransformation() 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 @@ -920,7 +918,7 @@ void AIS_Manipulator::setTransformPersistence (const Handle(Graphic3d_TransformP //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"); @@ -1131,7 +1129,7 @@ void AIS_Manipulator::ComputeSelection (const Handle(SelectMgr_Selection)& theSe 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); diff --git a/src/AIS/AIS_Manipulator.hxx b/src/AIS/AIS_Manipulator.hxx index 9fb2494fd6..b05e1dc57c 100644 --- a/src/AIS/AIS_Manipulator.hxx +++ b/src/AIS/AIS_Manipulator.hxx @@ -357,7 +357,7 @@ protected: //! 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 @@ -520,7 +520,7 @@ protected: //! @name Auxiliary classes to fill presentation with proper primitiv } } - void Transform (const Handle(Geom_Transformation)& theTransformation) + void Transform (const Handle(TopLoc_Datum3D)& theTransformation) { if (!myHighlightTranslator.IsNull()) { diff --git a/src/AIS/AIS_MultipleConnectedInteractive.cxx b/src/AIS/AIS_MultipleConnectedInteractive.cxx index 7e9387c466..d201fbd319 100644 --- a/src/AIS/AIS_MultipleConnectedInteractive.cxx +++ b/src/AIS/AIS_MultipleConnectedInteractive.cxx @@ -60,7 +60,7 @@ Standard_Integer AIS_MultipleConnectedInteractive::Signature() const //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()) diff --git a/src/AIS/AIS_MultipleConnectedInteractive.hxx b/src/AIS/AIS_MultipleConnectedInteractive.hxx index f5109006ed..da79236975 100644 --- a/src/AIS/AIS_MultipleConnectedInteractive.hxx +++ b/src/AIS/AIS_MultipleConnectedInteractive.hxx @@ -38,7 +38,7 @@ public: //! 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); @@ -86,7 +86,7 @@ public: // short aliases to Connect() method 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. @@ -96,7 +96,7 @@ public: // short aliases to Connect() method 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") @@ -105,7 +105,7 @@ public: // short aliases to Connect() method 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: @@ -122,7 +122,7 @@ 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: diff --git a/src/AIS/AIS_Plane.cxx b/src/AIS/AIS_Plane.cxx index afb0da2e91..b46b9aae20 100644 --- a/src/AIS/AIS_Plane.cxx +++ b/src/AIS/AIS_Plane.cxx @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include diff --git a/src/AIS/AIS_PlaneTrihedron.cxx b/src/AIS/AIS_PlaneTrihedron.cxx index 7a3d476cd3..e668b22ce8 100644 --- a/src/AIS/AIS_PlaneTrihedron.cxx +++ b/src/AIS/AIS_PlaneTrihedron.cxx @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include diff --git a/src/AIS/AIS_Point.cxx b/src/AIS/AIS_Point.cxx index 0acb6a1c3f..4ac15e329a 100644 --- a/src/AIS/AIS_Point.cxx +++ b/src/AIS/AIS_Point.cxx @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include diff --git a/src/AIS/AIS_PointCloud.cxx b/src/AIS/AIS_PointCloud.cxx index a395b0de4e..b3a2727a23 100644 --- a/src/AIS/AIS_PointCloud.cxx +++ b/src/AIS/AIS_PointCloud.cxx @@ -29,7 +29,7 @@ #include #include #include -#include +#include IMPLEMENT_STANDARD_RTTIEXT(AIS_PointCloudOwner, SelectMgr_EntityOwner) IMPLEMENT_STANDARD_RTTIEXT(AIS_PointCloud, AIS_InteractiveObject) @@ -400,7 +400,7 @@ void AIS_PointCloud::Compute (const Handle(PrsMgr_PresentationManager3d)& /*theP return; } - StdPrs_BndBox::Add (thePrs, aBndBox, myDrawer); + Prs3d_BndBox::Add (thePrs, aBndBox, myDrawer); break; } } diff --git a/src/AIS/AIS_Shape.cxx b/src/AIS/AIS_Shape.cxx index ca23c15921..feda097ae6 100644 --- a/src/AIS/AIS_Shape.cxx +++ b/src/AIS/AIS_Shape.cxx @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include @@ -45,7 +44,7 @@ #include #include #include -#include +#include #include #include #include @@ -60,7 +59,6 @@ #include #include #include -#include #include #include @@ -210,7 +208,7 @@ void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentat } else { - StdPrs_BndBox::Add (aPrs, BoundingBox(), myDrawer); + Prs3d_BndBox::Add (aPrs, BoundingBox(), myDrawer); } } } @@ -327,7 +325,7 @@ void AIS_Shape::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection, // 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 diff --git a/src/AIS/AIS_Shape.hxx b/src/AIS/AIS_Shape.hxx index ad13131f62..ce3ca48b20 100644 --- a/src/AIS/AIS_Shape.hxx +++ b/src/AIS/AIS_Shape.hxx @@ -254,7 +254,7 @@ protected: //! 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() diff --git a/src/AIS/AIS_TexturedShape.cxx b/src/AIS/AIS_TexturedShape.cxx index 00b1c22695..552c95f07c 100644 --- a/src/AIS/AIS_TexturedShape.cxx +++ b/src/AIS/AIS_TexturedShape.cxx @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include #include @@ -433,7 +433,7 @@ void AIS_TexturedShape::Compute (const Handle(PrsMgr_PresentationManager3d)& /*t } else { - StdPrs_BndBox::Add (thePrs, BoundingBox(), myDrawer); + Prs3d_BndBox::Add (thePrs, BoundingBox(), myDrawer); } break; } diff --git a/src/AIS/AIS_Trihedron.cxx b/src/AIS/AIS_Trihedron.cxx index aa50e63841..5105e8391c 100644 --- a/src/AIS/AIS_Trihedron.cxx +++ b/src/AIS/AIS_Trihedron.cxx @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include diff --git a/src/AIS/AIS_Trihedron.hxx b/src/AIS/AIS_Trihedron.hxx index 011334e0e3..d239b2aeea 100644 --- a/src/AIS/AIS_Trihedron.hxx +++ b/src/AIS/AIS_Trihedron.hxx @@ -33,11 +33,6 @@ #include 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. diff --git a/src/Font/FILES b/src/Font/FILES index 3a0d070d02..c173a250d0 100644 --- a/src/Font/FILES +++ b/src/Font/FILES @@ -1,6 +1,4 @@ -Font_BRepFont.cxx Font_BRepFont.hxx -Font_BRepTextBuilder.cxx Font_BRepTextBuilder.hxx Font_FontAspect.hxx Font_FontMgr.cxx diff --git a/src/Font/Font_BRepFont.hxx b/src/Font/Font_BRepFont.hxx index d143038a3a..f6673f9c90 100755 --- a/src/Font/Font_BRepFont.hxx +++ b/src/Font/Font_BRepFont.hxx @@ -15,230 +15,9 @@ #ifndef _Font_BRepFont_H__ #define _Font_BRepFont_H__ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include -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& theWires, - TopoDS_Shape& theRes); - - //! Hide visibility. - using Font_FTFont::FindAndCreate; - -protected: //! @name Protected fields - - NCollection_DataMap - 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__ diff --git a/src/Font/Font_BRepTextBuilder.hxx b/src/Font/Font_BRepTextBuilder.hxx index af03f79e3d..bf9bb8a1bc 100644 --- a/src/Font/Font_BRepTextBuilder.hxx +++ b/src/Font/Font_BRepTextBuilder.hxx @@ -1,6 +1,4 @@ -// 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. // @@ -16,36 +14,9 @@ #ifndef Font_BRepTextBuilder_Header #define Font_BRepTextBuilder_Header -#include -#include -#include +#include -//! 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 diff --git a/src/Graphic3d/Graphic3d_CStructure.hxx b/src/Graphic3d/Graphic3d_CStructure.hxx index 053b3ba364..6ce2599277 100644 --- a/src/Graphic3d/Graphic3d_CStructure.hxx +++ b/src/Graphic3d/Graphic3d_CStructure.hxx @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include class Graphic3d_GraphicDriver; @@ -79,10 +79,10 @@ public: } //! 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; } @@ -227,7 +227,7 @@ protected: 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 diff --git a/src/Graphic3d/Graphic3d_CView.cxx b/src/Graphic3d/Graphic3d_CView.cxx index 6306a58fdf..eb01c689fe 100644 --- a/src/Graphic3d/Graphic3d_CView.cxx +++ b/src/Graphic3d/Graphic3d_CView.cxx @@ -298,7 +298,7 @@ void Graphic3d_CView::ReCompute (const Handle(Graphic3d_Structure)& theStruct) // 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(); @@ -768,7 +768,7 @@ void Graphic3d_CView::Display (const Handle(Graphic3d_Structure)& theStructure) if (anIndex != 0) { aStruct = myStructsComputed.Value (anIndex); - aStruct->SetTransformation (Handle(Geom_Transformation)()); + aStruct->SetTransformation (Handle(TopLoc_Datum3D)()); } theStructure->computeHLR (myCamera, aStruct); @@ -871,7 +871,7 @@ void Graphic3d_CView::Highlight (const Handle(Graphic3d_Structure)& theStructure // 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) diff --git a/src/Graphic3d/Graphic3d_CView.hxx b/src/Graphic3d/Graphic3d_CView.hxx index 82d689393e..3642e605af 100644 --- a/src/Graphic3d/Graphic3d_CView.hxx +++ b/src/Graphic3d/Graphic3d_CView.hxx @@ -193,7 +193,7 @@ private: //! 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 //! in the view . diff --git a/src/Graphic3d/Graphic3d_Structure.cxx b/src/Graphic3d/Graphic3d_Structure.cxx index 202c0c5729..e165e7100c 100644 --- a/src/Graphic3d/Graphic3d_Structure.cxx +++ b/src/Graphic3d/Graphic3d_Structure.cxx @@ -669,7 +669,7 @@ void Graphic3d_Structure::DisconnectAll (const Graphic3d_TypeOfConnection theTyp //function : SetTransform //purpose : //============================================================================= -void Graphic3d_Structure::SetTransformation (const Handle(Geom_Transformation)& theTrsf) +void Graphic3d_Structure::SetTransformation (const Handle(TopLoc_Datum3D)& theTrsf) { if (IsDeleted()) return; @@ -678,7 +678,7 @@ void Graphic3d_Structure::SetTransformation (const Handle(Geom_Transformation)& if (!theTrsf.IsNull() && theTrsf->Trsf().Form() == gp_Identity) { - myCStructure->SetTransformation (Handle(Geom_Transformation)()); + myCStructure->SetTransformation (Handle(TopLoc_Datum3D)()); } else { diff --git a/src/Graphic3d/Graphic3d_Structure.hxx b/src/Graphic3d/Graphic3d_Structure.hxx index 15a6070a40..3812df9791 100644 --- a/src/Graphic3d/Graphic3d_Structure.hxx +++ b/src/Graphic3d/Graphic3d_Structure.hxx @@ -344,13 +344,13 @@ public: } //! 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); @@ -375,7 +375,7 @@ public: 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; } diff --git a/src/Graphic3d/Graphic3d_StructureManager.cxx b/src/Graphic3d/Graphic3d_StructureManager.cxx index 0c1728b717..82dc50cea3 100644 --- a/src/Graphic3d/Graphic3d_StructureManager.cxx +++ b/src/Graphic3d/Graphic3d_StructureManager.cxx @@ -407,7 +407,7 @@ void Graphic3d_StructureManager::UnHighlight() // 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()) { diff --git a/src/Graphic3d/Graphic3d_StructureManager.hxx b/src/Graphic3d/Graphic3d_StructureManager.hxx index 0f36aa2b23..e4676adcc7 100644 --- a/src/Graphic3d/Graphic3d_StructureManager.hxx +++ b/src/Graphic3d/Graphic3d_StructureManager.hxx @@ -109,7 +109,7 @@ public: 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 . Standard_EXPORT virtual void ChangeDisplayPriority (const Handle(Graphic3d_Structure)& theStructure, const Standard_Integer theOldPriority, const Standard_Integer theNewPriority); diff --git a/src/Graphic3d/Graphic3d_ZLayerSettings.hxx b/src/Graphic3d/Graphic3d_ZLayerSettings.hxx index 1b161f0d86..7812bf3f09 100644 --- a/src/Graphic3d/Graphic3d_ZLayerSettings.hxx +++ b/src/Graphic3d/Graphic3d_ZLayerSettings.hxx @@ -15,7 +15,7 @@ #define _Graphic3d_ZLayerSettings_HeaderFile #include -#include +#include #include #include #include @@ -63,7 +63,7 @@ struct Graphic3d_ZLayerSettings 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) @@ -72,8 +72,9 @@ struct Graphic3d_ZLayerSettings 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); } } @@ -236,7 +237,7 @@ protected: 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 diff --git a/src/IVtkOCC/IVtkOCC_ShapeMesher.cxx b/src/IVtkOCC/IVtkOCC_ShapeMesher.cxx index 643f427ec9..09735d6136 100644 --- a/src/IVtkOCC/IVtkOCC_ShapeMesher.cxx +++ b/src/IVtkOCC/IVtkOCC_ShapeMesher.cxx @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -94,7 +95,7 @@ Standard_Real IVtkOCC_ShapeMesher::GetDeflection() const 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; diff --git a/src/MeshVS/MeshVS_MeshEntityOwner.cxx b/src/MeshVS/MeshVS_MeshEntityOwner.cxx index 9ff4d9927c..b3fad6fca5 100644 --- a/src/MeshVS/MeshVS_MeshEntityOwner.cxx +++ b/src/MeshVS/MeshVS_MeshEntityOwner.cxx @@ -36,7 +36,7 @@ IMPLEMENT_STANDARD_RTTIEXT(MeshVS_MeshEntityOwner,SelectMgr_EntityOwner) // 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, diff --git a/src/MeshVS/MeshVS_MeshEntityOwner.hxx b/src/MeshVS/MeshVS_MeshEntityOwner.hxx index 43db8e1ed5..cbc9b2acd9 100644 --- a/src/MeshVS/MeshVS_MeshEntityOwner.hxx +++ b/src/MeshVS/MeshVS_MeshEntityOwner.hxx @@ -16,15 +16,8 @@ #ifndef _MeshVS_MeshEntityOwner_HeaderFile #define _MeshVS_MeshEntityOwner_HeaderFile -#include -#include - -#include #include -#include -#include #include -#include #include #include class PrsMgr_PresentationManager; @@ -43,7 +36,7 @@ class MeshVS_MeshEntityOwner : public SelectMgr_EntityOwner 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; diff --git a/src/MeshVS/MeshVS_MeshOwner.cxx b/src/MeshVS/MeshVS_MeshOwner.cxx index ef64a208ce..9f5608aadd 100644 --- a/src/MeshVS/MeshVS_MeshOwner.cxx +++ b/src/MeshVS/MeshVS_MeshOwner.cxx @@ -35,7 +35,7 @@ IMPLEMENT_STANDARD_RTTIEXT(MeshVS_MeshOwner,SelectMgr_EntityOwner) // 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 ) diff --git a/src/MeshVS/MeshVS_MeshOwner.hxx b/src/MeshVS/MeshVS_MeshOwner.hxx index c67f9ba1d2..e3d9b3f103 100644 --- a/src/MeshVS/MeshVS_MeshOwner.hxx +++ b/src/MeshVS/MeshVS_MeshOwner.hxx @@ -16,15 +16,10 @@ #ifndef _MeshVS_MeshOwner_HeaderFile #define _MeshVS_MeshOwner_HeaderFile -#include -#include - -#include #include -#include #include #include -#include + class MeshVS_DataSource; class TColStd_HPackedMapOfInteger; class PrsMgr_PresentationManager; @@ -42,7 +37,7 @@ class MeshVS_MeshOwner : public SelectMgr_EntityOwner 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; diff --git a/src/OpenGl/OpenGl_Structure.cxx b/src/OpenGl/OpenGl_Structure.cxx index b9a9f9a9e4..82f4ae4d80 100644 --- a/src/OpenGl/OpenGl_Structure.cxx +++ b/src/OpenGl/OpenGl_Structure.cxx @@ -135,16 +135,17 @@ void OpenGl_Structure::SetZLayer (const Graphic3d_ZLayerId theLayerIndex) // 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; } @@ -426,7 +427,7 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &theWorkspace) con 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); diff --git a/src/OpenGl/OpenGl_Structure.hxx b/src/OpenGl/OpenGl_Structure.hxx index 7efa12953f..b031d31036 100644 --- a/src/OpenGl/OpenGl_Structure.hxx +++ b/src/OpenGl/OpenGl_Structure.hxx @@ -65,7 +65,7 @@ public: 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; diff --git a/src/OpenGl/OpenGl_View.hxx b/src/OpenGl/OpenGl_View.hxx index 346c753a67..db1b635c73 100644 --- a/src/OpenGl/OpenGl_View.hxx +++ b/src/OpenGl/OpenGl_View.hxx @@ -834,7 +834,7 @@ protected: //! @name methods related to ray-tracing //! 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. diff --git a/src/OpenGl/OpenGl_View_Raytrace.cxx b/src/OpenGl/OpenGl_View_Raytrace.cxx index d39623baa7..73eb9a3b5b 100644 --- a/src/OpenGl/OpenGl_View_Raytrace.cxx +++ b/src/OpenGl/OpenGl_View_Raytrace.cxx @@ -504,7 +504,7 @@ Standard_Boolean OpenGl_View::addRaytraceStructure (const OpenGl_Structure* // ======================================================================= 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; diff --git a/src/Prs3d/FILES b/src/Prs3d/FILES index 37271672b8..2785086732 100755 --- a/src/Prs3d/FILES +++ b/src/Prs3d/FILES @@ -6,6 +6,8 @@ Prs3d_ArrowAspect.cxx Prs3d_ArrowAspect.hxx Prs3d_BasicAspect.cxx Prs3d_BasicAspect.hxx +Prs3d_BndBox.cxx +Prs3d_BndBox.hxx Prs3d_DatumAspect.cxx Prs3d_DatumAspect.hxx Prs3d_DatumAttribute.hxx @@ -38,7 +40,6 @@ Prs3d_PresentationShadow.hxx Prs3d_Root.hxx Prs3d_ShadingAspect.cxx Prs3d_ShadingAspect.hxx -Prs3d_ShapeTool.cxx Prs3d_ShapeTool.hxx Prs3d_Text.cxx Prs3d_Text.hxx diff --git a/src/Prs3d/Prs3d.cxx b/src/Prs3d/Prs3d.cxx index 33f33fe10f..9c780a1021 100644 --- a/src/Prs3d/Prs3d.cxx +++ b/src/Prs3d/Prs3d.cxx @@ -16,15 +16,83 @@ #include -#include -#include #include +#include #include -#include +#include +#include #include -#include -#include -#include + +// ========================================================================= +// function : AddFreeEdges +// purpose : +// ========================================================================= +void Prs3d::AddFreeEdges (TColgp_SequenceOfPnt& theSegments, + const Handle(Poly_Triangulation)& thePolyTri, + const gp_Trsf& theLocation) +{ + if (thePolyTri.IsNull()) + { + return; + } + + const TColgp_Array1OfPnt& aNodes = thePolyTri->Nodes(); + + // Build the connect tool. + Poly_Connect aPolyConnect (thePolyTri); + + Standard_Integer aNbTriangles = thePolyTri->NbTriangles(); + Standard_Integer aT[3]; + Standard_Integer aN[3]; + + // Count the free edges. + Standard_Integer aNbFree = 0; + for (Standard_Integer anI = 1; anI <= aNbTriangles; ++anI) + { + aPolyConnect.Triangles (anI, aT[0], aT[1], aT[2]); + for (Standard_Integer aJ = 0; aJ < 3; ++aJ) + { + if (aT[aJ] == 0) + { + ++aNbFree; + } + } + } + if (aNbFree == 0) + { + return; + } + + TColStd_Array1OfInteger aFree (1, 2 * aNbFree); + + Standard_Integer aFreeIndex = 1; + const Poly_Array1OfTriangle& aTriangles = thePolyTri->Triangles(); + for (Standard_Integer anI = 1; anI <= aNbTriangles; ++anI) + { + aPolyConnect.Triangles (anI, aT[0], aT[1], aT[2]); + aTriangles (anI).Get (aN[0], aN[1], aN[2]); + for (Standard_Integer aJ = 0; aJ < 3; aJ++) + { + Standard_Integer k = (aJ + 1) % 3; + if (aT[aJ] == 0) + { + aFree (aFreeIndex) = aN[aJ]; + aFree (aFreeIndex + 1) = aN[k]; + aFreeIndex += 2; + } + } + } + + // free edges + Standard_Integer aFreeHalfNb = aFree.Length() / 2; + for (Standard_Integer anI = 1; anI <= aFreeHalfNb; ++anI) + { + const gp_Pnt aPoint1 = aNodes (aFree (2 * anI - 1)).Transformed (theLocation); + const gp_Pnt aPoint2 = aNodes (aFree (2 * anI )).Transformed (theLocation); + theSegments.Append (aPoint1); + theSegments.Append (aPoint2); + } +} //======================================================================= //function : MatchSegment @@ -55,44 +123,6 @@ Standard_Boolean Prs3d::MatchSegment return (dist < aDistance); } -//======================================================================= -//function : GetDeflection -//purpose : -//======================================================================= -Standard_Real Prs3d::GetDeflection (const TopoDS_Shape& theShape, - const Handle(Prs3d_Drawer)& theDrawer) -{ - if (theDrawer->TypeOfDeflection() != Aspect_TOD_RELATIVE) - { - return theDrawer->MaximalChordialDeviation(); - } - - Bnd_Box aBndBox; - BRepBndLib::Add (theShape, aBndBox, Standard_False); - if (aBndBox.IsVoid()) - { - return theDrawer->MaximalChordialDeviation(); - } - else if (aBndBox.IsOpen()) - { - if (!aBndBox.HasFinitePart()) - { - return theDrawer->MaximalChordialDeviation(); - } - aBndBox = aBndBox.FinitePart(); - } - - Graphic3d_Vec3d aVecMin, aVecMax; - aBndBox.Get (aVecMin.x(), aVecMin.y(), aVecMin.z(), aVecMax.x(), aVecMax.y(), aVecMax.z()); - const Graphic3d_Vec3d aDiag = aVecMax - aVecMin; - const Standard_Real aDeflection = aDiag.maxComp() * theDrawer->DeviationCoefficient() * 4.0; - - // we store computed relative deflection of shape as absolute deviation coefficient - // in case relative type to use it later on for sub-shapes. - theDrawer->SetMaximalChordialDeviation (aDeflection); - return aDeflection; -} - //================================================================== // function: PrimitivesFromPolylines // purpose: @@ -140,7 +170,7 @@ void Prs3d::AddPrimitivesGroup (const Handle(Prs3d_Presentation)& thePrs, thePolylines.Clear(); if (!aPrims.IsNull()) { - Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup (thePrs); + Handle(Graphic3d_Group) aGroup = thePrs->NewGroup(); aGroup->SetPrimitivesAspect (theAspect->Aspect()); aGroup->AddPrimitiveArray (aPrims); } diff --git a/src/Prs3d/Prs3d.hxx b/src/Prs3d/Prs3d.hxx index 73e10d5300..f8a8cd324d 100644 --- a/src/Prs3d/Prs3d.hxx +++ b/src/Prs3d/Prs3d.hxx @@ -17,15 +17,14 @@ #ifndef _Prs3d_HeaderFile #define _Prs3d_HeaderFile +#include #include -#include #include -#include #include #include #include -class TopoDS_Shape; +class Poly_Triangulation; //! The Prs3d package provides the following services //! - a presentation object (the context for all @@ -49,20 +48,48 @@ public: //! draws an arrow at a given location, with respect //! to a given direction. Standard_EXPORT static Standard_Boolean MatchSegment (const Standard_Real X, const Standard_Real Y, const Standard_Real Z, const Standard_Real aDistance, const gp_Pnt& p1, const gp_Pnt& p2, Standard_Real& dist); - - //! Computes the absolute deflection value depending on - //! the type of deflection in theDrawer: - //!
    - //!
  • Aspect_TOD_RELATIVE: the absolute deflection is computed using the relative - //! deviation coefficient from theDrawer and the shape's bounding box;
  • - //!
  • Aspect_TOD_ABSOLUTE: the maximal chordial deviation from theDrawer is returned.
  • - //!
- //! In case of the type of deflection in theDrawer computed relative deflection for shape - //! is stored as absolute deflection. It is necessary to use it later on for sub-shapes. - //! This function should always be used to compute the deflection value for building - //! discrete representations of the shape (triangualtion, wireframe) to avoid incosistencies - //! between different representations of the shape and undesirable visual artifacts. - Standard_EXPORT static Standard_Real GetDeflection (const TopoDS_Shape& theShape, const Handle(Prs3d_Drawer)& theDrawer); + + //! Computes the absolute deflection value based on relative deflection Prs3d_Drawer::DeviationCoefficient(). + //! @param theBndMin [in] bounding box min corner + //! @param theBndMax [in] bounding box max corner + //! @param theDeviationCoefficient [in] relative deflection coefficient from Prs3d_Drawer::DeviationCoefficient() + //! @return absolute deflection coefficient based on bounding box dimensions + static Standard_Real GetDeflection (const Graphic3d_Vec3d& theBndMin, + const Graphic3d_Vec3d& theBndMax, + const Standard_Real theDeviationCoefficient) + { + const Graphic3d_Vec3d aDiag = theBndMax - theBndMin; + return aDiag.maxComp() * theDeviationCoefficient * 4.0; + } + + //! Computes the absolute deflection value based on relative deflection Prs3d_Drawer::DeviationCoefficient(). + //! @param theBndBox [in] bounding box + //! @param theDeviationCoefficient [in] relative deflection coefficient from Prs3d_Drawer::DeviationCoefficient() + //! @param theMaximalChordialDeviation [in] absolute deflection coefficient from Prs3d_Drawer::MaximalChordialDeviation() + //! @return absolute deflection coefficient based on bounding box dimensions or theMaximalChordialDeviation if bounding box is Void or Infinite + static Standard_Real GetDeflection (const Bnd_Box& theBndBox, + const Standard_Real theDeviationCoefficient, + const Standard_Real theMaximalChordialDeviation) + { + if (theBndBox.IsVoid()) + { + return theMaximalChordialDeviation; + } + + Bnd_Box aBndBox = theBndBox; + if (theBndBox.IsOpen()) + { + if (!theBndBox.HasFinitePart()) + { + return theMaximalChordialDeviation; + } + aBndBox = theBndBox.FinitePart(); + } + + Graphic3d_Vec3d aVecMin, aVecMax; + aBndBox.Get (aVecMin.x(), aVecMin.y(), aVecMin.z(), aVecMax.x(), aVecMax.y(), aVecMax.z()); + return GetDeflection (aVecMin, aVecMax, theDeviationCoefficient); + } //! Assembles array of primitives for sequence of polylines. //! @param thePoints [in] the polylines sequence @@ -74,6 +101,14 @@ public: const Handle(Prs3d_LineAspect)& theAspect, Prs3d_NListOfSequenceOfPnt& thePolylines); + //! Add triangulation free edges into sequence of line segments. + //! @param theSegments [out] sequence of line segments to fill + //! @param thePolyTri [in] triangulation to process + //! @param theLocation [in] transformation to apply + Standard_EXPORT static void AddFreeEdges (TColgp_SequenceOfPnt& theSegments, + const Handle(Poly_Triangulation)& thePolyTri, + const gp_Trsf& theLocation); + }; #endif // _Prs3d_HeaderFile diff --git a/src/StdPrs/StdPrs_BndBox.cxx b/src/Prs3d/Prs3d_BndBox.cxx similarity index 81% rename from src/StdPrs/StdPrs_BndBox.cxx rename to src/Prs3d/Prs3d_BndBox.cxx index cbe3f208e1..c29b38c8bb 100644 --- a/src/StdPrs/StdPrs_BndBox.cxx +++ b/src/Prs3d/Prs3d_BndBox.cxx @@ -13,7 +13,7 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -#include +#include #include @@ -21,9 +21,9 @@ //function : Add //purpose : //======================================================================= -void StdPrs_BndBox::Add (const Handle(Prs3d_Presentation)& thePresentation, - const Bnd_Box& theBndBox, - const Handle(Prs3d_Drawer)& theDrawer) +void Prs3d_BndBox::Add (const Handle(Prs3d_Presentation)& thePresentation, + const Bnd_Box& theBndBox, + const Handle(Prs3d_Drawer)& theDrawer) { if (!theBndBox.IsVoid()) { @@ -39,9 +39,9 @@ void StdPrs_BndBox::Add (const Handle(Prs3d_Presentation)& thePresentation, //function : Add //purpose : //======================================================================= -void StdPrs_BndBox::Add (const Handle(Prs3d_Presentation)& thePresentation, - const Bnd_OBB& theBndBox, - const Handle(Prs3d_Drawer)& theDrawer) +void Prs3d_BndBox::Add (const Handle(Prs3d_Presentation)& thePresentation, + const Bnd_OBB& theBndBox, + const Handle(Prs3d_Drawer)& theDrawer) { if (!theBndBox.IsVoid()) { diff --git a/src/Prs3d/Prs3d_BndBox.hxx b/src/Prs3d/Prs3d_BndBox.hxx new file mode 100644 index 0000000000..b32c37b727 --- /dev/null +++ b/src/Prs3d/Prs3d_BndBox.hxx @@ -0,0 +1,148 @@ +// Created on: 2014-10-14 +// Created by: Anton POLETAEV +// Copyright (c) 2013-2014 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef _Prs3d_BndBox_H__ +#define _Prs3d_BndBox_H__ + +#include +#include +#include +#include +#include +#include + +//! 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__ diff --git a/src/Prs3d/Prs3d_ShapeTool.hxx b/src/Prs3d/Prs3d_ShapeTool.hxx index cd64f03660..f2a5001471 100644 --- a/src/Prs3d/Prs3d_ShapeTool.hxx +++ b/src/Prs3d/Prs3d_ShapeTool.hxx @@ -17,95 +17,9 @@ #ifndef _Prs3d_ShapeTool_HeaderFile #define _Prs3d_ShapeTool_HeaderFile -#include -#include -#include -#include -#include -#include -#include -#include +#include -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 diff --git a/src/Prs3d/Prs3d_ToolCylinder.hxx b/src/Prs3d/Prs3d_ToolCylinder.hxx index 681778b544..fecfba14be 100644 --- a/src/Prs3d/Prs3d_ToolCylinder.hxx +++ b/src/Prs3d/Prs3d_ToolCylinder.hxx @@ -16,7 +16,6 @@ #ifndef _Prs3d_ToolCylinder_HeaderFile #define _Prs3d_ToolCylinder_HeaderFile -#include #include //! Standard presentation algorithm that outputs graphical primitives for cylindrical surface. diff --git a/src/Prs3d/Prs3d_ToolDisk.hxx b/src/Prs3d/Prs3d_ToolDisk.hxx index 6897083162..c722639f7b 100644 --- a/src/Prs3d/Prs3d_ToolDisk.hxx +++ b/src/Prs3d/Prs3d_ToolDisk.hxx @@ -16,7 +16,6 @@ #ifndef _Prs3d_ToolDisk_HeaderFile #define _Prs3d_ToolDisk_HeaderFile -#include #include //! Standard presentation algorithm that outputs graphical primitives for disk surface. diff --git a/src/Prs3d/Prs3d_ToolQuadric.hxx b/src/Prs3d/Prs3d_ToolQuadric.hxx index 8b6befa1ae..c3493edd1b 100644 --- a/src/Prs3d/Prs3d_ToolQuadric.hxx +++ b/src/Prs3d/Prs3d_ToolQuadric.hxx @@ -16,14 +16,8 @@ #ifndef _Prs3d_ToolQuadric_HeaderFile #define _Prs3d_ToolQuadric_HeaderFile -#include -#include #include #include -#include -#include -#include -#include //! Base class to build 3D surfaces presentation of quadric surfaces. class Prs3d_ToolQuadric diff --git a/src/Prs3d/Prs3d_ToolSector.hxx b/src/Prs3d/Prs3d_ToolSector.hxx index 009dbe0be6..383de716cd 100644 --- a/src/Prs3d/Prs3d_ToolSector.hxx +++ b/src/Prs3d/Prs3d_ToolSector.hxx @@ -16,7 +16,6 @@ #ifndef _Prs3d_ToolSector_HeaderFile #define _Prs3d_ToolSector_HeaderFile -#include #include //! Standard presentation algorithm that outputs graphical primitives for disk surface. diff --git a/src/Prs3d/Prs3d_ToolSphere.hxx b/src/Prs3d/Prs3d_ToolSphere.hxx index 671262c5b3..ed893a71f4 100644 --- a/src/Prs3d/Prs3d_ToolSphere.hxx +++ b/src/Prs3d/Prs3d_ToolSphere.hxx @@ -16,14 +16,6 @@ #ifndef _Prs3d_ToolSphere_HeaderFile #define _Prs3d_ToolSphere_HeaderFile -#include -#include -#include -#include -#include -#include -#include -#include #include //! Standard presentation algorithm that outputs graphical primitives for spherical surface. diff --git a/src/PrsDim/PrsDim_ConcentricRelation.cxx b/src/PrsDim/PrsDim_ConcentricRelation.cxx index e759fab084..273ff76958 100644 --- a/src/PrsDim/PrsDim_ConcentricRelation.cxx +++ b/src/PrsDim/PrsDim_ConcentricRelation.cxx @@ -223,15 +223,12 @@ void PrsDim_ConcentricRelation::ComputeSelection(const Handle(SelectMgr_Selectio //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 diff --git a/src/PrsDim/PrsDim_Dimension.cxx b/src/PrsDim/PrsDim_Dimension.cxx index 17e989097f..9589d7d062 100644 --- a/src/PrsDim/PrsDim_Dimension.cxx +++ b/src/PrsDim/PrsDim_Dimension.cxx @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -1386,10 +1385,7 @@ void PrsDim_Dimension::ComputeSelection (const Handle(SelectMgr_Selection)& theS { 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); diff --git a/src/PrsDim/PrsDim_EqualDistanceRelation.cxx b/src/PrsDim/PrsDim_EqualDistanceRelation.cxx index 72c2868c3b..b726874a2b 100644 --- a/src/PrsDim/PrsDim_EqualDistanceRelation.cxx +++ b/src/PrsDim/PrsDim_EqualDistanceRelation.cxx @@ -250,9 +250,7 @@ void PrsDim_EqualDistanceRelation::ComputeSelection( const Handle( SelectMgr_Sel 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 ); } } @@ -273,9 +271,7 @@ void PrsDim_EqualDistanceRelation::ComputeSelection( const Handle( SelectMgr_Sel 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 ); } } @@ -296,8 +292,7 @@ void PrsDim_EqualDistanceRelation::ComputeSelection( const Handle( SelectMgr_Sel 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 { @@ -322,9 +317,7 @@ void PrsDim_EqualDistanceRelation::ComputeSelection( const Handle( SelectMgr_Sel 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 ); } } diff --git a/src/PrsMgr/PrsMgr_PresentableObject.cxx b/src/PrsMgr/PrsMgr_PresentableObject.cxx index 10edc778af..a87c7522af 100644 --- a/src/PrsMgr/PrsMgr_PresentableObject.cxx +++ b/src/PrsMgr/PrsMgr_PresentableObject.cxx @@ -77,7 +77,7 @@ PrsMgr_PresentableObject::~PrsMgr_PresentableObject() 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; } } @@ -102,7 +102,7 @@ void PrsMgr_PresentableObject::Fill (const Handle(PrsMgr_PresentationManager)& t //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"); @@ -246,7 +246,7 @@ void PrsMgr_PresentableObject::SetTypeOfPresentation (const PrsMgr_TypeOfPresent //function : setLocalTransformation //purpose : //======================================================================= -void PrsMgr_PresentableObject::setLocalTransformation (const Handle(Geom_Transformation)& theTransformation) +void PrsMgr_PresentableObject::setLocalTransformation (const Handle(TopLoc_Datum3D)& theTransformation) { myLocalTransformation = theTransformation; UpdateTransformation(); @@ -258,14 +258,14 @@ void PrsMgr_PresentableObject::setLocalTransformation (const Handle(Geom_Transfo //======================================================================= 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(); @@ -284,7 +284,7 @@ void PrsMgr_PresentableObject::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 @@ -420,7 +420,7 @@ void PrsMgr_PresentableObject::RemoveChild (const Handle(PrsMgr_PresentableObjec if (anIter.Value() == theObject) { theObject->myParent = NULL; - theObject->SetCombinedParentTransform (Handle(Geom_Transformation)()); + theObject->SetCombinedParentTransform (Handle(TopLoc_Datum3D)()); myChildren.Remove (anIter); break; } diff --git a/src/PrsMgr/PrsMgr_PresentableObject.hxx b/src/PrsMgr/PrsMgr_PresentableObject.hxx index 0d50aaeb07..06c51a3065 100644 --- a/src/PrsMgr/PrsMgr_PresentableObject.hxx +++ b/src/PrsMgr/PrsMgr_PresentableObject.hxx @@ -209,17 +209,17 @@ public: //! @name object transformation //! 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; } @@ -227,7 +227,7 @@ public: //! @name object transformation //! 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 @@ -247,7 +247,7 @@ public: //! @name object transformation 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(); @@ -349,7 +349,7 @@ protected: //! @name interface methods //! @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. @@ -364,10 +364,10 @@ protected: //! @name interface methods //! 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(); @@ -559,9 +559,9 @@ protected: 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 diff --git a/src/PrsMgr/PrsMgr_Presentation.cxx b/src/PrsMgr/PrsMgr_Presentation.cxx index d9b8ae3c62..f28b9597be 100644 --- a/src/PrsMgr/PrsMgr_Presentation.cxx +++ b/src/PrsMgr/PrsMgr_Presentation.cxx @@ -14,7 +14,6 @@ #include -#include #include #include #include diff --git a/src/PrsMgr/PrsMgr_Presentation.hxx b/src/PrsMgr/PrsMgr_Presentation.hxx index 6e27895299..f2295b02ca 100644 --- a/src/PrsMgr/PrsMgr_Presentation.hxx +++ b/src/PrsMgr/PrsMgr_Presentation.hxx @@ -24,7 +24,6 @@ class PrsMgr_PresentationManager; class PrsMgr_PresentableObject; class Quantity_Color; class Graphic3d_Camera; -class Geom_Transformation; class Prs3d_Drawer; class Graphic3d_Structure; class Graphic3d_DataStructureManager; diff --git a/src/PrsMgr/PrsMgr_PresentationManager.cxx b/src/PrsMgr/PrsMgr_PresentationManager.cxx index 56bb28898e..8ae5a7e6c4 100644 --- a/src/PrsMgr/PrsMgr_PresentationManager.cxx +++ b/src/PrsMgr/PrsMgr_PresentationManager.cxx @@ -14,7 +14,7 @@ #include -#include +#include #include #include #include @@ -594,8 +594,8 @@ void PrsMgr_PresentationManager::Connect (const Handle(PrsMgr_PresentableObject) // 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); } @@ -645,15 +645,12 @@ void PrsMgr_PresentationManager::Color (const Handle(PrsMgr_PresentableObject)& 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()) { @@ -688,7 +685,7 @@ void PrsMgr_PresentationManager::UpdateHighlightTrsf (const Handle(V3d_Viewer)& return; } - Handle(Geom_Transformation) aTrsf = theObj->LocalTransformationGeom(); + Handle(TopLoc_Datum3D) aTrsf = theObj->LocalTransformationGeom(); const Standard_Integer aParentId = aPrs->CStructure()->Id; updatePrsTransformation (myImmediateList, aParentId, aTrsf); diff --git a/src/PrsMgr/PrsMgr_PresentationManager.hxx b/src/PrsMgr/PrsMgr_PresentationManager.hxx index ae94609f6c..38e7ddf8e0 100644 --- a/src/PrsMgr/PrsMgr_PresentationManager.hxx +++ b/src/PrsMgr/PrsMgr_PresentationManager.hxx @@ -32,7 +32,7 @@ class Graphic3d_Structure; typedef Graphic3d_Structure Prs3d_Presentation; -class Geom_Transformation; +class TopLoc_Datum3D; class Prs3d_Drawer; class PrsMgr_Presentation; class PrsMgr_PresentableObject; @@ -136,7 +136,9 @@ public: //! 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; } diff --git a/src/QABugs/QABugs_17.cxx b/src/QABugs/QABugs_17.cxx index a4c7c94b3a..65729451c6 100644 --- a/src/QABugs/QABugs_17.cxx +++ b/src/QABugs/QABugs_17.cxx @@ -68,7 +68,6 @@ #include #include -#include #include #include #include diff --git a/src/Select3D/Select3D_SensitiveCircle.cxx b/src/Select3D/Select3D_SensitiveCircle.cxx index e1523f1e4b..3f3f14f5c2 100644 --- a/src/Select3D/Select3D_SensitiveCircle.cxx +++ b/src/Select3D/Select3D_SensitiveCircle.cxx @@ -16,7 +16,7 @@ #include -#include +#include #include #include @@ -24,7 +24,7 @@ IMPLEMENT_STANDARD_RTTIEXT(Select3D_SensitiveCircle,Select3D_SensitivePoly) 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. @@ -33,24 +33,37 @@ namespace 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); } } @@ -59,51 +72,24 @@ namespace //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) @@ -117,51 +103,25 @@ Select3D_SensitiveCircle::Select3D_SensitiveCircle(const Handle(SelectMgr_Entity //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) @@ -271,25 +231,6 @@ Standard_Boolean Select3D_SensitiveCircle::Matches (SelectBasics_SelectingVolume 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 : @@ -301,7 +242,7 @@ Handle(Select3D_SensitiveEntity) Select3D_SensitiveCircle::GetConnected() // 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()) { diff --git a/src/Select3D/Select3D_SensitiveCircle.hxx b/src/Select3D/Select3D_SensitiveCircle.hxx index 9f9e2884fd..57deeaf5fb 100644 --- a/src/Select3D/Select3D_SensitiveCircle.hxx +++ b/src/Select3D/Select3D_SensitiveCircle.hxx @@ -17,14 +17,11 @@ #ifndef _Select3D_SensitiveCircle_HeaderFile #define _Select3D_SensitiveCircle_HeaderFile +#include #include -#include -#include #include - -class Geom_Circle; -class Standard_ConstructionError; -class Standard_OutOfRange; +#include +#include //! A framework to define sensitive 3D arcs and circles. //! In some cases this class can raise Standard_ConstructionError and @@ -38,7 +35,7 @@ public: //! 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); @@ -47,7 +44,7 @@ public: //! 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, @@ -75,11 +72,6 @@ public: 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 @@ -104,7 +96,7 @@ private: 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 }; diff --git a/src/Select3D/Select3D_SensitiveCurve.cxx b/src/Select3D/Select3D_SensitiveCurve.cxx index 06669d2e95..cd0b6bab9b 100644 --- a/src/Select3D/Select3D_SensitiveCurve.cxx +++ b/src/Select3D/Select3D_SensitiveCurve.cxx @@ -15,26 +15,12 @@ // commercial license or contractual agreement. #include + #include #include - 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 : @@ -58,46 +44,17 @@ Select3D_SensitiveCurve::Select3D_SensitiveCurve (const Handle(SelectMgr_EntityO 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 +} diff --git a/src/Select3D/Select3D_SensitiveCurve.hxx b/src/Select3D/Select3D_SensitiveCurve.hxx index 1e63a87bdc..225aca2204 100644 --- a/src/Select3D/Select3D_SensitiveCurve.hxx +++ b/src/Select3D/Select3D_SensitiveCurve.hxx @@ -36,9 +36,14 @@ public: //! 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. @@ -55,12 +60,18 @@ public: 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) diff --git a/src/Select3D/Select3D_SensitivePoly.hxx b/src/Select3D/Select3D_SensitivePoly.hxx index 5e88b4dbb6..833b637332 100644 --- a/src/Select3D/Select3D_SensitivePoly.hxx +++ b/src/Select3D/Select3D_SensitivePoly.hxx @@ -69,6 +69,22 @@ public: } } + //! 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; diff --git a/src/SelectMgr/FILES b/src/SelectMgr/FILES index 1978fa8d59..208700b0e9 100755 --- a/src/SelectMgr/FILES +++ b/src/SelectMgr/FILES @@ -1,3 +1,5 @@ +SelectMgr.cxx +SelectMgr.hxx SelectMgr_AndFilter.cxx SelectMgr_AndFilter.hxx SelectMgr_BaseFrustum.cxx @@ -30,6 +32,8 @@ SelectMgr_SelectingVolumeManager.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 @@ -39,7 +43,6 @@ SelectMgr_SensitiveEntitySet.hxx SelectMgr_SequenceOfFilter.hxx SelectMgr_SequenceOfOwner.hxx SelectMgr_SequenceOfSelection.hxx -SelectMgr_SOPtr.hxx SelectMgr_SortCriterion.hxx SelectMgr_StateOfSelection.hxx SelectMgr_ToleranceMap.hxx @@ -55,3 +58,5 @@ SelectMgr_ViewClipRange.cxx SelectMgr_ViewClipRange.hxx SelectMgr_ViewerSelector.cxx SelectMgr_ViewerSelector.hxx +SelectMgr_ViewerSelector3d.cxx +SelectMgr_ViewerSelector3d.hxx diff --git a/src/SelectMgr/SelectMgr.cxx b/src/SelectMgr/SelectMgr.cxx new file mode 100644 index 0000000000..7db447afa2 --- /dev/null +++ b/src/SelectMgr/SelectMgr.cxx @@ -0,0 +1,252 @@ +// 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 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +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::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& anEntities = aWire->GetEdges(); + for (NCollection_Vector::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); + } +} diff --git a/src/SelectMgr/SelectMgr.hxx b/src/SelectMgr/SelectMgr.hxx new file mode 100644 index 0000000000..72281a9552 --- /dev/null +++ b/src/SelectMgr/SelectMgr.hxx @@ -0,0 +1,37 @@ +// 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 + +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 diff --git a/src/SelectMgr/SelectMgr_SOPtr.hxx b/src/SelectMgr/SelectMgr_SOPtr.hxx deleted file mode 100644 index d18732318c..0000000000 --- a/src/SelectMgr/SelectMgr_SOPtr.hxx +++ /dev/null @@ -1,23 +0,0 @@ -// 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 diff --git a/src/SelectMgr/SelectMgr_SelectionImageFiller.cxx b/src/SelectMgr/SelectMgr_SelectionImageFiller.cxx new file mode 100644 index 0000000000..7bfa8ce505 --- /dev/null +++ b/src/SelectMgr/SelectMgr_SelectionImageFiller.cxx @@ -0,0 +1,361 @@ +// 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 + +#include + +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::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 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 (theRow, theCol) = ShortRealLast(); + return; + } + + const SelectMgr_SortCriterion& aSortCriterion = myMainSel->PickedData (thePicked); + myUnnormImage.ChangeValue (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 (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::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 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::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 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)(); +} diff --git a/src/SelectMgr/SelectMgr_SelectionImageFiller.hxx b/src/SelectMgr/SelectMgr_SelectionImageFiller.hxx new file mode 100644 index 0000000000..5d3f090932 --- /dev/null +++ b/src/SelectMgr/SelectMgr_SelectionImageFiller.hxx @@ -0,0 +1,82 @@ +// 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 +#include +#include +#include +#include + +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 myUniqueColors; +}; + +#endif diff --git a/src/SelectMgr/SelectMgr_ViewerSelector.cxx b/src/SelectMgr/SelectMgr_ViewerSelector.cxx index f42d368d36..71e1f22ab3 100644 --- a/src/SelectMgr/SelectMgr_ViewerSelector.cxx +++ b/src/SelectMgr/SelectMgr_ViewerSelector.cxx @@ -130,6 +130,28 @@ myEntityIdx (0) myEntitySetBuilder = new BVH_BinnedBuilder (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 : diff --git a/src/SelectMgr/SelectMgr_ViewerSelector.hxx b/src/SelectMgr/SelectMgr_ViewerSelector.hxx index 57d50ddc20..86df12385b 100644 --- a/src/SelectMgr/SelectMgr_ViewerSelector.hxx +++ b/src/SelectMgr/SelectMgr_ViewerSelector.hxx @@ -88,6 +88,12 @@ public: //! 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 . + 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(); @@ -201,6 +207,9 @@ public: //! 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(); diff --git a/src/SelectMgr/SelectMgr_ViewerSelector3d.cxx b/src/SelectMgr/SelectMgr_ViewerSelector3d.cxx new file mode 100644 index 0000000000..478d3d7a83 --- /dev/null +++ b/src/SelectMgr/SelectMgr_ViewerSelector3d.cxx @@ -0,0 +1,265 @@ +// 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 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +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 (theXPix), + static_cast (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 (theXPMin), + static_cast (theYPMin)); + gp_Pnt2d aMaxMousePos (static_cast (theXPMax), + static_cast (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 (theImage.SizeX()); + const Standard_Integer aSizeY = static_cast (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) + } +} diff --git a/src/SelectMgr/SelectMgr_ViewerSelector3d.hxx b/src/SelectMgr/SelectMgr_ViewerSelector3d.hxx new file mode 100644 index 0000000000..2aa5b38819 --- /dev/null +++ b/src/SelectMgr/SelectMgr_ViewerSelector3d.hxx @@ -0,0 +1,96 @@ +// 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 +#include +#include +#include + +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 and . 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 , , + //! and 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 . + 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 diff --git a/src/StdPrs/FILES b/src/StdPrs/FILES index 8c307bc97e..eda18e5be3 100644 --- a/src/StdPrs/FILES +++ b/src/StdPrs/FILES @@ -1,4 +1,7 @@ -StdPrs_BndBox.cxx +StdPrs_BRepFont.cxx +StdPrs_BRepFont.hxx +StdPrs_BRepTextBuilder.cxx +StdPrs_BRepTextBuilder.hxx StdPrs_BndBox.hxx StdPrs_Curve.cxx StdPrs_Curve.hxx @@ -23,6 +26,8 @@ StdPrs_ShadedShape.cxx StdPrs_ShadedShape.hxx StdPrs_ShadedSurface.cxx StdPrs_ShadedSurface.hxx +StdPrs_ShapeTool.cxx +StdPrs_ShapeTool.hxx StdPrs_ToolPoint.cxx StdPrs_ToolPoint.hxx StdPrs_ToolRFace.cxx diff --git a/src/Font/Font_BRepFont.cxx b/src/StdPrs/StdPrs_BRepFont.cxx old mode 100755 new mode 100644 similarity index 91% rename from src/Font/Font_BRepFont.cxx rename to src/StdPrs/StdPrs_BRepFont.cxx index ef75e1cfc5..203a0c1a47 --- a/src/Font/Font_BRepFont.cxx +++ b/src/StdPrs/StdPrs_BRepFont.cxx @@ -12,7 +12,7 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -#include +#include #include #include @@ -51,7 +51,7 @@ #include FT_FREETYPE_H #include FT_OUTLINE_H -IMPLEMENT_STANDARD_RTTIEXT(Font_BRepFont,Font_FTFont) +IMPLEMENT_STANDARD_RTTIEXT(StdPrs_BRepFont, Font_FTFont) namespace { @@ -120,7 +120,7 @@ namespace // function : Constructor // purpose : // ======================================================================= -Font_BRepFont::Font_BRepFont () +StdPrs_BRepFont::StdPrs_BRepFont () : myPrecision (Precision::Confusion()), myScaleUnits (1.0), myIsCompositeCurve (Standard_False), @@ -134,7 +134,7 @@ Font_BRepFont::Font_BRepFont () // function : init // purpose : // ======================================================================= -void Font_BRepFont::init() +void StdPrs_BRepFont::init() { mySurface = new Geom_Plane (gp_Pln (gp::XOY())); myCurve2dAdaptor = new Geom2dAdaptor_HCurve(); @@ -146,9 +146,9 @@ void Font_BRepFont::init() // function : Constructor // purpose : // ======================================================================= -Font_BRepFont::Font_BRepFont (const NCollection_String& theFontPath, - const Standard_Real theSize, - const Standard_Integer theFaceId) +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), @@ -169,10 +169,10 @@ Font_BRepFont::Font_BRepFont (const NCollection_String& theFontPath, // function : Constructor // purpose : // ======================================================================= -Font_BRepFont::Font_BRepFont (const NCollection_String& theFontName, - const Font_FontAspect theFontAspect, - const Standard_Real theSize, - const Font_StrictLevel theStrictLevel) +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), @@ -193,7 +193,7 @@ Font_BRepFont::Font_BRepFont (const NCollection_String& theFontName, // function : Release // purpose : // ======================================================================= -void Font_BRepFont::Release() +void StdPrs_BRepFont::Release() { myCache.Clear(); Font_FTFont::Release(); @@ -203,7 +203,7 @@ void Font_BRepFont::Release() // function : SetCompositeCurveMode // purpose : // ======================================================================= -void Font_BRepFont::SetCompositeCurveMode (const Standard_Boolean theToConcatenate) +void StdPrs_BRepFont::SetCompositeCurveMode (const Standard_Boolean theToConcatenate) { if (myIsCompositeCurve != theToConcatenate) { @@ -216,9 +216,9 @@ void Font_BRepFont::SetCompositeCurveMode (const Standard_Boolean theToConcatena // function : Init // purpose : // ======================================================================= -bool Font_BRepFont::Init (const NCollection_String& theFontPath, - const Standard_Real theSize, - const Standard_Integer theFaceId) +bool StdPrs_BRepFont::Init (const NCollection_String& theFontPath, + const Standard_Real theSize, + const Standard_Integer theFaceId) { if (theSize <= myPrecision * 100.0) { @@ -233,10 +233,10 @@ bool Font_BRepFont::Init (const NCollection_String& theFontPath, // function : FindAndInit // purpose : // ======================================================================= -bool Font_BRepFont::FindAndInit (const TCollection_AsciiString& theFontName, - const Font_FontAspect theFontAspect, - const Standard_Real theSize, - const Font_StrictLevel theStrictLevel) +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) { @@ -251,7 +251,7 @@ bool Font_BRepFont::FindAndInit (const TCollection_AsciiString& theFontName, // function : RenderGlyph // purpose : // ======================================================================= -TopoDS_Shape Font_BRepFont::RenderGlyph (const Standard_Utf32Char& theChar) +TopoDS_Shape StdPrs_BRepFont::RenderGlyph (const Standard_Utf32Char& theChar) { TopoDS_Shape aShape; Standard_Mutex::Sentry aSentry (myMutex); @@ -263,9 +263,9 @@ TopoDS_Shape Font_BRepFont::RenderGlyph (const Standard_Utf32Char& theChar) // function : to3d // purpose : // ======================================================================= -bool Font_BRepFont::to3d (const Handle(Geom2d_Curve)& theCurve2d, - const GeomAbs_Shape theContinuity, - Handle(Geom_Curve)& theCurve3d) +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; @@ -283,8 +283,8 @@ bool Font_BRepFont::to3d (const Handle(Geom2d_Curve)& theCurve2d, // function : buildFaces // purpose : // ======================================================================= -Standard_Boolean Font_BRepFont::buildFaces (const NCollection_Sequence& theWires, - TopoDS_Shape& theRes) +Standard_Boolean StdPrs_BRepFont::buildFaces (const NCollection_Sequence& theWires, + TopoDS_Shape& theRes) { // classify wires NCollection_DataMap, TopTools_ShapeMapHasher> aMapOutInts; @@ -399,13 +399,12 @@ Standard_Boolean Font_BRepFont::buildFaces (const NCollection_Sequence +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +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& theWires, + TopoDS_Shape& theRes); + + //! Hide visibility. + using Font_FTFont::FindAndCreate; + +protected: //! @name Protected fields + + NCollection_DataMap + 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__ diff --git a/src/Font/Font_BRepTextBuilder.cxx b/src/StdPrs/StdPrs_BRepTextBuilder.cxx similarity index 77% rename from src/Font/Font_BRepTextBuilder.cxx rename to src/StdPrs/StdPrs_BRepTextBuilder.cxx index 2304c19957..4ba004b19c 100644 --- a/src/Font/Font_BRepTextBuilder.cxx +++ b/src/StdPrs/StdPrs_BRepTextBuilder.cxx @@ -13,15 +13,15 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -#include +#include // ======================================================================= // Function : Perfrom // Purpose : // ======================================================================= -TopoDS_Shape Font_BRepTextBuilder::Perform (Font_BRepFont& theFont, - const Font_TextFormatter& theFormatter, - const gp_Ax3& thePenLoc) +TopoDS_Shape StdPrs_BRepTextBuilder::Perform (StdPrs_BRepFont& theFont, + const Font_TextFormatter& theFormatter, + const gp_Ax3& thePenLoc) { gp_Trsf aTrsf; gp_XYZ aPen; @@ -71,11 +71,11 @@ TopoDS_Shape Font_BRepTextBuilder::Perform (Font_BRepFont& theFont, // 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) +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; diff --git a/src/StdPrs/StdPrs_BRepTextBuilder.hxx b/src/StdPrs/StdPrs_BRepTextBuilder.hxx new file mode 100644 index 0000000000..4e6b60a3b3 --- /dev/null +++ b/src/StdPrs/StdPrs_BRepTextBuilder.hxx @@ -0,0 +1,51 @@ +// 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 +#include +#include + +//! 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 diff --git a/src/StdPrs/StdPrs_BndBox.hxx b/src/StdPrs/StdPrs_BndBox.hxx index 307b1b1b7d..802c01aa6d 100644 --- a/src/StdPrs/StdPrs_BndBox.hxx +++ b/src/StdPrs/StdPrs_BndBox.hxx @@ -1,6 +1,4 @@ -// 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. // @@ -16,133 +14,8 @@ #ifndef _StdPrs_BndBox_H__ #define _StdPrs_BndBox_H__ -#include -#include -#include -#include -#include -#include +#include -//! 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__ diff --git a/src/Prs3d/Prs3d_ShapeTool.cxx b/src/StdPrs/StdPrs_ShapeTool.cxx similarity index 53% rename from src/Prs3d/Prs3d_ShapeTool.cxx rename to src/StdPrs/StdPrs_ShapeTool.cxx index 732f3205a7..12cdf5cfee 100644 --- a/src/Prs3d/Prs3d_ShapeTool.cxx +++ b/src/StdPrs/StdPrs_ShapeTool.cxx @@ -14,6 +14,7 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. +#include #include #include @@ -27,24 +28,18 @@ #include #include #include -#include #include #include -#include -#include -#include -#include -#include #include #include #include //======================================================================= -//function : Prs3d_ShapeTool -//purpose : +//function : StdPrs_ShapeTool +//purpose : //======================================================================= -Prs3d_ShapeTool::Prs3d_ShapeTool (const TopoDS_Shape& theShape, - const Standard_Boolean theAllVertices) +StdPrs_ShapeTool::StdPrs_ShapeTool (const TopoDS_Shape& theShape, + const Standard_Boolean theAllVertices) : myShape (theShape) { myEdgeMap.Clear(); @@ -83,53 +78,11 @@ Prs3d_ShapeTool::Prs3d_ShapeTool (const TopoDS_Shape& theShape, } } -//======================================================================= -//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 : +//purpose : //======================================================================= - -Bnd_Box Prs3d_ShapeTool::FaceBound() const +Bnd_Box StdPrs_ShapeTool::FaceBound() const { const TopoDS_Face& F = TopoDS::Face(myFaceExplorer.Current()); Bnd_Box B; @@ -139,10 +92,9 @@ Bnd_Box Prs3d_ShapeTool::FaceBound() const //======================================================================= //function : IsPlanarFace -//purpose : +//purpose : //======================================================================= - -Standard_Boolean Prs3d_ShapeTool::IsPlanarFace (const TopoDS_Face& theFace) +Standard_Boolean StdPrs_ShapeTool::IsPlanarFace (const TopoDS_Face& theFace) { TopLoc_Location l; const Handle(Geom_Surface)& S = BRep_Tool::Surface(theFace, l); @@ -161,54 +113,11 @@ Standard_Boolean Prs3d_ShapeTool::IsPlanarFace (const TopoDS_Face& theFace) 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 : +//purpose : //======================================================================= - -Bnd_Box Prs3d_ShapeTool::CurveBound () const +Bnd_Box StdPrs_ShapeTool::CurveBound() const { const TopoDS_Edge& E = TopoDS::Edge(myEdgeMap.FindKey(myEdge)); Bnd_Box B; @@ -218,10 +127,9 @@ Bnd_Box Prs3d_ShapeTool::CurveBound () const //======================================================================= //function : Neighbours -//purpose : +//purpose : //======================================================================= - -Standard_Integer Prs3d_ShapeTool::Neighbours () const +Standard_Integer StdPrs_ShapeTool::Neighbours() const { const TopTools_ListOfShape& L = myEdgeMap.FindFromIndex(myEdge); return L.Extent(); @@ -229,121 +137,64 @@ Standard_Integer Prs3d_ShapeTool::Neighbours () const //======================================================================= //function : FacesOfEdge -//purpose : +//purpose : //======================================================================= - -Handle(TopTools_HSequenceOfShape) Prs3d_ShapeTool::FacesOfEdge () const +Handle(TopTools_HSequenceOfShape) StdPrs_ShapeTool::FacesOfEdge() const { - Handle(TopTools_HSequenceOfShape) H = new TopTools_HSequenceOfShape; - + 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()); + for (TopTools_ListIteratorOfListOfShape LI (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 : +//purpose : //======================================================================= - -Standard_Boolean Prs3d_ShapeTool::HasSurface() const +Standard_Boolean StdPrs_ShapeTool::HasSurface() const { TopLoc_Location l; const Handle(Geom_Surface)& S = BRep_Tool::Surface(GetFace(), l); - return (!S.IsNull()); + return !S.IsNull(); } - - //======================================================================= //function : CurrentTriangulation -//purpose : +//purpose : //======================================================================= - -Handle(Poly_Triangulation) Prs3d_ShapeTool::CurrentTriangulation(TopLoc_Location& l) const +Handle(Poly_Triangulation) StdPrs_ShapeTool::CurrentTriangulation(TopLoc_Location& l) const { return BRep_Tool::Triangulation(GetFace(), l); } - //======================================================================= //function : HasCurve -//purpose : +//purpose : //======================================================================= - -Standard_Boolean Prs3d_ShapeTool::HasCurve() const +Standard_Boolean StdPrs_ShapeTool::HasCurve() const { - return (BRep_Tool::IsGeometric(GetCurve())); + return BRep_Tool::IsGeometric(GetCurve()); } - - - //======================================================================= //function : PolygonOnTriangulation -//purpose : +//purpose : //======================================================================= - -void Prs3d_ShapeTool::PolygonOnTriangulation -(Handle(Poly_PolygonOnTriangulation)& Indices, - Handle(Poly_Triangulation)& T, - TopLoc_Location& l) const +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 : +//purpose : //======================================================================= - -Handle(Poly_Polygon3D) Prs3d_ShapeTool::Polygon3D(TopLoc_Location& l) const +Handle(Poly_Polygon3D) StdPrs_ShapeTool::Polygon3D(TopLoc_Location& l) const { return BRep_Tool::Polygon3D(GetCurve(), l); } diff --git a/src/StdPrs/StdPrs_ShapeTool.hxx b/src/StdPrs/StdPrs_ShapeTool.hxx new file mode 100644 index 0000000000..712514fb65 --- /dev/null +++ b/src/StdPrs/StdPrs_ShapeTool.hxx @@ -0,0 +1,110 @@ +// 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include + +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 diff --git a/src/StdPrs/StdPrs_ToolTriangulatedShape.cxx b/src/StdPrs/StdPrs_ToolTriangulatedShape.cxx index 681d3db788..7e257bfa7c 100644 --- a/src/StdPrs/StdPrs_ToolTriangulatedShape.cxx +++ b/src/StdPrs/StdPrs_ToolTriangulatedShape.cxx @@ -16,6 +16,7 @@ #include +#include #include #include #include @@ -233,6 +234,39 @@ void StdPrs_ToolTriangulatedShape::Normal (const TopoDS_Face& theFace, } } +//======================================================================= +//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 : @@ -240,7 +274,7 @@ void StdPrs_ToolTriangulatedShape::Normal (const TopoDS_Face& theFace, 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); } // ======================================================================= @@ -257,7 +291,7 @@ Standard_Boolean StdPrs_ToolTriangulatedShape::Tessellate (const TopoDS_Shape& 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, diff --git a/src/StdPrs/StdPrs_ToolTriangulatedShape.hxx b/src/StdPrs/StdPrs_ToolTriangulatedShape.hxx index db85a042e0..81372a2a3e 100644 --- a/src/StdPrs/StdPrs_ToolTriangulatedShape.hxx +++ b/src/StdPrs/StdPrs_ToolTriangulatedShape.hxx @@ -68,6 +68,20 @@ public: Poly_Connect& thePolyConnect, TColgp_Array1OfDir& theNormals); + //! Computes the absolute deflection value depending on the type of deflection in theDrawer: + //!
    + //!
  • Aspect_TOD_RELATIVE: the absolute deflection is computed using the relative + //! deviation coefficient from theDrawer and the shape's bounding box;
  • + //!
  • Aspect_TOD_ABSOLUTE: the maximal chordial deviation from theDrawer is returned.
  • + //!
+ //! 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. diff --git a/src/StdPrs/StdPrs_WFShape.cxx b/src/StdPrs/StdPrs_WFShape.cxx index c6aeea6c7f..c03da7fcad 100644 --- a/src/StdPrs/StdPrs_WFShape.cxx +++ b/src/StdPrs/StdPrs_WFShape.cxx @@ -21,13 +21,12 @@ #include #include #include -#include #include +#include +#include #include -#include #include #include -#include #include #include #include @@ -115,7 +114,7 @@ void StdPrs_WFShape::Add (const Handle(Prs3d_Presentation)& thePresentation, 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 { @@ -154,7 +153,7 @@ void StdPrs_WFShape::Add (const Handle(Prs3d_Presentation)& thePresentation, 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; } @@ -170,7 +169,7 @@ void StdPrs_WFShape::Add (const Handle(Prs3d_Presentation)& thePresentation, 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); } @@ -230,7 +229,7 @@ void StdPrs_WFShape::Add (const Handle(Prs3d_Presentation)& thePresentation, 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); @@ -434,69 +433,9 @@ void StdPrs_WFShape::AddEdgesOnTriangulation (TColgp_SequenceOfPnt& theSegments, 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); } } } diff --git a/src/StdSelect/FILES b/src/StdSelect/FILES index df65920f3a..0cfc6f10e5 100644 --- a/src/StdSelect/FILES +++ b/src/StdSelect/FILES @@ -2,27 +2,17 @@ StdSelect.cxx 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 diff --git a/src/StdSelect/StdSelect.cxx b/src/StdSelect/StdSelect.cxx index 809729e647..542c312869 100644 --- a/src/StdSelect/StdSelect.cxx +++ b/src/StdSelect/StdSelect.cxx @@ -14,23 +14,10 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. +#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include -#include #include -#include //======================================================================= //function : SetDrawerForBRepOwner diff --git a/src/StdSelect/StdSelect.hxx b/src/StdSelect/StdSelect.hxx index 6cc5c5b376..ca2286ca49 100644 --- a/src/StdSelect/StdSelect.hxx +++ b/src/StdSelect/StdSelect.hxx @@ -17,20 +17,8 @@ #ifndef _StdSelect_HeaderFile #define _StdSelect_HeaderFile -#include -#include -#include - #include #include -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 @@ -58,39 +46,10 @@ public: 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 diff --git a/src/StdSelect/StdSelect_BRepOwner.lxx b/src/StdSelect/StdSelect_BRepOwner.lxx deleted file mode 100644 index b7479a9a8c..0000000000 --- a/src/StdSelect/StdSelect_BRepOwner.lxx +++ /dev/null @@ -1,36 +0,0 @@ -// 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 - -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;} - - diff --git a/src/StdSelect/StdSelect_BRepSelectionTool.cxx b/src/StdSelect/StdSelect_BRepSelectionTool.cxx index 284e2c0f0a..accbbaee83 100644 --- a/src/StdSelect/StdSelect_BRepSelectionTool.cxx +++ b/src/StdSelect/StdSelect_BRepSelectionTool.cxx @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -482,10 +481,10 @@ void StdSelect_BRepSelectionTool::GetEdgeSensitive (const TopoDS_Shape& theShape } 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 { @@ -704,7 +703,7 @@ Standard_Boolean StdSelect_BRepSelectionTool::GetSensitiveForFace (const TopoDS_ } else { - theSensitiveList.Append (new Select3D_SensitiveCircle (theOwner, new Geom_Circle (cu3d.Circle()), theInteriorFlag, 16)); + theSensitiveList.Append (new Select3D_SensitiveCircle (theOwner, cu3d.Circle(), theInteriorFlag, 16)); } } } diff --git a/src/StdSelect/StdSelect_DisplayMode.hxx b/src/StdSelect/StdSelect_DisplayMode.hxx deleted file mode 100644 index 3962916c21..0000000000 --- a/src/StdSelect/StdSelect_DisplayMode.hxx +++ /dev/null @@ -1,28 +0,0 @@ -// 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 diff --git a/src/StdSelect/StdSelect_IndexedDataMapOfOwnerPrs.hxx b/src/StdSelect/StdSelect_IndexedDataMapOfOwnerPrs.hxx deleted file mode 100644 index ea3f2adc02..0000000000 --- a/src/StdSelect/StdSelect_IndexedDataMapOfOwnerPrs.hxx +++ /dev/null @@ -1,27 +0,0 @@ -// 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 -#include -#include -#include - -typedef NCollection_IndexedDataMap StdSelect_IndexedDataMapOfOwnerPrs; - -#endif diff --git a/src/StdSelect/StdSelect_Prs.cxx b/src/StdSelect/StdSelect_Prs.cxx deleted file mode 100644 index 7875b35957..0000000000 --- a/src/StdSelect/StdSelect_Prs.cxx +++ /dev/null @@ -1,28 +0,0 @@ -// 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 -#include -#include - -IMPLEMENT_STANDARD_RTTIEXT(StdSelect_Prs,Prs3d_Presentation) - -StdSelect_Prs:: -StdSelect_Prs(const Handle(Graphic3d_StructureManager)& aStructureManager): -Prs3d_Presentation(aStructureManager), -myManager(aStructureManager){} - diff --git a/src/StdSelect/StdSelect_Prs.hxx b/src/StdSelect/StdSelect_Prs.hxx deleted file mode 100644 index 7dc4dcda67..0000000000 --- a/src/StdSelect/StdSelect_Prs.hxx +++ /dev/null @@ -1,67 +0,0 @@ -// 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 -#include - -#include -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 - - - - - -#endif // _StdSelect_Prs_HeaderFile diff --git a/src/StdSelect/StdSelect_Prs.lxx b/src/StdSelect/StdSelect_Prs.lxx deleted file mode 100644 index c7fae0b5b7..0000000000 --- a/src/StdSelect/StdSelect_Prs.lxx +++ /dev/null @@ -1,16 +0,0 @@ -// 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;} diff --git a/src/StdSelect/StdSelect_SensitivityMode.hxx b/src/StdSelect/StdSelect_SensitivityMode.hxx deleted file mode 100644 index dd838ba516..0000000000 --- a/src/StdSelect/StdSelect_SensitivityMode.hxx +++ /dev/null @@ -1,29 +0,0 @@ -// 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 diff --git a/src/StdSelect/StdSelect_Shape.cxx b/src/StdSelect/StdSelect_Shape.cxx index e1f25bb292..a1d7710137 100644 --- a/src/StdSelect/StdSelect_Shape.cxx +++ b/src/StdSelect/StdSelect_Shape.cxx @@ -16,7 +16,6 @@ #include -#include #include #include #include diff --git a/src/StdSelect/StdSelect_ShapeTypeFilter.hxx b/src/StdSelect/StdSelect_ShapeTypeFilter.hxx index 2ee69535dc..5bf4320260 100644 --- a/src/StdSelect/StdSelect_ShapeTypeFilter.hxx +++ b/src/StdSelect/StdSelect_ShapeTypeFilter.hxx @@ -17,67 +17,33 @@ #ifndef _StdSelect_ShapeTypeFilter_HeaderFile #define _StdSelect_ShapeTypeFilter_HeaderFile -#include -#include - #include #include -#include -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 - - - - - #endif // _StdSelect_ShapeTypeFilter_HeaderFile diff --git a/src/StdSelect/StdSelect_ShapeTypeFilter.lxx b/src/StdSelect/StdSelect_ShapeTypeFilter.lxx deleted file mode 100644 index 728dcbfd37..0000000000 --- a/src/StdSelect/StdSelect_ShapeTypeFilter.lxx +++ /dev/null @@ -1,18 +0,0 @@ -// 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;} diff --git a/src/StdSelect/StdSelect_TypeOfResult.hxx b/src/StdSelect/StdSelect_TypeOfResult.hxx deleted file mode 100644 index 36d69eb63d..0000000000 --- a/src/StdSelect/StdSelect_TypeOfResult.hxx +++ /dev/null @@ -1,29 +0,0 @@ -// 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 diff --git a/src/StdSelect/StdSelect_ViewerSelector3d.cxx b/src/StdSelect/StdSelect_ViewerSelector3d.cxx deleted file mode 100644 index 4140942b5d..0000000000 --- a/src/StdSelect/StdSelect_ViewerSelector3d.cxx +++ /dev/null @@ -1,1104 +0,0 @@ -// 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - - -IMPLEMENT_STANDARD_RTTIEXT(StdSelect_ViewerSelector3d,SelectMgr_ViewerSelector) - -static Standard_Integer StdSel_NumberOfFreeEdges (const Handle(Poly_Triangulation)& Trg) -{ - Standard_Integer nFree = 0; - Poly_Connect pc(Trg); - Standard_Integer t[3]; - Standard_Integer i, j; - for (i = 1; i <= Trg->NbTriangles(); i++) - { - pc.Triangles (i, t[0], t[1], t[2]); - for (j = 0; j < 3; j++) - if (t[j] == 0) nFree++; - } - return nFree; -} - -//======================================================================= -// Function : Constructor -// Purpose : -//======================================================================= -StdSelect_ViewerSelector3d::StdSelect_ViewerSelector3d() {} - -//======================================================================= -// Function: SetPixelTolerance -// Purpose : -//======================================================================= -void StdSelect_ViewerSelector3d::SetPixelTolerance (const Standard_Integer theTolerance) -{ - if (myTolerances.Tolerance() != theTolerance) - { - if (theTolerance < 0) - myTolerances.ResetDefaults(); - else - myTolerances.SetCustomTolerance (theTolerance); - myToUpdateTolerance = Standard_True; - } -} - -//======================================================================= -// Function: Pick -// Purpose : -//======================================================================= -void StdSelect_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 (theXPix), - static_cast (theYPix)); - mySelectingVolumeMgr.BuildSelectingVolume (aMousePos); - mySelectingVolumeMgr.SetViewClipping (theView->ClipPlanes(), Handle(Graphic3d_SequenceOfHClipPlane)()); - - TraverseSensitives(); -} - -//======================================================================= -// Function: Pick -// Purpose : -//======================================================================= -void StdSelect_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 (theXPMin), - static_cast (theYPMin)); - gp_Pnt2d aMaxMousePos (static_cast (theXPMax), - static_cast (theYPMax)); - mySelectingVolumeMgr.BuildSelectingVolume (aMinMousePos, - aMaxMousePos); - - mySelectingVolumeMgr.SetViewClipping (theView->ClipPlanes(), Handle(Graphic3d_SequenceOfHClipPlane)()); - - TraverseSensitives(); -} - -//======================================================================= -// Function: Pick -// Purpose : Selection using a polyline -//======================================================================= -void StdSelect_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 StdSelect_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) - { - 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 StdSelect_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 StdSelect_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()); - - computeSensitivePrs (aStruct, theSel, theTrsf, Handle(Graphic3d_TransformPers)()); - - myStructs.Append (aStruct); - myStructs.Last()->SetDisplayPriority (10); - myStructs.Last()->Display(); - - theView->Update(); -} - -//======================================================================= -//function : computeSensitivePrs -//purpose : -//======================================================================= -void StdSelect_ViewerSelector3d::computeSensitivePrs (const Handle(Graphic3d_Structure)& theStructure, - const Handle(SelectMgr_Selection)& theSel, - const gp_Trsf& theLoc, - const Handle(Graphic3d_TransformPers)& theTrsfPers) -{ - theStructure->SetTransformPersistence (theTrsfPers); - - Handle(Graphic3d_Group) aSensGroup = theStructure->NewGroup(); - - Quantity_Color aColor (Quantity_NOC_INDIANRED3); - Handle(Graphic3d_AspectMarker3d) aMarkerAspect =new Graphic3d_AspectMarker3d (Aspect_TOM_O_PLUS, aColor, 2.0); - - aSensGroup->SetPrimitivesAspect (aMarkerAspect); - aSensGroup->SetPrimitivesAspect (new Graphic3d_AspectLine3d (Quantity_NOC_GRAY40, Aspect_TOL_SOLID, 2.0)); - - Handle(Graphic3d_Group) anAreaGroup = theStructure->NewGroup(); - - anAreaGroup->SetPrimitivesAspect (new Graphic3d_AspectLine3d (Quantity_NOC_AQUAMARINE1, Aspect_TOL_DASH, 1.0)); - - TColgp_SequenceOfPnt aSeqLines, aSeqFree; - TColStd_SequenceOfInteger aSeqBnds; - for (NCollection_Vector::Iterator aSelEntIter (theSel->Entities()); aSelEntIter.More(); aSelEntIter.Next()) - { - const Handle(Select3D_SensitiveEntity)& Ent = aSelEntIter.Value()->BaseSensitive(); - const Standard_Boolean hasloc = theLoc.Form() != gp_Identity; - - //============== - // Box - //============= - - if (Ent->DynamicType()==STANDARD_TYPE(Select3D_SensitiveBox)) - { - const Bnd_Box& B = Handle(Select3D_SensitiveBox)::DownCast (Ent)->Box(); - Standard_Real xmin, ymin, zmin, xmax, ymax, zmax; - B.Get (xmin, ymin, zmin, xmax, ymax, zmax); - Standard_Integer i; - gp_Pnt theboxpoint[8] = - { - gp_Pnt(xmin,ymin,zmin), - gp_Pnt(xmax,ymin,zmin), - gp_Pnt(xmax,ymax,zmin), - gp_Pnt(xmin,ymax,zmin), - gp_Pnt(xmin,ymin,zmax), - gp_Pnt(xmax,ymin,zmax), - gp_Pnt(xmax,ymax,zmax), - gp_Pnt(xmin,ymax,zmax) - }; - if(hasloc) - { - for (i = 0; i <= 7; i++) - theboxpoint[i].Transform (theLoc); - } - - aSeqBnds.Append(5); - for (i = 0; i < 4; i++) - aSeqLines.Append(theboxpoint[i]); - aSeqLines.Append(theboxpoint[0]); - - aSeqBnds.Append(5); - for (i = 4; i < 8; i++) - aSeqLines.Append(theboxpoint[i]); - aSeqLines.Append(theboxpoint[4]); - - for (i = 0; i < 4; i++) - { - aSeqBnds.Append(2); - aSeqLines.Append(theboxpoint[i]); - aSeqLines.Append(theboxpoint[i+4]); - } - } - //============== - // Face - //============= - else if (Ent->DynamicType()==STANDARD_TYPE(Select3D_SensitiveFace)) - { - Handle(Select3D_SensitiveFace) aFace = Handle(Select3D_SensitiveFace)::DownCast(Ent); - Handle(TColgp_HArray1OfPnt) TheHPts; - aFace->GetPoints(TheHPts); - const TColgp_Array1OfPnt& ThePts = TheHPts->Array1(); - - aSeqBnds.Append(ThePts.Length()); - for (Standard_Integer I = ThePts.Lower(); I <= ThePts.Upper(); I++) - { - if (hasloc) - aSeqLines.Append(ThePts(I).Transformed (theLoc)); - else - aSeqLines.Append(ThePts(I)); - } - } - //============== - // Curve - //============= - else if (Ent->DynamicType()==STANDARD_TYPE(Select3D_SensitiveCurve)) - { - Handle(Select3D_SensitiveCurve) aCurve = Handle(Select3D_SensitiveCurve)::DownCast(Ent); - Handle(TColgp_HArray1OfPnt) TheHPts; - aCurve->Points3D(TheHPts); - const TColgp_Array1OfPnt& ThePts = TheHPts->Array1(); - - aSeqBnds.Append(ThePts.Length()); - for (Standard_Integer I = ThePts.Lower(); I <= ThePts.Upper(); I++) - { - if (hasloc) - aSeqLines.Append(ThePts(I).Transformed (theLoc)); - else - aSeqLines.Append(ThePts(I)); - } - } - //============== - // Wire - //============= - else if (Ent->DynamicType()==STANDARD_TYPE(Select3D_SensitiveWire)) - { - Handle(Select3D_SensitiveWire) aWire = Handle(Select3D_SensitiveWire)::DownCast(Ent); - const NCollection_Vector& anEntities = aWire->GetEdges(); - - for (int i = 0; i < anEntities.Length(); i++) - { - Handle(Select3D_SensitiveEntity) SubEnt = anEntities.Value(i); - - //Segment - if (SubEnt->DynamicType()==STANDARD_TYPE(Select3D_SensitiveSegment)) - { - gp_Pnt P1 (Handle(Select3D_SensitiveSegment)::DownCast(SubEnt)->StartPoint().XYZ()); - gp_Pnt P2 (Handle(Select3D_SensitiveSegment)::DownCast(SubEnt)->EndPoint().XYZ()); - if (hasloc) - { - P1.Transform(theLoc); - P2.Transform(theLoc); - } - aSeqBnds.Append(2); - aSeqLines.Append(P1); - aSeqLines.Append(P2); - } - - //circle - if (SubEnt->DynamicType()==STANDARD_TYPE(Select3D_SensitiveCircle)) - { - Handle(Select3D_SensitiveCircle) aCircle = Handle(Select3D_SensitiveCircle)::DownCast(SubEnt); - Standard_Integer aFrom, aTo; - aCircle->ArrayBounds (aFrom, aTo); - aTo -= 2; - for (Standard_Integer aPntIter = aFrom; aPntIter <= aTo; aPntIter += 2) - { - gp_Pnt aPnts[3] = - { - gp_Pnt (aCircle->GetPoint3d (aPntIter + 0).XYZ()), - gp_Pnt (aCircle->GetPoint3d (aPntIter + 1).XYZ()), - gp_Pnt (aCircle->GetPoint3d (aPntIter + 2).XYZ()) - }; - - if (hasloc) - { - aPnts[0].Transform (theLoc); - aPnts[1].Transform (theLoc); - aPnts[2].Transform (theLoc); - } - - aSeqBnds.Append (4); - aSeqLines.Append (aPnts[0]); - aSeqLines.Append (aPnts[1]); - aSeqLines.Append (aPnts[2]); - aSeqLines.Append (aPnts[0]); - } - } - - //curve - if (SubEnt->DynamicType()==STANDARD_TYPE(Select3D_SensitiveCurve)) - { - Handle(Select3D_SensitiveCurve) aCurve = Handle(Select3D_SensitiveCurve)::DownCast(SubEnt); - Handle(TColgp_HArray1OfPnt) TheHPts; - aCurve->Points3D (TheHPts); - const TColgp_Array1OfPnt& ThePts = TheHPts->Array1(); - - aSeqBnds.Append(ThePts.Length()); - for (Standard_Integer I = ThePts.Lower(); I <= ThePts.Upper(); I++) - { - if (hasloc) - aSeqLines.Append(ThePts(I).Transformed (theLoc)); - else - aSeqLines.Append(ThePts(I)); - } - } - } - } - //============== - // Segment - //============= - else if (Ent->DynamicType()==STANDARD_TYPE(Select3D_SensitiveSegment)) - { - gp_Pnt P1 (Handle(Select3D_SensitiveSegment)::DownCast(Ent)->StartPoint().XYZ()); - gp_Pnt P2 (Handle(Select3D_SensitiveSegment)::DownCast(Ent)->EndPoint().XYZ()); - if (hasloc) - { - P1.Transform (theLoc); - P2.Transform (theLoc); - } - aSeqBnds.Append(2); - aSeqLines.Append(P1); - aSeqLines.Append(P2); - } - //============== - // Circle - //============= - else if (Ent->DynamicType()==STANDARD_TYPE(Select3D_SensitiveCircle)) - { - Handle(Select3D_SensitiveCircle) aCircle = Handle(Select3D_SensitiveCircle)::DownCast(Ent); - Standard_Integer aFrom, aTo; - aCircle->ArrayBounds (aFrom, aTo); - aTo -= 2; - for (Standard_Integer aPntIter = aFrom; aPntIter <= aTo; aPntIter += 2) - { - gp_Pnt aPnts[3] = - { - gp_Pnt (aCircle->GetPoint3d (aPntIter + 0).XYZ()), - gp_Pnt (aCircle->GetPoint3d (aPntIter + 1).XYZ()), - gp_Pnt (aCircle->GetPoint3d (aPntIter + 2).XYZ()) - }; - - if (hasloc) - { - aPnts[0].Transform (theLoc); - aPnts[1].Transform (theLoc); - aPnts[2].Transform (theLoc); - } - - aSeqBnds.Append (4); - aSeqLines.Append (aPnts[0]); - aSeqLines.Append (aPnts[1]); - aSeqLines.Append (aPnts[2]); - aSeqLines.Append (aPnts[0]); - } - } - //============== - // Point - //============= - else if (Ent->DynamicType()==STANDARD_TYPE(Select3D_SensitivePoint)) - { - gp_Pnt P = hasloc ? - Handle(Select3D_SensitivePoint)::DownCast(Ent)->Point() : - Handle(Select3D_SensitivePoint)::DownCast(Ent)->Point().Transformed (theLoc); - Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (1); - anArrayOfPoints->AddVertex (P.X(), P.Y(), P.Z()); - aSensGroup->AddPrimitiveArray (anArrayOfPoints); - } - //============================================================ - // Triangulation : On met un petit offset ves l'interieur... - //========================================================== - else if (Ent->DynamicType()==STANDARD_TYPE(Select3D_SensitiveTriangulation)) - { - Handle(Poly_Triangulation) PT (Handle(Select3D_SensitiveTriangulation)::DownCast (Ent)->Triangulation()); - - const Poly_Array1OfTriangle& triangles = PT->Triangles(); - const TColgp_Array1OfPnt& Nodes = PT->Nodes(); - Standard_Integer n[3]; - - TopLoc_Location iloc, bidloc; - if (Handle(Select3D_SensitiveTriangulation)::DownCast (Ent)->HasInitLocation()) - bidloc = Handle(Select3D_SensitiveTriangulation)::DownCast (Ent)->GetInitLocation(); - - if (bidloc.IsIdentity()) - iloc = theLoc; - else - iloc = theLoc * bidloc; - - Standard_Integer i; - for (i = 1; i <= PT->NbTriangles(); i++) - { - triangles (i).Get (n[0], n[1], n[2]); - gp_Pnt P1 (Nodes (n[0]).Transformed (iloc)); - gp_Pnt P2 (Nodes (n[1]).Transformed (iloc)); - gp_Pnt P3 (Nodes (n[2]).Transformed (iloc)); - gp_XYZ V1 (P1.XYZ()); - gp_XYZ V2 (P2.XYZ()); - gp_XYZ V3 (P3.XYZ()); - gp_XYZ CDG (P1.XYZ()); CDG += (P2.XYZ()); CDG += (P3.XYZ()); CDG /= 3.0; - V1 -= CDG; V2 -= CDG; V3 -= CDG; - V1 *= 0.9; V2 *= 0.9; V3 *= 0.9; - V1 += CDG; V2 += CDG; V3 += CDG; - - aSeqBnds.Append(4); - aSeqLines.Append(gp_Pnt(V1)); - aSeqLines.Append(gp_Pnt(V2)); - aSeqLines.Append(gp_Pnt(V3)); - aSeqLines.Append(gp_Pnt(V1)); - } - - // recherche des bords libres... - - Handle(TColStd_HArray1OfInteger) FreeEdges = new TColStd_HArray1OfInteger (1, 2 * StdSel_NumberOfFreeEdges (PT)); - TColStd_Array1OfInteger& FreeE = FreeEdges->ChangeArray1(); - Poly_Connect pc (PT); - Standard_Integer t[3]; - Standard_Integer j; - Standard_Integer fr (1); - for (i = 1; i <= PT->NbTriangles(); i++) - { - pc.Triangles (i, t[0], t[1], t[2]); - triangles (i).Get (n[0], n[1], n[2]); - for (j = 0; j < 3; j++) - { - Standard_Integer k = (j + 1) % 3; - if (t[j] == 0) - { - FreeE (fr) = n[j]; - FreeE (fr + 1)= n[k]; - fr += 2; - } - } - } - for (Standard_Integer ifri = 1; ifri <= FreeE.Length(); ifri += 2) - { - gp_Pnt pe1 (Nodes (FreeE (ifri)).Transformed (iloc)), pe2 (Nodes (FreeE (ifri + 1)).Transformed (iloc)); - aSeqFree.Append(pe1); - aSeqFree.Append(pe2); - } - } - else if (Ent->DynamicType()==STANDARD_TYPE(Select3D_SensitiveTriangle)) - { - Handle(Select3D_SensitiveTriangle) Str = Handle(Select3D_SensitiveTriangle)::DownCast(Ent); - gp_Pnt P1, P2, P3; - Str->Points3D (P1, P2, P3); - gp_Pnt CDG = Str->Center3D(); - - gp_XYZ V1 (P1.XYZ()); V1 -= (CDG.XYZ()); - gp_XYZ V2 (P2.XYZ()); V2 -= (CDG.XYZ()); - gp_XYZ V3 (P3.XYZ()); V3 -= (CDG.XYZ()); - V1 *= 0.9; V2 *= 0.9; V3 *= 0.9; - V1 += CDG.XYZ(); V2 += CDG.XYZ(); V3 += CDG.XYZ(); - - aSeqBnds.Append(4); - aSeqLines.Append(gp_Pnt(V1)); - aSeqLines.Append(gp_Pnt(V2)); - aSeqLines.Append(gp_Pnt(V3)); - aSeqLines.Append(gp_Pnt(V1)); - } - } - - Standard_Integer i; - - if (aSeqLines.Length()) - { - Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(aSeqLines.Length(),aSeqBnds.Length()); - for (i = 1; i <= aSeqLines.Length(); i++) - aPrims->AddVertex(aSeqLines(i)); - for (i = 1; i <= aSeqBnds.Length(); i++) - aPrims->AddBound(aSeqBnds(i)); - anAreaGroup->AddPrimitiveArray(aPrims); - } - - if (aSeqFree.Length()) - { - aSensGroup->SetPrimitivesAspect (new Graphic3d_AspectLine3d (Quantity_NOC_GREEN, Aspect_TOL_SOLID, 2.0)); - Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(aSeqFree.Length(),aSeqFree.Length()/2); - for (i = 1; i <= aSeqFree.Length(); i++) - { - aPrims->AddBound(2); - aPrims->AddVertex(aSeqLines(i++)); - aPrims->AddVertex(aSeqLines(i)); - } - aSensGroup->AddPrimitiveArray(aPrims); - aSensGroup->SetPrimitivesAspect (new Graphic3d_AspectLine3d (Quantity_NOC_GRAY40, Aspect_TOL_SOLID, 2.0)); - } -} - -//======================================================================= -// Function: updateZLayers -// Purpose : -//======================================================================= -void StdSelect_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); - } -} - -namespace -{ - //! Abstract class for filling pixel with color. - class BaseFiller : public Standard_Transient - { - DEFINE_STANDARD_RTTI_INLINE(BaseFiller, Standard_Transient) - public: - - //! Main constructor. - BaseFiller (Image_PixMap& thePixMap, - StdSelect_ViewerSelector3d* 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; - StdSelect_ViewerSelector3d* myMainSel; - math_BullardGenerator myBullardGenerator; - NCollection_Map myUniqueColors; - }; - - //! Help class for filling pixel with random color. - class GeneratedEntityColorFiller : public BaseFiller - { - DEFINE_STANDARD_RTTI_INLINE(GeneratedEntityColorFiller, BaseFiller) - public: - GeneratedEntityColorFiller (Image_PixMap& thePixMap, - StdSelect_ViewerSelector3d* theSelector, - const SelectMgr_SelectableObjectSet& theSelObjects) - : BaseFiller (thePixMap, theSelector) - { - // generate per-entity colors in the order as they have been activated - for (SelectMgr_SelectableObjectSet::Iterator anObjIter (theSelObjects); 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::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 myMapEntityColors; - }; - - //! Help class for filling pixel with normalized depth of ray. - class NormalizedDepthFiller : public BaseFiller - { - DEFINE_STANDARD_RTTI_INLINE(NormalizedDepthFiller, BaseFiller) - public: - NormalizedDepthFiller (Image_PixMap& thePixMap, - StdSelect_ViewerSelector3d* theSelector, - const Standard_Boolean theToInverse) - : BaseFiller (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 (theRow, theCol) = ShortRealLast(); - return; - } - - const SelectMgr_SortCriterion& aSortCriterion = myMainSel->PickedData (thePicked); - myUnnormImage.ChangeValue (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 (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 BaseFiller - { - DEFINE_STANDARD_RTTI_INLINE(UnnormalizedDepthFiller, BaseFiller) - public: - UnnormalizedDepthFiller (Image_PixMap& thePixMap, - StdSelect_ViewerSelector3d* theSelector) - : BaseFiller (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 BaseFiller - { - DEFINE_STANDARD_RTTI_INLINE(GeneratedOwnerColorFiller, BaseFiller) - public: - GeneratedOwnerColorFiller (Image_PixMap& thePixMap, - StdSelect_ViewerSelector3d* theSelector, - const SelectMgr_SelectableObjectSet& theSelObjects) - : BaseFiller (thePixMap, theSelector) - { - // generate per-owner colors in the order as they have been activated - for (SelectMgr_SelectableObjectSet::Iterator anObjIter (theSelObjects); 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::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 myMapOwnerColors; - }; - - //! Help class for filling pixel with random color for each selection mode. - class GeneratedSelModeColorFiller : public BaseFiller - { - DEFINE_STANDARD_RTTI_INLINE(GeneratedSelModeColorFiller, BaseFiller) - public: - GeneratedSelModeColorFiller (Image_PixMap& thePixMap, - StdSelect_ViewerSelector3d* theSelector) - : BaseFiller (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::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 myMapSelectionModeColors; - }; - - //! Help class for filling pixel with color of detected shape. - class DetectedObjectColorFiller : public BaseFiller - { - DEFINE_STANDARD_RTTI_INLINE(DetectedObjectColorFiller, BaseFiller) - public: - DetectedObjectColorFiller (Image_PixMap& thePixMap, - StdSelect_ViewerSelector3d* theSelector) - : BaseFiller (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 : ToPixMap -//purpose : -//======================================================================= -Standard_Boolean StdSelect_ViewerSelector3d::ToPixMap (Image_PixMap& theImage, - const Handle(V3d_View)& theView, - const StdSelect_TypeOfSelectionImage theType, - const Standard_Integer thePickedIndex) -{ - if (theImage.IsEmpty()) - { - throw Standard_ProgramError("StdSelect_ViewerSelector3d::ToPixMap() has been called with empty image"); - } - - Handle(BaseFiller) aFiller; - switch (theType) - { - case StdSelect_TypeOfSelectionImage_NormalizedDepth: - case StdSelect_TypeOfSelectionImage_NormalizedDepthInverted: - { - aFiller = new NormalizedDepthFiller (theImage, this, - theType == StdSelect_TypeOfSelectionImage_NormalizedDepthInverted); - break; - } - case StdSelect_TypeOfSelectionImage_UnnormalizedDepth: - { - aFiller = new UnnormalizedDepthFiller (theImage, this); - break; - } - case StdSelect_TypeOfSelectionImage_ColoredDetectedObject: - { - aFiller = new DetectedObjectColorFiller (theImage, this); - break; - } - case StdSelect_TypeOfSelectionImage_ColoredEntity: - { - aFiller = new GeneratedEntityColorFiller (theImage, this, mySelectableObjects); - break; - } - case StdSelect_TypeOfSelectionImage_ColoredOwner: - { - aFiller = new GeneratedOwnerColorFiller (theImage, this, mySelectableObjects); - break; - } - case StdSelect_TypeOfSelectionImage_ColoredSelectionMode: - { - aFiller = new GeneratedSelModeColorFiller (theImage, this); - break; - } - } - if (aFiller.IsNull()) - { - return Standard_False; - } - - const Standard_Integer aSizeX = static_cast (theImage.SizeX()); - const Standard_Integer aSizeY = static_cast (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 StdSelect_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) - } -} diff --git a/src/StdSelect/StdSelect_ViewerSelector3d.hxx b/src/StdSelect/StdSelect_ViewerSelector3d.hxx index 9496cb5866..b109ad0a03 100644 --- a/src/StdSelect/StdSelect_ViewerSelector3d.hxx +++ b/src/StdSelect/StdSelect_ViewerSelector3d.hxx @@ -1,7 +1,4 @@ -// Created on: 1995-03-15 -// Created by: Robert COUBLANC -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS +// Copyright (c) 2020 OPEN CASCADE SAS // // This file is part of Open CASCADE Technology software library. // @@ -17,102 +14,8 @@ #ifndef _StdSelect_ViewerSelector3d_HeaderFile #define _StdSelect_ViewerSelector3d_HeaderFile -#include -#include -#include +#include -#include -#include -#include -#include -#include -#include -#include +typedef SelectMgr_ViewerSelector3d StdSelect_ViewerSelector3d; -class Graphic3d_Group; -class Graphic3d_Structure; -class Graphic3d_TransformPers; -class V3d_View; -class SelectMgr_EntityOwner; -class SelectMgr_SelectableObjectSet; - - -//! Selector Usable by Viewers from V3d -class StdSelect_ViewerSelector3d : public SelectMgr_ViewerSelector -{ - -public: - - //! Constructs an empty 3D selector object. - Standard_EXPORT StdSelect_ViewerSelector3d(); - - //! Sets the pixel tolerance . - Standard_EXPORT void SetPixelTolerance (const Standard_Integer theTolerance); - - //! Returns the pixel tolerance. - Standard_Integer PixelTolerance() const { return myTolerances.Tolerance(); } - - //! Picks the sensitive entity at the pixel coordinates of - //! the mouse and . 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 , , - //! and 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); - - //! Displays sensitives in view . - 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; - - DEFINE_STANDARD_RTTIEXT(StdSelect_ViewerSelector3d,SelectMgr_ViewerSelector) - -protected: - - Standard_EXPORT void computeSensitivePrs (const Handle(Graphic3d_Structure)& theStructure, - const Handle(SelectMgr_Selection)& theSel, - const gp_Trsf& theLoc, - const Handle(Graphic3d_TransformPers)& theTrsfPers); - - //! Update z-layers order map. - Standard_EXPORT void updateZLayers (const Handle(V3d_View)& theView); - -protected: - - Graphic3d_SequenceOfStructure myStructs; -}; - -DEFINE_STANDARD_HANDLE(StdSelect_ViewerSelector3d, SelectMgr_ViewerSelector) - -#endif +#endif // _StdSelect_ViewerSelector3d_HeaderFile diff --git a/src/TColQuantity/FILES b/src/TColQuantity/FILES deleted file mode 100644 index 797ce735a6..0000000000 --- a/src/TColQuantity/FILES +++ /dev/null @@ -1,4 +0,0 @@ -TColQuantity_Array1OfLength.hxx -TColQuantity_Array2OfLength.hxx -TColQuantity_HArray1OfLength.hxx -TColQuantity_HArray2OfLength.hxx diff --git a/src/TColQuantity/TColQuantity_Array1OfLength.hxx b/src/TColQuantity/TColQuantity_Array1OfLength.hxx deleted file mode 100644 index a532be5598..0000000000 --- a/src/TColQuantity/TColQuantity_Array1OfLength.hxx +++ /dev/null @@ -1,26 +0,0 @@ -// Created on: 1994-03-03 -// Created by: Jean Louis FRENKEL -// Copyright (c) 1994-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 TColQuantity_Array1OfLength_HeaderFile -#define TColQuantity_Array1OfLength_HeaderFile - -#include -#include - -typedef NCollection_Array1 TColQuantity_Array1OfLength; - - -#endif diff --git a/src/TColQuantity/TColQuantity_Array2OfLength.hxx b/src/TColQuantity/TColQuantity_Array2OfLength.hxx deleted file mode 100644 index 24db99922a..0000000000 --- a/src/TColQuantity/TColQuantity_Array2OfLength.hxx +++ /dev/null @@ -1,26 +0,0 @@ -// Created on: 1994-03-03 -// Created by: Jean Louis FRENKEL -// Copyright (c) 1994-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 TColQuantity_Array2OfLength_HeaderFile -#define TColQuantity_Array2OfLength_HeaderFile - -#include -#include - -typedef NCollection_Array2 TColQuantity_Array2OfLength; - - -#endif diff --git a/src/TColQuantity/TColQuantity_HArray1OfLength.hxx b/src/TColQuantity/TColQuantity_HArray1OfLength.hxx deleted file mode 100644 index f0b2b95f5e..0000000000 --- a/src/TColQuantity/TColQuantity_HArray1OfLength.hxx +++ /dev/null @@ -1,27 +0,0 @@ -// Created on: 1994-03-03 -// Created by: Jean Louis FRENKEL -// Copyright (c) 1994-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 TColQuantity_HArray1OfLength_HeaderFile -#define TColQuantity_HArray1OfLength_HeaderFile - -#include -#include -#include - -DEFINE_HARRAY1(TColQuantity_HArray1OfLength, TColQuantity_Array1OfLength) - - -#endif diff --git a/src/TColQuantity/TColQuantity_HArray2OfLength.hxx b/src/TColQuantity/TColQuantity_HArray2OfLength.hxx deleted file mode 100644 index f5d68c80b8..0000000000 --- a/src/TColQuantity/TColQuantity_HArray2OfLength.hxx +++ /dev/null @@ -1,27 +0,0 @@ -// Created on: 1994-03-03 -// Created by: Jean Louis FRENKEL -// Copyright (c) 1994-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 TColQuantity_HArray2OfLength_HeaderFile -#define TColQuantity_HArray2OfLength_HeaderFile - -#include -#include -#include - -DEFINE_HARRAY2(TColQuantity_HArray2OfLength, TColQuantity_Array2OfLength) - - -#endif diff --git a/src/TKOpenGl/EXTERNLIB b/src/TKOpenGl/EXTERNLIB index 02ec594fb8..8760fee2cd 100755 --- a/src/TKOpenGl/EXTERNLIB +++ b/src/TKOpenGl/EXTERNLIB @@ -1,7 +1,6 @@ TKernel TKService TKMath -TKV3d CSF_TBB CSF_FREETYPE CSF_OpenGlLibs diff --git a/src/TKService/EXTERNLIB b/src/TKService/EXTERNLIB index b5d8d722c2..80590f6c1a 100755 --- a/src/TKService/EXTERNLIB +++ b/src/TKService/EXTERNLIB @@ -1,11 +1,5 @@ TKernel TKMath -TKBRep -TKGeomBase -TKGeomAlgo -TKG2d -TKG3d -TKTopAlgo CSF_user32 CSF_advapi32 CSF_OpenGlLibs diff --git a/src/TKService/PACKAGES b/src/TKService/PACKAGES index c7eb831649..1196ba0e84 100755 --- a/src/TKService/PACKAGES +++ b/src/TKService/PACKAGES @@ -1,9 +1,9 @@ Aspect InterfaceGraphic +Graphic3d Xw Image Media WNT Cocoa -TColQuantity Font diff --git a/src/TKV3d/PACKAGES b/src/TKV3d/PACKAGES index cf8000db28..904ab32610 100755 --- a/src/TKV3d/PACKAGES +++ b/src/TKV3d/PACKAGES @@ -1,5 +1,4 @@ V3d -Graphic3d Select3D Prs3d StdPrs diff --git a/src/TPrsStd/TPrsStd_NamedShapeDriver.cxx b/src/TPrsStd/TPrsStd_NamedShapeDriver.cxx index 17c26a5d70..5b720e8096 100644 --- a/src/TPrsStd/TPrsStd_NamedShapeDriver.cxx +++ b/src/TPrsStd/TPrsStd_NamedShapeDriver.cxx @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include diff --git a/src/TopLoc/FILES b/src/TopLoc/FILES index c109adb630..febf3afb81 100644 --- a/src/TopLoc/FILES +++ b/src/TopLoc/FILES @@ -1,6 +1,5 @@ TopLoc_Datum3D.cxx TopLoc_Datum3D.hxx -TopLoc_Datum3D.lxx TopLoc_IndexedMapOfLocation.hxx TopLoc_ItemLocation.cxx TopLoc_ItemLocation.hxx diff --git a/src/TopLoc/TopLoc_Datum3D.hxx b/src/TopLoc/TopLoc_Datum3D.hxx index 0997bca4b8..bfbad01c89 100644 --- a/src/TopLoc/TopLoc_Datum3D.hxx +++ b/src/TopLoc/TopLoc_Datum3D.hxx @@ -23,9 +23,6 @@ #include #include #include -class Standard_ConstructionError; -class gp_Trsf; - class TopLoc_Datum3D; DEFINE_STANDARD_HANDLE(TopLoc_Datum3D, Standard_Transient) @@ -40,7 +37,6 @@ class TopLoc_Datum3D : public Standard_Transient public: - //! Constructs a default Datum3D. Standard_EXPORT TopLoc_Datum3D(); @@ -48,10 +44,14 @@ public: //! raised if the Trsf is not a rigid transformation. Standard_EXPORT TopLoc_Datum3D(const gp_Trsf& T); - //! Returns a gp_Trsf which, when applied to this datum, - //! produces the default datum. - const gp_Trsf& Transformation() const; - + //! Returns a gp_Trsf which, when applied to this datum, produces the default datum. + const gp_Trsf& Transformation() const { return myTrsf; } + + //! Returns a gp_Trsf which, when applied to this datum, produces the default datum. + const gp_Trsf& Trsf() const { return myTrsf; } + + //! Return transformation form. + gp_TrsfForm Form() const { return myTrsf.Form(); } //! Dumps the content of me into the stream Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const; @@ -59,33 +59,16 @@ public: //! Writes the contents of this Datum3D to the stream S. Standard_EXPORT void ShallowDump (Standard_OStream& S) const; - - - DEFINE_STANDARD_RTTIEXT(TopLoc_Datum3D,Standard_Transient) -protected: - - - - private: - gp_Trsf myTrsf; - }; - -#include - - - inline void ShallowDump(const Handle(TopLoc_Datum3D)& me,Standard_OStream& S) { me->ShallowDump(S); } - - #endif // _TopLoc_Datum3D_HeaderFile diff --git a/src/TopLoc/TopLoc_Datum3D.lxx b/src/TopLoc/TopLoc_Datum3D.lxx deleted file mode 100644 index 24c11e9d2f..0000000000 --- a/src/TopLoc/TopLoc_Datum3D.lxx +++ /dev/null @@ -1,25 +0,0 @@ -// Created on: 1993-03-01 -// Created by: Remi LEQUETTE -// 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. - -//======================================================================= -//function : Transformation -//purpose : -//======================================================================= - -inline const gp_Trsf& TopLoc_Datum3D::Transformation() const -{ - return myTrsf; -} diff --git a/src/V3d/V3d_CircularGrid.cxx b/src/V3d/V3d_CircularGrid.cxx index ccf2092719..ae7001af9c 100644 --- a/src/V3d/V3d_CircularGrid.cxx +++ b/src/V3d/V3d_CircularGrid.cxx @@ -172,7 +172,7 @@ void V3d_CircularGrid::UpdateDisplay () -SinAlpha, CosAlpha, 0.0, -YOrigin(), 0.0, 0.0, 1.0, 0.0); aTrsf.Multiply (aTrsf2); - myStructure->SetTransformation (new Geom_Transformation (aTrsf)); + myStructure->SetTransformation (new TopLoc_Datum3D (aTrsf)); myCurAngle = RotationAngle (); myCurXo = XOrigin (), myCurYo = YOrigin (); diff --git a/src/V3d/V3d_Plane.cxx b/src/V3d/V3d_Plane.cxx index 8f94c65c7d..894299b920 100755 --- a/src/V3d/V3d_Plane.cxx +++ b/src/V3d/V3d_Plane.cxx @@ -143,5 +143,5 @@ void V3d_Plane::Update() gp_Trsf aTransform; aTransform.SetTransformation (aGeomPln.Position()); aTransform.Invert(); - myGraphicStructure->SetTransformation (new Geom_Transformation (aTransform)); + myGraphicStructure->SetTransformation (new TopLoc_Datum3D (aTransform)); } diff --git a/src/V3d/V3d_RectangularGrid.cxx b/src/V3d/V3d_RectangularGrid.cxx index 4a24e55306..18b394aed6 100644 --- a/src/V3d/V3d_RectangularGrid.cxx +++ b/src/V3d/V3d_RectangularGrid.cxx @@ -172,7 +172,7 @@ void V3d_RectangularGrid::UpdateDisplay () -SinAlpha, CosAlpha, 0.0, -YOrigin(), 0.0, 0.0, 1.0, 0.0); aTrsf.Multiply (aTrsf2); - myStructure->SetTransformation (new Geom_Transformation (aTrsf)); + myStructure->SetTransformation (new TopLoc_Datum3D (aTrsf)); myCurAngle = RotationAngle (); myCurXo = XOrigin (), myCurYo = YOrigin (); diff --git a/src/ViewerTest/ViewerTest_ObjectCommands.cxx b/src/ViewerTest/ViewerTest_ObjectCommands.cxx index d2007a95cc..95995ad911 100644 --- a/src/ViewerTest/ViewerTest_ObjectCommands.cxx +++ b/src/ViewerTest/ViewerTest_ObjectCommands.cxx @@ -131,8 +131,6 @@ #include #include -#include -#include #include #include #include @@ -1999,8 +1997,7 @@ void FilledCircle::ComputeSelection(const Handle(SelectMgr_Selection) &theSelect const Standard_Integer /*theMode*/) { Handle(SelectMgr_EntityOwner) anEntityOwner = new SelectMgr_EntityOwner(this); - Handle(Select3D_SensitiveCircle) aSensitiveCircle = new Select3D_SensitiveCircle(anEntityOwner, - myCircle, myFilledStatus); + Handle(Select3D_SensitiveCircle) aSensitiveCircle = new Select3D_SensitiveCircle (anEntityOwner, myCircle->Circ(), myFilledStatus); theSelection->Add(aSensitiveCircle); } @@ -2686,7 +2683,6 @@ static int VDrawText (Draw_Interpretor& theDI, #include #include #include -#include #include diff --git a/src/VrmlConverter/VrmlConverter_WFDeflectionShape.cxx b/src/VrmlConverter/VrmlConverter_WFDeflectionShape.cxx index d82933dc02..9694e61cd6 100644 --- a/src/VrmlConverter/VrmlConverter_WFDeflectionShape.cxx +++ b/src/VrmlConverter/VrmlConverter_WFDeflectionShape.cxx @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include #include @@ -44,7 +44,7 @@ void VrmlConverter_WFDeflectionShape::Add( Standard_OStream& a const Handle (VrmlConverter_Drawer)& aDrawer) { - Prs3d_ShapeTool Tool(aShape); + StdPrs_ShapeTool Tool(aShape); Standard_Real theRequestedDeflection; if(aDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE) // TOD_RELATIVE, TOD_ABSOLUTE diff --git a/src/VrmlConverter/VrmlConverter_WFShape.cxx b/src/VrmlConverter/VrmlConverter_WFShape.cxx index 1ba9061111..a38cef3bcd 100644 --- a/src/VrmlConverter/VrmlConverter_WFShape.cxx +++ b/src/VrmlConverter/VrmlConverter_WFShape.cxx @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include #include @@ -42,7 +42,7 @@ void VrmlConverter_WFShape::Add(Standard_OStream& anOStream, const Handle(VrmlConverter_Drawer)& aDrawer) { - Prs3d_ShapeTool Tool(aShape); + StdPrs_ShapeTool Tool(aShape); if (aDrawer->UIsoAspect()->Number() != 0 || aDrawer->VIsoAspect()->Number() != 0 ) { -- 2.20.1