0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / src / BOPAlgo / BOPAlgo_Splitter.cxx
1 // Created by: Eugeny MALTCHIKOV
2 // Copyright (c) 2017 OPEN CASCADE SAS
3 //
4 // This file is part of Open CASCADE Technology software library.
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
11 //
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
14
15
16 #include <BOPAlgo_Splitter.hxx>
17 #include <BOPAlgo_PaveFiller.hxx>
18 #include <BOPAlgo_Alerts.hxx>
19
20 #include <TopoDS_Iterator.hxx>
21
22 //=======================================================================
23 //function : 
24 //purpose  : 
25 //=======================================================================
26 BOPAlgo_Splitter::BOPAlgo_Splitter()
27 : BOPAlgo_ToolsProvider()
28 {
29 }
30 //=======================================================================
31 //function : 
32 //purpose  : 
33 //=======================================================================
34 BOPAlgo_Splitter::BOPAlgo_Splitter(const Handle(NCollection_BaseAllocator)& theAllocator)
35 : BOPAlgo_ToolsProvider(theAllocator)
36 {
37 }
38 //=======================================================================
39 //function : ~
40 //purpose  : 
41 //=======================================================================
42 BOPAlgo_Splitter::~BOPAlgo_Splitter()
43 {
44 }
45 //=======================================================================
46 // function: CheckData
47 // purpose: 
48 //=======================================================================
49 void BOPAlgo_Splitter::CheckData()
50 {
51   if (myArguments.IsEmpty() ||
52       (myArguments.Extent() + myTools.Extent()) < 2) {
53     // too few arguments to process
54     AddError (new BOPAlgo_AlertTooFewArguments);
55     return;
56   }
57   //
58   CheckFiller();
59 }
60
61 //=======================================================================
62 //function : Perform
63 //purpose  : 
64 //=======================================================================
65 void BOPAlgo_Splitter::Perform()
66 {
67   GetReport()->Clear();
68   //
69   if (myEntryPoint == 1) {
70     if (myPaveFiller) {
71       delete myPaveFiller;
72       myPaveFiller = NULL;
73     }
74   }
75   //
76   // prepare shapes for intersection
77   TopTools_ListOfShape aLS;
78   //
79   TopTools_ListIteratorOfListOfShape aItLS(myArguments);
80   for (; aItLS.More(); aItLS.Next()) {
81     aLS.Append(aItLS.Value());
82   }
83   //
84   aItLS.Initialize(myTools);
85   for (; aItLS.More(); aItLS.Next()) {
86     aLS.Append(aItLS.Value());
87   }
88   //
89   BOPAlgo_PaveFiller *pPF = new BOPAlgo_PaveFiller();
90   pPF->SetArguments(aLS);
91   pPF->SetRunParallel(myRunParallel);
92   if (myProgressScope != NULL)
93   {
94     pPF->SetProgressIndicator(*myProgressScope);
95   }
96   pPF->SetFuzzyValue(myFuzzyValue);
97   pPF->SetNonDestructive(myNonDestructive);
98   pPF->SetGlue(myGlue);
99   pPF->SetUseOBB(myUseOBB);
100   //
101   pPF->Perform();
102   //
103   myEntryPoint = 1;
104   PerformInternal(*pPF);
105 }
106
107 //=======================================================================
108 //function : BuildResult
109 //purpose  : 
110 //=======================================================================
111 void BOPAlgo_Splitter::BuildResult(const TopAbs_ShapeEnum theType)
112 {
113   BOPAlgo_Builder::BuildResult(theType);
114
115   if (theType == TopAbs_COMPOUND)
116   {
117     // The method is called for the last time for this operation.
118     // If there is only one argument shape and it has been modified into
119     // a single shape, or has not been modified at all, the result shape
120     // has to be overwritten to avoid the unnecessary enclosure into compound.
121     if (myArguments.Extent() == 1)
122     {
123       TopoDS_Iterator it(myShape);
124       if (it.More())
125       {
126         const TopoDS_Shape& aSFirst = it.Value();
127         it.Next();
128         if (!it.More())
129           myShape = aSFirst;
130       }
131     }
132   }
133 }