Skip to content

Commit

Permalink
+ rename method 'transform' to 'tramsformGeometry' for the classes Pr…
Browse files Browse the repository at this point in the history
…opertyNormalList and PropertyCurvatureList

+ make transformGeometry method ready for undo/redo
  • Loading branch information
wwmayer committed Jan 22, 2016
1 parent 7bba2ee commit 27fbcca
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 27 deletions.
5 changes: 2 additions & 3 deletions src/Mod/Mesh/App/MeshProperties.cpp
Expand Up @@ -192,7 +192,7 @@ unsigned int PropertyNormalList::getMemSize (void) const
return static_cast<unsigned int>(_lValueList.size() * sizeof(Base::Vector3f));
}

void PropertyNormalList::transform(const Base::Matrix4D &mat)
void PropertyNormalList::transformGeometry(const Base::Matrix4D &mat)
{
// A normal vector is only a direction with unit length, so we only need to rotate it
// (no translations or scaling)
Expand Down Expand Up @@ -222,7 +222,6 @@ void PropertyNormalList::transform(const Base::Matrix4D &mat)
}

hasSetValue();

}

// ----------------------------------------------------------------------------
Expand Down Expand Up @@ -300,7 +299,7 @@ std::vector<float> PropertyCurvatureList::getCurvature( int mode ) const
return fValues;
}

void PropertyCurvatureList::transform(const Base::Matrix4D &mat)
void PropertyCurvatureList::transformGeometry(const Base::Matrix4D &mat)
{
// The principal direction is only a vector with unit length, so we only need to rotate it
// (no translations or scaling)
Expand Down
24 changes: 16 additions & 8 deletions src/Mod/Mesh/App/MeshProperties.h
Expand Up @@ -65,11 +65,11 @@ class MeshExport PropertyNormalList: public App::PropertyLists
void setValue(float x, float y, float z);

const Base::Vector3f& operator[] (const int idx) const {
return _lValueList.operator[] (idx);
return _lValueList[idx];
}

void set1Value (const int idx, const Base::Vector3f& value) {
_lValueList.operator[] (idx) = value;
_lValueList[idx] = value;
}

void setValues (const std::vector<Base::Vector3f>& values);
Expand All @@ -92,7 +92,7 @@ class MeshExport PropertyNormalList: public App::PropertyLists

virtual unsigned int getMemSize (void) const;

void transform(const Base::Matrix4D &rclMat);
void transformGeometry(const Base::Matrix4D &rclMat);

private:
std::vector<Base::Vector3f> _lValueList;
Expand Down Expand Up @@ -132,10 +132,16 @@ class MeshExport PropertyCurvatureList: public App::PropertyLists
void setValues(const std::vector<CurvatureInfo>&);

/// index operator
const CurvatureInfo& operator[] (const int idx) const {return _lValueList.operator[] (idx);}
void set1Value (const int idx, const CurvatureInfo& value){_lValueList.operator[] (idx) = value;}
const std::vector<CurvatureInfo> &getValues(void) const{return _lValueList;}
void transform(const Base::Matrix4D &rclMat);
const CurvatureInfo& operator[] (const int idx) const {
return _lValueList[idx];
}
void set1Value (const int idx, const CurvatureInfo& value) {
_lValueList[idx] = value;
}
const std::vector<CurvatureInfo> &getValues(void) const {
return _lValueList;
}
void transformGeometry(const Base::Matrix4D &rclMat);

void Save (Base::Writer &writer) const;
void Restore(Base::XMLReader &reader);
Expand Down Expand Up @@ -231,7 +237,9 @@ class MeshExport PropertyMeshKernel : public App::PropertyComplexGeoData
void setPyObject(PyObject *value);
//@}

const char* getEditorName(void) const { return "MeshGui::PropertyMeshKernelItem"; }
const char* getEditorName(void) const {
return "MeshGui::PropertyMeshKernelItem";
}

/** @name Save/restore */
//@{
Expand Down
12 changes: 10 additions & 2 deletions src/Mod/Points/App/Properties.cpp
Expand Up @@ -364,7 +364,7 @@ unsigned int PropertyNormalList::getMemSize (void) const
return static_cast<unsigned int>(_lValueList.size() * sizeof(Base::Vector3f));
}

void PropertyNormalList::transform(const Base::Matrix4D &mat)
void PropertyNormalList::transformGeometry(const Base::Matrix4D &mat)
{
// A normal vector is only a direction with unit length, so we only need to rotate it
// (no translations or scaling)
Expand All @@ -386,10 +386,14 @@ void PropertyNormalList::transform(const Base::Matrix4D &mat)
}
}

aboutToSetValue();

// Rotate the normal vectors
for (int ii=0; ii<getSize(); ii++) {
set1Value(ii, rot * operator[](ii));
}

hasSetValue();
}

void PropertyNormalList::removeIndices( const std::vector<unsigned long>& uIndices )
Expand Down Expand Up @@ -489,7 +493,7 @@ std::vector<float> PropertyCurvatureList::getCurvature( int mode ) const
return fValues;
}

void PropertyCurvatureList::transform(const Base::Matrix4D &mat)
void PropertyCurvatureList::transformGeometry(const Base::Matrix4D &mat)
{
// The principal direction is only a vector with unit length, so we only need to rotate it
// (no translations or scaling)
Expand All @@ -511,13 +515,17 @@ void PropertyCurvatureList::transform(const Base::Matrix4D &mat)
}
}

aboutToSetValue();

// Rotate the principal directions
for (int ii=0; ii<getSize(); ii++) {
CurvatureInfo ci = operator[](ii);
ci.cMaxCurvDir = rot * ci.cMaxCurvDir;
ci.cMinCurvDir = rot * ci.cMinCurvDir;
set1Value(ii, ci);
}

hasSetValue();
}

void PropertyCurvatureList::removeIndices( const std::vector<unsigned long>& uIndices )
Expand Down
44 changes: 30 additions & 14 deletions src/Mod/Points/App/Properties.h
Expand Up @@ -71,13 +71,19 @@ class PointsExport PropertyGreyValueList: public App::PropertyLists
void setValue(float);

/// index operator
float operator[] (const int idx) const {return _lValueList.operator[] (idx);}

void set1Value (const int idx, float value){_lValueList.operator[] (idx) = value;}
float operator[] (const int idx) const {
return _lValueList[idx];
}

void set1Value (const int idx, float value) {
_lValueList[idx] = value;
}
void setValues (const std::vector<float>& values);

const std::vector<float> &getValues(void) const{return _lValueList;}

const std::vector<float> &getValues(void) const {
return _lValueList;
}

virtual PyObject *getPyObject(void);
virtual void setPyObject(PyObject *);

Expand Down Expand Up @@ -115,11 +121,11 @@ class PointsExport PropertyNormalList: public App::PropertyLists
void setValue(float x, float y, float z);

const Base::Vector3f& operator[] (const int idx) const {
return _lValueList.operator[] (idx);
return _lValueList[idx];
}

void set1Value (const int idx, const Base::Vector3f& value) {
_lValueList.operator[] (idx) = value;
_lValueList[idx] = value;
}

void setValues (const std::vector<Base::Vector3f>& values);
Expand All @@ -144,7 +150,7 @@ class PointsExport PropertyNormalList: public App::PropertyLists

/** @name Modify */
//@{
void transform(const Base::Matrix4D &rclMat);
void transformGeometry(const Base::Matrix4D &rclMat);
void removeIndices( const std::vector<unsigned long>& );
//@}

Expand Down Expand Up @@ -178,16 +184,26 @@ class PointsExport PropertyCurvatureList: public App::PropertyLists
PropertyCurvatureList();
~PropertyCurvatureList();

void setSize(int newSize){_lValueList.resize(newSize);}
int getSize(void) const {return _lValueList.size();}
void setSize(int newSize) {
_lValueList.resize(newSize);
}
int getSize(void) const {
return _lValueList.size();
}
void setValue(const CurvatureInfo&);
void setValues(const std::vector<CurvatureInfo>&);
std::vector<float> getCurvature( int tMode) const;

/// index operator
const CurvatureInfo& operator[] (const int idx) const {return _lValueList.operator[] (idx);}
void set1Value (const int idx, const CurvatureInfo& value){_lValueList.operator[] (idx) = value;}
const std::vector<CurvatureInfo> &getValues(void) const{return _lValueList;}
const CurvatureInfo& operator[] (const int idx) const {
return _lValueList[idx];
}
void set1Value (const int idx, const CurvatureInfo& value) {
_lValueList[idx] = value;
}
const std::vector<CurvatureInfo> &getValues(void) const {
return _lValueList;
}

/** @name Save/restore */
//@{
Expand All @@ -209,7 +225,7 @@ class PointsExport PropertyCurvatureList: public App::PropertyLists

/** @name Modify */
//@{
void transform(const Base::Matrix4D &rclMat);
void transformGeometry(const Base::Matrix4D &rclMat);
void removeIndices( const std::vector<unsigned long>& );
//@}

Expand Down

0 comments on commit 27fbcca

Please sign in to comment.