Salome HOME
e6b3b6eab975334a758bdaa46b64639adb26f9a6
[plugins/canrecplugin.git] / src / CANRECPLUGINEngine / CANRECPluginEngine_IOperations_i.cc
1 // Copyright (C) 2014-2015  OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include "CANRECPluginEngine_IOperations_i.hh"
21 #include "CANRECPluginImpl_IOperations.hxx"
22
23 #include <utilities.h>
24
25 CANRECPluginEngine_IOperations_i::CANRECPluginEngine_IOperations_i( PortableServer::POA_ptr thePOA, 
26                                                                     GEOM::GEOM_Gen_ptr theEngine, 
27                                                                     CANRECPluginImpl_IOperations* theImpl )
28   : GEOM_IOperations_i( thePOA, theEngine, theImpl )
29 {
30   MESSAGE( "CANRECPluginEngine_IOperations_i::CANRECPluginEngine_IOperations_i()" );
31 }
32
33 CANRECPluginEngine_IOperations_i::~CANRECPluginEngine_IOperations_i()
34 {
35   MESSAGE( "CANRECPluginEngine_IOperations_i::~CANRECPluginEngine_IOperations_i()" );
36 }
37
38 //=============================================================================
39 /*!
40  *  Create a canonical recognition for the object
41  *  \param theMergeSurf set merging surfaces
42  *  \param theMergeCurves set merging curves
43  *  \param theTolerance set tolerance
44  *  \param theObject is initial object
45  *  \return New GEOM_Object, containing the created shape.
46  */
47 //=============================================================================
48 GEOM::GEOM_Object_ptr
49 CANRECPluginEngine_IOperations_i::MakeCanonicalRecognition( GEOM::GEOM_Object_ptr theObject,
50                                                             CORBA::Boolean theMergeSurf,
51                                                             CORBA::Boolean theMergeCurves,
52                                                             CORBA::Double theTolerance )
53 {
54   // Set a not done flag
55   GetOperations()->SetNotDone();
56
57   // Get the reference points
58   Handle(GEOM_Object) anInitObject = GetObjectImpl( theObject );
59
60   if ( anInitObject.IsNull() ) return GEOM::GEOM_Object::_nil();
61
62   // Make Canonical Recognition
63   Handle(GEOM_Object) anObject = GetOperations()->MakeCanonicalRecognition( anInitObject,
64                                                                             theMergeSurf, 
65                                                                             theMergeCurves, 
66                                                                             theTolerance );
67   if ( !GetOperations()->IsDone() || anObject.IsNull() )
68     return GEOM::GEOM_Object::_nil();
69
70   return GetObject( anObject );
71 }
72
73 ::CANRECPluginImpl_IOperations* CANRECPluginEngine_IOperations_i::GetOperations()
74 {
75   return (::CANRECPluginImpl_IOperations*)GetImpl();
76 }