Example #1
0
 def _read_cord2c(self, data, n):
     """
     (2001,20,9) - the marker for Record 4
     """
     s = Struct(self._endian + b'4i9f')
     nentries = (len(data) - n) // 52
     for i in range(nentries):
         edata = data[n:n + 52]  # 13*4
         out = s.unpack(edata)
         (cid, two1, two2, rid, a1, a2, a3, b1, b2, b3, c1, c2, c3) = out
         assert two1 == 2, two1
         assert two2 == 2, two2
         data_in = [cid, rid, a1, a2, a3, b1, b2, b3, c1, c2, c3]
         coord = CORD2C.add_op2_data(data_in)
         if self.is_debug_file:
             self.binary_debug.write('  CORD2C=%s\n' % str(out))
         self._add_coord_object(coord, allow_overwrites=True)
         n += 52
     self.increase_card_count('CORD2C', nentries)
     return n
Example #2
0
 def _read_cord2c(self, data, n):
     """
     (2001,20,9) - the marker for Record 4
     """
     s = Struct(b(self._endian + '4i9f'))
     nentries = (len(data) - n) // 52
     for i in range(nentries):
         edata = data[n:n + 52]  # 13*4
         out = s.unpack(edata)
         (cid, two1, two2, rid, a1, a2, a3, b1, b2, b3, c1, c2, c3) = out
         assert two1 == 2, two1
         assert two2 == 2, two2
         data_in = [cid, rid, a1, a2, a3, b1, b2, b3, c1, c2, c3]
         coord = CORD2C.add_op2_data(data_in)
         if self.is_debug_file:
             self.binary_debug.write('  CORD2C=%s\n' % str(out))
         self.add_coord(coord, allow_overwrites=True)
         n += 52
     self._increase_card_count('CORD2C', nentries)
     return n
Example #3
0
 def _read_cord2c(self, data, n):
     """
     (2001,20,9) - the marker for Record 4
     """
     ntotal = 52 * self.factor # 13*4
     s = Struct(mapfmt(self._endian + b'4i9f', self.size))
     nentries = (len(data) - n) // ntotal
     for unused_i in range(nentries):
         edata = data[n:n + ntotal]
         out = s.unpack(edata)
         (cid, two1, two2, rid, a1, a2, a3, b1, b2, b3, c1, c2, c3) = out
         assert two1 == 2, two1
         assert two2 == 2, two2
         data_in = [cid, rid, a1, a2, a3, b1, b2, b3, c1, c2, c3]
         coord = CORD2C.add_op2_data(data_in)
         if self.is_debug_file:
             self.binary_debug.write('  CORD2C=%s\n' % str(out))
         self._add_coord_object(coord, allow_overwrites=False)
         n += ntotal
     self.increase_card_count('CORD2C', nentries)
     return n
Example #4
0
    def test_cord2c_01(self):
        """simple CORD2R/CORD2C input/output test"""
        lines = [
            'CORD2C*                3               0              0.              0.',
            '*                     0.              0.              0.              1.*',
            '*                     1.              0.              1.'
        ]
        model = BDF(debug=False)
        card = model._process_card(lines)
        cardi = BDFCard(card)
        cord2c = CORD2C.add_card(cardi)
        model._add_coord_object(cord2c)

        lines = [
            'CORD2R         4       3     10.      0.      5.     10.     90.      5.',
            '             10.      0.      6.'
        ]
        card = model._process_card(lines)
        cardi = BDFCard(card)
        cord2r = CORD2R.add_card(cardi)
        model._add_coord_object(cord2r)
        model.cross_reference()

        cord2r_b = model.Coord(3)
        self.assertEqual(cord2r_b.Cid(), 3)
        self.assertEqual(cord2r_b.Rid(), 0)

        cord2r_c = model.Coord(4)
        self.assertEqual(cord2r_c.Cid(), 4)
        self.assertEqual(cord2r_c.Rid(), 3)

        self.assertTrue(allclose(cord2r_c.i, array([0., 0., 1.])))
        delta = cord2r_c.j - array([1., 1., 0.]) / 2**0.5
        self.assertTrue(allclose(cord2r_c.j,
                                 array([1., 1., 0.]) / 2**0.5), str(delta))
        delta = cord2r_c.k - array([-1., 1., 0.]) / 2**0.5
        self.assertTrue(allclose(cord2r_c.k,
                                 array([-1., 1., 0.]) / 2**0.5), str(delta))
Example #5
0
 def add_cord2c(self, card, comment=''):
     """adds a CORD2C card"""
     coord = CORD2C.add_card(card, comment=comment)
     self.coords[coord.cid] = coord
     self.n += 1
Example #6
0
 def add_cord2c(self, card, comment=''):
     """adds a CORD2C card"""
     coord = CORD2C.add_card(card, comment=comment)
     self.coords[coord.cid] = coord
     self.n += 1