PageRenderTime 162ms CodeModel.GetById 41ms RepoModel.GetById 0ms app.codeStats 0ms

/Library/VisItLib/avt/DBAtts/MetaData/avtVectorMetaData.C

https://github.com/robertmaynard/VisIt-Bridge
C++ | 556 lines | 144 code | 54 blank | 358 comment | 14 complexity | cfa09b38388a0c9b5ff7ade623e7340d MD5 | raw file
  1. /*****************************************************************************
  2. *
  3. * Copyright (c) 2000 - 2013, Lawrence Livermore National Security, LLC
  4. * Produced at the Lawrence Livermore National Laboratory
  5. * LLNL-CODE-442911
  6. * All rights reserved.
  7. *
  8. * This file is part of VisIt. For details, see https://visit.llnl.gov/. The
  9. * full copyright notice is contained in the file COPYRIGHT located at the root
  10. * of the VisIt distribution or at http://www.llnl.gov/visit/copyright.html.
  11. *
  12. * Redistribution and use in source and binary forms, with or without
  13. * modification, are permitted provided that the following conditions are met:
  14. *
  15. * - Redistributions of source code must retain the above copyright notice,
  16. * this list of conditions and the disclaimer below.
  17. * - Redistributions in binary form must reproduce the above copyright notice,
  18. * this list of conditions and the disclaimer (as noted below) in the
  19. * documentation and/or other materials provided with the distribution.
  20. * - Neither the name of the LLNS/LLNL nor the names of its contributors may
  21. * be used to endorse or promote products derived from this software without
  22. * specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  25. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  27. * ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY,
  28. * LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY
  29. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  30. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  31. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  32. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  33. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  34. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
  35. * DAMAGE.
  36. *
  37. *****************************************************************************/
  38. #include <avtVectorMetaData.h>
  39. #include <DataNode.h>
  40. // ****************************************************************************
  41. // Method: avtVectorMetaData::avtVectorMetaData
  42. //
  43. // Purpose:
  44. // Init utility for the avtVectorMetaData class.
  45. //
  46. // Note: Autogenerated by xml2atts.
  47. //
  48. // Programmer: xml2atts
  49. // Creation: omitted
  50. //
  51. // Modifications:
  52. //
  53. // ****************************************************************************
  54. void avtVectorMetaData::Init()
  55. {
  56. varDim = 0;
  57. avtVectorMetaData::SelectAll();
  58. }
  59. // ****************************************************************************
  60. // Method: avtVectorMetaData::avtVectorMetaData
  61. //
  62. // Purpose:
  63. // Copy utility for the avtVectorMetaData class.
  64. //
  65. // Note: Autogenerated by xml2atts.
  66. //
  67. // Programmer: xml2atts
  68. // Creation: omitted
  69. //
  70. // Modifications:
  71. //
  72. // ****************************************************************************
  73. void avtVectorMetaData::Copy(const avtVectorMetaData &obj)
  74. {
  75. varDim = obj.varDim;
  76. avtVectorMetaData::SelectAll();
  77. }
  78. // Type map format string
  79. const char *avtVectorMetaData::TypeMapFormatString = AVTVECTORMETADATA_TMFS;
  80. const AttributeGroup::private_tmfs_t avtVectorMetaData::TmfsStruct = {AVTVECTORMETADATA_TMFS};
  81. // ****************************************************************************
  82. // Method: avtVectorMetaData::avtVectorMetaData
  83. //
  84. // Purpose:
  85. // Default constructor for the avtVectorMetaData class.
  86. //
  87. // Note: Autogenerated by xml2atts.
  88. //
  89. // Programmer: xml2atts
  90. // Creation: omitted
  91. //
  92. // Modifications:
  93. //
  94. // ****************************************************************************
  95. avtVectorMetaData::avtVectorMetaData() :
  96. avtVarMetaData(avtVectorMetaData::TmfsStruct)
  97. {
  98. avtVectorMetaData::Init();
  99. }
  100. // ****************************************************************************
  101. // Method: avtVectorMetaData::avtVectorMetaData
  102. //
  103. // Purpose:
  104. // Constructor for the derived classes of avtVectorMetaData class.
  105. //
  106. // Note: Autogenerated by xml2atts.
  107. //
  108. // Programmer: xml2atts
  109. // Creation: omitted
  110. //
  111. // Modifications:
  112. //
  113. // ****************************************************************************
  114. avtVectorMetaData::avtVectorMetaData(private_tmfs_t tmfs) :
  115. avtVarMetaData(tmfs)
  116. {
  117. avtVectorMetaData::Init();
  118. }
  119. // ****************************************************************************
  120. // Method: avtVectorMetaData::avtVectorMetaData
  121. //
  122. // Purpose:
  123. // Copy constructor for the avtVectorMetaData class.
  124. //
  125. // Note: Autogenerated by xml2atts.
  126. //
  127. // Programmer: xml2atts
  128. // Creation: omitted
  129. //
  130. // Modifications:
  131. //
  132. // ****************************************************************************
  133. avtVectorMetaData::avtVectorMetaData(const avtVectorMetaData &obj) :
  134. avtVarMetaData(obj,avtVectorMetaData::TmfsStruct)
  135. {
  136. avtVectorMetaData::Copy(obj);
  137. }
  138. // ****************************************************************************
  139. // Method: avtVectorMetaData::avtVectorMetaData
  140. //
  141. // Purpose:
  142. // Copy constructor for derived classes of the avtVectorMetaData class.
  143. //
  144. // Note: Autogenerated by xml2atts.
  145. //
  146. // Programmer: xml2atts
  147. // Creation: omitted
  148. //
  149. // Modifications:
  150. //
  151. // ****************************************************************************
  152. avtVectorMetaData::avtVectorMetaData(const avtVectorMetaData &obj, private_tmfs_t tmfs) :
  153. avtVarMetaData(obj,tmfs)
  154. {
  155. avtVectorMetaData::Copy(obj);
  156. }
  157. // ****************************************************************************
  158. // Method: avtVectorMetaData::~avtVectorMetaData
  159. //
  160. // Purpose:
  161. // Destructor for the avtVectorMetaData class.
  162. //
  163. // Note: Autogenerated by xml2atts.
  164. //
  165. // Programmer: xml2atts
  166. // Creation: omitted
  167. //
  168. // Modifications:
  169. //
  170. // ****************************************************************************
  171. avtVectorMetaData::~avtVectorMetaData()
  172. {
  173. // nothing here
  174. }
  175. // ****************************************************************************
  176. // Method: avtVectorMetaData::operator =
  177. //
  178. // Purpose:
  179. // Assignment operator for the avtVectorMetaData class.
  180. //
  181. // Note: Autogenerated by xml2atts.
  182. //
  183. // Programmer: xml2atts
  184. // Creation: omitted
  185. //
  186. // Modifications:
  187. //
  188. // ****************************************************************************
  189. avtVectorMetaData&
  190. avtVectorMetaData::operator = (const avtVectorMetaData &obj)
  191. {
  192. if (this == &obj) return *this;
  193. // call the base class' assignment operator first
  194. avtVarMetaData::operator=(obj);
  195. avtVectorMetaData::Copy(obj);
  196. return *this;
  197. }
  198. // ****************************************************************************
  199. // Method: avtVectorMetaData::operator ==
  200. //
  201. // Purpose:
  202. // Comparison operator == for the avtVectorMetaData class.
  203. //
  204. // Note: Autogenerated by xml2atts.
  205. //
  206. // Programmer: xml2atts
  207. // Creation: omitted
  208. //
  209. // Modifications:
  210. //
  211. // ****************************************************************************
  212. bool
  213. avtVectorMetaData::operator == (const avtVectorMetaData &obj) const
  214. {
  215. // Create the return value
  216. return ((varDim == obj.varDim) &&
  217. avtVarMetaData::operator==(obj));
  218. }
  219. // ****************************************************************************
  220. // Method: avtVectorMetaData::operator !=
  221. //
  222. // Purpose:
  223. // Comparison operator != for the avtVectorMetaData class.
  224. //
  225. // Note: Autogenerated by xml2atts.
  226. //
  227. // Programmer: xml2atts
  228. // Creation: omitted
  229. //
  230. // Modifications:
  231. //
  232. // ****************************************************************************
  233. bool
  234. avtVectorMetaData::operator != (const avtVectorMetaData &obj) const
  235. {
  236. return !(this->operator == (obj));
  237. }
  238. // ****************************************************************************
  239. // Method: avtVectorMetaData::TypeName
  240. //
  241. // Purpose:
  242. // Type name method for the avtVectorMetaData class.
  243. //
  244. // Note: Autogenerated by xml2atts.
  245. //
  246. // Programmer: xml2atts
  247. // Creation: omitted
  248. //
  249. // Modifications:
  250. //
  251. // ****************************************************************************
  252. const std::string
  253. avtVectorMetaData::TypeName() const
  254. {
  255. return "avtVectorMetaData";
  256. }
  257. // ****************************************************************************
  258. // Method: avtVectorMetaData::CopyAttributes
  259. //
  260. // Purpose:
  261. // CopyAttributes method for the avtVectorMetaData class.
  262. //
  263. // Note: Autogenerated by xml2atts.
  264. //
  265. // Programmer: xml2atts
  266. // Creation: omitted
  267. //
  268. // Modifications:
  269. //
  270. // ****************************************************************************
  271. bool
  272. avtVectorMetaData::CopyAttributes(const AttributeGroup *atts)
  273. {
  274. if(TypeName() != atts->TypeName())
  275. return false;
  276. // Call assignment operator.
  277. const avtVectorMetaData *tmp = (const avtVectorMetaData *)atts;
  278. *this = *tmp;
  279. return true;
  280. }
  281. // ****************************************************************************
  282. // Method: avtVectorMetaData::CreateCompatible
  283. //
  284. // Purpose:
  285. // CreateCompatible method for the avtVectorMetaData class.
  286. //
  287. // Note: Autogenerated by xml2atts.
  288. //
  289. // Programmer: xml2atts
  290. // Creation: omitted
  291. //
  292. // Modifications:
  293. //
  294. // ****************************************************************************
  295. AttributeSubject *
  296. avtVectorMetaData::CreateCompatible(const std::string &tname) const
  297. {
  298. AttributeSubject *retval = 0;
  299. if(TypeName() == tname)
  300. retval = new avtVectorMetaData(*this);
  301. // Other cases could go here too.
  302. return retval;
  303. }
  304. // ****************************************************************************
  305. // Method: avtVectorMetaData::NewInstance
  306. //
  307. // Purpose:
  308. // NewInstance method for the avtVectorMetaData class.
  309. //
  310. // Note: Autogenerated by xml2atts.
  311. //
  312. // Programmer: xml2atts
  313. // Creation: omitted
  314. //
  315. // Modifications:
  316. //
  317. // ****************************************************************************
  318. AttributeSubject *
  319. avtVectorMetaData::NewInstance(bool copy) const
  320. {
  321. AttributeSubject *retval = 0;
  322. if(copy)
  323. retval = new avtVectorMetaData(*this);
  324. else
  325. retval = new avtVectorMetaData;
  326. return retval;
  327. }
  328. // ****************************************************************************
  329. // Method: avtVectorMetaData::SelectAll
  330. //
  331. // Purpose:
  332. // Selects all attributes.
  333. //
  334. // Note: Autogenerated by xml2atts.
  335. //
  336. // Programmer: xml2atts
  337. // Creation: omitted
  338. //
  339. // Modifications:
  340. //
  341. // ****************************************************************************
  342. void
  343. avtVectorMetaData::SelectAll()
  344. {
  345. // call the base class' SelectAll() first
  346. avtVarMetaData::SelectAll();
  347. Select(ID_varDim, (void *)&varDim);
  348. }
  349. ///////////////////////////////////////////////////////////////////////////////
  350. // Set property methods
  351. ///////////////////////////////////////////////////////////////////////////////
  352. ///////////////////////////////////////////////////////////////////////////////
  353. // Get property methods
  354. ///////////////////////////////////////////////////////////////////////////////
  355. ///////////////////////////////////////////////////////////////////////////////
  356. // User-defined methods.
  357. ///////////////////////////////////////////////////////////////////////////////
  358. // ****************************************************************************
  359. // Method: avtVectorMetaData constructor
  360. //
  361. // Arguments:
  362. // n The name of the vector variable.
  363. // mn The name of the mesh the vector var is defined on.
  364. // c The centering of the variable.
  365. // vd The dimension of the variable.
  366. //
  367. // Programmer: Hank Childs
  368. // Creation: August 25, 2000
  369. //
  370. // Modifications:
  371. // Hank Childs, Mon Dec 9 17:04:39 PST 2002
  372. // Initialized validVariable.
  373. //
  374. // Brad Whitlock, Tue Jul 20 13:48:31 PST 2004
  375. // Added units.
  376. //
  377. // Hank Childs, Mon Feb 14 14:16:49 PST 2005
  378. // Added original name.
  379. //
  380. // Brad Whitlock, Fri Mar 2 15:33:10 PST 2007
  381. // Updated.
  382. //
  383. // ****************************************************************************
  384. avtVectorMetaData::avtVectorMetaData(std::string n, std::string mn,
  385. avtCentering c, int vd)
  386. : avtVarMetaData(avtVectorMetaData::TmfsStruct, n, mn, c)
  387. {
  388. avtVectorMetaData::Init();
  389. varDim = vd;
  390. }
  391. // ****************************************************************************
  392. // Method: avtVectorMetaData constructor
  393. //
  394. // Arguments:
  395. // n The name of the vector variable.
  396. // mn The name of the mesh the vector var is defined on.
  397. // c The centering of the variable.
  398. // vd The dimension of the variable.
  399. // extents The extents of the variable.
  400. //
  401. // Programmer: Hank Childs
  402. // Creation: August 25, 2000
  403. //
  404. // Modifications:
  405. // Hank Childs, Mon Dec 9 17:04:39 PST 2002
  406. // Initialized validVariable.
  407. //
  408. // Brad Whitlock, Tue Jul 20 13:48:55 PST 2004
  409. // Added units.
  410. //
  411. // Hank Childs, Mon Feb 14 14:16:49 PST 2005
  412. // Added original name.
  413. //
  414. // ****************************************************************************
  415. avtVectorMetaData::avtVectorMetaData(std::string n, std::string mn,
  416. avtCentering c, int vd,
  417. const double *extents)
  418. : avtVarMetaData(avtVectorMetaData::TmfsStruct, n, mn, c)
  419. {
  420. avtVectorMetaData::Init();
  421. varDim = vd;
  422. SetExtents(extents);
  423. }
  424. // ****************************************************************************
  425. // Method: avtVectorMetaData::SetExtents
  426. //
  427. // Purpose:
  428. // Sets the extents of the vector
  429. //
  430. // Arguments:
  431. // extents vector extents as <min_v1, max_v1, min_v2, max_v2, ...>.
  432. //
  433. // Programmer: Hank Childs
  434. // Creation: August 30, 2000
  435. //
  436. // Modifications:
  437. //
  438. // Hank Childs, Tue May 1 12:53:10 PDT 2001
  439. // Check for NULL extents.
  440. //
  441. // Kathleen Bonnell, Thu Mar 11 10:59:14 PST 2004
  442. // DataExtents now only has 2 components.
  443. //
  444. // ****************************************************************************
  445. void
  446. avtVectorMetaData::SetExtents(const double *extents)
  447. {
  448. if (extents == NULL)
  449. {
  450. hasDataExtents = false;
  451. }
  452. else
  453. {
  454. hasDataExtents = true;
  455. minDataExtents = extents[0];
  456. maxDataExtents = extents[1];
  457. }
  458. }
  459. void
  460. avtVectorMetaData::UnsetExtents()
  461. {
  462. hasDataExtents = false;
  463. }
  464. // ****************************************************************************
  465. // Method: avtVectorMetaData::Print
  466. //
  467. // Purpose:
  468. // Print statement for debugging.
  469. //
  470. // Arguments:
  471. // out The stream to output to.
  472. // indent The number of tabs to indent each line with.
  473. //
  474. // Programmer: Hank Childs
  475. // Creation: August 28, 2000
  476. //
  477. // Modifications:
  478. // Hank Childs, Mon Dec 9 17:04:39 PST 2002
  479. // Added validVariable.
  480. //
  481. // Brad Whitlock, Tue Jul 20 13:51:08 PST 2004
  482. // Added units.
  483. //
  484. // Hank Childs, Mon Feb 14 14:16:49 PST 2005
  485. // Added original name.
  486. //
  487. // ****************************************************************************
  488. inline void
  489. Indent(ostream &out, int indent)
  490. {
  491. for (int i = 0 ; i < indent ; i++)
  492. {
  493. out << "\t";
  494. }
  495. }
  496. void
  497. avtVectorMetaData::Print(ostream &out, int indent) const
  498. {
  499. avtVarMetaData::Print(out, indent);
  500. Indent(out, indent);
  501. out << "Variable Dimension = " << varDim << endl;
  502. }