SET(${PROJECT_NAME_UC}_PATCH_VERSION 0)
SET(${PROJECT_NAME_UC}_VERSION
${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION})
-SET(${PROJECT_NAME_UC}_VERSION_DEV 0)
+SET(${PROJECT_NAME_UC}_VERSION_DEV 1)
# Find KERNEL
# ===========
--- /dev/null
+/*!
+
+\page shape_statistics_operation_page Shape Statistics
+
+This operation allows plotting a distribution histogram for the numerical parameters and creating the corresponding geometrical groups of the given shape.
+
+To call <b>Shape Statistics</b> dialog box, in the <b>Main Menu</b> select <b>Inspection - > Shape Statistics</b>.
+
+\image html shape_statistics.png
+
+In this dialog:
+- "Selected objects" standard selection box allows selecting one or more geometrical objects.
+
+- "Type" combo-box with the following items: "Edges length", "Faces area", "Solids volume".
+\note "Type" combo-box includes only parameters applied to the currently selected shape (e.g. "Solids volume" will not be available for face or shell being selected); multiple selection is processed correspondingly (i.e. only types applicable for all selected shapes will be available).
+
+- "Number of intervals" spin box is used to specify number of distribution histogram ranges.
+
+- "Scalar range" checkable group box that, when switched ON, allows specifying custom values range used for plotting and creating groups.
+\note By default, "Scalar range" controls is empty; pressing "Compute" button allows automatic computing initial range of the chosen parameter. This is needed as computation of the parameters range can be time-consuming for large or complex models. In case of multiple selection, scalar range is computed as common from all selected shapes.
+
+- "Plot" button opens or uses an opened Plot2d viewer and plots the distribution histogram for the selected shape(s).
+
+- "Create groups" button allows creating a groups according to the currently specified parameters. The groups names will include numerical values of the range, e.g. "Edges_length_0-20", "Edges_length_20-40", etc. Empty groups are not created.
+
+- Close dialog box, by pressing <b>Close</b> button.
+
+*/
<li>\subpage managing_dimensions_page "Dimensions"</li>
<li>\subpage whatis_page "WhatIs"</li>
<li>\subpage inspect_object_operation_page "Inspect Object"</li>
+<li>\subpage shape_statistics_operation_page "Shape Statistics"</li>
</ul>
\n To check their integrity:
To create a group of sub-shapes of a geometrical object in the main
menu select <b>New entity > Group > Create</b>
-\n The following menu will appear:
+\n The following dialog box will appear:
\image html geomcreategroup.png
The entities, which satisfy the entered filtering parameters, will be automatically highlighted
in the 3D viewer.
+\b Plot button into "Filter" group box provides an access
+to the \ref shape_statistics_operation_page "Shape Statistics" functionality with simplified look-n-feel:
+
+\image html shape_statistics_simple.png
+
\n <b>TUI Command:</b> <em>geompy.CreateGroup(MainShape,
ShapeType),</em> where MainShape is a shape for which the group is
created, ShapeType is a type of shapes in the created group.
GEOM.config
GEOMDS_Resources
ShHealing
+ Y14.5M-2009.ttf
3dsketch.png
isoline.png
isoline_v.png
<!-- Dimension presentation properties -->
<parameter name="dimensions_color" value="#ffffff" />
<parameter name="dimensions_line_width" value="1" />
- <parameter name="dimensions_font_height" value="10" />
+ <parameter name="dimensions_font" value="Y14.5M-2009,14" />
<parameter name="dimensions_arrow_length" value="5" />
<parameter name="dimensions_show_units" value="0" />
<parameter name="dimensions_length_units" value="m" />
<parameter name="dimensions_angle_units" value="deg" />
- <parameter name="dimensions_default_flyout" value="20" />
+ <parameter name="dimensions_default_flyout" value="20" />
+ <parameter name="dimensions_use_text3d" value="0" />
<!-- Scalar bar for field step presentation -->
<parameter name="scalar_bar_x_position" value="0.05" />
SET(SUBDIRS_GUI
OBJECT DlgRef GEOMFiltersSelection Material GEOMGUI
GEOMBase DependencyTree GEOMToolsGUI DisplayGUI BasicGUI PrimitiveGUI GenerationGUI
- CurveCreator EntityGUI BuildGUI BooleanGUI TransformationGUI OperationGUI
- RepairGUI MeasureGUI GroupGUI BlocksGUI AdvancedGUI
+ CurveCreator MeasureGUI EntityGUI BuildGUI BooleanGUI TransformationGUI OperationGUI
+ RepairGUI GroupGUI BlocksGUI AdvancedGUI
GEOM_SWIG_WITHIHM
)
ENDIF()
${PROJECT_SOURCE_DIR}/src/GEOMImpl
${PROJECT_SOURCE_DIR}/src/GEOMGUI
${PROJECT_SOURCE_DIR}/src/GEOMBase
+ ${PROJECT_SOURCE_DIR}/src/MeasureGUI
${PROJECT_SOURCE_DIR}/src/SKETCHER
${PROJECT_SOURCE_DIR}/src/CurveCreator
${PROJECT_SOURCE_DIR}/src/ShapeRecognition
DlgRef
GEOMSketcher
CurveCreator
+ MeasureGUI
)
# optional sources
#include <GeometryGUI.h>
#include <GEOMBase.h>
#include <GEOMUtils.hxx>
+#include <MeasureGUI_ShapeStatisticsDlg.h>
#include <OCCViewer_ViewModel.h>
#include <SVTK_ViewModel.h>
myLessFilterSpin = new SalomeApp_DoubleSpinBox(myFilterGrp);
myGreaterFilterSpin = new SalomeApp_DoubleSpinBox(myFilterGrp);
myApplyFilterButton = new QPushButton(tr("GEOM_BUT_APPLY"), myFilterGrp);
+ myPlotDistributionButton = new QPushButton(tr("GEOM_PLOT_DISTRIBUTION"), myFilterGrp);
QGridLayout* filterLayout = new QGridLayout(myFilterGrp);
filterLayout->addWidget(myLessFilterCheck, 0, 0);
filterLayout->addWidget(myGreaterFilterCombo, 1, 1);
filterLayout->addWidget(myGreaterFilterSpin, 1, 2);
filterLayout->addWidget(myApplyFilterButton, 0, 3);
+ filterLayout->addWidget(myPlotDistributionButton, 1, 3);
QVBoxLayout* layout = new QVBoxLayout(centralWidget());
layout->setMargin(0); layout->setSpacing(6);
connect(GroupPoints->PushButton4, SIGNAL(clicked()), this, SLOT(showOnlySelected()));
connect(myApplyFilterButton, SIGNAL(clicked()), this, SLOT(ClickOnOkFilter()));
+ connect(myPlotDistributionButton, SIGNAL(clicked()), this, SLOT(ClickOnPlot()));
connect(myLessFilterCheck, SIGNAL(stateChanged(int)), this, SLOT(MeasureToggled()));
connect(myGreaterFilterCheck, SIGNAL(stateChanged(int)), this, SLOT(MeasureToggled()));
GroupPoints->CheckButton1->isChecked() &&
shapeType() < GEOM::VERTEX);
+ myPlotDistributionButton->setEnabled( myFilterGrp->isEnabled() &&
+ ( shapeType() == TopAbs_EDGE ||
+ shapeType() == TopAbs_FACE ||
+ shapeType() == TopAbs_SOLID ) );
+
activateSelection();
}
updateButtonState();
}
+//=================================================================================
+// function : ClickOnPlot()
+// purpose : opens "Shape Statistics" dialog box in order to plot sub-shapes distribution.
+//=================================================================================
+void EntityGUI_SubShapeDlg::ClickOnPlot()
+{
+ QDialog* dlg = new MeasureGUI_ShapeStatisticsDlg( this, myShape, (TopAbs_ShapeEnum)shapeType() );
+ if ( dlg ) {
+ dlg->show();
+ }
+}
+
//=================================================================================
// function : MeasureToggled()
// purpose :
void showOnlySelected();
void ClickOnOkFilter();
+ void ClickOnPlot();
void MeasureToggled();
private:
SalomeApp_DoubleSpinBox* myLessFilterSpin;
SalomeApp_DoubleSpinBox* myGreaterFilterSpin;
QPushButton* myApplyFilterButton;
+ QPushButton* myPlotDistributionButton;
QGroupBox* myFilterGrp;
};
GEOMAlgo_DataMapOfPassKeyInteger.hxx
GEOMAlgo_DataMapOfShapeMapOfShape.hxx
GEOMAlgo_DataMapOfShapePnt.hxx
+ GEOMAlgo_FinderShapeOn.hxx
+ GEOMAlgo_FinderShapeOn1.hxx
GEOMAlgo_FinderShapeOn2.hxx
+ GEOMAlgo_FinderShapeOnQuad.hxx
GEOMAlgo_GetInPlace.hxx
GEOMAlgo_GetInPlaceAPI.hxx
GEOMAlgo_GlueAnalyser.hxx
GEOMAlgo_IndexedDataMapOfShapeState.hxx
GEOMAlgo_KindOfBounds.hxx
GEOMAlgo_KindOfClosed.hxx
+ GEOMAlgo_KindOfDef.hxx
GEOMAlgo_KindOfName.hxx
GEOMAlgo_KindOfShape.hxx
GEOMAlgo_ListIteratorOfListOfCoupleOfShapes.hxx
GEOMAlgo_AlgoTools.hxx
GEOMAlgo_AlgoTools.cxx
GEOMAlgo_AlgoTools_1.cxx
-GEOMAlgo_AlgoTools_2.cxx
GEOMAlgo_SolidSolid.hxx
GEOMAlgo_SolidSolid.cxx
GEOMAlgo_ShapeAlgo.hxx
GEOMAlgo_ShapeAlgo.cxx
+GEOMAlgo_FinderShapeOn.hxx
+GEOMAlgo_FinderShapeOn.cxx
+GEOMAlgo_FinderShapeOn1.hxx
+GEOMAlgo_FinderShapeOn1.cxx
GEOMAlgo_HAlgo.hxx
GEOMAlgo_HAlgo.cxx
GEOMAlgo_Clsf.hxx
GEOMAlgo_Clsf.cxx
GEOMAlgo_ClsfBox.hxx
GEOMAlgo_ClsfBox.cxx
-GEOMAlgo_ClsfQuad.hxx
-GEOMAlgo_ClsfQuad.cxx
GEOMAlgo_ClsfSolid.hxx
GEOMAlgo_ClsfSolid.cxx
GEOMAlgo_ClsfSurf.hxx
GEOMAlgo_ClsfSurf.cxx
GEOMAlgo_FinderShapeOn2.hxx
GEOMAlgo_FinderShapeOn2.cxx
+GEOMAlgo_FinderShapeOnQuad.hxx
+GEOMAlgo_FinderShapeOnQuad.cxx
GEOMAlgo_Gluer.hxx
GEOMAlgo_Gluer.cxx
GEOMAlgo_GlueAnalyser.hxx
GEOMAlgo_GetInPlace_1.cxx
GEOMAlgo_GetInPlace_2.cxx
GEOMAlgo_GetInPlace_3.cxx
-GEOMAlgo_GetInPlaceAPI.hxx
-GEOMAlgo_GetInPlaceAPI.cxx
GEOMAlgo_Splitter.hxx
GEOMAlgo_Splitter.cxx
GEOMAlgo_ShapeInfoFiller.hxx
GEOMAlgo_IndexedDataMapOfShapeShapeInfo.hxx
Basics_OCCTVersion.hxx
+
+GEOMAlgo_KindOfDef.hxx
Standard_Integer& iCnt);
static
void CopySource(const TopoDS_Shape& aS,
- TopTools_IndexedDataMapOfShapeShape& aMapSS,
- TopoDS_Shape& aSC);
+ TopTools_IndexedDataMapOfShapeShape& aMapSS,
+ TopoDS_Shape& aSC);
//=======================================================================
//function : CopyShape
//purpose :
//=======================================================================
void GEOMAlgo_AlgoTools::CopyShape(const TopoDS_Shape& aS,
- TopoDS_Shape& aSC)
+ TopoDS_Shape& aSC)
{
TopTools_IndexedDataMapOfShapeShape aMapSS;
//
//purpose :
//=======================================================================
void GEOMAlgo_AlgoTools::CopyShape(const TopoDS_Shape& aS,
- TopoDS_Shape& aSC,
- TopTools_IndexedDataMapOfShapeShape& aMapSS)
+ TopoDS_Shape& aSC,
+ TopTools_IndexedDataMapOfShapeShape& aMapSS)
{
CopySource(aS, aMapSS, aSC);
}
//purpose :
//=======================================================================
void GEOMAlgo_AlgoTools::FaceNormal (const TopoDS_Face& aF,
- const Standard_Real U,
- const Standard_Real V,
- gp_Vec& aN)
+ const Standard_Real U,
+ const Standard_Real V,
+ gp_Vec& aN)
{
gp_Pnt aPnt ;
gp_Vec aD1U, aD1V;
// purpose:
//=======================================================================
void GEOMAlgo_AlgoTools::MakeContainer(const TopAbs_ShapeEnum theType,
- TopoDS_Shape& theC)
+ TopoDS_Shape& theC)
{
BRep_Builder aBB;
//
//purpose :
//=======================================================================
void GEOMAlgo_AlgoTools::RefinePCurveForEdgeOnFace(const TopoDS_Edge& aE,
- const TopoDS_Face& aF,
- const Standard_Real aUMin,
- const Standard_Real aUMax)
+ const TopoDS_Face& aF,
+ const Standard_Real aUMin,
+ const Standard_Real aUMax)
{
Standard_Real aT1, aT2, aTx, aUx, aTol;
gp_Pnt2d aP2D;
//purpose :
//=======================================================================
void GEOMAlgo_AlgoTools::PointOnEdge(const TopoDS_Edge& aE,
- gp_Pnt& aP3D)
+ gp_Pnt& aP3D)
{
Standard_Real aTx, aT1, aT2;
//
//purpose :
//=======================================================================
void GEOMAlgo_AlgoTools::PointOnEdge(const TopoDS_Edge& aE,
- const Standard_Real aT,
- gp_Pnt& aP3D)
+ const Standard_Real aT,
+ gp_Pnt& aP3D)
{
Standard_Real aT1, aT2;
Handle(Geom_Curve) aC3D;
//purpose :
//=======================================================================
void GEOMAlgo_AlgoTools::PointOnFace(const TopoDS_Face& aF,
- const Standard_Real aU,
- const Standard_Real aV,
- gp_Pnt& aP3D)
+ const Standard_Real aU,
+ const Standard_Real aV,
+ gp_Pnt& aP3D)
{
Handle(Geom_Surface) aS;
//
//purpose :
//=======================================================================
void GEOMAlgo_AlgoTools::PointOnFace(const TopoDS_Face& aF,
- gp_Pnt& aP3D)
+ gp_Pnt& aP3D)
{
Standard_Real aU, aV, aUMin, aUMax, aVMin, aVMax;
//
//purpose :
//=======================================================================
void GEOMAlgo_AlgoTools::PointOnShape(const TopoDS_Shape& aS,
- gp_Pnt& aP3D)
+ gp_Pnt& aP3D)
{
TopAbs_ShapeEnum aType;
//
return 0; // Nothing to do
}
//
- while(1) {
+ for(;;) {
aNbEProcessed=aMProcessed.Extent();
if (aNbEProcessed==aNbE) {
break;
//purpose :
//=======================================================================
Standard_Integer GEOMAlgo_AlgoTools::PntInFace(const TopoDS_Face& aF,
- gp_Pnt& theP,
- gp_Pnt2d& theP2D)
+ gp_Pnt& theP,
+ gp_Pnt2d& theP2D)
{
Standard_Boolean bIsDone, bHasFirstPoint, bHasSecondPoint;
Standard_Integer iErr, aIx, aNbDomains, i;
//
Geom2dHatch_Intersector aIntr(aTotArcIntr, aTolTangfIntr);
Geom2dHatch_Hatcher aHatcher(aIntr,
- aTolHatch2D, aTolHatch3D,
- Standard_True, Standard_False);
+ aTolHatch2D, aTolHatch3D,
+ Standard_True, Standard_False);
//
iErr=0;
aEpsT=1.e-12;
}
//
// 4.
+ aVx=aVMin;
aNbDomains=aHatcher.NbDomains(aIx);
- for (i=1; i<=aNbDomains; ++i) {
- const HatchGen_Domain& aDomain=aHatcher.Domain (aIx, i) ;
- bHasFirstPoint=aDomain.HasFirstPoint();
- if (!bHasFirstPoint) {
- iErr=5;
- return iErr;
- }
- //
- aV1=aDomain.FirstPoint().Parameter();
- //
- bHasSecondPoint=aDomain.HasSecondPoint();
- if (!bHasSecondPoint) {
- iErr=6;
- return iErr;
- }
- //
- aV2=aDomain.SecondPoint().Parameter();
- //
- aVx=IntTools_Tools::IntermediatePoint(aV1, aV2);
- //
- break;
+ if (!aNbDomains) {
+ iErr=5;
+ return iErr;
}
//
+ i=1;
+ const HatchGen_Domain& aDomain=aHatcher.Domain (aIx, i) ;
+ bHasFirstPoint=aDomain.HasFirstPoint();
+ if (!bHasFirstPoint) {
+ iErr=5;
+ return iErr;
+ }
+ //
+ aV1=aDomain.FirstPoint().Parameter();
+ //
+ bHasSecondPoint=aDomain.HasSecondPoint();
+ if (!bHasSecondPoint) {
+ iErr=6;
+ return iErr;
+ }
+ //
+ aV2=aDomain.SecondPoint().Parameter();
+ //
+ aVx=IntTools_Tools::IntermediatePoint(aV1, aV2);
+ //
aS->D0(aUx, aVx, aPx);
//
theP2D.SetCoord(aUx, aVx);
#include <BRepLib_MakeFace.hxx>
#include <BRepLib_FaceError.hxx>
-//#include <BOPTools_DSFiller.hxx>
#include <GEOMAlgo_WireSolid.hxx>
#include <GEOMAlgo_ShellSolid.hxx>
{
myErrorStatus=0;
//
- Standard_Boolean bIsDone;
Standard_Integer i, iErr;
TopAbs_State aSts[]={TopAbs_IN, TopAbs_OUT, TopAbs_ON};
TopTools_ListIteratorOfListOfShape aIt;
aType1=myGAS.GetType();
//
TopExp::MapShapes(myShape, TopAbs_EDGE, aM);
+ //
+ bIsConformState=Standard_False;
+ //
aNb=aM.Extent();
for (i=1; i<=aNb; ++i) {
GEOMAlgo_ListOfPnt aLP;
}
}
//
+ bIsConformState=Standard_False;
+ //
aExp.Init(aF, TopAbs_EDGE);
for (; aExp.More(); aExp.Next()) {
const TopoDS_Shape& aE=aExp.Current();
const TopoDS_Shape& aSd=aM(i);
aMF.Clear();
TopExp::MapShapes(aSd, TopAbs_FACE, aMF);
+ //
+ bIsConformState=Standard_False;
+ //
aNbF=aMF.Extent();
for (j=1; j<=aNbF; ++j) {
const TopoDS_Shape& aF=aMF(j);
}// if (aType==GeomAbs_Plane || aType==GeomAbs_Cylinder)
}// if (!aNb && myNbPntsMin) {
}
-//modified by NIZNHY-PKV Thu Jan 26 09:56:20 2012f
//=======================================================================
//function : InnerPoints
//purpose :
aLP.Clear();
InnerPoints(aE, aNbPntsMin, aLP);
}
-//modified by NIZNHY-PKV Thu Jan 26 09:56:32 2012t
//=======================================================================
//function : InnerPoints
//purpose :
return;
}
//
- //modified by NIZNHY-PKV Thu Jan 26 09:51:20 2012f
- /*
- aNbT=myNbPntsMin+1;
- dT=(aT2-aT1)/aNbT;
- for (j=1; j<=aNbPntsMin; ++j) {
- aT=aT1+j*dT;
- aC3D->D0(aT, aP);
- aLP.Append(aP);
- }
- */
aNbT=aNbPntsMin+1;
dT=(aT2-aT1)/aNbT;
for (j=1; j<aNbT; ++j) {
aC3D->D0(aT, aP);
aLP.Append(aP);
}
- //modified by NIZNHY-PKV Thu Jan 26 09:51:24 2012t
}
//=======================================================================
//
const TopoDS_Edge& aE=TopoDS::Edge(aM(i));
//
+ bIsConformState=Standard_False;
+ //
aExp.Init(aE, TopAbs_VERTEX);
for (; aExp.More(); aExp.Next()) {
const TopoDS_Shape& aV=aExp.Current();
}
}
//
+ //
+ bIsConformState=Standard_False;
+ //
aExp.Init(aF, TopAbs_EDGE);
for (; aExp.More(); aExp.Next()) {
const TopoDS_Shape& aE=aExp.Current();
const TopoDS_Shape& aSd=aM(i);
aMF.Clear();
TopExp::MapShapes(aSd, TopAbs_FACE, aMF);
+ //
+ bIsConformState=Standard_False;
+ //
aNbF=aMF.Extent();
for (j=1; j<=aNbF; ++j) {
const TopoDS_Shape& aF=aMF(j);
gp_Pnt aPx;
gp_Pnt2d aP2Dx;
gp_Vec aDNx;
-
TopoDS_Face aF;
TopExp_Explorer aExp;
//
aCoef=10.;
//
aExp.Init (aZ, TopAbs_FACE);
- for (; aExp.More() ; aExp.Next()) {
+ if (aExp.More()) {
aF=*((TopoDS_Face*)&aExp.Current());
- break;
}
//
iErr=PntInFace(aF, aPx, aP2Dx);
//
// 4.
aNbDomains=aHatcher.NbDomains(aIx);
- for (i=1; i<=aNbDomains; ++i) {
- const HatchGen_Domain& aDomain=aHatcher.Domain (aIx, i) ;
- bHasFirstPoint=aDomain.HasFirstPoint();
- if (!bHasFirstPoint) {
- iErr=5;
- return iErr;
- }
- //
- aV1=aDomain.FirstPoint().Parameter();
- //
- bHasSecondPoint=aDomain.HasSecondPoint();
- if (!bHasSecondPoint) {
- iErr=6;
- return iErr;
- }
- //
- aV2=aDomain.SecondPoint().Parameter();
- //
- aVx=IntTools_Tools::IntermediatePoint(aV1, aV2);
- //
- break;
+ if (!aNbDomains) {
+ iErr=5;
+ return iErr;
+ }
+ //
+ i=1;
+ const HatchGen_Domain& aDomain=aHatcher.Domain (aIx, i) ;
+ bHasFirstPoint=aDomain.HasFirstPoint();
+ if (!bHasFirstPoint) {
+ iErr=5;
+ return iErr;
+ }
+ //
+ aV1=aDomain.FirstPoint().Parameter();
+ //
+ bHasSecondPoint=aDomain.HasSecondPoint();
+ if (!bHasSecondPoint) {
+ iErr=6;
+ return iErr;
}
//
+ aV2=aDomain.SecondPoint().Parameter();
+ //
+ aVx=IntTools_Tools::IntermediatePoint(aV1, aV2);
+ //
aS->D0(aUx, aVx, aPx);
//
theP2D.SetCoord(aUx, aVx);
//=======================================================================
GEOMAlgo_GlueDetector::~GEOMAlgo_GlueDetector()
{}
-//modified by NIZNHY-PKV Tue Mar 13 12:26:50 2012f
//=======================================================================
//function : StickedShapes
//purpose :
{
return myStickedShapes;
}
-//modified by NIZNHY-PKV Tue Mar 13 12:26:54 2012t
//=======================================================================
//function : Perform
//purpose :
return;
}
//
- //modified by NIZNHY-PKV Wed Mar 14 08:00:09 2012f
CheckDetected();
if (myErrorStatus) {
return;
}
- //modified by NIZNHY-PKV Wed Mar 14 08:00:12 2012t
//
DetectEdges();
if (myErrorStatus) {
TColStd_MapIteratorOfMapOfInteger aIt1;
//
aMIP.Add(i);
- while(1) {
+ for(;;) {
aNbIP=aMIP.Extent();
aIt1.Initialize(aMIP);
for(; aIt1.More(); aIt1.Next()) {
//
aPK.SetShapes(aLV);
}
-//modified by NIZNHY-PKV Tue Mar 13 09:54:18 2012f
//=======================================================================
//function : CheckDetected
//purpose :
//
return iRet;
}
-//modified by NIZNHY-PKV Tue Mar 13 09:54:59 2012t
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-// File: GEOMAlgo_Gluer.cxx
-// Created: Sat Dec 04 12:45:53 2004
-// Author: Peter KURNEV
-// <peter@PREFEX>
+// File: GEOMAlgo_Gluer.cxx
+// Created: Sat Dec 04 12:45:53 2004
+// Author: Peter KURNEV
+// <peter@PREFEX>
//
#include <GEOMAlgo_Gluer.hxx>
//
static
void GetSubShapes(const TopoDS_Shape& aS,
- TopTools_IndexedMapOfShape& aMSS);
+ TopTools_IndexedMapOfShape& aMSS);
//=======================================================================
//function : GEOMAlgo_Gluer
TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItIm;
TopTools_DataMapOfShapeListOfShape aMVV;
GEOMAlgo_IndexedDataMapOfIntegerShape aMIS;
- //modified by NIZNHY-PKV Thu Jan 21 10:03:07 2010f
- //GEOMAlgo_IndexedDataMapOfShapeBox aMSB;
GEOMAlgo_IndexedDataMapOfShapeBndSphere aMSB;
- //modified by NIZNHY-PKV Thu Jan 21 10:03:10 2010t
//
GEOMAlgo_BndSphereTreeSelector aSelector;
GEOMAlgo_BndSphereTree aBBTree;
TColStd_MapIteratorOfMapOfInteger aIt1;
//
aMIP.Add(i);
- while(1) {
+ for(;;) {
aNbIP=aMIP.Extent();
aIt1.Initialize(aMIP);
for(; aIt1.More(); aIt1.Next()) {
- aIP=aIt1.Key();
- if (aMIPC.Contains(aIP)) {
- continue;
- }
- //
- const TopoDS_Shape& aVP=aMIS.FindFromKey(aIP);
- //modified by NIZNHY-PKV Thu Jan 21 10:04:09 2010f
- const GEOMAlgo_BndSphere& aBoxVP=aMSB.FindFromKey(aVP);
- //const Bnd_Box& aBoxVP=aMSB.FindFromKey(aVP);
- //modified by NIZNHY-PKV Thu Jan 21 10:04:11 2010t
- //
- aSelector.Clear();
- aSelector.SetBox(aBoxVP);
- //
- aNbVSD=aBBTree.Select(aSelector);
- if (!aNbVSD) {
- continue; // it must not be
- }
- //
- const TColStd_ListOfInteger& aLI=aSelector.Indices();
- //
- aIt.Initialize(aLI);
- for (; aIt.More(); aIt.Next()) {
- aIP1=aIt.Value();
- if (aMIP.Contains(aIP1)) {
- continue;
- }
- aMIP1.Add(aIP1);
- } //for (; aIt.More(); aIt.Next()) {
+ aIP=aIt1.Key();
+ if (aMIPC.Contains(aIP)) {
+ continue;
+ }
+ //
+ const TopoDS_Shape& aVP=aMIS.FindFromKey(aIP);
+ const GEOMAlgo_BndSphere& aBoxVP=aMSB.FindFromKey(aVP);
+ //
+ aSelector.Clear();
+ aSelector.SetBox(aBoxVP);
+ //
+ aNbVSD=aBBTree.Select(aSelector);
+ if (!aNbVSD) {
+ continue; // it must not be
+ }
+ //
+ const TColStd_ListOfInteger& aLI=aSelector.Indices();
+ //
+ aIt.Initialize(aLI);
+ for (; aIt.More(); aIt.Next()) {
+ aIP1=aIt.Value();
+ if (aMIP.Contains(aIP1)) {
+ continue;
+ }
+ aMIP1.Add(aIP1);
+ } //for (; aIt.More(); aIt.Next()) {
}//for(; aIt1.More(); aIt1.Next()) {
//
aNbIP1=aMIP1.Extent();
if (!aNbIP1) {
- break;
+ break;
}
//
aIt1.Initialize(aMIP);
for(; aIt1.More(); aIt1.Next()) {
- aIP=aIt1.Key();
- aMIPC.Add(aIP);
+ aIP=aIt1.Key();
+ aMIPC.Add(aIP);
}
//
aMIP.Clear();
aIt1.Initialize(aMIP1);
for(; aIt1.More(); aIt1.Next()) {
- aIP=aIt1.Key();
- aMIP.Add(aIP);
+ aIP=aIt1.Key();
+ aMIP.Add(aIP);
}
aMIP1.Clear();
}// while(1)
else { // SD vertices founded [ aMIPC ]
aIt1.Initialize(aMIPC);
for(j=0; aIt1.More(); aIt1.Next(), ++j) {
- aIP=aIt1.Key();
- const TopoDS_Shape& aVP=aMIS.FindFromKey(aIP);
- if (!j) {
- aVF=aVP;
- }
- aLVSD.Append(aVP);
- aMVProcessed.Add(aVP);
+ aIP=aIt1.Key();
+ const TopoDS_Shape& aVP=aMIS.FindFromKey(aIP);
+ if (!j) {
+ aVF=aVP;
+ }
+ aLVSD.Append(aVP);
+ aMVProcessed.Add(aVP);
}
}
myImages.Bind(aVF, aLVSD);
for (; aItS.More(); aItS.Next()) {
const TopoDS_Shape& aVSD=aItS.Value();
if (!myOrigins.IsBound(aVSD)) {
- myOrigins.Bind(aVSD, aV);
+ myOrigins.Bind(aVSD, aV);
}
}
}
aER.Orientation(TopAbs_FORWARD);
if (!BRep_Tool::Degenerated(aER)) {
// orient image
- Standard_Boolean bIsToReverse=GEOMAlgo_AlgoTools::IsSplitToReverse(aER, aE, myContext);
+ Standard_Boolean bIsToReverse=
+ GEOMAlgo_AlgoTools::IsSplitToReverse(aER, aE, myContext);
if (bIsToReverse) {
aER.Reverse();
}
aBB.Add(theResult, aShapeR);
}
}
- else
- {
+ else {
if (myKeepNonSolids) {
// just add image
const TopoDS_Shape& aShapeR = myOrigins.Find(theShape);
const TopoDS_Face& aF=TopoDS::Face(aExp.Current());
aFR=TopoDS::Face(myOrigins.Find(aF));
if (aFR.IsSame(aF)) {
- aBB.Add(aNewShell, aF);
- continue;
+ aBB.Add(aNewShell, aF);
+ continue;
}
bIsToReverse=IsToReverse(aFR, aF);
if (bIsToReverse) {
- aFR.Reverse();
+ aFR.Reverse();
}
aBB.Add(aNewShell, aFR);
}
if (aNbSDF==1) {
bHasNewSubShape=HasNewSubShape(aS1);
if (!bHasNewSubShape) {
- aNewShape=aS1;
- aNewShape.Orientation(TopAbs_FORWARD);
+ aNewShape=aS1;
+ aNewShape.Orientation(TopAbs_FORWARD);
}
}
//
if (bHasNewSubShape) {
if (aType==TopAbs_FACE) {
- TopoDS_Face aNewFace;
- //
- const TopoDS_Face& aF1=TopoDS::Face(aS1);
- MakeFace(aF1, aNewFace);
- aNewShape=aNewFace;
+ TopoDS_Face aNewFace;
+ //
+ const TopoDS_Face& aF1=TopoDS::Face(aS1);
+ MakeFace(aF1, aNewFace);
+ aNewShape=aNewFace;
}
else if (aType==TopAbs_EDGE) {
- TopoDS_Edge aNewEdge;
- //
- const TopoDS_Edge& aE1=TopoDS::Edge(aS1);
- MakeEdge(aE1, aNewEdge);
- aNewShape=aNewEdge;
+ TopoDS_Edge aNewEdge;
+ //
+ const TopoDS_Edge& aE1=TopoDS::Edge(aS1);
+ MakeEdge(aE1, aNewEdge);
+ aNewShape=aNewEdge;
}
}
//
for (; aItS.More(); aItS.Next()) {
const TopoDS_Shape& aFSD=aItS.Value();
if (!myOrigins.IsBound(aFSD)) {
- myOrigins.Bind(aFSD, aNewShape);
+ myOrigins.Bind(aFSD, aNewShape);
}
}
}
for (j=1; j<=aNbFS; ++j) {
const TopoDS_Shape& aFS=aMFS(j);
if (aMFR.Contains(aFS)) {
- const TopTools_ListOfShape& aLSx=aMFR.FindFromKey(aFS);
- aNbSx=aLSx.Extent();
- if (aNbSx==2) {
- bFound=!bFound;
- break;
- }
+ const TopTools_ListOfShape& aLSx=aMFR.FindFromKey(aFS);
+ aNbSx=aLSx.Extent();
+ if (aNbSx==2) {
+ bFound=!bFound;
+ break;
+ }
}
}
//
//purpose :
//=======================================================================
void GEOMAlgo_Gluer::FacePassKey(const TopoDS_Face& aF,
- GEOMAlgo_PassKeyShape& aPK)
+ GEOMAlgo_PassKeyShape& aPK)
{
Standard_Integer i, aNbE;
TopTools_ListOfShape aLE;
//purpose :
//=======================================================================
void GEOMAlgo_Gluer::EdgePassKey(const TopoDS_Edge& aE,
- GEOMAlgo_PassKeyShape& aPK)
+ GEOMAlgo_PassKeyShape& aPK)
{
TopoDS_Vertex aV1, aV2;
//
//purpose :
//=======================================================================
void GEOMAlgo_Gluer::MakeVertex(const TopTools_ListOfShape& aLV,
- TopoDS_Vertex& aNewVertex)
+ TopoDS_Vertex& aNewVertex)
{
Standard_Integer aNbV;
Standard_Real aTolV, aD, aDmax;
//purpose :
//=======================================================================
void GEOMAlgo_Gluer::MakeEdge(const TopoDS_Edge& aE,
- TopoDS_Edge& aNewEdge)
+ TopoDS_Edge& aNewEdge)
{
myErrorStatus=0;
//
//purpose :
//=======================================================================
void GEOMAlgo_Gluer::MakeFace(const TopoDS_Face& aF,
- TopoDS_Face& aNewFace)
+ TopoDS_Face& aNewFace)
{
myErrorStatus=0;
//
//
aER.Orientation(TopAbs_FORWARD);
if (!BRep_Tool::Degenerated(aER)) {
- // build p-curve
- if (bIsUPeriodic) {
- GEOMAlgo_AlgoTools::RefinePCurveForEdgeOnFace(aER, aFFWD, aUMin, aUMax);
- }
- BOPTools_AlgoTools2D::BuildPCurveForEdgeOnFace(aER, aFFWD);
-
- // orient image
- bIsToReverse=GEOMAlgo_AlgoTools::IsSplitToReverse(aER, aE, myContext);
- if (bIsToReverse) {
- aER.Reverse();
- }
+ // build p-curve
+ if (bIsUPeriodic) {
+ GEOMAlgo_AlgoTools::RefinePCurveForEdgeOnFace(aER, aFFWD, aUMin, aUMax);
+ }
+ BOPTools_AlgoTools2D::BuildPCurveForEdgeOnFace(aER, aFFWD);
+
+ // orient image
+ bIsToReverse=GEOMAlgo_AlgoTools::IsSplitToReverse(aER, aE, myContext);
+ if (bIsToReverse) {
+ aER.Reverse();
+ }
}
else {
- aER.Orientation(aE.Orientation());
+ aER.Orientation(aE.Orientation());
}
//
aBB.Add(newWire, aER);
//purpose :
//=======================================================================
Standard_Boolean GEOMAlgo_Gluer::IsToReverse(const TopoDS_Face& aFR,
- const TopoDS_Face& aF)
+ const TopoDS_Face& aF)
{
Standard_Boolean bRet;
Standard_Real aT, aT1, aT2, aTR, aScPr;
//purpose :
//=======================================================================
void GetSubShapes(const TopoDS_Shape& aS,
- TopTools_IndexedMapOfShape& aMSS)
+ TopTools_IndexedMapOfShape& aMSS)
{
Standard_Integer aR;
TopAbs_ShapeEnum aType;
//function : Modified
//purpose :
//=======================================================================
-const TopTools_ListOfShape& GEOMAlgo_Gluer::Modified (const TopoDS_Shape& aS)
+const TopTools_ListOfShape& GEOMAlgo_Gluer::Modified
+ (const TopoDS_Shape& aS)
{
TopAbs_ShapeEnum aType;
//
if(myOrigins.IsBound(aS)) {
const TopoDS_Shape& aSnew=myOrigins.Find(aS);
if (!aSnew.IsSame(aS)) {
- myGenerated.Append(aSnew);
+ myGenerated.Append(aSnew);
}
}
}
myImagesToWork.Clear();
myOriginsToWork.Clear();
myKeepNonSolids=Standard_False;
- //modified by NIZNHY-PKV Tue Mar 13 13:38:28 2012f
myDetector.Clear();
- //modified by NIZNHY-PKV Tue Mar 13 13:38:30 2012t
}
-//modified by NIZNHY-PKV Tue Mar 13 12:26:50 2012f
//=======================================================================
//function : StickedShapes
//purpose :
{
return myDetector.StickedShapes();
}
-//modified by NIZNHY-PKV Tue Mar 13 12:26:54 2012t
//=======================================================================
//function : SetShapesToGlue
//purpose :
//=======================================================================
-void GEOMAlgo_Gluer2::SetShapesToGlue(const TopTools_DataMapOfShapeListOfShape& aM)
+void GEOMAlgo_Gluer2::SetShapesToGlue
+ (const TopTools_DataMapOfShapeListOfShape& aM)
{
myShapesToGlue=aM;
}
myWarningStatus=0;
//
aNbSG=myShapesToGlue.Extent();
+ aType=TopAbs_SHAPE;
if (aNbSG) {
// Check myShapesToGlue
aItDMSLS.Initialize(myShapesToGlue);
myErrorStatus=0;
myWarningStatus=0;
//
+ bHasImage=Standard_False;
aItC.Initialize(myArgument);
for (; aItC.More(); aItC.Next()) {
const TopoDS_Shape& aCx=aItC.Value();
--- /dev/null
+// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//GEOMAlgo_KindOfDef
+#ifndef _GEOMAlgo_KindOfDef_HeaderFile
+#define _GEOMAlgo_KindOfDef_HeaderFile
+
+
+enum GEOMAlgo_KindOfDef {
+GEOMAlgo_KD_UNKNOWN,
+GEOMAlgo_KD_SPECIFIED,
+GEOMAlgo_KD_ARBITRARY
+};
+
+#ifndef _Standard_PrimitiveTypes_HeaderFile
+#include <Standard_PrimitiveTypes.hxx>
+#endif
+
+#endif
GEOMAlgo_KN_RECTANGLE,
GEOMAlgo_KN_TRIANGLE,
GEOMAlgo_KN_QUADRANGLE,
-GEOMAlgo_KN_ARCELLIPSE
+GEOMAlgo_KN_ARCELLIPSE,
+GEOMAlgo_KN_SOLID
};
#ifndef _Standard_PrimitiveTypes_HeaderFile
GEOMAlgo_KS_CIRCLE,
GEOMAlgo_KS_LINE,
GEOMAlgo_KS_DEGENERATED,
-//modified by NIZNHY-PKV Tue Jul 03 10:28:09 2012f
GEOMAlgo_KS_BSPLINE
-//modified by NIZNHY-PKV Tue Jul 03 10:28:11 2012t
};
#ifndef _Standard_PrimitiveTypes_HeaderFile
void DumpKindOfBounds(const GEOMAlgo_KindOfBounds aKB);
static
void DumpKindOfName(const GEOMAlgo_KindOfName aKS);
+static
+ void DumpKindOfDef(const GEOMAlgo_KindOfDef aKD);
static
void DumpPosition(const gp_Ax3& aAx3);
static
//function :
//purpose :
//=======================================================================
- GEOMAlgo_ShapeInfo::GEOMAlgo_ShapeInfo()
+GEOMAlgo_ShapeInfo::GEOMAlgo_ShapeInfo()
{
Reset();
}
//function : ~
//purpose :
//=======================================================================
- GEOMAlgo_ShapeInfo::~GEOMAlgo_ShapeInfo()
+GEOMAlgo_ShapeInfo::~GEOMAlgo_ShapeInfo()
{
}
//=======================================================================
//function : Reset
//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfo::Reset()
+void GEOMAlgo_ShapeInfo::Reset()
{
Standard_Integer i;
//
myKindOfBounds=GEOMAlgo_KB_UNKNOWN;
myKindOfClosed=GEOMAlgo_KC_UNKNOWN;
myKindOfName=GEOMAlgo_KN_UNKNOWN;
+ myKindOfDef=GEOMAlgo_KD_UNKNOWN;
//
myLocation.SetCoord(99., 99., 99.);
myDirection.SetCoord(1.,0.,0.);
//function : SetType
//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfo::SetType(const TopAbs_ShapeEnum aType)
+void GEOMAlgo_ShapeInfo::SetType(const TopAbs_ShapeEnum aType)
{
myType=aType;
}
//function : Type
//purpose :
//=======================================================================
- TopAbs_ShapeEnum GEOMAlgo_ShapeInfo::Type() const
+TopAbs_ShapeEnum GEOMAlgo_ShapeInfo::Type() const
{
return myType;
}
//function : SetNbSubShapes
//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfo::SetNbSubShapes(const TopAbs_ShapeEnum aType,
- const Standard_Integer aNb)
+void GEOMAlgo_ShapeInfo::SetNbSubShapes(const TopAbs_ShapeEnum aType,
+ const Standard_Integer aNb)
{
Standard_Integer iN;
//function : NbSubShapes
//purpose :
//=======================================================================
- Standard_Integer GEOMAlgo_ShapeInfo::NbSubShapes(const TopAbs_ShapeEnum aType) const
+Standard_Integer GEOMAlgo_ShapeInfo::NbSubShapes
+ (const TopAbs_ShapeEnum aType) const
{
Standard_Integer iN;
//function : SetKindOfShape
//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfo::SetKindOfShape(const GEOMAlgo_KindOfShape aT)
+void GEOMAlgo_ShapeInfo::SetKindOfShape(const GEOMAlgo_KindOfShape aT)
{
myKindOfShape=aT;
}
//function : KindOfShape
//purpose :
//=======================================================================
- GEOMAlgo_KindOfShape GEOMAlgo_ShapeInfo::KindOfShape() const
+GEOMAlgo_KindOfShape GEOMAlgo_ShapeInfo::KindOfShape() const
{
return myKindOfShape;
}
//function : SetKindOfName
//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfo::SetKindOfName(const GEOMAlgo_KindOfName aT)
+void GEOMAlgo_ShapeInfo::SetKindOfName(const GEOMAlgo_KindOfName aT)
{
myKindOfName=aT;
}
//function : KindOfName
//purpose :
//=======================================================================
- GEOMAlgo_KindOfName GEOMAlgo_ShapeInfo::KindOfName() const
+GEOMAlgo_KindOfName GEOMAlgo_ShapeInfo::KindOfName() const
{
return myKindOfName;
}
//function : SetKindOfBounds
//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfo::SetKindOfBounds(const GEOMAlgo_KindOfBounds aT)
+void GEOMAlgo_ShapeInfo::SetKindOfBounds(const GEOMAlgo_KindOfBounds aT)
{
myKindOfBounds=aT;
}
//function : KindOfBounds
//purpose :
//=======================================================================
- GEOMAlgo_KindOfBounds GEOMAlgo_ShapeInfo::KindOfBounds() const
+GEOMAlgo_KindOfBounds GEOMAlgo_ShapeInfo::KindOfBounds() const
{
return myKindOfBounds;
}
//function : SetKindOfClosed
//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfo::SetKindOfClosed(const GEOMAlgo_KindOfClosed aT)
+void GEOMAlgo_ShapeInfo::SetKindOfClosed(const GEOMAlgo_KindOfClosed aT)
{
myKindOfClosed=aT;
}
//function : KindOfClosed
//purpose :
//=======================================================================
- GEOMAlgo_KindOfClosed GEOMAlgo_ShapeInfo::KindOfClosed() const
+GEOMAlgo_KindOfClosed GEOMAlgo_ShapeInfo::KindOfClosed() const
{
return myKindOfClosed;
}
//=======================================================================
+//function : SetKindOfDef
+//purpose :
+//=======================================================================
+void GEOMAlgo_ShapeInfo::SetKindOfDef(const GEOMAlgo_KindOfDef aT)
+{
+ myKindOfDef=aT;
+}
+//=======================================================================
+//function : KindOfDef
+//purpose :
+//=======================================================================
+GEOMAlgo_KindOfDef GEOMAlgo_ShapeInfo::KindOfDef() const
+{
+ return myKindOfDef;
+}
+//=======================================================================
//function : SetLocation
//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfo::SetLocation(const gp_Pnt& aP)
+void GEOMAlgo_ShapeInfo::SetLocation(const gp_Pnt& aP)
{
myLocation=aP;
}
//function : Location
//purpose :
//=======================================================================
- const gp_Pnt& GEOMAlgo_ShapeInfo::Location() const
+const gp_Pnt& GEOMAlgo_ShapeInfo::Location() const
{
return myLocation;
}
//function : SetDirection
//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfo::SetDirection(const gp_Dir& aD)
+void GEOMAlgo_ShapeInfo::SetDirection(const gp_Dir& aD)
{
myDirection=aD;
}
//function : Direction
//purpose :
//=======================================================================
- const gp_Dir& GEOMAlgo_ShapeInfo::Direction() const
+const gp_Dir& GEOMAlgo_ShapeInfo::Direction() const
{
return myDirection;
}
//function : SetPosition
//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfo::SetPosition(const gp_Ax2& aAx2)
+void GEOMAlgo_ShapeInfo::SetPosition(const gp_Ax2& aAx2)
{
gp_Ax3 aAx3(aAx2);
SetPosition(aAx3);
//function : SetPosition
//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfo::SetPosition(const gp_Ax3& aAx3)
+void GEOMAlgo_ShapeInfo::SetPosition(const gp_Ax3& aAx3)
{
myPosition=aAx3;
}
//function : Position
//purpose :
//=======================================================================
- const gp_Ax3& GEOMAlgo_ShapeInfo::Position() const
+const gp_Ax3& GEOMAlgo_ShapeInfo::Position() const
{
return myPosition;
}
//function : SetPnt1
//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfo::SetPnt1(const gp_Pnt& aP)
+void GEOMAlgo_ShapeInfo::SetPnt1(const gp_Pnt& aP)
{
myPnt1=aP;
}
//function : Pnt1
//purpose :
//=======================================================================
- const gp_Pnt& GEOMAlgo_ShapeInfo::Pnt1() const
+const gp_Pnt& GEOMAlgo_ShapeInfo::Pnt1() const
{
return myPnt1;
}
//function : SetPnt2
//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfo::SetPnt2(const gp_Pnt& aP)
+void GEOMAlgo_ShapeInfo::SetPnt2(const gp_Pnt& aP)
{
myPnt2=aP;
}
//function : Pnt2
//purpose :
//=======================================================================
- const gp_Pnt& GEOMAlgo_ShapeInfo::Pnt2() const
+const gp_Pnt& GEOMAlgo_ShapeInfo::Pnt2() const
{
return myPnt2;
}
//function : SetRadius1
//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfo::SetRadius1(const Standard_Real aR)
+void GEOMAlgo_ShapeInfo::SetRadius1(const Standard_Real aR)
{
myRadius1=aR;
}
//function : Radius1
//purpose :
//=======================================================================
- Standard_Real GEOMAlgo_ShapeInfo::Radius1() const
+Standard_Real GEOMAlgo_ShapeInfo::Radius1() const
{
return myRadius1;
}
//function : SetRadius2
//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfo::SetRadius2(const Standard_Real aR)
+void GEOMAlgo_ShapeInfo::SetRadius2(const Standard_Real aR)
{
myRadius2=aR;
}
//function : Radius2
//purpose :
//=======================================================================
- Standard_Real GEOMAlgo_ShapeInfo::Radius2() const
+Standard_Real GEOMAlgo_ShapeInfo::Radius2() const
{
return myRadius2;
}
//function : SetLength
//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfo::SetLength(const Standard_Real aL)
+void GEOMAlgo_ShapeInfo::SetLength(const Standard_Real aL)
{
myLength=aL;
}
//function : Length
//purpose :
//=======================================================================
- Standard_Real GEOMAlgo_ShapeInfo::Length() const
+Standard_Real GEOMAlgo_ShapeInfo::Length() const
{
return myLength;
}
//function : SetWidth
//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfo::SetWidth(const Standard_Real aW)
+void GEOMAlgo_ShapeInfo::SetWidth(const Standard_Real aW)
{
myWidth=aW;
}
//function : Width
//purpose :
//=======================================================================
- Standard_Real GEOMAlgo_ShapeInfo::Width() const
+Standard_Real GEOMAlgo_ShapeInfo::Width() const
{
return myWidth;
}
//function : SetHeight
//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfo::SetHeight(const Standard_Real aH)
+void GEOMAlgo_ShapeInfo::SetHeight(const Standard_Real aH)
{
myHeight=aH;
}
//function : Height
//purpose :
//=======================================================================
- Standard_Real GEOMAlgo_ShapeInfo::Height() const
+Standard_Real GEOMAlgo_ShapeInfo::Height() const
{
return myHeight;
}
//function : Dump
//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfo::Dump()const
+void GEOMAlgo_ShapeInfo::Dump()const
{
switch (myType) {
//
//function : DumpCompound
//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfo::DumpCompound()const
+void GEOMAlgo_ShapeInfo::DumpCompound()const
{
Standard_Integer aNbV, aNbE, aNbF, aNbS, aNbC, aNbP;
GEOMAlgo_KindOfShape aKS;
//function : DumpCompSolid
//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfo::DumpCompSolid()const
+void GEOMAlgo_ShapeInfo::DumpCompSolid()const
{
Standard_Integer aNbV, aNbE, aNbF, aNbS;
GEOMAlgo_KindOfShape aKS;
DumpKindOfBounds(aKB);
DumpKindOfClosed(aKC);
}
-
//=======================================================================
//function : DumpSolid
//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfo::DumpSolid()const
+void GEOMAlgo_ShapeInfo::DumpSolid()const
{
Standard_Integer aNbV, aNbE, aNbF;
GEOMAlgo_KindOfShape aKS;
printf(" Height : %.3lf\n", myHeight);
}
}
-
//=======================================================================
//function : DumpFace
//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfo::DumpFace()const
+void GEOMAlgo_ShapeInfo::DumpFace()const
{
Standard_Integer aNbV, aNbE;
GEOMAlgo_KindOfShape aKS;
GEOMAlgo_KindOfName aKN;
GEOMAlgo_KindOfBounds aKB;
GEOMAlgo_KindOfClosed aKC;
+ GEOMAlgo_KindOfDef aKD;
//
aNbV=NbSubShapes(TopAbs_VERTEX);
aNbE=NbSubShapes(TopAbs_EDGE);
aKN=KindOfName();
aKB=KindOfBounds();
aKC=KindOfClosed();
+ aKD=KindOfDef();
//
printf(" *FACE\n");
printf(" number of vertices: %d\n", aNbV);
DumpKindOfName (aKN);
DumpKindOfBounds(aKB);
DumpKindOfClosed(aKC);
+ DumpKindOfDef(aKD);
//
// PLANE
if (aKN==GEOMAlgo_KN_PLANE) {
//function : DumpShell
//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfo::DumpShell()const
+void GEOMAlgo_ShapeInfo::DumpShell()const
{
Standard_Integer aNbV, aNbE, aNbF;
GEOMAlgo_KindOfClosed aKC;
//function : DumpWire
//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfo::DumpWire()const
+void GEOMAlgo_ShapeInfo::DumpWire()const
{
Standard_Integer aNbV, aNbE;
GEOMAlgo_KindOfClosed aKC;
//function : DumpEdge
//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfo::DumpEdge()const
+void GEOMAlgo_ShapeInfo::DumpEdge()const
{
Standard_Integer aNbV;
Standard_Real aX, aY, aZ;
//function : DumpVertex
//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfo::DumpVertex()const
+void GEOMAlgo_ShapeInfo::DumpVertex()const
{
printf(" *VERTEX\n");
DumpLocation(myLocation);
//function : DumpLocation
//purpose :
//=======================================================================
- void DumpLocation(const gp_Pnt& aP)
+void DumpLocation(const gp_Pnt& aP)
{
Standard_Real aX, aY, aZ;
//
//function : DumpDirection
//purpose :
//=======================================================================
- void DumpDirection(const gp_Dir& aD)
+void DumpDirection(const gp_Dir& aD)
{
Standard_Real aX, aY, aZ;
//
"KN_RECTANGLE",
"KN_TRIANGLE",
"KN_QUADRANGLE",
- "KN_ARCELLIPSE"
+ "KN_ARCELLIPSE",
+ "KN_SOLID"
};
int i;
//
i=(Standard_Integer)aKS;
printf(" KindOfName : %s\n", pStr[i]);
}
+//=======================================================================
+//function : DumpKindOfDef
+//purpose :
+//=======================================================================
+void DumpKindOfDef(const GEOMAlgo_KindOfDef aKD)
+{
+ const char *pStr[]={
+ "KD_UNKNOWN",
+ "KD_SPECIFIED",
+ "KB_ARBITRARY"
+ };
+ int i;
+ //
+ i=(Standard_Integer)aKD;
+ printf(" KindOfDef: %s\n", pStr[i]);
+}
#include <GEOMAlgo_KindOfName.hxx>
#include <GEOMAlgo_KindOfBounds.hxx>
#include <GEOMAlgo_KindOfClosed.hxx>
+#include <GEOMAlgo_KindOfDef.hxx>
//=======================================================================
TopAbs_ShapeEnum Type() const;
Standard_EXPORT
- void SetNbSubShapes(const TopAbs_ShapeEnum aType,const Standard_Integer aNb) ;
+ void SetNbSubShapes(const TopAbs_ShapeEnum aType,
+ const Standard_Integer aNb) ;
Standard_EXPORT
Standard_Integer NbSubShapes(const TopAbs_ShapeEnum aType) const;
Standard_EXPORT
GEOMAlgo_KindOfClosed KindOfClosed() const;
+ Standard_EXPORT
+ void SetKindOfDef(const GEOMAlgo_KindOfDef aT) ;
+
+ Standard_EXPORT
+ GEOMAlgo_KindOfDef KindOfDef() const;
+
Standard_EXPORT
void SetLocation(const gp_Pnt& aP) ;
GEOMAlgo_KindOfName myKindOfName;
GEOMAlgo_KindOfBounds myKindOfBounds;
GEOMAlgo_KindOfClosed myKindOfClosed;
+ GEOMAlgo_KindOfDef myKindOfDef;
gp_Pnt myLocation;
gp_Dir myDirection;
gp_Ax3 myPosition;
//function :
//purpose :
//=======================================================================
- GEOMAlgo_ShapeInfoFiller::GEOMAlgo_ShapeInfoFiller()
+GEOMAlgo_ShapeInfoFiller::GEOMAlgo_ShapeInfoFiller()
:
GEOMAlgo_Algo()
{
//function : ~
//purpose :
//=======================================================================
- GEOMAlgo_ShapeInfoFiller::~GEOMAlgo_ShapeInfoFiller()
+GEOMAlgo_ShapeInfoFiller::~GEOMAlgo_ShapeInfoFiller()
{
}
//=======================================================================
//function : SetTolerance
//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfoFiller::SetTolerance(const Standard_Real aT)
+void GEOMAlgo_ShapeInfoFiller::SetTolerance(const Standard_Real aT)
{
myTolerance=aT;
}
//function : Tolerance
//purpose :
//=======================================================================
- Standard_Real GEOMAlgo_ShapeInfoFiller::Tolerance()const
+Standard_Real GEOMAlgo_ShapeInfoFiller::Tolerance()const
{
return myTolerance;
}
//function : SetShape
//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfoFiller::SetShape(const TopoDS_Shape& aS)
+void GEOMAlgo_ShapeInfoFiller::SetShape(const TopoDS_Shape& aS)
{
myShape=aS;
}
//function : Shape
//purpose :
//=======================================================================
- const TopoDS_Shape& GEOMAlgo_ShapeInfoFiller::Shape() const
+const TopoDS_Shape& GEOMAlgo_ShapeInfoFiller::Shape() const
{
return myShape;
}
//function : Info
//purpose :
//=======================================================================
- const GEOMAlgo_ShapeInfo& GEOMAlgo_ShapeInfoFiller::Info() const
+const GEOMAlgo_ShapeInfo& GEOMAlgo_ShapeInfoFiller::Info() const
{
return Info(myShape);
}
//function : Info
//purpose :
//=======================================================================
- const GEOMAlgo_ShapeInfo& GEOMAlgo_ShapeInfoFiller::Info(const TopoDS_Shape& aS) const
+const GEOMAlgo_ShapeInfo& GEOMAlgo_ShapeInfoFiller::Info
+ (const TopoDS_Shape& aS) const
{
if (!aS.IsNull()) {
if (myMapInfo.Contains(aS)) {
//function : CheckData
//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfoFiller::CheckData()
+void GEOMAlgo_ShapeInfoFiller::CheckData()
{
myErrorStatus=0;
//
//function : Perform
//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfoFiller::Perform()
+void GEOMAlgo_ShapeInfoFiller::Perform()
{
myErrorStatus=0;
//
//function :FillShape
//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfoFiller::FillShape(const TopoDS_Shape& aS)
+void GEOMAlgo_ShapeInfoFiller::FillShape(const TopoDS_Shape& aS)
{
TopAbs_ShapeEnum aType;
//
//function :FillSubShapes
//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfoFiller::FillSubShapes(const TopoDS_Shape& aS)
+void GEOMAlgo_ShapeInfoFiller::FillSubShapes(const TopoDS_Shape& aS)
{
TopoDS_Iterator aIt;
//
//function : FillContainer
//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfoFiller::FillContainer(const TopoDS_Shape& aS)
+void GEOMAlgo_ShapeInfoFiller::FillContainer(const TopoDS_Shape& aS)
{
myErrorStatus=0;
//
//function : FillSolid
//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfoFiller::FillSolid(const TopoDS_Shape& aS)
+void GEOMAlgo_ShapeInfoFiller::FillSolid(const TopoDS_Shape& aS)
{
- Standard_Integer aNbShells;
TopoDS_Solid aSd;
//
myErrorStatus=0;
//
aSd=TopoDS::Solid(aS);
//
- aNbShells=GEOMAlgo_ShapeInfoFiller::NbShells(aSd);
- if (aNbShells>1) {
- return;
- }
- //
FillDetails(aSd);
}
//=======================================================================
//function :FillFace
//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfoFiller::FillFace(const TopoDS_Shape& aS)
+void GEOMAlgo_ShapeInfoFiller::FillFace(const TopoDS_Shape& aS)
{
myErrorStatus=0;
+ if (myMapInfo.Contains(aS)) {
+ return;
+ }
//
Standard_Boolean bIsAllowedType;
- Standard_Integer aNbWires;//, iRet
Standard_Boolean bInf, bInfU1, bInfU2, bInfV1, bInfV2;
- Standard_Real aUMin, aUMax, aVMin, aVMax, aR1, aR2;
+ Standard_Real aUMin, aUMax, aVMin, aVMax, aR1, aR2, dV;
gp_Pnt aP0;
gp_Dir aDN;
gp_Ax3 aAx3;
GeomAbs_SurfaceType aST;
Handle(Geom_Surface) aSurf;
TopoDS_Face aF;
- //GEOMAlgo_KindOfName aKindOfName;
//----------------------------------------------------
- if (myMapInfo.Contains(aS)) {
- return;
- }
- else {
- GEOMAlgo_ShapeInfo aInfoX;
- myMapInfo.Add(aS, aInfoX);
- }
+ GEOMAlgo_ShapeInfo aInfoX;
+ myMapInfo.Add(aS, aInfoX);
+ //
GEOMAlgo_ShapeInfo& aInfo=myMapInfo.ChangeFromKey(aS);
//----------------------------------------------------
aInfo.SetType(TopAbs_FACE);
//
aF=TopoDS::Face(aS);
//
- aNbWires=GEOMAlgo_ShapeInfoFiller::NbWires(aF);
- //
aSurf=BRep_Tool::Surface(aF);
GeomAdaptor_Surface aGAS(aSurf);
aST=aGAS.GetType();
return;
}
//
+ //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// 1. Plane
if (aST==GeomAbs_Plane) {
gp_Pln aPln;
aP0=aPln.Location();
aAx3=aPln.Position();
//
- aInfo.SetKindOfShape(GEOMAlgo_KS_PLANE);
+ aInfo.SetKindOfShape(GEOMAlgo_KS_PLANE);
+ aInfo.SetKindOfName(GEOMAlgo_KN_PLANE);
aInfo.SetKindOfClosed(GEOMAlgo_KC_NOTCLOSED);
aInfo.SetLocation(aP0);
aInfo.SetPosition(aAx3);
//
- if (aNbWires>1) {
- return;
- }
- //
- //aSurf->Bounds(aUMin, aUMax, aVMin, aVMax);
BRepTools::UVBounds(aF, aUMin, aUMax, aVMin, aVMax);
bInfU1=Precision::IsNegativeInfinite(aUMin);
bInfU2=Precision::IsPositiveInfinite(aUMax);
bInf=(bInfU1 || bInfU2 || bInfV1 || bInfV2);
if (bInf) {
aInfo.SetKindOfBounds(GEOMAlgo_KB_INFINITE);
+ return;
}
- else {
- aInfo.SetKindOfBounds(GEOMAlgo_KB_TRIMMED);
- }
+ //
+ aInfo.SetKindOfBounds(GEOMAlgo_KB_TRIMMED);
//
FillDetails(aF, aPln);
}// if (aCT==GeomAbs_Line) {
//
+ //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// 2. Sphere
else if (aST==GeomAbs_Sphere) {
gp_Sphere aSphere;
aR1=aSphere.Radius();
//
aInfo.SetKindOfShape(GEOMAlgo_KS_SPHERE);
+ aInfo.SetKindOfName(GEOMAlgo_KN_SPHERE);
aInfo.SetLocation(aP0);
aInfo.SetPosition(aAx3);
aInfo.SetRadius1(aR1);
//
- if (aNbWires>1) {
- return;
- }
- //
aInfo.SetKindOfBounds(GEOMAlgo_KB_TRIMMED);
aInfo.SetKindOfClosed(GEOMAlgo_KC_CLOSED);
//
FillDetails(aF, aSphere);
}// else if (aST==GeomAbs_Sphere) {
//
+ //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// 3. Cylinder
else if (aST==GeomAbs_Cylinder) {
gp_Cylinder aCyl;
aR1=aCyl.Radius();
//
aInfo.SetKindOfShape(GEOMAlgo_KS_CYLINDER);
+ aInfo.SetKindOfName(GEOMAlgo_KN_CYLINDER);
aInfo.SetLocation(aP0);
aInfo.SetPosition(aAx3);
aInfo.SetRadius1(aR1);
//
- if (aNbWires>1) {
- return;
- }
- //
BRepTools::UVBounds(aF, aUMin, aUMax, aVMin, aVMax);
bInfU1=Precision::IsNegativeInfinite(aUMin);
bInfU2=Precision::IsPositiveInfinite(aUMax);
bInf=(bInfU1 || bInfU2 || bInfV1 || bInfV2);
if (bInf) {
aInfo.SetKindOfBounds(GEOMAlgo_KB_INFINITE);
+ return;
}
- else {
- aInfo.SetKindOfBounds(GEOMAlgo_KB_TRIMMED);
- }
+ //
+ aInfo.SetKindOfBounds(GEOMAlgo_KB_TRIMMED);
+ //
+ dV=aVMax-aVMin;
+ aInfo.SetHeight(dV);
+ //
FillDetails(aF, aCyl);
}
//
+ //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// 4. Cone
else if (aST==GeomAbs_Cone) {
+ Standard_Real aSemiAngle;
gp_Cone aCone;
//
aCone=aGAS.Cone();
aP0=aCone.Location();
aAx3=aCone.Position();
- //aR1=aCyl.Radius();
//
aInfo.SetKindOfShape(GEOMAlgo_KS_CONE);
+ aInfo.SetKindOfName(GEOMAlgo_KN_CONE);
aInfo.SetLocation(aP0);
aInfo.SetPosition(aAx3);
- //aInfo.SetRadius1(aR1);
- //
- if (aNbWires>1) {
- return;
- }
//
BRepTools::UVBounds(aF, aUMin, aUMax, aVMin, aVMax);
bInfU1=Precision::IsNegativeInfinite(aUMin);
bInf=(bInfU1 || bInfU2 || bInfV1 || bInfV2);
if (bInf) {
aInfo.SetKindOfBounds(GEOMAlgo_KB_INFINITE);
+ return;
}
- else {
- aInfo.SetKindOfBounds(GEOMAlgo_KB_TRIMMED);
- }
+ //
+ aInfo.SetKindOfBounds(GEOMAlgo_KB_TRIMMED);
+ //
+ aSemiAngle=fabs(aCone.SemiAngle());
+ dV=(aVMax-aVMin)*cos(aSemiAngle);
+
+ aInfo.SetHeight(dV);
+ //
FillDetails(aF, aCone);
}
//
+ //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// 5. Torus
else if (aST==GeomAbs_Torus) {
gp_Torus aTorus;
aR2=aTorus.MinorRadius();
//
aInfo.SetKindOfShape(GEOMAlgo_KS_TORUS);
+ aInfo.SetKindOfName(GEOMAlgo_KN_TORUS);
aInfo.SetLocation(aP0);
aInfo.SetPosition(aAx3);
aInfo.SetRadius1(aR1);
aInfo.SetRadius2(aR2);
//
- if (aNbWires>1) {
- return;
- }
- //
aInfo.SetKindOfBounds(GEOMAlgo_KB_TRIMMED);
//
FillDetails(aF, aTorus);
FillSubShapes(aS);
return;
}
- //modified by NIZNHY-PKV Tue Jul 03 10:19:03 2012f
// BSplineCurve
if (aCT==GeomAbs_BSplineCurve) {
Standard_Integer aNbKnots, aNbPoles, aDegree;
aInfo.SetDirection(aDir);
}
}
- //modified by NIZNHY-PKV Tue Jul 03 10:19:06 2012t
// Line
else if (aCT==GeomAbs_Line) {
Standard_Boolean bInf1, bInf2;
//function :FillVertex
//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfoFiller::FillVertex(const TopoDS_Shape& aS)
+void GEOMAlgo_ShapeInfoFiller::FillVertex(const TopoDS_Shape& aS)
{
myErrorStatus=0;
//
//function : FillNbSubshapes
//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfoFiller::FillNbSubShapes(const TopoDS_Shape& aS,
- GEOMAlgo_ShapeInfo& aInfo)
+void GEOMAlgo_ShapeInfoFiller::FillNbSubShapes(const TopoDS_Shape& aS,
+ GEOMAlgo_ShapeInfo& aInfo)
{
myErrorStatus=0;
//
//function :NbShells
//purpose :
//=======================================================================
-Standard_Integer GEOMAlgo_ShapeInfoFiller::NbShells(const TopoDS_Solid& aSd)
+Standard_Integer GEOMAlgo_ShapeInfoFiller::NbShells
+ (const TopoDS_Solid& aSd)
{
Standard_Integer iCnt;
TopoDS_Iterator aIt;
//
aIt.Initialize(aSd);
for (; aIt.More(); aIt.Next()) {
- //const TopoDS_Shape& aSh=aIt.Value();
++iCnt;
}
return iCnt;
//function : NbWires
//purpose :
//=======================================================================
-Standard_Integer GEOMAlgo_ShapeInfoFiller::NbWires(const TopoDS_Face& aF)
+Standard_Integer GEOMAlgo_ShapeInfoFiller::NbWires
+ (const TopoDS_Face& aF)
{
Standard_Integer iCnt;
TopoDS_Iterator aIt;
//
aIt.Initialize(aF);
for (; aIt.More(); aIt.Next()) {
- //const TopoDS_Shape& aW=aIt.Value();
++iCnt;
}
return iCnt;
//function : IsAllowedType
//purpose :
//=======================================================================
-Standard_Boolean GEOMAlgo_ShapeInfoFiller::IsAllowedType(const GeomAbs_CurveType aCT)
+Standard_Boolean GEOMAlgo_ShapeInfoFiller::IsAllowedType
+ (const GeomAbs_CurveType aCT)
{
Standard_Boolean bRet;
Standard_Integer i, aNb;
GeomAbs_Line,
GeomAbs_Circle,
GeomAbs_Ellipse,
- GeomAbs_BSplineCurve //modified by NIZNHY-PKV Tue Jul 03 10:18:01 2012ft
+ GeomAbs_BSplineCurve
};
//
bRet=Standard_False;
//function : IsAllowedType
//purpose :
//=======================================================================
-Standard_Boolean GEOMAlgo_ShapeInfoFiller::IsAllowedType(const GeomAbs_SurfaceType aST)
+Standard_Boolean GEOMAlgo_ShapeInfoFiller::IsAllowedType
+ (const GeomAbs_SurfaceType aST)
{
Standard_Boolean bRet;
Standard_Integer i, aNb;
void GEOMAlgo_ShapeInfoFiller::FillDetails(const TopoDS_Solid& aSd)
{
Standard_Boolean bIsStepSphere;
- Standard_Integer i, aNbF, aNbCyl, aNbCon, aNbPgn, aNbRct, aNbCrc, aNbX;
+ Standard_Integer i, aNbF, aNbCyl, aNbCon, aNbPgn, aNbRct;
+ Standard_Integer aNbShells, aNbCrc, aNbX;
TopoDS_Shape aFCyl, aFCon;
TopTools_IndexedMapOfShape aMF;
GEOMAlgo_KindOfName aKNF;
+ GEOMAlgo_KindOfDef aKD;
//
GEOMAlgo_ShapeInfo& aInfo=myMapInfo.ChangeFromKey(aSd);
aInfo.SetKindOfName(GEOMAlgo_KN_UNKNOWN);
return;
}
//
+ aKD=GEOMAlgo_KD_SPECIFIED;
+ for (i=1; i<=aNbF && aKD==GEOMAlgo_KD_SPECIFIED; ++i) {
+ const TopoDS_Shape& aF=aMF(i);
+ GEOMAlgo_ShapeInfo& aInfoF=myMapInfo.ChangeFromKey(aF);
+ aKD=aInfoF.KindOfDef();
+ }
+ if (aKD!=GEOMAlgo_KD_SPECIFIED) {
+ aInfo.SetKindOfName(GEOMAlgo_KN_SOLID);
+ return;
+ }
+ //
+ aNbShells=GEOMAlgo_ShapeInfoFiller::NbShells(aSd);
+ if (aNbShells>1) {
+ aInfo.SetKindOfName(GEOMAlgo_KN_SOLID);
+ return;
+ }
+ //
+ //
if (aNbF==1) {
+ // mb: sphere, torus
const TopoDS_Shape& aF=aMF(1);
GEOMAlgo_ShapeInfo& aInfoF=myMapInfo.ChangeFromKey(aF);
aKNF=aInfoF.KindOfName(); // mb: sphere, torus
return;
}
}
- //modified by NIZNHY-PKV Tue Jul 03 13:23:55 2012f
else if (aNbF==2) {
// specific solid that should be treated as a sphere
bIsStepSphere=TreatStepSphere(aSd);
return;
}
}
- //modified by NIZNHY-PKV Tue Jul 03 13:23:57 2012t
//
aNbCyl=0;
aNbCon=0;
const gp_Dir& aDNj=aIFj.Position().Direction();
//
aDot=aDNi*aDNj;
- //modified by NIZNHY-PKV Tue Jul 03 10:01:56 2012f
if (aDot<0.) {
aDot=-aDot;
}
- //modified by NIZNHY-PKV Tue Jul 03 10:01:52 2012t
if (fabs(1.-aDot)<0.0001) {
aMp.Add(i);
aMp.Add(j);
return;
}
//
+ iMin=-1;
+ iMax=-1;
aDistMin=1.e15;
aDistMax=-aDistMin;
for (i=0; i<aNbFi; ++i) {
TopTools_IndexedMapOfShape aMV;
BRepTools_WireExplorer aWExp;
GEOMAlgo_KindOfName aKN, aKNE;
- GEOMAlgo_KindOfShape aKS;
//
GEOMAlgo_ShapeInfo& aInfo=myMapInfo.ChangeFromKey(aF);
- aKN=GEOMAlgo_KN_UNKNOWN;
- aInfo.SetKindOfName(GEOMAlgo_KN_UNKNOWN);
- //
- aKS=aInfo.KindOfShape();
- if (aKS!=GEOMAlgo_KS_PLANE) {
- return;
- }
//
- if (aInfo.KindOfBounds()==GEOMAlgo_KB_INFINITE) {
- aInfo.SetKindOfName(GEOMAlgo_KN_PLANE);
- return;
- }
+ aInfo.SetKindOfDef(GEOMAlgo_KD_ARBITRARY);
//
aNbV=aInfo.NbSubShapes(TopAbs_VERTEX);
aNbE=aInfo.NbSubShapes(TopAbs_EDGE);
// 1. may be it is circle/ellipse
if (aNbV==1 && aNbE==1) {
aExp.Init(aF, TopAbs_EDGE);
- for (; aExp.More(); aExp.Next()) {
+ if (aExp.More()) {
aE=aExp.Current();
- break;
}
//
const GEOMAlgo_ShapeInfo& aInfoE=myMapInfo.FindFromKey(aE);
aInfo.SetRadius1(aInfoE.Radius1());
aInfo.SetLocation(aInfoE.Location());
aInfo.SetPosition(aInfoE.Position());
+ aInfo.SetKindOfDef(GEOMAlgo_KD_SPECIFIED);
}
if (aKNE==GEOMAlgo_KN_ELLIPSE) {
aKN=GEOMAlgo_KN_DISKELLIPSE;
aInfo.SetRadius2(aInfoE.Radius2());
aInfo.SetLocation(aInfoE.Location());
aInfo.SetPosition(aInfoE.Position());
+ aInfo.SetKindOfDef(GEOMAlgo_KD_SPECIFIED);
}
- }
+ return;
+ }// if (aNbV==1 && aNbE==1) {
//
- // 2. may be it is rectangle
- else {
- aExp.Init(aF, TopAbs_EDGE);
- for (; aExp.More(); aExp.Next()) {
- aE=aExp.Current();
- const GEOMAlgo_ShapeInfo& aInfoE=myMapInfo.FindFromKey(aE);
- aKNE=aInfoE.KindOfName();
- if (aKNE!=GEOMAlgo_KN_SEGMENT) {
- return;
- }
+ //
+ Standard_Boolean bSegment;
+ //
+ bSegment=Standard_True;
+ aExp.Init(aF, TopAbs_EDGE);
+ for (; aExp.More() && bSegment; aExp.Next()) {
+ aE=aExp.Current();
+ const GEOMAlgo_ShapeInfo& aInfoE=myMapInfo.FindFromKey(aE);
+ aKNE=aInfoE.KindOfName();
+ if (aKNE!=GEOMAlgo_KN_SEGMENT) {
+ bSegment=!bSegment;
}
- //
- aInfo.SetKindOfName(GEOMAlgo_KN_POLYGON);
+ }
+ //
+ if (bSegment) {
+ // 2. may be it is TRIANGLE, POLYGON, QUADRANGLE, RECTANGLE
+ aInfo.SetKindOfDef(GEOMAlgo_KD_SPECIFIED);
+ aInfo.SetKindOfName(GEOMAlgo_KN_POLYGON);
//
if (aNbV==3 && aNbE==3) {
aInfo.SetKindOfName(GEOMAlgo_KN_TRIANGLE);
//
aInfo.SetLocation(aPc);
aInfo.SetPosition(aAx3);
- //
- return;
- }
+ } // if (aNbV==3 && aNbE==3) {
//
- if (!(aNbV==4 && aNbE==4)) {
- return;
- }
- //
- // aNbV==4 && aNbE==4 and all edges are segments
- aIt.Initialize(aF);
- for (; aIt.More(); aIt.Next()){
- aW=TopoDS::Wire(aIt.Value());
- break;
- }
- //
- aWExp.Init(aW, aF);
- for (i=0; aWExp.More(); aWExp.Next(), ++i) {
- aEx=aWExp.Current();
- const GEOMAlgo_ShapeInfo& aInfoEx=myMapInfo.FindFromKey(aEx);
- aDx[i]=aInfoEx.Direction();
- aPx[i]=aInfoEx.Location();
- }
- //
- Standard_Boolean isRectangle = Standard_True;
- for (i=0; i<4; ++i) {
- j=(i==3) ? 0 : i+1;
- aDot=aDx[i]*aDx[j];
- if (fabs (aDot) > myTolerance) {
- isRectangle = Standard_False;
- break;
+ if (aNbV==4 && aNbE==4) {
+ aIt.Initialize(aF);
+ if (aIt.More()) {
+ aW=*((TopoDS_Wire*)&aIt.Value());
+ }
+ //
+ aWExp.Init(aW, aF);
+ for (i=0; aWExp.More(); aWExp.Next(), ++i) {
+ aEx=aWExp.Current();
+ const GEOMAlgo_ShapeInfo& aInfoEx=myMapInfo.FindFromKey(aEx);
+ aDx[i]=aInfoEx.Direction();
+ aPx[i]=aInfoEx.Location();
}
- }
- //
- // rectangle
- // shift location to the center
- aXYZc.SetCoord(0.,0.,0.);
- TopExp::MapShapes(aF, TopAbs_VERTEX, aMV);
- for (i=1; i<=aNbV; ++i) {
- const TopoDS_Vertex& aV=TopoDS::Vertex(aMV(i));
- aP=BRep_Tool::Pnt(aV);
- const gp_XYZ& aXYZ=aP.XYZ();
- aXYZc=aXYZc+aXYZ;
- }
- //
- // Location : aPc in center of rectangle
- // Position : 0z is plane normal
- // 0x is along the first edge (quadrangle) or
- // along length (rectangle)
- //
- aXYZc.Divide(4.);
- aPc.SetXYZ(aXYZc);
- aDX=aDx[0];
- aInfo.SetLocation(aPc);
-
- if (isRectangle) {
- // Calculate sizes
- gp_Lin aL0(aPx[0], aDx[0]);
- gp_Lin aL1(aPx[1], aDx[1]);
//
- aD0=aL0.Distance(aPc);
- aD1=aL1.Distance(aPc);
+ Standard_Boolean isRectangle = Standard_True;
+ for (i=0; i<4; ++i) {
+ j=(i==3) ? 0 : i+1;
+ aDot=aDx[i]*aDx[j];
+ if (fabs (aDot) > myTolerance) {
+ isRectangle = Standard_False;
+ break;
+ }
+ }
//
- aLength=aD1;
- aWidth =aD0;
-
- if (aD0>aD1) {
- aLength=aD0;
- aWidth =aD1;
- aDX=aDx[1];
+ // rectangle
+ // shift location to the center
+ aXYZc.SetCoord(0.,0.,0.);
+ TopExp::MapShapes(aF, TopAbs_VERTEX, aMV);
+ for (i=1; i<=aNbV; ++i) {
+ const TopoDS_Vertex& aV=TopoDS::Vertex(aMV(i));
+ aP=BRep_Tool::Pnt(aV);
+ const gp_XYZ& aXYZ=aP.XYZ();
+ aXYZc=aXYZc+aXYZ;
}
//
- aLength=2.*aLength;
- aWidth =2.*aWidth;
+ // Location : aPc in center of rectangle
+ // Position : 0z is plane normal
+ // 0x is along the first edge (quadrangle) or
+ // along length (rectangle)
//
- aInfo.SetLength(aLength);
- aInfo.SetWidth(aWidth);
- aInfo.SetKindOfName(GEOMAlgo_KN_RECTANGLE);
- } else {
- aInfo.SetKindOfName(GEOMAlgo_KN_QUADRANGLE);
- }
- //
- const gp_Dir& aDZ=aPln.Axis().Direction();
- gp_Ax2 aAx2(aPc, aDZ, aDX);
- gp_Ax3 aAx3(aAx2);
- aInfo.SetPosition(aAx3);
- }
+ aXYZc.Divide(4.);
+ aPc.SetXYZ(aXYZc);
+ aDX=aDx[0];
+ aInfo.SetLocation(aPc);
- return;
+ if (isRectangle) {
+ // Calculate sizes
+ gp_Lin aL0(aPx[0], aDx[0]);
+ gp_Lin aL1(aPx[1], aDx[1]);
+ //
+ aD0=aL0.Distance(aPc);
+ aD1=aL1.Distance(aPc);
+ //
+ aLength=aD1;
+ aWidth =aD0;
+
+ if (aD0>aD1) {
+ aLength=aD0;
+ aWidth =aD1;
+ aDX=aDx[1];
+ }
+ //
+ aLength=2.*aLength;
+ aWidth =2.*aWidth;
+ //
+ aInfo.SetLength(aLength);
+ aInfo.SetWidth(aWidth);
+ aInfo.SetKindOfName(GEOMAlgo_KN_RECTANGLE);
+ } else {
+ aInfo.SetKindOfName(GEOMAlgo_KN_QUADRANGLE);
+ }
+ //
+ const gp_Dir& aDZ=aPln.Axis().Direction();
+ gp_Ax2 aAx2(aPc, aDZ, aDX);
+ gp_Ax3 aAx3(aAx2);
+ aInfo.SetPosition(aAx3);
+ //
+ }// if (aNbV==4 && aNbE==4) {
+ return;
+ }// if (bSegment) {
+ //
+ //aInfo.SetKindOfName(GEOMAlgo_KN_PLANE);
}
//=======================================================================
//function : FillDetails
//purpose :
//=======================================================================
void GEOMAlgo_ShapeInfoFiller::FillDetails(const TopoDS_Face& aF,
- const gp_Sphere& )
+ const gp_Sphere& )//aSph)
{
+
Standard_Integer aNbV, aNbE, aNbSE, aNbDE;
TopoDS_Edge aE;
TopExp_Explorer aExp;
TopTools_MapOfShape aM;
- GEOMAlgo_KindOfShape aKS, aKSE;
+ GEOMAlgo_KindOfShape aKSE;//, aKSE;
//
GEOMAlgo_ShapeInfo& aInfo=myMapInfo.ChangeFromKey(aF);
- aInfo.SetKindOfName(GEOMAlgo_KN_UNKNOWN);
- //
- aKS=aInfo.KindOfShape();
- if (aKS!=GEOMAlgo_KS_SPHERE) {
- return;
- }
- //
+ //
+ aInfo.SetKindOfDef(GEOMAlgo_KD_ARBITRARY);
aNbV=aInfo.NbSubShapes(TopAbs_VERTEX);
aNbE=aInfo.NbSubShapes(TopAbs_EDGE);
- if (!(aNbV==2 && aNbE==3)) {
- return;
- }
- //
- aNbSE=0;
- aNbDE=0;
- aExp.Init(aF, TopAbs_EDGE);
- for (; aExp.More(); aExp.Next()) {
- aE=TopoDS::Edge(aExp.Current());
- if(aM.Add(aE)) {
- const GEOMAlgo_ShapeInfo& aInfoE=myMapInfo.FindFromKey(aE);
- aKSE=aInfoE.KindOfShape();
- //
- if (BRep_Tool::IsClosed(aE, aF)) {
- ++aNbSE;
- }
- else if (aKSE==GEOMAlgo_KS_DEGENERATED) {
- ++aNbDE;
+ if (aNbV==2 && aNbE==3) {
+ aNbSE=0;
+ aNbDE=0;
+ aExp.Init(aF, TopAbs_EDGE);
+ for (; aExp.More(); aExp.Next()) {
+ aE=TopoDS::Edge(aExp.Current());
+ if(aM.Add(aE)) {
+ const GEOMAlgo_ShapeInfo& aInfoE=myMapInfo.FindFromKey(aE);
+ aKSE=aInfoE.KindOfShape();
+ //
+ if (BRep_Tool::IsClosed(aE, aF)) {
+ ++aNbSE;
+ }
+ else if (aKSE==GEOMAlgo_KS_DEGENERATED) {
+ ++aNbDE;
+ }
}
}
+ //
+ if (aNbSE==1 && aNbDE==2) {
+ aInfo.SetKindOfDef(GEOMAlgo_KD_SPECIFIED);
+ }
}
- //
- if (!(aNbSE==1 && aNbDE==2)) {
- return;
- }
- aInfo.SetKindOfName(GEOMAlgo_KN_SPHERE);
}
//=======================================================================
//function : FillDetails
//purpose :
//=======================================================================
void GEOMAlgo_ShapeInfoFiller::FillDetails(const TopoDS_Face& aF,
- const gp_Cone& )//aCone)
+ const gp_Cylinder& aCyl)
+
{
- Standard_Integer aNbV, aNbE, aNbCE, aNbSE, aNbDE, i;
- Standard_Real aR[3], aHeight;
- gp_Pnt aPC[3], aPD, aPc, aPX[3];
- TopoDS_Vertex aVD;
+ Standard_Integer i, aNbV, aNbE, aNbCE, aNbSE;
+ Standard_Real aT0, aT1, aHeight;
+ gp_Pnt aPC[3], aPc;
TopoDS_Edge aE;
- TopoDS_Iterator aIt;
TopExp_Explorer aExp;
TopTools_MapOfShape aM;
- GEOMAlgo_KindOfShape aKS, aKSE;
- GEOMAlgo_KindOfName aKN, aKNE;
+ GEOMAlgo_KindOfName aKNE;
GEOMAlgo_KindOfClosed aKCE;
//
GEOMAlgo_ShapeInfo& aInfo=myMapInfo.ChangeFromKey(aF);
- aKN=GEOMAlgo_KN_UNKNOWN;
- aInfo.SetKindOfName(aKN);
- //
- aKS=aInfo.KindOfShape();
- if (aKS!=GEOMAlgo_KS_CONE) {
- return;
- }
- //
- if (aInfo.KindOfBounds()==GEOMAlgo_KB_INFINITE) {
- return;
- }
//
+ aInfo.SetKindOfDef(GEOMAlgo_KD_ARBITRARY);
aNbV=aInfo.NbSubShapes(TopAbs_VERTEX);
aNbE=aInfo.NbSubShapes(TopAbs_EDGE);
- if (!(aNbV==2 && aNbE==3)) {
- return;
- }
- //
- i=0;
- aNbCE=0;
- aNbSE=0;
- aNbDE=0;
- aExp.Init(aF, TopAbs_EDGE);
- for (; aExp.More(); aExp.Next()) {
- aE=TopoDS::Edge(aExp.Current());
- if(aM.Add(aE)) {
- const GEOMAlgo_ShapeInfo& aInfoE=myMapInfo.FindFromKey(aE);
- aKNE=aInfoE.KindOfName();
- aKCE=aInfoE.KindOfClosed();
- aKSE=aInfoE.KindOfShape();
- if (aKNE==GEOMAlgo_KN_CIRCLE && aKCE==GEOMAlgo_KC_CLOSED) {
- aPC[i]=aInfoE.Location();
- aR[i]=aInfoE.Radius1();
- //
- aIt.Initialize(aE);
- for (; aIt.More(); aIt.Next()) {
- aVD=TopoDS::Vertex(aIt.Value());
- break;
- }
- aPX[i]=BRep_Tool::Pnt(aVD);
- //
- ++i;
- ++aNbCE;
- }
- else if (aKNE==GEOMAlgo_KN_SEGMENT) {
- if (BRep_Tool::IsClosed(aE, aF)) {
- ++aNbSE;
+ if (aNbV==2 && aNbE==3) {
+ const gp_Ax1& aAx1=aCyl.Axis();
+ const gp_Dir& aDir=aAx1.Direction();
+ const gp_Pnt& aPLoc=aAx1.Location();
+ //
+ i=0;
+ aNbCE=0;
+ aNbSE=0;
+ aExp.Init(aF, TopAbs_EDGE);
+ for (; aExp.More(); aExp.Next()) {
+ aE=TopoDS::Edge(aExp.Current());
+ if(aM.Add(aE)) {
+ const GEOMAlgo_ShapeInfo& aInfoE=myMapInfo.FindFromKey(aE);
+ aKNE=aInfoE.KindOfName();
+ aKCE=aInfoE.KindOfClosed();
+ if (aKNE==GEOMAlgo_KN_CIRCLE && aKCE==GEOMAlgo_KC_CLOSED) {
+ aPC[aNbCE]=aInfoE.Location();
+ ++aNbCE;
}
- }
- else if (aKSE==GEOMAlgo_KS_DEGENERATED) {
- aIt.Initialize(aE);
- for (; aIt.More(); aIt.Next()) {
- aVD=TopoDS::Vertex(aIt.Value());
- break;
+ else if (aKNE==GEOMAlgo_KN_SEGMENT) {
+ if (BRep_Tool::IsClosed(aE, aF)) {
+ ++aNbSE;
+ }
}
- //
- aPD=BRep_Tool::Pnt(aVD);
- //
- ++aNbDE;
}
}
- }
- //
- if (!((aNbCE==2 || (aNbCE==1 && aNbDE==1)) && aNbSE==1)) {
- return;
- }
- //
- if (aNbDE==1) {
- aPC[1]=aPD;
- aR[1]=0.;
- }
- //
- aHeight=aPC[0].Distance(aPC[1]);
- //
- Standard_Real aRmin, aRmax;
- gp_Ax2 aAx2new;
- //
- if (aR[0]>aR[1]) {
- aRmin=aR[1];
- aRmax=aR[0];
- aPc=aPC[0];
- gp_Vec aVz(aPC[0], aPC[1]);
- gp_Vec aVx(aPC[0], aPX[0]);
- gp_Dir aDz(aVz);
- gp_Dir aDx(aVx);
- gp_Ax2 aAx2(aPc, aDz, aDx);
- aAx2new=aAx2;
- }
- else {
- aRmin=aR[0];
- aRmax=aR[1];
- aPc=aPC[1];
- gp_Vec aVz(aPC[1], aPC[0]);
- gp_Vec aVx(aPC[1], aPX[1]);
- gp_Dir aDz(aVz);
- gp_Dir aDx(aVx);
- gp_Ax2 aAx2(aPc, aDz, aDx);
- aAx2new=aAx2;
- }
- //
- gp_Ax3 aAx3(aAx2new);
- aInfo.SetLocation(aPc);
- aInfo.SetPosition(aAx3);
- aInfo.SetRadius1(aRmax);
- aInfo.SetRadius2(aRmin);
- aInfo.SetHeight(aHeight);
- //
- aInfo.SetKindOfName(GEOMAlgo_KN_CONE);
+ //
+ if (aNbCE==2 && aNbSE==1) {
+ gp_Lin aLin(aPLoc, aDir);
+ //
+ aT0=ElCLib::Parameter(aLin, aPC[0]);
+ aT1=ElCLib::Parameter(aLin, aPC[1]);
+ //
+ aPc=aPC[0];
+ if (aT0>aT1) {
+ aPc=aPC[1];
+ }
+ aHeight=aPC[0].Distance(aPC[1]);
+ //
+ gp_Ax3 aAx3=aCyl.Position();
+ aAx3.SetLocation(aPc);
+ //
+ aInfo.SetPosition(aAx3);
+ aInfo.SetLocation(aPc);
+ aInfo.SetHeight(aHeight);
+ //
+ aInfo.SetKindOfDef(GEOMAlgo_KD_SPECIFIED);
+ return; // conventional cylinder
+ }//if (aNbCE==2 && aNbSE==1) {
+ }//if (aNbV==2 && aNbE==3) {
}
//=======================================================================
//function : FillDetails
//purpose :
//=======================================================================
void GEOMAlgo_ShapeInfoFiller::FillDetails(const TopoDS_Face& aF,
- const gp_Cylinder& aCyl)
+ const gp_Cone& aCone)
{
- Standard_Integer i, aNbV, aNbE, aNbCE, aNbSE;
- Standard_Real aT0, aT1, aHeight;
- gp_Pnt aPC[3], aPc;
+ Standard_Integer aNbV, aNbE, aNbCE, aNbSE, aNbDE, i;
+ Standard_Real aR[3], aHeight, aRmin, aRmax;
+ gp_Pnt aPC[3], aPD, aPc, aPX[3];
+ TopoDS_Vertex aVD;
TopoDS_Edge aE;
+ TopoDS_Iterator aIt;
TopExp_Explorer aExp;
TopTools_MapOfShape aM;
- GEOMAlgo_KindOfShape aKS;
- GEOMAlgo_KindOfName aKN, aKNE;
+ GEOMAlgo_KindOfShape aKSE;
+ GEOMAlgo_KindOfName aKNE;
GEOMAlgo_KindOfClosed aKCE;
//
GEOMAlgo_ShapeInfo& aInfo=myMapInfo.ChangeFromKey(aF);
- aKN=GEOMAlgo_KN_UNKNOWN;
- aInfo.SetKindOfName(aKN);
//
- aKS=aInfo.KindOfShape();
- if (aKS!=GEOMAlgo_KS_CYLINDER) {
- return;
- }
- //
- if (aInfo.KindOfBounds()==GEOMAlgo_KB_INFINITE) {
- return;
- }
+ aInfo.SetKindOfDef(GEOMAlgo_KD_ARBITRARY);
//
aNbV=aInfo.NbSubShapes(TopAbs_VERTEX);
aNbE=aInfo.NbSubShapes(TopAbs_EDGE);
- if (!(aNbV==2 && aNbE==3)) {
- return;
- }
- //
- i=0;
- aNbCE=0;
- aNbSE=0;
- aExp.Init(aF, TopAbs_EDGE);
- for (; aExp.More(); aExp.Next()) {
- aE=TopoDS::Edge(aExp.Current());
- if(aM.Add(aE)) {
- const GEOMAlgo_ShapeInfo& aInfoE=myMapInfo.FindFromKey(aE);
- aKNE=aInfoE.KindOfName();
- aKCE=aInfoE.KindOfClosed();
- if (aKNE==GEOMAlgo_KN_CIRCLE && aKCE==GEOMAlgo_KC_CLOSED) {
- aPC[aNbCE]=aInfoE.Location();
- ++aNbCE;
- }
- else if (aKNE==GEOMAlgo_KN_SEGMENT) {
- if (BRep_Tool::IsClosed(aE, aF)) {
- ++aNbSE;
+ if (aNbV==2 && aNbE==3) {
+ i=0;
+ aNbCE=0;
+ aNbSE=0;
+ aNbDE=0;
+ aExp.Init(aF, TopAbs_EDGE);
+ for (; aExp.More(); aExp.Next()) {
+ aE=TopoDS::Edge(aExp.Current());
+ if(aM.Add(aE)) {
+ const GEOMAlgo_ShapeInfo& aInfoE=myMapInfo.FindFromKey(aE);
+ aKNE=aInfoE.KindOfName();
+ aKCE=aInfoE.KindOfClosed();
+ aKSE=aInfoE.KindOfShape();
+ if (aKNE==GEOMAlgo_KN_CIRCLE && aKCE==GEOMAlgo_KC_CLOSED) {
+ aPC[i]=aInfoE.Location();
+ aR[i]=aInfoE.Radius1();
+ //
+ aIt.Initialize(aE);
+ if (aIt.More()) {
+ aVD=*((TopoDS_Vertex*)&aIt.Value());
+ }
+ aPX[i]=BRep_Tool::Pnt(aVD);
+ //
+ ++i;
+ ++aNbCE;
+ }
+ else if (aKNE==GEOMAlgo_KN_SEGMENT) {
+ if (BRep_Tool::IsClosed(aE, aF)) {
+ ++aNbSE;
+ }
+ }
+ else if (aKSE==GEOMAlgo_KS_DEGENERATED) {
+ aIt.Initialize(aE);
+ if (aIt.More()) {
+ aVD=*((TopoDS_Vertex*)&aIt.Value());
+ }
+ //
+ aPD=BRep_Tool::Pnt(aVD);
+ //
+ ++aNbDE;
}
}
}
- }
- //
- if (!(aNbCE==2 && aNbSE==1)) {
- return;
- }
- //
- const gp_Ax1& aAx1=aCyl.Axis();
- const gp_Dir& aDir=aAx1.Direction();
- const gp_Pnt& aPLoc=aAx1.Location();
- gp_Lin aLin(aPLoc, aDir);
- //
- aT0=ElCLib::Parameter(aLin, aPC[0]);
- aT1=ElCLib::Parameter(aLin, aPC[1]);
- //
- aPc=aPC[0];;
- if (aT0>aT1) {
- aPc=aPC[1];
- }
- aHeight=aPC[0].Distance(aPC[1]);
+ //
+ if ((aNbCE==2 || (aNbCE==1 && aNbDE==1)) && aNbSE==1) {
+ if (aNbDE==1) {
+ aPC[1]=aPD;
+ aR[1]=0.;
+ }
+ //
+ aHeight=aPC[0].Distance(aPC[1]);
+ //
+
+ gp_Ax2 aAx2new;
+ //
+ if (aR[0]>aR[1]) {
+ aRmin=aR[1];
+ aRmax=aR[0];
+ aPc=aPC[0];
+ gp_Vec aVz(aPC[0], aPC[1]);
+ gp_Vec aVx(aPC[0], aPX[0]);
+ gp_Dir aDz(aVz);
+ gp_Dir aDx(aVx);
+ gp_Ax2 aAx2(aPc, aDz, aDx);
+ aAx2new=aAx2;
+ }
+ else {
+ aRmin=aR[0];
+ aRmax=aR[1];
+ aPc=aPC[1];
+ gp_Vec aVz(aPC[1], aPC[0]);
+ gp_Vec aVx(aPC[1], aPX[1]);
+ gp_Dir aDz(aVz);
+ gp_Dir aDx(aVx);
+ gp_Ax2 aAx2(aPc, aDz, aDx);
+ aAx2new=aAx2;
+ }
+ //
+ gp_Ax3 aAx3(aAx2new);
+ aInfo.SetLocation(aPc);
+ aInfo.SetPosition(aAx3);
+ aInfo.SetRadius1(aRmax);
+ aInfo.SetRadius2(aRmin);
+ aInfo.SetHeight(aHeight);
+ //
+ aInfo.SetKindOfDef(GEOMAlgo_KD_SPECIFIED);
+ return;
+ }//if ((aNbCE==2 || (aNbCE==1 && aNbDE==1)) && aNbSE==1) {
+ }//if (aNbV==2 && aNbE==3) {
//
- gp_Ax3 aAx3=aCyl.Position();
- aAx3.SetLocation(aPc);
+ aInfo.SetRadius1 (aCone.RefRadius());
//
- aInfo.SetKindOfName(GEOMAlgo_KN_CYLINDER);
- aInfo.SetPosition(aAx3);
- aInfo.SetLocation(aPc);
- aInfo.SetHeight(aHeight);
+ aRmin=0.; // ZZ
+ aInfo.SetRadius2(aRmin);
}
-
//=======================================================================
//function : FillDetails
//purpose :
void GEOMAlgo_ShapeInfoFiller::FillDetails(const TopoDS_Face& aF,
const gp_Torus& )
{
+
Standard_Integer aNbV, aNbE, aNbSE;
TopoDS_Edge aE;
TopExp_Explorer aExp;
GEOMAlgo_KindOfShape aKS;
//
GEOMAlgo_ShapeInfo& aInfo=myMapInfo.ChangeFromKey(aF);
- aInfo.SetKindOfName(GEOMAlgo_KN_UNKNOWN);
+ aInfo.SetKindOfDef(GEOMAlgo_KD_ARBITRARY);
//
aKS=aInfo.KindOfShape();
if (aKS!=GEOMAlgo_KS_TORUS) {
return;
}
- //
+
aNbV=aInfo.NbSubShapes(TopAbs_VERTEX);
- aNbE=aInfo.NbSubShapes(TopAbs_EDGE);
- if (!(aNbV==1 && aNbE==2)) {
- return;
- }
- //
- aNbSE=0;
- aExp.Init(aF, TopAbs_EDGE);
- for (; aExp.More(); aExp.Next()) {
- aE=TopoDS::Edge(aExp.Current());
- if (aM.Add(aE)) {
- if (BRep_Tool::IsClosed(aE, aF)) {
- ++aNbSE;
+ aNbE=aInfo.NbSubShapes(TopAbs_EDGE);
+
+ if (aNbV==1 && aNbE==2) {
+ aNbSE=0;
+ aExp.Init(aF, TopAbs_EDGE);
+ for (; aExp.More(); aExp.Next()) {
+ aE=TopoDS::Edge(aExp.Current());
+ if (aM.Add(aE)) {
+ if (BRep_Tool::IsClosed(aE, aF)) {
+ ++aNbSE;
+ }
}
}
+ //
+ if (aNbSE==2) {
+ aInfo.SetKindOfDef(GEOMAlgo_KD_SPECIFIED);
+ }
}
- //
- if (aNbSE!=2) {
- return;
- }
- aInfo.SetKindOfName(GEOMAlgo_KN_TORUS);
}
-//modified by NIZNHY-PKV Tue Jul 03 13:29:41 2012f
//=======================================================================
//function : TreatStepSphere
//purpose :
//=======================================================================
-Standard_Boolean
- GEOMAlgo_ShapeInfoFiller::TreatStepSphere(const TopoDS_Solid& aSd)
+Standard_Boolean GEOMAlgo_ShapeInfoFiller::TreatStepSphere
+ (const TopoDS_Solid& aSd)
{
Standard_Boolean bRet, bIsAllowedType, bOnlyClosed, bIsEqual;
Standard_Integer j;
//
return bRet;
}
-//modified by NIZNHY-PKV Tue Jul 03 13:29:43 2012t
const BOPDS_IndexRange& aRange=pDS->Range(iRank);
aRange.Indices(iBeg, iEnd);
const TopoDS_Solid& aSolid=(!iRank) ? *((TopoDS_Solid*)&aTool) : *((TopoDS_Solid*)&aObj);
- BRepClass3d_SolidClassifier& aSC=aCtx->SolidClassifier(aSolid);
+ //BRepClass3d_SolidClassifier& aSC=aCtx->SolidClassifier(aSolid);
//
//------------------------------ShellSolidBuilder
GEOMAlgo_ShellSolidBuilder aSSB;
const TopoDS_Shape& aS=pDS->Shape(i);
aType=aS.ShapeType();
if (aType!=TopAbs_FACE) {
- continue;
+ continue;
}
//
aState=TopAbs_UNKNOWN;
aF=*((TopoDS_Face*)&aS);
//
if (!aImages.IsBound(aS)) {
- iErr=GEOMAlgo_AlgoTools::PntInFace(aF, aP, aP2D);
- if (iErr) {
- myErrorStatus=16;
- return;
- }
- //
- aState=BOPTools_AlgoTools::ComputeState(aP, aSolid, aTol, aCtx);
+ iErr=GEOMAlgo_AlgoTools::PntInFace(aF, aP, aP2D);
+ if (iErr) {
+ myErrorStatus=16;
+ return;
+ }
+ //
+ aState=BOPTools_AlgoTools::ComputeState(aP, aSolid, aTol, aCtx);
}
else {
- const BOPCol_ListOfShape& aLSp=aImages.Find(aS);
- aNbSp=aLSp.Extent();
- if (aNbSp>0) {
- continue;
- }
- //
- if (aNbSp==1) {
- aF=*((TopoDS_Face*)&aLSp.First());
- }
- //
- iErr=GEOMAlgo_AlgoTools::PntInFace(aF, aP, aP2D);
- if (iErr) {
- myErrorStatus=16;
- return;
- }
- //
- aState=BOPTools_AlgoTools::ComputeState(aP, aSolid, aTol, aCtx);
+ const BOPCol_ListOfShape& aLSp=aImages.Find(aS);
+ aNbSp=aLSp.Extent();
+ if (aNbSp>0) {
+ continue;
+ }
+ //
+ if (aNbSp==1) {
+ aF=*((TopoDS_Face*)&aLSp.First());
+ }
+ //
+ iErr=GEOMAlgo_AlgoTools::PntInFace(aF, aP, aP2D);
+ if (iErr) {
+ myErrorStatus=16;
+ return;
+ }
+ //
+ aState=BOPTools_AlgoTools::ComputeState(aP, aSolid, aTol, aCtx);
}
//----------
if (aState==TopAbs_ON) {
- myLSON.Append(aF);
+ myLSON.Append(aF);
}
else if (aState==TopAbs_OUT) {
- myLSOUT.Append(aF);
+ myLSOUT.Append(aF);
}
else if (aState==TopAbs_IN) {
- myLSIN.Append(aF);
- }
+ myLSIN.Append(aF);
+ }
//----------
}//for (i=iBeg; i<=iEnd; ++i) {
TopoDS_Iterator aItC;
//
aLC.Append (aC1);
- while(1) {
+ for(;;) {
aLC1.Clear();
aIt.Initialize(aLC);
for (; aIt.More(); aIt.Next()) {
//function : GetState
//purpose :
//=======================================================================
- Standard_Integer GEOMAlgo_SurfaceTools::GetState(const gp_Pnt& aP,
- const GeomAdaptor_Surface& aGAS,
- const Standard_Real aTol,
- TopAbs_State& aState)
+ Standard_Integer GEOMAlgo_SurfaceTools::GetState
+ (const gp_Pnt& aP,
+ const GeomAdaptor_Surface& aGAS,
+ const Standard_Real aTol,
+ TopAbs_State& aState)
{
Standard_Integer iErr = 0;
GeomAbs_SurfaceType aType = aGAS.GetType();
//function : GetState
//purpose :
//=======================================================================
- Standard_Integer GEOMAlgo_SurfaceTools::GetState(const gp_Pnt& aP,
- const Handle(Geom_Surface)& aSurf,
- const Standard_Real aTol,
- TopAbs_State& aState)
+ Standard_Integer GEOMAlgo_SurfaceTools::GetState
+ (const gp_Pnt& aP,
+ const Handle(Geom_Surface)& aSurf,
+ const Standard_Real aTol,
+ TopAbs_State& aState)
{
Standard_Integer iErr;
GeomAdaptor_Surface aGAS;
//function : ReverseState
//purpose :
//=======================================================================
- TopAbs_State GEOMAlgo_SurfaceTools::ReverseState(const TopAbs_State aState)
+ TopAbs_State GEOMAlgo_SurfaceTools::ReverseState
+ (const TopAbs_State aState)
{
TopAbs_State aRSt=aState;
//
//function : IsCoaxial
//purpose :
//=======================================================================
-Standard_Boolean GEOMAlgo_SurfaceTools::IsCoaxial(const gp_Pnt& aP1,
- const gp_Pnt& aP2,
- const gp_Cylinder& aCyl,
- const Standard_Real aTol)
+Standard_Boolean GEOMAlgo_SurfaceTools::IsCoaxial
+ (const gp_Pnt& aP1,
+ const gp_Pnt& aP2,
+ const gp_Cylinder& aCyl,
+ const Standard_Real aTol)
{
const gp_XYZ &aLoc = aCyl.Location().XYZ();
const gp_Ax1 &aAxis = aCyl.Axis();
gp_XYZ aDP2 = aP2.XYZ().Subtracted(aLoc);
Standard_Real aDot1 = aDP1.Dot(aDAxis);
Standard_Real aDot2 = aDP1.Dot(aDAxis);
- Standard_Real aTol2 = aTol*aTol;
+ //Standard_Real aTol2 = aTol*aTol;
// Project P1 and P2 onto a plane with location aLoc and Norm aDAxis.
aDP1.Subtract(aDAxis.Multiplied(aDot1));
if (fabs(aRadius1 - aRadius2) <= aTol) {
// Check the deflection of the middle point.
gp_XYZ aMidP = 0.5*(aDP1 + aDP2);
- Standard_Real aMidRadius1 = aMidP.Modulus();
+ //Standard_Real aMidRadius1 = aMidP.Modulus();
if (fabs(aRadius1 - aRadius2) <= aTol) {
isOn = Standard_True;
//function : IsAnalytic
//purpose :
//=======================================================================
-Standard_Boolean GEOMAlgo_SurfaceTools::IsAnalytic(const Handle(Geom_Surface)& aSurf)
+Standard_Boolean GEOMAlgo_SurfaceTools::IsAnalytic
+ (const Handle(Geom_Surface)& aSurf)
{
Standard_Boolean bRet;
GeomAbs_SurfaceType aType;
//function : IsConformState
//purpose :
//=======================================================================
-Standard_Boolean GEOMAlgo_SurfaceTools::IsConformState(const TopAbs_State aST1,
- const GEOMAlgo_State aST2)
+Standard_Boolean GEOMAlgo_SurfaceTools::IsConformState
+ (const TopAbs_State aST1,
+ const GEOMAlgo_State aST2)
{
Standard_Boolean bRet=Standard_False;
//
// Function : PublishSubObject
// Purpose : Publish sub-shape under the main object
//================================================================
-void GEOMBase::PublishSubObject( GEOM::GEOM_Object_ptr object )
+void GEOMBase::PublishSubObject( GEOM::GEOM_Object_ptr object, const QString& name )
{
SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
if ( study && !CORBA::is_nil( object ) ) {
GEOM::GEOM_Object_var father = object->GetMainShape();
QString fatherEntry = GetEntry( father );
if ( entry.isEmpty() && !CORBA::is_nil( father ) && !fatherEntry.isEmpty() ) {
- QString name = GetName( object );
+ QString aName = !name.isEmpty() ? name : GetName( object );
GeometryGUI::GetGeomGen()->AddInStudy( GeometryGUI::ClientStudyToStudy( studyDS ),
- object, name.toLatin1().data(), father.in() );
+ object, aName.toLatin1().data(), father.in() );
}
}
}
static QString GetEntry( GEOM::GEOM_Object_ptr object );
/* Publish sub-shape under the main object */
- static void PublishSubObject( GEOM::GEOM_Object_ptr object );
+ static void PublishSubObject( GEOM::GEOM_Object_ptr object, const QString& name = QString() );
static void Synchronize( QList<GEOM::GeomObjPtr>& left, QList<GEOM::GeomObjPtr>& right );
};
GEOMGUI_Selection.h
GEOM_GEOMGUI.hxx
GEOMGUI_CreationInfoWdg.h
+ GEOMGUI_TextTreeWdg.h
GEOMGUI_DimensionProperty.h
)
# header files / to be processed by moc
SET(_moc_HEADERS
GEOMGUI_CreationInfoWdg.h
+ GEOMGUI_TextTreeWdg.h
GeometryGUI.h
)
GEOMGUI_OCCSelector.cxx
GEOMGUI_Selection.cxx
GEOMGUI_CreationInfoWdg.cxx
+ GEOMGUI_TextTreeWdg.cxx
GEOMGUI_DimensionProperty.cxx
${_moc_SOURCES}
${_rcc_SOURCES}
--- /dev/null
+// Copyright (C) 2015 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// File : GEOMGUI_TextTreeWdg.cxx
+// Author : Alexander KOVALEV (akl)
+
+#include "GEOMGUI_TextTreeWdg.h"
+
+#include "GEOMGUI_DimensionProperty.h"
+#include "GeometryGUI.h"
+#include "GeometryGUI_Operations.h"
+#include <GEOM_Constants.h>
+#include <GEOMUtils.hxx>
+
+// GUI includes
+#include <LightApp_Module.h>
+#include <SalomeApp_Application.h>
+#include <SalomeApp_Study.h>
+#include <SUIT_Desktop.h>
+#include <SUIT_Session.h>
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_DataBrowser.h>
+
+// Qt includes
+#include <QAction>
+#include <QMenu>
+#include <QString>
+#include <QLabel>
+#include <QLineEdit>
+#include <QTreeWidget>
+#include <QHeaderView>
+#include <QGroupBox>
+#include <QVBoxLayout>
+#include <QHBoxLayout>
+#include <QHash>
+
+GEOMGUI_TextTreeWdg::GEOMGUI_TextTreeWdg( SalomeApp_Application* app )
+ : myDisplayer(NULL)
+{
+ myStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
+ myDisplayer = GEOM_Displayer( myStudy );
+
+ SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+ myVisibleIcon = QIcon( resMgr->loadPixmap( "SUIT", tr( "ICON_DATAOBJ_VISIBLE" ) ) );
+ myInvisibleIcon = QIcon( resMgr->loadPixmap( "SUIT", tr( "ICON_DATAOBJ_INVISIBLE" ) ) );
+
+ setWindowTitle( tr( "TEXT_TREE_VIEW_TITLE" ) );
+ setObjectName( "geomTextTreeWdg" );
+
+ setRootIsDecorated( true );
+ setSelectionMode( QAbstractItemView::ExtendedSelection );
+ setAllColumnsShowFocus( true );
+ setUniformRowHeights( true );
+
+ QStringList columnNames;
+ columnNames << tr("TEXT_TREE_VIEW_NAME") << "";
+ QTreeWidgetItem * headerItem = new QTreeWidgetItem( columnNames );
+ headerItem->setIcon( 1, myVisibleIcon );
+ setHeaderItem ( headerItem );
+ header()->moveSection( 1, 0 );
+ header()->setResizeMode( 1, QHeaderView::ResizeToContents );
+
+ QStringList rootNames;
+ rootNames << tr("GEOM_DIMENSIONS") << "";
+ myDimensionsItem = new QTreeWidgetItem( this, rootNames );
+ myDimensionsItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
+ addTopLevelItem( myDimensionsItem );
+
+ // get a free dockable window id
+ myWindowID = 11;
+ while( app->dockWindow( myWindowID ))
+ ++myWindowID;
+ ++myWindowID;
+
+ createActions();
+ setContextMenuPolicy( Qt::CustomContextMenu );
+ connect( this, SIGNAL( customContextMenuRequested(const QPoint&) ),
+ this, SLOT( showContextMenu(const QPoint&) ) );
+
+ connect( myStudy, SIGNAL( objVisibilityChanged( QString, Qtx::VisibilityState ) ),
+ this, SLOT( updateVisibilityColumn( QString, Qtx::VisibilityState ) ) );
+ connect( app->objectBrowser(), SIGNAL( updated() ), this, SLOT( updateTree() ) );
+ GeometryGUI* aGeomGUI = dynamic_cast<GeometryGUI*>( app->module( "Geometry" ) );
+ connect( aGeomGUI, SIGNAL( DimensionsUpdated( const QString& ) ), this, SLOT( updateBranch( const QString& ) ) );
+ connect( this, SIGNAL( itemClicked( QTreeWidgetItem*, int) ),
+ this, SLOT( onItemClicked( QTreeWidgetItem*, int ) ) );
+
+}
+
+GEOMGUI_TextTreeWdg::~GEOMGUI_TextTreeWdg()
+{
+ //std::cout<<"~GEOMGUI_TextTreeWdg"<<std::endl;
+}
+
+//=================================================================================
+// function : createActions
+// purpose : Create context popup menu actions.
+//=================================================================================
+void GEOMGUI_TextTreeWdg::createActions()
+{
+ QAction* a = new QAction( tr( "MEN_DISPLAY" ), this );
+ a->setIcon( myVisibleIcon );
+ myActions.insert( GEOMOp::OpShow, a );
+
+ QAction* b = new QAction( tr( "MEN_ERASE" ), this );
+ b->setIcon( myInvisibleIcon );
+ myActions.insert( GEOMOp::OpHide, b );
+}
+
+//=================================================================================
+// function : updateTree
+// purpose :
+//=================================================================================
+void GEOMGUI_TextTreeWdg::updateTree()
+{
+ myStudy = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
+ _PTR(Study) aDSStudy = myStudy->studyDS();
+ if ( aDSStudy ) {
+ _PTR(SComponent) SC ( aDSStudy->FindComponent( "GEOM" ) );
+ if ( SC ) {
+ _PTR(ChildIterator) anIter ( aDSStudy->NewChildIterator( SC ) );
+ anIter->InitEx( true );
+ QList<QString> objEntries = myObjects.keys();
+ while( anIter->More() ) {
+ _PTR(SObject) valSO ( anIter->Value() );
+ _PTR(SObject) refSO;
+ if ( !valSO->ReferencedObject( refSO ) ) {
+ // update tree of object's dimensions
+ QString anEntry = valSO->GetID().c_str();
+ updateBranch( anEntry );
+ objEntries.removeAll( anEntry );
+ }
+ anIter->Next();
+ }
+ foreach (QString entry, objEntries) {
+ removeBranch( entry, true );
+ }
+ }
+ }
+}
+
+//=================================================================================
+// function : updateBranch
+// purpose :
+//=================================================================================
+void GEOMGUI_TextTreeWdg::updateBranch( const QString& theEntry )
+{
+ myStudy = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
+ if ( myStudy ) {
+ _PTR(Study) aStudyDS = myStudy->studyDS();
+ if ( aStudyDS ) {
+ _PTR(SObject) obj( aStudyDS->FindObjectID( theEntry.toStdString() ) );
+ QString aName = obj->GetName().c_str();
+
+ GEOMGUI_DimensionProperty aProp;
+ aProp.LoadFromAttribute( myStudy, theEntry.toStdString() );
+ int nbProps = aProp.GetNumber();
+
+ QTreeWidgetItem* objectItem = itemFromEntry( theEntry );
+ if ( objectItem ) {
+ removeBranch( theEntry, nbProps > 0 ? false : true );
+ }
+ QStringList itemName;
+ if ( nbProps > 0 ) {
+ itemName << aName << "";
+ if ( !objectItem ) {
+ objectItem = new QTreeWidgetItem( myDimensionsItem, itemName );
+ objectItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
+ objectItem->setData( 1, Qt::UserRole, theEntry );
+ myDimensionsItem->addChild( objectItem );
+ myObjects.insert( theEntry, objectItem );
+ if ( myDimensionsItem->childCount() == 1 )
+ myDimensionsItem->setExpanded( true );
+ }
+ bool isDisplayed = myDisplayer.IsDisplayed( theEntry );
+ // read dimension records from property
+ for ( int anIt = 0; anIt < aProp.GetNumber(); ++anIt )
+ {
+ QString aName = aProp.GetName( anIt );
+ bool isVisible = aProp.IsVisible( anIt );
+
+ QTreeWidgetItem* anItem = new QTreeWidgetItem;
+ anItem->setText( 0, aName );
+ // if ( isDisplayed )
+ anItem->setIcon( 1, isVisible ? myVisibleIcon : myInvisibleIcon );
+ anItem->setData( 0, Qt::UserRole, anIt );
+ anItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
+ objectItem->addChild( anItem );
+ }
+ }
+ }
+ }
+}
+
+//=================================================================================
+// function : removeBranch
+// purpose :
+//=================================================================================
+void GEOMGUI_TextTreeWdg::removeBranch( const QString& theEntry, bool force )
+{
+ QTreeWidgetItem* objectItem = itemFromEntry( theEntry );
+ if ( !objectItem )
+ return;
+ qDeleteAll( objectItem->takeChildren() );
+ if ( force ) {
+ myDimensionsItem->removeChild( objectItem );
+ myObjects.remove( theEntry );
+ }
+}
+
+//=================================================================================
+// function : onItemClicked()
+// purpose : called when tree item was clicked
+//=================================================================================
+void GEOMGUI_TextTreeWdg::onItemClicked( QTreeWidgetItem* theItem, int theColumn )
+{
+ if( theColumn != 1 || theItem->icon( 1 ).isNull() || theItem->isDisabled() )
+ return;
+
+ std::string anEntry = entryFromItem( theItem->parent() ).toStdString();
+ int aDimIndex = idFromItem( theItem );
+ GEOMGUI_DimensionProperty aProp;
+ aProp.LoadFromAttribute( myStudy, anEntry );
+ if ( aProp.IsVisible( aDimIndex ) ) {
+ aProp.SetVisible( aDimIndex, false );
+ theItem->setIcon( 1, myInvisibleIcon );
+ } else {
+ aProp.SetVisible( aDimIndex, true );
+ theItem->setIcon( 1, myVisibleIcon );
+ }
+ aProp.SaveToAttribute( myStudy, anEntry );
+ redisplay( anEntry.c_str() );
+}
+
+//=================================================================================
+// function : idFromItem
+// purpose :
+//=================================================================================
+int GEOMGUI_TextTreeWdg::idFromItem( QTreeWidgetItem* theItem )
+{
+ if ( !theItem )
+ return -1;
+
+ bool isIdOK = false;
+ const int anId = theItem->data( 0, Qt::UserRole ).toInt( &isIdOK );
+
+ return isIdOK ? anId : -1;
+}
+
+//=================================================================================
+// function : entryFromItem
+// purpose :
+//=================================================================================
+QString GEOMGUI_TextTreeWdg::entryFromItem( QTreeWidgetItem* theShapeItem )
+{
+ if ( !theShapeItem )
+ return "";
+
+ return theShapeItem->data( 1, Qt::UserRole ).toString();
+}
+
+//=================================================================================
+// function : itemFromEntry
+// purpose :
+//=================================================================================
+QTreeWidgetItem* GEOMGUI_TextTreeWdg::itemFromEntry( QString theEntry )
+{
+ if ( theEntry.isEmpty() )
+ return 0;
+
+ return myObjects.value( theEntry, 0 );
+}
+
+//=================================================================================
+// function : updateVisibilityColumn
+// purpose : Update icons of dimension items.
+//=================================================================================
+void GEOMGUI_TextTreeWdg::updateVisibilityColumn( QString theEntry, Qtx::VisibilityState theState )
+{
+ QTreeWidgetItem* anItem = itemFromEntry( theEntry );
+ if ( !anItem )
+ return;
+ anItem->setDisabled( theState != Qtx::ShownState );
+ QTreeWidgetItem* aChildItem;
+ GEOMGUI_DimensionProperty aProp;
+ for ( int i=0; i < anItem->childCount(); i++ ) {
+ aChildItem = anItem->child( i );
+ if ( theState == Qtx::ShownState ) {
+ aProp.LoadFromAttribute( myStudy, theEntry.toStdString() );
+ if ( aProp.GetNumber() == 0 )
+ continue;
+ aChildItem->setIcon( 1, aProp.IsVisible( idFromItem( aChildItem ) ) ? myVisibleIcon : myInvisibleIcon );
+ aChildItem->setDisabled( false );
+ } else {
+ aChildItem->setIcon( 1, QIcon() );
+ aChildItem->setDisabled( true );
+ }
+ }
+}
+
+//=================================================================================
+// function : showContextMenu
+// purpose :
+//=================================================================================
+void GEOMGUI_TextTreeWdg::showContextMenu( const QPoint& pos )
+{
+ if ( selectedItems().isEmpty() )
+ return;
+ QMenu aMenu;
+ aMenu.addAction( myActions[GEOMOp::OpShow] );
+ aMenu.addAction( myActions[GEOMOp::OpHide] );
+ if ( selectedItems().count() == 1 ) {
+ QTreeWidgetItem* anItem = selectedItems().first();
+ QString anEntry = entryFromItem( anItem->parent() );
+ if ( !anEntry.isEmpty() ) {
+ GEOMGUI_DimensionProperty aProp;
+ aProp.LoadFromAttribute( myStudy, anEntry.toStdString() );
+ if ( aProp.GetNumber() == 0 )
+ return;
+ aMenu.clear();
+ if ( aProp.IsVisible( idFromItem( anItem ) ) )
+ aMenu.addAction( myActions[GEOMOp::OpHide] );
+ else
+ aMenu.addAction( myActions[GEOMOp::OpShow] );
+ }
+ }
+ QAction* selPopupItem = aMenu.exec( viewport()->mapToGlobal(pos) );
+ if ( selPopupItem == myActions[GEOMOp::OpShow] )
+ setVisibility( true );
+ else if ( selPopupItem == myActions[GEOMOp::OpHide] )
+ setVisibility( false );
+}
+
+//=================================================================================
+// function : setVisibility
+// purpose :
+//=================================================================================
+void GEOMGUI_TextTreeWdg::setVisibility( bool theVisibility )
+{
+ if ( myDimensionsItem->isSelected() ) {
+ // set visibility for all dimensions
+ QTreeWidgetItem* anItem;
+ foreach ( QString entry, myObjects.keys() ) {
+ anItem = itemFromEntry( entry );
+ if ( !anItem->isDisabled() )
+ setShapeDimensionsVisibility( entry, theVisibility );
+ }
+ return;
+ }
+ foreach ( QTreeWidgetItem* item, selectedItems() ) {
+ if ( item->isDisabled() || item->parent()->isSelected() )
+ continue;
+ QString anEntry = entryFromItem( item );
+ if ( !anEntry.isEmpty() ) {
+ // it is a shape item
+ setShapeDimensionsVisibility( anEntry, theVisibility );
+ } else {
+ // it is a dimension item
+ anEntry = entryFromItem( item->parent() );
+ setDimensionVisibility( anEntry, item, theVisibility );
+ }
+ }
+}
+
+//=================================================================================
+// function : setShapeDimensionsVisibility
+// purpose :
+//=================================================================================
+void GEOMGUI_TextTreeWdg::setShapeDimensionsVisibility( QString theEntry, bool theVisibility )
+{
+ QTreeWidgetItem* anItem = itemFromEntry( theEntry );
+ QTreeWidgetItem* aChildItem;
+ for ( int i=0; i < anItem->childCount(); i++ ) {
+ aChildItem = anItem->child( i );
+ setDimensionVisibility( theEntry, aChildItem, theVisibility );
+ }
+ redisplay( theEntry );
+}
+
+//=================================================================================
+// function : setDimensionVisibility
+// purpose :
+//=================================================================================
+void GEOMGUI_TextTreeWdg::setDimensionVisibility( QString theEntry, QTreeWidgetItem* theDimItem, bool theVisibility )
+{
+ GEOMGUI_DimensionProperty aProp;
+ aProp.LoadFromAttribute( myStudy, theEntry.toStdString() );
+ int aDimIndex = idFromItem( theDimItem );
+ if ( aProp.GetNumber() == 0 || aProp.IsVisible( aDimIndex ) == theVisibility )
+ return;;
+ aProp.SetVisible( aDimIndex, theVisibility );
+ aProp.SaveToAttribute( myStudy, theEntry.toStdString() );
+
+ theDimItem->setIcon( 1, theVisibility ? myVisibleIcon : myInvisibleIcon );
+ redisplay( theEntry );
+}
+
+//=================================================================================
+// function : redisplay
+// purpose :
+//=================================================================================
+void GEOMGUI_TextTreeWdg::redisplay( QString theEntry )
+{
+ Handle(SALOME_InteractiveObject) io = new SALOME_InteractiveObject( theEntry.toLatin1().constData(), "GEOM", "TEMP_IO" );
+ myDisplayer.Redisplay( io );
+}
--- /dev/null
+// Copyright (C) 2015 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef GEOMGUI_TEXTTREEWDG_H
+#define GEOMGUI_TEXTTREEWDG_H
+
+#include "GEOM_GEOMGUI.hxx"
+#include "GEOM_Displayer.h"
+
+#include <QTreeWidget>
+#include <QHash>
+
+#include <SALOMEDSClient.hxx>
+
+class QLabel;
+class QLineEdit;
+class QString;
+class QTreeWidgetItem;
+class SalomeApp_Application;
+class SalomeApp_Study;
+
+/*!
+ * \brief Tree view contains Dimension and Annotation text items:
+ * - text visibility in OCC viewer
+ * - text object name
+ */
+class GEOMGUI_EXPORT GEOMGUI_TextTreeWdg : public QTreeWidget
+{
+ Q_OBJECT
+
+ public:
+ GEOMGUI_TextTreeWdg( SalomeApp_Application* app );
+ ~GEOMGUI_TextTreeWdg();
+
+ int getWinID() { return myWindowID; }
+
+ void removeBranch( const QString& theEntry,
+ bool force = true );
+ int idFromItem( QTreeWidgetItem* theItem );
+ QString entryFromItem( QTreeWidgetItem* theShapeItem );
+ QTreeWidgetItem* itemFromEntry( QString theEntry );
+ void setShapeDimensionsVisibility( QString theEntry, bool theVisibility );
+ void setDimensionVisibility( QString theEntry, QTreeWidgetItem* theDimItem, bool theVisibility );
+
+protected:
+ void createActions();
+ void redisplay( QString theEntry );
+
+ public slots:
+ void updateTree();
+ void updateBranch( const QString& theEntry );
+
+private slots:
+ void onItemClicked(QTreeWidgetItem*, int );
+ void updateVisibilityColumn( QString theEntry, Qtx::VisibilityState theState );
+ void setVisibility( bool visibility );
+ void showContextMenu( const QPoint& pos );
+
+ private:
+
+ int myWindowID;
+
+ QIcon myVisibleIcon;
+ QIcon myInvisibleIcon;
+ QHash<QString, QTreeWidgetItem*> myObjects;
+ SalomeApp_Study* myStudy;
+ QTreeWidgetItem* myDimensionsItem;
+ GEOM_Displayer myDisplayer;
+
+ QMap<int, QAction*> myActions; //!< menu actions list
+
+};
+#endif
QColor aQColor = aResMgr->colorValue ( "Geometry", "dimensions_color", QColor( 0, 255, 0 ) );
int aLineWidth = aResMgr->integerValue( "Geometry", "dimensions_line_width", 1 );
- double aFontHeight = aResMgr->doubleValue ( "Geometry", "dimensions_font_height", 10 );
+ QFont aFont = aResMgr->fontValue ( "Geometry", "dimensions_font", QFont("Y14.5M-2009", 14) );
double anArrowLength = aResMgr->doubleValue ( "Geometry", "dimensions_arrow_length", 5 );
bool isUnitsShown = aResMgr->booleanValue( "Geometry", "dimensions_show_units", false );
QString aUnitsLength = aResMgr->stringValue ( "Geometry", "dimensions_length_units", "m" );
QString aUnitsAngle = aResMgr->stringValue ( "Geometry", "dimensions_angle_units", "deg" );
+ bool aUseText3d = aResMgr->booleanValue( "Geometry", "dimensions_use_text3d", false );
// restore dimension presentation from saved attribute or property data
AIS_ListOfInteractive aRestoredDimensions;
aStyle->SetCommonColor( aColor );
aStyle->MakeUnitsDisplayed( (Standard_Boolean) isUnitsShown );
- aStyle->MakeText3d( Standard_True );
+ aStyle->MakeText3d( aUseText3d );
aStyle->MakeTextShaded( Standard_True );
- aStyle->SetExtensionSize( aFontHeight * 0.5 );
- aStyle->TextAspect()->SetHeight( aFontHeight );
+ int fsize = aFont.pixelSize() != -1 ? aFont.pixelSize() : aFont.pointSize();
+ aStyle->SetExtensionSize( fsize * 0.5 );
+ aStyle->TextAspect()->SetFont( aFont.family().toLatin1().data() );
+ aStyle->TextAspect()->SetHeight( fsize );
aStyle->ArrowAspect()->SetLength( anArrowLength );
aStyle->LineAspect()->SetWidth( aLineWidth );
aStyle->SetTextHorizontalPosition( aPrs->DimensionAspect()->TextHorizontalPosition() );
<source>GEOM_FAST_CHECK_INTERSECTIONS</source>
<translation>Fast intersection</translation>
</message>
+ <message>
+ <source>GEOM_SHAPE_STATISTICS</source>
+ <translation>Shape Statistics</translation>
+ </message>
<message>
<source>GEOM_CIRCLE</source>
<translation>Circle</translation>
<source>MEN_FAST_CHECK_INTERSECTIONS</source>
<translation>Fast intersection</translation>
</message>
+ <message>
+ <source>MEN_SHAPE_STATISTICS</source>
+ <translation>Shape Statistics</translation>
+ </message>
<message>
<source>MEN_CHECK_FREE_BNDS</source>
<translation>Check Free Boundaries</translation>
</message>
<message>
<source>MEN_MEASURES</source>
- <translation>Measures</translation>
+ <translation>Inspection</translation>
</message>
<message>
<source>MEN_MIN_DIST</source>
<translation>Line width</translation>
</message>
<message>
- <source>PREF_DIMENSIONS_FONT_HEIGHT</source>
- <translation>Font height</translation>
+ <source>PREF_DIMENSIONS_FONT</source>
+ <translation>Font</translation>
</message>
<message>
<source>PREF_DIMENSIONS_ARROW_LENGTH</source>
<source>PREF_DIMENSIONS_SHOW_UNITS</source>
<translation>Show units of measurement</translation>
</message>
+ <message>
+ <source>PREF_DIMENSIONS_USE_TEXT3D</source>
+ <translation>Use 3D text</translation>
+ </message>
<message>
<source>PREF_HIDE_INPUT_OBJECT</source>
<translation>Hide input objects from the viewer</translation>
<message>
<source>STB_FAST_CHECK_INTERSECTIONS</source>
<translation>Fast intersection</translation>
- </message>
+ </message>
<message>
+ <source>STB_SHAPE_STATISTICS</source>
+ <translation>Shape Statistics</translation>
+ </message>
+ <message>
<source>STB_CHECK_FREE_BNDS</source>
<translation>Check free boundaries</translation>
</message>
<source>TOP_FAST_CHECK_INTERSECTIONS</source>
<translation>Fast intersection</translation>
</message>
+ <message>
+ <source>TOP_SHAPE_STATISTICS</source>
+ <translation>Shape Statistics</translation>
+ </message>
<message>
<source>TOP_CHECK_FREE_BNDS</source>
<translation>Check free boundaries</translation>
<source>GEOM_HEALING_STATS_COL_2</source>
<translation>Modification</translation>
</message>
+ <message>
+ <source>GEOM_PLOT_DISTRIBUTION</source>
+ <translation>Plot</translation>
+ </message>
</context>
<context>
<name>GeometryGUI</name>
</message>
<message>
<source>TOOL_MEASURES</source>
- <translation>Measures</translation>
+ <translation>Inspection</translation>
</message>
<message>
<source>TOOL_IMPORTEXPORT</source>
<translation>(No info available)</translation>
</message>
</context>
+<context>
+ <name>GEOMGUI_TextTreeWdg</name>
+ <message>
+ <source>TEXT_TREE_VIEW_TITLE</source>
+ <translation>Text</translation>
+ </message>
+ <message>
+ <source>TEXT_TREE_VIEW_NAME</source>
+ <translation>Name</translation>
+ </message>
+</context>
<context>
<name>EntityGUI_IsolineDlg</name>
<message>
<translation>Objects And Results</translation>
</message>
</context>
+<context>
+ <name>MeasureGUI_ShapeStatisticsDlg</name>
+ <message>
+ <source>GEOM_SHAPE_STATISTICS_TYPE</source>
+ <translation>Type</translation>
+ </message>
+ <message>
+ <source>GEOM_SHAPE_STATISTICS_LENGTH</source>
+ <translation>Edges length</translation>
+ </message>
+ <message>
+ <source>GEOM_SHAPE_STATISTICS_AREA</source>
+ <translation>Faces area</translation>
+ </message>
+ <message>
+ <source>GEOM_SHAPE_STATISTICS_VOLUME</source>
+ <translation>Solids volume</translation>
+ </message>
+ <message>
+ <source>GEOM_SHAPE_STATISTICS_NB_INTERVALS</source>
+ <translation>Number of intervals</translation>
+ </message>
+ <message>
+ <source>GEOM_SHAPE_STATISTICS_SCALAR_RANGE</source>
+ <translation>Scalar range</translation>
+ </message>
+ <message>
+ <source>GEOM_SHAPE_STATISTICS_COMPUTE</source>
+ <translation>Compute</translation>
+ </message>
+ <message>
+ <source>GEOM_SHAPE_STATISTICS_MIN</source>
+ <translation>Min</translation>
+ </message>
+ <message>
+ <source>GEOM_SHAPE_STATISTICS_MAX</source>
+ <translation>Max</translation>
+ </message>
+ <message>
+ <source>GEOM_SHAPE_STATISTICS_CREATE_GROUPS</source>
+ <translation>Create Groups</translation>
+ </message>
+ <message>
+ <source>GEOM_SHAPE_STATISTICS_DISTRIBUTION_NB_ENT</source>
+ <translation>Number of entities</translation>
+ </message>
+ <message>
+ <source>GEOM_SHAPE_STATISTICS_MIN_ERROR</source>
+ <translation>Set minimal range value or switch-off Scalar range</translation>
+ </message>
+ <message>
+ <source>GEOM_SHAPE_STATISTICS_MAX_ERROR</source>
+ <translation>Set maximal range value or switch-off Scalar range</translation>
+ </message>
+ <message>
+ <source>GEOM_SHAPE_STATISTICS_MIN_MAX_ERROR</source>
+ <translation>Minimal range value can not be more than maximal</translation>
+ </message>
+ <message>
+ <source>GEOM_MSG_GROUPS_CREATED</source>
+ <translation>%1 groups created</translation>
+ </message>
+</context>
<context>
<name>TransformationGUI_ExtensionDlg</name>
<message>
<source>GEOM_FAST_CHECK_INTERSECTIONS</source>
<translation>Intersection rapide</translation>
</message>
+ <message>
+ <source>GEOM_SHAPE_STATISTICS</source>
+ <translation type="unfinished">Shape Statistics</translation>
+ </message>
<message>
<source>GEOM_CIRCLE</source>
<translation>Cercle</translation>
<source>MEN_FAST_CHECK_INTERSECTIONS</source>
<translation>Intersection rapide</translation>
</message>
+ <message>
+ <source>MEN_SHAPE_STATISTICS</source>
+ <translation type="unfinished">Shape Statistics</translation>
+ </message>
<message>
<source>MEN_CHECK_FREE_BNDS</source>
<translation>Contrôler les contours libres</translation>
</message>
<message>
<source>MEN_MEASURES</source>
- <translation>Mesures</translation>
+ <translation type="unfinished">Inspection</translation>
</message>
<message>
<source>MEN_MIN_DIST</source>
<translation>Epaisseur de la ligne</translation>
</message>
<message>
- <source>PREF_DIMENSIONS_FONT_HEIGHT</source>
- <translation>Taille de police</translation>
+ <source>PREF_DIMENSIONS_FONT</source>
+ <translation type="unfinished">Font</translation>
</message>
<message>
<source>PREF_DIMENSIONS_ARROW_LENGTH</source>
<source>PREF_DIMENSIONS_SHOW_UNITS</source>
<translation>Afficher les unités</translation>
</message>
+ <message>
+ <source>PREF_DIMENSIONS_USE_TEXT3D</source>
+ <translation type="unfinished">Use 3D text</translation>
+ </message>
<message>
<source>PREF_HIDE_INPUT_OBJECT</source>
<translation>Cacher dans la vue les objets en entrée</translation>
<source>STB_FAST_CHECK_INTERSECTIONS</source>
<translation>Intersection rapide</translation>
</message>
+ <message>
+ <source>STB_SHAPE_STATISTICS</source>
+ <translation type="unfinished">Shape Statistics</translation>
+ </message>
<message>
<source>STB_CHECK_FREE_BNDS</source>
<translation>Vérifier les contours libres</translation>
<source>TOP_FAST_CHECK_INTERSECTIONS</source>
<translation>Intersection rapide</translation>
</message>
+ <message>
+ <source>TOP_SHAPE_STATISTICS</source>
+ <translation type="unfinished">Shape Statistics</translation>
+ </message>
<message>
<source>TOP_CHECK_FREE_BNDS</source>
<translation>Valider les contours libres</translation>
<source>GEOM_HEALING_STATS_COL_2</source>
<translation>Modification</translation>
</message>
+ <message>
+ <source>GEOM_PLOT_DISTRIBUTION</source>
+ <translation type="unfinished">Plot</translation>
+ </message>
</context>
<context>
<name>GeometryGUI</name>
</message>
<message>
<source>TOOL_MEASURES</source>
- <translation>Informations</translation>
+ <translation type="unfinished">Inspection</translation>
</message>
<message>
<source>TOOL_IMPORTEXPORT</source>
<translation>(aucune information disponible)</translation>
</message>
</context>
+<context>
+ <name>GEOMGUI_TextTreeWdg</name>
+ <message>
+ <source>TEXT_TREE_VIEW_TITLE</source>
+ <translation type="unfinished">Text</translation>
+ </message>
+ <message>
+ <source>TEXT_TREE_VIEW_NAME</source>
+ <translation type="unfinished">Name</translation>
+ </message>
+</context>
<context>
<name>EntityGUI_IsolineDlg</name>
<message>
<translation>Objets et résultats</translation>
</message>
</context>
+<context>
+ <name>MeasureGUI_ShapeStatisticsDlg</name>
+ <message>
+ <source>GEOM_SHAPE_STATISTICS_TYPE</source>
+ <translation type="unfinished">Type</translation>
+ </message>
+ <message>
+ <source>GEOM_SHAPE_STATISTICS_LENGTH</source>
+ <translation type="unfinished">Edges length</translation>
+ </message>
+ <message>
+ <source>GEOM_SHAPE_STATISTICS_AREA</source>
+ <translation type="unfinished">Faces area</translation>
+ </message>
+ <message>
+ <source>GEOM_SHAPE_STATISTICS_VOLUME</source>
+ <translation type="unfinished">Solids volume</translation>
+ </message>
+ <message>
+ <source>GEOM_SHAPE_STATISTICS_NB_INTERVALS</source>
+ <translation type="unfinished">Number of intervals</translation>
+ </message>
+ <message>
+ <source>GEOM_SHAPE_STATISTICS_SCALAR_RANGE</source>
+ <translation type="unfinished">Scalar range</translation>
+ </message>
+ <message>
+ <source>GEOM_SHAPE_STATISTICS_COMPUTE</source>
+ <translation type="unfinished">Compute</translation>
+ </message>
+ <message>
+ <source>GEOM_SHAPE_STATISTICS_MIN</source>
+ <translation type="unfinished">Min</translation>
+ </message>
+ <message>
+ <source>GEOM_SHAPE_STATISTICS_MAX</source>
+ <translation type="unfinished">Max</translation>
+ </message>
+ <message>
+ <source>GEOM_SHAPE_STATISTICS_CREATE_GROUPS</source>
+ <translation type="unfinished">Create Groups</translation>
+ </message>
+ <message>
+ <source>GEOM_SHAPE_STATISTICS_DISTRIBUTION_NB_ENT</source>
+ <translation type="unfinished">Number of entities</translation>
+ </message>
+ <message>
+ <source>GEOM_SHAPE_STATISTICS_MIN_ERROR</source>
+ <translation type="unfinished">Set minimal range value or switch-off Scalar range</translation>
+ </message>
+ <message>
+ <source>GEOM_SHAPE_STATISTICS_MAX_ERROR</source>
+ <translation type="unfinished">Set maximal range value or switch-off Scalar range</translation>
+ </message>
+ <message>
+ <source>GEOM_SHAPE_STATISTICS_MIN_MAX_ERROR</source>
+ <translation type="unfinished">Minimal range value can not be more than maximal</translation>
+ </message>
+ <message>
+ <source>GEOM_MSG_GROUPS_CREATED</source>
+ <translation type="unfinished">%1 groups created</translation>
+ </message>
+</context>
<context>
<name>TransformationGUI_ExtensionDlg</name>
<message>
<source>GEOM_FAST_CHECK_INTERSECTIONS</source>
<translation>クイック交点</translation>
</message>
+ <message>
+ <source>GEOM_SHAPE_STATISTICS</source>
+ <translation type="unfinished">Shape Statistics</translation>
+ </message>
+ <message>
+ <source>GEOM_CHECK_SELF_INTERSECTIONS_FAILED</source>
+ <translation>自己交差の検出に失敗しました</translation>
+ </message>
+ <message>
+ <source>GEOM_NO_SELF_INTERSECTIONS</source>
+ <translation>自己交差は検出されませんでした。</translation>
+ </message>
+ <message>
+ <source>GEOM_SELF_INTERSECTIONS_FOUND</source>
+ <translation>自己交差が検出されました。</translation>
+ </message>
+ <message>
+ <source>GEOM_CHECK_SELF_INTERSECTIONS_ERRORS</source>
+ <translation>警告: 操作中にエラーがあったので、リストが不完全かもしれない</translation>
+ </message>
<message>
<source>GEOM_CIRCLE</source>
<translation>Circle</translation>
<source>MEN_FAST_CHECK_INTERSECTIONS</source>
<translation>クイック交点</translation>
</message>
+ <message>
+ <source>MEN_SHAPE_STATISTICS</source>
+ <translation type="unfinished">Shape Statistics</translation>
+ </message>
<message>
<source>MEN_CHECK_FREE_BNDS</source>
<translation>自由境界の確認</translation>
</message>
<message>
<source>MEN_MEASURES</source>
- <translation>計測</translation>
+ <translation type="unfinished">Inspection</translation>
</message>
<message>
<source>MEN_MIN_DIST</source>
<translation>線幅</translation>
</message>
<message>
- <source>PREF_DIMENSIONS_FONT_HEIGHT</source>
- <translation>フォント高さ</translation>
+ <source>PREF_DIMENSIONS_FONT</source>
+ <translation type="unfinished">Font</translation>
</message>
<message>
<source>PREF_DIMENSIONS_ARROW_LENGTH</source>
<source>PREF_DIMENSIONS_SHOW_UNITS</source>
<translation>測定単位の表示</translation>
</message>
+ <message>
+ <source>PREF_DIMENSIONS_USE_TEXT3D</source>
+ <translation type="unfinished">Use 3D text</translation>
+ </message>
<message>
<source>PREF_HIDE_INPUT_OBJECT</source>
<translation>ビューワから入力したオブジェクトの非表示</translation>
<source>STB_FAST_CHECK_INTERSECTIONS</source>
<translation>クイック交点</translation>
</message>
+ <message>
+ <source>STB_SHAPE_STATISTICS</source>
+ <translation type="unfinished">Shape Statistics</translation>
+ </message>
<message>
<source>STB_CHECK_FREE_BNDS</source>
<translation>自由境界をチェック</translation>
<source>TOP_FAST_CHECK_INTERSECTIONS</source>
<translation>クイック交点</translation>
</message>
+ <message>
+ <source>TOP_SHAPE_STATISTICS</source>
+ <translation type="unfinished">Shape Statistics</translation>
+ </message>
<message>
<source>TOP_CHECK_FREE_BNDS</source>
<translation>自由境界を確認</translation>
<source>GEOM_HEALING_STATS_COL_2</source>
<translation>修正</translation>
</message>
+ <message>
+ <source>GEOM_PLOT_DISTRIBUTION</source>
+ <translation type="unfinished">Plot</translation>
+ </message>
</context>
<context>
<name>GeometryGUI</name>
<translation>(有効情報なし)</translation>
</message>
</context>
+ <context>
+ <name>GEOMGUI_TextTreeWdg</name>
+ <message>
+ <source>TEXT_TREE_VIEW_TITLE</source>
+ <translation type="unfinished">Text</translation>
+ </message>
+ <message>
+ <source>TEXT_TREE_VIEW_NAME</source>
+ <translation type="unfinished">Name</translation>
+ </message>
+ </context>
<context>
<name>EntityGUI_IsolineDlg</name>
<message>
<translation>オブジェクトと結果</translation>
</message>
</context>
+ <context>
+ <name>MeasureGUI_ShapeStatisticsDlg</name>
+ <message>
+ <source>GEOM_SHAPE_STATISTICS_TYPE</source>
+ <translation type="unfinished">Type</translation>
+ </message>
+ <message>
+ <source>GEOM_SHAPE_STATISTICS_LENGTH</source>
+ <translation type="unfinished">Edges length</translation>
+ </message>
+ <message>
+ <source>GEOM_SHAPE_STATISTICS_AREA</source>
+ <translation type="unfinished">Faces area</translation>
+ </message>
+ <message>
+ <source>GEOM_SHAPE_STATISTICS_VOLUME</source>
+ <translation type="unfinished">Solids volume</translation>
+ </message>
+ <message>
+ <source>GEOM_SHAPE_STATISTICS_NB_INTERVALS</source>
+ <translation type="unfinished">Number of intervals</translation>
+ </message>
+ <message>
+ <source>GEOM_SHAPE_STATISTICS_SCALAR_RANGE</source>
+ <translation type="unfinished">Scalar range</translation>
+ </message>
+ <message>
+ <source>GEOM_SHAPE_STATISTICS_COMPUTE</source>
+ <translation type="unfinished">Compute</translation>
+ </message>
+ <message>
+ <source>GEOM_SHAPE_STATISTICS_MIN</source>
+ <translation type="unfinished">Min</translation>
+ </message>
+ <message>
+ <source>GEOM_SHAPE_STATISTICS_MAX</source>
+ <translation type="unfinished">Max</translation>
+ </message>
+ <message>
+ <source>GEOM_SHAPE_STATISTICS_CREATE_GROUPS</source>
+ <translation type="unfinished">Create Groups</translation>
+ </message>
+ <message>
+ <source>GEOM_SHAPE_STATISTICS_DISTRIBUTION_NB_ENT</source>
+ <translation type="unfinished">Number of entities</translation>
+ </message>
+ <message>
+ <source>GEOM_SHAPE_STATISTICS_MIN_ERROR</source>
+ <translation type="unfinished">Set minimal range value or switch-off Scalar range</translation>
+ </message>
+ <message>
+ <source>GEOM_SHAPE_STATISTICS_MAX_ERROR</source>
+ <translation type="unfinished">Set maximal range value or switch-off Scalar range</translation>
+ </message>
+ <message>
+ <source>GEOM_SHAPE_STATISTICS_MIN_MAX_ERROR</source>
+ <translation type="unfinished">Minimal range value can not be more than maximal</translation>
+ </message>
+ <message>
+ <source>GEOM_MSG_GROUPS_CREATED</source>
+ <translation type="unfinished">%1 groups created</translation>
+ </message>
+ </context>
<context>
<name>TransformationGUI_ExtensionDlg</name>
<message>
#include "GEOMGUI_OCCSelector.h"
#include "GEOMGUI_Selection.h"
#include "GEOMGUI_CreationInfoWdg.h"
+#include "GEOMGUI_TextTreeWdg.h"
#include "GEOMGUI_DimensionProperty.h"
#include "GEOM_Constants.h"
#include "GEOM_Displayer.h"
#include <SALOMEDS_SObject.hxx>
#include <Basics_OCCTVersion.hxx>
+#include <QtxFontEdit.h>
// External includes
#include <QDir>
#include <QString>
#include <QPainter>
#include <QSignalMapper>
+#include <QFontDatabase>
#include <AIS_ListOfInteractive.hxx>
#include <AIS_ListIteratorOfListOfInteractive.hxx>
#include <NCollection_DataMap.hxx>
#include <TColStd_HArray1OfByte.hxx>
+#include <TColStd_SequenceOfHAsciiString.hxx>
#include <utilities.h>
#include <Standard_Failure.hxx>
#include <Standard_ErrorHandler.hxx>
+#include <Font_SystemFont.hxx>
+#include <Font_FontMgr.hxx>
+#include <TCollection_HAsciiString.hxx>
+
#include "GEOM_version.h"
#include "GEOMImpl_Types.hxx" // dangerous hxx (defines short-name macros) - include after all
myLocalSelectionMode = GEOM_ALLOBJECTS;
myCreationInfoWdg = 0;
+ myTextTreeWdg = 0;
connect( Material_ResourceMgr::resourceMgr(), SIGNAL( changed() ), this, SLOT( updateMaterials() ) );
case GEOMOp::OpCheckSelfInters: // MENU MEASURE - CHECK SELF INTERSECTIONS
case GEOMOp::OpFastCheckInters: // MENU MEASURE - FAST CHECK INTERSECTIONS
case GEOMOp::OpManageDimensions: // MENU MEASURE - MANAGE DIMENSIONS
+ case GEOMOp::OpShapeStatistics: // MENU MEASURE - SHAPE STATISTICS
case GEOMOp::OpShowAllDimensions: // POPUP MENU - SHOW ALL DIMENSIONS
case GEOMOp::OpHideAllDimensions: // POPUP MENU - HIDE ALL DIMENSIONS
libName = "MeasureGUI";
createGeomAction( GEOMOp::OpGetNonBlocks, "GET_NON_BLOCKS" );
createGeomAction( GEOMOp::OpCheckSelfInters, "CHECK_SELF_INTERSECTIONS" );
createGeomAction( GEOMOp::OpFastCheckInters, "FAST_CHECK_INTERSECTIONS" );
+ createGeomAction( GEOMOp::OpShapeStatistics, "SHAPE_STATISTICS" );
#ifdef _DEBUG_ // PAL16821
createGeomAction( GEOMOp::OpCheckGeom, "CHECK_GEOMETRY" );
createMenu( GEOMOp::OpCheckSelfInters, measurId, -1 );
createMenu( GEOMOp::OpFastCheckInters, measurId, -1 );
createMenu( GEOMOp::OpInspectObj, measurId, -1 );
+ createMenu( GEOMOp::OpShapeStatistics, measurId, -1 );
int toolsId = createMenu( tr( "MEN_TOOLS" ), -1, -1, 50 );
#if defined(_DEBUG_) || defined(_DEBUG) // PAL16821
getApp()->insertDockWindow( myCreationInfoWdg->getWinID(), myCreationInfoWdg );
getApp()->placeDockWindow( myCreationInfoWdg->getWinID(), Qt::LeftDockWidgetArea );
+ if ( !myTextTreeWdg )
+ myTextTreeWdg = new GEOMGUI_TextTreeWdg( getApp() );
+ getApp()->insertDockWindow( myTextTreeWdg->getWinID(), myTextTreeWdg );
+ getApp()->placeDockWindow( myTextTreeWdg->getWinID(), Qt::LeftDockWidgetArea );
+
//NPAL 19674
SALOME_ListIO selected;
sm->selectedObjects( selected );
disconnect( selMrg, SIGNAL( currentSelectionChanged() ), this, SLOT( updateCreationInfo() ));
disconnect( selMrg, SIGNAL( currentSelectionChanged() ), this, SLOT( updateFieldColorScale() ));
- getApp()->removeDockWindow( myCreationInfoWdg->getWinID() );
- myCreationInfoWdg = 0;
+ if ( myCreationInfoWdg ) {
+ getApp()->removeDockWindow( myCreationInfoWdg->getWinID() );
+ myCreationInfoWdg = 0;
+ }
+ if ( myTextTreeWdg ) {
+ getApp()->removeDockWindow( myTextTreeWdg->getWinID() );
+ disconnect( application(), 0, myTextTreeWdg, 0 );
+ myTextTreeWdg = 0;
+ }
EmitSignalCloseAllDialogs();
mappa.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
if ( myCreationInfoWdg )
mappa.insert( myCreationInfoWdg->getWinID(), Qt::LeftDockWidgetArea );
+ if ( myTextTreeWdg )
+ mappa.insert( myTextTreeWdg->getWinID(), Qt::LeftDockWidgetArea );
}
void GeometryGUI::viewManagers( QStringList& lst ) const
void GeometryGUI::createPreferences()
{
+ SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+
int tabId = addPreference( tr( "PREF_TAB_SETTINGS" ) );
int genGroup = addPreference( tr( "PREF_GROUP_GENERAL" ), tabId );
setPreferenceProperty( aDimLineWidthId, "min", 1 );
setPreferenceProperty( aDimLineWidthId, "max", 5 );
- int aDimFontHeightId = addPreference( tr( "PREF_DIMENSIONS_FONT_HEIGHT" ), aDimGroupId,
- LightApp_Preferences::DblSpin, "Geometry", "dimensions_font_height" );
-
- setPreferenceProperty( aDimFontHeightId, "min", 1e-9 );
- setPreferenceProperty( aDimFontHeightId, "max", 1e+9 );
- setPreferenceProperty( aDimFontHeightId, "precision", 9 );
+ int aDimFontId = addPreference( tr( "PREF_DIMENSIONS_FONT" ), aDimGroupId, LightApp_Preferences::Font, "Geometry", "dimensions_font" );
+
+ int f = QtxFontEdit::Family | QtxFontEdit::Size;
+ setPreferenceProperty( aDimFontId, "features", f );
+ setPreferenceProperty( aDimFontId, "mode", QtxFontEdit::Custom );
+
+ Handle(Font_FontMgr) fmgr = Font_FontMgr::GetInstance();
+ QString aFontFile = "";
+ resMgr->value("resources", "GEOM", aFontFile);
+ aFontFile = aFontFile + QDir::separator() + "Y14.5M-2009.ttf";
+ // add enginier font into combobox
+ int fontID = QFontDatabase::addApplicationFont( aFontFile );
+ Handle(Font_SystemFont) sf = new Font_SystemFont(
+ new TCollection_HAsciiString("Y14.5M-2009"),
+ Font_FA_Regular,
+ new TCollection_HAsciiString(aFontFile.toLatin1().data()) );
+ // register font in OCC font manager
+ fmgr->RegisterFont( sf, Standard_False );
+
+ // get list of supported fonts by OCC
+ QStringList anOCCFonts;
+ TColStd_SequenceOfHAsciiString theFontsNames;
+ fmgr->GetAvailableFontsNames( theFontsNames );
+ for(Standard_Integer i=1; i<=theFontsNames.Length(); i++) {
+ Handle(TCollection_HAsciiString) str = theFontsNames(i);
+ anOCCFonts << str->ToCString();
+ }
+ anOCCFonts.removeDuplicates();
+ // set the supported fonts into combobox to use its only
+ setPreferenceProperty( aDimFontId, "fonts", anOCCFonts );
int aDimArrLengthId = addPreference( tr( "PREF_DIMENSIONS_ARROW_LENGTH" ), aDimGroupId,
LightApp_Preferences::DblSpin, "Geometry", "dimensions_arrow_length" );
int anAngUnitsId = addPreference( tr( "PREF_DIMENSIONS_ANGLE_UNITS" ), aDimGroupId,
LightApp_Preferences::Selector, "Geometry", "dimensions_angle_units" );
- addPreference( tr( "PREF_DIMENSIONS_SHOW_UNITS" ), aDimGroupId,
- LightApp_Preferences::Bool, "Geometry", "dimensions_show_units" );
-
QStringList aListOfLengthUnits;
aListOfLengthUnits << "m";
aListOfLengthUnits << "cm";
setPreferenceProperty( aLengthUnitsId, "strings", aListOfLengthUnits );
setPreferenceProperty( anAngUnitsId, "strings", aListOfAngUnits );
+ addPreference( tr( "PREF_DIMENSIONS_SHOW_UNITS" ), aDimGroupId,
+ LightApp_Preferences::Bool, "Geometry", "dimensions_show_units" );
+
int aDimDefFlyout = addPreference( tr( "PREF_DIMENSIONS_DEFAULT_FLYOUT" ), aDimGroupId,
LightApp_Preferences::DblSpin, "Geometry", "dimensions_default_flyout" );
setPreferenceProperty( aDimDefFlyout, "max", 1e+9 );
setPreferenceProperty( aDimDefFlyout, "precision", 9 );
+ addPreference( tr( "PREF_DIMENSIONS_USE_TEXT3D" ), aDimGroupId,
+ LightApp_Preferences::Bool, "Geometry", "dimensions_use_text3d" );
+
int isoGroup = addPreference( tr( "PREF_ISOS" ), tabId );
setPreferenceProperty( isoGroup, "columns", 2 );
int isoU = addPreference( tr( "PREF_ISOS_U" ), isoGroup,
QList<QVariant> aMarkerTypeIndicesList;
QList<QVariant> aMarkerTypeIconsList;
- SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
for ( int i = GEOM::MT_POINT; i < GEOM::MT_USER; i++ ) {
QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
QPixmap pixmap = resMgr->loadPixmap( "GEOM", tr( qPrintable( icoFile ) ) );
}
else if ( param == QString("dimensions_color") ||
param == QString("dimensions_line_width") ||
- param == QString("dimensions_font_height") ||
+ param == QString("dimensions_font") ||
param == QString("dimensions_arrow_length") ||
param == QString("dimensions_show_units") ||
param == QString("dimensions_length_units") ||
param == QString("dimensions_angle_units") ||
+ param == QString("dimensions_use_text3d") ||
param == QString("label_color") )
{
SalomeApp_Application* anApp = getApp();
// update Object browser
getApp()->updateObjectBrowser( false );
}
+
+void GeometryGUI::emitDimensionsUpdated( QString entry )
+{
+ emit DimensionsUpdated( entry );
+}
class SUIT_ViewManager;
class SalomeApp_Study;
class GEOMGUI_CreationInfoWdg;
+class GEOMGUI_TextTreeWdg;
//=================================================================================
// class : GeometryGUI
SUIT_DataObject* where,
const int row, Qt::DropAction action );
+ void emitDimensionsUpdated( QString entry );
+
public slots:
virtual bool deactivateModule( SUIT_Study* );
virtual bool activateModule( SUIT_Study* );
void SignalDefaultStepValueChanged( double newVal );
void SignalDependencyTreeParamChanged( const QString&, const QString& );
void SignalDependencyTreeRenameObject( const QString& );
+ void DimensionsUpdated( const QString& );
protected:
virtual LightApp_Selection* createSelection() const;
GEOMGUI_CreationInfoWdg* myCreationInfoWdg;
+ GEOMGUI_TextTreeWdg* myTextTreeWdg;
+
SALOME_ListIO myTopLevelIOList;
friend class DisplayGUI;
OpHideAllDimensions = 5016, // POPUP MENU - HIDE ALL DIMENSIONS
OpFastCheckInters = 5017, // MENU MEASURES - FAST CHECK INTERSECTIONS
OpInspectObj = 5018, // MENU MEASURES - INSPECT OBJECT
+ OpShapeStatistics = 5019, // MENU MEASURES - SHAPE STATISTICS
// GroupGUI --------------------//--------------------------------
OpGroupCreate = 6000, // MENU GROUP - CREATE
OpGroupEdit = 6001, // MENU GROUP - EDIT
return NULL; //There is no function which creates an object to be processed
// Add a new object
- Handle(GEOM_Object) aNewObject = GetEngine()->AddObject(GetDocID(), theObject->GetType());
+ Handle(GEOM_Object) aNewObject = GetEngine()->AddObject(GetDocID(), GEOM_COPY);
if (theObject->GetType() == GEOM_VECTOR) { // Mantis issue 21066
//Add the function
if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
//Add a new Copy object
- Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
+ Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_COPY);
//Add a translate function
Handle(GEOM_Function) aFunction =
if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
//Add a new Copy object
- Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
+ Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_COPY);
//Add a translate function
Handle(GEOM_Function) aFunction =
if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
//Add a new Copy object
- Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
+ Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_COPY);
//Add a translate function
Handle(GEOM_Function) aFunction =
if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
//Add a new Copy object
- Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
+ Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_COPY);
//Add a mirror function
Handle(GEOM_Function) aFunction =
if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
//Add a new Copy object
- Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
+ Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_COPY);
//Add a mirror function
Handle(GEOM_Function) aFunction =
if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
//Add a new Copy object
- Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
+ Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_COPY);
//Add a mirror function
Handle(GEOM_Function) aFunction =
if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be offset
//Add a new Copy object
- Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
+ Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_COPY);
//Add a new Offset function
Handle(GEOM_Function) aFunction =
if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be scaled
//Add a new Copy object
- Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
+ Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_COPY);
//Add a scale function
Handle(GEOM_Function) aFunction =
if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position
//Add a new Copy object
- Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
+ Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_COPY);
//Add a position function
Standard_Integer aType = POSITION_SHAPE_COPY;
if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
//Add a new Copy object
- Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
+ Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_COPY);
//Add a rotate function
aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_COPY);
if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
//Add a new Copy object
- Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
+ Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_COPY);
//Add a rotate function
aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_THREE_POINTS_COPY);
if (aSampleFunc.IsNull()) return NULL; // There is no function which creates a sample object
// Add a new Copy object
- Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
+ Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_COPY);
// Add a transform function (depends on theSample function)
Handle(GEOM_Function) aFunction =
GEOMUtils.hxx
GEOMUtils_Hatcher.hxx
GEOMUtils_HTrsfCurve2d.hxx
+ GEOMUtils_ShapeStatistics.hxx
GEOMUtils_Trsf2d.hxx
GEOMUtils_TrsfCurve2d.hxx
GEOMUtils_XmlHandler.hxx
GEOMUtils.cxx
GEOMUtils_Hatcher.cxx
GEOMUtils_HTrsfCurve2d.cxx
+ GEOMUtils_ShapeStatistics.cxx
GEOMUtils_Trsf2d.cxx
GEOMUtils_TrsfCurve2d.cxx
GEOMUtils_XmlHandler.cxx
--- /dev/null
+// Copyright (C) 2015 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// File : GEOMUtils_ShapeStatisticsDlg.cxx
+// Author : Alexander KOVALEV, OPEN CASCADE S.A.S.
+
+#include "GEOMUtils_ShapeStatistics.hxx"
+
+#include <BRepGProp.hxx>
+#include <GProp_GProps.hxx>
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+
+namespace GEOMUtils
+{
+//=================================================================================
+// function : ComputeMeasures()
+// purpose : gets measures of the given type for list of shapes in the range
+//=================================================================================
+ std::map<int,double> ComputeMeasures( std::list<TopoDS_Shape> shapes,
+ TopAbs_ShapeEnum entity,
+ Range &range)
+{
+ bool hasRange = (range.min != -1.0); // -1.0 means that range must not be used
+ if ( !hasRange )
+ range.min = 1e+32, range.max = 0.0;
+ // list of measures of entities
+ std::map<int, double> measures;
+
+ std::list<TopoDS_Shape>::const_iterator it;
+ int shift = 0;
+ for ( it = shapes.begin(); it != shapes.end(); ++it ) {
+ double aMeasure;
+ TopTools_IndexedMapOfShape aSubShapesMap;
+ TopExp::MapShapes(*it, aSubShapesMap); // map of all global indices
+ TopTools_IndexedMapOfShape aMx;
+ TopExp::MapShapes( *it, entity, aMx ); // map of current type sub-shape indices
+ int aNbS = aMx.Extent();
+ int index = -1;
+ for ( int i = 1; i <= aNbS; ++i ) {
+ aMeasure = 0.0;
+ const TopoDS_Shape& aSubShape = aMx( i );
+ //Get the measure: length, area or volume
+ GProp_GProps LProps, SProps, VProps;
+ if ( entity == TopAbs_EDGE ) {
+ BRepGProp::LinearProperties( aSubShape, LProps );
+ aMeasure = LProps.Mass();
+ } else if ( entity == TopAbs_FACE ) {
+ BRepGProp::SurfaceProperties( aSubShape, SProps );
+ aMeasure = SProps.Mass();
+ } else if ( entity == TopAbs_SOLID ) {
+ BRepGProp::VolumeProperties( aSubShape, VProps );
+ aMeasure = VProps.Mass();
+ }
+ // Don't pass sub-shapes with out of range measure, if range is used
+ if ( hasRange ) {
+ if ( aMeasure < range.min || aMeasure > range.max )
+ continue;
+ } else {
+ // get range min and max
+ if ( aMeasure < range.min ) range.min = aMeasure;
+ if ( aMeasure > range.max ) range.max = aMeasure;
+ }
+ // get global index of sub-shape
+ index = aSubShapesMap.FindIndex( aSubShape );
+ // keep measures to distribute it
+ measures[shift+index] = aMeasure;
+ }
+ shift += aSubShapesMap.Extent();
+ }
+ return measures;
+}
+
+//=================================================================================
+// function : ComputeDistribution()
+// purpose : gets distribution data for single shape
+//=================================================================================
+Distribution ComputeDistribution( TopoDS_Shape shape,
+ TopAbs_ShapeEnum entity,
+ int intervals,
+ Range range)
+{
+ std::list<TopoDS_Shape> aShapes;
+ aShapes.push_back( shape );
+ return ComputeDistribution( aShapes, entity, intervals, range );
+}
+
+//=================================================================================
+// function : ComputeDistribution()
+// purpose : gets distribution data for list of shapes
+//=================================================================================
+Distribution ComputeDistribution( std::list<TopoDS_Shape> shapes,
+ TopAbs_ShapeEnum entity,
+ int nbIntervals,
+ Range range)
+{
+ // get list of measures and compute range (if it was not specified)
+ std::map<int,double> measures = ComputeMeasures( shapes, entity, range );
+
+ // compute a step
+ double aStep = (range.max - range.min) / nbIntervals;
+
+ // compute distribution in intervals
+ Distribution aDistr;
+ std::map<int,double>::iterator dit;
+ for ( int i = 0; i < nbIntervals; i++ ) {
+ Range localRange; // range of current interval
+ localRange.min = range.min + ( i * aStep );
+ localRange.max = range.min + ( (i+1) * aStep );
+ localRange.count = 0;
+
+ std::vector<int> indicesToErase;
+ for ( dit = measures.begin(); dit != measures.end(); dit++ ) {
+ if ( ( dit->second >= localRange.min && dit->second < localRange.max ) ||
+ ( i == nbIntervals-1 && dit->second == localRange.max ) ) {
+ localRange.count++;
+ localRange.indices.push_back( dit->first );
+ // measure is in interval, so remove it from map of search
+ indicesToErase.push_back( dit->first );
+ }
+ }
+ aDistr.push_back( localRange );
+ for( int j=0; j < indicesToErase.size(); j++ )
+ measures.erase( indicesToErase[j] );
+ }
+
+ return aDistr;
+}
+
+} //namespace GEOMUtils
--- /dev/null
+// Copyright (C) 2015 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// File : GEOMUtils_ShapeStatisticsDlg.hxx
+// Author : Alexander KOVALEV, OPEN CASCADE S.A.S.
+
+#ifndef _GEOMUtils_ShapeStatistics_HXX_
+#define _GEOMUtils_ShapeStatistics_HXX_
+
+#include <list>
+#include <map>
+#include <vector>
+
+#include <TopoDS_Shape.hxx>
+
+namespace GEOMUtils
+{
+ // struct to store range data
+ typedef struct { double min; double max; long count; std::list<long> indices; } Range;
+ // distribution is a set of ranges
+ typedef std::vector<Range> Distribution;
+
+ // function to get measures of entities and compute range for list of shapes
+ Standard_EXPORT std::map<int,double> ComputeMeasures(
+ std::list<TopoDS_Shape> shapes,
+ TopAbs_ShapeEnum entity,
+ Range &range );
+
+ // function to get distribution data for single shape
+ Standard_EXPORT Distribution ComputeDistribution(
+ TopoDS_Shape shape,
+ TopAbs_ShapeEnum entity,
+ int intervals,
+ Range range );
+
+ // function to get distribution data for list of shapes
+ Standard_EXPORT Distribution ComputeDistribution(
+ std::list<TopoDS_Shape> shapes,
+ TopAbs_ShapeEnum entity,
+ int intervals,
+ Range range );
+
+}
+
+#endif // _GEOMUtils_ShapeStatistics_HXX_
${PROJECT_SOURCE_DIR}/src/GEOMImpl
${PROJECT_SOURCE_DIR}/src/GEOMGUI
${PROJECT_SOURCE_DIR}/src/GEOMBase
+ ${PROJECT_SOURCE_DIR}/src/MeasureGUI
${PROJECT_SOURCE_DIR}/src/DlgRef
${PROJECT_BINARY_DIR}/src/DlgRef
${CMAKE_CURRENT_SOURCE_DIR}
SET(_link_LIBRARIES
GEOMBase
GEOMUtils
+ MeasureGUI
)
# --- resources ---
#include <GeometryGUI.h>
#include <GEOM_Displayer.h>
#include <GEOMUtils.hxx>
+#include <MeasureGUI_ShapeStatisticsDlg.h>
#include <SalomeApp_Application.h>
#include <SalomeApp_Study.h>
myLessFilterSpin = new SalomeApp_DoubleSpinBox(myFilterGrp);
myGreaterFilterSpin = new SalomeApp_DoubleSpinBox(myFilterGrp);
myApplyFilterButton = new QPushButton(tr("GEOM_BUT_APPLY"), myFilterGrp);
+ myPlotDistributionButton = new QPushButton(tr("GEOM_PLOT_DISTRIBUTION"), myFilterGrp);
QGridLayout* filterLayout = new QGridLayout(myFilterGrp);
filterLayout->addWidget(myLessFilterCheck, 0, 0);
filterLayout->addWidget(myGreaterFilterCombo, 1, 1);
filterLayout->addWidget(myGreaterFilterSpin, 1, 2);
filterLayout->addWidget(myApplyFilterButton, 0, 3);
+ filterLayout->addWidget(myPlotDistributionButton, 1, 3);
QVBoxLayout* layout = new QVBoxLayout(centralWidget());
layout->setMargin(0); layout->setSpacing(6);
connect(myIdList, SIGNAL(itemSelectionChanged()), this, SLOT(selectionChanged()));
connect(myApplyFilterButton, SIGNAL(clicked()), this, SLOT(ClickOnOkFilter()));
+ connect(myPlotDistributionButton, SIGNAL(clicked()), this, SLOT(ClickOnPlot()));
connect(myLessFilterCheck, SIGNAL(stateChanged(int)), this, SLOT(MeasureToggled()));
connect(myGreaterFilterCheck, SIGNAL(stateChanged(int)), this, SLOT(MeasureToggled()));
subSelectionWay() == ALL_SUBSHAPES &&
myIsShapeType &&
getShapeType() != TopAbs_VERTEX);
+ // manage of 'Plot' button access
+ GEOM::GEOM_IShapesOperations_var aShOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
+ GEOM::ListOfLong_var aSubShapes = aShOp->SubShapeAllIDs( myMainObj, getShapeType(), false );
+ bool hasCurrentEntities = aSubShapes->length() > 0;
+ myPlotDistributionButton->setEnabled( myFilterGrp->isEnabled() &&
+ myIsShapeType &&
+ ( getShapeType() == TopAbs_EDGE ||
+ getShapeType() == TopAbs_FACE ||
+ getShapeType() == TopAbs_SOLID ) &&
+ hasCurrentEntities );
if (subSelectionWay() == ALL_SUBSHAPES)
setInPlaceObj(GEOM::GEOM_Object::_nil());
}
updateState(true);
}
+//=================================================================================
+// function : ClickOnPlot()
+// purpose : opens "Shape Statistics" dialog box in order to plot sub-shapes distribution.
+//=================================================================================
+void GroupGUI_GroupDlg::ClickOnPlot()
+{
+ TopoDS_Shape aMainShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), myMainObj);
+ QDialog* dlg = new MeasureGUI_ShapeStatisticsDlg( this, aMainShape, getShapeType() );
+ if ( dlg ) {
+ dlg->show();
+ }
+}
+
void GroupGUI_GroupDlg::MeasureToggled()
{
myLessFilterSpin->setEnabled(myLessFilterCheck->isChecked());
void showOnlySelected();
void selectionChanged();
void ClickOnOkFilter();
+ void ClickOnPlot();
void MeasureToggled();
private:
SalomeApp_DoubleSpinBox* myLessFilterSpin;
SalomeApp_DoubleSpinBox* myGreaterFilterSpin;
QPushButton* myApplyFilterButton;
+ QPushButton* myPlotDistributionButton;
QGroupBox* myFilterGrp;
};
MeasureGUI_ManageDimensionsDlg.h
MeasureGUI_CreateDimensionDlg.h
MeasureGUI_DimensionInteractor.h
+ MeasureGUI_ShapeStatisticsDlg.h
)
# header files / uic wrappings
MeasureGUI_DimensionCreateTool.cxx
MeasureGUI_DimensionInteractor.cxx
MeasureGUI_DimensionFilter.cxx
+ MeasureGUI_ShapeStatisticsDlg.cxx
${_moc_SOURCES}
${_uic_files}
)
#include "MeasureGUI_FastCheckIntersectionsDlg.h" // Method FAST CHECK INTERSCTIONS
#include "MeasureGUI_PointDlg.h" // Method POINTCOORDINATES
#include "MeasureGUI_ManageDimensionsDlg.h" // Method MANAGEDIMENSIONS
+#include "MeasureGUI_ShapeStatisticsDlg.h" // Method SHAPE STATISTICS
#include <QApplication>
case GEOMOp::OpFastCheckInters:
dlg = new MeasureGUI_FastCheckIntersectionsDlg( getGeometryGUI(), parent );
break; // FAST CHECK INTERSCTIONS
+ case GEOMOp::OpShapeStatistics:
+ dlg = new MeasureGUI_ShapeStatisticsDlg( parent );
+ break; // FAST CHECK INTERSCTIONS
case GEOMOp::OpPointCoordinates:
dlg = new MeasureGUI_PointDlg( getGeometryGUI(), parent );
break; // POINT COORDINATES
QColor aQColor = aResMgr->colorValue ( "Geometry", "dimensions_color", QColor( 0, 255, 0 ) );
int aLineWidth = aResMgr->integerValue( "Geometry", "dimensions_line_width", 1 );
- double aFontHeight = aResMgr->doubleValue ( "Geometry", "dimensions_font_height", 10 );
+ QFont aFont = aResMgr->fontValue ( "Geometry", "dimensions_font", QFont("Y14.5M-2009", 14) );
double anArrowLength = aResMgr->doubleValue ( "Geometry", "dimensions_arrow_length", 5 );
double aDefFlyout = aResMgr->doubleValue ( "Geometry", "dimensions_default_flyout", 20 );
bool isUnitsShown = aResMgr->booleanValue( "Geometry", "dimensions_show_units", false );
QString aUnitsLength = aResMgr->stringValue ( "Geometry", "dimensions_length_units", "m" );
QString aUnitsAngle = aResMgr->stringValue ( "Geometry", "dimensions_angle_units", "deg" );
+ bool aUseText3d = aResMgr->booleanValue( "Geometry", "dimensions_use_text3d", false );
OCCViewer_ViewWindow* anActiveView = NULL;
aStyle->SetCommonColor( aColor );
aStyle->MakeUnitsDisplayed( (Standard_Boolean) isUnitsShown );
- aStyle->MakeText3d( Standard_True );
+ aStyle->MakeText3d( aUseText3d );
aStyle->MakeTextShaded( Standard_True );
- aStyle->SetExtensionSize( aFontHeight * 0.5 );
- aStyle->TextAspect()->SetHeight( aFontHeight );
+ int fsize = aFont.pixelSize() != -1 ? aFont.pixelSize() : aFont.pointSize();
+ aStyle->SetExtensionSize( fsize * 0.5 );
+ aStyle->TextAspect()->SetFont( aFont.family().toLatin1().data() );
+ aStyle->TextAspect()->SetHeight( fsize );
aStyle->ArrowAspect()->SetLength( anArrowLength );
aStyle->LineAspect()->SetWidth( aLineWidth );
#include "MeasureGUI_DimensionFilter.h"
#include <GEOMGUI_DimensionProperty.h>
+#include <GEOMGUI_TextTreeWdg.h>
#include <GEOMUtils.hxx>
#include <GEOMGUI_OCCSelector.h>
#include <GEOM_AISDimension.hxx>
mySavedPropertyState.SaveToAttribute( aStudy, myEditObject->GetStudyEntry() );
+ myGeomGUI->emitDimensionsUpdated( QString( myEditObject->GetStudyEntry() ) );
+
return true;
}
myEditObject->GetStudyEntry(),
GEOM::propertyName( GEOM::Dimensions ),
QVariant() );
+
if ( myIsNeedRedisplay ) {
- redisplay( myEditObject.get());
+ redisplay( myEditObject.get() );
}
+
+ myGeomGUI->emitDimensionsUpdated( QString( myEditObject->GetStudyEntry() ) );
}
//=================================================================================
--- /dev/null
+// Copyright (C) 2015 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// File : MeasureGUI_ShapeStatisticsDlg.cxx
+// Author : Alexander KOVALEV, OPEN CASCADE S.A.S.
+
+// internal includes
+#include "MeasureGUI_ShapeStatisticsDlg.h"
+
+// GEOM includes
+#include <GEOMBase.h>
+#include <GEOMUtils_ShapeStatistics.hxx>
+#include <GeometryGUI.h>
+#include <DlgRef.h>
+
+// GUI includes
+#include <SUIT_Desktop.h>
+#include <SUIT_MessageBox.h>
+#include <SUIT_Session.h>
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_ViewManager.h>
+#include <SUIT_ViewWindow.h>
+
+#include <LightApp_SelectionMgr.h>
+
+#include <SalomeApp_Application.h>
+#include <SalomeApp_Study.h>
+
+#include <Plot2d_Histogram.h>
+#include <Plot2d_ViewFrame.h>
+#include <Plot2d_ViewModel.h>
+#include <Plot2d_ViewWindow.h>
+
+// Qt includes
+#include <QIcon>
+#include <QGridLayout>
+#include <QPushButton>
+#include <QLabel>
+
+// Qtx includes
+#include <QtxValidator.h>
+
+// OCC includes
+#include <TopoDS_Shape.hxx>
+
+#include <GEOMImpl_Types.hxx>
+
+//===========================================================================
+// class : MeasureGUI_ShapeStatisticsDlg()
+//===========================================================================
+MeasureGUI_ShapeStatisticsDlg::MeasureGUI_ShapeStatisticsDlg( QWidget* parent, TopoDS_Shape aShape, TopAbs_ShapeEnum aSubShapeType )
+ : GEOMBase_Helper( SUIT_Session::session()->activeApplication()->desktop() ),
+ QDialog( parent ),
+ myHistogram ( 0 )
+{
+ myShapes.push_back( aShape );
+
+ QIcon iconSelect( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
+
+ setWindowTitle( tr( "GEOM_SHAPE_STATISTICS" ) );
+ setAttribute( Qt::WA_DeleteOnClose );
+
+ myApp = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
+
+ QVBoxLayout* topLayout = new QVBoxLayout( this );
+
+ QGridLayout* settingsLayout = new QGridLayout();
+
+ /********************** Selected Objects **********************/
+
+ QLabel* objsLabel = new QLabel( tr( "GEOM_SELECTED_OBJECTS" ), this );
+ QPushButton* selBtn = new QPushButton( this );
+ selBtn->setIcon( iconSelect );
+ myEditMainShape = new QLineEdit( this );
+ myEditMainShape->setReadOnly(true);
+
+ settingsLayout->addWidget( objsLabel, 0, 0 );
+ settingsLayout->addWidget( selBtn, 0, 1 );
+ settingsLayout->addWidget( myEditMainShape, 0, 2 );
+
+ if ( !aShape.IsNull() ) {
+ objsLabel->hide();
+ selBtn->hide();
+ myEditMainShape->hide();
+ }
+
+ /********************** Type **********************/
+
+ QLabel* typeLabel = new QLabel( tr( "GEOM_SHAPE_STATISTICS_TYPE" ), this );
+ myCBTypes = new QtxComboBox( this );
+ myCBTypes->setCleared( true );
+ if ( aSubShapeType != TopAbs_SHAPE ) {
+ fillTypes( aSubShapeType == TopAbs_EDGE,
+ aSubShapeType == TopAbs_FACE,
+ aSubShapeType == TopAbs_SOLID );
+ myCBTypes->setEnabled( false );
+ }
+
+ settingsLayout->addWidget( typeLabel, 1, 0 );
+ settingsLayout->addWidget( myCBTypes, 1, 2 );
+
+ /********************** Number of intervals **********************/
+
+ QLabel* nbIntervalsLabel = new QLabel( tr( "GEOM_SHAPE_STATISTICS_NB_INTERVALS" ), this );
+ myNbIntervals = new QtxIntSpinBox( 1, 1000, 1, this );
+ myNbIntervals->setValue( 10 );
+
+ settingsLayout->addWidget( nbIntervalsLabel, 2, 0 );
+ settingsLayout->addWidget( myNbIntervals, 2, 2 );
+
+ /********************** Scalar Range **********************/
+
+ myScalarRangeBox = new QGroupBox( tr( "GEOM_SHAPE_STATISTICS_SCALAR_RANGE" ), this );
+ myScalarRangeBox->setCheckable( true );
+ myScalarRangeBox->setChecked( false );
+ QLabel* minLabel = new QLabel( tr( "GEOM_SHAPE_STATISTICS_MIN" ), this );
+ myMin = new QLineEdit( this );
+ QtxDoubleValidator* aValid = new QtxDoubleValidator( this );
+ aValid->setBottom( 0.0 );
+ myMin->setValidator( aValid );
+ QLabel* maxLabel = new QLabel( tr( "GEOM_SHAPE_STATISTICS_MAX" ), this );
+ myMax = new QLineEdit( this );
+ myMax->setValidator( aValid );
+
+ QPushButton* buttonCompute = new QPushButton( tr( "GEOM_SHAPE_STATISTICS_COMPUTE" ), this );
+ connect( buttonCompute, SIGNAL( clicked() ), this, SLOT( clickOnCompute() ) );
+
+ QGridLayout* scalarRangeLayout = new QGridLayout();
+ scalarRangeLayout->setMargin( 11 ); settingsLayout->setSpacing( 6 );
+
+ scalarRangeLayout->addWidget( minLabel, 0, 0 );
+ scalarRangeLayout->addWidget( myMin, 0, 1 );
+ scalarRangeLayout->addWidget( maxLabel, 1, 0 );
+ scalarRangeLayout->addWidget( myMax, 1, 1 );
+ scalarRangeLayout->addWidget( buttonCompute, 0, 2, 2, 1 );
+
+ myScalarRangeBox->setLayout( scalarRangeLayout );
+
+ /********************** Buttons **********************/
+
+ myButtonPlot = new QPushButton( tr( "GEOM_PLOT_DISTRIBUTION" ), this );
+ myButtonPlot->setDefault( true );
+ myButtonCreateGr = new QPushButton( tr( "GEOM_SHAPE_STATISTICS_CREATE_GROUPS" ), this );
+ QPushButton* buttonClose = new QPushButton( tr( "GEOM_BUT_CLOSE" ), this );
+ QPushButton* buttonHelp = new QPushButton( tr( "GEOM_BUT_HELP" ), this );
+
+ QHBoxLayout* buttonsLayout = new QHBoxLayout();
+ buttonsLayout->addWidget( myButtonPlot );
+ buttonsLayout->addWidget( myButtonCreateGr );
+ buttonsLayout->addWidget( buttonClose );
+ buttonsLayout->addWidget( buttonHelp );
+
+ if ( !aShape.IsNull() ) {
+ myButtonCreateGr->hide();
+ }
+ /********************** Layouting **********************/
+
+ topLayout->addLayout( settingsLayout );
+ topLayout->addWidget( myScalarRangeBox );
+ topLayout->addLayout( buttonsLayout );
+
+ // Signals and slots connections
+
+ connect( selBtn, SIGNAL( clicked() ), this, SLOT( onEditMainShape() ) );
+
+ connect( myButtonPlot, SIGNAL( clicked() ), this, SLOT( clickOnPlot() ) );
+ connect( myButtonCreateGr, SIGNAL( clicked() ), this, SLOT( clickOnCreateGroups() ) );
+
+ connect( buttonClose, SIGNAL( clicked() ), this, SLOT( reject() ) );
+ connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( clickOnHelp() ) );
+
+ connect(myApp->selectionMgr(),
+ SIGNAL(currentSelectionChanged()), this, SLOT(onEditMainShape()));
+
+ if ( aShape.IsNull() )
+ onEditMainShape();
+}
+
+//===========================================================================
+// function : ~MeasureGUI_ShapeStatisticsDlg()
+// purpose : Destroys the object and frees any allocated resources
+//===========================================================================
+MeasureGUI_ShapeStatisticsDlg::~MeasureGUI_ShapeStatisticsDlg()
+{
+}
+
+//=================================================================================
+// function : createOperation
+// purpose :
+//=================================================================================
+GEOM::GEOM_IOperations_ptr MeasureGUI_ShapeStatisticsDlg::createOperation()
+{
+ return getGeomEngine()->GetIGroupOperations(getStudyId());
+}
+
+#define RETURN_WITH_MSG(a, b) \
+ if (!(a)) { \
+ theMessage += (b); \
+ return false; \
+ }
+
+//================================================================
+// Function : getFather
+// Purpose : Get father object for object to be added in study
+// (called with addInStudy method)
+//================================================================
+GEOM::GEOM_Object_ptr MeasureGUI_ShapeStatisticsDlg::getFather(GEOM::GEOM_Object_ptr theObj)
+{
+ GEOM::GEOM_Object_var aFatherObj;
+ if (theObj->GetType() == GEOM_GROUP) {
+ GEOM::GEOM_IGroupOperations_var anOper = GEOM::GEOM_IGroupOperations::_narrow(getOperation());
+ aFatherObj = anOper->GetMainShape(theObj);
+ }
+ return aFatherObj._retn();
+}
+
+//=================================================================================
+// function : getSourceObjects
+// purpose : virtual method to get source objects
+//=================================================================================
+QList<GEOM::GeomObjPtr> MeasureGUI_ShapeStatisticsDlg::getSourceObjects()
+{
+ QList<GEOM::GeomObjPtr> res;
+ res << myMainObj;
+ return res;
+}
+
+//=================================================================================
+// function : onEditMainShape()
+// purpose : called when selection button was clicked
+//=================================================================================
+void MeasureGUI_ShapeStatisticsDlg::onEditMainShape()
+{
+ // restore initial parameters for dialog box
+ myEditMainShape->setText("");
+ myEditMainShape->setFocus();
+
+ //get shapes from selection
+ QList<GEOM::GeomObjPtr> selShapes = getSelected( TopAbs_SHAPE, -1 );
+
+ myButtonPlot->setEnabled( !selShapes.isEmpty() );
+ myButtonCreateGr->setEnabled( selShapes.count() == 1 );
+
+ if ( !selShapes.isEmpty() ) {
+ if ( selShapes.count() == 1 )
+ myMainObj = selShapes[0];
+ QString aName = selShapes.count() > 1 ? QString( "%1_objects").arg( selShapes.count() ) : GEOMBase::GetName( myMainObj.get() );
+ myEditMainShape->setText( aName );
+ }
+
+ updateTypes( selShapes );
+}
+
+//=================================================================================
+// function : currentType()
+// purpose : returns currently selected type of shapes in 'Type' combobox
+//=================================================================================
+void MeasureGUI_ShapeStatisticsDlg::fillTypes( bool hasEdges, bool hasFaces, bool hasSolids )
+{
+ if ( hasEdges )
+ myCBTypes->addItem( tr("GEOM_SHAPE_STATISTICS_LENGTH"), (int)TopAbs_EDGE );
+ if ( hasFaces )
+ myCBTypes->addItem( tr("GEOM_SHAPE_STATISTICS_AREA"), (int)TopAbs_FACE );
+ if ( hasSolids )
+ myCBTypes->addItem( tr("GEOM_SHAPE_STATISTICS_VOLUME"), (int)TopAbs_SOLID );
+
+ myCBTypes->setEnabled( myCBTypes->count() > 0 );
+}
+
+//=================================================================================
+// function : updateTypes()
+// purpose : update 'Type' combobox with available types
+//=================================================================================
+void MeasureGUI_ShapeStatisticsDlg::updateTypes( QList<GEOM::GeomObjPtr> theShapes )
+{
+ myCBTypes->clear();
+ myCBTypes->setEnabled( false );
+
+ int hasEdges = -1, hasFaces = -1, hasSolids = -1;
+
+ myShapes.clear();
+ // get types of the shapes and its sub-shapes
+ foreach( GEOM::GeomObjPtr aShapePtr, theShapes ) {
+ if ( !aShapePtr )
+ return;
+
+ TopoDS_Shape aShape;
+ if ( !GEOMBase::GetShape( aShapePtr.get(), aShape ) || aShape.IsNull() )
+ return;
+
+ myShapes.push_back( aShape );
+
+ GEOM::ListOfLong_var aSubShapes;
+ GEOM::GEOM_IShapesOperations_var aShOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
+ if ( hasEdges != 0 )
+ hasEdges = aShOp->NumberOfSubShapes( aShapePtr.get(), TopAbs_EDGE ) > 0;
+ if ( hasFaces != 0 )
+ hasEdges = aShOp->NumberOfSubShapes( aShapePtr.get(), TopAbs_FACE ) > 0;
+ if ( hasSolids != 0 )
+ hasEdges = aShOp->NumberOfSubShapes( aShapePtr.get(), TopAbs_SOLID ) > 0;
+ }
+ fillTypes( hasEdges, hasFaces, hasSolids );
+}
+
+//=================================================================================
+// function : currentType()
+// purpose : returns currently selected type of shapes in 'Type' combobox
+//=================================================================================
+TopAbs_ShapeEnum MeasureGUI_ShapeStatisticsDlg::currentType()
+{
+ return (TopAbs_ShapeEnum)( myCBTypes->itemData( myCBTypes->currentIndex() ).toInt() );
+}
+
+//=================================================================================
+// function : clickOnPlot()
+// purpose : called when Plot button was clicked
+//=================================================================================
+bool MeasureGUI_ShapeStatisticsDlg::isValid(QString& theMessage)
+{
+ if ( myScalarRangeBox->isChecked() ) {
+ RETURN_WITH_MSG( !myMin->text().isEmpty(), tr("GEOM_SHAPE_STATISTICS_MIN_ERROR") )
+ RETURN_WITH_MSG( !myMax->text().isEmpty(), tr("GEOM_SHAPE_STATISTICS_MAX_ERROR") )
+ RETURN_WITH_MSG( myMin->text().toDouble() <= myMax->text().toDouble(), tr("GEOM_SHAPE_STATISTICS_MIN_MAX_ERROR") )
+ }
+ return true;
+}
+//=================================================================================
+// function : clickOnPlot()
+// purpose : called when Plot button was clicked
+//=================================================================================
+void MeasureGUI_ShapeStatisticsDlg::clickOnPlot()
+{
+ GEOMUtils::Range aRange;
+ if ( myScalarRangeBox->isChecked() ) {
+ QString msg;
+ if ( !isValid( msg ) ) {
+ showError( msg );
+ return;
+ }
+ aRange.min = myMin->text().toDouble();
+ aRange.max = myMax->text().toDouble();
+ } else {
+ aRange.min = -1.0; // flag that range is empty
+ aRange.max = -1.0; // flag that range is empty
+ }
+
+ GEOMUtils::Distribution aShapesDistr =
+ GEOMUtils::ComputeDistribution( myShapes, currentType(), myNbIntervals->value(), aRange );
+
+ QList<double> xVals, yVals;
+ double width = -1, min = -1;
+ double xmin = 1e+32, xmax = 0.0, ymax = 0.0;
+ int i=0;
+ GEOMUtils::Distribution::const_iterator it;
+ for (it = aShapesDistr.begin(); it != aShapesDistr.end(); it++) {
+ GEOMUtils::Range ran = *it;
+ if ( width < 0 ) width = ran.max - ran.min; // bar width
+ if ( min < 0 ) min = ran.min; // global min
+ xVals << width / 2. + i*width + min; // get a middle of bar
+ yVals << ran.count;
+ // get global boundary max values
+ if ( ran.min < xmin ) xmin = ran.min;
+ if ( ran.max > xmax ) xmax = ran.max;
+ if ( ran.count > ymax ) ymax = ran.count;
+ i++;
+ }
+
+ // plot the computed distribution
+ SUIT_ViewManager* aViewManager = myApp->getViewManager( Plot2d_Viewer::Type(), true ); // create if necessary
+ if( !aViewManager )
+ return;
+ Plot2d_ViewWindow* aViewWnd = dynamic_cast<Plot2d_ViewWindow*>(aViewManager->getActiveView());
+ if( !aViewWnd )
+ return;
+ Plot2d_ViewFrame* aPlot = aViewWnd->getViewFrame();
+ if ( !aPlot )
+ return;
+
+ aPlot->EraseAll();
+
+ // create or reuse histogram
+ if( !myHistogram )
+ myHistogram = new Plot2d_Histogram();
+ else
+ myHistogram->clearAllPoints();
+ // set histogram parameters
+ myHistogram->setData( xVals, yVals );
+ if ( width != 0.0 )
+ myHistogram->setWidth( width );
+ myHistogram->setAutoAssign(true);
+ myHistogram->setName( myEditMainShape->text() );
+ myHistogram->setHorTitle( myCBTypes->currentText() );
+ myHistogram->setVerTitle( tr("GEOM_SHAPE_STATISTICS_DISTRIBUTION_NB_ENT") );
+ myHistogram->setColor( QColor(0, 85, 0) );
+ // display histogram
+ aPlot->displayObject( myHistogram, true );
+ if ( width == 0.0 ) // only one X value
+ aPlot->fitAll();
+ else
+ aPlot->fitData( 0, xmin, xmax, 0.0, ymax );
+}
+
+//=================================================================================
+// function : clickOnCompute()
+// purpose : called when Compute button was clicked
+//=================================================================================
+void MeasureGUI_ShapeStatisticsDlg::clickOnCompute()
+{
+ GEOMUtils::Range aRange;
+ aRange.min = -1.0; // flag that range is empty
+ aRange.max = -1.0; // flag that range is empty
+ std::map<int,double> measures = GEOMUtils::ComputeMeasures( myShapes, currentType(), aRange );
+ if ( measures.size() != 0 ) {
+ SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+ int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
+ myMin->setText( DlgRef::PrintDoubleValue( aRange.min, aPrecision ) );
+ myMax->setText( DlgRef::PrintDoubleValue( aRange.max, aPrecision ) );
+ }
+}
+
+//=================================================================================
+// function : clickOnCreateGroups()
+// purpose : called when Create Groups button was clicked
+//=================================================================================
+void MeasureGUI_ShapeStatisticsDlg::clickOnCreateGroups()
+{
+ onAccept(false, false, false);
+}
+
+//=================================================================================
+// function : execute(ObjectList& objects)
+// purpose :
+//=================================================================================
+bool MeasureGUI_ShapeStatisticsDlg::execute(ObjectList& objects)
+{
+ if ( myMainObj.isNull() )
+ return false;
+
+ GEOM::GroupOpPtr anOper = GEOM::GEOM_IGroupOperations::_narrow(getOperation());
+
+ GEOMUtils::Range aRange;
+ if ( myScalarRangeBox->isChecked() ) {
+ QString msg;
+ if ( !isValid( msg ) ) {
+ showError( msg );
+ return false;
+ }
+ aRange.min = myMin->text().toDouble();
+ aRange.max = myMax->text().toDouble();
+ } else {
+ aRange.min = -1.0; // flag that range is empty
+ aRange.max = -1.0; // flag that range is empty
+ }
+
+ SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+ int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
+ QString aTypePrefix = myCBTypes->currentText().replace(' ', '_');
+ QString objIOR, aMin, aMax, aGroupName;
+ SalomeApp_Study* study = getStudy();
+
+ GEOMUtils::Distribution aShapesDistr =
+ GEOMUtils::ComputeDistribution( myShapes, currentType(), myNbIntervals->value(), aRange );
+
+ int nbGroups = 0;
+
+ GEOMUtils::Distribution::const_iterator it;
+ for (it = aShapesDistr.begin(); it != aShapesDistr.end(); it++) {
+ std::list<long> idList = (*it).indices;
+ int nn = idList.size();
+ if ( nn > 0 ) {
+ GEOM::ListOfLong_var aNewList = new GEOM::ListOfLong;
+ aNewList->length(nn);
+ int ii = 0;
+ std::list<long>::const_iterator id_it;
+ for ( id_it = idList.begin(); id_it != idList.end(); id_it++ ) {
+ aNewList[ii++] = *id_it;
+ }
+
+ // Create an empty group
+ GEOM::GEOM_Object_var aGroup;
+ aGroup = anOper->CreateGroup( myMainObj.get(), currentType() );
+
+ if (CORBA::is_nil(aGroup) || !anOper->IsDone())
+ return false;
+
+ // Add sub-shapes into group
+ anOper->UnionIDs(aGroup, aNewList);
+ if (!anOper->IsDone())
+ return false;
+
+ // publish group
+ aMin = DlgRef::PrintDoubleValue( (*it).min, aPrecision );
+ aMax = DlgRef::PrintDoubleValue( (*it).max, aPrecision );
+ aGroupName = aTypePrefix + "_" + aMin + "_" + aMax;
+ GEOMBase::PublishSubObject( aGroup, aGroupName );
+
+ // this is needed just to avoid error message
+ objects.push_back(aGroup._retn());
+
+ nbGroups++;
+ }
+ }
+
+ SUIT_MessageBox::information( this, tr( "INF_INFO" ), tr( "GEOM_MSG_GROUPS_CREATED" ).arg( nbGroups ) );
+
+ return true;
+}
+
+//=================================================================================
+// function : clickOnHelp()
+// purpose : called when Help button was clicked
+//=================================================================================
+void MeasureGUI_ShapeStatisticsDlg::clickOnHelp()
+{
+ GeometryGUI* aGeomGUI = dynamic_cast<GeometryGUI*>( myApp->module( "Geometry" ) );
+ myApp->onHelpContextModule( aGeomGUI ? myApp->moduleName( aGeomGUI->moduleName() ) : QString(""), "shape_statistics_operation_page.html" );
+}
--- /dev/null
+// Copyright (C) 2015 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// GEOM GEOMGUI : GUI for Geometry component
+// File : MeasureGUI_ShapeStatisticsDlg.h
+// Author : Alexander KOVALEV, Open CASCADE (alexander.kovalev@opencascade.com)
+//
+#ifndef MEASUREGUI_SHAPESTATISTICSDLG_H
+#define MEASUREGUI_SHAPESTATISTICSDLG_H
+
+// GEOM includes
+#include <GEOMBase_Helper.h>
+#include "GEOM_GenericObjPtr.h"
+
+// Qt includes
+#include <QDialog>
+#include <QLineEdit>
+#include <QPointer>
+#include <QGroupBox>
+
+// Qtx includes
+#include <QtxIntSpinBox.h>
+#include <QtxComboBox.h>
+
+class Plot2d_Histogram;
+
+//==========================================================================
+// class : MeasureGUI_ShapeStatisticsDlg
+// purpose :
+//==========================================================================
+
+class MeasureGUI_ShapeStatisticsDlg : public QDialog, public GEOMBase_Helper
+{
+ Q_OBJECT
+
+public:
+ MeasureGUI_ShapeStatisticsDlg( QWidget*, TopoDS_Shape aShape = TopoDS_Shape(), TopAbs_ShapeEnum aSubShapeType = TopAbs_SHAPE );
+ ~MeasureGUI_ShapeStatisticsDlg();
+
+protected:
+ // redefined from GEOMBase_Helper
+ virtual GEOM::GEOM_IOperations_ptr createOperation();
+ virtual bool isValid (QString&);
+ virtual bool execute (ObjectList&);
+ virtual GEOM::GEOM_Object_ptr getFather (GEOM::GEOM_Object_ptr);
+ virtual QList<GEOM::GeomObjPtr> getSourceObjects();
+
+private slots:
+ void onEditMainShape();
+ void clickOnCompute();
+ void clickOnPlot();
+ void clickOnCreateGroups();
+ void clickOnHelp();
+
+private:
+ void fillTypes( bool, bool, bool );
+ void updateTypes( QList<GEOM::GeomObjPtr> theShapes );
+ TopAbs_ShapeEnum currentType();
+
+private:
+ SalomeApp_Application* myApp;
+ QLineEdit* myEditMainShape;
+ QtxComboBox* myCBTypes;
+ std::list<TopoDS_Shape> myShapes;
+ GEOM::GeomObjPtr myMainObj;
+ QtxIntSpinBox* myNbIntervals;
+ QGroupBox* myScalarRangeBox;
+ QLineEdit* myMin;
+ QLineEdit* myMax;
+ QPushButton* myButtonPlot;
+ QPushButton* myButtonCreateGr;
+ Plot2d_Histogram* myHistogram;
+
+};
+
+#endif // MEASUREGUI_SHAPESTATISTICSDLG_H