1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include "GEOM_IFieldOperations_i.hh"
25 #include "utilities.h"
27 #include "Utils_ExceptHandlers.hxx"
29 #include "GEOM_Engine.hxx"
30 #include "GEOM_Object.hxx"
31 #include "GEOM_Field.hxx"
33 //=============================================================================
37 //=============================================================================
38 GEOM_IFieldOperations_i::GEOM_IFieldOperations_i (PortableServer::POA_ptr thePOA,
39 GEOM::GEOM_Gen_ptr theEngine,
40 ::GEOMImpl_IFieldOperations* theImpl)
41 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
43 MESSAGE("GEOM_IFieldOperations_i::GEOM_IFieldOperations_i");
46 //=============================================================================
50 //=============================================================================
51 GEOM_IFieldOperations_i::~GEOM_IFieldOperations_i()
53 MESSAGE("GEOM_IFieldOperations_i::~GEOM_IFieldOperations_i");
57 //=============================================================================
59 * \brief Creates a field
61 //=============================================================================
64 GEOM_IFieldOperations_i::CreateField(GEOM::GEOM_Object_ptr theShape,
66 GEOM::field_data_type theType,
67 CORBA::Short theDimension,
68 const GEOM::string_array& theComponentNames)
70 GEOM::GEOM_Field_var aField;
72 Handle(TColStd_HArray1OfExtendedString) compNames;
73 if ( theComponentNames.length() > 0 )
75 compNames = new TColStd_HArray1OfExtendedString( 1, theComponentNames.length() );
76 for ( size_t i = 0; i < theComponentNames.length(); ++i )
77 compNames->SetValue( i+1, theComponentNames[ i ].in() );
79 HANDLE_NAMESPACE(GEOM_Object) aShapeRef = GetObjectImpl( theShape );
80 HANDLE_NAMESPACE(GEOM_Field) aFieldRef = GetOperations()->CreateField( aShapeRef,
85 if ( !aFieldRef.IsNull() )
86 aField = GEOM::GEOM_Field::_narrow( GetBaseObject( aFieldRef ));
88 return aField._retn();
91 //=============================================================================
93 * \brief Returns number of fields on a shape
95 //=============================================================================
97 CORBA::Long GEOM_IFieldOperations_i::CountFields( GEOM::GEOM_Object_ptr shape)
99 HANDLE_NAMESPACE(GEOM_Object) go = GetObjectImpl( shape );
101 return ( CORBA::Long) GetOperations()->CountFields( go );
104 //=============================================================================
106 * \brief Returns all fields on a shape
108 //=============================================================================
110 GEOM::ListOfFields* GEOM_IFieldOperations_i::GetFields( GEOM::GEOM_Object_ptr shape )
112 GEOM::ListOfFields_var fields = new GEOM::ListOfFields;
114 HANDLE_NAMESPACE(GEOM_Object) go = GetObjectImpl( shape );
116 Handle(TColStd_HSequenceOfTransient) seq = GetOperations()->GetFields( go );
119 fields->length( seq->Length() );
121 for ( int i = 1; i <= seq->Length(); ++i )
123 HANDLE_NAMESPACE(GEOM_Field) f = HANDLE_NAMESPACE(GEOM_Field)::DownCast( seq->Value( i ));
124 GEOM::GEOM_Field_var fvar = GEOM::GEOM_Field::_narrow( GetBaseObject( f ));
125 if ( !fvar->_is_nil() )
126 fields[ nbF++ ] = fvar._retn();
128 fields->length( nbF );
130 return fields._retn();
133 //=============================================================================
135 * \brief Returns all fields on a shape
137 //=============================================================================
139 GEOM::GEOM_Field_ptr GEOM_IFieldOperations_i::GetField( GEOM::GEOM_Object_ptr shape,
142 GEOM::GEOM_Field_var field;
144 HANDLE_NAMESPACE(GEOM_Object) go = GetObjectImpl( shape );
146 HANDLE_NAMESPACE(GEOM_Field) f = GetOperations()->GetField( go, name );
147 field = GEOM::GEOM_Field::_narrow( GetBaseObject( f ));
149 return field._retn();
152 //=============================================================================
154 * \brief Returns number of sub-shapes of given dimension
156 //=============================================================================
158 ::CORBA::Long GEOM_IFieldOperations_i::GetNbSubShapes(::GEOM::GEOM_Object_ptr shape,
159 ::CORBA::Short fieldDim)
161 HANDLE_NAMESPACE(GEOM_Object) go = GetObjectImpl( shape );
162 return GEOM_Field::GetNbSubShapes( go, fieldDim );