Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:10

0001 // Created on: 1999-03-03
0002 // Created by: Fabrice SERVANT
0003 // Copyright (c) 1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _IntPolyh_MaillageAffinage_HeaderFile
0018 #define _IntPolyh_MaillageAffinage_HeaderFile
0019 
0020 #include <Adaptor3d_Surface.hxx>
0021 #include <Bnd_Box.hxx>
0022 #include <IntPolyh_ArrayOfPoints.hxx>
0023 #include <IntPolyh_ArrayOfEdges.hxx>
0024 #include <IntPolyh_ArrayOfTriangles.hxx>
0025 #include <IntPolyh_ListOfCouples.hxx>
0026 #include <TColStd_Array1OfReal.hxx>
0027 #include <IntPolyh_ArrayOfPointNormal.hxx>
0028 #include <IntPolyh_ArrayOfSectionLines.hxx>
0029 #include <IntPolyh_ArrayOfTangentZones.hxx>
0030 
0031 class IntPolyh_StartPoint;
0032 
0033 //! Low-level algorithm to compute intersection of the surfaces
0034 //! by computing the intersection of their triangulations.
0035 class IntPolyh_MaillageAffinage
0036 {
0037 public:
0038 
0039   DEFINE_STANDARD_ALLOC
0040 
0041 
0042   Standard_EXPORT IntPolyh_MaillageAffinage(const Handle(Adaptor3d_Surface)& S1, const Standard_Integer NbSU1, const Standard_Integer NbSV1, const Handle(Adaptor3d_Surface)& S2, const Standard_Integer NbSU2, const Standard_Integer NbSV2, const Standard_Integer PRINT);
0043 
0044   Standard_EXPORT IntPolyh_MaillageAffinage(const Handle(Adaptor3d_Surface)& S1, const Handle(Adaptor3d_Surface)& S2, const Standard_Integer PRINT);
0045 
0046 
0047   //! Makes the sampling of the surface -
0048   //! Fills the arrays with the parametric values of the sampling points (triangulation nodes).
0049   Standard_EXPORT void MakeSampling (const Standard_Integer SurfID,
0050                                      TColStd_Array1OfReal& theUPars,
0051                                      TColStd_Array1OfReal& theVPars);
0052 
0053   //! Computes points on one surface and fills an array of points;
0054   //! standard (default) method
0055   Standard_EXPORT void FillArrayOfPnt (const Standard_Integer SurfID);
0056 
0057   //! isShiftFwd flag is added. The purpose is to define shift
0058   //! of points along normal to the surface in this point. The
0059   //! shift length represents maximal deflection of triangulation.
0060   //! The direction (forward or reversed regarding to normal
0061   //! direction) is defined by isShiftFwd flag.
0062   //! Compute points on one surface and fill an array of points;
0063   //! advanced method
0064   Standard_EXPORT void FillArrayOfPnt (const Standard_Integer SurfID,
0065                                        const Standard_Boolean isShiftFwd);
0066 
0067   //! Compute points on one surface and fill an array of points;
0068   //! If given, <theDeflTol> is the deflection tolerance of the given sampling.
0069   //! standard (default) method
0070   Standard_EXPORT void FillArrayOfPnt (const Standard_Integer SurfID,
0071                                        const TColStd_Array1OfReal& Upars,
0072                                        const TColStd_Array1OfReal& Vpars,
0073                                        const Standard_Real *theDeflTol = NULL);
0074 
0075   //! isShiftFwd flag is added. The purpose is to define shift
0076   //! of points along normal to the surface in this point. The
0077   //! shift length represents maximal deflection of triangulation.
0078   //! The direction (forward or reversed regarding to normal
0079   //! direction) is defined by isShiftFwd flag.
0080   //! Compute points on one surface and fill an array of points;
0081   //! If given, <theDeflTol> is the deflection tolerance of the given sampling.
0082   //! advanced method
0083   Standard_EXPORT void FillArrayOfPnt (const Standard_Integer SurfID,
0084                                        const Standard_Boolean isShiftFwd,
0085                                        const TColStd_Array1OfReal& Upars,
0086                                        const TColStd_Array1OfReal& Vpars,
0087                                        const Standard_Real *theDeflTol = NULL);
0088 
0089   //! Fills the array of points for the surface taking into account the shift
0090   Standard_EXPORT void FillArrayOfPnt(const Standard_Integer SurfID,
0091                                       const Standard_Boolean isShiftFwd,
0092                                       const IntPolyh_ArrayOfPointNormal& thePoints,
0093                                       const TColStd_Array1OfReal& theUPars,
0094                                       const TColStd_Array1OfReal& theVPars,
0095                                       const Standard_Real theDeflTol);
0096 
0097   //! Looks for the common box of the surfaces and marks the points
0098   //! of the surfaces inside that common box for possible intersection
0099   Standard_EXPORT void CommonBox();
0100 
0101   //! Compute the common box  witch is the intersection
0102   //! of the two bounding boxes,  and mark the points of
0103   //! the two surfaces that are inside.
0104   Standard_EXPORT void CommonBox (const Bnd_Box& B1, const Bnd_Box& B2, Standard_Real& xMin, Standard_Real& yMin, Standard_Real& zMin, Standard_Real& xMax, Standard_Real& yMax, Standard_Real& zMax);
0105 
0106   //! Compute edges from the array of points
0107   Standard_EXPORT void FillArrayOfEdges (const Standard_Integer SurfID);
0108 
0109   //! Compute triangles from the array of points, and --
0110   //! mark the triangles  that use marked points by the
0111   //! CommonBox function.
0112   Standard_EXPORT void FillArrayOfTriangles (const Standard_Integer SurfID);
0113 
0114   //! Refine systematicaly all marked triangles of both surfaces
0115   Standard_EXPORT void CommonPartRefinement();
0116 
0117   //! Refine systematicaly all marked triangles of ONE surface
0118   Standard_EXPORT void LocalSurfaceRefinement (const Standard_Integer SurfId);
0119 
0120   //! Compute deflection  for   all  triangles  of  one
0121   //! surface,and sort min and max of deflections
0122   Standard_EXPORT void ComputeDeflections (const Standard_Integer SurfID);
0123 
0124   //! Refine  both  surfaces using  BoundSortBox  as --
0125   //! rejection.  The  criterions  used to refine a  --
0126   //! triangle are:  The deflection The  size of the --
0127   //! bounding boxes   (one surface may be   very small
0128   //! compared to the other)
0129   Standard_EXPORT void TrianglesDeflectionsRefinementBSB();
0130 
0131   //! This function checks if two triangles are in contact or not,
0132   //! return 1 if yes, return 0 if not.
0133   Standard_EXPORT Standard_Integer TriContact (const IntPolyh_Point& P1, const IntPolyh_Point& P2, const IntPolyh_Point& P3, const IntPolyh_Point& Q1, const IntPolyh_Point& Q2, const IntPolyh_Point& Q3, Standard_Real& Angle) const;
0134 
0135   Standard_EXPORT Standard_Integer TriangleEdgeContact (const Standard_Integer TriSurfID, const Standard_Integer EdgeIndice, const IntPolyh_Triangle& Tri1, const IntPolyh_Triangle& Tri2, const IntPolyh_Point& P1, const IntPolyh_Point& P2, const IntPolyh_Point& P3, const IntPolyh_Point& C1, const IntPolyh_Point& C2, const IntPolyh_Point& C3, const IntPolyh_Point& Pe1, const IntPolyh_Point& Pe2, const IntPolyh_Point& E, const IntPolyh_Point& N, IntPolyh_StartPoint& SP1, IntPolyh_StartPoint& SP2) const;
0136 
0137   //! From two triangles compute intersection points.
0138   //! If we found more than two intersection points
0139   //! that means that those triangles are coplanar
0140   Standard_EXPORT Standard_Integer StartingPointsResearch (const Standard_Integer T1, const Standard_Integer T2, IntPolyh_StartPoint& SP1, IntPolyh_StartPoint& SP2) const;
0141 
0142   //! from two triangles and an intersection point I
0143   //! search the other point (if it exists).
0144   //! This function is used by StartPointChain
0145   Standard_EXPORT Standard_Integer NextStartingPointsResearch (const Standard_Integer T1, const Standard_Integer T2, const IntPolyh_StartPoint& SPInit, IntPolyh_StartPoint& SPNext) const;
0146 
0147   //! Analyse each couple of triangles from the two -- array of triangles,
0148   //! to see if they are in contact, and compute the incidence.
0149   //! Then put couples in contact in the array of couples
0150   Standard_EXPORT Standard_Integer TriangleCompare();
0151 
0152   //! Loop on the array of couples. Compute StartPoints.
0153   //! Try to chain  the StartPoints into SectionLines or
0154   //! put  the  point  in  the    ArrayOfTangentZones if
0155   //! chaining it, is not possible.
0156   Standard_EXPORT Standard_Integer StartPointsChain (IntPolyh_ArrayOfSectionLines& TSectionLines, IntPolyh_ArrayOfTangentZones& TTangentZones);
0157 
0158   //! Mainly  used  by StartPointsChain(), this function
0159   //! try to compute the next StartPoint.
0160   Standard_EXPORT Standard_Integer GetNextChainStartPoint (const IntPolyh_StartPoint& SPInit, IntPolyh_StartPoint& SPNext, IntPolyh_SectionLine& MySectionLine, IntPolyh_ArrayOfTangentZones& TTangentZones, const Standard_Boolean Prepend = Standard_False);
0161 
0162   Standard_EXPORT const IntPolyh_ArrayOfPoints& GetArrayOfPoints (const Standard_Integer SurfID) const;
0163 
0164   Standard_EXPORT const IntPolyh_ArrayOfEdges& GetArrayOfEdges (const Standard_Integer SurfID) const;
0165 
0166   Standard_EXPORT const IntPolyh_ArrayOfTriangles& GetArrayOfTriangles (const Standard_Integer SurfID) const;
0167 
0168   Standard_EXPORT Standard_Integer GetFinTE (const Standard_Integer SurfID) const;
0169 
0170   Standard_EXPORT Standard_Integer GetFinTT (const Standard_Integer SurfID) const;
0171 
0172   Standard_EXPORT Bnd_Box GetBox (const Standard_Integer SurfID) const;
0173 
0174   //! This method returns list of couples of contact triangles.
0175   Standard_EXPORT IntPolyh_ListOfCouples& GetCouples();
0176 
0177   Standard_EXPORT void SetEnlargeZone (const Standard_Boolean EnlargeZone);
0178 
0179   Standard_EXPORT Standard_Boolean GetEnlargeZone() const;
0180 
0181   //! returns FlecheMin
0182   Standard_EXPORT Standard_Real GetMinDeflection (const Standard_Integer SurfID) const;
0183 
0184   //! returns FlecheMax
0185   Standard_EXPORT Standard_Real GetMaxDeflection (const Standard_Integer SurfID) const;
0186 
0187 private:
0188 
0189   Handle(Adaptor3d_Surface) MaSurface1;
0190   Handle(Adaptor3d_Surface) MaSurface2;
0191   Bnd_Box MyBox1;
0192   Bnd_Box MyBox2;
0193   Standard_Integer NbSamplesU1;
0194   Standard_Integer NbSamplesU2;
0195   Standard_Integer NbSamplesV1;
0196   Standard_Integer NbSamplesV2;
0197   Standard_Real FlecheMax1;
0198   Standard_Real FlecheMax2;
0199   Standard_Real FlecheMin1;
0200   Standard_Real FlecheMin2;
0201   // For the arrays of Points, Edges and Triangles we need instant access to the items.
0202   // Moreover, we might add new items during refinement process in case the deflection
0203   // is too big, thus the vectors should be used.
0204   IntPolyh_ArrayOfPoints TPoints1;
0205   IntPolyh_ArrayOfPoints TPoints2;
0206   IntPolyh_ArrayOfEdges TEdges1;
0207   IntPolyh_ArrayOfEdges TEdges2;
0208   IntPolyh_ArrayOfTriangles TTriangles1;
0209   IntPolyh_ArrayOfTriangles TTriangles2;
0210   // The intersecting triangles are just filled and then
0211   // sequentially analyzed, thus we might use the list.
0212   IntPolyh_ListOfCouples TTrianglesContacts;
0213 
0214   Standard_Boolean myEnlargeZone;
0215 
0216 };
0217 
0218 #endif // _IntPolyh_MaillageAffinage_HeaderFile