0031668: Visualization - WebGL sample doesn't work on Emscripten 1.39
[occt.git] / src / BOPAlgo / BOPAlgo_BuilderSolid.hxx
CommitLineData
42cf5bc1 1// Created by: Peter KURNEV
2// Copyright (c) 2010-2014 OPEN CASCADE SAS
3// Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
4// Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
5// EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6//
7// This file is part of Open CASCADE Technology software library.
8//
9// This library is free software; you can redistribute it and/or modify it under
10// the terms of the GNU Lesser General Public License version 2.1 as published
11// by the Free Software Foundation, with special exception defined in the file
12// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
13// distribution for complete text of the license and disclaimer of any warranty.
14//
15// Alternatively, this file may be used under the terms of Open CASCADE
16// commercial license or contractual agreement.
17
18#ifndef _BOPAlgo_BuilderSolid_HeaderFile
19#define _BOPAlgo_BuilderSolid_HeaderFile
20
21#include <Standard.hxx>
22#include <Standard_DefineAlloc.hxx>
23#include <Standard_Handle.hxx>
24
42cf5bc1 25#include <BOPAlgo_BuilderArea.hxx>
1155d05a 26#include <NCollection_BaseAllocator.hxx>
27#include <TopTools_DataMapOfShapeBox.hxx>
42cf5bc1 28
29
7f3408c8 30//! Solid Builder is the algorithm for building solids from set of faces.
31//! The given faces should be non-intersecting, i.e. all coinciding parts
32//! of the faces should be shared among them.
33//!
34//! The algorithm performs the following steps to build the solids:
35//! 1. Find:
36//! - faces orientated INTERNAL;
37//! - alone faces given twice with different orientation;
38//! 2. Build all possible closed shells from the rest of the faces
39//! (*BOPAlgo_ShellSplitter* is used for that);
40//! 3. Classify the obtained shells on the Holes and Growths;
41//! 4. Build solids from the Growth shells, put Hole shells into closest Growth solids;
42//! 5. Classify all unused faces relatively created solids and put them as internal
43//! shells into the closest solids;
44//! 6. Find all unclassified faces, i.e. faces outside of all created solids,
45//! make internal shells from them and put these shells into a warning.
46//!
47//! It is possible to avoid all internal shells in the resulting solids.
48//! For that it is necessary to use the method SetAvoidInternalShapes(true)
49//! of the base class. In this case the steps 5 and 6 will not be performed at all.
50//!
51//! The algorithm may return the following warnings:
52//! - *BOPAlgo_AlertShellSplitterFailed* in case the ShellSplitter algorithm has failed;
53//! - *BOPAlgo_AlertSolidBuilderUnusedFaces* in case there are some faces outside of
54//! created solids left.
55//!
56//! Example of usage of the algorithm:
57//! ~~~~
58//! const TopTools_ListOfShape& aFaces = ...; // Faces to build the solids
59//! Standard_Boolean isAvoidInternals = ...; // Flag which defines whether to create the internal shells or not
60//! BOPAlgo_BuilderSolid aBS; // Solid Builder tool
61//! aBS.SetShapes(aFaces); // Set the faces
62//! aBS.SetAvoidInternalShapes(isAvoidInternals); // Set the AvoidInternalShapesFlag
63//! aBS.Perform(); // Perform the operation
64//! if (!aBS.IsDone()) // Check for the errors
65//! {
66//! // error treatment
67//! Standard_SStream aSStream;
68//! aBS.DumpErrors(aSStream);
69//! return;
70//! }
71//! if (aBS.HasWarnings()) // Check for the warnings
72//! {
73//! // warnings treatment
74//! Standard_SStream aSStream;
75//! aBS.DumpWarnings(aSStream);
76//! }
77//!
78//! const TopTools_ListOfShape& aSolids = aBS.Areas(); // Obtaining the result solids
79//! ~~~~
80//!
42cf5bc1 81class BOPAlgo_BuilderSolid : public BOPAlgo_BuilderArea
82{
83public:
84
85 DEFINE_STANDARD_ALLOC
86
7f3408c8 87public: //! @name Constructors
88
89 //! Empty constructor
42cf5bc1 90 Standard_EXPORT BOPAlgo_BuilderSolid();
7f3408c8 91 Standard_EXPORT virtual ~BOPAlgo_BuilderSolid();
92
93 //! Constructor with allocator
1155d05a 94 Standard_EXPORT BOPAlgo_BuilderSolid(const Handle(NCollection_BaseAllocator)& theAllocator);
7f3408c8 95
96public: //! @name Performing the operation
97
98 //! Performs the construction of the solids from the given faces
42cf5bc1 99 Standard_EXPORT virtual void Perform() Standard_OVERRIDE;
100
7f3408c8 101public: //! @name Getting the bounding boxes of the created solids
102
103 //! For classification purposes the algorithm builds the bounding boxes
104 //! for all created solids. This method returns the data map of solid - box pairs.
1155d05a 105 const TopTools_DataMapOfShapeBox& GetBoxesMap() const
b7cd7c2b 106 {
107 return myBoxes;
108 }
109
7f3408c8 110protected: //! @name Protected methods performing the operation
111
112 //! Collect the faces:
113 //! - with INTERNAL orientation;
114 //! - that are alone but given twice with different orientation.
115 //! These faces will be put into the map *myShapesToAvoid* and will be
116 //! avoided in shells construction, but will be classified later on.
42cf5bc1 117 Standard_EXPORT virtual void PerformShapesToAvoid() Standard_OVERRIDE;
42cf5bc1 118
7f3408c8 119 //! Build all possible closed shells from the given faces.
120 //! The method fills the following maps:
121 //! - myLoops - Created closed shells;
122 //! - myLoopsInternal - The shells created from unused faces.
123 Standard_EXPORT virtual void PerformLoops() Standard_OVERRIDE;
42cf5bc1 124
7f3408c8 125 //! Classifies the created shells on the Holes and Growths.
126 //! Creates the solids from the Growths shells.
127 //! Puts the Hole shells into the closest Growths solids.
128 Standard_EXPORT virtual void PerformAreas() Standard_OVERRIDE;
42cf5bc1 129
7f3408c8 130 //! Classifies the unused faces relatively the created solids.
131 //! Puts the classified faces into the closest solids as internal shells.
132 //! Warns the user about unclassified faces if any.
133 Standard_EXPORT virtual void PerformInternalShapes() Standard_OVERRIDE;
42cf5bc1 134
135private:
136
1155d05a 137 TopTools_DataMapOfShapeBox myBoxes; // Boxes of the produced solids
42cf5bc1 138
139};
140
42cf5bc1 141#endif // _BOPAlgo_BuilderSolid_HeaderFile