Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:09

0001 // Created on: 1995-03-23
0002 // Created by: Jing Cheng MEI
0003 // Copyright (c) 1995-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 _BRepBuilderAPI_Sewing_HeaderFile
0018 #define _BRepBuilderAPI_Sewing_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_Type.hxx>
0022 
0023 #include <TopTools_IndexedDataMapOfShapeShape.hxx>
0024 #include <TopoDS_Shape.hxx>
0025 #include <TopTools_IndexedMapOfShape.hxx>
0026 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
0027 #include <TopTools_DataMapOfShapeShape.hxx>
0028 #include <Standard_Integer.hxx>
0029 #include <TopTools_DataMapOfShapeListOfShape.hxx>
0030 #include <TopTools_MapOfShape.hxx>
0031 #include <Standard_Transient.hxx>
0032 #include <TopTools_ListOfShape.hxx>
0033 #include <TopTools_SequenceOfShape.hxx>
0034 #include <TColStd_IndexedMapOfInteger.hxx>
0035 #include <TColStd_SequenceOfBoolean.hxx>
0036 #include <TColStd_SequenceOfInteger.hxx>
0037 #include <TColStd_Array1OfBoolean.hxx>
0038 #include <TColStd_Array1OfReal.hxx>
0039 #include <TColgp_Array1OfPnt.hxx>
0040 #include <TColStd_SequenceOfReal.hxx>
0041 
0042 #include <Message_ProgressRange.hxx>
0043 
0044 class BRepTools_ReShape;
0045 class TopoDS_Edge;
0046 class TopoDS_Face;
0047 class Geom_Surface;
0048 class TopLoc_Location;
0049 class Geom2d_Curve;
0050 class Geom_Curve;
0051 
0052 
0053 class BRepBuilderAPI_Sewing;
0054 DEFINE_STANDARD_HANDLE(BRepBuilderAPI_Sewing, Standard_Transient)
0055 
0056 //! Provides methods to
0057 //!
0058 //! - identify possible contiguous boundaries (for control
0059 //! afterwards (of continuity: C0, C1, ...))
0060 //!
0061 //! - assemble contiguous shapes into one shape.
0062 //! Only manifold shapes will be found. Sewing will not
0063 //! be done in case of multiple edges.
0064 //!
0065 //! For sewing, use this function as following:
0066 //! - create an empty object
0067 //! - default tolerance 1.E-06
0068 //! - with face analysis on
0069 //! - with sewing operation on
0070 //! - set the cutting option as you need (default True)
0071 //! - define a tolerance
0072 //! - add shapes to be sewed -> Add
0073 //! - compute -> Perfom
0074 //! - output the resulted shapes
0075 //! - output free edges if necessary
0076 //! - output multiple edges if necessary
0077 //! - output the problems if any
0078 class BRepBuilderAPI_Sewing : public Standard_Transient
0079 {
0080 
0081 public:
0082 
0083   
0084   //! Creates an object with
0085   //! tolerance of connexity
0086   //! option for sewing (if false only control)
0087   //! option for analysis of degenerated shapes
0088   //! option for cutting of free edges.
0089   //! option for non manifold processing
0090   Standard_EXPORT BRepBuilderAPI_Sewing(const Standard_Real tolerance = 1.0e-06, const Standard_Boolean option1 = Standard_True, const Standard_Boolean option2 = Standard_True, const Standard_Boolean option3 = Standard_True, const Standard_Boolean option4 = Standard_False);
0091   
0092   //! initialize the parameters if necessary
0093   Standard_EXPORT void Init (const Standard_Real tolerance = 1.0e-06, const Standard_Boolean option1 = Standard_True, const Standard_Boolean option2 = Standard_True, const Standard_Boolean option3 = Standard_True, const Standard_Boolean option4 = Standard_False);
0094   
0095   //! Loades the context shape.
0096   Standard_EXPORT void Load (const TopoDS_Shape& shape);
0097   
0098   //! Defines the shapes to be sewed or controlled
0099   Standard_EXPORT void Add (const TopoDS_Shape& shape);
0100   
0101   //! Computing
0102   //! theProgress - progress indicator of algorithm
0103   Standard_EXPORT void Perform (const Message_ProgressRange& theProgress = Message_ProgressRange());
0104   
0105   //! Gives the sewed shape
0106   //! a null shape if nothing constructed
0107   //! may be a face, a shell, a solid or a compound
0108   Standard_EXPORT const TopoDS_Shape& SewedShape() const;
0109   
0110   //! set context
0111   Standard_EXPORT void SetContext (const Handle(BRepTools_ReShape)& theContext);
0112   
0113   //! return context
0114   Standard_EXPORT const Handle(BRepTools_ReShape)& GetContext() const;
0115   
0116   //! Gives the number of free edges (edge shared by one face)
0117   Standard_EXPORT Standard_Integer NbFreeEdges() const;
0118   
0119   //! Gives each free edge
0120   Standard_EXPORT const TopoDS_Edge& FreeEdge (const Standard_Integer index) const;
0121   
0122   //! Gives the number of multiple edges
0123   //! (edge shared by more than two faces)
0124   Standard_EXPORT Standard_Integer NbMultipleEdges() const;
0125   
0126   //! Gives each multiple edge
0127   Standard_EXPORT const TopoDS_Edge& MultipleEdge (const Standard_Integer index) const;
0128   
0129   //! Gives the number of contiguous edges (edge shared by two faces)
0130   Standard_EXPORT Standard_Integer NbContigousEdges() const;
0131   
0132   //! Gives each contiguous edge
0133   Standard_EXPORT const TopoDS_Edge& ContigousEdge (const Standard_Integer index) const;
0134   
0135   //! Gives the sections (edge) belonging to a contiguous edge
0136   Standard_EXPORT const TopTools_ListOfShape& ContigousEdgeCouple (const Standard_Integer index) const;
0137   
0138   //! Indicates if a section is bound (before use SectionToBoundary)
0139   Standard_EXPORT Standard_Boolean IsSectionBound (const TopoDS_Edge& section) const;
0140   
0141   //! Gives the original edge (free boundary) which becomes the
0142   //! the section. Remember that sections constitute  common edges.
0143   //! This imformation is important for control because with
0144   //! original edge we can find the surface to which the section
0145   //! is attached.
0146   Standard_EXPORT const TopoDS_Edge& SectionToBoundary (const TopoDS_Edge& section) const;
0147   
0148   //! Gives the number of degenerated shapes
0149   Standard_EXPORT Standard_Integer NbDegeneratedShapes() const;
0150   
0151   //! Gives each degenerated shape
0152   Standard_EXPORT const TopoDS_Shape& DegeneratedShape (const Standard_Integer index) const;
0153   
0154   //! Indicates if a input shape is degenerated
0155   Standard_EXPORT Standard_Boolean IsDegenerated (const TopoDS_Shape& shape) const;
0156   
0157   //! Indicates if a input shape has been modified
0158   Standard_EXPORT Standard_Boolean IsModified (const TopoDS_Shape& shape) const;
0159   
0160   //! Gives a modifieded shape
0161   Standard_EXPORT const TopoDS_Shape& Modified (const TopoDS_Shape& shape) const;
0162   
0163   //! Indicates if a input subshape has been modified
0164   Standard_EXPORT Standard_Boolean IsModifiedSubShape (const TopoDS_Shape& shape) const;
0165   
0166   //! Gives a modifieded subshape
0167   Standard_EXPORT TopoDS_Shape ModifiedSubShape (const TopoDS_Shape& shape) const;
0168   
0169   //! print the information
0170   Standard_EXPORT void Dump() const;
0171   
0172   //! Gives the number of deleted faces (faces smallest than tolerance)
0173   Standard_EXPORT Standard_Integer NbDeletedFaces() const;
0174   
0175   //! Gives each deleted face
0176   Standard_EXPORT const TopoDS_Face& DeletedFace (const Standard_Integer index) const;
0177   
0178   //! Gives a modified shape
0179   Standard_EXPORT TopoDS_Face WhichFace (const TopoDS_Edge& theEdg, const Standard_Integer index = 1) const;
0180   
0181   //! Gets same parameter mode.
0182     Standard_Boolean SameParameterMode() const;
0183   
0184   //! Sets same parameter mode.
0185     void SetSameParameterMode (const Standard_Boolean SameParameterMode);
0186   
0187   //! Gives set tolerance.
0188     Standard_Real Tolerance() const;
0189   
0190   //! Sets tolerance
0191     void SetTolerance (const Standard_Real theToler);
0192   
0193   //! Gives set min tolerance.
0194     Standard_Real MinTolerance() const;
0195   
0196   //! Sets min tolerance
0197     void SetMinTolerance (const Standard_Real theMinToler);
0198   
0199   //! Gives set max tolerance
0200     Standard_Real MaxTolerance() const;
0201   
0202   //! Sets max tolerance.
0203     void SetMaxTolerance (const Standard_Real theMaxToler);
0204   
0205   //! Returns mode for sewing faces By default - true.
0206     Standard_Boolean FaceMode() const;
0207   
0208   //! Sets mode for sewing faces By default - true.
0209     void SetFaceMode (const Standard_Boolean theFaceMode);
0210   
0211   //! Returns mode for sewing floating edges By default - false.
0212     Standard_Boolean FloatingEdgesMode() const;
0213   
0214   //! Sets mode for sewing floating edges By default - false.
0215   //! Returns mode for cutting floating edges By default - false.
0216   //! Sets mode for cutting floating edges By default - false.
0217     void SetFloatingEdgesMode (const Standard_Boolean theFloatingEdgesMode);
0218   
0219   //! Returns mode for accounting of local tolerances
0220   //! of edges and vertices during of merging.
0221     Standard_Boolean LocalTolerancesMode() const;
0222   
0223   //! Sets mode for accounting of local tolerances
0224   //! of edges and vertices during of merging
0225   //! in this case WorkTolerance = myTolerance + tolEdge1+ tolEdg2;
0226     void SetLocalTolerancesMode (const Standard_Boolean theLocalTolerancesMode);
0227   
0228   //! Sets mode for non-manifold sewing.
0229     void SetNonManifoldMode (const Standard_Boolean theNonManifoldMode);
0230   
0231   //! Gets mode for non-manifold sewing.
0232   //!
0233   //! INTERNAL FUNCTIONS ---
0234     Standard_Boolean NonManifoldMode() const;
0235 
0236 
0237 
0238 
0239   DEFINE_STANDARD_RTTIEXT(BRepBuilderAPI_Sewing,Standard_Transient)
0240 
0241 protected:
0242 
0243   
0244   //! Performs cutting of sections
0245   //! theProgress - progress indicator of processing
0246   Standard_EXPORT void Cutting (const Message_ProgressRange& theProgress = Message_ProgressRange());
0247   
0248   Standard_EXPORT void Merging (const Standard_Boolean passage, const Message_ProgressRange& theProgress = Message_ProgressRange());
0249   
0250   Standard_EXPORT Standard_Boolean IsMergedClosed (const TopoDS_Edge& Edge1, const TopoDS_Edge& Edge2, const TopoDS_Face& fase) const;
0251   
0252   Standard_EXPORT Standard_Boolean FindCandidates (TopTools_SequenceOfShape& seqSections, TColStd_IndexedMapOfInteger& mapReference, TColStd_SequenceOfInteger& seqCandidates, TColStd_SequenceOfBoolean& seqOrientations);
0253   
0254   Standard_EXPORT void AnalysisNearestEdges (const TopTools_SequenceOfShape& sequenceSec, TColStd_SequenceOfInteger& seqIndCandidate, TColStd_SequenceOfBoolean& seqOrientations, const Standard_Boolean evalDist = Standard_True);
0255   
0256   //! Merged nearest edges.
0257   Standard_EXPORT Standard_Boolean MergedNearestEdges (const TopoDS_Shape& edge, TopTools_SequenceOfShape& SeqMergedEdge, TColStd_SequenceOfBoolean& SeqMergedOri);
0258   
0259   Standard_EXPORT void EdgeProcessing (const Message_ProgressRange& theProgress = Message_ProgressRange());
0260 
0261   //! Recompute regularity on merged edges
0262   Standard_EXPORT void EdgeRegularity (const Message_ProgressRange& theProgress = Message_ProgressRange());
0263   
0264   Standard_EXPORT void CreateOutputInformations();
0265   
0266   //! Defines if surface is U closed.
0267   Standard_EXPORT virtual Standard_Boolean IsUClosedSurface (const Handle(Geom_Surface)& surf, const TopoDS_Shape& theEdge, const TopLoc_Location& theloc) const;
0268   
0269   //! Defines if surface is V closed.
0270   Standard_EXPORT virtual Standard_Boolean IsVClosedSurface (const Handle(Geom_Surface)& surf, const TopoDS_Shape& theEdge, const TopLoc_Location& theloc) const;
0271   
0272 
0273   //! This method is called from Perform only
0274   //! theProgress - progress indicator of processing
0275   Standard_EXPORT virtual void FaceAnalysis (const Message_ProgressRange& theProgress = Message_ProgressRange());
0276   
0277 
0278   //! This method is called from Perform only
0279   Standard_EXPORT virtual void FindFreeBoundaries();
0280   
0281 
0282   //! This method is called from Perform only
0283   //! theProgress - progress indicator of processing
0284   Standard_EXPORT virtual void VerticesAssembling (const Message_ProgressRange& theProgress = Message_ProgressRange());
0285   
0286 
0287   //! This method is called from Perform only
0288   Standard_EXPORT virtual void CreateSewedShape();
0289   
0290   //! Get wire from free edges.
0291   //! This method is called from EdgeProcessing only
0292   Standard_EXPORT virtual void GetFreeWires (TopTools_IndexedMapOfShape& MapFreeEdges,
0293                                              TopTools_SequenceOfShape& seqWires);
0294   
0295 
0296   //! This method is called from MergingOfSections only
0297   Standard_EXPORT virtual void EvaluateAngulars (TopTools_SequenceOfShape& sequenceSec, TColStd_Array1OfBoolean& secForward, TColStd_Array1OfReal& tabAng, const Standard_Integer indRef) const;
0298   
0299 
0300   //! This method is called from MergingOfSections only
0301   Standard_EXPORT virtual void EvaluateDistances (TopTools_SequenceOfShape& sequenceSec, TColStd_Array1OfBoolean& secForward, TColStd_Array1OfReal& tabAng, TColStd_Array1OfReal& arrLen, TColStd_Array1OfReal& tabMinDist, const Standard_Integer indRef) const;
0302   
0303 
0304   //! This method is called from SameParameterEdge only
0305   Standard_EXPORT virtual Handle(Geom2d_Curve) SameRange (const Handle(Geom2d_Curve)& CurvePtr, const Standard_Real FirstOnCurve, const Standard_Real LastOnCurve, const Standard_Real RequestedFirst, const Standard_Real RequestedLast) const;
0306   
0307 
0308   //! This method is called from SameParameterEdge only
0309   Standard_EXPORT virtual void SameParameter (const TopoDS_Edge& edge) const;
0310   
0311 
0312   //! This method is called from Merging only
0313   Standard_EXPORT virtual TopoDS_Edge SameParameterEdge (const TopoDS_Shape& edge, const TopTools_SequenceOfShape& seqEdges, const TColStd_SequenceOfBoolean& seqForward, TopTools_MapOfShape& mapMerged, const Handle(BRepTools_ReShape)& locReShape);
0314   
0315 
0316   //! This method is called from Merging only
0317   Standard_EXPORT virtual TopoDS_Edge SameParameterEdge (const TopoDS_Edge& edge1, const TopoDS_Edge& edge2, const TopTools_ListOfShape& listFaces1, const TopTools_ListOfShape& listFaces2, const Standard_Boolean secForward, Standard_Integer& whichSec, const Standard_Boolean firstCall = Standard_True);
0318   
0319   //! Projects points on curve
0320   //! This method is called from Cutting only
0321   Standard_EXPORT void ProjectPointsOnCurve (const TColgp_Array1OfPnt& arrPnt, const Handle(Geom_Curve)& Crv, const Standard_Real first, const Standard_Real last, TColStd_Array1OfReal& arrDist, TColStd_Array1OfReal& arrPara, TColgp_Array1OfPnt& arrProj, const Standard_Boolean isConsiderEnds) const;
0322   
0323   //! Creates cutting vertices on projections
0324   //! This method is called from Cutting only
0325   Standard_EXPORT virtual void CreateCuttingNodes (const TopTools_IndexedMapOfShape& MapVert, const TopoDS_Shape& bound, const TopoDS_Shape& vfirst, const TopoDS_Shape& vlast, const TColStd_Array1OfReal& arrDist, const TColStd_Array1OfReal& arrPara, const TColgp_Array1OfPnt& arrPnt, TopTools_SequenceOfShape& seqNode, TColStd_SequenceOfReal& seqPara);
0326   
0327   //! Performs cutting of bound
0328   //! This method is called from Cutting only
0329   Standard_EXPORT virtual void CreateSections (const TopoDS_Shape& bound, const TopTools_SequenceOfShape& seqNode, const TColStd_SequenceOfReal& seqPara, TopTools_ListOfShape& listEdge);
0330   
0331   //! Makes all edges from shape same parameter
0332   //! if SameParameterMode is equal to Standard_True
0333   //! This method is called from Perform only
0334   Standard_EXPORT virtual void SameParameterShape();
0335 
0336   Standard_Real myTolerance;
0337   Standard_Boolean mySewing;
0338   Standard_Boolean myAnalysis;
0339   Standard_Boolean myCutting;
0340   Standard_Boolean myNonmanifold;
0341   TopTools_IndexedDataMapOfShapeShape myOldShapes;
0342   TopoDS_Shape mySewedShape;
0343   TopTools_IndexedMapOfShape myDegenerated;
0344   TopTools_IndexedMapOfShape myFreeEdges;
0345   TopTools_IndexedMapOfShape myMultipleEdges;
0346   TopTools_IndexedDataMapOfShapeListOfShape myContigousEdges;
0347   TopTools_DataMapOfShapeShape myContigSecBound;
0348   Standard_Integer myNbShapes;
0349   Standard_Integer myNbVertices;
0350   Standard_Integer myNbEdges;
0351   TopTools_IndexedDataMapOfShapeListOfShape myBoundFaces;
0352   TopTools_DataMapOfShapeListOfShape myBoundSections;
0353   TopTools_DataMapOfShapeShape mySectionBound;
0354   TopTools_IndexedDataMapOfShapeShape myVertexNode;
0355   TopTools_IndexedDataMapOfShapeShape myVertexNodeFree;
0356   TopTools_DataMapOfShapeListOfShape myNodeSections;
0357   TopTools_DataMapOfShapeListOfShape myCuttingNode;
0358   TopTools_IndexedMapOfShape myLittleFace;
0359   TopoDS_Shape myShape;
0360   Handle(BRepTools_ReShape) myReShape;
0361 
0362 
0363 private:
0364 
0365 
0366   Standard_Boolean myFaceMode;
0367   Standard_Boolean myFloatingEdgesMode;
0368   Standard_Boolean mySameParameterMode;
0369   Standard_Boolean myLocalToleranceMode;
0370   Standard_Real myMinTolerance;
0371   Standard_Real myMaxTolerance;
0372   TopTools_MapOfShape myMergedEdges;
0373 
0374 
0375 };
0376 
0377 
0378 #include <BRepBuilderAPI_Sewing.lxx>
0379 
0380 
0381 
0382 
0383 
0384 #endif // _BRepBuilderAPI_Sewing_HeaderFile