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.h

    r544 r546  
    414414        void rotate(const Pt3D& angles) { Orient o = Orient_1; o.rotate(angles); rotate(o); }
    415415
    416         /// build this model using new shapes, based on the provided model that uses old shapes. See also shapeconvert.cpp.
    417         void buildUsingNewShapes(const Model& src_old_shapes, Part::Shape default_shape = Part::SHAPE_CYLINDER, float thickness = 0.2);
     416        /// build this model using solid shape types, based on the provided ball-and-stick model. See also shapeconvert.cpp.
     417        void buildUsingSolidShapeTypes(const Model& src_ballandstick_shapes, Part::Shape use_shape = Part::SHAPE_CYLINDER, float thickness = 0.2);
    418418
    419419#ifdef EASYMAPDEBUG
     
    448448};
    449449
     450/**
     451   An object of this class is created from a Model and returns the solids-type const Model& regardless of the source Model shape type.
     452   For solids-type Models, the same source Model reference is returned.
     453   For ball-and-stick-type Models, the new temporary Model is created (using Model::buildUsingSolidShapeTypes).
     454   Useful for making the solids-only code work for both solids Models and ball-and-stick Models, without if's and special cases, like in this example:
     455   
     456   void fun(const Model& input) // 'input' can be any shape type
     457   {
     458      SolidsShapeTypeModel converted(input); // 'converted' contains either 'input' or the new solids-type Model created from 'input'
     459      functionAcceptingSolidsTypeModel(converted); // operator const Model&() is called automatically because of the function signature
     460      int n=converted.getModel().getPartCount(); // getting the const Model& explicitly (converted.getPartCount() would fail)
     461   }
     462 */
     463class SolidsShapeTypeModel
     464{
     465public:
     466        Model *converted_model;
     467        const Model *using_model;
     468        SolidsShapeTypeModel(const Model& m, Part::Shape use_shape = Part::SHAPE_CYLINDER, float thickness = 0.2);
     469        operator const Model&() const { return *using_model; }
     470        const Model& getModel() const { return *using_model; }
     471        ~SolidsShapeTypeModel() { if (converted_model) delete converted_model; }
     472};
     473
    450474#endif
Note: See TracChangeset for help on using the changeset viewer.