Пример #1
0
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
M113a_Chassis::M113a_Chassis(const std::string& name, bool fixed, ChassisCollisionType chassis_collision_type)
    : ChRigidChassis(name, fixed) {
    m_inertia.SetElement(0, 0, m_inertiaXX.x());
    m_inertia.SetElement(1, 1, m_inertiaXX.y());
    m_inertia.SetElement(2, 2, m_inertiaXX.z());

    m_inertia.SetElement(0, 1, m_inertiaXY.x());
    m_inertia.SetElement(0, 2, m_inertiaXY.y());
    m_inertia.SetElement(1, 2, m_inertiaXY.z());
    m_inertia.SetElement(1, 0, m_inertiaXY.x());
    m_inertia.SetElement(2, 0, m_inertiaXY.y());
    m_inertia.SetElement(2, 1, m_inertiaXY.z());

    // Belly shape (all dimensions in cm)
    // width: 170
    // points in x-z transversal plane: (-417.0 -14.3), (4.1, -14.3), (21.4, 34.3)
    // thickness: 20
    double width = 1.70;
    double Ax = -4.17;
    double Az = -0.143;
    double Bx = 0.041;
    double Bz = -0.143;
    double Cx = 0.214;
    double Cz = 0.343;
    double thickness = 0.2;

    ChVector<> dims1((Bx - Ax), width, thickness);
    ChVector<> loc1(0.5 * (Ax + Bx), 0.0, Az + 0.5 * thickness);
    ChQuaternion<> rot1(1, 0, 0, 0);
    BoxShape box1(loc1, rot1, dims1);

    double alpha = std::atan2(Cz - Bz, Cx - Bx);  // pitch angle of front box

    ChVector<> dims2((Cx - Bx) / std::cos(alpha), width, thickness);
    ChVector<> loc2(0.5 * (Bx + Cx) - 0.5 * thickness * std::sin(alpha), 0.0,
        0.5 * (Bz + Cz) + 0.5 * thickness * std::cos(alpha));
    ChQuaternion<> rot2 = Q_from_AngY(-alpha);
    BoxShape box2(loc2, rot2, dims2);

    m_has_primitives = true;
    m_vis_boxes.push_back(box1);
    m_vis_boxes.push_back(box2);

    m_has_mesh = true;
    m_vis_mesh_name = "Chassis_POV_geom";
    m_vis_mesh_file = "M113/Chassis.obj";

    m_has_collision = (chassis_collision_type != ChassisCollisionType::NONE);
    switch (chassis_collision_type) {
    case ChassisCollisionType::PRIMITIVES:
        m_coll_boxes.push_back(box1);
        m_coll_boxes.push_back(box2);
        break;
    case ChassisCollisionType::MESH:
        m_coll_mesh_names.push_back("M113/Chassis_Hulls.obj");
        break;
    default:
        break;
    }
}
Пример #2
0
// Compute the mapping between linear array and the hypercube
// corresponding to all the trees.
void GeneratorTrees::ComputeCubeMapping()
{
  assert(trees.length()>=1);

  if (trees.length()==1) {  // A single tree
    ComputeOneGenMapping(map2array, trees[0]);
  }
  else { // more than one generator
    // Compute the sub-mapping for every generator. Also prepare two hypercube
    // signature objects for the index calculations, with the two ordering of
    // the generators: one for the generators ordered by their index 0,1,2...
    // and the other odred the generators by the order of their trees

    Vec<long> dims1(INIT_SIZE,trees.length()), dims2(INIT_SIZE,trees.length());
    Vec<Permut> genMappings(INIT_SIZE, trees.length());
    for (long i=0; i<trees.length(); i++) {
      dims1[i] = trees[i][0].getData().size;
      ComputeOneGenMapping(genMappings[i], trees[i]);
    }
    getCubeDims(dims2);
    CubeSignature sig1(dims1), sig2(dims2);


    // Allocate space for the mapping
    map2array.SetLength(sig1.getSize());

    // Combine the generator perms to a single permutation over the cube
    for (long i=0; i<map2array.length(); i++) {
      long t=0;
      for (long j1=0; j1<trees.length(); j1++) {
	long j2 = trees[j1].getAuxKey();
	long digit = sig1.getCoord(i,j1); // the j1 digit of i in base dims
	digit = genMappings[j1][digit];   // apply the j1 permutation to it
	t += digit * sig2.getProd(j2+1);  // adds the permuted digit

      }
      map2array[i] = t;
    }
  }

  // Compute the inverse permutation
  map2cube.SetLength(map2array.length());
  for (long i=0; i<map2array.length(); i++) map2cube[ map2array[i] ] = i;
}
int main(int argc, char** argv)
{
    try
    {
        // Parse the command line
        if (argc != 2)
        {
            std::cerr << "Usage: " << sys::Path::basename(argv[0])
                      << " <output NITF pathname prefix>\n\n";
            return 1;
        }
        const std::string outPathnamePrefix(argv[1]);
        verifySchemaEnvVariableIsSet();

        // In order to make it easier to test segmenting, let's artificially set
        // the segment size really small
        const size_t numCols = 200;

        const size_t maxSize = numCols * 50;

        six::XMLControlRegistry xmlRegistry;
        xmlRegistry.addCreator(
                six::DataType::DERIVED,
                new six::XMLControlCreatorT<
                        six::sidd::DerivedXMLControl>());

        six::Container container(six::DataType::DERIVED);

        std::vector<six::UByte*> buffers;

        // First a single segment without a legend
        types::RowCol<size_t> dims1(40, numCols);
        std::auto_ptr<six::Data> data1(mockupDerivedData(dims1));

        const mem::ScopedArray<sys::ubyte> buffer1(new sys::ubyte[dims1.normL1()]);
        std::fill_n(buffer1.get(), dims1.normL1(), 20);

        container.addData(data1);
        buffers.push_back(buffer1.get());

        // Now a single segment with a mono legend
        types::RowCol<size_t> dims2(40, numCols);
        std::auto_ptr<six::Data> data2(mockupDerivedData(dims2));

        const types::RowCol<size_t> legendDims(50, 50);
        std::auto_ptr<six::Legend> monoLegend(new six::Legend());
        monoLegend->mType = six::PixelType::MONO8I;
        monoLegend->mLocation.row = 10;
        monoLegend->mLocation.col = 10;
        monoLegend->setDims(legendDims);

        const mem::ScopedArray<sys::ubyte> buffer2(new sys::ubyte[dims2.normL1()]);
        std::fill_n(buffer2.get(), dims2.normL1(), 100);

        container.addData(data2, monoLegend);
        buffers.push_back(buffer2.get());

        // Now a multi-segment without a legend
        types::RowCol<size_t> dims3(150, numCols);
        std::auto_ptr<six::Data> data3(mockupDerivedData(dims3));

        const mem::ScopedArray<sys::ubyte> buffer3(new sys::ubyte[dims3.normL1()]);
        std::fill_n(buffer3.get(), dims3.normL1(), 60);

        container.addData(data3);
        buffers.push_back(buffer3.get());

        // Now a multi-segment with an RGB legend
        types::RowCol<size_t> dims4(155, numCols);
        std::auto_ptr<six::Data> data4(mockupDerivedData(dims4));

        std::auto_ptr<six::Legend> rgbLegend(new six::Legend());
        rgbLegend->mType = six::PixelType::RGB8LU;
        rgbLegend->mLocation.row = 10;
        rgbLegend->mLocation.col = 10;
        rgbLegend->setDims(legendDims);
        rgbLegend->mLUT.reset(new six::LUT(256, 3));
        for (size_t ii = 0, idx = 0;
             ii < rgbLegend->mLUT->numEntries;
             ++ii, idx += 3)
        {
            rgbLegend->mLUT->table[idx] = ii;
            rgbLegend->mLUT->table[idx + 1] = ii;
            rgbLegend->mLUT->table[idx + 2] = ii;
        }

        const mem::ScopedArray<sys::ubyte> buffer4(new sys::ubyte[dims4.normL1()]);
        std::fill_n(buffer4.get(), dims4.normL1(), 200);

        container.addData(data4, rgbLegend);
        buffers.push_back(buffer4.get());

        // Write it out
        {
            six::NITFWriteControl writer;

            writer.getOptions().setParameter(
                    six::NITFWriteControl::OPT_MAX_PRODUCT_SIZE,
                    str::toString(maxSize));

            writer.setXMLControlRegistry(&xmlRegistry);
            writer.initialize(&container);

            writer.save(buffers, outPathnamePrefix + "_unblocked.nitf");
        }

        // Write it out with blocking
        {
            six::NITFWriteControl writer;

            writer.getOptions().setParameter(
                    six::NITFWriteControl::OPT_MAX_PRODUCT_SIZE,
                    str::toString(maxSize));

            const std::string blockSize("1024");
            writer.getOptions().setParameter(
                    six::NITFWriteControl::OPT_NUM_ROWS_PER_BLOCK,
                    blockSize);

            writer.getOptions().setParameter(
                    six::NITFWriteControl::OPT_NUM_COLS_PER_BLOCK,
                    blockSize);

            writer.setXMLControlRegistry(&xmlRegistry);
            writer.initialize(&container);

            writer.save(buffers, outPathnamePrefix + "_blocked.nitf");
        }

        return 0;
    }
    catch (const except::Exception& e)
    {
        std::cerr << "Caught exception: " << e.getMessage() << std::endl;
        return 1;
    }
    catch (const std::exception& e)
    {
        std::cerr << "Caught exception: " << e.what() << std::endl;
        return 1;
    }
    catch (...)
    {
        std::cerr << "Unknown exception\n";
        return 1;
    }
}