diff --git a/apps/test/segmentation3d/main.cpp b/apps/test/segmentation3d/main.cpp index 3020fab4..d2ef98eb 100644 --- a/apps/test/segmentation3d/main.cpp +++ b/apps/test/segmentation3d/main.cpp @@ -32,10 +32,10 @@ int main( int argc, char ** argv ) #ifdef _TORUS //w.simpleGLWidget1->SetExtractionParameters(); //s->SetSegmentParameters(10,0.5f,0.2f,0.8f,0.4f,3.f,vcg::Point3f(1.f,1.f,1.f),1000,15); - s->SetSegmentParameters(10,0.5f,0.8f,0.65f,0.4f,3.f,vcg::Point3f(1.f,1.f,1.f),1000,15); + s->SetSegmentParameters(10,0.5f,0.8f,0.8f,0.2f,3.f,vcg::Point3f(1.f,1.f,1.f),1000,15); s->BBox().min=Point3f(-40.f,-40.f,-40.f); s->BBox().max=Point3f(40.f,40.f,40.f); - s->InitSegmentation(Point3f(0.f,25.f,0.f)); + s->InitSegmentation(Point3f(-25.f,0.f,0.f)); w.simpleGLWidget1->CenterExtraction=vcg::Point3f(0.f,-25.f,0.f); s->gray_init=100; #endif diff --git a/apps/test/segmentation3d/segmentator.h b/apps/test/segmentation3d/segmentator.h index 480b649b..d068bd4b 100644 --- a/apps/test/segmentation3d/segmentator.h +++ b/apps/test/segmentation3d/segmentator.h @@ -157,7 +157,11 @@ public: ScalarType ForceValue(ScalarType l0,ScalarType l1) { - return ((l0-l1)/(l0/l1) *_k); + ScalarType diff=(l0-l1); + if (diff>0)//compression + return ((diff/l1)*_k); + else + return (diff *_k); } ///update of the internal forces using the dihedral angle @@ -203,18 +207,18 @@ public: } } - ///area changing constrain penalize area goes to zero - CoordType m0=(V(0)->P()+V(1)->P())/2.f; - CoordType m1=(V(1)->P()+V(2)->P())/2.f; - CoordType m2=(V(2)->P()+V(0)->P())/2.f; - m0=(V(2)->P()-m0).Normalize();//directions - m1=(V(0)->P()-m1).Normalize(); - m2=(V(1)->P()-m2).Normalize(); - ScalarType FArea=AreaRep/Area()*_k; - V(0)->IntForce()+=m0*FArea/3.f; - V(1)->IntForce()+=m1*FArea/3.f; - V(2)->IntForce()+=m2*FArea/3.f; - ///end area constrain + ////area changing constrain penalize area goes to zero + //CoordType m0=(V(0)->P()+V(1)->P())/2.f; + //CoordType m1=(V(1)->P()+V(2)->P())/2.f; + //CoordType m2=(V(2)->P()+V(0)->P())/2.f; + //m0=(V(2)->P()-m0).Normalize();//directions + //m1=(V(0)->P()-m1).Normalize(); + //m2=(V(1)->P()-m2).Normalize(); + //ScalarType FArea=((ScalarType)1/AreaRep-Area())*_k; + //V(0)->IntForce()+=m0*FArea/3.f; + //V(1)->IntForce()+=m1*FArea/3.f; + //V(2)->IntForce()+=m2*FArea/3.f; + ////end area constrain return(__super::Update()); ///new @@ -357,18 +361,19 @@ private: return (fatt2<=conf); } + float getColor(MyTriMesh::CoordType p) { MyTriMesh::CoordType p1=MyTriMesh::CoordType(p.X(),p.Z(),p.Y()); - //MyTriMesh::CoordType p2=MyTriMesh::CoordType(p.Z(),p.Y(),p.X()); - - - if (InTorus(p)||InTorus(p1))//||InTorus(p2)) + MyTriMesh::CoordType p2=MyTriMesh::CoordType(p.Z(),p.Y(),p.X()); + + if (InTorus(p)||InTorus(p1)||InTorus(p2)) return (100.f); else return (0.f); } + #else ///return integer coordinete in volumetric dataset float getColor(MyTriMesh::CoordType p)