1 // Copyright (C) 2007-2020 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 // SMESH SMESH_I : idl implementation based on 'SMESH' unit's classes
24 // File : StdMeshers_BlockRenumber_i.cxx
25 // Author : Edward AGAPOV
29 #include "StdMeshers_ObjRefUlils.hxx"
30 #include "StdMeshers_BlockRenumber_i.hxx"
31 #include "SMESH_Gen_i.hxx"
32 #include "SMESH_Gen.hxx"
33 #include "SMESH_PythonDump.hxx"
35 #include "Utils_CorbaException.hxx"
37 //=============================================================================
39 * StdMeshers_BlockRenumber_i::StdMeshers_BlockRenumber_i
43 //=============================================================================
45 StdMeshers_BlockRenumber_i::StdMeshers_BlockRenumber_i( PortableServer::POA_ptr thePOA,
46 ::SMESH_Gen* theGenImpl )
47 : SALOME::GenericObj_i( thePOA ),
48 SMESH_Hypothesis_i( thePOA )
50 myBaseImpl = new ::StdMeshers_BlockRenumber( theGenImpl->GetANewId(),
54 //================================================================================
56 * \brief Set orientation of blocks
58 //================================================================================
60 void StdMeshers_BlockRenumber_i::SetBlocksOrientation( const StdMeshers::blockcs_array& blockCS )
64 CORBA::String_var entry;
65 std::vector< StdMeshers_BlockCS > bcsVec( blockCS.length() );
66 for ( size_t i = 0; i < bcsVec.size(); i++ )
68 StdMeshers_BlockCS& bcs = bcsVec[i];
69 if ( !CORBA::is_nil( blockCS[i].solid ) &&
70 !CORBA::is_nil( blockCS[i].vertex000 )&&
71 !CORBA::is_nil( blockCS[i].vertex001 ))
73 entry = blockCS[i].solid->GetStudyEntry();
74 bcs._solid = entry.in();
75 entry = blockCS[i].vertex000->GetStudyEntry();
76 bcs._vertex000 = entry.in();
77 entry = blockCS[i].vertex001->GetStudyEntry();
78 bcs._vertex001 = entry.in();
80 if ( !dump.empty() ) dump << ",\n ";
81 dump << "StdMeshers.BlockCS( "
82 << bcs._solid << ", " << bcs._vertex000 << ", " << bcs._vertex001
86 this->GetImpl()->SetBlocksOrientation( bcsVec );
88 // Update Python script
89 SMESH::TPythonDump() << _this() << ".SetBlocksOrientation([ " << dump << " ])";
91 catch ( SALOME_Exception& S_ex ) {
92 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
96 //================================================================================
98 * \brief Return orientation of blocks
100 //================================================================================
102 StdMeshers::blockcs_array* StdMeshers_BlockRenumber_i::GetBlocksOrientation()
104 const std::vector< StdMeshers_BlockCS >& bcsVec = this->GetImpl()->GetBlocksOrientation();
105 StdMeshers::blockcs_array_var bcsArray = new StdMeshers::blockcs_array();
106 bcsArray->length( bcsVec.size() );
107 TopoDS_Shape nullShape;
108 for ( size_t i = 0; i < bcsVec.size(); ++i )
111 StdMeshers_ObjRefUlils::EntryOrShapeToGeomObject( bcsVec[i]._solid, nullShape );
112 bcsArray[i].vertex000 =
113 StdMeshers_ObjRefUlils::EntryOrShapeToGeomObject( bcsVec[i]._vertex000, nullShape );
114 bcsArray[i].vertex001 =
115 StdMeshers_ObjRefUlils::EntryOrShapeToGeomObject( bcsVec[i]._vertex001, nullShape );
117 return bcsArray._retn();
120 //================================================================================
122 * \brief Return geom entries
124 //================================================================================
127 StdMeshers_BlockRenumber_i::getObjectsDependOn( std::vector< std::string > & entryArray,
128 std::vector< int > & /*subIDArray*/ ) const
130 const std::vector< StdMeshers_BlockCS >& bcsVec =
131 const_cast<StdMeshers_BlockRenumber_i*>(this)->GetImpl()->GetBlocksOrientation();
132 entryArray.reserve( entryArray.capacity() + 3 * bcsVec.size());
133 for ( size_t i = 0; i < bcsVec.size(); ++i )
135 entryArray.push_back( bcsVec[i]._solid );
136 entryArray.push_back( bcsVec[i]._vertex000 );
137 entryArray.push_back( bcsVec[i]._vertex001 );
139 return !bcsVec.empty();
142 //================================================================================
144 * \brief Update geom entries for a new geometry
146 //================================================================================
148 bool StdMeshers_BlockRenumber_i::setObjectsDependOn( std::vector< std::string > & entryArray,
149 std::vector< int > & /*subIDArray*/ )
151 std::vector< StdMeshers_BlockCS > bcsVec( entryArray.size() / 3 );
152 for ( size_t i = 0; i + 2 < entryArray.size(); i += 3 )
154 StdMeshers_BlockCS& bcs = bcsVec[i];
155 bcs._solid = entryArray[ i ];
156 bcs._vertex000 = entryArray[ i + 1 ];
157 bcs._vertex001 = entryArray[ i + 2 ];
159 this->GetImpl()->SetBlocksOrientation( bcsVec );
164 //=============================================================================
166 * StdMeshers_BlockRenumber_i::GetImpl
170 //=============================================================================
172 ::StdMeshers_BlockRenumber* StdMeshers_BlockRenumber_i::GetImpl()
174 return ( ::StdMeshers_BlockRenumber* )myBaseImpl;
177 //================================================================================
179 * \brief Verify whether hypothesis supports given entity type
180 * \param type - dimension (see SMESH::Dimension enumeration)
181 * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
183 * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
185 //================================================================================
186 CORBA::Boolean StdMeshers_BlockRenumber_i::IsDimSupported( SMESH::Dimension type )
188 return type == SMESH::DIM_3D;