1 // Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #ifndef _GEOMImpl_IMeasureOperations_HXX_
24 #define _GEOMImpl_IMeasureOperations_HXX_
26 #include "GEOM_IOperations.hxx"
28 #include <BRepCheck_Analyzer.hxx>
29 #include <BRepCheck_Status.hxx>
30 #include <TopoDS_Shape.hxx>
31 #include <TCollection_AsciiString.hxx>
32 #include <TColStd_HSequenceOfInteger.hxx>
33 #include <TColStd_HSequenceOfReal.hxx>
34 #include <TopTools_DataMapOfIntegerListOfShape.hxx>
35 #include <TopTools_MapOfShape.hxx>
36 #include <Geom_Surface.hxx>
37 #include <Precision.hxx>
42 class GEOMImpl_IMeasureOperations : public GEOM_IOperations {
44 Standard_EXPORT GEOMImpl_IMeasureOperations(GEOM_Engine* theEngine);
45 Standard_EXPORT ~GEOMImpl_IMeasureOperations();
55 SK_SPHERE, // full sphere
56 SK_CYLINDER, // cylinder
57 SK_BOX, // box with faces, parallel to global coordinate planes
58 SK_ROTATED_BOX, // other box
59 SK_TORUS, // full torus
61 SK_POLYHEDRON, // solid, bounded by polygons
62 SK_SOLID, // other solid
64 SK_SPHERE2D, // spherical face (closed)
65 SK_CYLINDER2D, // cylindrical face with defined height
66 SK_TORUS2D, // toroidal face (closed)
67 SK_CONE2D, // conical face with defined height
68 SK_DISK_CIRCLE, // planar, bounded by circle
69 SK_DISK_ELLIPSE, // planar, bounded by ellipse
70 SK_POLYGON, // planar, bounded by segments
71 SK_PLANE, // infinite planar
72 SK_PLANAR, // other planar
73 SK_FACE, // other face
75 SK_CIRCLE, // full circle
76 SK_ARC_CIRCLE, // arc of circle
77 SK_ELLIPSE, // full ellipse
78 SK_ARC_ELLIPSE, // arc of ellipse
79 SK_LINE, // infinite segment
80 SK_SEGMENT, // segment
81 SK_EDGE, // other edge
85 SK_LCS, // local coordinate system
86 // (other advanced shapes)
87 SK_ADVANCED, // all advanced shapes (temporary implementation)
91 * This enumeration represents the level of checking shape on
92 * self-interference. It defines which interferferences will be checked.
96 SI_V_V = 0, // only V/V interferences
97 SI_V_E, // V/V and V/E interferences
98 SI_E_E, // V/V, V/E and E/E interferences
99 SI_V_F, // V/V, V/E, E/E and V/F interferences
100 SI_E_F, // V/V, V/E, E/E, V/F and E/F interferences
101 SI_ALL // all interferences
104 Standard_EXPORT ShapeKind KindOfShape (Handle(GEOM_Object) theShape,
105 Handle(TColStd_HSequenceOfInteger)& theIntegers,
106 Handle(TColStd_HSequenceOfReal)& theDoubles);
108 Standard_EXPORT void GetPosition (Handle(GEOM_Object) theShape,
109 Standard_Real& Ox, Standard_Real& Oy, Standard_Real& Oz,
110 Standard_Real& Zx, Standard_Real& Zy, Standard_Real& Zz,
111 Standard_Real& Xx, Standard_Real& Xy, Standard_Real& Xz);
113 Standard_EXPORT Handle(GEOM_Object) GetCentreOfMass (Handle(GEOM_Object) theShape);
115 Standard_EXPORT Handle(GEOM_Object) GetVertexByIndex (Handle(GEOM_Object) theShape,
116 Standard_Integer theIndex,
117 Standard_Boolean theUseOri);
119 Standard_EXPORT Handle(GEOM_Object) GetNormal (Handle(GEOM_Object) theFace,
120 Handle(GEOM_Object) theOptionalPoint);
122 Standard_EXPORT void GetBasicProperties (Handle(GEOM_Object) theShape,
123 const Standard_Real theTolerance,
124 Standard_Real& theLength,
125 Standard_Real& theSurfArea,
126 Standard_Real& theVolume);
128 Standard_EXPORT void GetInertia (Handle(GEOM_Object) theShape,
129 Standard_Real& I11, Standard_Real& I12, Standard_Real& I13,
130 Standard_Real& I21, Standard_Real& I22, Standard_Real& I23,
131 Standard_Real& I31, Standard_Real& I32, Standard_Real& I33,
132 Standard_Real& Ix , Standard_Real& Iy , Standard_Real& Iz);
134 Standard_EXPORT void GetBoundingBox (Handle(GEOM_Object) theShape,
135 const Standard_Boolean precise,
136 Standard_Real& Xmin, Standard_Real& Xmax,
137 Standard_Real& Ymin, Standard_Real& Ymax,
138 Standard_Real& Zmin, Standard_Real& Zmax);
140 Standard_EXPORT Handle(GEOM_Object) GetBoundingBox (Handle(GEOM_Object) theShape,
141 const Standard_Boolean precise);
143 Standard_EXPORT void GetTolerance (Handle(GEOM_Object) theShape,
144 Standard_Real& FaceMin, Standard_Real& FaceMax,
145 Standard_Real& EdgeMin, Standard_Real& EdgeMax,
146 Standard_Real& VertMin, Standard_Real& VertMax);
149 BRepCheck_Status error;
150 std::list<int> incriminated;
153 Standard_EXPORT bool CheckShape (Handle(GEOM_Object) theShape,
154 const Standard_Boolean theIsCheckGeom,
155 std::list<ShapeError> &theErrors);
157 Standard_EXPORT TCollection_AsciiString PrintShapeErrors
158 (Handle(GEOM_Object) theShape,
159 const std::list<ShapeError> &theErrors);
161 Standard_EXPORT bool CheckSelfIntersections (Handle(GEOM_Object) theShape,
162 const SICheckLevel theCheckLevel,
163 Handle(TColStd_HSequenceOfInteger)& theIntersections);
165 Standard_EXPORT bool CheckSelfIntersectionsFast (Handle(GEOM_Object) theShape,
168 Handle(TColStd_HSequenceOfInteger)& theIntersections);
170 Standard_EXPORT bool CheckBOPArguments (const Handle(GEOM_Object) &theShape);
172 Standard_EXPORT bool FastIntersect (Handle(GEOM_Object) theShape1, Handle(GEOM_Object) theShape2,
173 double tolerance, float deflection,
174 Handle(TColStd_HSequenceOfInteger)& theIntersections1,
175 Handle(TColStd_HSequenceOfInteger)& theIntersections2);
177 Standard_EXPORT TCollection_AsciiString IsGoodForSolid (Handle(GEOM_Object) theShape);
179 Standard_EXPORT TCollection_AsciiString WhatIs (Handle(GEOM_Object) theShape);
181 Standard_EXPORT std::vector<bool> AreCoordsInside (Handle(GEOM_Object) theShape,
182 const std::vector<double>& coords,
183 double tolerance = Precision::Confusion());
185 Standard_EXPORT Standard_Real GetMinDistance (Handle(GEOM_Object) theShape1,
186 Handle(GEOM_Object) theShape2,
187 Standard_Real& X1, Standard_Real& Y1, Standard_Real& Z1,
188 Standard_Real& X2, Standard_Real& Y2, Standard_Real& Z2);
190 Standard_EXPORT Standard_Integer ClosestPoints (Handle(GEOM_Object) theShape1,
191 Handle(GEOM_Object) theShape2,
192 Handle(TColStd_HSequenceOfReal)& theDoubles);
194 Standard_EXPORT void PointCoordinates (Handle(GEOM_Object) theShape,
195 Standard_Real& theX, Standard_Real& theY, Standard_Real& theZ);
197 Standard_EXPORT Standard_Real GetAngle (Handle(GEOM_Object) theLine1, Handle(GEOM_Object) theLine2);
199 Standard_EXPORT Standard_Real GetAngleBtwVectors (Handle(GEOM_Object) theVec1, Handle(GEOM_Object) theVec2);
201 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) PatchFace(Handle(GEOM_Object) theShape);
203 // Methods for receiving radiuses of curvature of curves and surfaces
204 // in the given point
205 Standard_EXPORT Standard_Real CurveCurvatureByParam (Handle(GEOM_Object) theCurve,
206 Standard_Real& theParam);
207 Standard_EXPORT Standard_Real CurveCurvatureByPoint (Handle(GEOM_Object) theCurve,
208 Handle(GEOM_Object) thePoint);
209 Standard_EXPORT Standard_Real MaxSurfaceCurvatureByParam (Handle(GEOM_Object) theSurf,
210 Standard_Real& theUParam,
211 Standard_Real& theVParam);
212 Standard_EXPORT Standard_Real MaxSurfaceCurvatureByPoint (Handle(GEOM_Object) theSurf,
213 Handle(GEOM_Object) thePoint);
214 Standard_EXPORT Standard_Real MinSurfaceCurvatureByParam (Handle(GEOM_Object) theSurf,
215 Standard_Real& theUParam,
216 Standard_Real& theVParam);
217 Standard_EXPORT Standard_Real MinSurfaceCurvatureByPoint (Handle(GEOM_Object) theSurf,
218 Handle(GEOM_Object) thePoint);
220 // Methods checking the shapes which are not applicable to modelling operations
221 typedef std::pair< Handle(GEOM_Object), Handle(GEOM_Object)> CoupleOfObjects;
224 Standard_Integer TypeOfCheck;
225 CoupleOfObjects FailedShapes;
228 Standard_EXPORT std::list<CoupleOfObjects> SelfIntersected2D(const std::list<FailedChecks>& theChecks);
229 Standard_EXPORT std::list<CoupleOfObjects> InterferingSubshapes(const std::list<FailedChecks>& theChecks,
230 const int theShapeType1,
231 const int theShapeType2);
232 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) SmallEdges(const std::list<FailedChecks>& theChecks);
233 Standard_EXPORT std::list<CoupleOfObjects> DistantShapes(const std::list<FailedChecks>& theChecks,
234 const int theShapeType,
235 const int theSubShapeType,
236 double theTolerance);
237 Standard_EXPORT void CheckConformityShape(Handle(GEOM_Object) theShape, std::list<FailedChecks>& theChecks);
239 Standard_EXPORT double ComputeTolerance(Handle(GEOM_Object) theEdge, Handle(GEOM_Object) theFace);
240 Standard_EXPORT double UpdateTolerance(Handle(GEOM_Object) theShape);
242 Standard_EXPORT Handle(GEOM_Object) SurfaceCurvatureByPointAndDirection
243 (Handle(GEOM_Object) theSurf,
244 Handle(GEOM_Object) thePoint,
245 Handle(GEOM_Object) theDirection);
247 // Methods to compute proximity between two shapes
248 Standard_EXPORT Handle(GEOM_Object) ShapeProximityCalculator(Handle(GEOM_Object) theShape1,
249 Handle(GEOM_Object) theShape2);
250 Standard_EXPORT Standard_Real GetCoarseProximity(Handle(GEOM_Object) theCalculator,
251 bool doPythonDump = true);
252 Standard_EXPORT Standard_Real GetPreciseProximity(Handle(GEOM_Object) theCalculator);
253 Standard_EXPORT void SetShapeSampling(Handle(GEOM_Object) theCalculator,
254 Handle(GEOM_Object) theShape,
255 const Standard_Integer theNbSamples);
260 (const BRepCheck_Analyzer &theAna,
261 const TopoDS_Shape &theShape,
262 const TopAbs_ShapeEnum theSubType,
263 TopTools_DataMapOfIntegerListOfShape &theMapErrors) const;
265 (const BRepCheck_Analyzer &theAna,
266 const TopoDS_Shape &theShape,
267 TopTools_DataMapOfIntegerListOfShape &theMapErrors,
268 TopTools_MapOfShape &theMapShapes) const;
270 void FillErrors (const BRepCheck_Analyzer &theAna,
271 const TopoDS_Shape &theShape,
272 std::list<ShapeError> &theErrors) const;
274 Standard_Real getSurfaceCurvatures (const Handle(Geom_Surface)& aSurf,
275 Standard_Real theUParam,
276 Standard_Real theVParam,
277 Standard_Boolean theNeedMaxCurv);