Ignore:
Timestamp:
07/28/16 03:39:26 (8 years ago)
Author:
Maciej Komosinski
Message:

Renamed: Model::buildUsingNewShapes -> Model::buildUsingSolidShapeTypes()
Added class SolidsShapeTypeModel? (for making ball-and-stick Models look like solids-type Models)
ModelGeometryInfo? functions: findSizesAndAxesOfModel(), volume() and area() now accept ball-and-stick Models (using SolidsShapeTypeModel? class)
[refs #46] and possibly closes this issue (needs verification)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/model/model.cpp

    r544 r546  
    973973                                j->p2_refno = j->part2->refno;
    974974                                if (checklevel > 0)
    975                                         {
     975                                {
    976976                                        j->part1->mass += 1.0;
    977977                                        j->part2->mass += 1.0;
    978                                         }
     978                                }
    979979                                if ((j->usedelta) && ((j->d.x != JOINT_DELTA_MARKER) || (j->d.y != JOINT_DELTA_MARKER) || (j->d.z != JOINT_DELTA_MARKER)))
    980980                                { // delta positioning -> calc. orient.
     
    13361336}
    13371337
    1338 void Model::buildUsingNewShapes(const Model& old, Part::Shape default_shape, float thickness)
    1339 {
    1340         for (int i = 0; i < old.getJointCount(); i++)
    1341         {
    1342                 Joint *oj = old.getJoint(i);
    1343                 Part *p = addNewPart(default_shape);
     1338void Model::buildUsingSolidShapeTypes(const Model& src_ballandstick_shapes, Part::Shape use_shape, float thickness)
     1339{
     1340        for (int i = 0; i < src_ballandstick_shapes.getJointCount(); i++)
     1341        {
     1342                Joint *oj = src_ballandstick_shapes.getJoint(i);
     1343                Part *p = addNewPart(use_shape);
    13441344                p->p = (oj->part1->p + oj->part2->p) / 2;
    13451345                Orient o;
     
    13501350                p->scale.z = thickness;
    13511351        }
    1352         for (int i = 0; i < old.getPartCount(); i++)
    1353         {
    1354                 Part *op = old.getPart(i);
    1355                 for (int j = 0; j < old.getJointCount(); j++)
    1356                 {
    1357                         Joint *oj = old.getJoint(j);
     1352        for (int i = 0; i < src_ballandstick_shapes.getPartCount(); i++)
     1353        {
     1354                Part *op = src_ballandstick_shapes.getPart(i);
     1355                for (int j = 0; j < src_ballandstick_shapes.getJointCount(); j++)
     1356                {
     1357                        Joint *oj = src_ballandstick_shapes.getJoint(j);
    13581358                        if ((oj->part1 == op) || (oj->part2 == op))
    13591359                        {
    1360                                 for (int j2 = j + 1; j2 < old.getJointCount(); j2++)
     1360                                for (int j2 = j + 1; j2 < src_ballandstick_shapes.getJointCount(); j2++)
    13611361                                {
    1362                                         Joint *oj2 = old.getJoint(j2);
     1362                                        Joint *oj2 = src_ballandstick_shapes.getJoint(j2);
    13631363                                        if ((oj2->part1 == op) || (oj2->part2 == op))
    13641364                                        {
     
    13691369                        }
    13701370                }
     1371        }
     1372}
     1373
     1374SolidsShapeTypeModel::SolidsShapeTypeModel(const Model& m, Part::Shape use_shape, float thickness)
     1375{
     1376        using_model = converted_model = NULL;
     1377        if (m.getShapeType() == Model::SHAPE_BALL_AND_STICK)
     1378        {
     1379                converted_model = new Model;
     1380                converted_model->open();
     1381                converted_model->buildUsingSolidShapeTypes(m, use_shape, thickness);
     1382                converted_model->close();
     1383                using_model = converted_model;
     1384        }
     1385        else
     1386        {
     1387                converted_model = NULL;
     1388                using_model = &m;
    13711389        }
    13721390}
Note: See TracChangeset for help on using the changeset viewer.