<NME> WrapObject.h
<BEF> #ifndef OPENSIM_WRAP_OBJECT_H_
#define OPENSIM_WRAP_OBJECT_H_
/* -------------------------------------------------------------------------- *
 *                           OpenSim:  WrapObject.h                           *
 * -------------------------------------------------------------------------- *
 * The OpenSim API is a toolkit for musculoskeletal modeling and simulation.  *
 * See http://opensim.stanford.edu and the NOTICE file for more information.  *
 * OpenSim is developed at Stanford University and supported by the US        *
 * National Institutes of Health (U54 GM072970, R24 HD065690) and by DARPA    *
 * through the Warrior Web program.                                           *
 *                                                                            *
 * Copyright (c) 2005-2017 Stanford University and the Authors                *
 * Author(s): Peter Loan                                                      *
 *                                                                            *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may    *
 * not use this file except in compliance with the License. You may obtain a  *
 * copy of the License at http://www.apache.org/licenses/LICENSE-2.0.         *
 *                                                                            *
 * Unless required by applicable law or agreed to in writing, software        *
 * distributed under the License is distributed on an "AS IS" BASIS,          *
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   *
 * See the License for the specific language governing permissions and        *
 * limitations under the License.                                             *
 * -------------------------------------------------------------------------- */

// INCLUDE
#include <OpenSim/Simulation/Model/ModelComponent.h>
#include <OpenSim/Simulation/Model/Appearance.h>
namespace OpenSim {

class PathWrap;
class WrapResult;
class Model;
class PhysicalFrame;
class AbstractPathPoint;

//=============================================================================
//=============================================================================
/**
 * An abstract class that specifies the interface for a wrapping
 * object.
 *
 * @author Peter Loan
 * @version 1.0
 */
class OSIMSIMULATION_API WrapObject : public ModelComponent {
OpenSim_DECLARE_ABSTRACT_OBJECT(WrapObject, ModelComponent);
public:
//==============================================================================
// PROPERTIES
//==============================================================================
    OpenSim_DECLARE_PROPERTY(active, bool,
        "Whether or not the WrapObject is considered active in computing paths");

    OpenSim_DECLARE_PROPERTY(xyz_body_rotation, SimTK::Vec3,
        "Body-fixed Euler angle sequence for the orientation of the WrapObject");

    OpenSim_DECLARE_PROPERTY(translation, SimTK::Vec3,
        "Translation of the WrapObject.");

    // Default display properties e.g. Representation, color, texture, etc.
    OpenSim_DECLARE_UNNAMED_PROPERTY(Appearance,
        "Default appearance for this Geometry");

    OpenSim_DECLARE_PROPERTY(quadrant, std::string,
        "The name of quadrant over which the wrap object is active. "
        "For example, '+x' or '-y' to set the sidedness of the wrapping.");

    enum WrapQuadrant
    {
        allQuadrants,
        negativeX,
        positiveX,
        negativeY,
        positiveY,
        negativeZ,
        positiveZ
    };

    enum WrapAction
    {
        noWrap,          // the path segment did not intersect the wrap object
        insideRadius,    // one or both path points are inside the wrap object
        wrapped,         // successful wrap, but may not be 'best' path
        mandatoryWrap    // successful wrap that must be used (e.g., both tangent
    };                  // points are on the constrained side of the wrap object)



//=============================================================================
// METHODS
//=============================================================================
public:
    WrapObject();
    virtual ~WrapObject();

    // Use default copy and assignment operator

    void extendScale(const SimTK::State& s, const ScaleSet& scaleSet) override;
    virtual void connectToModelAndBody(Model& aModel, PhysicalFrame& aBody) {}

    const PhysicalFrame& getFrame() const;
    void setFrame(const PhysicalFrame& frame);

    bool getActiveUseDefault() const { 
        return getProperty_active().getValueIsDefault();
    }
    bool getQuadrantNameUseDefault() const {
        return getProperty_quadrant().getValueIsDefault();
    }
    const SimTK::Transform& getTransform() const { return _pose; }
    virtual const char* getWrapTypeName() const = 0;

    // TODO: total SIMM hack!
    virtual std::string getDimensionsString() const { return ""; }

//=============================================================================
// WRAPPING
//=============================================================================
/**
* Calculate the wrapping of one path segment over one wrap object.
* @param state   The State of the model
* @param aPoint1 The first path point
* @param aPoint2 The second path point
* @param aPathWrap An object holding the parameters for this path/wrap-object pairing
	// CONSTRUCTION
	//--------------------------------------------------------------------------
public:
	WrapObject();
	WrapObject(const WrapObject& aWrapObject);
	virtual ~WrapObject();

     * Compute the transform of the wrap geomerty w.r.t. the mobilized body 
     * it is attached to.
     */
    SimTK::Transform calcWrapGeometryTransformInBaseFrame() const;
   /** Determine the appropriate values of _quadrant, _wrapAxis, and _wrapSign,
     * based on the name of the quadrant. finalizeFromProperties() should be
     * called whenever the quadrant property changes. */
    void extendFinalizeFromProperties() override;

    void updateFromXMLNode(SimTK::Xml::Element& node, int versionNumber)
        override;

private:
    void constructProperties();

    SimTK::ReferencePtr<const PhysicalFrame> _frame;

protected:

    WrapQuadrant _quadrant{ WrapQuadrant::allQuadrants };
    int _wrapAxis{ 0 };
    int _wrapSign{ 1 };

    SimTK::Transform _pose;
//=============================================================================
};  // END of class WrapObject
//=============================================================================
//=============================================================================

} // end of namespace OpenSim

#endif // OPENSIM_WRAP_OBJECT_H_
	void setGeometryQuadrants(AnalyticGeometry *aGeometry) const;
private:
	void setNull();
//=============================================================================
};	// END of class WrapObject
//=============================================================================

<MSG> Add display_preference and color properties for ContactGeometry and WrapObjects for finer granularity of visualization in GUI. Also support changing these properties in GUI. Included also in this commit updating the Java wrapping for Muscles and MuscleAnalysis.

git-svn-id: 9e047e1e624cce0a2485e750063112e834f85522@7339 fc29be9c-2cb0-420d-b520-73dbd18add6e

<DFF> @@ -126,7 +126,15 @@ protected:
 	// CONSTRUCTION
 	//--------------------------------------------------------------------------
 public:
-	WrapObject();
+    /** Display Preference to apply to the contact geometry.  **/
+    OpenSim_DECLARE_PROPERTY(display_preference, int,
+        "Display Pref. 0:Hide 1:Wire 3:Flat 4:Shaded");
+
+    /** Display Color to apply to the contact geometry.  **/
+    OpenSim_DECLARE_LIST_PROPERTY_SIZE(color, double, 3,
+        "Display Color");
+
+    WrapObject();
 	WrapObject(const WrapObject& aWrapObject);
 	virtual ~WrapObject();
 
@@ -165,6 +173,7 @@ protected:
 	void setGeometryQuadrants(AnalyticGeometry *aGeometry) const;
 private:
 	void setNull();
+    void constructProperties();
 //=============================================================================
 };	// END of class WrapObject
 //=============================================================================

{'commit': 'diff --git a/OpenSim/Simulation/Model/ContactGeometry.cpp b/OpenSim/Simulation/Model/ContactGeometry.cpp\nindex 5e4cf9fec..b5b54a0d0 100644\n--- a/OpenSim/Simulation/Model/ContactGeometry.cpp\n+++ b/OpenSim/Simulation/Model/ContactGeometry.cpp\n@@ -42,6 +42,7 @@ ContactGeometry::ContactGeometry() :\n {\r\n \tsetNull();\r\n \tsetupProperties();\r\n+    constructProperties();\r\n }\r\n \r\n ContactGeometry::ContactGeometry(const Vec3& location, const Vec3& orientation, Body& body) :\r\n@@ -51,6 +52,7 @@ ContactGeometry::ContactGeometry(const Vec3& location, const Vec3& orientation,\n {\r\n \tsetNull();\r\n \tsetupProperties();\r\n+    constructProperties();\r\n     _body = &body;\r\n     _bodyName = body.getName();\r\n     _locationInBody = location;\r\n@@ -64,6 +66,7 @@ ContactGeometry::ContactGeometry(const ContactGeometry& geom) : ModelComponent(g\n {\r\n \tsetNull();\r\n \tsetupProperties();\r\n+    //constructProperties();\r\n     copyData(geom);\r\n }\r\n \r\n@@ -92,6 +95,19 @@ void ContactGeometry::setupProperties()\n \t_propertySet.append(&_orientationInBodyProp);\r\n }\r\n \r\n+//_____________________________________________________________________________\r\n+/**\r\n+ * Connect properties to local pointers.\r\n+ */\r\n+void ContactGeometry::constructProperties()\r\n+{\r\n+    constructProperty_display_preference(1);\r\n+    Array<double> defaultColor(1.0, 3); //color default to 0, 1, 1\r\n+\tdefaultColor[0] = 0.0; \r\n+\r\n+    constructProperty_color(defaultColor);\r\n+}\r\n+\r\n void ContactGeometry::copyData(const ContactGeometry& source)\r\n {\r\n     _body = source._body;\r\ndiff --git a/OpenSim/Simulation/Model/ContactGeometry.h b/OpenSim/Simulation/Model/ContactGeometry.h\nindex cb74a188d..5e6270337 100644\n--- a/OpenSim/Simulation/Model/ContactGeometry.h\n+++ b/OpenSim/Simulation/Model/ContactGeometry.h\n@@ -78,6 +78,14 @@ protected:\n \t */\r\n     ContactGeometry(const SimTK::Vec3& location, const SimTK::Vec3& orientation, OpenSim::Body& body);\r\n public:\r\n+    /** Display Preference to apply to the contact geometry.  **/\r\n+    OpenSim_DECLARE_PROPERTY(display_preference, int,\r\n+        "Display Pref. 0:Hide 1:Wire 3:Flat 4:Shaded");\r\n+\r\n+    /** Display Color to apply to the contact geometry.  **/\r\n+    OpenSim_DECLARE_LIST_PROPERTY_SIZE(color, double, 3,\r\n+        "Display Color");\r\n+\r\n \tContactGeometry(const ContactGeometry& geom);\r\n \t~ContactGeometry();\r\n \r\n@@ -164,6 +172,7 @@ private:\n     // INITIALIZATION\r\n \tvoid setNull();\r\n \tvoid setupProperties();\r\n+    void constructProperties();\r\n //=============================================================================\r\n };\t// END of class ContactGeometry\r\n //=============================================================================\r\ndiff --git a/OpenSim/Simulation/Model/ContactHalfSpace.cpp b/OpenSim/Simulation/Model/ContactHalfSpace.cpp\nindex f30ab28e0..f23628515 100644\n--- a/OpenSim/Simulation/Model/ContactHalfSpace.cpp\n+++ b/OpenSim/Simulation/Model/ContactHalfSpace.cpp\n@@ -64,6 +64,7 @@ void ContactHalfSpace::setNull()\n \r\n SimTK::ContactGeometry ContactHalfSpace::createSimTKContactGeometry()\r\n {\r\n+    _displayer.freeGeometry();\r\n \t_displayer.addGeometry(new PolyhedralGeometry("unit_plane.obj"));\r\n \treturn SimTK::ContactGeometry::HalfSpace();\r\n }\r\ndiff --git a/OpenSim/Simulation/Wrap/WrapObject.cpp b/OpenSim/Simulation/Wrap/WrapObject.cpp\nindex f4efe71eb..15fb25ead 100644\n--- a/OpenSim/Simulation/Wrap/WrapObject.cpp\n+++ b/OpenSim/Simulation/Wrap/WrapObject.cpp\n@@ -65,6 +65,7 @@ WrapObject::WrapObject() :\n {\r\n \tsetNull();\r\n \tsetupProperties();\r\n+    constructProperties();\r\n }\r\n \r\n //_____________________________________________________________________________\r\n@@ -92,6 +93,7 @@ WrapObject::WrapObject(const WrapObject& aWrapObject) :\n {\r\n \tsetNull();\r\n \tsetupProperties();\r\n+    //constructProperties();\r\n \tcopyData(aWrapObject);\r\n }\r\n \r\n@@ -137,6 +139,15 @@ void WrapObject::setupProperties()\n \r\n }\r\n \r\n+void WrapObject::constructProperties()\r\n+{\r\n+    constructProperty_display_preference(1);\r\n+    Array<double> defaultColor(1.0, 3); //color default to 0, 1, 1\r\n+\tdefaultColor[0] = 0.0; \r\n+\r\n+    constructProperty_color(defaultColor);\r\n+}\r\n+\r\n //_____________________________________________________________________________\r\n /**\r\n  * Perform some set up functions that happen after the\r\ndiff --git a/OpenSim/Simulation/Wrap/WrapObject.h b/OpenSim/Simulation/Wrap/WrapObject.h\nindex fcb2e8109..8e714d38f 100644\n--- a/OpenSim/Simulation/Wrap/WrapObject.h\n+++ b/OpenSim/Simulation/Wrap/WrapObject.h\n@@ -126,7 +126,15 @@ protected:\n \t// CONSTRUCTION\r\n \t//--------------------------------------------------------------------------\r\n public:\r\n-\tWrapObject();\r\n+    /** Display Preference to apply to the contact geometry.  **/\r\n+    OpenSim_DECLARE_PROPERTY(display_preference, int,\r\n+        "Display Pref. 0:Hide 1:Wire 3:Flat 4:Shaded");\r\n+\r\n+    /** Display Color to apply to the contact geometry.  **/\r\n+    OpenSim_DECLARE_LIST_PROPERTY_SIZE(color, double, 3,\r\n+        "Display Color");\r\n+\r\n+    WrapObject();\r\n \tWrapObject(const WrapObject& aWrapObject);\r\n \tvirtual ~WrapObject();\r\n \r\n@@ -165,6 +173,7 @@ protected:\n \tvoid setGeometryQuadrants(AnalyticGeometry *aGeometry) const;\r\n private:\r\n \tvoid setNull();\r\n+    void constructProperties();\r\n //=============================================================================\r\n };\t// END of class WrapObject\r\n //=============================================================================\r\n', 'commit_subject': 'Add display_preference and color properties for ContactGeometry and WrapObjects for finer granularity of visualization in GUI. Also support changing these properties in GUI. Included also in this commit updating the Java wrapping for Muscles and MuscleAnalysis.', 'repo_name': 'opensim-org/opensim-core', 'committer': {'name': 'Ayman Habib', 'email': '8ed3d36c15b09fc26f15c5d6263fa800d475ac16@stanford.edu', 'time_sec': '1341948499', 'tz_offset': '0', 'date': {'seconds': '1341948499'}}, 'commit_tree': '652881d298035c6c33b76ddd6f360d191cc10fbb', 'commit_message': 'Add display_preference and color properties for ContactGeometry and WrapObjects for finer granularity of visualization in GUI. Also support changing these properties in GUI. Included also in this commit updating the Java wrapping for Muscles and MuscleAnalysis.\n\ngit-svn-id: 9e047e1e624cce0a2485e750063112e834f85522@7339 fc29be9c-2cb0-420d-b520-73dbd18add6e\n', 'language_name': 'Python', 'license': 'apache-2.0', 'hunks': '@@ -126,7 +126,15 @@ protected:\n \t// CONSTRUCTION\r\n \t//--------------------------------------------------------------------------\r\n public:\r\n-\tWrapObject();\r\n+    /** Display Preference to apply to the contact geometry.  **/\r\n+    OpenSim_DECLARE_PROPERTY(display_preference, int,\r\n+        "Display Pref. 0:Hide 1:Wire 3:Flat 4:Shaded");\r\n+\r\n+    /** Display Color to apply to the contact geometry.  **/\r\n+    OpenSim_DECLARE_LIST_PROPERTY_SIZE(color, double, 3,\r\n+        "Display Color");\r\n+\r\n+    WrapObject();\r\n \tWrapObject(const WrapObject& aWrapObject);\r\n \tvirtual ~WrapObject();\r\n \r\n@@ -165,6 +173,7 @@ protected:\n \tvoid setGeometryQuadrants(AnalyticGeometry *aGeometry) const;\r\n private:\r\n \tvoid setNull();\r\n+    void constructProperties();\r\n //=============================================================================\r\n };\t// END of class WrapObject\r\n //=============================================================================\r\n', 'addition_count': 10, 'deletion_count': 1, 'src_file': 'a/OpenSim/Simulation/Wrap/WrapObject.h', 'tgt_file': 'b/OpenSim/Simulation/Wrap/WrapObject.h', 'file_extension': '.h', 'before_file': '#ifndef OPENSIM_WRAP_OBJECT_H_\n#define OPENSIM_WRAP_OBJECT_H_\n/* -------------------------------------------------------------------------- *\n *                           OpenSim:  WrapObject.h                           *\n * -------------------------------------------------------------------------- *\n * The OpenSim API is a toolkit for musculoskeletal modeling and simulation.  *\n * See http://opensim.stanford.edu and the NOTICE file for more information.  *\n * OpenSim is developed at Stanford University and supported by the US        *\n * National Institutes of Health (U54 GM072970, R24 HD065690) and by DARPA    *\n * through the Warrior Web program.                                           *\n *                                                                            *\n * Copyright (c) 2005-2017 Stanford University and the Authors                *\n * Author(s): Peter Loan                                                      *\n *                                                                            *\n * Licensed under the Apache License, Version 2.0 (the "License"); you may    *\n * not use this file except in compliance with the License. You may obtain a  *\n * copy of the License at http://www.apache.org/licenses/LICENSE-2.0.         *\n *                                                                            *\n * Unless required by applicable law or agreed to in writing, software        *\n * distributed under the License is distributed on an "AS IS" BASIS,          *\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   *\n * See the License for the specific language governing permissions and        *\n * limitations under the License.                                             *\n * -------------------------------------------------------------------------- */\n\n// INCLUDE\n#include <OpenSim/Simulation/Model/ModelComponent.h>\n#include <OpenSim/Simulation/Model/Appearance.h>\nnamespace OpenSim {\n\nclass PathWrap;\nclass WrapResult;\nclass Model;\nclass PhysicalFrame;\nclass AbstractPathPoint;\n\n//=============================================================================\n//=============================================================================\n/**\n * An abstract class that specifies the interface for a wrapping\n * object.\n *\n * @author Peter Loan\n * @version 1.0\n */\nclass OSIMSIMULATION_API WrapObject : public ModelComponent {\nOpenSim_DECLARE_ABSTRACT_OBJECT(WrapObject, ModelComponent);\npublic:\n//==============================================================================\n// PROPERTIES\n//==============================================================================\n    OpenSim_DECLARE_PROPERTY(active, bool,\n        "Whether or not the WrapObject is considered active in computing paths");\n\n    OpenSim_DECLARE_PROPERTY(xyz_body_rotation, SimTK::Vec3,\n        "Body-fixed Euler angle sequence for the orientation of the WrapObject");\n\n    OpenSim_DECLARE_PROPERTY(translation, SimTK::Vec3,\n        "Translation of the WrapObject.");\n\n    // Default display properties e.g. Representation, color, texture, etc.\n    OpenSim_DECLARE_UNNAMED_PROPERTY(Appearance,\n        "Default appearance for this Geometry");\n\n    OpenSim_DECLARE_PROPERTY(quadrant, std::string,\n        "The name of quadrant over which the wrap object is active. "\n        "For example, \'+x\' or \'-y\' to set the sidedness of the wrapping.");\n\n    enum WrapQuadrant\n    {\n        allQuadrants,\n        negativeX,\n        positiveX,\n        negativeY,\n        positiveY,\n        negativeZ,\n        positiveZ\n    };\n\n    enum WrapAction\n    {\n        noWrap,          // the path segment did not intersect the wrap object\n        insideRadius,    // one or both path points are inside the wrap object\n        wrapped,         // successful wrap, but may not be \'best\' path\n        mandatoryWrap    // successful wrap that must be used (e.g., both tangent\n    };                  // points are on the constrained side of the wrap object)\n\n\n\n//=============================================================================\n// METHODS\n//=============================================================================\npublic:\n    WrapObject();\n    virtual ~WrapObject();\n\n    // Use default copy and assignment operator\n\n    void extendScale(const SimTK::State& s, const ScaleSet& scaleSet) override;\n    virtual void connectToModelAndBody(Model& aModel, PhysicalFrame& aBody) {}\n\n    const PhysicalFrame& getFrame() const;\n    void setFrame(const PhysicalFrame& frame);\n\n    bool getActiveUseDefault() const { \n        return getProperty_active().getValueIsDefault();\n    }\n    bool getQuadrantNameUseDefault() const {\n        return getProperty_quadrant().getValueIsDefault();\n    }\n    const SimTK::Transform& getTransform() const { return _pose; }\n    virtual const char* getWrapTypeName() const = 0;\n\n    // TODO: total SIMM hack!\n    virtual std::string getDimensionsString() const { return ""; }\n\n//=============================================================================\n// WRAPPING\n//=============================================================================\n/**\n* Calculate the wrapping of one path segment over one wrap object.\n* @param state   The State of the model\n* @param aPoint1 The first path point\n* @param aPoint2 The second path point\n* @param aPathWrap An object holding the parameters for this path/wrap-object pairing\n\t// CONSTRUCTION\r\n\t//--------------------------------------------------------------------------\r\npublic:\r\n\tWrapObject();\r\n\tWrapObject(const WrapObject& aWrapObject);\r\n\tvirtual ~WrapObject();\r\n\r\n     * Compute the transform of the wrap geomerty w.r.t. the mobilized body \n     * it is attached to.\n     */\n    SimTK::Transform calcWrapGeometryTransformInBaseFrame() const;\n   /** Determine the appropriate values of _quadrant, _wrapAxis, and _wrapSign,\n     * based on the name of the quadrant. finalizeFromProperties() should be\n     * called whenever the quadrant property changes. */\n    void extendFinalizeFromProperties() override;\n\n    void updateFromXMLNode(SimTK::Xml::Element& node, int versionNumber)\n        override;\n\nprivate:\n    void constructProperties();\n\n    SimTK::ReferencePtr<const PhysicalFrame> _frame;\n\nprotected:\n\n    WrapQuadrant _quadrant{ WrapQuadrant::allQuadrants };\n    int _wrapAxis{ 0 };\n    int _wrapSign{ 1 };\n\n    SimTK::Transform _pose;\n//=============================================================================\n};  // END of class WrapObject\n//=============================================================================\n//=============================================================================\n\n} // end of namespace OpenSim\n\n#endif // OPENSIM_WRAP_OBJECT_H_\n\tvoid setGeometryQuadrants(AnalyticGeometry *aGeometry) const;\r\nprivate:\r\n\tvoid setNull();\r\n//=============================================================================\r\n};\t// END of class WrapObject\r\n//=============================================================================\r\n', 'message': 'Add display_preference and color properties for ContactGeometry and WrapObjects for finer granularity of visualization in GUI. Also support changing these properties in GUI. Included also in this commit updating the Java wrapping for Muscles and MuscleAnalysis.\n\ngit-svn-id: 9e047e1e624cce0a2485e750063112e834f85522@7339 fc29be9c-2cb0-420d-b520-73dbd18add6e\n', 'author_name': 'Ayman Habib', 'lang': 'h'}